bumpp 7.0.0 → 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.
package/dist/cli/index.js CHANGED
@@ -1,24 +1,764 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __esm = (fn, res) => function __init() {
38
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
39
+ };
40
+ var __commonJS = (cb, mod) => function __require() {
41
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
42
+ };
43
+ var __export = (target, all) => {
44
+ for (var name2 in all)
45
+ __defProp(target, name2, { get: all[name2], enumerable: true });
46
+ };
47
+ var __reExport = (target, module2, copyDefault, desc) => {
48
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
49
+ for (let key of __getOwnPropNames(module2))
50
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
51
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
52
+ }
53
+ return target;
54
+ };
55
+ var __toESM = (module2, isNodeMode) => {
56
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
57
+ };
58
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
59
+ return (module2, temp) => {
60
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
61
+ };
62
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
63
+
64
+ // node_modules/.pnpm/tsup@5.11.9_typescript@4.5.4/node_modules/tsup/assets/cjs_shims.js
65
+ var init_cjs_shims = __esm({
66
+ "node_modules/.pnpm/tsup@5.11.9_typescript@4.5.4/node_modules/tsup/assets/cjs_shims.js"() {
67
+ }
68
+ });
69
+
70
+ // node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js
71
+ var require_is_unicode_supported = __commonJS({
72
+ "node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js"(exports, module2) {
73
+ "use strict";
74
+ init_cjs_shims();
75
+ module2.exports = () => {
76
+ if (process.platform !== "win32") {
77
+ return true;
78
+ }
79
+ return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty";
80
+ };
81
+ }
82
+ });
83
+
84
+ // node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js
85
+ var require_log_symbols = __commonJS({
86
+ "node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js"(exports, module2) {
87
+ "use strict";
88
+ init_cjs_shims();
89
+ var chalk = require("chalk");
90
+ var isUnicodeSupported = require_is_unicode_supported();
91
+ var main2 = {
92
+ info: chalk.blue("\u2139"),
93
+ success: chalk.green("\u2714"),
94
+ warning: chalk.yellow("\u26A0"),
95
+ error: chalk.red("\u2716")
96
+ };
97
+ var fallback = {
98
+ info: chalk.blue("i"),
99
+ success: chalk.green("\u221A"),
100
+ warning: chalk.yellow("\u203C"),
101
+ error: chalk.red("\xD7")
102
+ };
103
+ module2.exports = isUnicodeSupported() ? main2 : fallback;
104
+ }
105
+ });
106
+
107
+ // node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js
108
+ var require_detect_newline = __commonJS({
109
+ "node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js"(exports, module2) {
110
+ "use strict";
111
+ init_cjs_shims();
112
+ var detectNewline2 = (string) => {
113
+ if (typeof string !== "string") {
114
+ throw new TypeError("Expected a string");
115
+ }
116
+ const newlines = string.match(/(?:\r?\n)/g) || [];
117
+ if (newlines.length === 0) {
118
+ return;
119
+ }
120
+ const crlf = newlines.filter((newline) => newline === "\r\n").length;
121
+ const lf = newlines.length - crlf;
122
+ return crlf > lf ? "\r\n" : "\n";
123
+ };
124
+ module2.exports = detectNewline2;
125
+ module2.exports.graceful = (string) => typeof string === "string" && detectNewline2(string) || "\n";
126
+ }
127
+ });
128
+
129
+ // src/cli/index.ts
130
+ var cli_exports = {};
131
+ __export(cli_exports, {
132
+ main: () => main
133
+ });
134
+ init_cjs_shims();
135
+ var import_log_symbols2 = __toESM(require_log_symbols());
136
+
137
+ // package.json
138
+ var name = "bumpp";
139
+ var version = "7.2.0";
140
+ var description = "Automatically (or with prompts) bump your version number, commit changes, tag, and push to Git";
141
+
142
+ // src/types/version-bump-progress.ts
143
+ init_cjs_shims();
144
+ var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
145
+ ProgressEvent2["FileUpdated"] = "file updated";
146
+ ProgressEvent2["FileSkipped"] = "file skipped";
147
+ ProgressEvent2["GitCommit"] = "git commit";
148
+ ProgressEvent2["GitTag"] = "git tag";
149
+ ProgressEvent2["GitPush"] = "git push";
150
+ ProgressEvent2["NpmScript"] = "npm script";
151
+ return ProgressEvent2;
152
+ })(ProgressEvent || {});
153
+ var NpmScript = /* @__PURE__ */ ((NpmScript3) => {
154
+ NpmScript3["PreVersion"] = "preversion";
155
+ NpmScript3["Version"] = "version";
156
+ NpmScript3["PostVersion"] = "postversion";
157
+ return NpmScript3;
158
+ })(NpmScript || {});
159
+
160
+ // src/version-bump.ts
161
+ init_cjs_shims();
162
+ var ezSpawn3 = __toESM(require("@jsdevtools/ez-spawn"));
163
+
164
+ // src/get-new-version.ts
165
+ init_cjs_shims();
166
+ var import_chalk = require("chalk");
167
+ var import_prompts = __toESM(require("prompts"));
168
+ var import_semver2 = require("semver");
169
+ var import_semver3 = __toESM(require("semver"));
170
+
171
+ // src/release-type.ts
172
+ init_cjs_shims();
173
+ var import_semver = require("semver");
174
+ var prereleaseTypes = ["prerelease"];
175
+ var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
176
+ function isPrerelease(value) {
177
+ return prereleaseTypes.includes(value);
178
+ }
179
+ function isReleaseType(value) {
180
+ return releaseTypes.includes(value);
181
+ }
2
182
 
