Skip to content

Commit e0c6e95

Browse files
committedJan 16, 2025··
fix: remove usage of aggregate-error library

File tree

10 files changed

+31
-26
lines changed

10 files changed

+31
-26
lines changed
 

‎packages/semantic-release-clean-package-json/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@
8383
"dependencies": {
8484
"@semantic-release/error": "^4.0.0",
8585
"@visulima/fs": "^2.3.7",
86-
"@visulima/path": "^1.3.3",
87-
"aggregate-error": "^5.0.0"
86+
"@visulima/path": "^1.3.3"
8887
},
8988
"devDependencies": {
9089
"@anolilab/eslint-config": "^15.0.3",

‎packages/semantic-release-clean-package-json/src/utils/get-pkg.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { FindUpOptions } from "@visulima/fs";
33
import { findUp, readJson } from "@visulima/fs";
44
import { NotFoundError } from "@visulima/fs/error";
55
import { resolve } from "@visulima/path";
6-
import AggregateError from "aggregate-error";
76
import type { PackageJson } from "type-fest";
87

98
import type { CommonContext } from "../definitions/context";
@@ -47,14 +46,18 @@ export default async (
4746
const { packageJson } = await findPackageJson(pkgRoot ? resolve(cwd, pkgRoot) : cwd);
4847

4948
if (!packageJson.name) {
50-
throw new AggregateError([getError("ENOPKGNAME")]);
49+
const semanticError = getError("ENOPKGNAME");
50+
51+
throw new AggregateError([semanticError], semanticError.message);
5152
}
5253

5354
return packageJson;
5455
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5556
} catch (error: any) {
5657
if (error.code === "ENOENT") {
57-
throw new AggregateError([getError("ENOPKG")]);
58+
const semanticError = getError("ENOPKG");
59+
60+
throw new AggregateError([semanticError], semanticError.message);
5861
}
5962

6063
throw error;

‎packages/semantic-release-pnpm/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"@visulima/fs": "^2.3.7",
6969
"@visulima/package": "^3.4.4",
7070
"@visulima/path": "^1.3.3",
71-
"aggregate-error": "^5.0.0",
7271
"execa": "^9.5.2",
7372
"ini": "^5.0.0",
7473
"normalize-url": "^8.0.1",

‎packages/semantic-release-pnpm/src/publish.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { PackageJson } from "@visulima/package";
22
import { resolve } from "@visulima/path";
3-
import AggregateError from "aggregate-error";
43
import { execa } from "execa";
54

65
import type { PublishContext } from "./definitions/context";
@@ -61,7 +60,7 @@ export default async (pluginConfig: PluginConfig, packageJson: PackageJson, cont
6160
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
6261
logger.log(`Failed to publish ${packageJson.name}@${version} to dist-tag @${distributionTag} on ${registry}: ${error.message ?? error}`);
6362

64-
throw new AggregateError([error]);
63+
throw new AggregateError([error], error.message);
6564
}
6665

6766
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions

‎packages/semantic-release-pnpm/src/utils/get-pkg.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import type { PackageJson } from "@visulima/package";
33
import { findPackageJson } from "@visulima/package";
44
import { resolve } from "@visulima/path";
5-
import AggregateError from "aggregate-error";
65

76
import type { CommonContext } from "../definitions/context";
87
import getError from "./get-error";
@@ -16,14 +15,18 @@ export default async ({ pkgRoot }: Options, { cwd }: { cwd: CommonContext["cwd"]
1615
const { packageJson } = await findPackageJson(pkgRoot ? resolve(cwd, pkgRoot) : cwd);
1716

1817
if (!packageJson.name) {
19-
throw new AggregateError([getError("ENOPKGNAME")]);
18+
const semanticError = getError("ENOPKGNAME");
19+
20+
throw new AggregateError([semanticError], semanticError.message);
2021
}
2122

2223
return packageJson;
2324
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2425
} catch (error: any) {
2526
if (error.code === "ENOENT") {
26-
throw new AggregateError([getError("ENOPKG")]);
27+
const semanticError = getError("ENOPKG");
28+
29+
throw new AggregateError([semanticError], semanticError.message);
2730
}
2831

2932
throw error;

‎packages/semantic-release-pnpm/src/utils/set-npmrc-auth.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { rc } from "@anolilab/rc";
22
import { writeFile } from "@visulima/fs";
33
import { resolve } from "@visulima/path";
4-
import AggregateError from "aggregate-error";
54
import { stringify } from "ini";
65
import type { AuthOptions } from "registry-auth-token";
76
import getAuthToken from "registry-auth-token";
@@ -43,6 +42,8 @@ export default async (
4342

4443
logger.log(`Wrote NPM_TOKEN to ${npmrc}`);
4544
} else {
46-
throw new AggregateError([getError("ENONPMTOKEN", { registry })]);
45+
const semanticError = getError("ENONPMTOKEN", { registry });
46+
47+
throw new AggregateError([semanticError], semanticError.message);
4748
}
4849
};

‎packages/semantic-release-pnpm/src/verify/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import AggregateError from "aggregate-error";
2-
31
import type { VerifyConditionsContext } from "../definitions/context";
42
import type { PluginConfig } from "../definitions/plugin-config";
53
import getNpmrcPath from "../utils/get-npmrc-path";
@@ -11,13 +9,17 @@ import verifyPnpm from "./verify-pnpm";
119

1210
const verify = async (pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void> => {
1311
let errors: Error[] = verifyConfig(pluginConfig);
12+
let errorsMessage = "";
1413

1514
try {
1615
await verifyPnpm(context);
1716
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1817
} catch (error: any) {
1918
const typedError = error as AggregateError;
2019

20+
errorsMessage += typedError.message;
21+
22+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
2123
errors = [...errors, ...(typedError.errors ?? [error])];
2224
}
2325

@@ -33,11 +35,14 @@ const verify = async (pluginConfig: PluginConfig, context: VerifyConditionsConte
3335
} catch (error: any) {
3436
const typedError = error as AggregateError;
3537

38+
errorsMessage += typedError.message;
39+
40+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
3641
errors = [...errors, ...(typedError.errors ?? [error])];
3742
}
3843

3944
if (errors.length > 0) {
40-
throw new AggregateError(errors);
45+
throw new AggregateError(errors, errorsMessage);
4146
}
4247
};
4348

‎packages/semantic-release-pnpm/src/verify/verify-auth.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { PackageJson } from "@visulima/package";
2-
import AggregateError from "aggregate-error";
32
import { execa } from "execa";
43
import normalizeUrl from "normalize-url";
54

@@ -35,7 +34,9 @@ export default async (npmrc: string, package_: PackageJson, context: CommonConte
3534

3635
await whoamiResult;
3736
} catch {
38-
throw new AggregateError([getError("EINVALIDNPMTOKEN", { registry })]);
37+
const semanticError = getError("EINVALIDNPMTOKEN", { registry });
38+
39+
throw new AggregateError([semanticError], semanticError.message);
3940
}
4041
} else {
4142
logger.log(`Skipping authentication verification for non-default registry "${registry}"`);

‎packages/semantic-release-pnpm/src/verify/verify-pnpm.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getPackageManagerVersion } from "@visulima/package";
2-
import AggregateError from "aggregate-error";
32
import { gte } from "semver";
43

54
import type { CommonContext } from "../definitions/context";
@@ -13,6 +12,8 @@ export default async function verifyPnpm({ logger }: CommonContext): Promise<voi
1312
const version = getPackageManagerVersion("pnpm");
1413

1514
if (gte(MIN_PNPM_VERSION, version)) {
16-
throw new AggregateError([getError("EINVALIDPNPM", { version: String(version) })]);
15+
const semanticError = getError("EINVALIDPNPM", { version: String(version) });
16+
17+
throw new AggregateError([semanticError], semanticError.message);
1718
}
1819
}

‎pnpm-lock.yaml

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.