bumpp 9.10.2 → 9.11.1

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,38 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  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 __objRest = (source, exclude) => {
25
- var target = {};
26
- for (var prop in source)
27
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
- target[prop] = source[prop];
29
- if (source != null && __getOwnPropSymbols)
30
- for (var prop of __getOwnPropSymbols(source)) {
31
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
- target[prop] = source[prop];
33
- }
34
- return target;
35
- };
36
7
  var __commonJS = (cb, mod) => function __require() {
37
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
38
9
  };
@@ -130,14 +101,16 @@ var require_picocolors = __commonJS({
130
101
  }
131
102
  });
132
103
 
133
- // src/cli/index.ts
104
+ // src/cli.ts
134
105
  var cli_exports = {};
135
106
  __export(cli_exports, {
136
107
  checkGitStatus: () => checkGitStatus,
137
108
  main: () => main
138
109
  });
139
110
  module.exports = __toCommonJS(cli_exports);
140
- var import_node_process7 = __toESM(require("process"));
111
+
112
+ // src/cli/index.ts
113
+ var import_node_process7 = __toESM(require("process"), 1);
141
114
 
142
115
  // node_modules/.pnpm/log-symbols@7.0.0/node_modules/log-symbols/symbols.js
143
116
  var symbols_exports = {};