183
+ // src/get-new-version.ts
184
+ async function getNewVersion(operation) {
185
+ let { release } = operation.options;
186
+ let { oldVersion } = operation.state;
187
+ switch (release.type) {
188
+ case "prompt":
189
+ return promptForNewVersion(operation);
190
+ case "version":
191
+ let newSemVer = new import_semver3.SemVer(release.version, true);
192
+ return operation.update({
193
+ newVersion: newSemVer.version
194
+ });
195
+ default:
196
+ return operation.update({
197
+ release: release.type,
198
+ newVersion: getNextVersion(oldVersion, release)
199
+ });
200
+ }
201
+ }
202
+ function getNextVersion(oldVersion, bump) {
203
+ let oldSemVer = new import_semver3.SemVer(oldVersion);
204
+ let newSemVer = oldSemVer.inc(bump.type, bump.preid);
205
+ if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
206
+ newSemVer.prerelease[1] = "1";
207
+ newSemVer.format();
208
+ }
209
+ return newSemVer.version;
210
+ }
211
+ function getNextVersions(oldVersion, preid) {
212
+ var _a;
213
+ let next = {};
214
+ const parse = import_semver3.default.parse(oldVersion);
215
+ if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string") {
216
+ preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
217
+ }
218
+ for (let type of releaseTypes) {
219
+ next[type] = import_semver3.default.inc(oldVersion, type, preid);
220
+ }
221
+ next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? import_semver3.default.inc(oldVersion, "prerelease", preid) : import_semver3.default.inc(oldVersion, "patch");
222
+ return next;
223
+ }
224
+ async function promptForNewVersion(operation) {
225
+ let { oldVersion } = operation.state;
226
+ let release = operation.options.release;
227
+ let next = getNextVersions(oldVersion, release.preid);
228
+ let answers;
229
+ answers = await (0, import_prompts.default)([
230
+ {
231
+ type: "autocomplete",
232
+ name: "release",
233
+ message: `Current version: ${(0, import_chalk.green)(oldVersion)}`,
234
+ initial: "next",
235
+ choices: [
236
+ { value: "major", title: "major - " + (0, import_chalk.bold)(next.major) },
237
+ { value: "minor", title: "minor - " + (0, import_chalk.bold)(next.minor) },
238
+ { value: "patch", title: "patch - " + (0, import_chalk.bold)(next.patch) },
239
+ { value: "next", title: "next - " + (0, import_chalk.bold)(next.next) },
240
+ { value: "prerelease", title: "pre-release - " + (0, import_chalk.bold)(next.prerelease) },
241
+ { value: "none", title: "as-is - " + (0, import_chalk.bold)(oldVersion) },
242
+ { value: "custom", title: "custom..." }
243
+ ]
244
+ },
245
+ {
246
+ type: (prev) => prev === "custom" ? "text" : null,
247
+ name: "custom",
248
+ message: "Enter the new version number:",
249
+ initial: oldVersion,
250
+ validate: (custom) => {
251
+ return (0, import_semver2.valid)(custom) ? true : "That's not a valid version number";
252
+ }
253
+ }
254
+ ]);
255
+ const newVersion = answers.release === "none" ? oldVersion : answers.release === "custom" ? (0, import_semver2.clean)(answers.custom) : next[answers.release];
256
+ if (!newVersion) {
257
+ process.exit(1);
258
+ }
259
+ switch (answers.release) {
260
+ case "custom":
261
+ case "none":
262
+ return operation.update({ newVersion });
263
+ default:
264
+ return operation.update({ release: answers.release, newVersion });
265
+ }
266
+ }
3
267
 
