bumpp 7.1.1 → 7.2.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-2TP63A7S.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.1";
16
+ var version = "7.2.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,6 +103,7 @@ ${name} v${version} - ${description}
99
103
  ${usageText}`;
100
104
 
101
105
  // src/cli/parse-args.ts
106
+ init_esm_shims();
102
107
  import commandLineArgs from "command-line-args";
103
108
  import { valid as isValidVersion } from "semver";
104
109
  function parseArgs(argv) {
@@ -157,7 +162,7 @@ function parseArgs(argv) {
157
162
  function errorHandler(error) {
158
163
  console.error(error.message);
159
164
  console.error(usageText);
160
- return process.exit(ExitCode.InvalidArgument);
165
+ return process.exit(9 /* InvalidArgument */);
161
166
  }
162
167
 
163
168
  // src/cli/index.ts
@@ -168,10 +173,10 @@ async function main(args) {
168
173
  let { help, version: version2, quiet, options } = parseArgs(args);
169
174
  if (help) {
170
175
  console.log(helpText);
171
- process.exit(ExitCode.Success);
176
+ process.exit(0 /* Success */);
172
177
  } else if (version2) {
173
178
  console.log(version);
174
- process.exit(ExitCode.Success);
179
+ process.exit(0 /* Success */);
175
180
  } else {
176
181
  if (!quiet) {
177
182
  options.progress = progress;
@@ -184,22 +189,22 @@ async function main(args) {
184
189
  }
185
190
  function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
186
191
  switch (event) {
187
- case ProgressEvent.FileUpdated:
192
+ case "file updated" /* FileUpdated */:
188
193
  console.log(import_log_symbols.success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
189
194
  break;
190
- case ProgressEvent.FileSkipped:
195
+ case "file skipped" /* FileSkipped */:
191
196
  console.log(import_log_symbols.info, `${skippedFiles.pop()} did not need to be updated`);
192
197
  break;
193
- case ProgressEvent.GitCommit:
198
+ case "git commit" /* GitCommit */:
194
199
  console.log(import_log_symbols.success, "Git commit");
195
200
  break;
196
- case ProgressEvent.GitTag:
201
+ case "git tag" /* GitTag */:
197
202
  console.log(import_log_symbols.success, "Git tag");
198
203
  break;
199
- case ProgressEvent.GitPush:
204
+ case "git push" /* GitPush */:
200
205
  console.log(import_log_symbols.success, "Git push");
201
206
  break;
202
- case ProgressEvent.NpmScript:
207
+ case "npm script" /* NpmScript */:
203
208
  console.log(import_log_symbols.success, `Npm run ${script}`);
204
209
  break;
205
210
  }
@@ -210,7 +215,7 @@ function errorHandler2(error) {
210
215
  message = error.stack || message;
211
216
  }
212
217
  console.error(message);
213
- process.exit(ExitCode.FatalError);
218
+ process.exit(1 /* FatalError */);
214
219
  }
215
220
  export {
216
221
  main
package/dist/index.d.ts CHANGED
@@ -1,8 +1,223 @@
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
+ * Indicates whether to bypass git commit hooks (`git commit --no-verify`).
124
+ *
125
+ * Defaults to `false`.
126
+ */
127
+ noVerify?: boolean;
128
+ /**
129
+ * The files to be updated. For certain known files ("package.json", "bower.json", etc.)
130
+ * `versionBump()` will explicitly update the file's version number. For other files
131
+ * (ReadMe files, config files, source code, etc.) it will simply do a global replacement
132
+ * of the old version number with the new version number.
133
+ *
134
+ * Defaults to ["package.json", "package-lock.json"]
135
+ */
136
+ files?: string[];
137
+ /**
138
+ * The working directory, which is used as the basis for locating all files.
139
+ *
140
+ * Defaults to `process.cwd()`
141
+ */
142
+ cwd?: string;
143
+ /**
144
+ * Options for the command-line interface. Can be one of the following:
145
+ *
146
+ * - `true` - To default to `process.stdin` and `process.stdout`.
147
+ * - `false` - To disable all CLI output. Cannot be used when `release` is "prompt".
148
+ * - An object that will be passed to `readline.createInterface()`.
149
+ *
150
+ * Defaults to `true`.
151
+ */
152
+ interface?: boolean | InterfaceOptions;
153
+ /**
154
+ * Indicates whether to ignore version scripts.
155
+ *
156
+ * Defaults to `false`.
157
+ */
158
+ ignoreScripts?: boolean;
159
+ /**
160
+ * A callback that is provides information about the progress of the `versionBump()` function.
161
+ */
162
+ progress?(progress: VersionBumpProgress): void;
163
+ /**
164
+ * Excute additional command after bumping and before commiting
165
+ */
166
+ execute?: string;
167
+ }
168
+ /**
169
+ * Options for the command-line interface.
170
+ */
171
+ interface InterfaceOptions {
172
+ /**
173
+ * The stream that will be used to read user input. Can be one of the following:
174
+ *
175
+ * - `true` - To default to `process.stdin`
176
+ * - `false` - To disable all CLI input
177
+ * - Any readable stream
178
+ *
179
+ * Defaults to `true`.
180
+ */
181
+ input?: NodeJS.ReadableStream | NodeJS.ReadStream | boolean;
182
+ /**
183
+ * The stream that will be used to write output, such as prompts and progress.
184
+ * Can be one of the following:
185
+ *
186
+ * - `true` - To default to `process.stdout`
187
+ * - `false` - To disable all CLI output
188
+ * - Any writable stream
189
+ *
190
+ * Defaults to `true`.
191
+ */
192
+ output?: NodeJS.WritableStream | NodeJS.WriteStream | boolean;
193
+ /**
194
+ * Any other properties will be passed directly to `readline.createInterface()`.
195
+ * See the `ReadLineOptions` interface for possible options.
196
+ */
197
+ [key: string]: unknown;
198
+ }
199
+
200
+ /**
201
+ * Prompts the user for a version number and updates package.json and package-lock.json.
202
+ *
203
+ * @returns - The new version number
204
+ */
205
+ declare function versionBump(): Promise<VersionBumpResults>;
206
+ /**
207
+ * Bumps the version number in package.json, package-lock.json.
208
+ *
209
+ * @param release
210
+ * The release version or type. Can be one of the following:
211
+ *
212
+ * - The new version number (e.g. "1.23.456")
213
+ * - A release type (e.g. "major", "minor", "patch", "prerelease", etc.)
214
+ * - "prompt" to prompt the user for the version number
215
+ */
216
+ declare function versionBump(release: string): Promise<VersionBumpResults>;
217
+ /**
218
+ * Bumps the version number in one or more files, prompting the user if necessary.
219
+ * Optionally also commits, tags, and pushes to git.
5
220
  */
6
- declare function main(args: string[]): Promise<void>;
221
+ declare function versionBump(options: VersionBumpOptions): Promise<VersionBumpResults>;
7
222
 
8
- export { main };
223
+ export { InterfaceOptions, NpmScript, ProgressEvent, VersionBumpOptions, VersionBumpProgress, VersionBumpResults, versionBump as default, versionBump };