bumpp 9.10.1 → 9.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +1,10 @@
1
1
  import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
6
  var __getProtoOf = Object.getPrototypeOf;
10
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
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
8
  var __commonJS = (cb, mod) => function __require() {
38
9
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
39
10
  };
@@ -141,8 +112,7 @@ __export(symbols_exports, {
141
112
 
142
113
  // node_modules/.pnpm/yoctocolors@2.1.1/node_modules/yoctocolors/base.js
143
114
  import tty from "node:tty";
144
- var _a, _b, _c, _d, _e;
145
- var hasColors = (_e = (_d = (_c = (_b = (_a = tty) == null ? void 0 : _a.WriteStream) == null ? void 0 : _b.prototype) == null ? void 0 : _c.hasColors) == null ? void 0 : _d.call(_c)) != null ? _e : false;
115
+ var hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false;
146
116
  var format = (open, close) => {
147
117
  if (!hasColors) {
148
118
  return (input) => input;
@@ -228,7 +198,7 @@ var error = red(_isUnicodeSupported ? "\u2716\uFE0F" : "\xD7");
228
198
 
229
199
  // src/release-type.ts
230
200
  var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
231
- var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]);
201
+ var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next", "conventional"]);
232
202
  function isPrerelease(value) {
233
203
  return prereleaseTypes.includes(value);
234
204
  }
@@ -298,7 +268,7 @@ var tokenizeArgs = (argsString, options) => {
298
268
  if (currentToken.length > 0) {
299
269
  tokens.push(currentToken);
300
270
  }
301
- if (options == null ? void 0 : options.loose) {
271
+ if (options?.loose) {
302
272
  return tokens;
303
273
  }
304
274
  if (openningQuote) {
@@ -308,9 +278,10 @@ var tokenizeArgs = (argsString, options) => {
308
278
  };
309
279
 
310
280
  // src/version-bump.ts
311
- var import_picocolors3 = __toESM(require_picocolors());
281
+ var import_picocolors3 = __toESM(require_picocolors(), 1);
312
282
  import prompts2 from "prompts";
313
- import { x as x4 } from "tinyexec";
283
+ import { getRecentCommits } from "tiny-conventional-commits-parser";
284
+ import { x as x3 } from "tinyexec";
314
285
 
315
286
  // src/get-current-version.ts
316
287
  import { valid as isValidVersion } from "semver";
@@ -323,15 +294,15 @@ async function readJsoncFile(name, cwd) {
323
294
  const file = await readTextFile(name, cwd);
324
295
  const data = jsonc.parse(file.data);
325
296
  const modified = [];
326
- return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
297
+ return { ...file, data, modified, text: file.data };
327
298
  }
328
299
  async function writeJsoncFile(file) {
329
300
  let newJSON = file.text;
330
301
  for (const [key, value] of file.modified) {
331
- const edit = jsonc.modify(file.text, key, value, {});
302
+ const edit = jsonc.modify(newJSON, key, value, {});
332
303
  newJSON = jsonc.applyEdits(newJSON, edit);
333
304
  }
334
- return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
305
+ return writeTextFile({ ...file, data: newJSON });
335
306
  }
336
307
  function readTextFile(name, cwd) {
337
308
  return new Promise((resolve, reject) => {
@@ -364,8 +335,7 @@ function isManifest(obj) {
364
335
  return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
365
336
  }
366
337
  function isPackageLockManifest(manifest) {
367
- var _a2, _b2;
368
- return typeof ((_b2 = (_a2 = manifest.packages) == null ? void 0 : _a2[""]) == null ? void 0 : _b2.version) === "string";
338
+ return typeof manifest.packages?.[""]?.version === "string";
369
339
  }
370
340
  function isOptionalString(value) {
371
341
  const type = typeof value;
@@ -404,153 +374,22 @@ async function readVersion(file, cwd) {
404
374
  if (isValidVersion(manifest.version))
405
375
  return manifest.version;
406
376
  }
407
- } catch (e) {
377
+ } catch {
408
378
  return void 0;
409
379
  }
410
380
  }
411
381
 
412
382
  // src/get-new-version.ts
413
- var import_picocolors2 = __toESM(require_picocolors());
383
+ var import_picocolors = __toESM(require_picocolors(), 1);
414
384
  import process3 from "node:process";
415
385
  import prompts from "prompts";
416
386
  import semver, { clean as cleanVersion, valid as isValidVersion2, SemVer } from "semver";
417
-
418
- // src/print-commits.ts
419
- var import_picocolors = __toESM(require_picocolors());
420
- import { x } from "tinyexec";
421
- var messageColorMap = {
422
- feat: import_picocolors.default.green,
423
- feature: import_picocolors.default.green,
424
- refactor: import_picocolors.default.cyan,
425
- style: import_picocolors.default.cyan,
426
- docs: import_picocolors.default.blue,
427
- doc: import_picocolors.default.blue,
428
- types: import_picocolors.default.blue,
429
- type: import_picocolors.default.blue,
430
- chore: import_picocolors.default.gray,
431
- ci: import_picocolors.default.gray,
432
- build: import_picocolors.default.gray,
433
- deps: import_picocolors.default.gray,
434
- dev: import_picocolors.default.gray,
435
- fix: import_picocolors.default.yellow,
436
- test: import_picocolors.default.yellow,
437
- perf: import_picocolors.default.magenta,
438
- revert: import_picocolors.default.red,
439
- breaking: import_picocolors.default.red
440
- };
441
- function parseCommits(raw) {
442
- const lines = raw.toString().trim().split(/\n/g);
443
- if (!lines.length) {
444
- return [];
445
- }
446
- return lines.map((line) => {
447
- const [hash, ...parts] = line.split(" ");
448
- const message = parts.join(" ");
449
- const match = message.match(/^(\w+)(!)?(\([^)]+\))?(!)?:(.*)$/);
450
- if (match) {
451
- let color = messageColorMap[match[1].toLowerCase()] || ((c4) => c4);
452
- const breaking = match[2] === "!" || match[4] === "!";
453
- if (breaking) {
454
- color = (s) => import_picocolors.default.inverse(import_picocolors.default.red(s));
455
- }
456
- const tag = [match[1], match[2], match[4]].filter(Boolean).join("");
457
- const scope = match[3] || "";
458
- return {
459
- hash,
460
- tag,
461
- message: match[5].trim(),
462
- scope,
463
- breaking,
464
- color
465
- };
466
- }
467
- return {
468
- hash,
469
- tag: "",
470
- message,
471
- scope: "",
472
- color: (c4) => c4
473
- };
474
- }).reverse();
475
- }
476
- function formatParsedCommits(commits) {
477
- const tagLength = commits.map(({ tag }) => tag.length).reduce((a, b) => Math.max(a, b), 0);
478
- let scopeLength = commits.map(({ scope }) => scope.length).reduce((a, b) => Math.max(a, b), 0);
479
- if (scopeLength)
480
- scopeLength += 2;
481
- return commits.map(({ hash, tag, message, scope, color }) => {
482
- const paddedTag = tag.padStart(tagLength + 1, " ");
483
- const paddedScope = !scope ? " ".repeat(scopeLength) : import_picocolors.default.dim("(") + scope.slice(1, -1) + import_picocolors.default.dim(")") + " ".repeat(scopeLength - scope.length);
484
- return [
485
- import_picocolors.default.dim(hash),
486
- " ",
487
- color === import_picocolors.default.gray ? color(paddedTag) : import_picocolors.default.bold(color(paddedTag)),
488
- " ",
489
- paddedScope,
490
- import_picocolors.default.dim(":"),
491
- " ",
492
- color === import_picocolors.default.gray ? color(message) : message
493
- ].join("");
494
- });
495
- }
496
- async function printRecentCommits(operation) {
497
- let sha;
498
- sha || (sha = await x(
499
- "git",
500
- ["rev-list", "-n", "1", `v${operation.state.currentVersion}`],
501
- { nodeOptions: { stdio: "pipe" }, throwOnError: false }
502
- ).then((res) => res.stdout.trim()));
503
- sha || (sha = await x(
504
- "git",
505
- ["rev-list", "-n", "1", operation.state.currentVersion],
506
- { nodeOptions: { stdio: "pipe" }, throwOnError: false }
507
- ).then((res) => res.stdout.trim()));
508
- if (!sha) {
509
- console.log(
510
- import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` Failed to locate the previous tag ${import_picocolors.default.yellow(`v${operation.state.currentVersion}`)}`)
511
- );
512
- return;
513
- }
514
- const { stdout } = await x(
515
- "git",
516
- [
517
- "--no-pager",
518
- "log",
519
- `${sha}..HEAD`,
520
- "--oneline"
521
- ],
522
- {
523
- nodeOptions: {
524
- stdio: "pipe"
525
- }
526
- }
527
- );
528
- const parsed = parseCommits(stdout.toString().trim());
529
- const prettified = formatParsedCommits(parsed);
530
- if (!parsed.length) {
531
- console.log();
532
- console.log(import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` No commits since ${operation.state.currentVersion}`));
533
- console.log();
534
- return;
535
- }
536
- console.log();
537
- console.log(
538
- import_picocolors.default.bold(
539
- `${import_picocolors.default.green(parsed.length)} Commits since ${import_picocolors.default.gray(sha.slice(0, 7))}:`
540
- )
541
- );
542
- console.log();
543
- console.log(prettified.join("\n"));
544
- console.log();
545
- }
546
-
547
- // src/get-new-version.ts
548
- async function getNewVersion(operation) {
387
+ async function getNewVersion(operation, commits) {
549
388
  const { release } = operation.options;
550
389
  const { currentVersion } = operation.state;
551
390
  switch (release.type) {
552
391
  case "prompt":
553
- return promptForNewVersion(operation);
392
+ return promptForNewVersion(operation, commits);
554
393
  case "version":
555
394
  return operation.update({
556
395
  newVersion: new SemVer(release.version, true).version
@@ -558,13 +397,20 @@ async function getNewVersion(operation) {
558
397
  default:
559
398
  return operation.update({
560
399
  release: release.type,
561
- newVersion: getNextVersion(currentVersion, release)
400
+ newVersion: getNextVersion(currentVersion, release, commits)
562
401
  });
563
402
  }
564
403
  }
565
- function getNextVersion(currentVersion, bump) {
404
+ function getNextVersion(currentVersion, bump, commits) {
566
405
  const oldSemVer = new SemVer(currentVersion);
567
- const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type;
406
+ let type;
407
+ if (bump.type === "next") {
408
+ type = oldSemVer.prerelease.length ? "prerelease" : "patch";
409
+ } else if (bump.type === "conventional") {
410
+ type = oldSemVer.prerelease.length ? "prerelease" : determineSemverChange(commits);
411
+ } else {
412
+ type = bump.type;
413
+ }
568
414
  const newSemVer = oldSemVer.inc(type, bump.preid);
569
415
  if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
570
416
  newSemVer.prerelease[1] = "1";
@@ -572,43 +418,51 @@ function getNextVersion(currentVersion, bump) {
572
418
  }
573
419
  return newSemVer.version;
574
420
  }
575
- function getNextVersions(currentVersion, preid) {
421
+ function determineSemverChange(commits) {
422
+ let [hasMajor, hasMinor] = [false, false];
423
+ for (const commit of commits) {
424
+ if (commit.isBreaking) {
425
+ hasMajor = true;
426
+ } else if (commit.type === "feat") {
427
+ hasMinor = true;
428
+ }
429
+ }
430
+ return hasMajor ? "major" : hasMinor ? "minor" : "patch";
431
+ }
432
+ function getNextVersions(currentVersion, preid, commits) {
576
433
  const next = {};
577
434
  const parse2 = semver.parse(currentVersion);
578
- if (typeof (parse2 == null ? void 0 : parse2.prerelease[0]) === "string")
579
- preid = (parse2 == null ? void 0 : parse2.prerelease[0]) || "preid";
435
+ if (typeof parse2?.prerelease[0] === "string")
436
+ preid = parse2?.prerelease[0] || "preid";
580
437
  for (const type of releaseTypes)
581
- next[type] = getNextVersion(currentVersion, { type, preid });
438
+ next[type] = getNextVersion(currentVersion, { type, preid }, commits);
582
439
  return next;
583
440
  }
584
- async function promptForNewVersion(operation) {
585
- var _a2, _b2;
441
+ async function promptForNewVersion(operation, commits) {
586
442
  const { currentVersion } = operation.state;
587
443
  const release = operation.options.release;
588
- const next = getNextVersions(currentVersion, release.preid);
589
- const configCustomVersion = await ((_b2 = (_a2 = operation.options).customVersion) == null ? void 0 : _b2.call(_a2, currentVersion, semver));
590
- if (operation.options.printCommits) {
591
- await printRecentCommits(operation);
592
- }
444
+ const next = getNextVersions(currentVersion, release.preid, commits);
445
+ const configCustomVersion = await operation.options.customVersion?.(currentVersion, semver);
593
446
  const PADDING = 13;
594
447
  const answers = await prompts([
595
448
  {
596
449
  type: "autocomplete",
597
450
  name: "release",
598
- message: `Current version ${import_picocolors2.default.green(currentVersion)}`,
451
+ message: `Current version ${import_picocolors.default.green(currentVersion)}`,
599
452
  initial: configCustomVersion ? "config" : "next",
600
453
  choices: [
601
- { value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.major)}` },
602
- { value: "minor", title: `${"minor".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.minor)}` },
603
- { value: "patch", title: `${"patch".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.patch)}` },
604
- { value: "next", title: `${"next".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.next)}` },
454
+ { value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.major)}` },
455
+ { value: "minor", title: `${"minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.minor)}` },
456
+ { value: "patch", title: `${"patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.patch)}` },
457
+ { value: "next", title: `${"next".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.next)}` },
458
+ { value: "conventional", title: `${"conventional".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.conventional)}` },
605
459
  ...configCustomVersion ? [
606
- { value: "config", title: `${"from config".padStart(PADDING, " ")} ${import_picocolors2.default.bold(configCustomVersion)}` }
460
+ { value: "config", title: `${"from config".padStart(PADDING, " ")} ${import_picocolors.default.bold(configCustomVersion)}` }
607
461
  ] : [],
608
- { value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.prepatch)}` },
609
- { value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.preminor)}` },
610
- { value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.premajor)}` },
611
- { value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors2.default.bold(currentVersion)}` },
462
+ { value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.prepatch)}` },
463
+ { value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.preminor)}` },
464
+ { value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` },
465
+ { value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(currentVersion)}` },
612
466
  { value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
613
467
  ]
614
468
  },
@@ -629,6 +483,7 @@ async function promptForNewVersion(operation) {
629
483
  case "custom":
630
484
  case "config":
631
485
  case "next":
486
+ case "conventional":
632
487
  case "none":
633
488
  return operation.update({ newVersion });
634
489
  default:
@@ -637,7 +492,7 @@ async function promptForNewVersion(operation) {
637
492
  }
638
493
 
639
494
  // src/git.ts
640
- import { x as x2 } from "tinyexec";
495
+ import { x } from "tinyexec";
641
496
  async function gitCommit(operation) {
642
497
  if (!operation.options.commit)
643
498
  return operation;
@@ -657,7 +512,7 @@ async function gitCommit(operation) {
657
512
  args.push("--message", commitMessage);
658
513
  if (!all)
659
514
  args = args.concat(updatedFiles);
660
- await x2("git", ["commit", ...args], { throwOnError: true });
515
+ await x("git", ["commit", ...args], { throwOnError: true });
661
516
  return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
662
517
  }
663
518
  async function gitTag(operation) {
@@ -678,15 +533,15 @@ async function gitTag(operation) {
678
533
  if (operation.options.sign) {
679
534
  args.push("--sign");
680
535
  }
681
- await x2("git", ["tag", ...args], { throwOnError: true });
536
+ await x("git", ["tag", ...args], { throwOnError: true });
682
537
  return operation.update({ event: "git tag" /* GitTag */, tagName });
683
538
  }
684
539
  async function gitPush(operation) {
685
540
  if (!operation.options.push)
686
541
  return operation;
687
- await x2("git", ["push"], { throwOnError: true });
542
+ await x("git", ["push"], { throwOnError: true });
688
543
  if (operation.options.tag) {
689
- await x2("git", ["push", "--tags"], { throwOnError: true });
544
+ await x("git", ["push", "--tags"], { throwOnError: true });
690
545
  }
691
546
  return operation.update({ event: "git push" /* GitPush */ });
692
547
  }
@@ -704,7 +559,6 @@ import process4 from "node:process";
704
559
  import yaml from "js-yaml";
705
560
  import { glob } from "tinyglobby";
706
561
  async function normalizeOptions(raw) {
707
- var _a2, _b2, _d2;
708
562
  const preid = typeof raw.preid === "string" ? raw.preid : "beta";
709
563
  const sign = Boolean(raw.sign);
710
564
  const push = Boolean(raw.push);
@@ -732,7 +586,7 @@ async function normalizeOptions(raw) {
732
586
  commit = { all, noVerify, message: raw.commit };
733
587
  else if (raw.commit || tag || push)
734
588
  commit = { all, noVerify, message: "chore: release v" };
735
- if (recursive && !((_a2 = raw.files) == null ? void 0 : _a2.length)) {
589
+ if (recursive && !raw.files?.length) {
736
590
  raw.files = [
737
591
  "package.json",
738
592
  "package-lock.json",
@@ -746,14 +600,11 @@ async function normalizeOptions(raw) {
746
600
  const pnpmWorkspace = await fs2.readFile("pnpm-workspace.yaml", "utf8");
747
601
  const workspaces = yaml.load(pnpmWorkspace);
748
602
  const workspacesWithPackageJson = workspaces.packages.map((workspace) => `${workspace}/package.json`);
749
- const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => {
750
- var _a3;
751
- return !workspace.startsWith("!") && !((_a3 = raw.files) == null ? void 0 : _a3.includes(workspace));
752
- });
603
+ const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => !workspace.startsWith("!") && !raw.files?.includes(workspace));
753
604
  raw.files = raw.files.concat(withoutExcludedWorkspaces);
754
605
  }
755
606
  } else {
756
- 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"];
607
+ raw.files = raw.files?.length ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc", "deno.json", "deno.jsonc"];
757
608
  }
758
609
  const files = await glob(
759
610
  raw.files,
@@ -772,12 +623,12 @@ async function normalizeOptions(raw) {
772
623
  } else if (raw.interface === true || !raw.interface) {
773
624
  ui = { input: process4.stdin, output: process4.stdout };
774
625
  } else {
775
- let _c2 = raw.interface, { input, output } = _c2, other = __objRest(_c2, ["input", "output"]);
626
+ let { input, output, ...other } = raw.interface;
776
627
  if (input === true || input !== false && !input)
777
628
  input = process4.stdin;
778
629
  if (output === true || output !== false && !output)
779
630
  output = process4.stdout;
780
- ui = __spreadValues({ input, output }, other);
631
+ ui = { input, output, ...other };
781
632
  }
782
633
  if (release.type === "prompt" && !(ui.input && ui.output))
783
634
  throw new Error("Cannot prompt for the version number because input or output has been disabled.");
@@ -793,7 +644,7 @@ async function normalizeOptions(raw) {
793
644
  interface: ui,
794
645
  ignoreScripts,
795
646
  execute,
796
- printCommits: (_d2 = raw.printCommits) != null ? _d2 : true,
647
+ printCommits: raw.printCommits ?? true,
797
648
  customVersion: raw.customVersion,
798
649
  currentVersion: raw.currentVersion
799
650
  };
@@ -802,31 +653,22 @@ async function normalizeOptions(raw) {
802
653
  // src/operation.ts
803
654
  var Operation = class _Operation {
804
655
  /**
805
- * Private constructor. Use the `Operation.start()` static method instead.
656
+ * The options for this operation.
806
657
  */
807
- constructor(options, progress) {
808
- /**
809
- * The current state of the operation.
810
- */
811
- this.state = {
812
- release: void 0,
813
- currentVersion: "",
814
- currentVersionSource: "",
815
- newVersion: "",
816
- commitMessage: "",
817
- tagName: "",
818
- updatedFiles: [],
819
- skippedFiles: []
820
- };
821
- this.options = options;
822
- this._progress = progress;
823
- if (options.currentVersion) {
824
- this.update({
825
- currentVersion: options.currentVersion,
826
- currentVersionSource: "user"
827
- });
828
- }
829
- }
658
+ options;
659
+ /**
660
+ * The current state of the operation.
661
+ */
662
+ state = {
663
+ release: void 0,
664
+ currentVersion: "",
665
+ currentVersionSource: "",
666
+ newVersion: "",
667
+ commitMessage: "",
668
+ tagName: "",
669
+ updatedFiles: [],
670
+ skippedFiles: []
671
+ };
830
672
  /**
831
673
  * The results of the operation.
832
674
  */
@@ -843,6 +685,23 @@ var Operation = class _Operation {
843
685
  skippedFiles: state.skippedFiles.slice()
844
686
  };
845
687
  }
688
+ /**
689
+ * The callback that's used to report the progress of the operation.
690
+ */
691
+ _progress;
692
+ /**
693
+ * Private constructor. Use the `Operation.start()` static method instead.
694
+ */
695
+ constructor(options, progress) {
696
+ this.options = options;
697
+ this._progress = progress;
698
+ if (options.currentVersion) {
699
+ this.update({
700
+ currentVersion: options.currentVersion,
701
+ currentVersionSource: "user"
702
+ });
703
+ }
704
+ }
846
705
  /**
847
706
  * Starts a new `versionBump()` operation.
848
707
  */
@@ -853,24 +712,86 @@ var Operation = class _Operation {
853
712
  /**
854
713
  * Updates the operation state and results, and reports the updated progress to the user.
855
714
  */
856
- update(_a2) {
857
- var _b2 = _a2, { event, script } = _b2, newState = __objRest(_b2, ["event", "script"]);
715
+ update({ event, script, ...newState }) {
858
716
  Object.assign(this.state, newState);
859
717
  if (event && this._progress) {
860
- this._progress(__spreadValues({ event, script }, this.results));
718
+ this._progress({ event, script, ...this.results });
861
719
  }
862
720
  return this;
863
721
  }
864
722
  };
865
723
 
724
+ // src/print-commits.ts
725
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
726
+ var messageColorMap = {
727
+ feat: import_picocolors2.default.green,
728
+ feature: import_picocolors2.default.green,
729
+ refactor: import_picocolors2.default.cyan,
730
+ style: import_picocolors2.default.cyan,
731
+ docs: import_picocolors2.default.blue,
732
+ doc: import_picocolors2.default.blue,
733
+ types: import_picocolors2.default.blue,
734
+ type: import_picocolors2.default.blue,
735
+ chore: import_picocolors2.default.gray,
736
+ ci: import_picocolors2.default.gray,
737
+ build: import_picocolors2.default.gray,
738
+ deps: import_picocolors2.default.gray,
739
+ dev: import_picocolors2.default.gray,
740
+ fix: import_picocolors2.default.yellow,
741
+ test: import_picocolors2.default.yellow,
742
+ perf: import_picocolors2.default.magenta,
743
+ revert: import_picocolors2.default.red,
744
+ breaking: import_picocolors2.default.red
745
+ };
746
+ function formatParsedCommits(commits) {
747
+ const typeLength = commits.map(({ type }) => type.length).reduce((a, b) => Math.max(a, b), 0);
748
+ const scopeLength = commits.map(({ scope }) => scope.length).reduce((a, b) => Math.max(a, b), 0);
749
+ return commits.map((commit) => {
750
+ let color = messageColorMap[commit.type] || ((c4) => c4);
751
+ if (commit.isBreaking) {
752
+ color = (s) => import_picocolors2.default.inverse(import_picocolors2.default.red(s));
753
+ }
754
+ const paddedType = commit.type.padStart(typeLength + 1, " ");
755
+ const paddedScope = !commit.scope ? " ".repeat(scopeLength ? scopeLength + 2 : 0) : import_picocolors2.default.dim("(") + commit.scope + import_picocolors2.default.dim(")") + " ".repeat(scopeLength - commit.scope.length);
756
+ return [
757
+ import_picocolors2.default.dim(commit.shortHash),
758
+ " ",
759
+ color === import_picocolors2.default.gray ? color(paddedType) : import_picocolors2.default.bold(color(paddedType)),
760
+ " ",
761
+ paddedScope,
762
+ import_picocolors2.default.dim(":"),
763
+ " ",
764
+ color === import_picocolors2.default.gray ? color(commit.description) : commit.description
765
+ ].join("");
766
+ });
767
+ }
768
+ function printRecentCommits(commits) {
769
+ if (!commits.length) {
770
+ console.log();
771
+ console.log(import_picocolors2.default.blue(`i`) + import_picocolors2.default.gray(` No commits since the last version`));
772
+ console.log();
773
+ return;
774
+ }
775
+ const prettified = formatParsedCommits(commits);
776
+ console.log();
777
+ console.log(
778
+ import_picocolors2.default.bold(
779
+ `${import_picocolors2.default.green(commits.length)} Commits since the last version:`
780
+ )
781
+ );
782
+ console.log();
783
+ console.log(prettified.join("\n"));
784
+ console.log();
785
+ }
786
+
866
787
  // src/run-npm-script.ts
867
- import { x as x3 } from "tinyexec";
788
+ import { x as x2 } from "tinyexec";
868
789
  async function runNpmScript(script, operation) {
869
790
  const { cwd, ignoreScripts } = operation.options;
870
791
  if (!ignoreScripts) {
871
792
  const { data: manifest } = await readJsoncFile("package.json", cwd);
872
793
  if (isManifest(manifest) && hasScript(manifest, script)) {
873
- await x3("npm", ["run", script, "--silent"], {
794
+ await x2("npm", ["run", script, "--silent"], {
874
795
  nodeOptions: { stdio: "inherit" }
875
796
  });
876
797
  operation.update({ event: "npm script" /* NpmScript */, script });
@@ -907,7 +828,7 @@ async function updateFiles(operation) {
907
828
  return operation;
908
829
  }
909
830
  async function updateFile(relPath, operation) {
910
- if (!existsSync(relPath)) {
831
+ if (!existsSync(path2.join(operation.options.cwd, relPath))) {
911
832
  return false;
912
833
  }
913
834
  const name = path2.basename(relPath).trim().toLowerCase();
@@ -965,8 +886,12 @@ async function versionBump(arg = {}) {
965
886
  if (typeof arg === "string")
966
887
  arg = { release: arg };
967
888
  const operation = await Operation.start(arg);
889
+ const commits = getRecentCommits();
890
+ if (operation.options.printCommits) {
891
+ printRecentCommits(commits);
892
+ }
968
893
  await getCurrentVersion(operation);
969
- await getNewVersion(operation);
894
+ await getNewVersion(operation, commits);
970
895
  if (arg.confirm) {
971
896
  printSummary(operation);
972
897
  if (!await prompts2({
@@ -983,7 +908,7 @@ async function versionBump(arg = {}) {
983
908
  if (operation.options.install) {
984
909
  const { detect } = await import("package-manager-detector/detect");
985
910
  const pm = await detect();
986
- if (!(pm == null ? void 0 : pm.name)) {
911
+ if (!pm?.name) {
987
912
  throw new Error("Could not detect package manager, failed to run npm install");
988
913
  }
989
914
  const { COMMANDS, constructCommand } = await import("package-manager-detector/commands");
@@ -992,7 +917,7 @@ async function versionBump(arg = {}) {
992
917
  throw new Error("Could not find install command for package manager");
993
918
  }
994
919
  console.log(symbols_exports.info, "Installing dependencies with", `${command.command} ${command.args.join(" ")}`);
995
- await x4(command.command, command.args, {
920
+ await x3(command.command, command.args, {
996
921
  throwOnError: true,
997
922
  nodeOptions: {
998
923
  stdio: "inherit",
@@ -1007,7 +932,7 @@ async function versionBump(arg = {}) {
1007
932
  } else {
1008
933
  const [command, ...args] = tokenizeArgs(operation.options.execute);
1009
934
  console.log(symbols_exports.info, "Executing script", command, ...args);
1010
- await x4(command, args, {
935
+ await x3(command, args, {
1011
936
  throwOnError: true,
1012
937
  nodeOptions: {
1013
938
  stdio: "inherit",
@@ -1046,8 +971,9 @@ async function versionBumpInfo(arg = {}) {
1046
971
  if (typeof arg === "string")
1047
972
  arg = { release: arg };
1048
973
  const operation = await Operation.start(arg);
974
+ const commits = getRecentCommits();
1049
975
  await getCurrentVersion(operation);
1050
- await getNewVersion(operation);
976
+ await getNewVersion(operation, commits);
1051
977
  return operation;
1052
978
  }
1053
979
 
@@ -1076,7 +1002,9 @@ async function loadBumpConfig(overrides, cwd = process6.cwd()) {
1076
1002
  const { config } = await loadConfig({
1077
1003
  name,
1078
1004
  defaults: bumpConfigDefaults,
1079
- overrides: __spreadValues({}, overrides),
1005
+ overrides: {
1006
+ ...overrides
1007
+ },
1080
1008
  cwd: configFile ? dirname(configFile) : cwd
1081
1009
  });
1082
1010
  return config;
@@ -1111,9 +1039,6 @@ function defineConfig(config) {
1111
1039
  }
1112
1040
 
1113
1041
  export {
1114
- __spreadValues,
1115
- __spreadProps,
1116
- __objRest,
1117
1042
  __toESM,
1118
1043
  symbols_exports,
1119
1044
  require_picocolors,