268
+ // src/get-old-version.ts
269
+ init_cjs_shims();
270
+ var import_semver4 = require("semver");
271
+
272
+ // src/fs.ts
273
+ init_cjs_shims();
274
+
275
+ // node_modules/.pnpm/detect-indent@7.0.0/node_modules/detect-indent/index.js
276
+ init_cjs_shims();
277
+ var INDENT_REGEX = /^(?:( )+|\t+)/;
278
+ var INDENT_TYPE_SPACE = "space";
279
+ var INDENT_TYPE_TAB = "tab";
280
+ function makeIndentsMap(string, ignoreSingleSpaces) {
281
+ const indents = /* @__PURE__ */ new Map();
282
+ let previousSize = 0;
283
+ let previousIndentType;
284
+ let key;
285
+ for (const line of string.split(/\n/g)) {
286
+ if (!line) {
287
+ continue;
288
+ }
289
+ let indent;
290
+ let indentType;
291
+ let weight;
292
+ let entry;
293
+ const matches = line.match(INDENT_REGEX);
294
+ if (matches === null) {
295
+ previousSize = 0;
296
+ previousIndentType = "";
297
+ } else {
298
+ indent = matches[0].length;
299
+ indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
300
+ if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
301
+ continue;
302
+ }
303
+ if (indentType !== previousIndentType) {
304
+ previousSize = 0;
305
+ }
306
+ previousIndentType = indentType;
307
+ weight = 0;
308
+ const indentDifference = indent - previousSize;
309
+ previousSize = indent;
310
+ if (indentDifference === 0) {
311
+ weight++;
312
+ } else {
313
+ const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
314
+ key = encodeIndentsKey(indentType, absoluteIndentDifference);
315
+ }
316
+ entry = indents.get(key);
317
+ entry = entry === void 0 ? [1, 0] : [++entry[0], entry[1] + weight];
318
+ indents.set(key, entry);
319
+ }
320
+ }
321
+ return indents;
322
+ }
323
+ function encodeIndentsKey(indentType, indentAmount) {
324
+ const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
325
+ return typeCharacter + String(indentAmount);
326
+ }
327
+ function decodeIndentsKey(indentsKey) {
328
+ const keyHasTypeSpace = indentsKey[0] === "s";
329
+ const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
330
+ const amount = Number(indentsKey.slice(1));
331
+ return { type, amount };
332
+ }
333
+ function getMostUsedKey(indents) {
334
+ let result;
335
+ let maxUsed = 0;
336
+ let maxWeight = 0;
337
+ for (const [key, [usedCount, weight]] of indents) {
338
+ if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
339
+ maxUsed = usedCount;
340
+ maxWeight = weight;
341
+ result = key;
342
+ }
343
+ }
344
+ return result;
345
+ }
346
+ function makeIndentString(type, amount) {
347
+ const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
348
+ return indentCharacter.repeat(amount);
349
+ }
350
+ function detectIndent(string) {
351
+ if (typeof string !== "string") {
352
+ throw new TypeError("Expected a string");
353
+ }
354
+ let indents = makeIndentsMap(string, true);
355
+ if (indents.size === 0) {
356
+ indents = makeIndentsMap(string, false);
357
+ }
358
+ const keyOfMostUsedIndent = getMostUsedKey(indents);
359
+ let type;
360
+ let amount = 0;
361
+ let indent = "";
362
+ if (keyOfMostUsedIndent !== void 0) {
363
+ ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
364
+ indent = makeIndentString(type, amount);
365
+ }
366
+ return {
367
+ amount,
368
+ type,
369
+ indent
370
+ };
371
+ }
4
372
 
