bumpp 7.1.0 → 8.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.
@@ -1,28 +1,32 @@
1
1
  import {
2
2
  ProgressEvent,
3
- __toModule,
3
+ __toESM,
4
+ init_esm_shims,
4
5
  isReleaseType,
5
6
  require_log_symbols,
6
7
  versionBump
7
- } from "../chunk-OYIBSTEN.mjs";
8
+ } from "../chunk-HM6FRF4P.mjs";
8
9
 
9
10
  // src/cli/index.ts
10
- var import_log_symbols = __toModule(require_log_symbols());
11
+ init_esm_shims();
12
+ var import_log_symbols = __toESM(require_log_symbols());
11
13
 
12
14
  // package.json
13
15
  var name = "bumpp";
14
- var version = "7.1.0";
16
+ var version = "8.0.0";
15
17
  var description = "Automatically (or with prompts) bump your version number, commit changes, tag, and push to Git";
16
18
 
17
19
  // src/cli/exit-code.ts
18
- var ExitCode;
19
- (function(ExitCode2) {
20
+ init_esm_shims();
21
+ var ExitCode = /* @__PURE__ */ ((ExitCode2) => {
20
22
  ExitCode2[ExitCode2["Success"] = 0] = "Success";
21
23
  ExitCode2[ExitCode2["FatalError"] = 1] = "FatalError";
22
24
  ExitCode2[ExitCode2["InvalidArgument"] = 9] = "InvalidArgument";
23
- })(ExitCode || (ExitCode = {}));
25
+ return ExitCode2;
26
+ })(ExitCode || {});
24
27
 
25
28
  // src/cli/help.ts
29
+ init_esm_shims();
26
30
  var usageText = `
27
31
  Usage: bumpp [release] [options] [files...]
28
32
 
@@ -99,25 +103,15 @@ ${name} v${version} - ${description}
99
103
  ${usageText}`;
100
104
 
101
105
  // src/cli/parse-args.ts
102
- import commandLineArgs from "command-line-args";
106
+ init_esm_shims();
103
107
  import { valid as isValidVersion } from "semver";
