@jsdevtools/npm-publish 1.4.3 → 2.1.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 +174 -147
- package/bin/npm-publish.js +10 -2
- package/lib/action/core.d.ts +45 -0
- package/lib/action/core.js +59 -0
- package/lib/action/core.js.map +1 -0
- package/lib/action/main.js +55 -0
- package/lib/action/main.js.map +1 -0
- package/lib/cli/index.d.ts +4 -2
- package/lib/cli/index.js +60 -53
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/parse-cli-arguments.d.ts +17 -0
- package/lib/cli/parse-cli-arguments.js +40 -0
- package/lib/cli/parse-cli-arguments.js.map +1 -0
- package/lib/compare-and-publish/compare-and-publish.d.ts +21 -0
- package/lib/compare-and-publish/compare-and-publish.js +49 -0
- package/lib/compare-and-publish/compare-and-publish.js.map +1 -0
- package/lib/compare-and-publish/compare-versions.d.ts +16 -0
- package/lib/compare-and-publish/compare-versions.js +41 -0
- package/lib/compare-and-publish/compare-versions.js.map +1 -0
- package/lib/compare-and-publish/get-arguments.d.ts +21 -0
- package/lib/compare-and-publish/get-arguments.js +50 -0
- package/lib/compare-and-publish/get-arguments.js.map +1 -0
- package/lib/compare-and-publish/index.d.ts +1 -0
- package/lib/compare-and-publish/index.js +18 -0
- package/lib/compare-and-publish/index.js.map +1 -0
- package/lib/errors.d.ts +39 -0
- package/lib/errors.js +121 -0
- package/lib/errors.js.map +1 -0
- package/lib/format-publish-result.d.ts +12 -0
- package/lib/format-publish-result.js +36 -0
- package/lib/format-publish-result.js.map +1 -0
- package/lib/index.d.ts +4 -5
- package/lib/index.js +11 -10
- package/lib/index.js.map +1 -1
- package/lib/normalize-options.d.ts +28 -1
- package/lib/normalize-options.js +89 -14
- package/lib/normalize-options.js.map +1 -1
- package/lib/npm/call-npm-cli.d.ts +38 -0
- package/lib/npm/call-npm-cli.js +113 -0
- package/lib/npm/call-npm-cli.js.map +1 -0
- package/lib/npm/index.d.ts +2 -0
- package/lib/npm/index.js +19 -0
- package/lib/npm/index.js.map +1 -0
- package/lib/npm/use-npm-environment.d.ts +15 -0
- package/lib/npm/use-npm-environment.js +44 -0
- package/lib/npm/use-npm-environment.js.map +1 -0
- package/lib/npm-publish.d.ts +7 -4
- package/lib/npm-publish.js +25 -26
- package/lib/npm-publish.js.map +1 -1
- package/lib/options.d.ts +67 -44
- package/lib/options.js +5 -0
- package/lib/options.js.map +1 -1
- package/lib/read-manifest.d.ts +22 -1
- package/lib/read-manifest.js +122 -22
- package/lib/read-manifest.js.map +1 -1
- package/lib/results.d.ts +30 -28
- package/lib/results.js +3 -0
- package/lib/results.js.map +1 -1
- package/package.json +47 -35
- package/src/action/core.ts +91 -0
- package/src/action/main.ts +32 -0
- package/src/cli/index.ts +72 -0
- package/src/cli/parse-cli-arguments.ts +49 -0
- package/src/compare-and-publish/compare-and-publish.ts +75 -0
- package/src/compare-and-publish/compare-versions.ts +48 -0
- package/src/compare-and-publish/get-arguments.ts +61 -0
- package/src/compare-and-publish/index.ts +1 -0
- package/src/errors.ts +137 -0
- package/src/format-publish-result.ts +40 -0
- package/src/index.ts +7 -0
- package/src/normalize-options.ts +123 -0
- package/src/npm/call-npm-cli.ts +140 -0
- package/src/npm/index.ts +2 -0
- package/src/npm/use-npm-environment.ts +57 -0
- package/src/npm-publish.ts +40 -0
- package/src/options.ts +108 -0
- package/src/read-manifest.ts +142 -0
- package/src/results.ts +50 -0
- package/CHANGELOG.md +0 -49
- package/lib/action/index.js +0 -67
- package/lib/action/index.js.map +0 -1
- package/lib/cli/exit-code.d.ts +0 -1
- package/lib/cli/exit-code.js +0 -16
- package/lib/cli/exit-code.js.map +0 -1
- package/lib/cli/help.d.ts +0 -1
- package/lib/cli/help.js +0 -28
- package/lib/cli/help.js.map +0 -1
- package/lib/cli/parse-args.d.ts +0 -1
- package/lib/cli/parse-args.js +0 -58
- package/lib/cli/parse-args.js.map +0 -1
- package/lib/npm-config.d.ts +0 -1
- package/lib/npm-config.js +0 -85
- package/lib/npm-config.js.map +0 -1
- package/lib/npm-env.d.ts +0 -6
- package/lib/npm-env.js +0 -24
- package/lib/npm-env.js.map +0 -1
- package/lib/npm.d.ts +0 -1
- package/lib/npm.js +0 -95
- package/lib/npm.js.map +0 -1
- /package/lib/action/{index.d.ts → main.d.ts} +0 -0
package/lib/cli/index.js
CHANGED
|
@@ -1,64 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
exports.main = exports.USAGE = void 0;
|
|
4
|
+
const index_js_1 = require("../index.js");
|
|
5
|
+
const parse_cli_arguments_js_1 = require("./parse-cli-arguments.js");
|
|
6
|
+
exports.USAGE = `
|
|
7
|
+
Usage:
|
|
8
|
+
|
|
9
|
+
npm-publish <options> [package]
|
|
10
|
+
|
|
11
|
+
Arguments:
|
|
12
|
+
|
|
13
|
+
package The path to the package to publish.
|
|
14
|
+
May be a directory, package.json, or .tgz file.
|
|
15
|
+
Defaults to the package in the current directory.
|
|
16
|
+
|
|
17
|
+
Options:
|
|
18
|
+
|
|
19
|
+
--token <token> (Required) npm authentication token.
|
|
20
|
+
|
|
21
|
+
--registry <url> Registry to read from and write to.
|
|
22
|
+
Defaults to "https://registry.npmjs.org/".
|
|
23
|
+
|
|
24
|
+
--tag <tag> The distribution tag to check against and publish to.
|
|
25
|
+
Defaults to "latest".
|
|
26
|
+
|
|
27
|
+
--access <access> Package access, may be "public" or "restricted".
|
|
28
|
+
See npm documentation for details.
|
|
29
|
+
|
|
30
|
+
--provenance Publish with provenance statements.
|
|
31
|
+
See npm documentation for details.
|
|
32
|
+
|
|
33
|
+
--strategy <strategy> Publish strategy, may be "all" or "upgrade".
|
|
34
|
+
Defaults to "all", see documentation for details.
|
|
35
|
+
|
|
36
|
+
--dry-run Do not actually publish anything.
|
|
37
|
+
--quiet Only print errors.
|
|
38
|
+
--debug Print debug logs.
|
|
39
|
+
|
|
40
|
+
-v, --version Print the version number.
|
|
41
|
+
-h, --help Show usage text.
|
|
42
|
+
|
|
43
|
+
Examples:
|
|
44
|
+
|
|
45
|
+
$ npm-publish --token abc123 ./my-package
|
|
46
|
+
`;
|
|
10
47
|
/**
|
|
11
48
|
* The main entry point of the CLI
|
|
12
49
|
*
|
|
13
|
-
* @param
|
|
50
|
+
* @param argv - The list of argument strings passed to the program.
|
|
51
|
+
* @param version - The version of this program.
|
|
14
52
|
*/
|
|
15
|
-
async function main(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Parse the command-line arguments
|
|
21
|
-
let { help, version, options } = parse_args_1.parseArgs(args);
|
|
22
|
-
if (help) {
|
|
23
|
-
// Show the help text and exit
|
|
24
|
-
console.log(help_1.usageText);
|
|
25
|
-
process.exit(exit_code_1.ExitCode.Success);
|
|
26
|
-
}
|
|
27
|
-
else if (version) {
|
|
28
|
-
// Show the version number and exit
|
|
29
|
-
let manifest = await read_manifest_1.readManifest(path_1.join(__dirname, "../../package.json"));
|
|
30
|
-
console.log(manifest.version.toString());
|
|
31
|
-
process.exit(exit_code_1.ExitCode.Success);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
let results = await npm_publish_1.npmPublish(options);
|
|
35
|
-
if (!options.quiet) {
|
|
36
|
-
if (results.type === "none") {
|
|
37
|
-
console.log(`\n📦 ${results.package} v${results.version} is already published to NPM`);
|
|
38
|
-
}
|
|
39
|
-
else if (results.dryRun) {
|
|
40
|
-
console.log(`\n📦 ${results.package} v${results.version} was NOT actually published to NPM (dry run)`);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
console.log(`\n📦 Successfully published ${results.package} v${results.version} to NPM`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
53
|
+
async function main(argv, version) {
|
|
54
|
+
const cliArguments = (0, parse_cli_arguments_js_1.parseCliArguments)(argv);
|
|
55
|
+
if (cliArguments.help) {
|
|
56
|
+
console.info(exports.USAGE);
|
|
57
|
+
return;
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
if (cliArguments.version) {
|
|
60
|
+
console.info(version);
|
|
61
|
+
return;
|
|
50
62
|
}
|
|
63
|
+
const logger = {
|
|
64
|
+
error: console.error,
|
|
65
|
+
info: cliArguments.quiet === false ? console.info : undefined,
|
|
66
|
+
debug: cliArguments.debug === true ? console.debug : undefined,
|
|
67
|
+
};
|
|
68
|
+
await (0, index_js_1.npmPublish)({ ...cliArguments.options, logger });
|
|
51
69
|
}
|
|
52
70
|
exports.main = main;
|
|
53
|
-
/**
|
|
54
|
-
* Prints errors to the console
|
|
55
|
-
*/
|
|
56
|
-
function errorHandler(error) {
|
|
57
|
-
let message = error.message || String(error);
|
|
58
|
-
if (process.env.DEBUG || process.env.NODE_ENV === "development") {
|
|
59
|
-
message = error.stack || message;
|
|
60
|
-
}
|
|
61
|
-
console.error(message);
|
|
62
|
-
process.exit(exit_code_1.ExitCode.FatalError);
|
|
63
|
-
}
|
|
64
71
|
//# 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":";;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AAAA,0CAAsD;AACtD,qEAA6D;AAEhD,QAAA,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCpB,CAAC;AAEF;;;;;GAKG;AACI,KAAK,UAAU,IAAI,CAAC,IAAc,EAAE,OAAe;IACxD,MAAM,YAAY,GAAG,IAAA,0CAAiB,EAAC,IAAI,CAAC,CAAC;IAE7C,IAAI,YAAY,CAAC,IAAI,EAAE;QACrB,OAAO,CAAC,IAAI,CAAC,aAAK,CAAC,CAAC;QACpB,OAAO;KACR;IAED,IAAI,YAAY,CAAC,OAAO,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO;KACR;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,IAAA,qBAAU,EAAC,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AACxD,CAAC;AApBD,oBAoBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Wrapper module for command-line-args */
|
|
2
|
+
import type { Options } from "../options.js";
|
|
3
|
+
/** The parsed command-line arguments */
|
|
4
|
+
export interface ParsedArguments {
|
|
5
|
+
help?: boolean;
|
|
6
|
+
version?: boolean;
|
|
7
|
+
quiet?: boolean;
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
options: Options;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse the given command-line arguments.
|
|
13
|
+
*
|
|
14
|
+
* @param argv The list of argument strings passed to the program.
|
|
15
|
+
* @returns A parsed object of options.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseCliArguments(argv: string[]): ParsedArguments;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Wrapper module for command-line-args */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
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"));
|
|
9
|
+
const ARGUMENTS_OPTIONS = [
|
|
10
|
+
{ name: "package", type: String, defaultOption: true },
|
|
11
|
+
{ name: "token", type: String },
|
|
12
|
+
{ name: "registry", type: String },
|
|
13
|
+
{ name: "tag", type: String },
|
|
14
|
+
{ name: "access", type: String },
|
|
15
|
+
{ name: "provenance", type: Boolean },
|
|
16
|
+
{ name: "strategy", type: String },
|
|
17
|
+
{ name: "dry-run", type: Boolean },
|
|
18
|
+
{ name: "quiet", type: Boolean },
|
|
19
|
+
{ name: "debug", type: Boolean },
|
|
20
|
+
{ name: "version", alias: "v", type: Boolean },
|
|
21
|
+
{ name: "help", alias: "h", type: Boolean },
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Parse the given command-line arguments.
|
|
25
|
+
*
|
|
26
|
+
* @param argv The list of argument strings passed to the program.
|
|
27
|
+
* @returns A parsed object of options.
|
|
28
|
+
*/
|
|
29
|
+
function parseCliArguments(argv) {
|
|
30
|
+
const { help, version, quiet, debug, ...options } = (0, command_line_args_1.default)(ARGUMENTS_OPTIONS, { argv, camelCase: true });
|
|
31
|
+
return {
|
|
32
|
+
help: Boolean(help),
|
|
33
|
+
version: Boolean(version),
|
|
34
|
+
quiet: Boolean(quiet),
|
|
35
|
+
debug: Boolean(debug),
|
|
36
|
+
options: options,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.parseCliArguments = parseCliArguments;
|
|
40
|
+
//# sourceMappingURL=parse-cli-arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-cli-arguments.js","sourceRoot":"","sources":["../../src/cli/parse-cli-arguments.ts"],"names":[],"mappings":";AAAA,2CAA2C;;;;;;AAE3C,0EAAgD;AAGhD,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI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AbD,8CAaC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PackageManifest } from "../read-manifest.js";
|
|
2
|
+
import type { NormalizedOptions } from "../normalize-options.js";
|
|
3
|
+
import { type NpmCliEnvironment } from "../npm/index.js";
|
|
4
|
+
import { type VersionComparison } from "./compare-versions.js";
|
|
5
|
+
export interface PublishResult extends VersionComparison {
|
|
6
|
+
id: string | undefined;
|
|
7
|
+
files: PublishFile[];
|
|
8
|
+
}
|
|
9
|
+
export interface PublishFile {
|
|
10
|
+
path: string;
|
|
11
|
+
size: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the currently published versions of a package and publish if needed.
|
|
15
|
+
*
|
|
16
|
+
* @param manifest The package to potentially publish.
|
|
17
|
+
* @param options Configuration options.
|
|
18
|
+
* @param environment Environment variables for the npm cli.
|
|
19
|
+
* @returns Information about the publish, including if it occurred.
|
|
20
|
+
*/
|
|
21
|
+
export declare function compareAndPublish(manifest: PackageManifest, options: NormalizedOptions, environment: NpmCliEnvironment): Promise<PublishResult>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareAndPublish = void 0;
|
|
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");
|
|
7
|
+
/**
|
|
8
|
+
* Get the currently published versions of a package and publish if needed.
|
|
9
|
+
*
|
|
10
|
+
* @param manifest The package to potentially publish.
|
|
11
|
+
* @param options Configuration options.
|
|
12
|
+
* @param environment Environment variables for the npm cli.
|
|
13
|
+
* @returns Information about the publish, including if it occurred.
|
|
14
|
+
*/
|
|
15
|
+
async function compareAndPublish(manifest, options, environment) {
|
|
16
|
+
const { name, version, packageSpec } = manifest;
|
|
17
|
+
const cliOptions = { environment, logger: options.logger };
|
|
18
|
+
const viewArguments = (0, get_arguments_js_1.getViewArguments)(name, options);
|
|
19
|
+
const publishArguments = (0, get_arguments_js_1.getPublishArguments)(packageSpec, options);
|
|
20
|
+
let viewCall = await (0, index_js_1.callNpmCli)(index_js_1.VIEW, viewArguments, cliOptions);
|
|
21
|
+
// `npm view` will succeed with no output the package exists in the registry
|
|
22
|
+
// with no `latest` tag. This is only possible with third-party registries.
|
|
23
|
+
// https://github.com/npm/cli/issues/6408
|
|
24
|
+
if (!viewCall.successData && !viewCall.error) {
|
|
25
|
+
// Retry the call to `npm view` with the configured publish tag,
|
|
26
|
+
// to at least try to get something.
|
|
27
|
+
const viewWithTagArguments = (0, get_arguments_js_1.getViewArguments)(name, options, true);
|
|
28
|
+
viewCall = await (0, index_js_1.callNpmCli)(index_js_1.VIEW, viewWithTagArguments, cliOptions);
|
|
29
|
+
}
|
|
30
|
+
if (viewCall.error && viewCall.errorCode !== index_js_1.E404) {
|
|
31
|
+
throw viewCall.error;
|
|
32
|
+
}
|
|
33
|
+
const comparison = (0, compare_versions_js_1.compareVersions)(version, viewCall.successData, options);
|
|
34
|
+
const publishCall = comparison.type
|
|
35
|
+
? await (0, index_js_1.callNpmCli)(index_js_1.PUBLISH, publishArguments, cliOptions)
|
|
36
|
+
: { successData: undefined, errorCode: undefined, error: undefined };
|
|
37
|
+
if (publishCall.error && publishCall.errorCode !== index_js_1.EPUBLISHCONFLICT) {
|
|
38
|
+
throw publishCall.error;
|
|
39
|
+
}
|
|
40
|
+
const { successData: publishData } = publishCall;
|
|
41
|
+
return {
|
|
42
|
+
id: publishData?.id,
|
|
43
|
+
files: publishData?.files ?? [],
|
|
44
|
+
type: publishData ? comparison.type : undefined,
|
|
45
|
+
oldVersion: comparison.oldVersion,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.compareAndPublish = compareAndPublish;
|
|
49
|
+
//# sourceMappingURL=compare-and-publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-and-publish.js","sour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AO,EAAE,gBAAgB,EAAE,UAAU,CAAC;QACzD,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAEvE,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,SAAS,KAAK,2BAAgB,EAAE;QACnE,MAAM,WAAW,CAAC,KAAK,CAAC;KACzB;IAED,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;IAEjD,OAAO;QACL,EAAE,EAAE,WAAW,EAAE,EAAE;QACnB,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;AA3CD,8CA2CC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { NormalizedOptions } from "../normalize-options.js";
|
|
2
|
+
import type { ReleaseType } from "../results.js";
|
|
3
|
+
import type { NpmViewData } from "../npm/index.js";
|
|
4
|
+
export interface VersionComparison {
|
|
5
|
+
type: ReleaseType | undefined;
|
|
6
|
+
oldVersion: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Compare previously published versions with the package's current version.
|
|
10
|
+
*
|
|
11
|
+
* @param currentVersion The current package version.
|
|
12
|
+
* @param publishedVersions The versions that have already been published.
|
|
13
|
+
* @param options Configuration options
|
|
14
|
+
* @returns The release type and previous version.
|
|
15
|
+
*/
|
|
16
|
+
export declare function compareVersions(currentVersion: string, publishedVersions: NpmViewData | undefined, options: NormalizedOptions): VersionComparison;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
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.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 INITIAL = "initial";
|
|
12
|
+
const DIFFERENT = "different";
|
|
13
|
+
/**
|
|
14
|
+
* Compare previously published versions with the package's current version.
|
|
15
|
+
*
|
|
16
|
+
* @param currentVersion The current package version.
|
|
17
|
+
* @param publishedVersions The versions that have already been published.
|
|
18
|
+
* @param options Configuration options
|
|
19
|
+
* @returns The release type and previous version.
|
|
20
|
+
*/
|
|
21
|
+
function compareVersions(currentVersion, publishedVersions, options) {
|
|
22
|
+
const { versions, "dist-tags": tags } = publishedVersions ?? {};
|
|
23
|
+
const { strategy, tag: publishTag } = options;
|
|
24
|
+
const oldVersion = (0, valid_js_1.default)(tags?.[publishTag.value]) ?? undefined;
|
|
25
|
+
const isUnique = !versions?.includes(currentVersion);
|
|
26
|
+
let type;
|
|
27
|
+
if (isUnique) {
|
|
28
|
+
if (!oldVersion) {
|
|
29
|
+
type = INITIAL;
|
|
30
|
+
}
|
|
31
|
+
else if ((0, gt_js_1.default)(currentVersion, oldVersion)) {
|
|
32
|
+
type = (0, diff_js_1.default)(currentVersion, oldVersion) ?? DIFFERENT;
|
|
33
|
+
}
|
|
34
|
+
else if (strategy.value === options_js_1.STRATEGY_ALL) {
|
|
35
|
+
type = DIFFERENT;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { type, oldVersion };
|
|
39
|
+
}
|
|
40
|
+
exports.compareVersions = compareVersions;
|
|
41
|
+
//# sourceMappingURL=compare-versions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-versions.js","sourceRoot":"","sources":["../../src/compare-and-publish/compare-versions.ts"],"names":[],"mappings":";;;;;;AAAA,uEAAwD;AACxD,mEAAuD;AACvD,yEAAoD;AAEpD,8CAA6C;AAU7C,MAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,MAAM,SAAS,GAAG,WAAW,CAAC;AAE9B;;;;;;;GAOG;AACH,SAAgB,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,IAAA,kBAAW,EAAC,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;QACZ,IAAI,CAAC,UAAU,EAAE;YACf,IAAI,GAAG,OAAO,CAAC;SAChB;aAAM,IAAI,IAAA,eAAiB,EAAC,cAAc,EAAE,UAAU,CAAC,EAAE;YACxD,IAAI,GAAG,IAAA,iBAAgB,EAAC,cAAc,EAAE,UAAU,CAAC,IAAI,SAAS,CAAC;SAClE;aAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,yBAAY,EAAE;YAC1C,IAAI,GAAG,SAAS,CAAC;SAClB;KACF;IAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,CAAC;AAtBD,0CAsBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NormalizedOptions } from "../normalize-options.js";
|
|
2
|
+
/**
|
|
3
|
+
* Given a package name and publish configuration, get the NPM CLI view
|
|
4
|
+
* arguments.
|
|
5
|
+
*
|
|
6
|
+
* @param packageName Package name.
|
|
7
|
+
* @param options Publish configuration.
|
|
8
|
+
* @param retryWithTag Include a non-latest tag in the package spec for a rety
|
|
9
|
+
* attempt.
|
|
10
|
+
* @returns Arguments to pass to the NPM CLI. If `retryWithTag` is true, but the
|
|
11
|
+
* publish config is using the `latest` tag, will return `undefined`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getViewArguments(packageName: string, options: NormalizedOptions, retryWithTag?: boolean): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Given a publish configuration, get the NPM CLI publish arguments.
|
|
16
|
+
*
|
|
17
|
+
* @param packageSpec Package specification path.
|
|
18
|
+
* @param options Publish configuration.
|
|
19
|
+
* @returns Arguments to pass to the NPM CLI.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getPublishArguments(packageSpec: string, options: NormalizedOptions): string[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPublishArguments = exports.getViewArguments = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Given a package name and publish configuration, get the NPM CLI view
|
|
6
|
+
* arguments.
|
|
7
|
+
*
|
|
8
|
+
* @param packageName Package name.
|
|
9
|
+
* @param options Publish configuration.
|
|
10
|
+
* @param retryWithTag Include a non-latest tag in the package spec for a rety
|
|
11
|
+
* attempt.
|
|
12
|
+
* @returns Arguments to pass to the NPM CLI. If `retryWithTag` is true, but the
|
|
13
|
+
* publish config is using the `latest` tag, will return `undefined`.
|
|
14
|
+
*/
|
|
15
|
+
function getViewArguments(packageName, options, retryWithTag = false) {
|
|
16
|
+
const packageSpec = retryWithTag
|
|
17
|
+
? `${packageName}@${options.tag.value}`
|
|
18
|
+
: packageName;
|
|
19
|
+
return [packageSpec, "dist-tags", "versions"];
|
|
20
|
+
}
|
|
21
|
+
exports.getViewArguments = getViewArguments;
|
|
22
|
+
/**
|
|
23
|
+
* Given a publish configuration, get the NPM CLI publish arguments.
|
|
24
|
+
*
|
|
25
|
+
* @param packageSpec Package specification path.
|
|
26
|
+
* @param options Publish configuration.
|
|
27
|
+
* @returns Arguments to pass to the NPM CLI.
|
|
28
|
+
*/
|
|
29
|
+
function getPublishArguments(packageSpec, options) {
|
|
30
|
+
const { tag, access, dryRun, provenance } = options;
|
|
31
|
+
const publishArguments = [];
|
|
32
|
+
if (packageSpec.length > 0) {
|
|
33
|
+
publishArguments.push(packageSpec);
|
|
34
|
+
}
|
|
35
|
+
if (!tag.isDefault) {
|
|
36
|
+
publishArguments.push("--tag", tag.value);
|
|
37
|
+
}
|
|
38
|
+
if (!access.isDefault && access.value) {
|
|
39
|
+
publishArguments.push("--access", access.value);
|
|
40
|
+
}
|
|
41
|
+
if (!provenance.isDefault && provenance.value) {
|
|
42
|
+
publishArguments.push("--provenance");
|
|
43
|
+
}
|
|
44
|
+
if (!dryRun.isDefault && dryRun.value) {
|
|
45
|
+
publishArguments.push("--dry-run");
|
|
46
|
+
}
|
|
47
|
+
return publishArguments;
|
|
48
|
+
}
|
|
49
|
+
exports.getPublishArguments = getPublishArguments;
|
|
50
|
+
//# sourceMappingURL=get-arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-arguments.js","sourceRoot":"","sources":["../../src/compare-and-publish/get-arguments.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,SAAgB,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;AAVD,4CAUC;AAED;;;;;;GAMG;AACH,SAAgB,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;QAC1B,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KACpC;IAED,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;QAClB,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;KAC3C;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,EAAE;QACrC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;KACjD;IAED,IAAI,CAAC,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,KAAK,EAAE;QAC7C,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;KACvC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,EAAE;QACrC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KACpC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AA5BD,kDA4BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./compare-and-publish.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
__exportStar(require("./compare-and-publish.js"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compare-and-publish/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare class InvalidPackageError extends TypeError {
|
|
2
|
+
constructor(value: unknown);
|
|
3
|
+
}
|
|
4
|
+
export declare class PackageJsonReadError extends Error {
|
|
5
|
+
constructor(manifestPath: string, originalError: unknown);
|
|
6
|
+
}
|
|
7
|
+
export declare class PackageTarballReadError extends Error {
|
|
8
|
+
constructor(tarballPath: string, originalError: unknown);
|
|
9
|
+
}
|
|
10
|
+
export declare class PackageJsonParseError extends SyntaxError {
|
|
11
|
+
constructor(packageSpec: string, originalError: unknown);
|
|
12
|
+
}
|
|
13
|
+
export declare class InvalidPackageNameError extends TypeError {
|
|
14
|
+
constructor(value: unknown);
|
|
15
|
+
}
|
|
16
|
+
export declare class InvalidPackageVersionError extends TypeError {
|
|
17
|
+
constructor(value: unknown);
|
|
18
|
+
}
|
|
19
|
+
export declare class InvalidPackagePublishConfigError extends TypeError {
|
|
20
|
+
constructor(value: unknown);
|
|
21
|
+
}
|
|
22
|
+
export declare class InvalidRegistryUrlError extends TypeError {
|
|
23
|
+
constructor(value: unknown);
|
|
24
|
+
}
|
|
25
|
+
export declare class InvalidTokenError extends TypeError {
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
export declare class InvalidTagError extends TypeError {
|
|
29
|
+
constructor(value: unknown);
|
|
30
|
+
}
|
|
31
|
+
export declare class InvalidAccessError extends TypeError {
|
|
32
|
+
constructor(value: unknown);
|
|
33
|
+
}
|
|
34
|
+
export declare class InvalidStrategyError extends TypeError {
|
|
35
|
+
constructor(value: unknown);
|
|
36
|
+
}
|
|
37
|
+
export declare class NpmCallError extends Error {
|
|
38
|
+
constructor(command: string, exitCode: number, stderr: string);
|
|
39
|
+
}
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
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.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 {
|
|
10
|
+
constructor(value) {
|
|
11
|
+
super(`Package must be a directory, package.json, or .tgz file, got "${String(value)}"`);
|
|
12
|
+
this.name = "PackageJsonReadError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.InvalidPackageError = InvalidPackageError;
|
|
16
|
+
class PackageJsonReadError extends Error {
|
|
17
|
+
constructor(manifestPath, originalError) {
|
|
18
|
+
const message = [
|
|
19
|
+
`Could not read package.json at ${manifestPath}`,
|
|
20
|
+
originalError instanceof Error ? originalError.message : "",
|
|
21
|
+
]
|
|
22
|
+
.filter(Boolean)
|
|
23
|
+
.join(node_os_1.default.EOL);
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = "PackageJsonReadError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.PackageJsonReadError = PackageJsonReadError;
|
|
29
|
+
class PackageTarballReadError extends Error {
|
|
30
|
+
constructor(tarballPath, originalError) {
|
|
31
|
+
const message = [
|
|
32
|
+
`Could not read package.json from ${tarballPath}`,
|
|
33
|
+
originalError instanceof Error ? originalError.message : "",
|
|
34
|
+
]
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.join(node_os_1.default.EOL);
|
|
37
|
+
super(message);
|
|
38
|
+
this.name = "PackageTarballReadError";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.PackageTarballReadError = PackageTarballReadError;
|
|
42
|
+
class PackageJsonParseError extends SyntaxError {
|
|
43
|
+
constructor(packageSpec, originalError) {
|
|
44
|
+
const message = [
|
|
45
|
+
`Invalid JSON, could not parse package.json for ${packageSpec}`,
|
|
46
|
+
originalError instanceof Error ? originalError.message : "",
|
|
47
|
+
]
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.join(node_os_1.default.EOL);
|
|
50
|
+
super(message);
|
|
51
|
+
this.name = "PackageJsonParseError";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.PackageJsonParseError = PackageJsonParseError;
|
|
55
|
+
class InvalidPackageNameError extends TypeError {
|
|
56
|
+
constructor(value) {
|
|
57
|
+
super(`Package name must be a string, got "${String(value)}"`);
|
|
58
|
+
this.name = "InvalidPackageNameError";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.InvalidPackageNameError = InvalidPackageNameError;
|
|
62
|
+
class InvalidPackageVersionError extends TypeError {
|
|
63
|
+
constructor(value) {
|
|
64
|
+
super(`Package version must be a string, got "${String(value)}"`);
|
|
65
|
+
this.name = "InvalidPackageVersionError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.InvalidPackageVersionError = InvalidPackageVersionError;
|
|
69
|
+
class InvalidPackagePublishConfigError extends TypeError {
|
|
70
|
+
constructor(value) {
|
|
71
|
+
super(`Publish config must be an object, got "${String(value)}"`);
|
|
72
|
+
this.name = "InvalidPackagePublishConfigError";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.InvalidPackagePublishConfigError = InvalidPackagePublishConfigError;
|
|
76
|
+
class InvalidRegistryUrlError extends TypeError {
|
|
77
|
+
constructor(value) {
|
|
78
|
+
super(`Registry URL invalid, got "${String(value)}"`);
|
|
79
|
+
this.name = "InvalidRegistryUrlError";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.InvalidRegistryUrlError = InvalidRegistryUrlError;
|
|
83
|
+
class InvalidTokenError extends TypeError {
|
|
84
|
+
constructor() {
|
|
85
|
+
super("Token must be a non-empty string.");
|
|
86
|
+
this.name = "InvalidTokenError";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.InvalidTokenError = InvalidTokenError;
|
|
90
|
+
class InvalidTagError extends TypeError {
|
|
91
|
+
constructor(value) {
|
|
92
|
+
super(`Tag must be a non-empty string, got "${String(value)}".`);
|
|
93
|
+
this.name = "InvalidTagError";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.InvalidTagError = InvalidTagError;
|
|
97
|
+
class InvalidAccessError extends TypeError {
|
|
98
|
+
constructor(value) {
|
|
99
|
+
super(`Access must be "${options_js_1.ACCESS_PUBLIC}" or "${options_js_1.ACCESS_RESTRICTED}", got "${String(value)}".`);
|
|
100
|
+
this.name = "InvalidAccessError";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.InvalidAccessError = InvalidAccessError;
|
|
104
|
+
class InvalidStrategyError extends TypeError {
|
|
105
|
+
constructor(value) {
|
|
106
|
+
super(`Strategy must be "${options_js_1.STRATEGY_UPGRADE}" or "${options_js_1.STRATEGY_ALL}", got "${String(value)}".`);
|
|
107
|
+
this.name = "InvalidStrategyError";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.InvalidStrategyError = InvalidStrategyError;
|
|
111
|
+
class NpmCallError extends Error {
|
|
112
|
+
constructor(command, exitCode, stderr) {
|
|
113
|
+
super([
|
|
114
|
+
`Call to "npm ${command}" exited with non-zero exit code ${exitCode}`,
|
|
115
|
+
stderr,
|
|
116
|
+
].join(node_os_1.default.EOL));
|
|
117
|
+
this.name = "NpmCallError";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.NpmCallError = NpmCallError;
|
|
121
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AAEzB,6CAKsB;AAEtB,MAAa,mBAAoB,SAAQ,SAAS;IAChD,YAAmB,KAAc;QAC/B,KAAK,CACH,iEAAiE,MAAM,CACrE,KAAK,CACN,GAAG,CACL,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AATD,kDASC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAmB,YAAoB,EAAE,aAAsB;QAC7D,MAAM,OAAO,GAAG;YACd,kCAAkC,YAAY,EAAE;YAChD,aAAa,YAAY,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;SAC5D;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,iBAAE,CAAC,GAAG,CAAC,CAAC;QAEhB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAZD,oDAYC;AAED,MAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAmB,WAAmB,EAAE,aAAsB;QAC5D,MAAM,OAAO,GAAG;YACd,oCAAoC,WAAW,EAAE;YACjD,aAAa,YAAY,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;SAC5D;aACE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{ PublishResult } from "./compare-and-publish/index.js";
|
|
2
|
+
import type { PackageManifest } from "./read-manifest.js";
|
|
3
|
+
import type { NormalizedOptions } from "./normalize-options.js";
|
|
4
|
+
/**
|
|
5
|
+
* Format publish results into a string.
|
|
6
|
+
*
|
|
7
|
+
* @param manifest Package manifest
|
|
8
|
+
* @param options Configuration options.
|
|
9
|
+
* @param result Results from running npm publish.
|
|
10
|
+
* @returns Formatted string.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatPublishResult(manifest: PackageManifest, options: NormalizedOptions, result: PublishResult): string;
|