@jsdevtools/npm-publish 3.1.1 → 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 +9 -16
- 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 +1 -1
- 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
package/README.md
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
Publish packages to npm automatically in GitHub Actions by updating the version number.
|
|
10
10
|
|
|
11
11
|
- [Change log][releases]
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
12
|
+
- [v3 to v4 migration guide](#v3-to-v4)
|
|
13
|
+
- [v2 to v4 migration guide](#v2-to-v4)
|
|
14
|
+
- [v1 to v4 migration guide](#v1-to-v4)
|
|
14
15
|
|
|
15
|
-
[releases]: https://github.com/JS-DevTools/npm-
|
|
16
|
+
[releases]: https://github.com/JS-DevTools/npm-publish/releases
|
|
16
17
|
|
|
17
18
|
## Features
|
|
18
19
|
|
|
@@ -54,13 +55,13 @@ jobs:
|
|
|
54
55
|
publish:
|
|
55
56
|
runs-on: ubuntu-latest
|
|
56
57
|
steps:
|
|
57
|
-
- uses: actions/checkout@
|
|
58
|
-
- uses: actions/setup-node@
|
|
58
|
+
- uses: actions/checkout@v5
|
|
59
|
+
- uses: actions/setup-node@v5
|
|
59
60
|
with:
|
|
60
|
-
node-version: "
|
|
61
|
+
node-version: "24"
|
|
61
62
|
- run: npm ci
|
|
62
63
|
- run: npm test
|
|
63
|
-
- uses: JS-DevTools/npm-publish@
|
|
64
|
+
- uses: JS-DevTools/npm-publish@v4
|
|
64
65
|
with:
|
|
65
66
|
token: ${{ secrets.NPM_TOKEN }}
|
|
66
67
|
```
|
|
@@ -79,13 +80,13 @@ jobs:
|
|
|
79
80
|
contents: read
|
|
80
81
|
packages: write # allow GITHUB_TOKEN to publish packages
|
|
81
82
|
steps:
|
|
82
|
-
- uses: actions/checkout@
|
|
83
|
-
- uses: actions/setup-node@
|
|
83
|
+
- uses: actions/checkout@v5
|
|
84
|
+
- uses: actions/setup-node@v5
|
|
84
85
|
with:
|
|
85
|
-
node-version: "
|
|
86
|
+
node-version: "24"
|
|
86
87
|
- run: npm ci
|
|
87
88
|
- run: npm test
|
|
88
|
-
- uses: JS-DevTools/npm-publish@
|
|
89
|
+
- uses: JS-DevTools/npm-publish@v4
|
|
89
90
|
with:
|
|
90
91
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
91
92
|
registry: "https://npm.pkg.github.com"
|
|
@@ -94,6 +95,7 @@ jobs:
|
|
|
94
95
|
[workflow file]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions
|
|
95
96
|
[npm authentication token]: https://docs.npmjs.com/creating-and-viewing-authentication-tokens
|
|
96
97
|
[GitHub Package Registry]: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
|
|
98
|
+
[good security practices]: https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions
|
|
97
99
|
|
|
98
100
|
### Action usage
|
|
99
101
|
|
|
@@ -124,7 +126,7 @@ npm-publish exposes several output variables, which you can use in later steps o
|
|
|
124
126
|
|
|
125
127
|
```diff
|
|
126
128
|
steps:
|
|
127
|
-
- uses: JS-DevTools/npm-publish@
|
|
129
|
+
- uses: JS-DevTools/npm-publish@v4
|
|
128
130
|
+ id: publish
|
|
129
131
|
with:
|
|
130
132
|
token: ${{ secrets.NPM_TOKEN }}
|
|
@@ -285,17 +287,29 @@ Examples:
|
|
|
285
287
|
Major releases of the action and libraries may contain breaking changes, documented here.
|
|
286
288
|
For more detailed change logs, see [releases][].
|
|
287
289
|
|
|
288
|
-
###
|
|
290
|
+
### v3 to v4
|
|
289
291
|
|
|
290
|
-
The
|
|
292
|
+
The `v4` release does not require any changes to how you use the `npm-publish` action from `v3`. The action was updated to Node 24 / npm 11.
|
|
293
|
+
|
|
294
|
+
In the library and CLI, support for Node 16 and Node 18 was dropped in `v4`, and the library API was switched to ESM-only. Library users should switch to ESM or update Node to a version with support for [loading ES modules using `require`][esm-require].
|
|
295
|
+
|
|
296
|
+
[esm-require]: https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require
|
|
297
|
+
|
|
298
|
+
### v2 to v4
|
|
299
|
+
|
|
300
|
+
The `v4` release does not require any changes to how you use the `npm-publish` action from `v2`. The action was updated to Node 20 in `v3` due to GitHub Action's [deprecation of Node 16][node16-deprecation], and then updated to Node 24 in `v4`.
|
|
301
|
+
|
|
302
|
+
In the library and CLI, support for Node 16 and Node 18 was dropped in `v4`, and the library API was switched to ESM-only. Library users should switch to ESM or update Node to a version with support for [loading ES modules using `require`][esm-require].
|
|
291
303
|
|
|
292
304
|
[node16-deprecation]: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
|
|
293
305
|
|
|
294
|
-
### v1 to
|
|
306
|
+
### v1 to v4
|
|
295
307
|
|
|
296
308
|
The v2 release made several breaking changes to inputs, outputs, and behaviors that were present in `v1`. The examples below focus on the action, but the same changes are applicable to the library and CLI, too.
|
|
297
309
|
|
|
298
|
-
|
|
310
|
+
In the library and CLI, support for Node 16 and Node 18 was dropped in `v4`, and the library API was switched to ESM-only. Library users should switch to ESM or update Node to a version with support for [loading ES modules using `require`][esm-require].
|
|
311
|
+
|
|
312
|
+
#### option changes
|
|
299
313
|
|
|
300
314
|
The `check-version` and `greater-version-only` boolean options were replaced with the `strategy` option:
|
|
301
315
|
|
|
@@ -319,9 +333,9 @@ The `check-version` and `greater-version-only` boolean options were replaced wit
|
|
|
319
333
|
`check-version: false` has been removed. If you only need to publish, without first checking whether the version exists in the registry, you can [use `npm` directly][publishing-nodejs-packages] instead:
|
|
320
334
|
|
|
321
335
|
```diff
|
|
322
|
-
- uses: actions/setup-node@
|
|
336
|
+
- uses: actions/setup-node@v5
|
|
323
337
|
with:
|
|
324
|
-
node-version: '
|
|
338
|
+
node-version: '24'
|
|
325
339
|
+ registry-url: https://registry.npmjs.org/
|
|
326
340
|
|
|
327
341
|
- - uses: JS-DevTools/npm-publish@v1
|
|
@@ -335,7 +349,7 @@ The `check-version` and `greater-version-only` boolean options were replaced wit
|
|
|
335
349
|
|
|
336
350
|
[publishing-nodejs-packages]: https://docs.github.com/actions/publishing-packages/publishing-nodejs-packages
|
|
337
351
|
|
|
338
|
-
####
|
|
352
|
+
#### output changes
|
|
339
353
|
|
|
340
354
|
The `type` output is now an empty string instead of `'none'` when no release occurs
|
|
341
355
|
|
|
@@ -345,7 +359,7 @@ The `type` output is now an empty string instead of `'none'` when no release occ
|
|
|
345
359
|
+ if: ${{ steps.publish.outputs.type }}
|
|
346
360
|
```
|
|
347
361
|
|
|
348
|
-
####
|
|
362
|
+
#### behavior changes
|
|
349
363
|
|
|
350
364
|
The `--ignore-scripts` option is now passed to `npm publish` as a security precaution. If you define any publish lifecycle scripts - `prepublishOnly`, `prepack`, `prepare`, `postpack`, `publish`, `postpublish` - we recommend you run that logic as a separate explicit build step.
|
|
351
365
|
|
|
@@ -353,7 +367,7 @@ The `--ignore-scripts` option is now passed to `npm publish` as a security preca
|
|
|
353
367
|
+ - run: npm run build
|
|
354
368
|
|
|
355
369
|
- - uses: JS-DevTools/npm-publish@v1
|
|
356
|
-
+ - uses: JS-DevTools/npm-publish@
|
|
370
|
+
+ - uses: JS-DevTools/npm-publish@v4
|
|
357
371
|
with:
|
|
358
372
|
token: ${{ secrets.NPM_TOKEN }}
|
|
359
373
|
```
|
|
@@ -362,7 +376,7 @@ If you can't change your build, you can set the `ignore-scripts` input to `false
|
|
|
362
376
|
|
|
363
377
|
```diff
|
|
364
378
|
- - uses: JS-DevTools/npm-publish@v1
|
|
365
|
-
+ - uses: JS-DevTools/npm-publish@
|
|
379
|
+
+ - uses: JS-DevTools/npm-publish@v4
|
|
366
380
|
with:
|
|
367
381
|
token: ${{ secrets.NPM_TOKEN }}
|
|
368
382
|
+ ignore-scripts: false
|
|
@@ -371,13 +385,13 @@ If you can't change your build, you can set the `ignore-scripts` input to `false
|
|
|
371
385
|
The global `.npmrc` file is no longer read nor modified. This means the `token` option is now required for the library and CLI. (It was already required for the action.) You may have workarounds in place referencing `INPUT_TOKEN`, which v1 [erroneously wrote][#15] to `.npmrc`. These workarounds should be removed.
|
|
372
386
|
|
|
373
387
|
```diff
|
|
374
|
-
- uses: actions/setup-node@
|
|
388
|
+
- uses: actions/setup-node@v5
|
|
375
389
|
with:
|
|
376
|
-
node-version: '
|
|
390
|
+
node-version: '24'
|
|
377
391
|
registry-url: https://registry.npmjs.org/
|
|
378
392
|
|
|
379
393
|
- - uses: JS-DevTools/npm-publish@v1
|
|
380
|
-
+ - uses: JS-DevTools/npm-publish@
|
|
394
|
+
+ - uses: JS-DevTools/npm-publish@v4
|
|
381
395
|
with:
|
|
382
396
|
token: ${{ secrets.NPM_TOKEN }}
|
|
383
397
|
|
package/bin/npm-publish.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import url from "node:url";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
const { version } = require("../package.json");
|
|
7
|
-
const { main } = require("../lib/cli/index.js");
|
|
7
|
+
import { main } from "../lib/cli/index.js";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
/** @type {{ version: string }} */
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
13
|
+
const { version } = JSON.parse(
|
|
14
|
+
fs.readFileSync(path.join(dirname, "../package.json"), "utf8")
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
await main(process.argv.slice(2), version);
|
|
19
|
+
} catch (error) {
|
|
10
20
|
console.error(error);
|
|
11
21
|
process.exitCode = 1;
|
|
12
|
-
}
|
|
22
|
+
}
|
package/lib/action/core.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const logger: Logger;
|
|
|
7
7
|
* @param name Input name
|
|
8
8
|
* @returns The input string value, or undefined if not set
|
|
9
9
|
*/
|
|
10
|
-
export declare function getInput
|
|
10
|
+
export declare function getInput(name: string): string | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* Get a required secret input by name.
|
|
13
13
|
*
|
package/lib/action/core.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setOutput = exports.setFailed = exports.getBooleanInput = exports.getRequiredSecretInput = exports.getInput = exports.logger = void 0;
|
|
4
1
|
/** Wrapper module for @actions/core */
|
|
5
|
-
|
|
2
|
+
import { debug as ghLogDebug, error as ghLogError, getInput as ghGetInput, info as ghLogInfo, setFailed as ghSetFailed, setOutput as ghSetOutput, setSecret as ghSetSecret, } from "@actions/core";
|
|
6
3
|
/** Logger using the methods from @actions/core. */
|
|
7
|
-
|
|
8
|
-
debug:
|
|
9
|
-
info:
|
|
10
|
-
error:
|
|
4
|
+
export const logger = {
|
|
5
|
+
debug: ghLogDebug,
|
|
6
|
+
info: ghLogInfo,
|
|
7
|
+
error: ghLogError,
|
|
11
8
|
};
|
|
12
9
|
/**
|
|
13
10
|
* Get input by name.
|
|
@@ -15,50 +12,44 @@ exports.logger = {
|
|
|
15
12
|
* @param name Input name
|
|
16
13
|
* @returns The input string value, or undefined if not set
|
|
17
14
|
*/
|
|
18
|
-
function getInput(name) {
|
|
19
|
-
const inputString = (
|
|
15
|
+
export function getInput(name) {
|
|
16
|
+
const inputString = ghGetInput(name);
|
|
20
17
|
return inputString.length > 0 ? inputString : undefined;
|
|
21
18
|
}
|
|
22
|
-
exports.getInput = getInput;
|
|
23
19
|
/**
|
|
24
20
|
* Get a required secret input by name.
|
|
25
21
|
*
|
|
26
22
|
* @param name Input name
|
|
27
23
|
* @returns The input secret value.
|
|
28
24
|
*/
|
|
29
|
-
function getRequiredSecretInput(name) {
|
|
30
|
-
const inputString = (
|
|
31
|
-
(
|
|
25
|
+
export function getRequiredSecretInput(name) {
|
|
26
|
+
const inputString = ghGetInput(name, { required: true });
|
|
27
|
+
ghSetSecret(inputString);
|
|
32
28
|
return inputString;
|
|
33
29
|
}
|
|
34
|
-
exports.getRequiredSecretInput = getRequiredSecretInput;
|
|
35
30
|
/**
|
|
36
31
|
* Get a boolean input by name.
|
|
37
32
|
*
|
|
38
33
|
* @param name Input name
|
|
39
34
|
* @returns True if value is "true", false if "false", undefined if unset
|
|
40
35
|
*/
|
|
41
|
-
function getBooleanInput(name) {
|
|
42
|
-
const inputString = (
|
|
36
|
+
export function getBooleanInput(name) {
|
|
37
|
+
const inputString = ghGetInput(name).toLowerCase();
|
|
43
38
|
if (inputString === "true")
|
|
44
39
|
return true;
|
|
45
40
|
if (inputString === "false")
|
|
46
41
|
return false;
|
|
47
42
|
return undefined;
|
|
48
43
|
}
|
|
49
|
-
exports.getBooleanInput = getBooleanInput;
|
|
50
44
|
/**
|
|
51
45
|
* Set the action as failed due to an error.
|
|
52
46
|
*
|
|
53
47
|
* @param error An value from a `catch`
|
|
54
48
|
*/
|
|
55
|
-
function setFailed(error) {
|
|
56
|
-
(
|
|
49
|
+
export function setFailed(error) {
|
|
50
|
+
ghSetFailed(error);
|
|
57
51
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
function setOutput(name, value, defaultValue) {
|
|
61
|
-
(0, core_1.setOutput)(name, value ?? defaultValue);
|
|
52
|
+
export function setOutput(name, value, defaultValue) {
|
|
53
|
+
ghSetOutput(name, value ?? defaultValue);
|
|
62
54
|
}
|
|
63
|
-
exports.setOutput = setOutput;
|
|
64
55
|
//# sourceMappingURL=core.js.map
|
package/lib/action/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/action/core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/action/core.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EACL,KAAK,IAAI,UAAU,EACnB,KAAK,IAAI,UAAU,EACnB,QAAQ,IAAI,UAAU,EACtB,IAAI,IAAI,SAAS,EACjB,SAAS,IAAI,WAAW,EACxB,SAAS,IAAI,WAAW,EACxB,SAAS,IAAI,WAAW,GACzB,MAAM,eAAe,CAAC;AAIvB,mDAAmD;AACnD,MAAM,CAAC,MAAM,MAAM,GAAW;IAC5B,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,WAAW,CAAC,WAAW,CAAC,CAAC;IACzB,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAEnD,IAAI,WAAW,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,WAAW,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,WAAW,CAAC,KAAc,CAAC,CAAC;AAC9B,CAAC;AAuBD,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,KAAmC,EACnC,YAA+B;IAE/B,WAAW,CAAC,IAAI,EAAE,KAAK,IAAI,YAAY,CAAC,CAAC;AAC3C,CAAC"}
|
package/lib/action/main.js
CHANGED
|
@@ -1,35 +1,9 @@
|
|
|
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 __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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.main = void 0;
|
|
27
1
|
/** Action entry point */
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
import { npmPublish } from "../index.js";
|
|
3
|
+
import * as core from "./core.js";
|
|
30
4
|
/** Run the action. */
|
|
31
5
|
async function run() {
|
|
32
|
-
const results = await
|
|
6
|
+
const results = await npmPublish({
|
|
33
7
|
token: core.getRequiredSecretInput("token"),
|
|
34
8
|
registry: core.getInput("registry"),
|
|
35
9
|
package: core.getInput("package"),
|
|
@@ -40,7 +14,7 @@ async function run() {
|
|
|
40
14
|
ignoreScripts: core.getBooleanInput("ignore-scripts"),
|
|
41
15
|
dryRun: core.getBooleanInput("dry-run"),
|
|
42
16
|
logger: core.logger,
|
|
43
|
-
temporaryDirectory: process.env
|
|
17
|
+
temporaryDirectory: process.env.RUNNER_TEMP,
|
|
44
18
|
});
|
|
45
19
|
core.setOutput("id", results.id, "");
|
|
46
20
|
core.setOutput("name", results.name);
|
|
@@ -54,7 +28,7 @@ async function run() {
|
|
|
54
28
|
core.setOutput("dry-run", results.dryRun);
|
|
55
29
|
}
|
|
56
30
|
/** Main action entry point. */
|
|
57
|
-
async function main() {
|
|
31
|
+
export async function main() {
|
|
58
32
|
try {
|
|
59
33
|
await run();
|
|
60
34
|
}
|
|
@@ -62,5 +36,4 @@ async function main() {
|
|
|
62
36
|
core.setFailed(error);
|
|
63
37
|
}
|
|
64
38
|
}
|
|
65
|
-
exports.main = main;
|
|
66
39
|
//# 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,OAAO,EAAe,UAAU,EAAiB,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,sBAAsB;AACtB,KAAK,UAAU,GAAG;IAChB,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC;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,CAAuB;QACrD,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC;QAC9C,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAyB;QAC3D,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,WAAW;KAC5C,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;AAC/B,MAAM,CAAC,KAAK,UAAU,IAAI;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;AACH,CAAC"}
|
package/lib/cli/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const index_js_1 = require("../index.js");
|
|
5
|
-
const parse_cli_arguments_js_1 = require("./parse-cli-arguments.js");
|
|
6
|
-
exports.USAGE = `
|
|
1
|
+
import { npmPublish } from "../index.js";
|
|
2
|
+
import { parseCliArguments } from "./parse-cli-arguments.js";
|
|
3
|
+
export const USAGE = `
|
|
7
4
|
Usage:
|
|
8
5
|
|
|
9
6
|
npm-publish <options> [package]
|
|
@@ -53,10 +50,10 @@ Examples:
|
|
|
53
50
|
* @param argv - The list of argument strings passed to the program.
|
|
54
51
|
* @param version - The version of this program.
|
|
55
52
|
*/
|
|
56
|
-
async function main(argv, version) {
|
|
57
|
-
const cliArguments =
|
|
53
|
+
export async function main(argv, version) {
|
|
54
|
+
const cliArguments = parseCliArguments(argv);
|
|
58
55
|
if (cliArguments.help) {
|
|
59
|
-
console.info(
|
|
56
|
+
console.info(USAGE);
|
|
60
57
|
return;
|
|
61
58
|
}
|
|
62
59
|
if (cliArguments.version) {
|
|
@@ -68,7 +65,6 @@ async function main(argv, version) {
|
|
|
68
65
|
info: cliArguments.quiet === false ? console.info : undefined,
|
|
69
66
|
debug: cliArguments.debug === true ? console.debug : undefined,
|
|
70
67
|
};
|
|
71
|
-
await
|
|
68
|
+
await npmPublish({ ...cliArguments.options, logger });
|
|
72
69
|
}
|
|
73
|
-
exports.main = main;
|
|
74
70
|
//# sourceMappingURL=index.js.map
|
package/lib/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAc,EAAE,OAAe;IACxD,MAAM,YAAY,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE7C,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO;IACT,CAAC;IAED,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAW;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,YAAY,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAC7D,KAAK,EAAE,YAAY,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;KAC/D,CAAC;IAEF,MAAM,UAAU,CAAC,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/** Wrapper module for command-line-args */
|
|
3
|
-
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.parseCliArguments = void 0;
|
|
8
|
-
const command_line_args_1 = __importDefault(require("command-line-args"));
|
|
2
|
+
import commandLineArgs from "command-line-args";
|
|
9
3
|
const ARGUMENTS_OPTIONS = [
|
|
10
4
|
{ name: "package", type: String, defaultOption: true },
|
|
11
5
|
{ name: "token", type: String },
|
|
@@ -27,8 +21,8 @@ const ARGUMENTS_OPTIONS = [
|
|
|
27
21
|
* @param argv The list of argument strings passed to the program.
|
|
28
22
|
* @returns A parsed object of options.
|
|
29
23
|
*/
|
|
30
|
-
function parseCliArguments(argv) {
|
|
31
|
-
const { help, version, quiet, debug, ...optionFlags } = (
|
|
24
|
+
export function parseCliArguments(argv) {
|
|
25
|
+
const { help, version, quiet, debug, ...optionFlags } = commandLineArgs(ARGUMENTS_OPTIONS, { argv, camelCase: true });
|
|
32
26
|
const options = Object.fromEntries(Object.entries(optionFlags).map(([key, value]) => {
|
|
33
27
|
return key === "noIgnoreScripts"
|
|
34
28
|
? ["ignoreScripts", !value]
|
|
@@ -42,5 +36,4 @@ function parseCliArguments(argv) {
|
|
|
42
36
|
options: options,
|
|
43
37
|
};
|
|
44
38
|
}
|
|
45
|
-
exports.parseCliArguments = parseCliArguments;
|
|
46
39
|
//# sourceMappingURL=parse-cli-arguments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cli-arguments.js","sourceRoot":"","sources":["../../src/cli/parse-cli-arguments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-cli-arguments.js","sourceRoot":"","sources":["../../src/cli/parse-cli-arguments.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAE3C,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAIhD,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE;IACtD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE;IAC/B,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE;IAClC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;IAC7B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE;IAChC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE;IACrC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE;IAClC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,EAAE;IAC5C,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE;IAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;IAChC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;IAChC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;IAC9C,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;CAC5C,CAAC;AAWF;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAc;IAC9C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,GAAG,eAAe,CACrE,iBAAiB,EACjB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAC1B,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAChC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC/C,OAAO,GAAG,KAAK,iBAAiB;YAC9B,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC,CACH,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;QACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC;QACrB,OAAO,EAAE,OAAkB;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PackageManifest } from "../read-manifest.js";
|
|
2
1
|
import type { NormalizedOptions } from "../normalize-options.js";
|
|
3
2
|
import { type NpmCliEnvironment } from "../npm/index.js";
|
|
3
|
+
import type { PackageManifest } from "../read-manifest.js";
|
|
4
4
|
import { type VersionComparison } from "./compare-versions.js";
|
|
5
5
|
export interface PublishResult extends VersionComparison {
|
|
6
6
|
id: string | undefined;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const index_js_1 = require("../npm/index.js");
|
|
5
|
-
const compare_versions_js_1 = require("./compare-versions.js");
|
|
6
|
-
const get_arguments_js_1 = require("./get-arguments.js");
|
|
1
|
+
import { callNpmCli, E404, E409, EPUBLISHCONFLICT, PUBLISH, VIEW, } from "../npm/index.js";
|
|
2
|
+
import { compareVersions } from "./compare-versions.js";
|
|
3
|
+
import { getPublishArguments, getViewArguments } from "./get-arguments.js";
|
|
7
4
|
/**
|
|
8
5
|
* Get the currently published versions of a package and publish if needed.
|
|
9
6
|
*
|
|
@@ -12,34 +9,36 @@ const get_arguments_js_1 = require("./get-arguments.js");
|
|
|
12
9
|
* @param environment Environment variables for the npm cli.
|
|
13
10
|
* @returns Information about the publish, including if it occurred.
|
|
14
11
|
*/
|
|
15
|
-
async function compareAndPublish(manifest, options, environment) {
|
|
12
|
+
export async function compareAndPublish(manifest, options, environment) {
|
|
16
13
|
const { name, version, packageSpec } = manifest;
|
|
17
14
|
const cliOptions = {
|
|
18
15
|
environment,
|
|
19
16
|
ignoreScripts: options.ignoreScripts.value,
|
|
20
17
|
logger: options.logger,
|
|
21
18
|
};
|
|
22
|
-
const viewArguments =
|
|
23
|
-
const publishArguments =
|
|
24
|
-
let viewCall = await
|
|
19
|
+
const viewArguments = getViewArguments(name, options);
|
|
20
|
+
const publishArguments = getPublishArguments(packageSpec, options);
|
|
21
|
+
let viewCall = await callNpmCli(VIEW, viewArguments, cliOptions);
|
|
25
22
|
// `npm view` will succeed with no output the package exists in the registry
|
|
26
23
|
// with no `latest` tag. This is only possible with third-party registries.
|
|
27
24
|
// https://github.com/npm/cli/issues/6408
|
|
28
25
|
if (!viewCall.successData && !viewCall.error) {
|
|
29
26
|
// Retry the call to `npm view` with the configured publish tag,
|
|
30
27
|
// to at least try to get something.
|
|
31
|
-
const viewWithTagArguments =
|
|
32
|
-
viewCall = await
|
|
28
|
+
const viewWithTagArguments = getViewArguments(name, options, true);
|
|
29
|
+
viewCall = await callNpmCli(VIEW, viewWithTagArguments, cliOptions);
|
|
33
30
|
}
|
|
34
|
-
if (viewCall.error && viewCall.errorCode !==
|
|
31
|
+
if (viewCall.error && viewCall.errorCode !== E404) {
|
|
35
32
|
throw viewCall.error;
|
|
36
33
|
}
|
|
37
34
|
const isDryRun = options.dryRun.value;
|
|
38
|
-
const comparison =
|
|
39
|
-
const publishCall = comparison.type ?? isDryRun
|
|
40
|
-
? await
|
|
35
|
+
const comparison = compareVersions(version, viewCall.successData, options);
|
|
36
|
+
const publishCall = (comparison.type ?? isDryRun)
|
|
37
|
+
? await callNpmCli(PUBLISH, publishArguments, cliOptions)
|
|
41
38
|
: { successData: undefined, errorCode: undefined, error: undefined };
|
|
42
|
-
if (publishCall.error &&
|
|
39
|
+
if (publishCall.error &&
|
|
40
|
+
publishCall.errorCode !== EPUBLISHCONFLICT &&
|
|
41
|
+
publishCall.errorCode !== E409) {
|
|
43
42
|
throw publishCall.error;
|
|
44
43
|
}
|
|
45
44
|
const { successData: publishData } = publishCall;
|
|
@@ -50,5 +49,4 @@ async function compareAndPublish(manifest, options, environment) {
|
|
|
50
49
|
oldVersion: comparison.oldVersion,
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
|
-
exports.compareAndPublish = compareAndPublish;
|
|
54
52
|
//# sourceMappingURL=compare-and-publish.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare-and-publish.js","sourceRoot":"","sources":["../../src/compare-and-publish/compare-and-publish.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compare-and-publish.js","sourceRoot":"","sources":["../../src/compare-and-publish/compare-and-publish.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,gBAAgB,EAEhB,OAAO,EACP,IAAI,GACL,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAA0B,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAY3E;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAyB,EACzB,OAA0B,EAC1B,WAA8B;IAE9B,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IAChD,MAAM,UAAU,GAAG;QACjB,WAAW;QACX,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK;QAC1C,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC;IAEF,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACnE,IAAI,QAAQ,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAEjE,4EAA4E;IAC5E,2EAA2E;IAC3E,yCAAyC;IACzC,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC7C,gEAAgE;QAChE,oCAAoC;QACpC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACnE,QAAQ,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,oBAAoB,EAAE,UAAU,CAAC,CAAC;IACtE,CAAC;IAED,IAAI,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAClD,MAAM,QAAQ,CAAC,KAAK,CAAC;IACvB,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IACtC,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3E,MAAM,WAAW,GACf,CAAC,UAAU,CAAC,IAAI,IAAI,QAAQ,CAAC;QAC3B,CAAC,CAAC,MAAM,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,CAAC;QACzD,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAEzE,IACE,WAAW,CAAC,KAAK;QACjB,WAAW,CAAC,SAAS,KAAK,gBAAgB;QAC1C,WAAW,CAAC,SAAS,KAAK,IAAI,EAC9B,CAAC;QACD,MAAM,WAAW,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;IAEjD,OAAO;QACL,EAAE,EAAE,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE;QAC9D,KAAK,EAAE,WAAW,EAAE,KAAK,IAAI,EAAE;QAC/B,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAC/C,UAAU,EAAE,UAAU,CAAC,UAAU;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NormalizedOptions } from "../normalize-options.js";
|
|
2
|
-
import { type ReleaseType } from "../results.js";
|
|
3
2
|
import type { NpmViewData } from "../npm/index.js";
|
|
3
|
+
import { type ReleaseType } from "../results.js";
|
|
4
4
|
export interface VersionComparison {
|
|
5
5
|
type: ReleaseType | undefined;
|
|
6
6
|
oldVersion: string | undefined;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.compareVersions = void 0;
|
|
7
|
-
const diff_js_1 = __importDefault(require("semver/functions/diff.js"));
|
|
8
|
-
const gt_js_1 = __importDefault(require("semver/functions/gt.js"));
|
|
9
|
-
const valid_js_1 = __importDefault(require("semver/functions/valid.js"));
|
|
10
|
-
const options_js_1 = require("../options.js");
|
|
11
|
-
const results_js_1 = require("../results.js");
|
|
1
|
+
import semverDifference from "semver/functions/diff.js";
|
|
2
|
+
import semverGreaterThan from "semver/functions/gt.js";
|
|
3
|
+
import semverValid from "semver/functions/valid.js";
|
|
4
|
+
import { STRATEGY_ALL } from "../options.js";
|
|
5
|
+
import { DIFFERENT, INITIAL } from "../results.js";
|
|
12
6
|
/**
|
|
13
7
|
* Compare previously published versions with the package's current version.
|
|
14
8
|
*
|
|
@@ -17,24 +11,23 @@ const results_js_1 = require("../results.js");
|
|
|
17
11
|
* @param options Configuration options
|
|
18
12
|
* @returns The release type and previous version.
|
|
19
13
|
*/
|
|
20
|
-
function compareVersions(currentVersion, publishedVersions, options) {
|
|
14
|
+
export function compareVersions(currentVersion, publishedVersions, options) {
|
|
21
15
|
const { versions, "dist-tags": tags } = publishedVersions ?? {};
|
|
22
16
|
const { strategy, tag: publishTag } = options;
|
|
23
|
-
const oldVersion = (
|
|
17
|
+
const oldVersion = semverValid(tags?.[publishTag.value]) ?? undefined;
|
|
24
18
|
const isUnique = !versions?.includes(currentVersion);
|
|
25
19
|
let type;
|
|
26
20
|
if (isUnique) {
|
|
27
21
|
if (!oldVersion) {
|
|
28
|
-
type =
|
|
22
|
+
type = INITIAL;
|
|
29
23
|
}
|
|
30
|
-
else if ((
|
|
31
|
-
type = (
|
|
24
|
+
else if (semverGreaterThan(currentVersion, oldVersion)) {
|
|
25
|
+
type = semverDifference(currentVersion, oldVersion) ?? DIFFERENT;
|
|
32
26
|
}
|
|
33
|
-
else if (strategy.value ===
|
|
34
|
-
type =
|
|
27
|
+
else if (strategy.value === STRATEGY_ALL) {
|
|
28
|
+
type = DIFFERENT;
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
31
|
return { type, oldVersion };
|
|
38
32
|
}
|
|
39
|
-
exports.compareVersions = compareVersions;
|
|
40
33
|
//# sourceMappingURL=compare-versions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare-versions.js","sourceRoot":"","sources":["../../src/compare-and-publish/compare-versions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compare-versions.js","sourceRoot":"","sources":["../../src/compare-and-publish/compare-versions.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,WAAW,MAAM,2BAA2B,CAAC;AAIpD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAoB,MAAM,eAAe,CAAC;AAOrE;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,cAAsB,EACtB,iBAA0C,EAC1C,OAA0B;IAE1B,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,iBAAiB,IAAI,EAAE,CAAC;IAChE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC9C,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC;IACtE,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;IACrD,IAAI,IAA6B,CAAC;IAElC,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,IAAI,GAAG,OAAO,CAAC;QACjB,CAAC;aAAM,IAAI,iBAAiB,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,CAAC;YACzD,IAAI,GAAG,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC,IAAI,SAAS,CAAC;QACnE,CAAC;aAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;YAC3C,IAAI,GAAG,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,CAAC"}
|