@@ -150,8 +123,7 @@ __export(symbols_exports, {
150
123
 
151
124
  // node_modules/.pnpm/yoctocolors@2.1.1/node_modules/yoctocolors/base.js
152
125
  var import_node_tty = __toESM(require("tty"), 1);
153
- var _a, _b, _c, _d, _e;
154
- var hasColors = (_e = (_d = (_c = (_b = (_a = import_node_tty.default) == null ? void 0 : _a.WriteStream) == null ? void 0 : _b.prototype) == null ? void 0 : _c.hasColors) == null ? void 0 : _d.call(_c)) != null ? _e : false;
126
+ var hasColors = import_node_tty.default?.WriteStream?.prototype?.hasColors?.() ?? false;
155
127
  var format = (open, close) => {
156
128
  if (!hasColors) {
157
129
  return (input) => input;
@@ -236,10 +208,10 @@ var warning = yellow(_isUnicodeSupported ? "\u26A0" : "\u203C");
236
208
  var error = red(_isUnicodeSupported ? "\u2716\uFE0F" : "\xD7");
237
209
 
238
210
  // src/cli/index.ts
239
- var import_tinyexec5 = require("tinyexec");
211
+ var import_tinyexec4 = require("tinyexec");
240
212
 
241
213
  // src/version-bump.ts
242
- var import_node_process4 = __toESM(require("process"));
214
+ var import_node_process4 = __toESM(require("process"), 1);
243
215
 
244
216
  // node_modules/.pnpm/args-tokenizer@0.3.0/node_modules/args-tokenizer/dist/args-tokenizer.js
245
217
  var spaceRegex = /\s/;
@@ -283,7 +255,7 @@ var tokenizeArgs = (argsString, options) => {
283
255
  if (currentToken.length > 0) {
284
256
  tokens.push(currentToken);
285
257
  }
286
- if (options == null ? void 0 : options.loose) {
258
+ if (options?.loose) {
287
259
  return tokens;
288
260
  }
289
261
  if (openningQuote) {
@@ -293,22 +265,23 @@ var tokenizeArgs = (argsString, options) => {
293
265
  };
294
266
 
295
267
  // src/version-bump.ts
296
- var import_picocolors3 = __toESM(require_picocolors());
297
- var import_prompts2 = __toESM(require("prompts"));
298
- var import_tinyexec4 = require("tinyexec");
268
+ var import_picocolors3 = __toESM(require_picocolors(), 1);
269
+ var import_prompts2 = __toESM(require("prompts"), 1);
270
+ var import_tiny_conventional_commits_parser = require("tiny-conventional-commits-parser");
271
+ var import_tinyexec3 = require("tinyexec");
299
272
 
300
273
  // src/get-current-version.ts
301
274
  var import_semver = require("semver");
302
275
 
303
276
  // src/fs.ts
304
- var import_node_fs = __toESM(require("fs"));
305
- var import_node_path = __toESM(require("path"));
306
- var jsonc = __toESM(require("jsonc-parser"));
277
+ var import_node_fs = __toESM(require("fs"), 1);
278
+ var import_node_path = __toESM(require("path"), 1);
279
+ var jsonc = __toESM(require("jsonc-parser"), 1);
307
280
  async function readJsoncFile(name, cwd) {
308
281
  const file = await readTextFile(name, cwd);
309
282
  const data = jsonc.parse(file.data);
310
283
  const modified = [];
311
- return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
284
+ return { ...file, data, modified, text: file.data };
312
285
  }
313
286
  async function writeJsoncFile(file) {
314
287
  let newJSON = file.text;
@@ -316,7 +289,7 @@ async function writeJsoncFile(file) {
316
289
  const edit = jsonc.modify(newJSON, key, value, {});
317
290
  newJSON = jsonc.applyEdits(newJSON, edit);
318
291
  }
319
- return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
292
+ return writeTextFile({ ...file, data: newJSON });
320
293
  }
321
294
  function readTextFile(name, cwd) {
322
295
  return new Promise((resolve, reject) => {
@@ -349,8 +322,7 @@ function isManifest(obj) {
349
322
  return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
350
323
  }
351
324
  function isPackageLockManifest(manifest) {
352
- var _a2, _b2;
353
- return typeof ((_b2 = (_a2 = manifest.packages) == null ? void 0 : _a2[""]) == null ? void 0 : _b2.version) === "string";
325
+ return typeof manifest.packages?.[""]?.version === "string";
354
326
  }
355
327
  function isOptionalString(value) {
356
328
  const type = typeof value;
@@ -389,149 +361,20 @@ async function readVersion(file, cwd) {
389
361
  if ((0, import_semver.valid)(manifest.version))
390
362
  return manifest.version;
391
363
  }
392
- } catch (e) {
364
+ } catch {
393
365
  return void 0;
394
366
  }
395
367
  }
396
368
 
397
369
  // src/get-new-version.ts
398
- var import_node_process2 = __toESM(require("process"));
399
- var import_picocolors2 = __toESM(require_picocolors());
400
- var import_prompts = __toESM(require("prompts"));
401
- var import_semver2 = __toESM(require("semver"));
402
-
403
- // src/print-commits.ts
404
- var import_picocolors = __toESM(require_picocolors());
405
- var import_tinyexec = require("tinyexec");
406
- var messageColorMap = {
407
- feat: import_picocolors.default.green,
408
- feature: import_picocolors.default.green,
409
- refactor: import_picocolors.default.cyan,
410
- style: import_picocolors.default.cyan,
411
- docs: import_picocolors.default.blue,
412
- doc: import_picocolors.default.blue,
413
- types: import_picocolors.default.blue,
414
- type: import_picocolors.default.blue,
415
- chore: import_picocolors.default.gray,
416
- ci: import_picocolors.default.gray,
417
- build: import_picocolors.default.gray,
418
- deps: import_picocolors.default.gray,
419
- dev: import_picocolors.default.gray,
420
- fix: import_picocolors.default.yellow,
421
- test: import_picocolors.default.yellow,
422
- perf: import_picocolors.default.magenta,
423
- revert: import_picocolors.default.red,
424
- breaking: import_picocolors.default.red
425
- };
426
- function parseCommits(raw) {
427
- const lines = raw.toString().trim().split(/\n/g);
428
- if (!lines.length) {
429
- return [];
430
- }
431
- return lines.map((line) => {
432
- const [hash, ...parts] = line.split(" ");
433
- const message = parts.join(" ");
434
- const match = message.match(/^(\w+)(!)?(\([^)]+\))?(!)?:(.*)$/);
435
- if (match) {
436
- let color = messageColorMap[match[1].toLowerCase()] || ((c5) => c5);
437
- const breaking = match[2] === "!" || match[4] === "!";
438
- if (breaking) {
439
- color = (s) => import_picocolors.default.inverse(import_picocolors.default.red(s));
440
- }
441
- const tag = [match[1], match[2], match[4]].filter(Boolean).join("");
442
- const scope = match[3] || "";
443
- return {
444
- hash,
445
- tag,
446
- message: match[5].trim(),
447
- scope,
448
- breaking,
449
- color
450
- };
451
- }
452
- return {
453
- hash,
454
- tag: "",
455
- message,
456
- scope: "",
457
- color: (c5) => c5
458
- };
459
- }).reverse();
460
- }
461
- function formatParsedCommits(commits) {
462
- const tagLength = commits.map(({ tag }) => tag.length).reduce((a, b) => Math.max(a, b), 0);
463
- let scopeLength = commits.map(({ scope }) => scope.length).reduce((a, b) => Math.max(a, b), 0);
464
- if (scopeLength)
465
- scopeLength += 2;
466
- return commits.map(({ hash, tag, message, scope, color }) => {
467
- const paddedTag = tag.padStart(tagLength + 1, " ");
468
- const paddedScope = !scope ? " ".repeat(scopeLength) : import_picocolors.default.dim("(") + scope.slice(1, -1) + import_picocolors.default.dim(")") + " ".repeat(scopeLength - scope.length);
469
- return [
470
- import_picocolors.default.dim(hash),
471
- " ",
472
- color === import_picocolors.default.gray ? color(paddedTag) : import_picocolors.default.bold(color(paddedTag)),
473
- " ",
474
- paddedScope,
475
- import_picocolors.default.dim(":"),
476
- " ",
477
- color === import_picocolors.default.gray ? color(message) : message
478
- ].join("");
479
- });
480
- }
481
- async function printRecentCommits(operation) {
482
- let sha;
483
- sha || (sha = await (0, import_tinyexec.x)(
484
- "git",
485
- ["rev-list", "-n", "1", `v${operation.state.currentVersion}`],
486
- { nodeOptions: { stdio: "pipe" }, throwOnError: false }
487
- ).then((res) => res.stdout.trim()));
488
- sha || (sha = await (0, import_tinyexec.x)(
489
- "git",
490
- ["rev-list", "-n", "1", operation.state.currentVersion],
491
- { nodeOptions: { stdio: "pipe" }, throwOnError: false }
492
- ).then((res) => res.stdout.trim()));
493
- if (!sha) {
494
- console.log(
495
- import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` Failed to locate the previous tag ${import_picocolors.default.yellow(`v${operation.state.currentVersion}`)}`)
496
- );
497
- return;
498
- }
499
- const { stdout } = await (0, import_tinyexec.x)(
500
- "git",
501
- [
502
- "--no-pager",
503
- "log",
504
- `${sha}..HEAD`,
505
- "--oneline"
506
- ],
507
- {
508
- nodeOptions: {
509
- stdio: "pipe"
510
- }
511
- }
512
- );
513
- const parsed = parseCommits(stdout.toString().trim());
514
- const prettified = formatParsedCommits(parsed);
515
- if (!parsed.length) {
516
- console.log();
517
- console.log(import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` No commits since ${operation.state.currentVersion}`));
518
- console.log();
519
- return;
520
- }
521
- console.log();
522
- console.log(
523
- import_picocolors.default.bold(
524
- `${import_picocolors.default.green(parsed.length)} Commits since ${import_picocolors.default.gray(sha.slice(0, 7))}:`
525
- )
526
- );
527
- console.log();
528
- console.log(prettified.join("\n"));
529
- console.log();
530
- }
370
+ var import_node_process2 = __toESM(require("process"), 1);
371
+ var import_picocolors = __toESM(require_picocolors(), 1);
372
+ var import_prompts = __toESM(require("prompts"), 1);
373
+ var import_semver2 = __toESM(require("semver"), 1);
531
374
 
532
375
  // src/release-type.ts
533
376
  var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
534
- var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]);
377
+ var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next", "conventional"]);
535
378
  function isPrerelease(value) {
536
379
  return prereleaseTypes.includes(value);
537
380
  }
@@ -540,12 +383,12 @@ function isReleaseType(value) {
540
383
  }
541
384
 
542
385
  // src/get-new-version.ts
543
- async function getNewVersion(operation) {
386
+ async function getNewVersion(operation, commits) {
544
387
  const { release } = operation.options;
545
388
  const { currentVersion } = operation.state;
546
389
  switch (release.type) {
547
390
  case "prompt":
548
- return promptForNewVersion(operation);
391
+ return promptForNewVersion(operation, commits);
549
392
  case "version":
550
393
  return operation.update({
551
394
  newVersion: new import_semver2.SemVer(release.version, true).version
@@ -553,13 +396,20 @@ async function getNewVersion(operation) {
553
396
  default:
554
397
  return operation.update({
555
398
  release: release.type,
556
- newVersion: getNextVersion(currentVersion, release)
399
+ newVersion: getNextVersion(currentVersion, release, commits)
557
400
  });
558
401
  }
559
402
  }
560
- function getNextVersion(currentVersion, bump) {
403
+ function getNextVersion(currentVersion, bump, commits) {
561
404
  const oldSemVer = new import_semver2.SemVer(currentVersion);
562
- const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type;
405
+ let type;
406
+ if (bump.type === "next") {
407
+ type = oldSemVer.prerelease.length ? "prerelease" : "patch";
408
+ } else if (bump.type === "conventional") {
409
+ type = oldSemVer.prerelease.length ? "prerelease" : determineSemverChange(commits);
410
+ } else {
411
+ type = bump.type;
412
+ }
563
413
  const newSemVer = oldSemVer.inc(type, bump.preid);
564
414
  if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
565
415
  newSemVer.prerelease[1] = "1";
@@ -567,43 +417,51 @@ function getNextVersion(currentVersion, bump) {
567
417
  }
568
418
  return newSemVer.version;
569
419
  }
570
- function getNextVersions(currentVersion, preid) {
420
+ function determineSemverChange(commits) {
421
+ let [hasMajor, hasMinor] = [false, false];
422
+ for (const commit of commits) {
423
+ if (commit.isBreaking) {
424
+ hasMajor = true;
425
+ } else if (commit.type === "feat") {
426
+ hasMinor = true;
427
+ }
428
+ }
429
+ return hasMajor ? "major" : hasMinor ? "minor" : "patch";
430
+ }
431
+ function getNextVersions(currentVersion, preid, commits) {
571
432
  const next = {};
572
433
  const parse2 = import_semver2.default.parse(currentVersion);
573
- if (typeof (parse2 == null ? void 0 : parse2.prerelease[0]) === "string")
574
- preid = (parse2 == null ? void 0 : parse2.prerelease[0]) || "preid";
434
+ if (typeof parse2?.prerelease[0] === "string")
435
+ preid = parse2?.prerelease[0] || "preid";
575
436
  for (const type of releaseTypes)
576
- next[type] = getNextVersion(currentVersion, { type, preid });
437
+ next[type] = getNextVersion(currentVersion, { type, preid }, commits);
577
438
  return next;
578
439
  }
579
- async function promptForNewVersion(operation) {
580
- var _a2, _b2;
440
+ async function promptForNewVersion(operation, commits) {
581
441
  const { currentVersion } = operation.state;
582
442
  const release = operation.options.release;
583
- const next = getNextVersions(currentVersion, release.preid);
584
- const configCustomVersion = await ((_b2 = (_a2 = operation.options).customVersion) == null ? void 0 : _b2.call(_a2, currentVersion, import_semver2.default));
585
- if (operation.options.printCommits) {
586
- await printRecentCommits(operation);
587
- }
443
+ const next = getNextVersions(currentVersion, release.preid, commits);
444
+ const configCustomVersion = await operation.options.customVersion?.(currentVersion, import_semver2.default);
588
445
  const PADDING = 13;
589
446
  const answers = await (0, import_prompts.default)([
590
447
  {
591
448
  type: "autocomplete",
592
449
  name: "release",
593
- message: `Current version ${import_picocolors2.default.green(currentVersion)}`,
450
+ message: `Current version ${import_picocolors.default.green(currentVersion)}`,
594
451
  initial: configCustomVersion ? "config" : "next",
595
452
  choices: [
596
- { value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.major)}` },
597
- { value: "minor", title: `${"minor".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.minor)}` },
598
- { value: "patch", title: `${"patch".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.patch)}` },
599
- { value: "next", title: `${"next".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.next)}` },
453
+ { value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.major)}` },
454
+ { value: "minor", title: `${"minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.minor)}` },
455
+ { value: "patch", title: `${"patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.patch)}` },
456
+ { value: "next", title: `${"next".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.next)}` },
457
+ { value: "conventional", title: `${"conventional".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.conventional)}` },
600
458
  ...configCustomVersion ? [
601
- { value: "config", title: `${"from config".padStart(PADDING, " ")} ${import_picocolors2.default.bold(configCustomVersion)}` }
459
+ { value: "config", title: `${"from config".padStart(PADDING, " ")} ${import_picocolors.default.bold(configCustomVersion)}` }
602
460
  ] : [],
603
- { value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.prepatch)}` },
604
- { value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.preminor)}` },
605
- { value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.premajor)}` },
606
- { value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors2.default.bold(currentVersion)}` },
461
+ { value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.prepatch)}` },
462
+ { value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.preminor)}` },
463
+ { value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` },
464
+ { value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(currentVersion)}` },
607
465
  { value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
608
466
  ]
609
467
  },
@@ -624,6 +482,7 @@ async function promptForNewVersion(operation) {
624
482
  case "custom":
625
483
  case "config":
626
484
  case "next":
485
+ case "conventional":
627
486
  case "none":
628
487
  return operation.update({ newVersion });
629
488
  default:
@@ -632,7 +491,7 @@ async function promptForNewVersion(operation) {
632
491
  }
633
492
 
634
493
  // src/git.ts
635
- var import_tinyexec2 = require("tinyexec");
494
+ var import_tinyexec = require("tinyexec");
636
495
  async function gitCommit(operation) {
637
496
  if (!operation.options.commit)
638
497
  return operation;
@@ -652,7 +511,7 @@ async function gitCommit(operation) {
652
511
  args.push("--message", commitMessage);
653
512
  if (!all)
654
513
  args = args.concat(updatedFiles);
655
- await (0, import_tinyexec2.x)("git", ["commit", ...args], { throwOnError: true });
514
+ await (0, import_tinyexec.x)("git", ["commit", ...args], { throwOnError: true });
656
515
  return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
657
516
  }
658
517
  async function gitTag(operation) {
@@ -673,15 +532,15 @@ async function gitTag(operation) {
673
532
  if (operation.options.sign) {
674
533
  args.push("--sign");
675
534
  }
676
- await (0, import_tinyexec2.x)("git", ["tag", ...args], { throwOnError: true });
535
+ await (0, import_tinyexec.x)("git", ["tag", ...args], { throwOnError: true });
677
536
  return operation.update({ event: "git tag" /* GitTag */, tagName });
678
537
  }
679
538
  async function gitPush(operation) {
680
539
  if (!operation.options.push)
681
540
  return operation;
682
- await (0, import_tinyexec2.x)("git", ["push"], { throwOnError: true });
541
+ await (0, import_tinyexec.x)("git", ["push"], { throwOnError: true });
683
542
  if (operation.options.tag) {
684
- await (0, import_tinyexec2.x)("git", ["push", "--tags"], { throwOnError: true });
543
+ await (0, import_tinyexec.x)("git", ["push", "--tags"], { throwOnError: true });
685
544
  }
686
545
  return operation.update({ event: "git push" /* GitPush */ });
687
546
  }
@@ -693,13 +552,12 @@ function formatVersionString(template, newVersion) {
693
552
  }
694
553
 
695
554
  // src/normalize-options.ts
696
- var import_node_fs2 = __toESM(require("fs"));
697
- var import_promises = __toESM(require("fs/promises"));
698
- var import_node_process3 = __toESM(require("process"));
699
- var import_js_yaml = __toESM(require("js-yaml"));
555
+ var import_node_fs2 = __toESM(require("fs"), 1);
556
+ var import_promises = __toESM(require("fs/promises"), 1);
557
+ var import_node_process3 = __toESM(require("process"), 1);
558
+ var import_js_yaml = __toESM(require("js-yaml"), 1);
700
559
  var import_tinyglobby = require("tinyglobby");
701
560
  async function normalizeOptions(raw) {
702
- var _a2, _b2, _d2;
703
561
  const preid = typeof raw.preid === "string" ? raw.preid : "beta";
704
562
  const sign = Boolean(raw.sign);
705
563
  const push = Boolean(raw.push);
@@ -727,7 +585,7 @@ async function normalizeOptions(raw) {
727
585
  commit = { all, noVerify, message: raw.commit };
728
586
  else if (raw.commit || tag || push)
729
587
  commit = { all, noVerify, message: "chore: release v" };
730
- if (recursive && !((_a2 = raw.files) == null ? void 0 : _a2.length)) {
588
+ if (recursive && !raw.files?.length) {
731
589
  raw.files = [
732
590
  "package.json",
733
591
  "package-lock.json",
@@ -741,14 +599,11 @@ async function normalizeOptions(raw) {
741
599
  const pnpmWorkspace = await import_promises.default.readFile("pnpm-workspace.yaml", "utf8");
742
600
  const workspaces = import_js_yaml.default.load(pnpmWorkspace);
743
601
  const workspacesWithPackageJson = workspaces.packages.map((workspace) => `${workspace}/package.json`);
744
- const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => {
745
- var _a3;
746
- return !workspace.startsWith("!") && !((_a3 = raw.files) == null ? void 0 : _a3.includes(workspace));
747
- });
602
+ const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => !workspace.startsWith("!") && !raw.files?.includes(workspace));
748
603
  raw.files = raw.files.concat(withoutExcludedWorkspaces);
749
604
  }
750
605
  } else {
751
- raw.files = ((_b2 = raw.files) == null ? void 0 : _b2.length) ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc", "deno.json", "deno.jsonc"];
606
+ raw.files = raw.files?.length ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc", "deno.json", "deno.jsonc"];
752
607
  }
753
608
  const files = await (0, import_tinyglobby.glob)(
754
609
  raw.files,
@@ -767,12 +622,12 @@ async function normalizeOptions(raw) {
767
622
  } else if (raw.interface === true || !raw.interface) {
768
623
  ui = { input: import_node_process3.default.stdin, output: import_node_process3.default.stdout };
769
624
  } else {
770
- let _c2 = raw.interface, { input, output } = _c2, other = __objRest(_c2, ["input", "output"]);
625
+ let { input, output, ...other } = raw.interface;
771
626
  if (input === true || input !== false && !input)
772
627
  input = import_node_process3.default.stdin;
773
628
  if (output === true || output !== false && !output)
774
629
  output = import_node_process3.default.stdout;
775
- ui = __spreadValues({ input, output }, other);
630
+ ui = { input, output, ...other };
776
631
  }
777
632
  if (release.type === "prompt" && !(ui.input && ui.output))
778
633
  throw new Error("Cannot prompt for the version number because input or output has been disabled.");
@@ -788,7 +643,7 @@ async function normalizeOptions(raw) {
788
643
  interface: ui,
789
644
  ignoreScripts,
790
645
  execute,
791
- printCommits: (_d2 = raw.printCommits) != null ? _d2 : true,
646
+ printCommits: raw.printCommits ?? true,
792
647
  customVersion: raw.customVersion,
793
648
  currentVersion: raw.currentVersion
794
649
  };
@@ -797,31 +652,22 @@ async function normalizeOptions(raw) {
797
652
  // src/operation.ts
798
653
  var Operation = class _Operation {
799
654
  /**
800
- * Private constructor. Use the `Operation.start()` static method instead.
655
+ * The options for this operation.
801
656
  */
802
- constructor(options, progress2) {
803
- /**
804
- * The current state of the operation.
805
- */
806
- this.state = {
807
- release: void 0,
808
- currentVersion: "",
809
- currentVersionSource: "",
810
- newVersion: "",
811
- commitMessage: "",
812
- tagName: "",
813
- updatedFiles: [],
814
- skippedFiles: []
815
- };
816
- this.options = options;
817
- this._progress = progress2;
818
- if (options.currentVersion) {
819
- this.update({
820
- currentVersion: options.currentVersion,
821
- currentVersionSource: "user"
822
- });
823
- }
824
- }
657
+ options;
658
+ /**
659
+ * The current state of the operation.
660
+ */
661
+ state = {
662
+ release: void 0,
663
+ currentVersion: "",
664
+ currentVersionSource: "",
665
+ newVersion: "",
666
+ commitMessage: "",
667
+ tagName: "",
668
+ updatedFiles: [],
669
+ skippedFiles: []
670
+ };
825
671
  /**
826
672
  * The results of the operation.
827
673
  */
@@ -838,6 +684,23 @@ var Operation = class _Operation {
838
684
  skippedFiles: state.skippedFiles.slice()
839
685
  };
840
686
  }
687
+ /**
688
+ * The callback that's used to report the progress of the operation.
689
+ */
690
+ _progress;
691
+ /**
692
+ * Private constructor. Use the `Operation.start()` static method instead.
693
+ */
694
+ constructor(options, progress2) {
695
+ this.options = options;
696
+ this._progress = progress2;
697
+ if (options.currentVersion) {
698
+ this.update({
699
+ currentVersion: options.currentVersion,
700
+ currentVersionSource: "user"
701
+ });
702
+ }
703
+ }
841
704
  /**
842
705
  * Starts a new `versionBump()` operation.
843
706
  */
@@ -848,24 +711,86 @@ var Operation = class _Operation {
848
711
  /**
849
712
  * Updates the operation state and results, and reports the updated progress to the user.
850
713
  */
851
- update(_a2) {
852
- var _b2 = _a2, { event, script } = _b2, newState = __objRest(_b2, ["event", "script"]);
714
+ update({ event, script, ...newState }) {
853
715
  Object.assign(this.state, newState);
854
716
  if (event && this._progress) {
855
- this._progress(__spreadValues({ event, script }, this.results));
717
+ this._progress({ event, script, ...this.results });
856
718
  }
857
719
  return this;
858
720
  }
859
721
  };
860
722
 
723
+ // src/print-commits.ts
724
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
725
+ var messageColorMap = {
726
+ feat: import_picocolors2.default.green,
727
+ feature: import_picocolors2.default.green,
728
+ refactor: import_picocolors2.default.cyan,
729
+ style: import_picocolors2.default.cyan,
730
+ docs: import_picocolors2.default.blue,
731
+ doc: import_picocolors2.default.blue,
732
+ types: import_picocolors2.default.blue,
733
+ type: import_picocolors2.default.blue,
734
+ chore: import_picocolors2.default.gray,
735
+ ci: import_picocolors2.default.gray,
736
+ build: import_picocolors2.default.gray,
737
+ deps: import_picocolors2.default.gray,
738
+ dev: import_picocolors2.default.gray,
739
+ fix: import_picocolors2.default.yellow,
740
+ test: import_picocolors2.default.yellow,
741
+ perf: import_picocolors2.default.magenta,
742
+ revert: import_picocolors2.default.red,
743
+ breaking: import_picocolors2.default.red
744
+ };
745
+ function formatParsedCommits(commits) {
746
+ const typeLength = commits.map(({ type }) => type.length).reduce((a, b) => Math.max(a, b), 0);
747
+ const scopeLength = commits.map(({ scope }) => scope.length).reduce((a, b) => Math.max(a, b), 0);
748
+ return commits.map((commit) => {
749
+ let color = messageColorMap[commit.type] || ((c5) => c5);
750
+ if (commit.isBreaking) {
751
+ color = (s) => import_picocolors2.default.inverse(import_picocolors2.default.red(s));
752
+ }
753
+ const paddedType = commit.type.padStart(typeLength + 1, " ");
754
+ const paddedScope = !commit.scope ? " ".repeat(scopeLength ? scopeLength + 2 : 0) : import_picocolors2.default.dim("(") + commit.scope + import_picocolors2.default.dim(")") + " ".repeat(scopeLength - commit.scope.length);
755
+ return [
756
+ import_picocolors2.default.dim(commit.shortHash),
757
+ " ",
758
+ color === import_picocolors2.default.gray ? color(paddedType) : import_picocolors2.default.bold(color(paddedType)),
759
+ " ",
760
+ paddedScope,
761
+ import_picocolors2.default.dim(":"),
762
+ " ",
763
+ color === import_picocolors2.default.gray ? color(commit.description) : commit.description
764
+ ].join("");
765
+ });
766
+ }
767
+ function printRecentCommits(commits) {
768
+ if (!commits.length) {
769
+ console.log();
770
+ console.log(import_picocolors2.default.blue(`i`) + import_picocolors2.default.gray(` No commits since the last version`));
771
+ console.log();
772
+ return;
773
+ }
774
+ const prettified = formatParsedCommits(commits);
775
+ console.log();
776
+ console.log(
777
+ import_picocolors2.default.bold(
778
+ `${import_picocolors2.default.green(commits.length)} Commits since the last version:`
779
+ )
780
+ );
781
+ console.log();
782
+ console.log(prettified.join("\n"));
783
+ console.log();
784
+ }
785
+
861
786
  // src/run-npm-script.ts
862
- var import_tinyexec3 = require("tinyexec");
787
+ var import_tinyexec2 = require("tinyexec");
863
788
  async function runNpmScript(script, operation) {
864
789
  const { cwd, ignoreScripts } = operation.options;
865
790
  if (!ignoreScripts) {
866
791
  const { data: manifest } = await readJsoncFile("package.json", cwd);
867
792
  if (isManifest(manifest) && hasScript(manifest, script)) {
868
- await (0, import_tinyexec3.x)("npm", ["run", script, "--silent"], {
793
+ await (0, import_tinyexec2.x)("npm", ["run", script, "--silent"], {
869
794
  nodeOptions: { stdio: "inherit" }
870
795
  });
871
796
  operation.update({ event: "npm script" /* NpmScript */, script });
@@ -882,7 +807,7 @@ function hasScript(manifest, script) {
882
807
 
883
808
  // src/update-files.ts
884
809
  var import_node_fs3 = require("fs");
885
- var path2 = __toESM(require("path"));
810
+ var path2 = __toESM(require("path"), 1);
886
811
  async function updateFiles(operation) {
887
812
  const { files } = operation.options;
888
813
  for (const relPath of files) {
@@ -960,8 +885,12 @@ async function versionBump(arg = {}) {
960
885
  if (typeof arg === "string")
961
886
  arg = { release: arg };
962
887
  const operation = await Operation.start(arg);
888
+ const commits = (0, import_tiny_conventional_commits_parser.getRecentCommits)();
889
+ if (operation.options.printCommits) {
890
+ printRecentCommits(commits);
891
+ }
963
892
  await getCurrentVersion(operation);
964
- await getNewVersion(operation);
893
+ await getNewVersion(operation, commits);
965
894
  if (arg.confirm) {
966
895
  printSummary(operation);
967
896
  if (!await (0, import_prompts2.default)({
@@ -978,7 +907,7 @@ async function versionBump(arg = {}) {
978
907
  if (operation.options.install) {
979
908
  const { detect } = await import("package-manager-detector/detect");
980
909
  const pm = await detect();
981
- if (!(pm == null ? void 0 : pm.name)) {
910
+ if (!pm?.name) {
982
911
  throw new Error("Could not detect package manager, failed to run npm install");
983
912
  }
984
913
  const { COMMANDS, constructCommand } = await import("package-manager-detector/commands");
@@ -987,7 +916,7 @@ async function versionBump(arg = {}) {
987
916
  throw new Error("Could not find install command for package manager");
988
917
  }
989
918
  console.log(symbols_exports.info, "Installing dependencies with", `${command.command} ${command.args.join(" ")}`);
990
- await (0, import_tinyexec4.x)(command.command, command.args, {
919
+ await (0, import_tinyexec3.x)(command.command, command.args, {
991
920
  throwOnError: true,
992
921
  nodeOptions: {
993
922
  stdio: "inherit",
@@ -1002,7 +931,7 @@ async function versionBump(arg = {}) {
1002
931
  } else {
1003
932
  const [command, ...args] = tokenizeArgs(operation.options.execute);
1004
933
  console.log(symbols_exports.info, "Executing script", command, ...args);
1005
- await (0, import_tinyexec4.x)(command, args, {
934
+ await (0, import_tinyexec3.x)(command, args, {
1006
935
  throwOnError: true,
1007
936
  nodeOptions: {
1008
937
  stdio: "inherit",
@@ -1039,19 +968,19 @@ function printSummary(operation) {
1039
968
  }
1040
969
 
1041
970
  // src/cli/parse-args.ts
1042
- var import_node_process6 = __toESM(require("process"));
1043
- var import_cac = __toESM(require("cac"));
1044
- var import_picocolors4 = __toESM(require_picocolors());
971
+ var import_node_process6 = __toESM(require("process"), 1);
972
+ var import_cac = __toESM(require("cac"), 1);
973
+ var import_picocolors4 = __toESM(require_picocolors(), 1);
1045
974
  var import_semver3 = require("semver");
1046
975
 
1047
976
  // package.json
1048
- var version = "9.10.2";
977
+ var version = "9.11.1";
1049
978
 
1050
979
  // src/config.ts
1051
980
  var import_node_path2 = require("path");
1052
- var import_node_process5 = __toESM(require("process"));
981
+ var import_node_process5 = __toESM(require("process"), 1);
1053
982
  var import_c12 = require("c12");
1054
- var import_sync = __toESM(require("escalade/sync"));
983
+ var import_sync = __toESM(require("escalade/sync"), 1);
1055
984
  var bumpConfigDefaults = {
1056
985
  commit: true,
1057
986
  push: true,
@@ -1072,7 +1001,9 @@ async function loadBumpConfig(overrides, cwd = import_node_process5.default.cwd(
1072
1001
  const { config } = await (0, import_c12.loadConfig)({
1073
1002
  name,
1074
1003
  defaults: bumpConfigDefaults,
1075
- overrides: __spreadValues({}, overrides),
1004
+ overrides: {
1005
+ ...overrides
1006
+ },
1076
1007
  cwd: configFile ? (0, import_node_path2.dirname)(configFile) : cwd
1077
1008
  });
1078
1009
  return config;
@@ -1105,7 +1036,6 @@ function findConfigFile(name, cwd) {
1105
1036
 
1106
1037
  // src/cli/parse-args.ts
1107
1038
  async function parseArgs() {
1108
- var _a2;
1109
1039
  try {
1110
1040
  const { args, resultArgs } = loadCliArgs();
1111
1041
  const parsedArgs = {
@@ -1138,7 +1068,7 @@ async function parseArgs() {
1138
1068
  parsedArgs.options.files.shift();
1139
1069
  }
1140
1070
  }
1141
- if (parsedArgs.options.recursive && ((_a2 = parsedArgs.options.files) == null ? void 0 : _a2.length))
1071
+ if (parsedArgs.options.recursive && parsedArgs.options.files?.length)
1142
1072
  console.log(import_picocolors4.default.yellow("The --recursive option is ignored when files are specified"));
1143
1073
  return parsedArgs;
1144
1074
  } catch (error2) {
@@ -1155,12 +1085,13 @@ function loadCliArgs(argv = import_node_process6.default.argv) {
1155
1085
  const TAG_REG = /(?:-t|--tag|--no-tag)(?:=.*|$)/;
1156
1086
  const hasCommitFlag = rawArgs.some((arg) => COMMIT_REG.test(arg));
1157
1087
  const hasTagFlag = rawArgs.some((arg) => TAG_REG.test(arg));
1158
- const _a2 = args, { tag, commit } = _a2, rest = __objRest(_a2, ["tag", "commit"]);
1088
+ const { tag, commit, ...rest } = args;
1159
1089
  return {
1160
- args: __spreadProps(__spreadValues({}, rest), {
1090
+ args: {
1091
+ ...rest,
1161
1092
  commit: hasCommitFlag ? commit : void 0,
1162
1093
  tag: hasTagFlag ? tag : void 0
1163
- }),
1094
+ },
1164
1095
  resultArgs: result.args
1165
1096
  };
1166
1097
  }
@@ -1190,7 +1121,7 @@ async function main() {
1190
1121
  }
1191
1122
  }
1192
1123
  async function checkGitStatus() {
1193
- const { stdout } = await (0, import_tinyexec5.x)("git", ["status", "--porcelain"]);
1124
+ const { stdout } = await (0, import_tinyexec4.x)("git", ["status", "--porcelain"]);
1194
1125
  if (stdout.trim()) {
1195
1126
  throw new Error(`Git working tree is not clean:
1196
1127
  ${stdout}`);