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.
package/dist/cli/index.js CHANGED
@@ -1,28 +1,762 @@
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
+ });
2
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());
3
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";
4
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
+ }
5
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
+ }
6
267
 
7
- var _chunkXF5JTHA6js = require('../chunk-XF5JTHA6.js');
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
+ }
8
372
 
9
- // src/cli/index.ts
10
- var import_log_symbols = _chunkXF5JTHA6js.__toModule.call(void 0, _chunkXF5JTHA6js.require_log_symbols.call(void 0, ));
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
+ }
11
417
 
12
- // package.json
13
- var name = "bumpp";
14
- var version = "7.1.1";
15
- var description = "Automatically (or with prompts) bump your version number, commit changes, tag, and push to Git";
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
+ }
427
+
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
+ }
16
748
 
17
749
  // src/cli/exit-code.ts
18
- var ExitCode;
19
- (function(ExitCode2) {
750
+ init_cjs_shims();
751
+ var ExitCode = /* @__PURE__ */ ((ExitCode2) => {
20
752
  ExitCode2[ExitCode2["Success"] = 0] = "Success";
21
753
  ExitCode2[ExitCode2["FatalError"] = 1] = "FatalError";
22
754
  ExitCode2[ExitCode2["InvalidArgument"] = 9] = "InvalidArgument";
23
- })(ExitCode || (ExitCode = {}));
755
+ return ExitCode2;
756
+ })(ExitCode || {});
24
757
 
25
758
  // src/cli/help.ts
759
+ init_cjs_shims();
26
760
  var usageText = `
27
761
  Usage: bumpp [release] [options] [files...]
28
762
 
@@ -99,11 +833,12 @@ ${name} v${version} - ${description}
99
833
  ${usageText}`;
100
834
 
101
835
  // src/cli/parse-args.ts
102
- var _commandlineargs = require('command-line-args'); var _commandlineargs2 = _interopRequireDefault(_commandlineargs);
103
- var _semver = require('semver');
836
+ init_cjs_shims();
837
+ var import_command_line_args = __toESM(require("command-line-args"));
838
+ var import_semver5 = require("semver");
104
839
  function parseArgs(argv) {
105
840
  try {
106
- let args = _commandlineargs2.default.call(void 0, [
841
+ let args = (0, import_command_line_args.default)([
107
842
  { name: "preid", type: String },
108
843
  { name: "commit", alias: "c", type: String },
109
844
  { name: "tag", alias: "t", type: String },
@@ -144,7 +879,7 @@ function parseArgs(argv) {
144
879
  }
145
880
  if (parsedArgs.options.files && parsedArgs.options.files.length > 0) {
146
881
  let firstArg = parsedArgs.options.files[0];
147
- if (firstArg === "prompt" || _chunkXF5JTHA6js.isReleaseType.call(void 0, firstArg) || _semver.valid.call(void 0, firstArg)) {
882
+ if (firstArg === "prompt" || isReleaseType(firstArg) || (0, import_semver5.valid)(firstArg)) {
148
883
  parsedArgs.options.release = firstArg;
149
884
  parsedArgs.options.files.shift();
150
885
  }
@@ -157,7 +892,7 @@ function parseArgs(argv) {
157
892
  function errorHandler(error) {
158
893
  console.error(error.message);
159
894
  console.error(usageText);
160
- return process.exit(ExitCode.InvalidArgument);
895
+ return process.exit(9 /* InvalidArgument */);
161
896
  }
162
897
 
163
898
  // src/cli/index.ts
@@ -168,15 +903,15 @@ async function main(args) {
168
903
  let { help, version: version2, quiet, options } = parseArgs(args);
169
904
  if (help) {
170
905
  console.log(helpText);
171
- process.exit(ExitCode.Success);
906
+ process.exit(0 /* Success */);
172
907
  } else if (version2) {
173
908
  console.log(version);
174
- process.exit(ExitCode.Success);
909
+ process.exit(0 /* Success */);
175
910
  } else {
176
911
  if (!quiet) {
177
912
  options.progress = progress;
178
913
  }
179
- await _chunkXF5JTHA6js.versionBump.call(void 0, options);
914
+ await versionBump(options);
180
915
  }
181
916
  } catch (error) {
182
917
  errorHandler2(error);
@@ -184,23 +919,23 @@ async function main(args) {
184
919
  }
185
920
  function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
186
921
  switch (event) {
187
- case _chunkXF5JTHA6js.ProgressEvent.FileUpdated:
188
- console.log(import_log_symbols.success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
922
+ case "file updated" /* FileUpdated */:
923
+ console.log(import_log_symbols2.success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
189
924
  break;
190
- case _chunkXF5JTHA6js.ProgressEvent.FileSkipped:
191
- console.log(import_log_symbols.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`);
192
927
  break;
193
- case _chunkXF5JTHA6js.ProgressEvent.GitCommit:
194
- console.log(import_log_symbols.success, "Git commit");
928
+ case "git commit" /* GitCommit */:
929
+ console.log(import_log_symbols2.success, "Git commit");
195
930
  break;
196
- case _chunkXF5JTHA6js.ProgressEvent.GitTag:
197
- console.log(import_log_symbols.success, "Git tag");
931
+ case "git tag" /* GitTag */:
932
+ console.log(import_log_symbols2.success, "Git tag");
198
933
  break;
199
- case _chunkXF5JTHA6js.ProgressEvent.GitPush:
200
- console.log(import_log_symbols.success, "Git push");
934
+ case "git push" /* GitPush */:
935
+ console.log(import_log_symbols2.success, "Git push");
201
936
  break;
202
- case _chunkXF5JTHA6js.ProgressEvent.NpmScript:
203
- console.log(import_log_symbols.success, `Npm run ${script}`);
937
+ case "npm script" /* NpmScript */:
938
+ console.log(import_log_symbols2.success, `Npm run ${script}`);
204
939
  break;
205
940
  }
206
941
  }
@@ -210,8 +945,10 @@ function errorHandler2(error) {
210
945
  message = error.stack || message;
211
946
  }
212
947
  console.error(message);
213
- process.exit(ExitCode.FatalError);
948
+ process.exit(1 /* FatalError */);
214
949
  }
215
-
216
-
217
- 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
+ });