@jsdevtools/npm-publish 3.1.0 → 4.0.0
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/README.md +39 -25
- package/bin/npm-publish.js +17 -7
- package/lib/action/core.d.ts +1 -1
- package/lib/action/core.js +16 -25
- package/lib/action/core.js.map +1 -1
- package/lib/action/main.js +5 -32
- package/lib/action/main.js.map +1 -1
- package/lib/cli/index.js +7 -11
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/parse-cli-arguments.js +3 -10
- package/lib/cli/parse-cli-arguments.js.map +1 -1
- package/lib/compare-and-publish/compare-and-publish.d.ts +1 -1
- package/lib/compare-and-publish/compare-and-publish.js +16 -18
- package/lib/compare-and-publish/compare-and-publish.js.map +1 -1
- package/lib/compare-and-publish/compare-versions.d.ts +1 -1
- package/lib/compare-and-publish/compare-versions.js +12 -19
- package/lib/compare-and-publish/compare-versions.js.map +1 -1
- package/lib/compare-and-publish/get-arguments.js +6 -8
- package/lib/compare-and-publish/get-arguments.js.map +1 -1
- package/lib/compare-and-publish/index.js +1 -17
- package/lib/compare-and-publish/index.js.map +1 -1
- package/lib/errors.js +22 -41
- package/lib/errors.js.map +1 -1
- package/lib/format-publish-result.d.ts +1 -1
- package/lib/format-publish-result.js +3 -10
- package/lib/format-publish-result.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -22
- package/lib/index.js.map +1 -1
- package/lib/normalize-options.d.ts +1 -1
- package/lib/normalize-options.js +18 -44
- package/lib/normalize-options.js.map +1 -1
- package/lib/npm/call-npm-cli.d.ts +1 -0
- package/lib/npm/call-npm-cli.js +15 -42
- package/lib/npm/call-npm-cli.js.map +1 -1
- package/lib/npm/index.js +2 -18
- package/lib/npm/index.js.map +1 -1
- package/lib/npm/use-npm-environment.d.ts +1 -1
- package/lib/npm/use-npm-environment.js +14 -22
- package/lib/npm/use-npm-environment.js.map +1 -1
- package/lib/npm-publish.js +10 -14
- package/lib/npm-publish.js.map +1 -1
- package/lib/options.js +4 -7
- package/lib/options.js.map +1 -1
- package/lib/read-manifest.js +27 -53
- package/lib/read-manifest.js.map +1 -1
- package/lib/results.d.ts +1 -1
- package/lib/results.js +2 -5
- package/lib/results.js.map +1 -1
- package/package.json +39 -42
- package/src/action/core.ts +7 -8
- package/src/action/main.ts +4 -4
- package/src/cli/index.ts +1 -1
- package/src/cli/parse-cli-arguments.ts +1 -0
- package/src/compare-and-publish/compare-and-publish.ts +12 -7
- package/src/compare-and-publish/compare-versions.ts +2 -2
- package/src/compare-and-publish/get-arguments.ts +4 -1
- package/src/errors.ts +1 -1
- package/src/format-publish-result.ts +1 -1
- package/src/index.ts +1 -1
- package/src/normalize-options.ts +13 -8
- package/src/npm/call-npm-cli.ts +14 -12
- package/src/npm/use-npm-environment.ts +11 -12
- package/src/npm-publish.ts +3 -3
- package/src/read-manifest.ts +16 -9
- package/src/results.ts +2 -1
- package/src/tar.d.ts +0 -3
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPublishArguments = exports.getViewArguments = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Given a package name and publish configuration, get the NPM CLI view
|
|
6
3
|
* arguments.
|
|
@@ -12,13 +9,12 @@ exports.getPublishArguments = exports.getViewArguments = void 0;
|
|
|
12
9
|
* @returns Arguments to pass to the NPM CLI. If `retryWithTag` is true, but the
|
|
13
10
|
* publish config is using the `latest` tag, will return `undefined`.
|
|
14
11
|
*/
|
|
15
|
-
function getViewArguments(packageName, options, retryWithTag = false) {
|
|
12
|
+
export function getViewArguments(packageName, options, retryWithTag = false) {
|
|
16
13
|
const packageSpec = retryWithTag
|
|
17
14
|
? `${packageName}@${options.tag.value}`
|
|
18
15
|
: packageName;
|
|
19
16
|
return [packageSpec, "dist-tags", "versions"];
|
|
20
17
|
}
|
|
21
|
-
exports.getViewArguments = getViewArguments;
|
|
22
18
|
/**
|
|
23
19
|
* Given a publish configuration, get the NPM CLI publish arguments.
|
|
24
20
|
*
|
|
@@ -26,7 +22,7 @@ exports.getViewArguments = getViewArguments;
|
|
|
26
22
|
* @param options Publish configuration.
|
|
27
23
|
* @returns Arguments to pass to the NPM CLI.
|
|
28
24
|
*/
|
|
29
|
-
function getPublishArguments(packageSpec, options) {
|
|
25
|
+
export function getPublishArguments(packageSpec, options) {
|
|
30
26
|
const { tag, access, dryRun, provenance } = options;
|
|
31
27
|
const publishArguments = [];
|
|
32
28
|
if (packageSpec.length > 0) {
|
|
@@ -42,9 +38,11 @@ function getPublishArguments(packageSpec, options) {
|
|
|
42
38
|
publishArguments.push("--provenance");
|
|
43
39
|
}
|
|
44
40
|
if (!dryRun.isDefault && dryRun.value) {
|
|
45
|
-
|
|
41
|
+
// NOTE: `--force` does not override `--dry-run`,
|
|
42
|
+
// but does bypass package existence check in npm >=11
|
|
43
|
+
// because we do our own existence checks separately
|
|
44
|
+
publishArguments.push("--dry-run", "--force");
|
|
46
45
|
}
|
|
47
46
|
return publishArguments;
|
|
48
47
|
}
|
|
49
|
-
exports.getPublishArguments = getPublishArguments;
|
|
50
48
|
//# sourceMappingURL=get-arguments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-arguments.js","sourceRoot":"","sources":["../../src/compare-and-publish/get-arguments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-arguments.js","sourceRoot":"","sources":["../../src/compare-and-publish/get-arguments.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAAmB,EACnB,OAA0B,EAC1B,YAAY,GAAG,KAAK;IAEpB,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC,GAAG,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;QACvC,CAAC,CAAC,WAAW,CAAC;IAEhB,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,WAAmB,EACnB,OAA0B;IAE1B,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,gBAAgB,GAAG,EAAE,CAAC;IAE5B,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACnB,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACtC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QAC9C,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACtC,iDAAiD;QACjD,sDAAsD;QACtD,oDAAoD;QACpD,gBAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./compare-and-publish.js"), exports);
|
|
1
|
+
export * from "./compare-and-publish.js";
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compare-and-publish/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compare-and-publish/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/lib/errors.js
CHANGED
|
@@ -1,121 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.NpmCallError = exports.InvalidStrategyError = exports.InvalidAccessError = exports.InvalidTagError = exports.InvalidTokenError = exports.InvalidRegistryUrlError = exports.InvalidPackagePublishConfigError = exports.InvalidPackageVersionError = exports.InvalidPackageNameError = exports.PackageJsonParseError = exports.PackageTarballReadError = exports.PackageJsonReadError = exports.InvalidPackageError = void 0;
|
|
7
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
8
|
-
const options_js_1 = require("./options.js");
|
|
9
|
-
class InvalidPackageError extends TypeError {
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import { ACCESS_PUBLIC, ACCESS_RESTRICTED, STRATEGY_ALL, STRATEGY_UPGRADE, } from "./options.js";
|
|
3
|
+
export class InvalidPackageError extends TypeError {
|
|
10
4
|
constructor(value) {
|
|
11
5
|
super(`Package must be a directory, package.json, or .tgz file, got "${String(value)}"`);
|
|
12
6
|
this.name = "PackageJsonReadError";
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
class PackageJsonReadError extends Error {
|
|
9
|
+
export class PackageJsonReadError extends Error {
|
|
17
10
|
constructor(manifestPath, originalError) {
|
|
18
11
|
const message = [
|
|
19
12
|
`Could not read package.json at ${manifestPath}`,
|
|
20
13
|
originalError instanceof Error ? originalError.message : "",
|
|
21
14
|
]
|
|
22
15
|
.filter(Boolean)
|
|
23
|
-
.join(
|
|
16
|
+
.join(os.EOL);
|
|
24
17
|
super(message);
|
|
25
18
|
this.name = "PackageJsonReadError";
|
|
26
19
|
}
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
class PackageTarballReadError extends Error {
|
|
21
|
+
export class PackageTarballReadError extends Error {
|
|
30
22
|
constructor(tarballPath, originalError) {
|
|
31
23
|
const message = [
|
|
32
24
|
`Could not read package.json from ${tarballPath}`,
|
|
33
25
|
originalError instanceof Error ? originalError.message : "",
|
|
34
26
|
]
|
|
35
27
|
.filter(Boolean)
|
|
36
|
-
.join(
|
|
28
|
+
.join(os.EOL);
|
|
37
29
|
super(message);
|
|
38
30
|
this.name = "PackageTarballReadError";
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
|
-
|
|
42
|
-
class PackageJsonParseError extends SyntaxError {
|
|
33
|
+
export class PackageJsonParseError extends SyntaxError {
|
|
43
34
|
constructor(packageSpec, originalError) {
|
|
44
35
|
const message = [
|
|
45
36
|
`Invalid JSON, could not parse package.json for ${packageSpec}`,
|
|
46
37
|
originalError instanceof Error ? originalError.message : "",
|
|
47
38
|
]
|
|
48
39
|
.filter(Boolean)
|
|
49
|
-
.join(
|
|
40
|
+
.join(os.EOL);
|
|
50
41
|
super(message);
|
|
51
42
|
this.name = "PackageJsonParseError";
|
|
52
43
|
}
|
|
53
44
|
}
|
|
54
|
-
|
|
55
|
-
class InvalidPackageNameError extends TypeError {
|
|
45
|
+
export class InvalidPackageNameError extends TypeError {
|
|
56
46
|
constructor(value) {
|
|
57
|
-
super(`Package name
|
|
47
|
+
super(`Package name is not valid, got "${String(value)}"`);
|
|
58
48
|
this.name = "InvalidPackageNameError";
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
|
-
|
|
62
|
-
class InvalidPackageVersionError extends TypeError {
|
|
51
|
+
export class InvalidPackageVersionError extends TypeError {
|
|
63
52
|
constructor(value) {
|
|
64
53
|
super(`Package version must be a valid semantic version, got "${String(value)}"`);
|
|
65
54
|
this.name = "InvalidPackageVersionError";
|
|
66
55
|
}
|
|
67
56
|
}
|
|
68
|
-
|
|
69
|
-
class InvalidPackagePublishConfigError extends TypeError {
|
|
57
|
+
export class InvalidPackagePublishConfigError extends TypeError {
|
|
70
58
|
constructor(value) {
|
|
71
59
|
super(`Publish config must be an object, got "${String(value)}"`);
|
|
72
60
|
this.name = "InvalidPackagePublishConfigError";
|
|
73
61
|
}
|
|
74
62
|
}
|
|
75
|
-
|
|
76
|
-
class InvalidRegistryUrlError extends TypeError {
|
|
63
|
+
export class InvalidRegistryUrlError extends TypeError {
|
|
77
64
|
constructor(value) {
|
|
78
65
|
super(`Registry URL invalid, got "${String(value)}"`);
|
|
79
66
|
this.name = "InvalidRegistryUrlError";
|
|
80
67
|
}
|
|
81
68
|
}
|
|
82
|
-
|
|
83
|
-
class InvalidTokenError extends TypeError {
|
|
69
|
+
export class InvalidTokenError extends TypeError {
|
|
84
70
|
constructor() {
|
|
85
71
|
super("Token must be a non-empty string.");
|
|
86
72
|
this.name = "InvalidTokenError";
|
|
87
73
|
}
|
|
88
74
|
}
|
|
89
|
-
|
|
90
|
-
class InvalidTagError extends TypeError {
|
|
75
|
+
export class InvalidTagError extends TypeError {
|
|
91
76
|
constructor(value) {
|
|
92
77
|
super(`Tag must be a non-empty string, got "${String(value)}".`);
|
|
93
78
|
this.name = "InvalidTagError";
|
|
94
79
|
}
|
|
95
80
|
}
|
|
96
|
-
|
|
97
|
-
class InvalidAccessError extends TypeError {
|
|
81
|
+
export class InvalidAccessError extends TypeError {
|
|
98
82
|
constructor(value) {
|
|
99
|
-
super(`Access must be "${
|
|
83
|
+
super(`Access must be "${ACCESS_PUBLIC}" or "${ACCESS_RESTRICTED}", got "${String(value)}".`);
|
|
100
84
|
this.name = "InvalidAccessError";
|
|
101
85
|
}
|
|
102
86
|
}
|
|
103
|
-
|
|
104
|
-
class InvalidStrategyError extends TypeError {
|
|
87
|
+
export class InvalidStrategyError extends TypeError {
|
|
105
88
|
constructor(value) {
|
|
106
|
-
super(`Strategy must be "${
|
|
89
|
+
super(`Strategy must be "${STRATEGY_UPGRADE}" or "${STRATEGY_ALL}", got "${String(value)}".`);
|
|
107
90
|
this.name = "InvalidStrategyError";
|
|
108
91
|
}
|
|
109
92
|
}
|
|
110
|
-
|
|
111
|
-
class NpmCallError extends Error {
|
|
93
|
+
export class NpmCallError extends Error {
|
|
112
94
|
constructor(command, exitCode, stderr) {
|
|
113
95
|
super([
|
|
114
96
|
`Call to "npm ${command}" exited with non-zero exit code ${exitCode}`,
|
|
115
97
|
stderr,
|
|
116
|
-
].join(
|
|
98
|
+
].join(os.EOL));
|
|
117
99
|
this.name = "NpmCallError";
|
|
118
100
|
}
|
|
119
101
|
}
|
|
120
|
-
exports.NpmCallError = NpmCallError;
|
|
121
102
|
//# sourceMappingURL=errors.js.map
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ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ChC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,YAAmB,KAAc;QAC/B,KAAK,CACH,mBAAmB,aAAa,SAAS,iBAAiB,WAAW,MAAM,CACzE,KAAK,CACN,IAAI,CACN,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IACjD,YAAmB,KAAc;QAC/B,KAAK,CACH,qBAAqB,gBAAgB,SAAS,YAAY,WAAW,MAAM,CACzE,KAAK,CACN,IAAI,CACN,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAmB,OAAe,EAAE,QAAgB,EAAE,MAAc;QAClE,KAAK,CACH;YACE,gBAAgB,OAAO,oCAAoC,QAAQ,EAAE;YACrE,MAAM;SACP,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CACf,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PublishResult } from "./compare-and-publish/index.js";
|
|
2
|
-
import type { PackageManifest } from "./read-manifest.js";
|
|
3
2
|
import type { NormalizedOptions } from "./normalize-options.js";
|
|
3
|
+
import type { PackageManifest } from "./read-manifest.js";
|
|
4
4
|
/**
|
|
5
5
|
* Format publish results into a string.
|
|
6
6
|
*
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.formatPublishResult = void 0;
|
|
7
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
1
|
+
import os from "node:os";
|
|
8
2
|
const DRY_RUN_BANNER = "=== DRY RUN === DRY RUN === DRY RUN === DRY RUN === DRY RUN ===";
|
|
9
3
|
const CONTENTS_BANNER = "=== Contents ===";
|
|
10
4
|
/**
|
|
@@ -15,7 +9,7 @@ const CONTENTS_BANNER = "=== Contents ===";
|
|
|
15
9
|
* @param result Results from running npm publish.
|
|
16
10
|
* @returns Formatted string.
|
|
17
11
|
*/
|
|
18
|
-
function formatPublishResult(manifest, options, result) {
|
|
12
|
+
export function formatPublishResult(manifest, options, result) {
|
|
19
13
|
const lines = [];
|
|
20
14
|
lines.push(result.id === undefined
|
|
21
15
|
? `🙅♀️ ${manifest.name}@${manifest.version} already published.`
|
|
@@ -28,9 +22,8 @@ function formatPublishResult(manifest, options, result) {
|
|
|
28
22
|
}
|
|
29
23
|
return (options.dryRun.value
|
|
30
24
|
? [DRY_RUN_BANNER, "", ...lines, "", DRY_RUN_BANNER]
|
|
31
|
-
: lines).join(
|
|
25
|
+
: lines).join(os.EOL);
|
|
32
26
|
}
|
|
33
|
-
exports.formatPublishResult = formatPublishResult;
|
|
34
27
|
const formatSize = (size) => {
|
|
35
28
|
if (size < 1000) {
|
|
36
29
|
return `${size} B`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-publish-result.js","sourceRoot":"","sources":["../src/format-publish-result.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format-publish-result.js","sourceRoot":"","sources":["../src/format-publish-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAMzB,MAAM,cAAc,GAClB,iEAAiE,CAAC;AAEpE,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAyB,EACzB,OAA0B,EAC1B,MAAqB;IAErB,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,KAAK,CAAC,IAAI,CACR,MAAM,CAAC,EAAE,KAAK,SAAS;QACrB,CAAC,CAAC,SAAS,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,qBAAqB;QACjE,CAAC,CAAC,MAAM,MAAM,CAAC,EAAE,EAAE,CACtB,CAAC;IAEF,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1C,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,CACL,OAAO,CAAC,MAAM,CAAC,KAAK;QAClB,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,cAAc,CAAC;QACpD,CAAC,CAAC,KAAK,CACV,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE;IAC1C,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;QAChB,OAAO,GAAG,IAAI,IAAI,CAAC;IACrB,CAAC;IACD,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1C,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/C,CAAC,CAAC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,25 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.npmPublish = void 0;
|
|
18
1
|
// Export the external type definitions as named exports
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./options.js";
|
|
4
|
+
export * from "./results.js";
|
|
22
5
|
// Export `npmPublish` as a named export
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(exports, "npmPublish", { enumerable: true, get: function () { return npm_publish_js_1.npmPublish; } });
|
|
6
|
+
export { npmPublish } from "./npm-publish.js";
|
|
25
7
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type Access, type Logger, type Options, type Strategy } from "./options.js";
|
|
1
2
|
import type { PackageManifest } from "./read-manifest.js";
|
|
2
|
-
import { type Access, type Strategy, type Options, type Logger } from "./options.js";
|
|
3
3
|
export declare const TAG_LATEST = "latest";
|
|
4
4
|
/** Normalized and sanitized auth, publish, and runtime configurations. */
|
|
5
5
|
export interface NormalizedOptions {
|
package/lib/normalize-options.js
CHANGED
|
@@ -1,37 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.normalizeOptions = exports.TAG_LATEST = void 0;
|
|
30
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
31
|
-
const errors = __importStar(require("./errors.js"));
|
|
32
|
-
const options_js_1 = require("./options.js");
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import * as errors from "./errors.js";
|
|
3
|
+
import { ACCESS_PUBLIC, ACCESS_RESTRICTED, STRATEGY_ALL, STRATEGY_UPGRADE, } from "./options.js";
|
|
33
4
|
const REGISTRY_NPM = "https://registry.npmjs.org/";
|
|
34
|
-
|
|
5
|
+
export const TAG_LATEST = "latest";
|
|
35
6
|
/**
|
|
36
7
|
* Normalizes and sanitizes options, and fills-in any default values.
|
|
37
8
|
*
|
|
@@ -39,11 +10,11 @@ exports.TAG_LATEST = "latest";
|
|
|
39
10
|
* @param options User-input options.
|
|
40
11
|
* @returns Validated auth and publish configuration.
|
|
41
12
|
*/
|
|
42
|
-
function normalizeOptions(manifest, options) {
|
|
43
|
-
const defaultTag = manifest.publishConfig?.tag ??
|
|
13
|
+
export function normalizeOptions(manifest, options) {
|
|
14
|
+
const defaultTag = manifest.publishConfig?.tag ?? TAG_LATEST;
|
|
44
15
|
const defaultRegistry = manifest.publishConfig?.registry ?? REGISTRY_NPM;
|
|
45
16
|
const defaultAccess = manifest.publishConfig?.access ??
|
|
46
|
-
(manifest.scope === undefined ?
|
|
17
|
+
(manifest.scope === undefined ? ACCESS_PUBLIC : undefined);
|
|
47
18
|
const defaultProvenance = manifest.publishConfig?.provenance ?? false;
|
|
48
19
|
return {
|
|
49
20
|
token: validateToken(options.token),
|
|
@@ -53,12 +24,11 @@ function normalizeOptions(manifest, options) {
|
|
|
53
24
|
provenance: setValue(options.provenance, defaultProvenance, Boolean),
|
|
54
25
|
ignoreScripts: setValue(options.ignoreScripts, true, Boolean),
|
|
55
26
|
dryRun: setValue(options.dryRun, false, Boolean),
|
|
56
|
-
strategy: setValue(options.strategy,
|
|
27
|
+
strategy: setValue(options.strategy, STRATEGY_ALL, validateStrategy),
|
|
57
28
|
logger: options.logger,
|
|
58
|
-
temporaryDirectory: options.temporaryDirectory ??
|
|
29
|
+
temporaryDirectory: options.temporaryDirectory ?? os.tmpdir(),
|
|
59
30
|
};
|
|
60
31
|
}
|
|
61
|
-
exports.normalizeOptions = normalizeOptions;
|
|
62
32
|
const setValue = (value, defaultValue, validate) => ({
|
|
63
33
|
value: validate(value ?? defaultValue),
|
|
64
34
|
isDefault: value === undefined,
|
|
@@ -78,21 +48,25 @@ const validateRegistry = (value) => {
|
|
|
78
48
|
}
|
|
79
49
|
};
|
|
80
50
|
const validateTag = (value) => {
|
|
81
|
-
if (typeof value === "string"
|
|
82
|
-
|
|
51
|
+
if (typeof value === "string") {
|
|
52
|
+
const trimmedValue = value.trim();
|
|
53
|
+
const encodedValue = encodeURIComponent(trimmedValue);
|
|
54
|
+
if (trimmedValue.length > 0 && trimmedValue === encodedValue) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
83
57
|
}
|
|
84
58
|
throw new errors.InvalidTagError(value);
|
|
85
59
|
};
|
|
86
60
|
const validateAccess = (value) => {
|
|
87
61
|
if (value === undefined ||
|
|
88
|
-
value ===
|
|
89
|
-
value ===
|
|
62
|
+
value === ACCESS_PUBLIC ||
|
|
63
|
+
value === ACCESS_RESTRICTED) {
|
|
90
64
|
return value;
|
|
91
65
|
}
|
|
92
66
|
throw new errors.InvalidAccessError(value);
|
|
93
67
|
};
|
|
94
68
|
const validateStrategy = (value) => {
|
|
95
|
-
if (value ===
|
|
69
|
+
if (value === STRATEGY_ALL || value === STRATEGY_UPGRADE) {
|
|
96
70
|
return value;
|
|
97
71
|
}
|
|
98
72
|
throw new errors.InvalidStrategyError(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../src/normalize-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../src/normalize-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,KAAK,MAAM,MAAM,aAAa,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AC;AAC1C,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,KAAc,EAAsB,EAAE;IAC5D,IACE,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,aAAa;QACvB,KAAK,KAAK,iBAAiB,EAC3B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAY,EAAE;IACpD,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,gBAAgB,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|
|
@@ -25,6 +25,7 @@ export interface NpmPublishData {
|
|
|
25
25
|
export declare const VIEW = "view";
|
|
26
26
|
export declare const PUBLISH = "publish";
|
|
27
27
|
export declare const E404 = "E404";
|
|
28
|
+
export declare const E409 = "E409";
|
|
28
29
|
export declare const EPUBLISHCONFLICT = "EPUBLISHCONFLICT";
|
|
29
30
|
/**
|
|
30
31
|
* Call the NPM CLI in JSON mode.
|
package/lib/npm/call-npm-cli.js
CHANGED
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.callNpmCli = exports.EPUBLISHCONFLICT = exports.E404 = exports.PUBLISH = exports.VIEW = void 0;
|
|
30
|
-
const node_child_process_1 = __importDefault(require("node:child_process"));
|
|
31
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
32
|
-
const errors = __importStar(require("../errors.js"));
|
|
33
|
-
exports.VIEW = "view";
|
|
34
|
-
exports.PUBLISH = "publish";
|
|
35
|
-
exports.E404 = "E404";
|
|
36
|
-
exports.EPUBLISHCONFLICT = "EPUBLISHCONFLICT";
|
|
37
|
-
const NPM = node_os_1.default.platform() === "win32" ? "npm.cmd" : "npm";
|
|
1
|
+
import childProcess from "node:child_process";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import * as errors from "../errors.js";
|
|
4
|
+
export const VIEW = "view";
|
|
5
|
+
export const PUBLISH = "publish";
|
|
6
|
+
export const E404 = "E404";
|
|
7
|
+
export const E409 = "E409";
|
|
8
|
+
export const EPUBLISHCONFLICT = "EPUBLISHCONFLICT";
|
|
9
|
+
const IS_WINDOWS = os.platform() === "win32";
|
|
10
|
+
const NPM = IS_WINDOWS ? "npm.cmd" : "npm";
|
|
38
11
|
const JSON_MATCH_RE = /(\{[\s\S]*\})/mu;
|
|
39
12
|
const baseArguments = (options) => options.ignoreScripts ? ["--ignore-scripts", "--json"] : ["--json"];
|
|
40
13
|
/**
|
|
@@ -45,7 +18,7 @@ const baseArguments = (options) => options.ignoreScripts ? ["--ignore-scripts",
|
|
|
45
18
|
* @param options Customize environment variables or add an error handler.
|
|
46
19
|
* @returns The parsed JSON, or stdout if unparsable.
|
|
47
20
|
*/
|
|
48
|
-
async function callNpmCli(command, cliArguments, options) {
|
|
21
|
+
export async function callNpmCli(command, cliArguments, options) {
|
|
49
22
|
const { stdout, stderr, exitCode } = await execNpm([command, ...baseArguments(options), ...cliArguments], options.environment, options.logger);
|
|
50
23
|
let successData;
|
|
51
24
|
let errorCode;
|
|
@@ -55,14 +28,13 @@ async function callNpmCli(command, cliArguments, options) {
|
|
|
55
28
|
}
|
|
56
29
|
else {
|
|
57
30
|
const errorPayload = parseJson(stdout, stderr);
|
|
58
|
-
if (errorPayload?.error?.code) {
|
|
59
|
-
errorCode =
|
|
31
|
+
if (typeof errorPayload?.error?.code === "string") {
|
|
32
|
+
errorCode = errorPayload.error.code.toUpperCase();
|
|
60
33
|
}
|
|
61
34
|
error = new errors.NpmCallError(command, exitCode, stderr);
|
|
62
35
|
}
|
|
63
36
|
return { successData, errorCode, error };
|
|
64
37
|
}
|
|
65
|
-
exports.callNpmCli = callNpmCli;
|
|
66
38
|
/**
|
|
67
39
|
* Execute the npm CLI.
|
|
68
40
|
*
|
|
@@ -76,8 +48,9 @@ async function execNpm(commandArguments, environment, logger) {
|
|
|
76
48
|
return new Promise((resolve) => {
|
|
77
49
|
let stdout = "";
|
|
78
50
|
let stderr = "";
|
|
79
|
-
const npm =
|
|
51
|
+
const npm = childProcess.spawn(NPM, commandArguments, {
|
|
80
52
|
env: { ...process.env, ...environment },
|
|
53
|
+
shell: IS_WINDOWS,
|
|
81
54
|
});
|
|
82
55
|
npm.stdout.on("data", (data) => (stdout += data));
|
|
83
56
|
npm.stderr.on("data", (data) => (stderr += data));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-npm-cli.js","sourceRoot":"","sources":["../../src/npm/call-npm-cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"call-npm-cli.js","sourceRoot":"","sources":["../../src/npm/call-np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,CAAC,IAAI,EAAE,EAAE;YACvB,MAAM,EAAE,KAAK,EAAE,CAAC,oBAAoB,MAAM,EAAE,CAAC,CAAC;YAC9C,MAAM,EAAE,KAAK,EAAE,CAAC,oBAAoB,MAAM,EAAE,CAAC,CAAC;YAE9C,OAAO,CAAC;gBACN,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;gBACrB,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;gBACrB,QAAQ,EAAE,IAAI,IAAI,CAAC;aACpB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,SAAS,CAAC,GAAG,MAAgB;IACpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAEjD,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/lib/npm/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./call-npm-cli.js"), exports);
|
|
18
|
-
__exportStar(require("./use-npm-environment.js"), exports);
|
|
1
|
+
export * from "./call-npm-cli.js";
|
|
2
|
+
export * from "./use-npm-environment.js";
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/lib/npm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/npm/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/npm/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PackageManifest } from "../read-manifest.js";
|
|
2
1
|
import type { NormalizedOptions } from "../normalize-options.js";
|
|
2
|
+
import type { PackageManifest } from "../read-manifest.js";
|
|
3
3
|
export type NpmCliEnvironment = Record<string, string>;
|
|
4
4
|
export type NpmCliTask<TReturn> = (manifest: PackageManifest, options: NormalizedOptions, environment: NpmCliEnvironment) => Promise<TReturn>;
|
|
5
5
|
/**
|