bumpp 10.4.1 → 11.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 +1 -0
- package/bin/bumpp.mjs +3 -3
- package/dist/cli.d.mts +3 -2
- package/dist/cli.mjs +120 -133
- package/dist/config-C6VUC_fF.mjs +5942 -0
- package/dist/index.d.mts +324 -289
- package/dist/index.mjs +5 -22
- package/package.json +25 -24
- package/dist/cli.d.ts +0 -7
- package/dist/index.d.ts +0 -386
- package/dist/shared/bumpp.Dvy0WV0b.mjs +0 -7138
package/README.md
CHANGED
package/bin/bumpp.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { main } from '../dist/cli.mjs'
|
|
3
|
+
|
|
4
|
+
main()
|
package/dist/cli.d.mts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,148 +1,135 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const version = "10.4.1";
|
|
28
|
-
|
|
1
|
+
import { c as isReleaseType, i as versionBump, l as symbols, r as loadBumpConfig, s as ProgressEvent, t as bumpConfigDefaults } from "./config-C6VUC_fF.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { styleText } from "node:util";
|
|
4
|
+
import { NonZeroExitError, x } from "tinyexec";
|
|
5
|
+
import { valid } from "semver";
|
|
6
|
+
import cac from "cac";
|
|
7
|
+
//#region src/cli/exit-code.ts
|
|
8
|
+
/**
|
|
9
|
+
* CLI exit codes.
|
|
10
|
+
*
|
|
11
|
+
* @see https://nodejs.org/api/process.html#process_exit_codes
|
|
12
|
+
*/
|
|
13
|
+
let ExitCode = /* @__PURE__ */ function(ExitCode) {
|
|
14
|
+
ExitCode[ExitCode["Success"] = 0] = "Success";
|
|
15
|
+
ExitCode[ExitCode["FatalError"] = 1] = "FatalError";
|
|
16
|
+
ExitCode[ExitCode["InvalidArgument"] = 9] = "InvalidArgument";
|
|
17
|
+
return ExitCode;
|
|
18
|
+
}({});
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region package.json
|
|
21
|
+
var version = "11.0.0";
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/cli/parse-args.ts
|
|
24
|
+
/**
|
|
25
|
+
* Parses the command-line arguments
|
|
26
|
+
*/
|
|
29
27
|
async function parseArgs() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
28
|
+
try {
|
|
29
|
+
const { args, resultArgs } = loadCliArgs();
|
|
30
|
+
const parsedArgs = {
|
|
31
|
+
help: args.help,
|
|
32
|
+
version: args.version,
|
|
33
|
+
quiet: args.quiet,
|
|
34
|
+
options: await loadBumpConfig({
|
|
35
|
+
preid: args.preid,
|
|
36
|
+
commit: args.commit,
|
|
37
|
+
tag: args.tag,
|
|
38
|
+
sign: args.sign,
|
|
39
|
+
push: args.push,
|
|
40
|
+
all: args.all,
|
|
41
|
+
noGitCheck: args.gitCheck === void 0 ? void 0 : !args.gitCheck,
|
|
42
|
+
confirm: args.yes === void 0 ? void 0 : !args.yes,
|
|
43
|
+
noVerify: args.verify === void 0 ? void 0 : !args.verify,
|
|
44
|
+
install: args.install,
|
|
45
|
+
files: [...args["--"] || [], ...resultArgs],
|
|
46
|
+
ignoreScripts: args.ignoreScripts,
|
|
47
|
+
currentVersion: args.currentVersion,
|
|
48
|
+
execute: args.execute,
|
|
49
|
+
printCommits: args.printCommits,
|
|
50
|
+
recursive: args.recursive,
|
|
51
|
+
release: args.release,
|
|
52
|
+
configFilePath: args.configFilePath
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
if (parsedArgs.options.files && parsedArgs.options.files.length > 0) {
|
|
56
|
+
const firstArg = parsedArgs.options.files[0];
|
|
57
|
+
if (firstArg === "prompt" || isReleaseType(firstArg) || valid(firstArg)) {
|
|
58
|
+
parsedArgs.options.release = firstArg;
|
|
59
|
+
parsedArgs.options.files.shift();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (parsedArgs.options.recursive && parsedArgs.options.files?.length) console.log(styleText("yellow", "The --recursive option is ignored when files are specified"));
|
|
63
|
+
return parsedArgs;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return errorHandler$1(error);
|
|
66
|
+
}
|
|
70
67
|
}
|
|
71
68
|
function loadCliArgs(argv = process.argv) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
};
|
|
69
|
+
const cli = cac("bumpp");
|
|
70
|
+
cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("-a, --all", `Include all files (default: ${bumpConfigDefaults.all})`).option("--git-check", `Run git check (default: ${!bumpConfigDefaults.noGitCheck})`).option("-c, --commit [msg]", `Commit message (default: ${bumpConfigDefaults.commit})`).option("-t, --tag [tag]", `Tag name (default: ${bumpConfigDefaults.tag})`).option("--sign", "Sign commit and tag").option("--install", `Run 'npm install' after bumping version (default: ${bumpConfigDefaults.install})`).option("-p, --push", `Push to remote (default: ${bumpConfigDefaults.push})`).option("-y, --yes", `Skip confirmation (default: ${!bumpConfigDefaults.confirm})`).option("-r, --recursive", `Bump package.json files recursively (default: ${bumpConfigDefaults.recursive})`).option("--verify", `Run git verification (default: ${!bumpConfigDefaults.noVerify})`).option("--ignore-scripts", `Ignore scripts (default: ${bumpConfigDefaults.ignoreScripts})`).option("-q, --quiet", "Quiet mode").option("--current-version <version>", "Current version").option("--print-commits", "Print recent commits").option("-x, --execute <command>", "Commands to execute after version bumps").option("--release <release>", `Release type or version number (e.g. 'major', 'minor', 'patch', 'prerelease', etc. default: ${bumpConfigDefaults.release})`).option("--configFilePath <configFilePath>", `Path to custom build.config file`).help();
|
|
71
|
+
const result = cli.parse(argv);
|
|
72
|
+
return {
|
|
73
|
+
args: result.options,
|
|
74
|
+
resultArgs: result.args
|
|
75
|
+
};
|
|
80
76
|
}
|
|
81
77
|
function errorHandler$1(error) {
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
console.error(error.message);
|
|
79
|
+
return process.exit(ExitCode.InvalidArgument);
|
|
84
80
|
}
|
|
85
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/cli/index.ts
|
|
83
|
+
/**
|
|
84
|
+
* The main entry point of the CLI
|
|
85
|
+
*/
|
|
86
86
|
async function main() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
} catch (error) {
|
|
102
|
-
errorHandler(error);
|
|
103
|
-
}
|
|
87
|
+
try {
|
|
88
|
+
process.on("uncaughtException", errorHandler);
|
|
89
|
+
process.on("unhandledRejection", errorHandler);
|
|
90
|
+
const { help, version, quiet, options } = await parseArgs();
|
|
91
|
+
if (help || version) process.exit(ExitCode.Success);
|
|
92
|
+
else {
|
|
93
|
+
if (!options.all && !options.noGitCheck) await checkGitStatus();
|
|
94
|
+
if (!quiet) options.progress = options.progress ? options.progress : progress;
|
|
95
|
+
await versionBump(options);
|
|
96
|
+
}
|
|
97
|
+
} catch (error) {
|
|
98
|
+
errorHandler(error);
|
|
99
|
+
}
|
|
104
100
|
}
|
|
105
101
|
async function checkGitStatus() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
throw new Error(`Git working tree is not clean:
|
|
109
|
-
${stdout}`);
|
|
110
|
-
}
|
|
102
|
+
const { stdout } = await x("git", ["status", "--porcelain"]);
|
|
103
|
+
if (stdout.trim()) throw new Error(`Git working tree is not clean:\n${stdout}`);
|
|
111
104
|
}
|
|
112
105
|
function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
106
|
+
switch (event) {
|
|
107
|
+
case ProgressEvent.FileUpdated:
|
|
108
|
+
console.log(symbols.success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
|
|
109
|
+
break;
|
|
110
|
+
case ProgressEvent.FileSkipped:
|
|
111
|
+
console.log(symbols.info, `${skippedFiles.pop()} did not need to be updated`);
|
|
112
|
+
break;
|
|
113
|
+
case ProgressEvent.GitCommit:
|
|
114
|
+
console.log(symbols.success, "Git commit");
|
|
115
|
+
break;
|
|
116
|
+
case ProgressEvent.GitTag:
|
|
117
|
+
console.log(symbols.success, "Git tag");
|
|
118
|
+
break;
|
|
119
|
+
case ProgressEvent.GitPush:
|
|
120
|
+
console.log(symbols.success, "Git push");
|
|
121
|
+
break;
|
|
122
|
+
case ProgressEvent.NpmScript:
|
|
123
|
+
console.log(symbols.success, `Npm run ${script}`);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
133
126
|
}
|
|
134
127
|
function errorHandler(error) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (process.env.DEBUG || process.env.NODE_ENV === "development")
|
|
141
|
-
message += `
|
|
142
|
-
|
|
143
|
-
${error.stack || ""}`;
|
|
144
|
-
console.error(message);
|
|
145
|
-
process.exit(ExitCode.FatalError);
|
|
128
|
+
let message = error.message || String(error);
|
|
129
|
+
if (error instanceof NonZeroExitError) message += `\n\n${error.output?.stderr || ""}`;
|
|
130
|
+
if (process.env.DEBUG || process.env.NODE_ENV === "development") message += `\n\n${error.stack || ""}`;
|
|
131
|
+
console.error(message);
|
|
132
|
+
process.exit(ExitCode.FatalError);
|
|
146
133
|
}
|
|
147
|
-
|
|
134
|
+
//#endregion
|
|
148
135
|
export { checkGitStatus, main };
|