108
+ import cac from "cac";
104
109
  function parseArgs(argv) {
105
110
  try {
106
- let args = commandLineArgs([
107
- { name: "preid", type: String },
108
- { name: "commit", alias: "c", type: String },
109
- { name: "tag", alias: "t", type: String },
110
- { name: "push", alias: "p", type: Boolean },
111
- { name: "all", alias: "a", type: Boolean },
112
- { name: "no-verify", type: Boolean },
113
- { name: "quiet", alias: "q", type: Boolean },
114
- { name: "version", alias: "v", type: Boolean },
115
- { name: "help", alias: "h", type: Boolean },
116
- { name: "ignore-scripts", type: Boolean },
117
- { name: "execute", alias: "x", type: String },
118
- { name: "files", type: String, multiple: true, defaultOption: true }
119
- ], { argv });
120
- let parsedArgs = {
111
+ const cli = cac("bumpp");
112
+ cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", "Include all files").option("-c, --commit [msg]", "Commit message", { default: true }).option("-t, --tag [tag]", "Tag name", { default: true }).option("-p, --push", "Push to remote", { default: true }).option("-y, --yes", "Skip confirmation").option("--no-verify", "Skip git verification").option("--ignore-scripts", "Ignore scripts", { default: false }).option("-q, --quiet", "Quiet mode").option("-v, --version <version>", "Tagert version").option("-x, --execute <command>", "Commands to execute after version bumps").help();
113
+ const args = cli.parse(argv).options;
114
+ const parsedArgs = {
121
115
  help: args.help,
122
116
  version: args.version,
123
117
  quiet: args.quiet,
@@ -127,23 +121,15 @@ function parseArgs(argv) {
127
121
  tag: args.tag,
128
122
  push: args.push,
129
123
  all: args.all,
130
- noVerify: args["no-verify"],
131
- files: args.files,
132
- ignoreScripts: args["ignore-scripts"],
124
+ confirm: !args.yes,
125
+ noVerify: !args.verify,
126
+ files: args["--"],
127
+ ignoreScripts: args.ignoreScripts,
133
128
  execute: args.execute
134
129
  }
135
130
  };
136
- if (args.preid === null) {
137
- throw new Error('The --preid option requires a value, such as "alpha", "beta", etc.');
138
- }
139
- if (args.commit === null) {
140
- parsedArgs.options.commit = true;
141
- }
142
- if (args.tag === null) {
143
- parsedArgs.options.tag = true;
144
- }
145
131
  if (parsedArgs.options.files && parsedArgs.options.files.length > 0) {
146
- let firstArg = parsedArgs.options.files[0];
132
+ const firstArg = parsedArgs.options.files[0];
147
133
  if (firstArg === "prompt" || isReleaseType(firstArg) || isValidVersion(firstArg)) {
148
134
  parsedArgs.options.release = firstArg;
149
135
  parsedArgs.options.files.shift();
@@ -157,7 +143,7 @@ function parseArgs(argv) {
157
143
  function errorHandler(error) {
158
144
  console.error(error.message);
159
145
  console.error(usageText);
160
- return process.exit(ExitCode.InvalidArgument);
146
+ return process.exit(9 /* InvalidArgument */);
161
147
  }
162
148
 
163
149
  // src/cli/index.ts
@@ -165,17 +151,16 @@ async function main(args) {
165
151
  try {
166
152
  process.on("uncaughtException", errorHandler2);
167
153
  process.on("unhandledRejection", errorHandler2);
168
- let { help, version: version2, quiet, options } = parseArgs(args);
154
+ const { help, version: version2, quiet, options } = parseArgs(args);
169
155
  if (help) {
170
156
  console.log(helpText);
171
- process.exit(ExitCode.Success);
157
+ process.exit(0 /* Success */);
172
158
  } else if (version2) {
173
159
  console.log(version);
174
- process.exit(ExitCode.Success);
160
+ process.exit(0 /* Success */);
175
161
  } else {
176
- if (!quiet) {
162
+ if (!quiet)
177
163
  options.progress = progress;
178
- }
179
164
  await versionBump(options);
180
165
  }
181
166
  } catch (error) {
@@ -184,33 +169,32 @@ async function main(args) {
184
169
  }
185
170
  function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
186
171
  switch (event) {
187
- case ProgressEvent.FileUpdated:
172
+ case "file updated" /* FileUpdated */:
188
173
  console.log(import_log_symbols.success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
189
174
  break;
190
- case ProgressEvent.FileSkipped:
175
+ case "file skipped" /* FileSkipped */:
191
176
  console.log(import_log_symbols.info, `${skippedFiles.pop()} did not need to be updated`);
192
177
  break;
193
- case ProgressEvent.GitCommit:
178
+ case "git commit" /* GitCommit */:
194
179
  console.log(import_log_symbols.success, "Git commit");
195
180
  break;
196
- case ProgressEvent.GitTag:
181
+ case "git tag" /* GitTag */:
197
182
  console.log(import_log_symbols.success, "Git tag");
198
183
  break;
199
- case ProgressEvent.GitPush:
184
+ case "git push" /* GitPush */:
200
185
  console.log(import_log_symbols.success, "Git push");
201
186
  break;
202
- case ProgressEvent.NpmScript:
187
+ case "npm script" /* NpmScript */:
203
188
  console.log(import_log_symbols.success, `Npm run ${script}`);
204
189
  break;
205
190
  }
206
191
  }
207
192
  function errorHandler2(error) {
208
193
  let message = error.message || String(error);
209
- if (process.env.DEBUG || process.env.NODE_ENV === "development") {
194
+ if (process.env.DEBUG || process.env.NODE_ENV === "development")
210
195
  message = error.stack || message;
211
- }
212
196
  console.error(message);
213
- process.exit(ExitCode.FatalError);
197
+ process.exit(1 /* FatalError */);
214
198
  }
215
199
  export {
216
200
  main
package/dist/index.d.ts CHANGED
@@ -1,8 +1,229 @@
1
+ import { ReleaseType } from 'semver';
2
+ export { ReleaseType } from 'semver';
3
+
4
+ /**
5
+ * Information about the work that was performed by the `versionBump()` function.
6
+ */
7
+ interface VersionBumpResults {
8
+ /**
9
+ * The release type that was used, or `undefined` if an explicit version number was used.
10
+ */
11
+ release?: ReleaseType;
12
+ /**
13
+ * The previous version number in package.json.
14
+ */
15
+ oldVersion: string;
16
+ /**
17
+ * The new version number.
18
+ */
19
+ newVersion: string;
20
+ /**
21
+ * The commit message that was used for the git commit, or `false` if no git commit was created.
22
+ *
23
+ * NOTE: This will never be an empty string. It will always contain at least the new version number.
24
+ */
25
+ commit: string | false;
26
+ /**
27
+ * The tag name that was used for the git tag, or `false` if no git tag was created.
28
+ *
29
+ * NOTE: This will never be an empty string. It will always contain at least the new version number.
30
+ */
31
+ tag: string | false;
32
+ /**
33
+ * The files that were actually modified.
34
+ */
35
+ updatedFiles: string[];
36
+ /**
37
+ * The files that were not updated because they did not contain the old version number.
38
+ */
39
+ skippedFiles: string[];
40
+ }
41
+
42
+ /**
43
+ * Progress events that indicate the progress of the `versionBump()` function.
44
+ */
45
+ declare const enum ProgressEvent {
46
+ FileUpdated = "file updated",
47
+ FileSkipped = "file skipped",
48
+ GitCommit = "git commit",
49
+ GitTag = "git tag",
50
+ GitPush = "git push",
51
+ NpmScript = "npm script"
52
+ }
1
53
  /**
2
- * The main entry point of the CLI
54
+ * The NPM version scripts
3
55
  *
4
- * @param args - The command-line arguments (e.g. ["major", "--preid=alpha", "-ctpa"])
56
+ * @see https://docs.npmjs.com/cli/version.html
57
+ */
58
+ declare const enum NpmScript {
59
+ PreVersion = "preversion",
60
+ Version = "version",
61
+ PostVersion = "postversion"
62
+ }
63
+ /**
64
+ * Information about the progress of the `versionBump()` function.
65
+ */
66
+ interface VersionBumpProgress extends VersionBumpResults {
67
+ event: ProgressEvent;
68
+ script?: NpmScript;
69
+ }
70
+
71
+ /**
72
+ * Options for the `versionBump()` function.
73
+ */
74
+ interface VersionBumpOptions {
75
+ /**
76
+ * The release version or type. Can be one of the following:
77
+ *
78
+ * - The new version number (e.g. "1.23.456")
79
+ * - A release type (e.g. "major", "minor", "patch", "prerelease", etc.)
80
+ * - "prompt" to prompt the user for the version number
81
+ *
82
+ * Defaults to "prompt".
83
+ */
84
+ release?: string;
85
+ /**
86
+ * The prerelease type (e.g. "alpha", "beta", "next").
87
+ *
88
+ * Defaults to "beta".
89
+ */
90
+ preid?: string;
91
+ /**
92
+ * Indicates whether to create a git commit. Can be set to a custom commit message string
93
+ * or `true` to use "release v". Any `%s` placeholders in the message string will be replaced
94
+ * with the new version number. If the message string does _not_ contain any `%s` placeholders,
95
+ * then the new version number will be appended to the message.
96
+ *
97
+ * Defaults to `false`.
98
+ */
99
+ commit?: boolean | string;
100
+ /**
101
+ * Indicates whether to tag the git commit. Can be set to a custom tag string
102
+ * or `true` to use "v". Any `%s` placeholders in the tag string will be replaced
103
+ * with the new version number. If the tag string does _not_ contain any `%s` placeholders,
104
+ * then the new version number will be appended to the tag.
105
+ *
106
+ * Defaults to `false`.
107
+ */
108
+ tag?: boolean | string;
109
+ /**
110
+ * Indicates whether to push the git commit and tag.
111
+ *
112
+ * Defaults to `false`.
113
+ */
114
+ push?: boolean;
115
+ /**
116
+ * Indicates whether the git commit should include ALL files (`git commit --all`)
117
+ * rather than just the files that were modified by `versionBump()`.
118
+ *
119
+ * Defaults to `false`.
120
+ */
121
+ all?: boolean;
122
+ /**
123
+ * Prompt for confirmation
124
+ *
125
+ * @default false
126
+ */
127
+ confirm?: boolean;
128
+ /**
129
+ * Indicates whether to bypass git commit hooks (`git commit --no-verify`).
130
+ *
131
+ * Defaults to `false`.
132
+ */
133
+ noVerify?: boolean;
134
+ /**
135
+ * The files to be updated. For certain known files ("package.json", "bower.json", etc.)
136
+ * `versionBump()` will explicitly update the file's version number. For other files
137
+ * (ReadMe files, config files, source code, etc.) it will simply do a global replacement
138
+ * of the old version number with the new version number.
139
+ *
140
+ * Defaults to ["package.json", "package-lock.json"]
141
+ */
142
+ files?: string[];
143
+ /**
144
+ * The working directory, which is used as the basis for locating all files.
145
+ *
146
+ * Defaults to `process.cwd()`
147
+ */
148
+ cwd?: string;
149
+ /**
150
+ * Options for the command-line interface. Can be one of the following:
151
+ *
152
+ * - `true` - To default to `process.stdin` and `process.stdout`.
153
+ * - `false` - To disable all CLI output. Cannot be used when `release` is "prompt".
154
+ * - An object that will be passed to `readline.createInterface()`.
155
+ *
156
+ * Defaults to `true`.
157
+ */
158
+ interface?: boolean | InterfaceOptions;
159
+ /**
160
+ * Indicates whether to ignore version scripts.
161
+ *
162
+ * Defaults to `false`.
163
+ */
164
+ ignoreScripts?: boolean;
165
+ /**
166
+ * A callback that is provides information about the progress of the `versionBump()` function.
167
+ */
168
+ progress?(progress: VersionBumpProgress): void;
169
+ /**
170
+ * Excute additional command after bumping and before commiting
171
+ */
172
+ execute?: string;
173
+ }
174
+ /**
175
+ * Options for the command-line interface.
176
+ */
177
+ interface InterfaceOptions {
178
+ /**
179
+ * The stream that will be used to read user input. Can be one of the following:
180
+ *
181
+ * - `true` - To default to `process.stdin`
182
+ * - `false` - To disable all CLI input
183
+ * - Any readable stream
184
+ *
185
+ * Defaults to `true`.
186
+ */
187
+ input?: NodeJS.ReadableStream | NodeJS.ReadStream | boolean;
188
+ /**
189
+ * The stream that will be used to write output, such as prompts and progress.
190
+ * Can be one of the following:
191
+ *
192
+ * - `true` - To default to `process.stdout`
193
+ * - `false` - To disable all CLI output
194
+ * - Any writable stream
195
+ *
196
+ * Defaults to `true`.
197
+ */
198
+ output?: NodeJS.WritableStream | NodeJS.WriteStream | boolean;
199
+ /**
200
+ * Any other properties will be passed directly to `readline.createInterface()`.
201
+ * See the `ReadLineOptions` interface for possible options.
202
+ */
203
+ [key: string]: unknown;
204
+ }
205
+
206
+ /**
207
+ * Prompts the user for a version number and updates package.json and package-lock.json.
208
+ *
209
+ * @returns - The new version number
210
+ */
211
+ declare function versionBump(): Promise<VersionBumpResults>;
212
+ /**
213
+ * Bumps the version number in package.json, package-lock.json.
214
+ *
215
+ * @param release
216
+ * The release version or type. Can be one of the following:
217
+ *
218
+ * - The new version number (e.g. "1.23.456")
219
+ * - A release type (e.g. "major", "minor", "patch", "prerelease", etc.)
220
+ * - "prompt" to prompt the user for the version number
221
+ */
222
+ declare function versionBump(release: string): Promise<VersionBumpResults>;
223
+ /**
224
+ * Bumps the version number in one or more files, prompting the user if necessary.
225
+ * Optionally also commits, tags, and pushes to git.
5
226
  */
6
- declare function main(args: string[]): Promise<void>;
227
+ declare function versionBump(options: VersionBumpOptions): Promise<VersionBumpResults>;
7
228
 
8
- export { main };
229
+ export { InterfaceOptions, NpmScript, ProgressEvent, VersionBumpOptions, VersionBumpProgress, VersionBumpResults, versionBump as default, versionBump };