@anolilab/semantic-release-pnpm 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ ## [1.0.0-alpha.2](https://github.com/anolilab/semantic-release-pnpm/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2024-05-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use no-git-checks for publish ([7b9762f](https://github.com/anolilab/semantic-release-pnpm/commit/7b9762f93adbc412e08bd84f6b7738c1e07fd4eb))
7
+
8
+ ## 1.0.0-alpha.1 (2024-05-16)
9
+
10
+
11
+ ### Features
12
+
13
+ * first version of semantic-release-pnpm ([ae2a519](https://github.com/anolilab/semantic-release-pnpm/commit/ae2a5191e61444d22178a082f91fa8271e6a8683))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * better error handling ([ff5c3b9](https://github.com/anolilab/semantic-release-pnpm/commit/ff5c3b93443b9cc5ea4f021d6471a48099f830c6))
19
+ * better error handling ([faa8047](https://github.com/anolilab/semantic-release-pnpm/commit/faa8047a454eda31eef63b97e6e2714852ad6476))
20
+ * better get-registry ([3097ab0](https://github.com/anolilab/semantic-release-pnpm/commit/3097ab09a5ae5642562d7d781c5797ed2be9947f))
21
+ * debug ([c9f52fb](https://github.com/anolilab/semantic-release-pnpm/commit/c9f52fbd474930614bf18198fe2458cd370d0a7a))
22
+ * debug ([9fd60c3](https://github.com/anolilab/semantic-release-pnpm/commit/9fd60c32d6251672f6b4f0fb9962aaa32aa37131))
23
+ * fixed audit issue ([06e6154](https://github.com/anolilab/semantic-release-pnpm/commit/06e61542762c41de7f6022f93c0167919615604c))
24
+ * fixed error ([0e14896](https://github.com/anolilab/semantic-release-pnpm/commit/0e148962d8e463b0ccdb24d722ec1393c4adfb5d))
25
+ * fixed pnpm version check ([0d3c084](https://github.com/anolilab/semantic-release-pnpm/commit/0d3c084ee9003f66c8ae7b06cd5d9fe8748e8fe1))
26
+ * moved some deps ([204a5c1](https://github.com/anolilab/semantic-release-pnpm/commit/204a5c158404442d08e3e47d37c9c13d5c91019b))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Anolilab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # semantic-release-pnpm
2
+
3
+ Semantic-release plugin to publish a npm package with pnpm
@@ -0,0 +1,79 @@
1
+ import stream from 'node:stream';
2
+ import { Commit, Options } from 'semantic-release';
3
+
4
+ interface CommonContext {
5
+ branch: BranchSpec;
6
+ branches: BranchSpec[];
7
+ cwd: string;
8
+ env: typeof process.env;
9
+ logger: {
10
+ error: (...message: string[]) => void;
11
+ log: (...message: string[]) => void;
12
+ success: (...message: string[]) => void;
13
+ };
14
+ options: Options;
15
+ stderr: stream.Writable;
16
+ stdout: stream.Writable;
17
+ }
18
+ type VerifyConditionsContext = CommonContext;
19
+ type CommonContext2 = CommonContext & {
20
+ releases: Release[];
21
+ };
22
+ type AddChannelContext = CommonContext2 & {
23
+ commits: Commit[];
24
+ lastRelease: Release;
25
+ currentRelease: Release;
26
+ nextRelease: Release;
27
+ };
28
+ type CommonContext3 = CommonContext2 & {
29
+ lastRelease: Release;
30
+ commits: Commit[];
31
+ };
32
+ type CommonContext4 = CommonContext3 & {
33
+ nextRelease: Release;
34
+ commits: Commit[];
35
+ };
36
+ type PrepareContext = CommonContext4;
37
+ type PublishContext = CommonContext4;
38
+ interface BranchSpec {
39
+ name: string;
40
+ tags?: Tag[];
41
+ }
42
+ interface Tag {
43
+ channel?: string;
44
+ gitHead?: string;
45
+ gitTag?: string;
46
+ version?: string;
47
+ }
48
+ interface Release {
49
+ channel?: string | null;
50
+ gitHead?: string;
51
+ gitTag?: string;
52
+ name?: string;
53
+ type?: "build" | "major" | "minor" | "patch" | "premajor" | "preminor" | "prepatch" | "prerelease" | undefined;
54
+ version: string;
55
+ }
56
+
57
+ interface ReleaseInfo {
58
+ channel: string;
59
+ name: string;
60
+ url?: string;
61
+ }
62
+
63
+ interface PluginConfig {
64
+ branches?: (string | {
65
+ name: string;
66
+ prerelease: boolean;
67
+ })[];
68
+ npmPublish?: boolean;
69
+ pkgRoot?: string;
70
+ publishBranch?: string;
71
+ tarballDir?: string;
72
+ }
73
+
74
+ declare function verifyConditions(pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void>;
75
+ declare function prepare(pluginConfig: PluginConfig, context: PrepareContext): Promise<void>;
76
+ declare function publish(pluginConfig: PluginConfig, context: PublishContext): Promise<false | ReleaseInfo>;
77
+ declare function addChannel(pluginConfig: PluginConfig, context: AddChannelContext): Promise<boolean | ReleaseInfo>;
78
+
79
+ export { addChannel, prepare, publish, verifyConditions };
package/dist/index.js ADDED
@@ -0,0 +1,602 @@
1
+ import { execa } from 'execa';
2
+ import { validRange, gte } from 'semver';
3
+ import { isAccessibleSync, ensureFile, readFile, writeFile } from '@visulima/fs';
4
+ import { findPackageJson, findCacheDirectorySync, getPackageManagerVersion } from '@visulima/package';
5
+ import { resolve } from '@visulima/path';
6
+ import SemanticReleaseError from '@semantic-release/error';
7
+ import rc from 'rc';
8
+ import normalizeUrl from 'normalize-url';
9
+ import { moveFile } from 'move-file';
10
+ import AggregateError5 from 'aggregate-error';
11
+ import getAuthToken from 'registry-auth-token';
12
+ import { URL } from 'url';
13
+
14
+ // src/add-channel.ts
15
+ var get_channel_default = (channel) => channel ? validRange(channel) ? `release-${channel}` : channel : "latest";
16
+
17
+ // package.json
18
+ var package_default = {
19
+ name: "@anolilab/semantic-release-pnpm",
20
+ version: "1.0.0-alpha.1",
21
+ description: "Semantic-release plugin to publish a npm package with pnpm.",
22
+ keywords: [
23
+ "anolilab",
24
+ "npm",
25
+ "publish",
26
+ "semantic-release",
27
+ "pnpm",
28
+ "monorepo"
29
+ ],
30
+ homepage: "https://github.com/anolilab/semantic-release-pnpm",
31
+ repository: {
32
+ type: "git",
33
+ url: "https://github.com/anolilab/semantic-release-pnpm.git"
34
+ },
35
+ license: "MIT",
36
+ author: {
37
+ name: "Daniel Bannert",
38
+ email: "d.bannert@anolilab.de"
39
+ },
40
+ type: "module",
41
+ exports: "./dist/index.js",
42
+ main: "dist/index.js",
43
+ types: "dist/index.d.ts",
44
+ files: [
45
+ "dist",
46
+ "README.md",
47
+ "CHANGELOG.md"
48
+ ],
49
+ scripts: {
50
+ build: "cross-env NODE_ENV=development tsup",
51
+ "build:prod": "cross-env NODE_ENV=production tsup",
52
+ "lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
53
+ "lint:eslint:fix": "pnpm run lint:eslint --fix",
54
+ "lint:fix": "pnpm run lint:prettier:fix && pnpm run lint:eslint:fix",
55
+ "lint:packagejson": "publint --strict",
56
+ "lint:prettier": "prettier --config=.prettierrc.cjs --check .",
57
+ "lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
58
+ "lint:secrets": "secretlint **/*",
59
+ "lint:staged": "lint-staged --verbose --concurrent false --debug",
60
+ "lint:text": "textlint ./.github/ ./README.md ./UPGRADE.md --parallel --experimental --cache --dry-run",
61
+ "lint:text:fix": "textlint ./.github/ ./README.md ./UPGRADE.md --parallel --experimental --fix",
62
+ "lint:types": "tsc --noEmit",
63
+ prepare: "is-ci || (node verify-node-version.cjs && pnpx only-allow pnpm && husky install)",
64
+ "sort-package-json": "sort-package-json ./package.json",
65
+ test: "vitest run",
66
+ "test:bench": "vitest bench",
67
+ "test:coverage": "vitest run --coverage",
68
+ "test:watch": "vitest",
69
+ "update:deps": "taze"
70
+ },
71
+ dependencies: {
72
+ "@visulima/package": "1.8.1",
73
+ "@visulima/fs": "^2.1.1",
74
+ "@visulima/path": "^1.0.0",
75
+ "@semantic-release/error": "^4.0.0",
76
+ "aggregate-error": "^5.0.0",
77
+ execa: "^9.1.0",
78
+ "move-file": "^3.1.0",
79
+ "normalize-url": "^8.0.1",
80
+ rc: "^1.2.8",
81
+ "registry-auth-token": "^5.0.2",
82
+ semver: "^7.6.2"
83
+ },
84
+ devDependencies: {
85
+ "@anolilab/commitlint-config": "^5.0.3",
86
+ "@anolilab/eslint-config": "^15.0.3",
87
+ "@anolilab/lint-staged-config": "^2.1.7",
88
+ "@anolilab/prettier-config": "^5.0.14",
89
+ "@anolilab/textlint-config": "^8.0.16",
90
+ "@babel/core": "^7.24.5",
91
+ "@babel/eslint-parser": "7.24.5",
92
+ "@commitlint/cli": "^19.3.0",
93
+ "@commitlint/config-conventional": "^19.2.2",
94
+ "@secretlint/secretlint-rule-preset-recommend": "^8.2.4",
95
+ "@semantic-release/changelog": "^6.0.3",
96
+ "@semantic-release/git": "^10.0.1",
97
+ "@semantic-release/github": "^10.0.3",
98
+ "@types/dockerode": "^3.3.29",
99
+ "@types/node": "^20.12.12",
100
+ "@types/rc": "^1.2.4",
101
+ "@types/semantic-release__error": "3.0.3",
102
+ "@types/semver": "7.5.8",
103
+ "@vitest/coverage-v8": "^1.6.0",
104
+ commitizen: "^4.3.0",
105
+ commitlint: "^19.3.0",
106
+ "cross-env": "^7.0.3",
107
+ "cz-conventional-changelog": "^3.3.0",
108
+ dockerode: "4.0.2",
109
+ eslint: "8.55.0",
110
+ "eslint-plugin-deprecation": "^2.0.0",
111
+ "eslint-plugin-editorconfig": "^4.0.3",
112
+ "eslint-plugin-import": "npm:eslint-plugin-i@2.29.1",
113
+ "eslint-plugin-mdx": "^3.1.5",
114
+ "eslint-plugin-n": "^17.7.0",
115
+ "eslint-plugin-vitest": "^0.4.1",
116
+ "eslint-plugin-vitest-globals": "^1.5.0",
117
+ "eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
118
+ "get-stream": "9.0.1",
119
+ husky: "^9.0.11",
120
+ "is-ci": "^3.0.1",
121
+ "lint-staged": "^15.2.2",
122
+ prettier: "^3.2.5",
123
+ publint: "^0.2.7",
124
+ rimraf: "^5.0.7",
125
+ secretlint: "8.2.4",
126
+ "semantic-release": "^23.1.1",
127
+ "sort-package-json": "^2.10.0",
128
+ taze: "^0.13.8",
129
+ tempy: "^3.1.0",
130
+ textlint: "^14.0.4",
131
+ tsup: "^8.0.2",
132
+ typescript: "^5.4.5",
133
+ vitest: "^1.6.0"
134
+ },
135
+ peerDependencies: {
136
+ "semantic-release": "^20.0 || ^21.0 || >=22.0.3"
137
+ },
138
+ packageManager: "pnpm@9.1.1",
139
+ engines: {
140
+ node: ">=18 || >=20.6.1"
141
+ },
142
+ publishConfig: {
143
+ access: "public",
144
+ provenance: true
145
+ },
146
+ anolilab: {
147
+ "eslint-config": {
148
+ plugin: {},
149
+ warn_on_unsupported_typescript_version: false,
150
+ info_on_disabling_jsx_react_rule: false,
151
+ info_on_disabling_prettier_conflict_rule: false,
152
+ info_on_disabling_jsonc_sort_keys_rule: false,
153
+ import_ignore_exports: [
154
+ "**/*.cjs",
155
+ "verify-node-version.cjs"
156
+ ]
157
+ }
158
+ },
159
+ pnpm: {
160
+ overrides: {
161
+ "chrono-node@<2.2.4": ">=2.2.4"
162
+ }
163
+ }
164
+ };
165
+
166
+ // src/definitions/errors.ts
167
+ var linkify = (file) => `${package_default.homepage}/blob/main/${file}`;
168
+ var errors = {
169
+ EINVALIDNPMPUBLISH: ({ npmPublish }) => {
170
+ return {
171
+ details: `The [npmPublish option](${linkify("README.md#npmpublish")}) option, if defined, must be a \`Boolean\`.
172
+ Your configuration for the \`npmPublish\` option is \`${npmPublish}\`.`,
173
+ message: "Invalid `npmPublish` option."
174
+ };
175
+ },
176
+ EINVALIDNPMTOKEN: ({ registry }) => {
177
+ return {
178
+ details: `The [npm token](${linkify(
179
+ "README.md#npm-registry-authentication"
180
+ )}) configured in the \`NPM_TOKEN\` environment variable must be a valid [token](https://docs.npmjs.com/getting-started/working_with_tokens) allowing to publish to the registry \`${registry}\`.
181
+ If you are using Two Factor Authentication for your account, set its level to ["Authorization only"](https://docs.npmjs.com/getting-started/using-two-factor-authentication#levels-of-authentication) in your account settings. **semantic-release** cannot publish with the default "Authorization and writes" level.
182
+ Please make sure to set the \`NPM_TOKEN\` environment variable in your CI with the exact value of the npm token.`,
183
+ message: "Invalid npm token."
184
+ };
185
+ },
186
+ EINVALIDPKGROOT: ({ pkgRoot }) => {
187
+ return {
188
+ details: `The [pkgRoot option](${linkify("README.md#pkgroot")}) option, if defined, must be a \`String\`.
189
+ Your configuration for the \`pkgRoot\` option is \`${pkgRoot}\`.`,
190
+ message: "Invalid `pkgRoot` option."
191
+ };
192
+ },
193
+ EINVALIDPNPM: ({ version }) => {
194
+ return {
195
+ details: `The version of Pnpm that you are using is not compatible. Please refer to [the README](${linkify(
196
+ "README.md#install"
197
+ )}) to review which versions of Pnpm are currently supported
198
+
199
+ Your version of Pnpm is "${version}".`,
200
+ message: "Incompatible Pnpm version detected."
201
+ };
202
+ },
203
+ EINVALIDPUBLISHBRANCH: ({ publishBranch }) => {
204
+ return {
205
+ details: `The [publishBranch option](${linkify("README.md#publishBranch")}) option, if defined, must be a \`String\`.
206
+ Your configuration for the \`publishBranch\` option is \`${publishBranch}\`.`,
207
+ message: "Invalid `publishBranch` option."
208
+ };
209
+ },
210
+ EINVALIDTARBALLDIR: ({ tarballDir }) => {
211
+ return {
212
+ details: `The [tarballDir option](${linkify("README.md#tarballdir")}) option, if defined, must be a \`String\`.
213
+ Your configuration for the \`tarballDir\` option is \`${tarballDir}\`.`,
214
+ message: "Invalid `tarballDir` option."
215
+ };
216
+ },
217
+ ENONPMTOKEN: ({ registry }) => {
218
+ return {
219
+ details: `An [npm token](${linkify(
220
+ "README.md#npm-registry-authentication"
221
+ )}) must be created and set in the \`NPM_TOKEN\` environment variable on your CI environment.
222
+ Please make sure to create an [npm token](https://docs.npmjs.com/getting-started/working_with_tokens#how-to-create-new-tokens) and to set it in the \`NPM_TOKEN\` environment variable on your CI environment. The token must allow to publish to the registry \`${registry}\`.`,
223
+ message: "No npm token specified."
224
+ };
225
+ },
226
+ ENOPKG: () => {
227
+ return {
228
+ details: `A [package.json file](https://docs.npmjs.com/files/package.json) at the root of your project is required to release on npm.
229
+ Please follow the [npm guideline](https://docs.npmjs.com/getting-started/creating-node-modules) to create a valid \`package.json\` file.`,
230
+ message: "Missing `package.json` file."
231
+ };
232
+ },
233
+ ENOPKGNAME: () => {
234
+ return {
235
+ details: `The \`package.json\`'s [name](https://docs.npmjs.com/files/package.json#name) property is required in order to publish a package to the npm registry.
236
+ Please make sure to add a valid \`name\` for your package in your \`package.json\`.`,
237
+ message: "Missing `name` property in `package.json`."
238
+ };
239
+ },
240
+ ENOPNPM: () => {
241
+ return {
242
+ details: `The Pnpm CLI could not be found in your PATH. Make sure Pnpm is installed and try again.`,
243
+ message: "Pnpm not found."
244
+ };
245
+ },
246
+ ENOPNPMRC: () => {
247
+ return {
248
+ details: `Didnt find a \`.npmrc\` file or it was not possible to create , in the root of your project.`,
249
+ message: "Missing `.npmrc` file."
250
+ };
251
+ },
252
+ EINVALIDBRANCHES: (branches) => {
253
+ return {
254
+ details: `The [branches option](${linkify("README.md#branches")}) option, if defined, must be an array of \`String\`.
255
+ Your configuration for the \`branches\` option is \`${branches}\`.`,
256
+ message: "Invalid `branches` option."
257
+ };
258
+ }
259
+ };
260
+
261
+ // src/utils/get-error.ts
262
+ var get_error_default = (code, context = {}) => {
263
+ const { details, message } = errors[code](context);
264
+ return new SemanticReleaseError(message, code, details);
265
+ };
266
+
267
+ // src/utils/get-npmrc.ts
268
+ var getNpmrc = (cwd, environment) => {
269
+ let npmrc = environment.NPM_CONFIG_USERCONFIG;
270
+ const npmrcPath = resolve(cwd, ".npmrc");
271
+ if (!npmrc && isAccessibleSync(npmrcPath)) {
272
+ npmrc = npmrcPath;
273
+ } else if (!npmrc) {
274
+ const temporaryNpmrcPath = findCacheDirectorySync("semantic-release-pnpm", { create: true, cwd });
275
+ if (temporaryNpmrcPath) {
276
+ ensureFile(temporaryNpmrcPath);
277
+ npmrc = temporaryNpmrcPath;
278
+ }
279
+ }
280
+ if (!npmrc) {
281
+ throw new AggregateError([
282
+ get_error_default("ENOPNPMRC", {
283
+ npmrc: npmrcPath
284
+ })
285
+ ]);
286
+ }
287
+ return npmrc;
288
+ };
289
+ var get_npmrc_default = getNpmrc;
290
+
291
+ // src/definitions/constants.ts
292
+ var DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org/";
293
+
294
+ // src/utils/get-registry.ts
295
+ var getRegistryUrl = (scope, npmrc) => {
296
+ let url = DEFAULT_NPM_REGISTRY;
297
+ if (npmrc) {
298
+ const registryUrl = npmrc[`${scope}:registry`] ?? npmrc["registry"];
299
+ if (registryUrl) {
300
+ url = registryUrl;
301
+ }
302
+ }
303
+ return url.slice(-1) === "/" ? url : `${url}/`;
304
+ };
305
+ var get_registry_default = ({ name, publishConfig: { registry } = {} }, { cwd, env }) => registry ?? env.NPM_CONFIG_REGISTRY ?? getRegistryUrl(
306
+ name.split("/")[0],
307
+ rc("npm", { registry: "https://registry.npmjs.org/" }, { config: env.NPM_CONFIG_USERCONFIG ?? resolve(cwd, ".npmrc") })
308
+ );
309
+ var getReleaseInfo = ({ name }, { env: { DEFAULT_NPM_REGISTRY: DEFAULT_NPM_REGISTRY2 = "https://registry.npmjs.org/" }, nextRelease: { version } }, distributionTag, registry) => {
310
+ return {
311
+ channel: distributionTag,
312
+ name: `pnpm package (@${distributionTag} dist-tag)`,
313
+ url: normalizeUrl(registry) === normalizeUrl(DEFAULT_NPM_REGISTRY2) ? `https://www.npmjs.com/package/${name}/v/${version}` : void 0
314
+ };
315
+ };
316
+
317
+ // src/utils/should-publish.ts
318
+ function shouldPublish(pluginConfig, package_) {
319
+ return reasonToNotPublish(pluginConfig, package_) === null;
320
+ }
321
+ function reasonToNotPublish(pluginConfig, package_) {
322
+ return pluginConfig.npmPublish === false ? "npmPublish plugin option is false" : package_.private === true && package_.workspaces === void 0 ? "package is private and has no workspaces" : null;
323
+ }
324
+
325
+ // src/add-channel.ts
326
+ var add_channel_default = async (pluginConfig, package_, context) => {
327
+ const {
328
+ cwd,
329
+ env,
330
+ logger,
331
+ nextRelease: { channel, version },
332
+ stderr,
333
+ stdout
334
+ } = context;
335
+ if (shouldPublish(pluginConfig, package_)) {
336
+ const registry = get_registry_default(package_, context);
337
+ const distributionTag = get_channel_default(channel);
338
+ logger.log(`Adding version ${version} to npm registry on dist-tag ${distributionTag}`);
339
+ const npmrc = get_npmrc_default(cwd, env);
340
+ const result = execa("pnpm", ["dist-tag", "add", `${package_.name}@${version}`, distributionTag, "--userconfig", npmrc, "--registry", registry], {
341
+ cwd,
342
+ env,
343
+ preferLocal: true
344
+ });
345
+ result.stdout.pipe(stdout, { end: false });
346
+ result.stderr.pipe(stderr, { end: false });
347
+ await result;
348
+ logger.log(`Added ${package_.name}@${version} to dist-tag @${distributionTag} on ${registry}`);
349
+ return getReleaseInfo(package_, context, distributionTag, registry);
350
+ }
351
+ logger.log(`Skip adding to npm channel as ${reasonToNotPublish(pluginConfig, package_)}`);
352
+ return false;
353
+ };
354
+ var prepare_default = async ({ pkgRoot, tarballDir }, { cwd, env, logger, nextRelease: { version }, stderr, stdout }) => {
355
+ const basePath = pkgRoot ? resolve(cwd, pkgRoot) : cwd;
356
+ logger.log("Write version %s to package.json in %s", version, basePath);
357
+ const versionResult = execa("pnpm", ["version", version, "--no-git-tag-version", "--allow-same-version"], {
358
+ cwd: basePath,
359
+ env,
360
+ preferLocal: true
361
+ });
362
+ versionResult.stdout.pipe(stdout, { end: false });
363
+ versionResult.stderr.pipe(stderr, { end: false });
364
+ await versionResult;
365
+ if (tarballDir) {
366
+ logger.log("Creating npm package version %s", version);
367
+ const packResult = execa("pnpm", ["pack", basePath], { cwd, env, preferLocal: true });
368
+ packResult.stdout.pipe(stdout, { end: false });
369
+ packResult.stderr.pipe(stderr, { end: false });
370
+ const tarball = (await packResult).stdout.split("\n").pop();
371
+ const tarballSource = resolve(cwd, tarball);
372
+ const tarballDestination = resolve(cwd, tarballDir.trim(), tarball);
373
+ if (tarballSource !== tarballDestination) {
374
+ await moveFile(tarballSource, tarballDestination);
375
+ }
376
+ }
377
+ };
378
+ var publish_default = async (pluginConfig, package_, context) => {
379
+ const {
380
+ cwd,
381
+ env,
382
+ logger,
383
+ nextRelease: { channel, version },
384
+ stderr,
385
+ stdout
386
+ } = context;
387
+ const { pkgRoot, publishBranch: publishBranchConfig } = pluginConfig;
388
+ if (shouldPublish(pluginConfig, package_)) {
389
+ const basePath = pkgRoot ? resolve(cwd, pkgRoot) : cwd;
390
+ const registry = get_registry_default(package_, context);
391
+ const distributionTag = get_channel_default(channel);
392
+ const { stdout: currentBranch } = await execa("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
393
+ cwd,
394
+ env,
395
+ preferLocal: true
396
+ });
397
+ const publishBranches = typeof publishBranchConfig === "string" && publishBranchConfig.split("|");
398
+ const isPublishBranch = publishBranches && publishBranches?.includes(currentBranch);
399
+ const publishBranch = isPublishBranch ? currentBranch : "main";
400
+ logger.log(`Publishing version ${version} on branch ${publishBranch} to npm registry on dist-tag ${distributionTag}`);
401
+ const result = execa("pnpm", ["publish", basePath, "--publish-branch", publishBranch, "--tag", distributionTag, "--registry", registry, "--no-git-checks"], {
402
+ cwd,
403
+ env,
404
+ preferLocal: true
405
+ });
406
+ result.stdout.pipe(stdout, { end: false });
407
+ result.stderr.pipe(stderr, { end: false });
408
+ try {
409
+ await result;
410
+ } catch (error) {
411
+ logger.log(`Failed to publish ${package_.name}@${version} to dist-tag @${distributionTag} on ${registry}: ${error.message || error}`);
412
+ throw new AggregateError5([error]);
413
+ }
414
+ logger.log(`Published ${package_.name}@${version} to dist-tag @${distributionTag} on ${registry}`);
415
+ return getReleaseInfo(package_, context, distributionTag, registry);
416
+ }
417
+ logger.log(`Skip publishing to npm registry as ${reasonToNotPublish(pluginConfig, package_)}`);
418
+ return false;
419
+ };
420
+ var get_pkg_default = async ({ pkgRoot }, { cwd }) => {
421
+ try {
422
+ const { packageJson } = await findPackageJson(pkgRoot ? resolve(cwd, pkgRoot) : cwd);
423
+ if (!packageJson.name) {
424
+ throw get_error_default("ENOPKGNAME");
425
+ }
426
+ return packageJson;
427
+ } catch (error) {
428
+ if (error.code === "ENOENT") {
429
+ throw get_error_default("ENOPKG");
430
+ }
431
+ throw error;
432
+ }
433
+ };
434
+ var nerfDart = (url) => {
435
+ const parsed = new URL(url);
436
+ const from = `${parsed.protocol}//${parsed.host}${parsed.pathname}`;
437
+ const rel = new URL(".", from);
438
+ return `//${rel.host}${rel.pathname}`;
439
+ };
440
+ var nerf_dart_default = nerfDart;
441
+
442
+ // src/utils/set-npmrc-auth.ts
443
+ var set_npmrc_auth_default = async (npmrc, registry, { cwd, env: { NPM_CONFIG_USERCONFIG, NPM_EMAIL, NPM_PASSWORD, NPM_TOKEN, NPM_USERNAME }, logger }) => {
444
+ logger.log("Verify authentication for registry %s", registry);
445
+ const { configs, ...rcConfig } = rc("npm", { registry: DEFAULT_NPM_REGISTRY }, { config: NPM_CONFIG_USERCONFIG ?? resolve(cwd, ".npmrc") });
446
+ if (configs) {
447
+ logger.log("Reading npm config from %s", configs.join(", "));
448
+ }
449
+ const currentConfig = configs ? (await Promise.all(configs.map((config) => readFile(config)))).join("\n") : "";
450
+ if (getAuthToken(registry, { npmrc: rcConfig })) {
451
+ await writeFile(npmrc, currentConfig);
452
+ return;
453
+ }
454
+ if (NPM_USERNAME && NPM_PASSWORD && NPM_EMAIL) {
455
+ await writeFile(npmrc, `${currentConfig ? `${currentConfig}
456
+ ` : ""}_auth = \${LEGACY_TOKEN}
457
+ email = \${NPM_EMAIL}`);
458
+ logger.log(`Wrote NPM_USERNAME, NPM_PASSWORD, and NPM_EMAIL to ${npmrc}`);
459
+ } else if (NPM_TOKEN) {
460
+ await writeFile(npmrc, `${currentConfig ? `${currentConfig}
461
+ ` : ""}${nerf_dart_default(registry)}:_authToken = \${NPM_TOKEN}`);
462
+ logger.log(`Wrote NPM_TOKEN to ${npmrc}`);
463
+ } else {
464
+ throw new AggregateError5([get_error_default("ENONPMTOKEN", { registry })]);
465
+ }
466
+ };
467
+
468
+ // src/verify/verify-auth.ts
469
+ var verify_auth_default = async (npmrc, package_, context) => {
470
+ const {
471
+ cwd,
472
+ env: { DEFAULT_NPM_REGISTRY: DEFAULT_NPM_REGISTRY2 = "https://registry.npmjs.org/", ...environment },
473
+ logger,
474
+ stderr,
475
+ stdout
476
+ } = context;
477
+ const registry = get_registry_default(package_, context);
478
+ await set_npmrc_auth_default(npmrc, registry, context);
479
+ if (normalizeUrl(registry) === normalizeUrl(DEFAULT_NPM_REGISTRY2)) {
480
+ try {
481
+ logger.log(`Running "pnpm whoami" to verify authentication on registry "${registry}"`);
482
+ const whoamiResult = execa("pnpm", ["whoami", "--userconfig", npmrc, "--registry", registry], {
483
+ cwd,
484
+ env: environment,
485
+ preferLocal: true
486
+ });
487
+ whoamiResult.stdout.pipe(stdout, { end: false });
488
+ whoamiResult.stderr.pipe(stderr, { end: false });
489
+ await whoamiResult;
490
+ } catch {
491
+ throw new AggregateError5([get_error_default("EINVALIDNPMTOKEN", { registry })]);
492
+ }
493
+ } else {
494
+ logger.log(`Skipping authentication verification for non-default registry "${registry}"`);
495
+ }
496
+ };
497
+
498
+ // src/verify/verify-config.ts
499
+ var isString = (value) => typeof value === "string";
500
+ var isNil = (value) => value === null || value === void 0;
501
+ var isNonEmptyString = (value) => isString(value) && value.trim();
502
+ var VALIDATORS = {
503
+ branches: Array.isArray,
504
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
505
+ npmPublish: (value) => typeof value === "boolean",
506
+ pkgRoot: isNonEmptyString,
507
+ publishBranch: isNonEmptyString,
508
+ tarballDir: isNonEmptyString
509
+ };
510
+ var verify_config_default = (config) => (
511
+ // eslint-disable-next-line unicorn/no-array-reduce
512
+ Object.entries(config).reduce((errors2, [option, value]) => {
513
+ if (isNil(value)) {
514
+ return errors2;
515
+ }
516
+ if (!(option in VALIDATORS)) {
517
+ return errors2;
518
+ }
519
+ if (VALIDATORS[option]?.(value)) {
520
+ return errors2;
521
+ }
522
+ return [...errors2, get_error_default(`EINVALID${option.toUpperCase()}`, { [option]: value })];
523
+ }, [])
524
+ );
525
+ var MIN_PNPM_VERSION = "8.0.0";
526
+ async function verifyPnpm({ logger }) {
527
+ logger.log(`Verify pnpm version is >= ${MIN_PNPM_VERSION}`);
528
+ const version = await getPackageManagerVersion("pnpm");
529
+ if (version === void 0) {
530
+ throw new AggregateError5([new Error("pnpm is not installed")]);
531
+ }
532
+ if (gte(MIN_PNPM_VERSION, version)) {
533
+ throw new AggregateError5([get_error_default("EINVALIDPNPM", { version: String(version) })]);
534
+ }
535
+ }
536
+
537
+ // src/verify/index.ts
538
+ var verify = async (pluginConfig, context) => {
539
+ let errors2 = verify_config_default(pluginConfig);
540
+ try {
541
+ verifyPnpm(context);
542
+ } catch (error) {
543
+ errors2 = [...errors2, ...error.errors ? error.errors : [error]];
544
+ }
545
+ try {
546
+ const packageJson = await get_pkg_default(pluginConfig, context);
547
+ if (shouldPublish(pluginConfig, packageJson)) {
548
+ const npmrc = get_npmrc_default(context.cwd, context.env);
549
+ await verify_auth_default(npmrc, packageJson, context);
550
+ }
551
+ } catch (error) {
552
+ errors2 = [...errors2, ...error.errors ? error.errors : [error]];
553
+ }
554
+ if (errors2.length > 0) {
555
+ throw new AggregateError5(errors2);
556
+ }
557
+ };
558
+ var verify_default = verify;
559
+
560
+ // src/index.ts
561
+ var PLUGIN_NAME = "semantic-release-pnpm";
562
+ var verified;
563
+ var prepared;
564
+ async function verifyConditions(pluginConfig, context) {
565
+ if (context.options?.["publish"]) {
566
+ const publish2 = Array.isArray(context.options?.["publish"]) ? context.options?.["publish"] : [context.options?.["publish"]];
567
+ const publishPlugin = publish2.find((config) => config.path && config.path === PLUGIN_NAME) || {};
568
+ pluginConfig.npmPublish = pluginConfig.npmPublish ?? publishPlugin.npmPublish;
569
+ pluginConfig.tarballDir = pluginConfig.tarballDir ?? publishPlugin.tarballDir;
570
+ pluginConfig.pkgRoot = pluginConfig.pkgRoot ?? publishPlugin.pkgRoot;
571
+ }
572
+ await verify_default(pluginConfig, context);
573
+ verified = true;
574
+ }
575
+ async function prepare(pluginConfig, context) {
576
+ if (!verified) {
577
+ await verify_default(pluginConfig, context);
578
+ }
579
+ await prepare_default(pluginConfig, context);
580
+ prepared = true;
581
+ }
582
+ async function publish(pluginConfig, context) {
583
+ const package_ = await get_pkg_default(pluginConfig, context);
584
+ if (!verified) {
585
+ await verify_default(pluginConfig, context);
586
+ }
587
+ if (!prepared) {
588
+ await prepare_default(pluginConfig, context);
589
+ }
590
+ return publish_default(pluginConfig, package_, context);
591
+ }
592
+ async function addChannel(pluginConfig, context) {
593
+ if (!verified) {
594
+ await verify_default(pluginConfig, context);
595
+ }
596
+ const package_ = await get_pkg_default(pluginConfig, context);
597
+ return add_channel_default(pluginConfig, package_, context);
598
+ }
599
+
600
+ export { addChannel, prepare, publish, verifyConditions };
601
+ //# sourceMappingURL=out.js.map
602
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/add-channel.ts","../src/utils/get-channel.ts","../src/utils/get-npmrc.ts","../src/utils/get-error.ts","../package.json","../src/definitions/errors.ts","../src/utils/get-registry.ts","../src/definitions/constants.ts","../src/utils/get-release-info.ts","../src/utils/should-publish.ts","../src/prepare.ts","../src/publish.ts","../src/utils/get-pkg.ts","../src/verify/index.ts","../src/verify/verify-auth.ts","../src/utils/set-npmrc-auth.ts","../src/utils/nerf-dart.ts","../src/verify/verify-config.ts","../src/verify/verify-pnpm.ts","../src/index.ts"],"names":["resolve","DEFAULT_NPM_REGISTRY","execa","AggregateError","normalizeUrl","rc","errors","publish"],"mappings":";AACA,SAAS,aAAa;;;ACDtB,SAAS,kBAAkB;AAE3B,IAAO,sBAAQ,CAAC,YAAgD,UAAW,WAAW,OAAO,IAAI,WAAW,OAAO,KAAK,UAAW;;;ACDnI,SAAS,YAAY,wBAAwB;AAE7C,SAAS,8BAA8B;AAEvC,SAAS,eAAe;;;ACLxB,OAAO,0BAA0B;;;ACAjC;AAAA,EACI,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,UAAY;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAAA,EACA,UAAY;AAAA,EACZ,YAAc;AAAA,IACV,MAAQ;AAAA,IACR,KAAO;AAAA,EACX;AAAA,EACA,SAAW;AAAA,EACX,QAAU;AAAA,IACN,MAAQ;AAAA,IACR,OAAS;AAAA,EACb;AAAA,EACA,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,OAAS;AAAA,EACT,OAAS;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAAA,EACA,SAAW;AAAA,IACP,OAAS;AAAA,IACT,cAAc;AAAA,IACd,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,YAAY;AAAA,IACZ,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,IAC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AM,gBAAW,cAAc,OAAO;AAEvD,SAAO,oBAAc,cAAc,UAAU,OAAO;AACxD","sourcesContent":["import type { PackageJson } from \"@visulima/package\";\nimport { execa } from \"execa\";\n\nimport type { AddChannelContext } from \"./definitions/context\";\nimport type { PluginConfig } from \"./definitions/plugin-config\";\nimport getChannel from \"./utils/get-channel\";\nimport getNpmrc from \"./utils/get-npmrc\";\nimport getRegistry from \"./utils/get-registry\";\nimport type { ReleaseInfo } from \"./utils/get-release-info\";\nimport { getReleaseInfo } from \"./utils/get-release-info\";\nimport { reasonToNotPublish, shouldPublish } from \"./utils/should-publish\";\n\nexport default async (pluginConfig: PluginConfig, package_: PackageJson, context: AddChannelContext): Promise<ReleaseInfo | boolean> => {\n const {\n cwd,\n env,\n logger,\n nextRelease: { channel, version },\n stderr,\n stdout,\n } = context;\n\n if (shouldPublish(pluginConfig, package_)) {\n const registry = getRegistry(package_, context);\n const distributionTag = getChannel(channel);\n\n logger.log(`Adding version ${version} to npm registry on dist-tag ${distributionTag}`);\n\n const npmrc = getNpmrc(cwd, env);\n\n const result = execa(\"pnpm\", [\"dist-tag\", \"add\", `${package_.name}@${version}`, distributionTag, \"--userconfig\", npmrc, \"--registry\", registry], {\n cwd,\n env,\n preferLocal: true,\n });\n\n result.stdout.pipe(stdout, { end: false });\n result.stderr.pipe(stderr, { end: false });\n\n await result;\n\n logger.log(`Added ${package_.name}@${version} to dist-tag @${distributionTag} on ${registry}`);\n\n return getReleaseInfo(package_, context, distributionTag, registry);\n }\n\n logger.log(`Skip adding to npm channel as ${reasonToNotPublish(pluginConfig, package_)}`);\n\n return false;\n};\n","import { validRange } from \"semver\";\n\nexport default (channel: string | null | undefined): string => (channel ? (validRange(channel) ? `release-${channel}` : channel) : \"latest\");\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { ensureFile, isAccessibleSync } from \"@visulima/fs\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { findCacheDirectorySync } from \"@visulima/package\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { resolve } from \"@visulima/path\";\n\nimport getError from \"./get-error\";\n\nconst getNpmrc = (cwd: string, environment: NodeJS.ProcessEnv): string => {\n let npmrc = environment.NPM_CONFIG_USERCONFIG;\n\n const npmrcPath = resolve(cwd, \".npmrc\");\n\n if (!npmrc && isAccessibleSync(npmrcPath)) {\n npmrc = npmrcPath;\n } else if (!npmrc) {\n const temporaryNpmrcPath = findCacheDirectorySync(\"semantic-release-pnpm\", { create: true, cwd });\n\n if (temporaryNpmrcPath) {\n ensureFile(temporaryNpmrcPath);\n\n npmrc = temporaryNpmrcPath;\n }\n }\n\n if (!npmrc) {\n // eslint-disable-next-line unicorn/error-message\n throw new AggregateError([\n getError(\"ENOPNPMRC\", {\n npmrc: npmrcPath,\n }),\n ]);\n }\n\n return npmrc;\n};\n\nexport default getNpmrc;\n","import SemanticReleaseError from \"@semantic-release/error\";\n\nimport type { ErrorContext, ErrorDefinition } from \"../definitions/errors\";\nimport { errors } from \"../definitions/errors\";\n\nexport default <T extends keyof typeof errors>(code: T, context: ErrorContext = {}): SemanticReleaseError => {\n const { details, message }: { details?: string; message: string } = (errors[code] as ErrorDefinition)(context);\n\n return new SemanticReleaseError(message, code, details);\n};\n","{\n \"name\": \"@anolilab/semantic-release-pnpm\",\n \"version\": \"1.0.0-alpha.1\",\n \"description\": \"Semantic-release plugin to publish a npm package with pnpm.\",\n \"keywords\": [\n \"anolilab\",\n \"npm\",\n \"publish\",\n \"semantic-release\",\n \"pnpm\",\n \"monorepo\"\n ],\n \"homepage\": \"https://github.com/anolilab/semantic-release-pnpm\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/anolilab/semantic-release-pnpm.git\"\n },\n \"license\": \"MIT\",\n \"author\": {\n \"name\": \"Daniel Bannert\",\n \"email\": \"d.bannert@anolilab.de\"\n },\n \"type\": \"module\",\n \"exports\": \"./dist/index.js\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"files\": [\n \"dist\",\n \"README.md\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"build\": \"cross-env NODE_ENV=development tsup\",\n \"build:prod\": \"cross-env NODE_ENV=production tsup\",\n \"lint:eslint\": \"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs\",\n \"lint:eslint:fix\": \"pnpm run lint:eslint --fix\",\n \"lint:fix\": \"pnpm run lint:prettier:fix && pnpm run lint:eslint:fix\",\n \"lint:packagejson\": \"publint --strict\",\n \"lint:prettier\": \"prettier --config=.prettierrc.cjs --check .\",\n \"lint:prettier:fix\": \"prettier --config=.prettierrc.cjs --write .\",\n \"lint:secrets\": \"secretlint **/*\",\n \"lint:staged\": \"lint-staged --verbose --concurrent false --debug\",\n \"lint:text\": \"textlint ./.github/ ./README.md ./UPGRADE.md --parallel --experimental --cache --dry-run\",\n \"lint:text:fix\": \"textlint ./.github/ ./README.md ./UPGRADE.md --parallel --experimental --fix\",\n \"lint:types\": \"tsc --noEmit\",\n \"prepare\": \"is-ci || (node verify-node-version.cjs && pnpx only-allow pnpm && husky install)\",\n \"sort-package-json\": \"sort-package-json ./package.json\",\n \"test\": \"vitest run\",\n \"test:bench\": \"vitest bench\",\n \"test:coverage\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\",\n \"update:deps\": \"taze\"\n },\n \"dependencies\": {\n \"@visulima/package\": \"1.8.1\",\n \"@visulima/fs\": \"^2.1.1\",\n \"@visulima/path\": \"^1.0.0\",\n \"@semantic-release/error\": \"^4.0.0\",\n \"aggregate-error\": \"^5.0.0\",\n \"execa\": \"^9.1.0\",\n \"move-file\": \"^3.1.0\",\n \"normalize-url\": \"^8.0.1\",\n \"rc\": \"^1.2.8\",\n \"registry-auth-token\": \"^5.0.2\",\n \"semver\": \"^7.6.2\"\n },\n \"devDependencies\": {\n \"@anolilab/commitlint-config\": \"^5.0.3\",\n \"@anolilab/eslint-config\": \"^15.0.3\",\n \"@anolilab/lint-staged-config\": \"^2.1.7\",\n \"@anolilab/prettier-config\": \"^5.0.14\",\n \"@anolilab/textlint-config\": \"^8.0.16\",\n \"@babel/core\": \"^7.24.5\",\n \"@babel/eslint-parser\": \"7.24.5\",\n \"@commitlint/cli\": \"^19.3.0\",\n \"@commitlint/config-conventional\": \"^19.2.2\",\n \"@secretlint/secretlint-rule-preset-recommend\": \"^8.2.4\",\n \"@semantic-release/changelog\": \"^6.0.3\",\n \"@semantic-release/git\": \"^10.0.1\",\n \"@semantic-release/github\": \"^10.0.3\",\n \"@types/dockerode\": \"^3.3.29\",\n \"@types/node\": \"^20.12.12\",\n \"@types/rc\": \"^1.2.4\",\n \"@types/semantic-release__error\": \"3.0.3\",\n \"@types/semver\": \"7.5.8\",\n \"@vitest/coverage-v8\": \"^1.6.0\",\n \"commitizen\": \"^4.3.0\",\n \"commitlint\": \"^19.3.0\",\n \"cross-env\": \"^7.0.3\",\n \"cz-conventional-changelog\": \"^3.3.0\",\n \"dockerode\": \"4.0.2\",\n \"eslint\": \"8.55.0\",\n \"eslint-plugin-deprecation\": \"^2.0.0\",\n \"eslint-plugin-editorconfig\": \"^4.0.3\",\n \"eslint-plugin-import\": \"npm:eslint-plugin-i@2.29.1\",\n \"eslint-plugin-mdx\": \"^3.1.5\",\n \"eslint-plugin-n\": \"^17.7.0\",\n \"eslint-plugin-vitest\": \"^0.4.1\",\n \"eslint-plugin-vitest-globals\": \"^1.5.0\",\n \"eslint-plugin-you-dont-need-lodash-underscore\": \"^6.14.0\",\n \"get-stream\": \"9.0.1\",\n \"husky\": \"^9.0.11\",\n \"is-ci\": \"^3.0.1\",\n \"lint-staged\": \"^15.2.2\",\n \"prettier\": \"^3.2.5\",\n \"publint\": \"^0.2.7\",\n \"rimraf\": \"^5.0.7\",\n \"secretlint\": \"8.2.4\",\n \"semantic-release\": \"^23.1.1\",\n \"sort-package-json\": \"^2.10.0\",\n \"taze\": \"^0.13.8\",\n \"tempy\": \"^3.1.0\",\n \"textlint\": \"^14.0.4\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.4.5\",\n \"vitest\": \"^1.6.0\"\n },\n \"peerDependencies\": {\n \"semantic-release\": \"^20.0 || ^21.0 || >=22.0.3\"\n },\n \"packageManager\": \"pnpm@9.1.1\",\n \"engines\": {\n \"node\": \">=18 || >=20.6.1\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"anolilab\": {\n \"eslint-config\": {\n \"plugin\": {},\n \"warn_on_unsupported_typescript_version\": false,\n \"info_on_disabling_jsx_react_rule\": false,\n \"info_on_disabling_prettier_conflict_rule\": false,\n \"info_on_disabling_jsonc_sort_keys_rule\": false,\n \"import_ignore_exports\": [\n \"**/*.cjs\",\n \"verify-node-version.cjs\"\n ]\n }\n },\n \"pnpm\": {\n \"overrides\": {\n \"chrono-node@<2.2.4\": \">=2.2.4\"\n }\n }\n}\n","import package_ from \"../../package.json\";\n\nconst linkify = (file: string) => `${package_.homepage}/blob/main/${file}`;\n\n\ninterface ErrorDetails {\n details: string;\n message: string;\n}\n\nexport type ErrorDefinition = (context: ErrorContext) => ErrorDetails;\n\nexport interface ErrorContext {\n npmPublish?: boolean;\n npmrc?: string;\n pkgRoot?: string;\n publishBranch?: string;\n registry?: string;\n tarballDir?: string;\n version?: string;\n}\n\nexport const errors = {\n EINVALIDNPMPUBLISH: ({ npmPublish }: ErrorContext) => {\n return {\n details: `The [npmPublish option](${linkify(\"README.md#npmpublish\")}) option, if defined, must be a \\`Boolean\\`.\nYour configuration for the \\`npmPublish\\` option is \\`${npmPublish}\\`.`,\n message: \"Invalid `npmPublish` option.\",\n };\n },\n EINVALIDNPMTOKEN: ({ registry }: ErrorContext) => {\n return {\n details: `The [npm token](${linkify(\n \"README.md#npm-registry-authentication\",\n )}) configured in the \\`NPM_TOKEN\\` environment variable must be a valid [token](https://docs.npmjs.com/getting-started/working_with_tokens) allowing to publish to the registry \\`${registry}\\`.\nIf you are using Two Factor Authentication for your account, set its level to [\"Authorization only\"](https://docs.npmjs.com/getting-started/using-two-factor-authentication#levels-of-authentication) in your account settings. **semantic-release** cannot publish with the default \"Authorization and writes\" level.\nPlease make sure to set the \\`NPM_TOKEN\\` environment variable in your CI with the exact value of the npm token.`,\n message: \"Invalid npm token.\",\n };\n },\n EINVALIDPKGROOT: ({ pkgRoot }: ErrorContext) => {\n return {\n details: `The [pkgRoot option](${linkify(\"README.md#pkgroot\")}) option, if defined, must be a \\`String\\`.\nYour configuration for the \\`pkgRoot\\` option is \\`${pkgRoot}\\`.`,\n message: \"Invalid `pkgRoot` option.\",\n };\n },\n EINVALIDPNPM: ({ version }: ErrorContext) => {\n return {\n details: `The version of Pnpm that you are using is not compatible. Please refer to [the README](${linkify(\n \"README.md#install\",\n )}) to review which versions of Pnpm are currently supported\n\nYour version of Pnpm is \"${version}\".`,\n message: \"Incompatible Pnpm version detected.\",\n };\n },\n EINVALIDPUBLISHBRANCH: ({ publishBranch }: ErrorContext) => {\n return {\n details: `The [publishBranch option](${linkify(\"README.md#publishBranch\")}) option, if defined, must be a \\`String\\`.\nYour configuration for the \\`publishBranch\\` option is \\`${publishBranch}\\`.`,\n message: \"Invalid `publishBranch` option.\",\n };\n },\n EINVALIDTARBALLDIR: ({ tarballDir }: ErrorContext) => {\n return {\n details: `The [tarballDir option](${linkify(\"README.md#tarballdir\")}) option, if defined, must be a \\`String\\`.\nYour configuration for the \\`tarballDir\\` option is \\`${tarballDir}\\`.`,\n message: \"Invalid `tarballDir` option.\",\n };\n },\n ENONPMTOKEN: ({ registry }: ErrorContext) => {\n return {\n details: `An [npm token](${linkify(\n \"README.md#npm-registry-authentication\",\n )}) must be created and set in the \\`NPM_TOKEN\\` environment variable on your CI environment.\nPlease make sure to create an [npm token](https://docs.npmjs.com/getting-started/working_with_tokens#how-to-create-new-tokens) and to set it in the \\`NPM_TOKEN\\` environment variable on your CI environment. The token must allow to publish to the registry \\`${registry}\\`.`,\n message: \"No npm token specified.\",\n };\n },\n ENOPKG: () => {\n return {\n details: `A [package.json file](https://docs.npmjs.com/files/package.json) at the root of your project is required to release on npm.\nPlease follow the [npm guideline](https://docs.npmjs.com/getting-started/creating-node-modules) to create a valid \\`package.json\\` file.`,\n message: \"Missing `package.json` file.\",\n };\n },\n ENOPKGNAME: () => {\n return {\n details: `The \\`package.json\\`'s [name](https://docs.npmjs.com/files/package.json#name) property is required in order to publish a package to the npm registry.\nPlease make sure to add a valid \\`name\\` for your package in your \\`package.json\\`.`,\n message: \"Missing `name` property in `package.json`.\",\n };\n },\n ENOPNPM: () => {\n return {\n details: `The Pnpm CLI could not be found in your PATH. Make sure Pnpm is installed and try again.`,\n message: \"Pnpm not found.\",\n };\n },\n ENOPNPMRC: () => {\n return {\n details: `Didnt find a \\`.npmrc\\` file or it was not possible to create , in the root of your project.`,\n message: \"Missing `.npmrc` file.\",\n };\n },\n EINVALIDBRANCHES: (branches: string[]) => {\n return {\n details: `The [branches option](${linkify(\"README.md#branches\")}) option, if defined, must be an array of \\`String\\`.\nYour configuration for the \\`branches\\` option is \\`${branches}\\`.`,\n message: \"Invalid `branches` option.\",\n };\n },\n};\n","import type { PackageJson } from \"@visulima/package\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { resolve } from \"@visulima/path\";\nimport rc from \"rc\";\nimport type { AuthOptions } from \"registry-auth-token\";\n\nimport { DEFAULT_NPM_REGISTRY } from \"../definitions/constants\";\nimport type { CommonContext } from \"../definitions/context\";\n\nconst getRegistryUrl = (scope: string, npmrc: AuthOptions[\"npmrc\"]): string => {\n let url: string = DEFAULT_NPM_REGISTRY;\n\n if (npmrc) {\n const registryUrl = npmrc[`${scope}:registry`] ?? npmrc[\"registry\"];\n\n if (registryUrl) {\n url = registryUrl;\n }\n }\n\n return url.slice(-1) === \"/\" ? url : `${url}/`;\n};\n\nexport default ({ name, publishConfig: { registry } = {} }: PackageJson, { cwd, env }: CommonContext): string =>\n registry ??\n env.NPM_CONFIG_REGISTRY ??\n getRegistryUrl(\n (name as string).split(\"/\")[0] as string,\n rc(\"npm\", { registry: \"https://registry.npmjs.org/\" }, { config: env.NPM_CONFIG_USERCONFIG ?? resolve(cwd, \".npmrc\") }) as AuthOptions[\"npmrc\"],\n );\n","export const DEFAULT_NPM_REGISTRY = \"https://registry.npmjs.org/\";\n","import type { PackageJson } from \"@visulima/package\";\nimport normalizeUrl from \"normalize-url\";\n\nimport type { PublishContext } from \"../definitions/context\";\n\nexport interface ReleaseInfo {\n channel: string;\n name: string;\n url?: string;\n}\n\nexport const getReleaseInfo = (\n { name }: PackageJson,\n { env: { DEFAULT_NPM_REGISTRY = \"https://registry.npmjs.org/\" }, nextRelease: { version } }: PublishContext,\n distributionTag: string,\n registry: string,\n): ReleaseInfo => {\n return {\n channel: distributionTag,\n name: `pnpm package (@${distributionTag} dist-tag)`,\n url: normalizeUrl(registry) === normalizeUrl(DEFAULT_NPM_REGISTRY) ? `https://www.npmjs.com/package/${name}/v/${version}` : undefined,\n };\n};\n","import type { PackageJson } from \"@visulima/package\";\n\nimport type { PluginConfig } from \"../definitions/plugin-config\";\n\nexport function shouldPublish(pluginConfig: PluginConfig, package_: PackageJson) {\n return reasonToNotPublish(pluginConfig, package_) === null;\n}\n/**\n * Returns null if `npmPublish` is not `false` and `pkg.private` is not\n * `true` or `pkg.workspaces` is not `undefined`.\n * Returns reason otherwise.\n */\nexport function reasonToNotPublish(pluginConfig: PluginConfig, package_: PackageJson) {\n return pluginConfig.npmPublish === false\n ? \"npmPublish plugin option is false\"\n : package_.private === true && package_.workspaces === undefined\n ? \"package is private and has no workspaces\"\n : null;\n}\n","import { resolve } from \"@visulima/path\";\nimport { execa } from \"execa\";\nimport { moveFile } from \"move-file\";\n\nimport type { PrepareContext } from \"./definitions/context\";\nimport type { PluginConfig } from \"./definitions/plugin-config\";\n\nexport default async ({ pkgRoot, tarballDir }: PluginConfig, { cwd, env, logger, nextRelease: { version }, stderr, stdout }: PrepareContext): Promise<void> => {\n const basePath = pkgRoot ? resolve(cwd, pkgRoot) : cwd;\n\n logger.log(\"Write version %s to package.json in %s\", version, basePath);\n\n const versionResult = execa(\"pnpm\", [\"version\", version, \"--no-git-tag-version\", \"--allow-same-version\"], {\n cwd: basePath,\n env,\n preferLocal: true,\n });\n\n versionResult.stdout.pipe(stdout, { end: false });\n versionResult.stderr.pipe(stderr, { end: false });\n\n await versionResult;\n\n if (tarballDir) {\n logger.log(\"Creating npm package version %s\", version);\n\n const packResult = execa(\"pnpm\", [\"pack\", basePath], { cwd, env, preferLocal: true });\n\n packResult.stdout.pipe(stdout, { end: false });\n packResult.stderr.pipe(stderr, { end: false });\n\n const tarball = (await packResult).stdout.split(\"\\n\").pop() as string;\n const tarballSource = resolve(cwd, tarball);\n const tarballDestination = resolve(cwd, tarballDir.trim(), tarball);\n\n // Only move the tarball if we need to\n // Fixes: https://github.com/semantic-release/npm/issues/169\n if (tarballSource !== tarballDestination) {\n await moveFile(tarballSource, tarballDestination);\n }\n }\n};\n","import type { PackageJson } from \"@visulima/package\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { resolve } from \"@visulima/path\";\nimport AggregateError from \"aggregate-error\";\nimport { execa } from \"execa\";\n\nimport type { PublishContext } from \"./definitions/context\";\nimport type { PluginConfig } from \"./definitions/plugin-config\";\nimport getChannel from \"./utils/get-channel\";\nimport getRegistry from \"./utils/get-registry\";\nimport { getReleaseInfo } from \"./utils/get-release-info\";\nimport { reasonToNotPublish, shouldPublish } from \"./utils/should-publish\";\n\nexport default async (pluginConfig: PluginConfig, package_: PackageJson, context: PublishContext) => {\n const {\n cwd,\n env,\n logger,\n nextRelease: { channel, version },\n stderr,\n stdout,\n } = context;\n const { pkgRoot, publishBranch: publishBranchConfig } = pluginConfig;\n\n if (shouldPublish(pluginConfig, package_)) {\n const basePath = pkgRoot ? resolve(cwd, pkgRoot) : cwd;\n const registry = getRegistry(package_, context);\n const distributionTag = getChannel(channel);\n\n const { stdout: currentBranch } = await execa(\"git\", [\"rev-parse\", \"--abbrev-ref\", \"HEAD\"], {\n cwd,\n env,\n preferLocal: true,\n });\n const publishBranches = typeof publishBranchConfig === \"string\" && publishBranchConfig.split(\"|\");\n const isPublishBranch = publishBranches && publishBranches?.includes(currentBranch);\n const publishBranch = isPublishBranch ? currentBranch : \"main\";\n\n logger.log(`Publishing version ${version} on branch ${publishBranch} to npm registry on dist-tag ${distributionTag}`);\n\n const result = execa(\"pnpm\", [\"publish\", basePath, \"--publish-branch\", publishBranch, \"--tag\", distributionTag, \"--registry\", registry, \"--no-git-checks\"], {\n cwd,\n env,\n preferLocal: true,\n });\n\n result.stdout.pipe(stdout, { end: false });\n result.stderr.pipe(stderr, { end: false });\n\n try {\n await result;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n logger.log(`Failed to publish ${package_.name}@${version} to dist-tag @${distributionTag} on ${registry}: ${error.message || error}`);\n\n throw new AggregateError([error]);\n }\n\n logger.log(`Published ${package_.name}@${version} to dist-tag @${distributionTag} on ${registry}`);\n\n return getReleaseInfo(package_, context, distributionTag, registry);\n }\n\n logger.log(`Skip publishing to npm registry as ${reasonToNotPublish(pluginConfig, package_)}`);\n\n return false;\n};\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport type { PackageJson } from \"@visulima/package\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { findPackageJson } from \"@visulima/package\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { resolve } from \"@visulima/path\";\n\nimport type { CommonContext } from \"../definitions/context\";\nimport getError from \"./get-error\";\n\ninterface Options {\n pkgRoot?: string;\n}\n\nexport default async ({ pkgRoot }: Options, { cwd }: { cwd: CommonContext[\"cwd\"] }): Promise<PackageJson> => {\n try {\n const { packageJson } = await findPackageJson(pkgRoot ? resolve(cwd, pkgRoot) : cwd);\n\n if (!packageJson.name) {\n throw getError(\"ENOPKGNAME\");\n }\n\n return packageJson;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (error.code === \"ENOENT\") {\n throw getError(\"ENOPKG\");\n }\n\n throw error;\n }\n};\n","import AggregateError from \"aggregate-error\";\n\nimport type { VerifyConditionsContext } from \"../definitions/context\";\nimport type { PluginConfig } from \"../definitions/plugin-config\";\nimport getNpmrc from \"../utils/get-npmrc\";\nimport getPackage from \"../utils/get-pkg\";\nimport { shouldPublish } from \"../utils/should-publish\";\nimport verifyAuth from \"./verify-auth\";\nimport verifyConfig from \"./verify-config\";\nimport verifyPnpm from \"./verify-pnpm\";\n\nconst verify = async (pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void> => {\n let errors: Error[] = verifyConfig(pluginConfig);\n\n try {\n verifyPnpm(context);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n errors = [...errors, ...(error.errors ? error.errors : [error])];\n }\n\n try {\n const packageJson = await getPackage(pluginConfig, context);\n\n if (shouldPublish(pluginConfig, packageJson)) {\n const npmrc = getNpmrc(context.cwd, context.env);\n\n await verifyAuth(npmrc, packageJson, context);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n errors = [...errors, ...(error.errors ? error.errors : [error])];\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors);\n }\n}\n\nexport default verify;\n","import type { PackageJson } from \"@visulima/package\";\nimport AggregateError from \"aggregate-error\";\nimport { execa } from \"execa\";\nimport normalizeUrl from \"normalize-url\";\n\nimport type { CommonContext } from \"../definitions/context\";\nimport getError from \"../utils/get-error\";\nimport getRegistry from \"../utils/get-registry\";\nimport setNpmrcAuth from \"../utils/set-npmrc-auth\";\n\nexport default async (npmrc: string, package_: PackageJson, context: CommonContext): Promise<void> => {\n const {\n cwd,\n env: { DEFAULT_NPM_REGISTRY = \"https://registry.npmjs.org/\", ...environment },\n logger,\n stderr,\n stdout,\n } = context;\n const registry = getRegistry(package_, context);\n\n await setNpmrcAuth(npmrc, registry, context);\n\n if (normalizeUrl(registry) === normalizeUrl(DEFAULT_NPM_REGISTRY)) {\n try {\n logger.log(`Running \"pnpm whoami\" to verify authentication on registry \"${registry}\"`);\n\n const whoamiResult = execa(\"pnpm\", [\"whoami\", \"--userconfig\", npmrc, \"--registry\", registry], {\n cwd,\n env: environment,\n preferLocal: true,\n });\n\n whoamiResult.stdout.pipe(stdout, { end: false });\n whoamiResult.stderr.pipe(stderr, { end: false });\n\n await whoamiResult;\n } catch {\n throw new AggregateError([getError(\"EINVALIDNPMTOKEN\", { registry })]);\n }\n } else {\n logger.log(`Skipping authentication verification for non-default registry \"${registry}\"`);\n }\n};\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { readFile, writeFile } from \"@visulima/fs\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { resolve } from \"@visulima/path\";\nimport AggregateError from \"aggregate-error\";\nimport rc from \"rc\";\nimport type { AuthOptions } from \"registry-auth-token\";\nimport getAuthToken from \"registry-auth-token\";\n\nimport { DEFAULT_NPM_REGISTRY } from \"../definitions/constants\";\nimport type { CommonContext } from \"../definitions/context\";\nimport getError from \"./get-error\";\nimport nerfDart from \"./nerf-dart\";\n\nexport default async (\n npmrc: string,\n registry: string,\n { cwd, env: { NPM_CONFIG_USERCONFIG, NPM_EMAIL, NPM_PASSWORD, NPM_TOKEN, NPM_USERNAME }, logger }: CommonContext,\n): Promise<void> => {\n logger.log(\"Verify authentication for registry %s\", registry);\n\n const { configs, ...rcConfig } = rc(\"npm\", { registry: DEFAULT_NPM_REGISTRY }, { config: NPM_CONFIG_USERCONFIG ?? resolve(cwd, \".npmrc\") });\n\n if (configs) {\n logger.log(\"Reading npm config from %s\", configs.join(\", \"));\n }\n\n // eslint-disable-next-line compat/compat,unicorn/no-await-expression-member\n const currentConfig = configs ? (await Promise.all(configs.map((config) => readFile(config)))).join(\"\\n\") : \"\";\n\n if (getAuthToken(registry, { npmrc: rcConfig } as AuthOptions)) {\n await writeFile(npmrc, currentConfig);\n\n return;\n }\n\n if (NPM_USERNAME && NPM_PASSWORD && NPM_EMAIL) {\n await writeFile(npmrc, `${currentConfig ? `${currentConfig}\\n` : \"\"}_auth = \\${LEGACY_TOKEN}\\nemail = \\${NPM_EMAIL}`);\n\n logger.log(`Wrote NPM_USERNAME, NPM_PASSWORD, and NPM_EMAIL to ${npmrc}`);\n } else if (NPM_TOKEN) {\n await writeFile(npmrc, `${currentConfig ? `${currentConfig}\\n` : \"\"}${nerfDart(registry)}:_authToken = \\${NPM_TOKEN}`);\n\n logger.log(`Wrote NPM_TOKEN to ${npmrc}`);\n } else {\n throw new AggregateError([getError(\"ENONPMTOKEN\", { registry })]);\n }\n};\n","import { URL } from \"node:url\";\n\n/**\n * Maps a URL to an identifier.\n *\n * The ISC License\n * Copyright (c) npm, Inc.\n *\n * Name courtesy schiffertronix media LLC, a New Jersey corporation\n *\n * @param {String} uri The URL to be nerfed.\n *\n * @returns {String} A nerfed URL.\n */\nconst nerfDart = (url: string): string => {\n const parsed = new URL(url);\n const from = `${parsed.protocol}//${parsed.host}${parsed.pathname}`;\n const rel = new URL(\".\", from);\n\n return `//${rel.host}${rel.pathname}`;\n};\n\nexport default nerfDart;\n","import type SemanticReleaseError from \"@semantic-release/error\";\n\nimport type { PluginConfig } from \"../definitions/plugin-config\";\nimport getError from \"../utils/get-error\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isString = (value: any): boolean => typeof value === \"string\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isNil = (value: any): boolean => value === null || value === undefined;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isNonEmptyString = (value: any): boolean => isString(value) && value.trim();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ValidatorFunction = (value: any) => boolean;\n\nconst VALIDATORS: Record<string, ValidatorFunction> = {\n branches: Array.isArray,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n npmPublish: (value: any): boolean => typeof value === \"boolean\",\n pkgRoot: isNonEmptyString,\n publishBranch: isNonEmptyString,\n tarballDir: isNonEmptyString,\n};\n\nexport default (config: PluginConfig): SemanticReleaseError[] =>\n // eslint-disable-next-line unicorn/no-array-reduce\n Object.entries(config).reduce((errors, [option, value]) => {\n if (isNil(value)) {\n return errors;\n }\n\n if (!(option in VALIDATORS)) {\n return errors;\n }\n\n if (VALIDATORS[option]?.(value)) {\n return errors;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment\n return [...errors, getError(`EINVALID${option.toUpperCase()}` as any, { [option]: value })];\n }, [] as SemanticReleaseError[]);\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { getPackageManagerVersion } from \"@visulima/package\";\nimport AggregateError from \"aggregate-error\";\nimport { gte } from \"semver\";\n\nimport type { CommonContext } from \"../definitions/context\";\nimport getError from \"../utils/get-error\";\n\nconst MIN_PNPM_VERSION = \"8.0.0\";\n\nexport default async function verifyPnpm({ logger }: CommonContext): Promise<void> {\n logger.log(`Verify pnpm version is >= ${MIN_PNPM_VERSION}`);\n\n const version = await getPackageManagerVersion(\"pnpm\");\n\n if (version === undefined) {\n throw new AggregateError([new Error(\"pnpm is not installed\")]);\n }\n\n if (gte(MIN_PNPM_VERSION, version)) {\n throw new AggregateError([getError(\"EINVALIDPNPM\", { version: String(version) })]);\n }\n}\n","import addChannelNpm from \"./add-channel\";\nimport type { AddChannelContext, PrepareContext, PublishContext, VerifyConditionsContext } from \"./definitions/context\";\nimport type { PluginConfig } from \"./definitions/plugin-config\";\nimport prepareNpm from \"./prepare\";\nimport publishNpm from \"./publish\";\nimport getPackage from \"./utils/get-pkg\";\nimport verify from \"./verify\";\n\nconst PLUGIN_NAME = \"semantic-release-pnpm\";\n\nlet verified: boolean;\nlet prepared: boolean;\n\nexport async function verifyConditions(pluginConfig: PluginConfig, context: VerifyConditionsContext) {\n /**\n * If the plugin is used and has `npmPublish`, `tarballDir` or\n * `pkgRoot` configured, validate them now in order to prevent any release if\n * the configuration is wrong\n */\n if (context.options?.[\"publish\"]) {\n const publish = Array.isArray(context.options?.[\"publish\"]) ? context.options?.[\"publish\"] : [context.options?.[\"publish\"]];\n const publishPlugin = publish.find((config) => config.path && config.path === PLUGIN_NAME) || {};\n\n pluginConfig.npmPublish = pluginConfig.npmPublish ?? publishPlugin.npmPublish;\n pluginConfig.tarballDir = pluginConfig.tarballDir ?? publishPlugin.tarballDir;\n pluginConfig.pkgRoot = pluginConfig.pkgRoot ?? publishPlugin.pkgRoot;\n }\n\n await verify(pluginConfig, context);\n\n verified = true;\n}\n\nexport async function prepare(pluginConfig: PluginConfig, context: PrepareContext) {\n if (!verified) {\n await verify(pluginConfig, context);\n }\n\n await prepareNpm(pluginConfig, context);\n\n prepared = true;\n}\n\nexport async function publish(pluginConfig: PluginConfig, context: PublishContext) {\n const package_ = await getPackage(pluginConfig, context);\n\n if (!verified) {\n await verify(pluginConfig, context);\n }\n\n if (!prepared) {\n await prepareNpm(pluginConfig, context);\n }\n\n return publishNpm(pluginConfig, package_, context);\n}\n\nexport async function addChannel(pluginConfig: PluginConfig, context: AddChannelContext) {\n if (!verified) {\n await verify(pluginConfig, context);\n }\n\n const package_ = await getPackage(pluginConfig, context);\n\n return addChannelNpm(pluginConfig, package_, context);\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,140 @@
1
+ {
2
+ "name": "@anolilab/semantic-release-pnpm",
3
+ "version": "1.0.0-alpha.2",
4
+ "description": "Semantic-release plugin to publish a npm package with pnpm.",
5
+ "keywords": [
6
+ "anolilab",
7
+ "npm",
8
+ "publish",
9
+ "semantic-release",
10
+ "pnpm",
11
+ "monorepo"
12
+ ],
13
+ "homepage": "https://github.com/anolilab/semantic-release-pnpm",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/anolilab/semantic-release-pnpm.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": {
20
+ "name": "Daniel Bannert",
21
+ "email": "d.bannert@anolilab.de"
22
+ },
23
+ "type": "module",
24
+ "exports": "./dist/index.js",
25
+ "main": "dist/index.js",
26
+ "types": "dist/index.d.ts",
27
+ "files": [
28
+ "dist",
29
+ "README.md",
30
+ "CHANGELOG.md"
31
+ ],
32
+ "dependencies": {
33
+ "@visulima/package": "1.8.1",
34
+ "@visulima/fs": "^2.1.1",
35
+ "@visulima/path": "^1.0.0",
36
+ "@semantic-release/error": "^4.0.0",
37
+ "aggregate-error": "^5.0.0",
38
+ "execa": "^9.1.0",
39
+ "move-file": "^3.1.0",
40
+ "normalize-url": "^8.0.1",
41
+ "rc": "^1.2.8",
42
+ "registry-auth-token": "^5.0.2",
43
+ "semver": "^7.6.2"
44
+ },
45
+ "devDependencies": {
46
+ "@anolilab/commitlint-config": "^5.0.3",
47
+ "@anolilab/eslint-config": "^15.0.3",
48
+ "@anolilab/lint-staged-config": "^2.1.7",
49
+ "@anolilab/prettier-config": "^5.0.14",
50
+ "@anolilab/textlint-config": "^8.0.16",
51
+ "@babel/core": "^7.24.5",
52
+ "@babel/eslint-parser": "7.24.5",
53
+ "@commitlint/cli": "^19.3.0",
54
+ "@commitlint/config-conventional": "^19.2.2",
55
+ "@secretlint/secretlint-rule-preset-recommend": "^8.2.4",
56
+ "@semantic-release/changelog": "^6.0.3",
57
+ "@semantic-release/git": "^10.0.1",
58
+ "@semantic-release/github": "^10.0.3",
59
+ "@types/dockerode": "^3.3.29",
60
+ "@types/node": "^20.12.12",
61
+ "@types/rc": "^1.2.4",
62
+ "@types/semantic-release__error": "3.0.3",
63
+ "@types/semver": "7.5.8",
64
+ "@vitest/coverage-v8": "^1.6.0",
65
+ "commitizen": "^4.3.0",
66
+ "commitlint": "^19.3.0",
67
+ "cross-env": "^7.0.3",
68
+ "cz-conventional-changelog": "^3.3.0",
69
+ "dockerode": "4.0.2",
70
+ "eslint": "8.55.0",
71
+ "eslint-plugin-deprecation": "^2.0.0",
72
+ "eslint-plugin-editorconfig": "^4.0.3",
73
+ "eslint-plugin-import": "npm:eslint-plugin-i@2.29.1",
74
+ "eslint-plugin-mdx": "^3.1.5",
75
+ "eslint-plugin-n": "^17.7.0",
76
+ "eslint-plugin-vitest": "^0.4.1",
77
+ "eslint-plugin-vitest-globals": "^1.5.0",
78
+ "eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
79
+ "get-stream": "9.0.1",
80
+ "husky": "^9.0.11",
81
+ "is-ci": "^3.0.1",
82
+ "lint-staged": "^15.2.2",
83
+ "prettier": "^3.2.5",
84
+ "publint": "^0.2.7",
85
+ "rimraf": "^5.0.7",
86
+ "secretlint": "8.2.4",
87
+ "semantic-release": "^23.1.1",
88
+ "sort-package-json": "^2.10.0",
89
+ "taze": "^0.13.8",
90
+ "tempy": "^3.1.0",
91
+ "textlint": "^14.0.4",
92
+ "tsup": "^8.0.2",
93
+ "typescript": "^5.4.5",
94
+ "vitest": "^1.6.0"
95
+ },
96
+ "peerDependencies": {
97
+ "semantic-release": "^20.0 || ^21.0 || >=22.0.3"
98
+ },
99
+ "engines": {
100
+ "node": ">=18 || >=20.6.1"
101
+ },
102
+ "publishConfig": {
103
+ "access": "public",
104
+ "provenance": true
105
+ },
106
+ "anolilab": {
107
+ "eslint-config": {
108
+ "plugin": {},
109
+ "warn_on_unsupported_typescript_version": false,
110
+ "info_on_disabling_jsx_react_rule": false,
111
+ "info_on_disabling_prettier_conflict_rule": false,
112
+ "info_on_disabling_jsonc_sort_keys_rule": false,
113
+ "import_ignore_exports": [
114
+ "**/*.cjs",
115
+ "verify-node-version.cjs"
116
+ ]
117
+ }
118
+ },
119
+ "scripts": {
120
+ "build": "cross-env NODE_ENV=development tsup",
121
+ "build:prod": "cross-env NODE_ENV=production tsup",
122
+ "lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
123
+ "lint:eslint:fix": "pnpm run lint:eslint --fix",
124
+ "lint:fix": "pnpm run lint:prettier:fix && pnpm run lint:eslint:fix",
125
+ "lint:packagejson": "publint --strict",
126
+ "lint:prettier": "prettier --config=.prettierrc.cjs --check .",
127
+ "lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
128
+ "lint:secrets": "secretlint **/*",
129
+ "lint:staged": "lint-staged --verbose --concurrent false --debug",
130
+ "lint:text": "textlint ./.github/ ./README.md ./UPGRADE.md --parallel --experimental --cache --dry-run",
131
+ "lint:text:fix": "textlint ./.github/ ./README.md ./UPGRADE.md --parallel --experimental --fix",
132
+ "lint:types": "tsc --noEmit",
133
+ "sort-package-json": "sort-package-json ./package.json",
134
+ "test": "vitest run",
135
+ "test:bench": "vitest bench",
136
+ "test:coverage": "vitest run --coverage",
137
+ "test:watch": "vitest",
138
+ "update:deps": "taze"
139
+ }
140
+ }