373
+ // src/fs.ts
374
+ var import_detect_newline = __toESM(require_detect_newline());
375
+ var import_fs = __toESM(require("fs"));
376
+ var import_path = __toESM(require("path"));
377
+ async function readJsonFile(name2, cwd) {
378
+ let file = await readTextFile(name2, cwd);
379
+ let data = JSON.parse(file.data);
380
+ let indent = detectIndent(file.data).indent;
381
+ let newline = (0, import_detect_newline.default)(file.data);
382
+ return __spreadProps(__spreadValues({}, file), { data, indent, newline });
383
+ }
384
+ async function writeJsonFile(file) {
385
+ let json = JSON.stringify(file.data, void 0, file.indent);
386
+ if (file.newline) {
387
+ json += file.newline;
388
+ }
389
+ return writeTextFile(__spreadProps(__spreadValues({}, file), { data: json }));
390
+ }
391
+ function readTextFile(name2, cwd) {
392
+ return new Promise((resolve, reject) => {
393
+ let filePath = import_path.default.join(cwd, name2);
394
+ import_fs.default.readFile(filePath, "utf8", (err, text) => {
395
+ if (err) {
396
+ reject(err);
397
+ } else {
398
+ resolve({
399
+ path: filePath,
400
+ data: text
401
+ });
402
+ }
403
+ });
404
+ });
405
+ }
406
+ function writeTextFile(file) {
407
+ return new Promise((resolve, reject) => {
408
+ import_fs.default.writeFile(file.path, file.data, (err) => {
409
+ if (err) {
410
+ reject(err);
411
+ } else {
412
+ resolve();
413
+ }
414
+ });
415
+ });
416
+ }
5
417
 
6
- var _chunkKWGIMQJUjs = require('../chunk-KWGIMQJU.js');
418
+ // src/manifest.ts
419
+ init_cjs_shims();
420
+ function isManifest(obj) {
421
+ return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
422
+ }
423
+ function isOptionalString(value) {
424
+ let type = typeof value;
425
+ return value === null || type === "undefined" || type === "string";
426
+ }
7
427
 
