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 CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  Forked from [`version-bump-prompt`](https://github.com/JS-DevTools/version-bump-prompt)
6
6
 
7
+ <!-- eslint-disable-next-line markdown/heading-increment -->
7
8
  ###### Changes in this fork
8
9
 
9
10
  - Renamed to `bumpp` - so you can use `npx bumpp` directly.
package/bin/bumpp.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- 'use strict'
3
- import('../dist/cli.mjs')
4
- .then(r => r.main())
2
+ import { main } from '../dist/cli.mjs'
3
+
4
+ main()
package/dist/cli.d.mts CHANGED
@@ -1,7 +1,8 @@
1
+ //#region src/cli/index.d.ts
1
2
  /**
2
3
  * The main entry point of the CLI
3
4
  */
4
5
  declare function main(): Promise<void>;
5
6
  declare function checkGitStatus(): Promise<void>;
6
-
7
- export { checkGitStatus, main };
7
+ //#endregion
8
+ export { checkGitStatus, main };
package/dist/cli.mjs CHANGED
@@ -1,148 +1,135 @@
1
- import process from 'node:process';
2
- import { x, NonZeroExitError } from 'tinyexec';
3
- import { l as loadBumpConfig, i as isReleaseType, b as bumpConfigDefaults, v as versionBump, P as ProgressEvent, s as symbols } from './shared/bumpp.Dvy0WV0b.mjs';
4
- import c from 'ansis';
5
- import cac from 'cac';
6
- import { valid } from 'semver';
7
- import 'args-tokenizer';
8
- import 'readline';
9
- import 'events';
10
- import 'node:child_process';
11
- import 'node:fs';
12
- import 'node:path';
13
- import 'jsonc-parser';
14
- import 'node:fs/promises';
15
- import 'tinyglobby';
16
- import 'yaml';
17
- import 'c12';
18
- import 'escalade/sync';
19
-
20
- var ExitCode = /* @__PURE__ */ ((ExitCode2) => {
21
- ExitCode2[ExitCode2["Success"] = 0] = "Success";
22
- ExitCode2[ExitCode2["FatalError"] = 1] = "FatalError";
23
- ExitCode2[ExitCode2["InvalidArgument"] = 9] = "InvalidArgument";
24
- return ExitCode2;
25
- })(ExitCode || {});
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
- try {
31
- const { args, resultArgs } = loadCliArgs();
32
- const parsedArgs = {
33
- help: args.help,
34
- version: args.version,
35
- quiet: args.quiet,
36
- options: await loadBumpConfig({
37
- preid: args.preid,
38
- commit: args.commit,
39
- tag: args.tag,
40
- sign: args.sign,
41
- push: args.push,
42
- all: args.all,
43
- noGitCheck: args.gitCheck === void 0 ? void 0 : !args.gitCheck,
44
- confirm: args.yes === void 0 ? void 0 : !args.yes,
45
- noVerify: args.verify === void 0 ? void 0 : !args.verify,
46
- install: args.install,
47
- files: [...args["--"] || [], ...resultArgs],
48
- ignoreScripts: args.ignoreScripts,
49
- currentVersion: args.currentVersion,
50
- execute: args.execute,
51
- printCommits: args.printCommits,
52
- recursive: args.recursive,
53
- release: args.release,
54
- configFilePath: args.configFilePath
55
- })
56
- };
57
- if (parsedArgs.options.files && parsedArgs.options.files.length > 0) {
58
- const firstArg = parsedArgs.options.files[0];
59
- if (firstArg === "prompt" || isReleaseType(firstArg) || valid(firstArg)) {
60
- parsedArgs.options.release = firstArg;
61
- parsedArgs.options.files.shift();
62
- }
63
- }
64
- if (parsedArgs.options.recursive && parsedArgs.options.files?.length)
65
- console.log(c.yellow("The --recursive option is ignored when files are specified"));
66
- return parsedArgs;
67
- } catch (error) {
68
- return errorHandler$1(error);
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
- const cli = cac("bumpp");
73
- 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();
74
- const result = cli.parse(argv);
75
- const args = result.options;
76
- return {
77
- args,
78
- resultArgs: result.args
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
- console.error(error.message);
83
- return process.exit(ExitCode.InvalidArgument);
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
- try {
88
- process.on("uncaughtException", errorHandler);
89
- process.on("unhandledRejection", errorHandler);
90
- const { help, version, quiet, options } = await parseArgs();
91
- if (help || version) {
92
- process.exit(ExitCode.Success);
93
- } else {
94
- if (!options.all && !options.noGitCheck) {
95
- await checkGitStatus();
96
- }
97
- if (!quiet)
98
- options.progress = options.progress ? options.progress : progress;
99
- await versionBump(options);
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
- const { stdout } = await x("git", ["status", "--porcelain"]);
107
- if (stdout.trim()) {
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
- switch (event) {
114
- case ProgressEvent.FileUpdated:
115
- console.log(symbols.success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
116
- break;
117
- case ProgressEvent.FileSkipped:
118
- console.log(symbols.info, `${skippedFiles.pop()} did not need to be updated`);
119
- break;
120
- case ProgressEvent.GitCommit:
121
- console.log(symbols.success, "Git commit");
122
- break;
123
- case ProgressEvent.GitTag:
124
- console.log(symbols.success, "Git tag");
125
- break;
126
- case ProgressEvent.GitPush:
127
- console.log(symbols.success, "Git push");
128
- break;
129
- case ProgressEvent.NpmScript:
130
- console.log(symbols.success, `Npm run ${script}`);
131
- break;
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
- let message = error.message || String(error);
136
- if (error instanceof NonZeroExitError)
137
- message += `
138
-
139
- ${error.output?.stderr || ""}`;
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 };