@jsdevtools/npm-publish 2.2.0 → 2.2.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/README.md +28 -2
- package/lib/action/main.d.ts +2 -1
- package/lib/action/main.js +11 -1
- package/lib/action/main.js.map +1 -1
- package/lib/cli/index.d.ts +1 -1
- package/lib/cli/index.js +2 -2
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/npm/call-npm-cli.d.ts +3 -4
- package/lib/npm/call-npm-cli.js +5 -1
- package/lib/npm/call-npm-cli.js.map +1 -1
- package/lib/read-manifest.js +4 -4
- package/lib/read-manifest.js.map +1 -1
- package/package.json +29 -29
- package/src/action/main.ts +8 -1
- package/src/cli/index.ts +2 -2
- package/src/index.ts +1 -1
- package/src/npm/call-npm-cli.ts +11 -6
- package/src/read-manifest.ts +4 -4
package/README.md
CHANGED
|
@@ -131,8 +131,35 @@ jobs:
|
|
|
131
131
|
token: ${{ secrets.NPM_TOKEN }}
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
You can also publish to third-party registries. For example, to publish to the [GitHub Package Registry][], set `token` to `secrets.GITHUB_TOKEN` and `registry` to `https://npm.pkg.github.com`:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
on:
|
|
138
|
+
push:
|
|
139
|
+
branches: main
|
|
140
|
+
|
|
141
|
+
jobs:
|
|
142
|
+
publish:
|
|
143
|
+
runs-on: ubuntu-latest
|
|
144
|
+
permissions:
|
|
145
|
+
contents: read
|
|
146
|
+
packages: write # allow GITHUB_TOKEN to publish packages
|
|
147
|
+
steps:
|
|
148
|
+
- uses: actions/checkout@v3
|
|
149
|
+
- uses: actions/setup-node@v3
|
|
150
|
+
with:
|
|
151
|
+
node-version: "18"
|
|
152
|
+
- run: npm ci
|
|
153
|
+
- run: npm test
|
|
154
|
+
- uses: JS-DevTools/npm-publish@v2
|
|
155
|
+
with:
|
|
156
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
157
|
+
registry: "https://npm.pkg.github.com"
|
|
158
|
+
```
|
|
159
|
+
|
|
134
160
|
[workflow file]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions
|
|
135
161
|
[npm authentication token]: https://docs.npmjs.com/creating-and-viewing-authentication-tokens
|
|
162
|
+
[GitHub Package Registry]: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
|
|
136
163
|
|
|
137
164
|
### Usage
|
|
138
165
|
|
|
@@ -169,8 +196,7 @@ steps:
|
|
|
169
196
|
token: ${{ secrets.NPM_TOKEN }}
|
|
170
197
|
|
|
171
198
|
- if: ${{ steps.publish.outputs.type }}
|
|
172
|
-
run:
|
|
173
|
-
echo "Version changed!"
|
|
199
|
+
run: echo "Version changed!"
|
|
174
200
|
```
|
|
175
201
|
|
|
176
202
|
| Name | Type | Description |
|
package/lib/action/main.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/** Main action entry point. */
|
|
2
|
+
export declare function main(): Promise<void>;
|
package/lib/action/main.js
CHANGED
|
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.main = void 0;
|
|
26
27
|
/** Action entry point */
|
|
27
28
|
const index_js_1 = require("../index.js");
|
|
28
29
|
const core = __importStar(require("./core.js"));
|
|
@@ -52,5 +53,14 @@ async function run() {
|
|
|
52
53
|
core.setOutput("strategy", results.strategy);
|
|
53
54
|
core.setOutput("dry-run", results.dryRun);
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
/** Main action entry point. */
|
|
57
|
+
async function main() {
|
|
58
|
+
try {
|
|
59
|
+
await run();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
core.setFailed(error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.main = main;
|
|
56
66
|
//# sourceMappingURL=main.js.map
|
package/lib/action/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/action/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/action/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAyB;AACzB,0CAAyC;AACzC,gDAAkC;AAElC,sBAAsB;AACtB,KAAK,UAAU,GAAG;IAChB,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAU,EAAC;QAC/B,KAAK,EAAE,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC;QAC3C,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QACnC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QACjC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QACzB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC/B,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC;QAC9C,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QACnC,aAAa,EAAE,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC;QACrD,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC;QACvC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;KAC/C,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACzC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACtD,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACpD,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC;AAED,+BAA+B;AACxB,KAAK,UAAU,IAAI;IACxB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACvB;AACH,CAAC;AAND,oBAMC"}
|
package/lib/cli/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const USAGE = "\nUsage:\n\n npm-publish <options> [package]\n\nArguments:\n\n package The path to the package to publish.\n May be a directory, package.json, or .tgz file.\n Defaults to the package in the current directory.\n\nOptions:\n\n --token <token> (Required) npm authentication token.\n\n --registry <url> Registry to read from and write to.\n Defaults to \"https://registry.npmjs.org/\".\n\n --tag <tag> The distribution tag to check against and publish to.\n Defaults to \"latest\".\n\n --access <access> Package access, may be \"public\" or \"restricted\".\n See npm documentation for details.\n\n --provenance Publish with provenance statements.\n See npm documentation for details.\n\n --strategy <strategy> Publish strategy, may be \"all\" or \"upgrade\".\n Defaults to \"all\", see documentation for details.\n\n --ignore-scripts
|
|
1
|
+
export declare const USAGE = "\nUsage:\n\n npm-publish <options> [package]\n\nArguments:\n\n package The path to the package to publish.\n May be a directory, package.json, or .tgz file.\n Defaults to the package in the current directory.\n\nOptions:\n\n --token <token> (Required) npm authentication token.\n\n --registry <url> Registry to read from and write to.\n Defaults to \"https://registry.npmjs.org/\".\n\n --tag <tag> The distribution tag to check against and publish to.\n Defaults to \"latest\".\n\n --access <access> Package access, may be \"public\" or \"restricted\".\n See npm documentation for details.\n\n --provenance Publish with provenance statements.\n See npm documentation for details.\n\n --strategy <strategy> Publish strategy, may be \"all\" or \"upgrade\".\n Defaults to \"all\", see documentation for details.\n\n --no-ignore-scripts Allow lifecycle scripts, which are disabled by default\n as a security precaution. Defaults to false.\n\n --dry-run Do not actually publish anything.\n --quiet Only print errors.\n --debug Print debug logs.\n\n -v, --version Print the version number.\n -h, --help Show usage text.\n\nExamples:\n\n $ npm-publish --token abc123 ./my-package\n";
|
|
2
2
|
/**
|
|
3
3
|
* The main entry point of the CLI
|
|
4
4
|
*
|
package/lib/cli/index.js
CHANGED
|
@@ -33,8 +33,8 @@ Options:
|
|
|
33
33
|
--strategy <strategy> Publish strategy, may be "all" or "upgrade".
|
|
34
34
|
Defaults to "all", see documentation for details.
|
|
35
35
|
|
|
36
|
-
--ignore-scripts
|
|
37
|
-
Defaults to
|
|
36
|
+
--no-ignore-scripts Allow lifecycle scripts, which are disabled by default
|
|
37
|
+
as a security precaution. Defaults to false.
|
|
38
38
|
|
|
39
39
|
--dry-run Do not actually publish anything.
|
|
40
40
|
--quiet Only print errors.
|
package/lib/index.js
CHANGED
|
@@ -19,7 +19,7 @@ exports.npmPublish = void 0;
|
|
|
19
19
|
__exportStar(require("./options.js"), exports);
|
|
20
20
|
__exportStar(require("./results.js"), exports);
|
|
21
21
|
__exportStar(require("./errors.js"), exports);
|
|
22
|
-
// Export `npmPublish` as a named export
|
|
22
|
+
// Export `npmPublish` as a named export
|
|
23
23
|
var npm_publish_js_1 = require("./npm-publish.js");
|
|
24
24
|
Object.defineProperty(exports, "npmPublish", { enumerable: true, get: function () { return npm_publish_js_1.npmPublish; } });
|
|
25
25
|
//# 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":";;;;;;;;;;;;;;;;;AAAA,wDAAwD;AACxD,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B;AAE5B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wDAAwD;AACxD,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B;AAE5B,wCAAwC;AACxC,mDAA8C;AAArC,4GAAA,UAAU,OAAA"}
|
|
@@ -5,12 +5,12 @@ export interface NpmCliOptions {
|
|
|
5
5
|
ignoreScripts: boolean;
|
|
6
6
|
logger?: Logger | undefined;
|
|
7
7
|
}
|
|
8
|
-
export interface NpmCallResult<CommandT extends
|
|
8
|
+
export interface NpmCallResult<CommandT extends string> {
|
|
9
9
|
successData: SuccessData<CommandT> | undefined;
|
|
10
10
|
errorCode: string | undefined;
|
|
11
11
|
error: Error | undefined;
|
|
12
12
|
}
|
|
13
|
-
type SuccessData<T extends
|
|
13
|
+
type SuccessData<T extends string> = T extends typeof VIEW ? NpmViewData : T extends typeof PUBLISH ? NpmPublishData : unknown;
|
|
14
14
|
export interface NpmViewData {
|
|
15
15
|
"dist-tags": Record<string, string>;
|
|
16
16
|
versions: string[];
|
|
@@ -22,7 +22,6 @@ export interface NpmPublishData {
|
|
|
22
22
|
size: number;
|
|
23
23
|
}[];
|
|
24
24
|
}
|
|
25
|
-
export type Command = typeof VIEW | typeof PUBLISH | string;
|
|
26
25
|
export declare const VIEW = "view";
|
|
27
26
|
export declare const PUBLISH = "publish";
|
|
28
27
|
export declare const E404 = "E404";
|
|
@@ -35,5 +34,5 @@ export declare const EPUBLISHCONFLICT = "EPUBLISHCONFLICT";
|
|
|
35
34
|
* @param options Customize environment variables or add an error handler.
|
|
36
35
|
* @returns The parsed JSON, or stdout if unparsable.
|
|
37
36
|
*/
|
|
38
|
-
export declare function callNpmCli<CommandT extends
|
|
37
|
+
export declare function callNpmCli<CommandT extends string>(command: CommandT, cliArguments: string[], options: NpmCliOptions): Promise<NpmCallResult<CommandT>>;
|
|
39
38
|
export {};
|
package/lib/npm/call-npm-cli.js
CHANGED
|
@@ -55,7 +55,9 @@ async function callNpmCli(command, cliArguments, options) {
|
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
57
|
const errorPayload = parseJson(stdout, stderr);
|
|
58
|
-
|
|
58
|
+
if (errorPayload?.error?.code) {
|
|
59
|
+
errorCode = String(errorPayload.error.code).toUpperCase();
|
|
60
|
+
}
|
|
59
61
|
error = new errors.NpmCallError(command, exitCode, stderr);
|
|
60
62
|
}
|
|
61
63
|
return { successData, errorCode, error };
|
|
@@ -80,6 +82,8 @@ async function execNpm(commandArguments, environment, logger) {
|
|
|
80
82
|
npm.stdout.on("data", (data) => (stdout += data));
|
|
81
83
|
npm.stderr.on("data", (data) => (stderr += data));
|
|
82
84
|
npm.on("close", (code) => {
|
|
85
|
+
logger?.debug?.(`Received stdout: ${stdout}`);
|
|
86
|
+
logger?.debug?.(`Received stderr: ${stderr}`);
|
|
83
87
|
resolve({
|
|
84
88
|
stdout: stdout.trim(),
|
|
85
89
|
stderr: stderr.trim(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-npm-cli.js","sourceRoot":"","sources":["../../src/npm/call-npm-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA8C;AAC9C,sDAAyB;AAEzB,qDAAuC;
|
|
1
|
+
{"version":3,"file":"call-npm-cli.js","sourceRoot":"","sources":["../../src/npm/call-npm-cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA8C;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pB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,SAAS,CAAU,GAAG,MAAgB;IAC7C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAEjD,IAAI,SAAS,EAAE;YACb,IAAI;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAY,CAAC;aACzC;YAAC,MAAM;gBACN,OAAO,SAAS,CAAC;aAClB;SACF;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/lib/read-manifest.js
CHANGED
|
@@ -44,8 +44,8 @@ const isDirectory = (file) => {
|
|
|
44
44
|
const isTarball = (file) => {
|
|
45
45
|
return typeof file === "string" && node_path_1.default.extname(file) === TARBALL_EXTNAME;
|
|
46
46
|
};
|
|
47
|
-
const
|
|
48
|
-
return (0, semver_1.valid)(version)
|
|
47
|
+
const validateVersion = (version) => {
|
|
48
|
+
return (0, semver_1.valid)(version) ?? undefined;
|
|
49
49
|
};
|
|
50
50
|
const readPackageJson = async (...pathSegments) => {
|
|
51
51
|
const file = node_path_1.default.resolve(...pathSegments);
|
|
@@ -109,7 +109,7 @@ async function readManifest(packagePath) {
|
|
|
109
109
|
try {
|
|
110
110
|
manifestJson = JSON.parse(manifestContents);
|
|
111
111
|
name = manifestJson["name"];
|
|
112
|
-
version = manifestJson["version"];
|
|
112
|
+
version = validateVersion(manifestJson["version"]);
|
|
113
113
|
publishConfig = manifestJson["publishConfig"] ?? {};
|
|
114
114
|
}
|
|
115
115
|
catch (error) {
|
|
@@ -118,7 +118,7 @@ async function readManifest(packagePath) {
|
|
|
118
118
|
if (typeof name !== "string" || name.length === 0) {
|
|
119
119
|
throw new errors.InvalidPackageNameError(name);
|
|
120
120
|
}
|
|
121
|
-
if (
|
|
121
|
+
if (typeof version !== "string") {
|
|
122
122
|
throw new errors.InvalidPackageVersionError(version);
|
|
123
123
|
}
|
|
124
124
|
if (typeof publishConfig !== "object" ||
|
package/lib/read-manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-manifest.js","sourceRoot":"","sources":["../src/read-manifest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAkC;AAClC,0DAA6B;AAC7B,mCAA8C;AAC9C,6BAAsD;AAEtD,oDAAsC;AAmBtC,MAAM,QAAQ,GAAG,cAAc,CAAC;AAEhC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AACzC,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,MAAM,UAAU,GAAG,CAAC,IAAa,EAAkB,EAAE;IACnD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,mBAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,iBAAiB,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAa,EAAkB,EAAE;IACpD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AAC/D,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,IAAa,EAAkB,EAAE;IAClD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,eAAe,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,
|
|
1
|
+
{"version":3,"file":"read-manifest.js","sourceRoot":"","sources":["../src/read-manifest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAkC;AAClC,0DAA6B;AAC7B,mCAA8C;AAC9C,6BAAsD;AAEtD,oDAAsC;AAmBtC,MAAM,QAAQ,GAAG,cAAc,CAAC;AAEhC,MAAM,iBAAiB,GAAG,cAAc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|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsdevtools/npm-publish",
|
|
3
3
|
"description": "Fast, easy publishing to NPM",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github-action",
|
|
7
7
|
"npm",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "https://github.com/JS-DevTools/npm-publish.git"
|
|
21
21
|
},
|
|
22
|
+
"type": "commonjs",
|
|
22
23
|
"main": "lib/index.js",
|
|
23
24
|
"types": "lib/index.d.ts",
|
|
24
25
|
"bin": {
|
|
@@ -51,36 +52,35 @@
|
|
|
51
52
|
"provenance": true
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@actions/core": "^1.10.
|
|
55
|
-
"@types/command-line-args": "^5.
|
|
56
|
-
"@types/node": "^
|
|
57
|
-
"@types/tar": "^6.1.
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
59
|
-
"@typescript-eslint/parser": "^
|
|
60
|
-
"@vitest/coverage-istanbul": "^0.
|
|
61
|
-
"concurrently": "^8.
|
|
62
|
-
"esbuild": "^0.
|
|
63
|
-
"eslint": "^8.
|
|
64
|
-
"eslint-config-prettier": "^
|
|
65
|
-
"eslint-import-resolver-typescript": "^3.
|
|
66
|
-
"eslint-plugin-import": "npm:eslint-plugin-i@^2.
|
|
67
|
-
"eslint-plugin-jsdoc": "^
|
|
68
|
-
"eslint-plugin-n": "^16.
|
|
55
|
+
"@actions/core": "^1.10.1",
|
|
56
|
+
"@types/command-line-args": "^5.2.1",
|
|
57
|
+
"@types/node": "^20.6.0",
|
|
58
|
+
"@types/tar": "^6.1.6",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
60
|
+
"@typescript-eslint/parser": "^6.7.0",
|
|
61
|
+
"@vitest/coverage-istanbul": "^0.34.4",
|
|
62
|
+
"concurrently": "^8.2.1",
|
|
63
|
+
"esbuild": "^0.19.2",
|
|
64
|
+
"eslint": "^8.49.0",
|
|
65
|
+
"eslint-config-prettier": "^9.0.0",
|
|
66
|
+
"eslint-import-resolver-typescript": "^3.6.0",
|
|
67
|
+
"eslint-plugin-import": "npm:eslint-plugin-i@^2.28.1",
|
|
68
|
+
"eslint-plugin-jsdoc": "^46.6.0",
|
|
69
|
+
"eslint-plugin-n": "^16.1.0",
|
|
69
70
|
"eslint-plugin-promise": "^6.1.1",
|
|
70
|
-
"eslint-plugin-sonarjs": "^0.
|
|
71
|
-
"eslint-plugin-unicorn": "^
|
|
72
|
-
"prettier": "^
|
|
73
|
-
"prettier-plugin-jsdoc": "^0.
|
|
74
|
-
"rimraf": "^5.0.
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"vitest": "^0.31.4"
|
|
71
|
+
"eslint-plugin-sonarjs": "^0.21.0",
|
|
72
|
+
"eslint-plugin-unicorn": "^48.0.1",
|
|
73
|
+
"prettier": "^3.0.3",
|
|
74
|
+
"prettier-plugin-jsdoc": "^1.0.2",
|
|
75
|
+
"rimraf": "^5.0.1",
|
|
76
|
+
"typescript": "^5.2.2",
|
|
77
|
+
"vitest": "^0.34.4",
|
|
78
|
+
"vitest-when": "^0.1.2"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@types/semver": "^7.
|
|
82
|
-
"command-line-args": "^5.
|
|
83
|
-
"semver": "
|
|
84
|
-
"tar": "
|
|
81
|
+
"@types/semver": "^7.5.1",
|
|
82
|
+
"command-line-args": "^5.2.1",
|
|
83
|
+
"semver": "7.5.4",
|
|
84
|
+
"tar": "6.2.0"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/action/main.ts
CHANGED
|
@@ -30,4 +30,11 @@ async function run(): Promise<void> {
|
|
|
30
30
|
core.setOutput("dry-run", results.dryRun);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
/** Main action entry point. */
|
|
34
|
+
export async function main(): Promise<void> {
|
|
35
|
+
try {
|
|
36
|
+
await run();
|
|
37
|
+
} catch (error) {
|
|
38
|
+
core.setFailed(error);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/cli/index.ts
CHANGED
|
@@ -31,8 +31,8 @@ Options:
|
|
|
31
31
|
--strategy <strategy> Publish strategy, may be "all" or "upgrade".
|
|
32
32
|
Defaults to "all", see documentation for details.
|
|
33
33
|
|
|
34
|
-
--ignore-scripts
|
|
35
|
-
Defaults to
|
|
34
|
+
--no-ignore-scripts Allow lifecycle scripts, which are disabled by default
|
|
35
|
+
as a security precaution. Defaults to false.
|
|
36
36
|
|
|
37
37
|
--dry-run Do not actually publish anything.
|
|
38
38
|
--quiet Only print errors.
|
package/src/index.ts
CHANGED
package/src/npm/call-npm-cli.ts
CHANGED
|
@@ -11,13 +11,13 @@ export interface NpmCliOptions {
|
|
|
11
11
|
logger?: Logger | undefined;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export interface NpmCallResult<CommandT extends
|
|
14
|
+
export interface NpmCallResult<CommandT extends string> {
|
|
15
15
|
successData: SuccessData<CommandT> | undefined;
|
|
16
16
|
errorCode: string | undefined;
|
|
17
17
|
error: Error | undefined;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
type SuccessData<T extends
|
|
20
|
+
type SuccessData<T extends string> = T extends typeof VIEW
|
|
21
21
|
? NpmViewData
|
|
22
22
|
: T extends typeof PUBLISH
|
|
23
23
|
? NpmPublishData
|
|
@@ -32,7 +32,6 @@ export interface NpmPublishData {
|
|
|
32
32
|
files: { path: string; size: number }[];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export type Command = typeof VIEW | typeof PUBLISH | string;
|
|
36
35
|
export const VIEW = "view";
|
|
37
36
|
export const PUBLISH = "publish";
|
|
38
37
|
|
|
@@ -53,7 +52,7 @@ const baseArguments = (options: NpmCliOptions) =>
|
|
|
53
52
|
* @param options Customize environment variables or add an error handler.
|
|
54
53
|
* @returns The parsed JSON, or stdout if unparsable.
|
|
55
54
|
*/
|
|
56
|
-
export async function callNpmCli<CommandT extends
|
|
55
|
+
export async function callNpmCli<CommandT extends string>(
|
|
57
56
|
command: CommandT,
|
|
58
57
|
cliArguments: string[],
|
|
59
58
|
options: NpmCliOptions
|
|
@@ -71,12 +70,15 @@ export async function callNpmCli<CommandT extends Command>(
|
|
|
71
70
|
if (exitCode === 0) {
|
|
72
71
|
successData = parseJson<SuccessData<CommandT>>(stdout);
|
|
73
72
|
} else {
|
|
74
|
-
const errorPayload = parseJson<{ error?: { code?:
|
|
73
|
+
const errorPayload = parseJson<{ error?: { code?: unknown } }>(
|
|
75
74
|
stdout,
|
|
76
75
|
stderr
|
|
77
76
|
);
|
|
78
77
|
|
|
79
|
-
|
|
78
|
+
if (errorPayload?.error?.code) {
|
|
79
|
+
errorCode = String(errorPayload.error.code).toUpperCase();
|
|
80
|
+
}
|
|
81
|
+
|
|
80
82
|
error = new errors.NpmCallError(command, exitCode, stderr);
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -109,6 +111,9 @@ async function execNpm(
|
|
|
109
111
|
npm.stdout.on("data", (data) => (stdout += data));
|
|
110
112
|
npm.stderr.on("data", (data) => (stderr += data));
|
|
111
113
|
npm.on("close", (code) => {
|
|
114
|
+
logger?.debug?.(`Received stdout: ${stdout}`);
|
|
115
|
+
logger?.debug?.(`Received stderr: ${stderr}`);
|
|
116
|
+
|
|
112
117
|
resolve({
|
|
113
118
|
stdout: stdout.trim(),
|
|
114
119
|
stderr: stderr.trim(),
|
package/src/read-manifest.ts
CHANGED
|
@@ -39,8 +39,8 @@ const isTarball = (file: unknown): file is string => {
|
|
|
39
39
|
return typeof file === "string" && path.extname(file) === TARBALL_EXTNAME;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
return semverValid(version as string)
|
|
42
|
+
const validateVersion = (version: unknown): string | undefined => {
|
|
43
|
+
return semverValid(version as string) ?? undefined;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const readPackageJson = async (...pathSegments: string[]): Promise<string> => {
|
|
@@ -110,7 +110,7 @@ export async function readManifest(
|
|
|
110
110
|
try {
|
|
111
111
|
manifestJson = JSON.parse(manifestContents) as Record<string, unknown>;
|
|
112
112
|
name = manifestJson["name"];
|
|
113
|
-
version = manifestJson["version"];
|
|
113
|
+
version = validateVersion(manifestJson["version"]);
|
|
114
114
|
publishConfig = manifestJson["publishConfig"] ?? {};
|
|
115
115
|
} catch (error) {
|
|
116
116
|
throw new errors.PackageJsonParseError(packageSpec, error);
|
|
@@ -120,7 +120,7 @@ export async function readManifest(
|
|
|
120
120
|
throw new errors.InvalidPackageNameError(name);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
if (
|
|
123
|
+
if (typeof version !== "string") {
|
|
124
124
|
throw new errors.InvalidPackageVersionError(version);
|
|
125
125
|
}
|
|
126
126
|
|