8
- // src/cli/index.ts
9
- var _logsymbols = require('log-symbols');
428
+ // src/get-old-version.ts
429
+ async function getOldVersion(operation) {
430
+ let { cwd, files } = operation.options;
431
+ let filesToCheck = files.filter((file) => file.endsWith(".json"));
432
+ if (!filesToCheck.includes("package.json")) {
433
+ filesToCheck.push("package.json");
434
+ }
435
+ for (let file of filesToCheck) {
436
+ let version2 = await readVersion(file, cwd);
437
+ if (version2) {
438
+ return operation.update({
439
+ oldVersionSource: file,
440
+ oldVersion: version2
441
+ });
442
+ }
443
+ }
444
+ throw new Error(`Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`);
445
+ }
446
+ async function readVersion(file, cwd) {
447
+ try {
448
+ let { data: manifest } = await readJsonFile(file, cwd);
449
+ if (isManifest(manifest)) {
450
+ if ((0, import_semver4.valid)(manifest.version)) {
451
+ return manifest.version;
452
+ }
453
+ }
454
+ } catch (error) {
455
+ return void 0;
456
+ }
457
+ }
458
+
459
+ // src/git.ts
460
+ init_cjs_shims();
461
+ var ezSpawn = __toESM(require("@jsdevtools/ez-spawn"));
462
+ async function gitCommit(operation) {
463
+ if (!operation.options.commit) {
464
+ return operation;
465
+ }
466
+ let { all, noVerify, message } = operation.options.commit;
467
+ let { updatedFiles, newVersion } = operation.state;
468
+ let args = [];
469
+ if (all) {
470
+ args.push("--all");
471
+ }
472
+ if (noVerify) {
473
+ args.push("--no-verify");
474
+ }
475
+ let commitMessage = formatVersionString(message, newVersion);
476
+ args.push("--message", commitMessage);
477
+ if (!all) {
478
+ args = args.concat(updatedFiles);
479
+ }
480
+ await ezSpawn.async("git", ["commit", ...args]);
481
+ return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
482
+ }
483
+ async function gitTag(operation) {
484
+ if (!operation.options.tag) {
485
+ return operation;
486
+ }
487
+ let { commit, tag } = operation.options;
488
+ let { newVersion } = operation.state;
489
+ let args = [
490
+ "--annotate",
491
+ "--message",
492
+ formatVersionString(commit.message, newVersion)
493
+ ];
494
+ let tagName = formatVersionString(tag.name, newVersion);
495
+ args.push(tagName);
496
+ await ezSpawn.async("git", ["tag", ...args]);
497
+ return operation.update({ event: "git tag" /* GitTag */, tagName });
498
+ }
499
+ async function gitPush(operation) {
500
+ if (!operation.options.push) {
501
+ return operation;
502
+ }
503
+ await ezSpawn.async("git", "push");
504
+ if (operation.options.tag) {
505
+ await ezSpawn.async("git", ["push", "--tags"]);
506
+ }
507
+ return operation.update({ event: "git push" /* GitPush */ });
508
+ }
509
+ function formatVersionString(template, newVersion) {
510
+ if (template.includes("%s")) {
511
+ return template.replace(/%s/g, newVersion);
512
+ } else {
513
+ return template + newVersion;
514
+ }
515
+ }
516
+
517
+ // src/operation.ts
518
+ init_cjs_shims();
519
+
520
+ // src/normalize-options.ts
521
+ init_cjs_shims();
522
+ var import_globby = __toESM(require("globby"));
523
+ var import_globby2 = require("globby");
524
+ async function normalizeOptions(raw) {
525
+ let preid = typeof raw.preid === "string" ? raw.preid : "beta";
526
+ let push = Boolean(raw.push);
527
+ let all = Boolean(raw.all);
528
+ let noVerify = Boolean(raw.noVerify);
529
+ let cwd = raw.cwd || process.cwd();
530
+ let ignoreScripts = Boolean(raw.ignoreScripts);
531
+ let execute = raw.execute;
532
+ let release;
533
+ if (!raw.release || raw.release === "prompt") {
534
+ release = { type: "prompt", preid };
535
+ } else if (isReleaseType(raw.release)) {
536
+ release = { type: raw.release, preid };
537
+ } else {
538
+ release = { type: "version", version: raw.release };
539
+ }
540
+ let tag;
541
+ if (typeof raw.tag === "string") {
542
+ tag = { name: raw.tag };
543
+ } else if (raw.tag) {
544
+ tag = { name: "v" };
545
+ }
546
+ let commit;
547
+ if (typeof raw.commit === "string") {
548
+ commit = { all, noVerify, message: raw.commit };
549
+ } else if (raw.commit || tag || push) {
550
+ commit = { all, noVerify, message: "release v" };
551
+ }
552
+ let files;
553
+ if (Array.isArray(raw.files) && raw.files.length > 0) {
554
+ files = await strictGlobMatches(raw.files, { cwd });
555
+ } else {
556
+ files = await (0, import_globby.default)(["package.json", "package-lock.json"], { cwd });
557
+ }
558
+ let ui;
559
+ if (raw.interface === false) {
560
+ ui = { input: false, outut: false };
561
+ } else if (raw.interface === true || !raw.interface) {
562
+ ui = { input: process.stdin, output: process.stdout };
563
+ } else {
564
+ let _a = raw.interface, { input, output } = _a, other = __objRest(_a, ["input", "output"]);
565
+ if (input === true || input !== false && !input) {
566
+ input = process.stdin;
567
+ }
568
+ if (output === true || output !== false && !output) {
569
+ output = process.stdout;
570
+ }
571
+ ui = __spreadValues({ input, output }, other);
572
+ }
573
+ if (release.type === "prompt" && !(ui.input && ui.output)) {
574
+ throw new Error("Cannot prompt for the version number because input or output has been disabled.");
575
+ }
576
+ return { release, commit, tag, push, files, cwd, interface: ui, ignoreScripts, execute };
577
+ }
578
+ async function strictGlobMatches(files, options) {
579
+ let matches = await Promise.all(files.map((file) => strictGlobMatch(file, options)));
580
+ let matchedFiles = /* @__PURE__ */ new Set();
581
+ for (let match of matches) {
582
+ for (let file of match) {
583
+ matchedFiles.add(file);
584
+ }
585
+ }
586
+ return [...matchedFiles];
587
+ }
588
+ async function strictGlobMatch(file, options) {
589
+ let matches = await (0, import_globby.default)(file, options);
590
+ if (matches.length === 0) {
591
+ if ((0, import_globby2.hasMagic)(file)) {
592
+ throw new Error(`Could not find any files matching "${file}".`);
593
+ } else {
594
+ throw new Error(`Could not find file: ${file}.`);
595
+ }
596
+ }
597
+ return matches.sort();
598
+ }
599
+
600
+ // src/operation.ts
601
+ var Operation = class {
602
+ constructor(options, progress2) {
603
+ this.state = {
604
+ release: void 0,
605
+ oldVersion: "",
606
+ oldVersionSource: "",
607
+ newVersion: "",
608
+ commitMessage: "",
609
+ tagName: "",
610
+ updatedFiles: [],
611
+ skippedFiles: []
612
+ };
613
+ this.options = options;
614
+ this._progress = progress2;
615
+ }
616
+ get results() {
617
+ let options = this.options;
618
+ let state = this.state;
619
+ return {
620
+ release: state.release,
621
+ oldVersion: state.oldVersion,
622
+ newVersion: state.newVersion,
623
+ commit: options.commit ? state.commitMessage : false,
624
+ tag: options.tag ? state.tagName : false,
625
+ updatedFiles: state.updatedFiles.slice(),
626
+ skippedFiles: state.skippedFiles.slice()
627
+ };
628
+ }
629
+ static async start(input) {
630
+ let options = await normalizeOptions(input);
631
+ return new Operation(options, input.progress);
632
+ }
633
+ update(_a) {
634
+ var _b = _a, { event, script } = _b, newState = __objRest(_b, ["event", "script"]);
635
+ Object.assign(this.state, newState);
636
+ if (event && this._progress) {
637
+ this._progress(__spreadValues({ event, script }, this.results));
638
+ }
639
+ return this;
640
+ }
641
+ };
642
+
643
+ // src/run-npm-script.ts
644
+ init_cjs_shims();
645
+ var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));
646
+ async function runNpmScript(script, operation) {
647
+ let { cwd, ignoreScripts } = operation.options;
648
+ if (!ignoreScripts) {
649
+ let { data: manifest } = await readJsonFile("package.json", cwd);
650
+ if (isManifest(manifest) && hasScript(manifest, script)) {
651
+ await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
652
+ operation.update({ event: "npm script" /* NpmScript */, script });
653
+ }
654
+ }
655
+ return operation;
656
+ }
657
+ function hasScript(manifest, script) {
658
+ let scripts = manifest.scripts;
659
+ if (scripts && typeof scripts === "object") {
660
+ return Boolean(scripts[script]);
661
+ }
662
+ return false;
663
+ }
664
+
665
+ // src/update-files.ts
666
+ init_cjs_shims();
667
+ var path2 = __toESM(require("path"));
668
+ async function updateFiles(operation) {
669
+ let { files } = operation.options;
670
+ for (let relPath of files) {
671
+ let modified = await updateFile(relPath, operation);
672
+ if (modified) {
673
+ operation.update({
674
+ event: "file updated" /* FileUpdated */,
675
+ updatedFiles: operation.state.updatedFiles.concat(relPath)
676
+ });
677
+ } else {
678
+ operation.update({
679
+ event: "file skipped" /* FileSkipped */,
680
+ skippedFiles: operation.state.skippedFiles.concat(relPath)
681
+ });
682
+ }
683
+ }
684
+ return operation;
685
+ }
686
+ async function updateFile(relPath, operation) {
687
+ let name2 = path2.basename(relPath).trim().toLowerCase();
688
+ switch (name2) {
689
+ case "package.json":
690
+ case "package-lock.json":
691
+ case "bower.json":
692
+ case "component.json":
693
+ return updateManifestFile(relPath, operation);
694
+ default:
695
+ return updateTextFile(relPath, operation);
696
+ }
697
+ }
698
+ async function updateManifestFile(relPath, operation) {
699
+ let { cwd } = operation.options;
700
+ let { newVersion } = operation.state;
701
+ let modified = false;
702
+ let file = await readJsonFile(relPath, cwd);
703
+ if (isManifest(file.data) && file.data.version !== newVersion) {
704
+ file.data.version = newVersion;
705
+ await writeJsonFile(file);
706
+ modified = true;
707
+ }
708
+ return modified;
709
+ }
710
+ async function updateTextFile(relPath, operation) {
711
+ let { cwd } = operation.options;
712
+ let { oldVersion, newVersion } = operation.state;
713
+ let modified = false;
714
+ let file = await readTextFile(relPath, cwd);
715
+ if (file.data.includes(oldVersion)) {
716
+ let sanitizedVersion = oldVersion.replace(/(\W)/g, "\\$1");
717
+ let replacePattern = new RegExp("(\\b|v)" + sanitizedVersion + "\\b", "g");
718
+ file.data = file.data.replace(replacePattern, "$1" + newVersion);
719
+ await writeTextFile(file);
720
+ return true;
721
+ }
722
+ return modified;
723
+ }
724
+
725
+ // src/version-bump.ts
726
+ var import_log_symbols = __toESM(require_log_symbols());
727
+ async function versionBump(arg = {}) {
728
+ if (typeof arg === "string") {
729
+ arg = { release: arg };
730
+ }
731
+ let operation = await Operation.start(arg);
732
+ await getOldVersion(operation);
733
+ await getNewVersion(operation);
734
+ await runNpmScript("preversion" /* PreVersion */, operation);
735
+ await updateFiles(operation);
736
+ if (operation.options.execute) {
737
+ console.log(import_log_symbols.info, "Executing script", operation.options.execute);
738
+ await ezSpawn3.async(operation.options.execute, { stdio: "inherit" });
739
+ console.log(import_log_symbols.success, "Script finished");
740
+ }
741
+ await runNpmScript("version" /* Version */, operation);
742
+ await gitCommit(operation);
743
+ await gitTag(operation);
744
+ await runNpmScript("postversion" /* PostVersion */, operation);
745
+ await gitPush(operation);
746
+ return operation.results;
747
+ }
10
748
 
11
749
  // src/cli/exit-code.ts
12
- var ExitCode;
13
- (function(ExitCode2) {
750
+ init_cjs_shims();
751
+ var ExitCode = /* @__PURE__ */ ((ExitCode2) => {
14
752
  ExitCode2[ExitCode2["Success"] = 0] = "Success";
15
753
  ExitCode2[ExitCode2["FatalError"] = 1] = "FatalError";
16
754
  ExitCode2[ExitCode2["InvalidArgument"] = 9] = "InvalidArgument";
17
- })(ExitCode || (ExitCode = {}));
755
+ return ExitCode2;
756
+ })(ExitCode || {});
18
757
 
19
758
  // src/cli/help.ts
759
+ init_cjs_shims();
20
760
  var usageText = `
21
- Usage: bump [release] [options] [files...]
761
+ Usage: bumpp [release] [options] [files...]
22
762
 
23
763
  release:
24
764
  The release version or type. Can be one of the following:
@@ -67,37 +807,38 @@ files...
67
807
 
68
808
  Examples:
69
809
 
70
- bump patch
810
+ bumpp patch
71
811
 
72
812
  Bumps the patch version number in package.json and package-lock.json.
73
813
  Nothing is committed to git.
74
814
 
75
- bump major --commit
815
+ bumpp major --commit
76
816
 
77
817
  Bumps the major version number in package.json and package-lock.json.
78
818
  Commits package.json and package-lock.json to git, but does not tag the commit.
79
819
 
80
- bump -tpa README.md
820
+ bumpp -tpa README.md
81
821
 
82
822
  Prompts for the new version number and updates package.json, package-lock.json, and README.md.
83
823
  Commits ALL modified files to git, tags the commit, and pushes the commit.
84
824
 
85
- bump 4.27.9934 --tag "Version " bower.json docs/**/*.md
825
+ bumpp 4.27.9934 --tag "Version " bower.json docs/**/*.md
86
826
 
87
827
  Sets the version number to 4.27.9934 in package.json, package-lock.json, bower.json,
88
828
  and all markdown files in the "docs" directory. Commits the updated files to git,
89
829
  and tags the commit as "Version 4.27.9934".
90
830
  `;
91
831
  var helpText = `
92
- ${_chunkKWGIMQJUjs.manifest.name} - ${_chunkKWGIMQJUjs.manifest.description}
832
+ ${name} v${version} - ${description}
93
833
  ${usageText}`;
94
834
 
95
835
  // src/cli/parse-args.ts
96
- var _commandlineargs = require('command-line-args'); var _commandlineargs2 = _interopRequireDefault(_commandlineargs);
97
- var _semver = require('semver'); var _semver2 = _interopRequireDefault(_semver);
836
+ init_cjs_shims();
837
+ var import_command_line_args = __toESM(require("command-line-args"));
838
+ var import_semver5 = require("semver");
98
839
  function parseArgs(argv) {
99
840
  try {
100
- let args = _commandlineargs2.default.call(void 0, [
841
+ let args = (0, import_command_line_args.default)([
101
842
  { name: "preid", type: String },
102
843
  { name: "commit", alias: "c", type: String },
103
844
  { name: "tag", alias: "t", type: String },
@@ -138,7 +879,7 @@ function parseArgs(argv) {
138
879
  }
139
880
  if (parsedArgs.options.files && parsedArgs.options.files.length > 0) {
140
881
  let firstArg = parsedArgs.options.files[0];
141
- if (firstArg === "prompt" || _chunkKWGIMQJUjs.isReleaseType.call(void 0, firstArg) || _semver2.default.valid(firstArg)) {
882
+ if (firstArg === "prompt" || isReleaseType(firstArg) || (0, import_semver5.valid)(firstArg)) {
142
883
  parsedArgs.options.release = firstArg;
143
884
  parsedArgs.options.files.shift();
144
885
  }
@@ -151,7 +892,7 @@ function parseArgs(argv) {
151
892
  function errorHandler(error) {
152
893
  console.error(error.message);
153
894
  console.error(usageText);
154
- return process.exit(ExitCode.InvalidArgument);
895
+ return process.exit(9 /* InvalidArgument */);
155
896
  }
156
897
 
157
898
  // src/cli/index.ts
@@ -159,18 +900,18 @@ async function main(args) {
159
900
  try {
160
901
  process.on("uncaughtException", errorHandler2);
161
902
  process.on("unhandledRejection", errorHandler2);
162
- let { help, version, quiet, options } = parseArgs(args);
903
+ let { help, version: version2, quiet, options } = parseArgs(args);
163
904
  if (help) {
164
905
  console.log(helpText);
165
- process.exit(ExitCode.Success);
166
- } else if (version) {
167
- console.log(_chunkKWGIMQJUjs.manifest.version);
168
- process.exit(ExitCode.Success);
906
+ process.exit(0 /* Success */);
907
+ } else if (version2) {
908
+ console.log(version);
909
+ process.exit(0 /* Success */);
169
910
  } else {
170
911
  if (!quiet) {
171
912
  options.progress = progress;
172
913
  }
173
- await _chunkKWGIMQJUjs.versionBump.call(void 0, options);
914
+ await versionBump(options);
174
915
  }
175
916
  } catch (error) {
176
917
  errorHandler2(error);
@@ -178,23 +919,23 @@ async function main(args) {
178
919
  }
179
920
  function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
180
921
  switch (event) {
181
- case _chunkKWGIMQJUjs.ProgressEvent.FileUpdated:
182
- console.log(_logsymbols.success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
922
+ case "file updated" /* FileUpdated */:
923
+ console.log(import_log_symbols2.success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
183
924
  break;
184
- case _chunkKWGIMQJUjs.ProgressEvent.FileSkipped:
185
- console.log(_logsymbols.info, `${skippedFiles.pop()} did not need to be updated`);
925
+ case "file skipped" /* FileSkipped */:
926
+ console.log(import_log_symbols2.info, `${skippedFiles.pop()} did not need to be updated`);
186
927
  break;
187
- case _chunkKWGIMQJUjs.ProgressEvent.GitCommit:
188
- console.log(_logsymbols.success, "Git commit");
928
+ case "git commit" /* GitCommit */:
929
+ console.log(import_log_symbols2.success, "Git commit");
189
930
  break;
190
- case _chunkKWGIMQJUjs.ProgressEvent.GitTag:
191
- console.log(_logsymbols.success, "Git tag");
931
+ case "git tag" /* GitTag */:
932
+ console.log(import_log_symbols2.success, "Git tag");
192
933
  break;
193
- case _chunkKWGIMQJUjs.ProgressEvent.GitPush:
194
- console.log(_logsymbols.success, "Git push");
934
+ case "git push" /* GitPush */:
935
+ console.log(import_log_symbols2.success, "Git push");
195
936
  break;
196
- case _chunkKWGIMQJUjs.ProgressEvent.NpmScript:
197
- console.log(_logsymbols.success, `Npm run ${script}`);
937
+ case "npm script" /* NpmScript */:
938
+ console.log(import_log_symbols2.success, `Npm run ${script}`);
198
939
  break;
199
940
  }
200
941
  }
@@ -204,8 +945,10 @@ function errorHandler2(error) {
204
945
  message = error.stack || message;
205
946
  }
206
947
  console.error(message);
207
- process.exit(ExitCode.FatalError);
948
+ process.exit(1 /* FatalError */);
208
949
  }
209
-
210
-
211
- exports.main = main;
950
+ module.exports = __toCommonJS(cli_exports);
951
+ // Annotate the CommonJS export names for ESM import in node:
952
+ 0 && (module.exports = {
953
+ main
954
+ });