bumpp 9.6.0 → 9.7.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
@@ -134,6 +134,7 @@ var require_picocolors = __commonJS({
134
134
  // src/cli/index.ts
135
135
  var cli_exports = {};
136
136
  __export(cli_exports, {
137
+ checkGitStatus: () => checkGitStatus,
137
138
  main: () => main2
138
139
  });
139
140
  module.exports = __toCommonJS(cli_exports);
@@ -651,13 +652,16 @@ var fallback = {
651
652
  var logSymbols = isUnicodeSupported() ? main : fallback;
652
653
  var log_symbols_default = logSymbols;
653
654
 
655
+ // src/cli/index.ts
656
+ var ezSpawn5 = __toESM(require("@jsdevtools/ez-spawn"));
657
+
654
658
  // package.json
655
- var version = "9.6.0";
659
+ var version = "9.7.0";
656
660
 
657
661
  // src/version-bump.ts
658
662
  var import_node_process5 = __toESM(require("process"));
659
663
  var ezSpawn4 = __toESM(require("@jsdevtools/ez-spawn"));
660
- var import_picocolors2 = __toESM(require_picocolors());
664
+ var import_picocolors3 = __toESM(require_picocolors());
661
665
  var import_prompts2 = __toESM(require("prompts"));
662
666
 
663
667
  // src/get-current-version.ts
@@ -759,11 +763,124 @@ async function readVersion(file, cwd) {
759
763
 
760
764
  // src/get-new-version.ts
761
765
  var import_node_process3 = __toESM(require("process"));
762
- var ezSpawn = __toESM(require("@jsdevtools/ez-spawn"));
763
- var import_picocolors = __toESM(require_picocolors());
766
+ var import_picocolors2 = __toESM(require_picocolors());
764
767
  var import_prompts = __toESM(require("prompts"));
765
768
  var import_semver2 = __toESM(require("semver"));
766
769
 
770
+ // src/print-commits.ts
771
+ var ezSpawn = __toESM(require("@jsdevtools/ez-spawn"));
772
+ var import_picocolors = __toESM(require_picocolors());
773
+ var messageColorMap = {
774
+ chore: import_picocolors.default.gray,
775
+ fix: import_picocolors.default.yellow,
776
+ feat: import_picocolors.default.green,
777
+ refactor: import_picocolors.default.cyan,
778
+ docs: import_picocolors.default.blue,
779
+ doc: import_picocolors.default.blue,
780
+ ci: import_picocolors.default.gray,
781
+ build: import_picocolors.default.gray
782
+ };
783
+ function parseCommits(raw) {
784
+ const lines = raw.toString().trim().split(/\n/g);
785
+ if (!lines.length) {
786
+ return [];
787
+ }
788
+ return lines.map((line) => {
789
+ const [hash, ...parts] = line.split(" ");
790
+ const message = parts.join(" ");
791
+ const match = message.match(/^(\w+)(!)?(\([^)]+\))?:(.*)$/);
792
+ if (match) {
793
+ let color = messageColorMap[match[1].toLowerCase()] || ((c5) => c5);
794
+ if (match[2] === "!") {
795
+ color = (s) => import_picocolors.default.inverse(import_picocolors.default.red(s));
796
+ }
797
+ const tag = [match[1], match[2]].filter(Boolean).join("");
798
+ const scope = match[3] || "";
799
+ return {
800
+ hash,
801
+ tag,
802
+ message: match[4].trim(),
803
+ scope,
804
+ breaking: match[2] === "!",
805
+ color
806
+ };
807
+ }
808
+ return {
809
+ hash,
810
+ tag: "",
811
+ message,
812
+ scope: "",
813
+ color: (c5) => c5
814
+ };
815
+ }).reverse();
816
+ }
817
+ function formatParsedCommits(commits) {
818
+ const tagLength = commits.map(({ tag }) => tag.length).reduce((a, b) => Math.max(a, b), 0);
819
+ let scopeLength = commits.map(({ scope }) => scope.length).reduce((a, b) => Math.max(a, b), 0);
820
+ if (scopeLength)
821
+ scopeLength += 2;
822
+ return commits.map(({ hash, tag, message, scope, color }) => {
823
+ const paddedTag = tag.padStart(tagLength + 1, " ");
824
+ const paddedScope = !scope ? " ".repeat(scopeLength) : import_picocolors.default.dim("(") + scope.slice(1, -1) + import_picocolors.default.dim(")") + " ".repeat(scopeLength - scope.length);
825
+ return [
826
+ import_picocolors.default.dim(hash),
827
+ " ",
828
+ color === import_picocolors.default.gray ? color(paddedTag) : import_picocolors.default.bold(color(paddedTag)),
829
+ " ",
830
+ paddedScope,
831
+ import_picocolors.default.dim(":"),
832
+ " ",
833
+ color === import_picocolors.default.gray ? color(message) : message
834
+ ].join("");
835
+ });
836
+ }
837
+ async function printRecentCommits(operation) {
838
+ let sha;
839
+ sha || (sha = await ezSpawn.async(
840
+ "git",
841
+ ["rev-list", "-n", "1", `v${operation.state.currentVersion}`],
842
+ { stdio: "pipe" }
843
+ ).then((res) => res.stdout.trim()).catch(() => void 0));
844
+ sha || (sha = await ezSpawn.async(
845
+ "git",
846
+ ["rev-list", "-n", "1", operation.state.currentVersion],
847
+ { stdio: "pipe" }
848
+ ).then((res) => res.stdout.trim()).catch(() => void 0));
849
+ if (!sha) {
850
+ console.log(
851
+ import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` Failed to locate the previous tag ${import_picocolors.default.yellow(`v${operation.state.currentVersion}`)}`)
852
+ );
853
+ return;
854
+ }
855
+ const { stdout } = await ezSpawn.async(
856
+ "git",
857
+ [
858
+ "--no-pager",
859
+ "log",
860
+ `${sha}..HEAD`,
861
+ "--oneline"
862
+ ],
863
+ { stdio: "pipe" }
864
+ );
865
+ const parsed = parseCommits(stdout.toString().trim());
866
+ const prettified = formatParsedCommits(parsed);
867
+ if (!parsed.length) {
868
+ console.log();
869
+ console.log(import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` No commits since ${operation.state.currentVersion}`));
870
+ console.log();
871
+ return;
872
+ }
873
+ console.log();
874
+ console.log(
875
+ import_picocolors.default.bold(
876
+ `${import_picocolors.default.green(parsed.length)} Commits since ${import_picocolors.default.gray(sha.slice(0, 7))}:`
877
+ )
878
+ );
879
+ console.log();
880
+ console.log(prettified.join("\n"));
881
+ console.log();
882
+ }
883
+
767
884
  // src/release-type.ts
768
885
  var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
769
886
  var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]);
@@ -825,20 +942,20 @@ async function promptForNewVersion(operation) {
825
942
  {
826
943
  type: "autocomplete",
827
944
  name: "release",
828
- message: `Current version ${import_picocolors.default.green(currentVersion)}`,
945
+ message: `Current version ${import_picocolors2.default.green(currentVersion)}`,
829
946
  initial: configCustomVersion ? "config" : "next",
830
947
  choices: [
831
- { value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.major)}` },
832
- { value: "minor", title: `${"minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.minor)}` },
833
- { value: "patch", title: `${"patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.patch)}` },
834
- { value: "next", title: `${"next".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.next)}` },
948
+ { value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.major)}` },
949
+ { value: "minor", title: `${"minor".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.minor)}` },
950
+ { value: "patch", title: `${"patch".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.patch)}` },
951
+ { value: "next", title: `${"next".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.next)}` },
835
952
  ...configCustomVersion ? [
836
- { value: "config", title: `${"from config".padStart(PADDING, " ")} ${import_picocolors.default.bold(configCustomVersion)}` }
953
+ { value: "config", title: `${"from config".padStart(PADDING, " ")} ${import_picocolors2.default.bold(configCustomVersion)}` }
837
954
  ] : [],
838
- { value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.prepatch)}` },
839
- { value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.preminor)}` },
840
- { value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` },
841
- { value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(currentVersion)}` },
955
+ { value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.prepatch)}` },
956
+ { value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.preminor)}` },
957
+ { value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.premajor)}` },
958
+ { value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors2.default.bold(currentVersion)}` },
842
959
  { value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
843
960
  ]
844
961
  },
@@ -865,97 +982,6 @@ async function promptForNewVersion(operation) {
865
982
  return operation.update({ release: answers.release, newVersion });
866
983
  }
867
984
  }
868
- var messageColorMap = {
869
- chore: import_picocolors.default.gray,
870
- fix: import_picocolors.default.yellow,
871
- feat: import_picocolors.default.green,
872
- refactor: import_picocolors.default.cyan,
873
- docs: import_picocolors.default.blue,
874
- doc: import_picocolors.default.blue,
875
- ci: import_picocolors.default.gray,
876
- build: import_picocolors.default.gray
877
- };
878
- async function printRecentCommits(operation) {
879
- let sha;
880
- sha || (sha = await ezSpawn.async(
881
- "git",
882
- ["rev-list", "-n", "1", `v${operation.state.currentVersion}`],
883
- { stdio: "pipe" }
884
- ).then((res) => res.stdout.trim()).catch(() => void 0));
885
- sha || (sha = await ezSpawn.async(
886
- "git",
887
- ["rev-list", "-n", "1", operation.state.currentVersion],
888
- { stdio: "pipe" }
889
- ).then((res) => res.stdout.trim()).catch(() => void 0));
890
- if (!sha) {
891
- console.log(
892
- import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` Failed to locate the previous tag ${import_picocolors.default.yellow(`v${operation.state.currentVersion}`)}`)
893
- );
894
- return;
895
- }
896
- const message = await ezSpawn.async(
897
- "git",
898
- [
899
- "--no-pager",
900
- "log",
901
- `${sha}..HEAD`,
902
- "--oneline"
903
- ],
904
- { stdio: "pipe" }
905
- );
906
- const lines = message.stdout.toString().trim().split(/\n/g);
907
- if (!lines.length) {
908
- console.log();
909
- console.log(import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` No commits since ${operation.state.currentVersion}`));
910
- console.log();
911
- return;
912
- }
913
- const parsed = lines.map((line) => {
914
- const [hash, ...parts] = line.split(" ");
915
- const message2 = parts.join(" ");
916
- const match = message2.match(/^(\w+)(\([^)]+\))?(!)?:(.*)$/);
917
- if (match) {
918
- let color = messageColorMap[match[1].toLowerCase()] || ((c4) => c4);
919
- if (match[3] === "!") {
920
- color = import_picocolors.default.red;
921
- }
922
- const tag = [match[1], match[2], match[3]].filter(Boolean).join("");
923
- return {
924
- hash,
925
- tag,
926
- message: match[4].trim(),
927
- color
928
- };
929
- }
930
- return {
931
- hash,
932
- tag: "",
933
- message: message2,
934
- color: (c4) => c4
935
- };
936
- });
937
- const tagLength = parsed.map(({ tag }) => tag.length).reduce((a, b) => Math.max(a, b), 0);
938
- const prettified = parsed.map(({ hash, tag, message: message2, color }) => {
939
- const paddedTag = tag.padStart(tagLength + 2, " ");
940
- return [
941
- import_picocolors.default.dim(hash),
942
- " ",
943
- color === import_picocolors.default.gray ? color(paddedTag) : import_picocolors.default.bold(color(paddedTag)),
944
- import_picocolors.default.dim(":"),
945
- " ",
946
- color === import_picocolors.default.gray ? color(message2) : message2
947
- ].join("");
948
- });
949
- console.log();
950
- console.log(
951
- import_picocolors.default.bold(
952
- `${import_picocolors.default.green(lines.length)} Commits since ${import_picocolors.default.gray(sha.slice(0, 7))}:`
953
- )
954
- );
955
- console.log();
956
- console.log(prettified.reverse().join("\n"));
957
- console.log();
958
- }
959
985
 
960
986
  // src/git.ts
961
987
  var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));
@@ -971,6 +997,9 @@ async function gitCommit(operation) {
971
997
  if (noVerify) {
972
998
  args.push("--no-verify");
973
999
  }
1000
+ if (operation.options.sign) {
1001
+ args.push("--gpg-sign");
1002
+ }
974
1003
  const commitMessage = formatVersionString(message, newVersion);
975
1004
  args.push("--message", commitMessage);
976
1005
  if (!all)
@@ -993,6 +1022,9 @@ async function gitTag(operation) {
993
1022
  ];
994
1023
  const tagName = formatVersionString(tag.name, newVersion);
995
1024
  args.push(tagName);
1025
+ if (operation.options.sign) {
1026
+ args.push("--sign");
1027
+ }
996
1028
  await ezSpawn2.async("git", ["tag", ...args]);
997
1029
  return operation.update({ event: "git tag" /* GitTag */, tagName });
998
1030
  }
@@ -1021,6 +1053,7 @@ var import_js_yaml = __toESM(require("js-yaml"));
1021
1053
  async function normalizeOptions(raw) {
1022
1054
  var _a, _b, _d;
1023
1055
  const preid = typeof raw.preid === "string" ? raw.preid : "beta";
1056
+ const sign = Boolean(raw.sign);
1024
1057
  const push = Boolean(raw.push);
1025
1058
  const all = Boolean(raw.all);
1026
1059
  const noVerify = Boolean(raw.noVerify);
@@ -1097,6 +1130,7 @@ async function normalizeOptions(raw) {
1097
1130
  release,
1098
1131
  commit,
1099
1132
  tag,
1133
+ sign,
1100
1134
  push,
1101
1135
  files,
1102
1136
  cwd,
@@ -1238,7 +1272,13 @@ async function updateManifestFile(relPath, operation) {
1238
1272
  const { newVersion } = operation.state;
1239
1273
  let modified = false;
1240
1274
  const file = await readJsoncFile(relPath, cwd);
1241
- if (isManifest(file.data) && file.data.version !== newVersion) {
1275
+ if (!isManifest(file.data)) {
1276
+ return modified;
1277
+ }
1278
+ if (file.data.version == null) {
1279
+ return modified;
1280
+ }
1281
+ if (file.data.version !== newVersion) {
1242
1282
  file.modified.push([["version"], newVersion]);
1243
1283
  if (isPackageLockManifest(file.data))
1244
1284
  file.modified.push([["packages", "", "version"], newVersion]);
@@ -1296,25 +1336,25 @@ async function versionBump(arg = {}) {
1296
1336
  }
1297
1337
  function printSummary(operation) {
1298
1338
  console.log();
1299
- console.log(` files ${operation.options.files.map((i) => import_picocolors2.default.bold(i)).join("\n ")}`);
1339
+ console.log(` files ${operation.options.files.map((i) => import_picocolors3.default.bold(i)).join("\n ")}`);
1300
1340
  if (operation.options.commit)
1301
- console.log(` commit ${import_picocolors2.default.bold(formatVersionString(operation.options.commit.message, operation.state.newVersion))}`);
1341
+ console.log(` commit ${import_picocolors3.default.bold(formatVersionString(operation.options.commit.message, operation.state.newVersion))}`);
1302
1342
  if (operation.options.tag)
1303
- console.log(` tag ${import_picocolors2.default.bold(formatVersionString(operation.options.tag.name, operation.state.newVersion))}`);
1343
+ console.log(` tag ${import_picocolors3.default.bold(formatVersionString(operation.options.tag.name, operation.state.newVersion))}`);
1304
1344
  if (operation.options.execute)
1305
- console.log(` execute ${import_picocolors2.default.bold(operation.options.execute)}`);
1345
+ console.log(` execute ${import_picocolors3.default.bold(operation.options.execute)}`);
1306
1346
  if (operation.options.push)
1307
- console.log(` push ${import_picocolors2.default.cyan(import_picocolors2.default.bold("yes"))}`);
1347
+ console.log(` push ${import_picocolors3.default.cyan(import_picocolors3.default.bold("yes"))}`);
1308
1348
  console.log();
1309
- console.log(` from ${import_picocolors2.default.bold(operation.state.currentVersion)}`);
1310
- console.log(` to ${import_picocolors2.default.green(import_picocolors2.default.bold(operation.state.newVersion))}`);
1349
+ console.log(` from ${import_picocolors3.default.bold(operation.state.currentVersion)}`);
1350
+ console.log(` to ${import_picocolors3.default.green(import_picocolors3.default.bold(operation.state.newVersion))}`);
1311
1351
  console.log();
1312
1352
  }
1313
1353
 
1314
1354
  // src/cli/parse-args.ts
1315
1355
  var import_node_process7 = __toESM(require("process"));
1316
1356
  var import_cac = __toESM(require("cac"));
1317
- var import_picocolors3 = __toESM(require_picocolors());
1357
+ var import_picocolors4 = __toESM(require_picocolors());
1318
1358
  var import_semver3 = require("semver");
1319
1359
 
1320
1360
  // src/config.ts
@@ -1326,11 +1366,13 @@ var bumpConfigDefaults = {
1326
1366
  commit: true,
1327
1367
  push: true,
1328
1368
  tag: true,
1369
+ sign: false,
1329
1370
  recursive: false,
1330
1371
  noVerify: false,
1331
1372
  confirm: true,
1332
1373
  ignoreScripts: false,
1333
1374
  all: false,
1375
+ noGitCheck: true,
1334
1376
  files: []
1335
1377
  };
1336
1378
  async function loadBumpConfig(overrides, cwd = import_node_process6.default.cwd()) {
@@ -1342,6 +1384,7 @@ async function loadBumpConfig(overrides, cwd = import_node_process6.default.cwd(
1342
1384
  overrides: __spreadValues({}, overrides),
1343
1385
  cwd: configFile ? (0, import_node_path2.dirname)(configFile) : cwd
1344
1386
  });
1387
+ console.log(config);
1345
1388
  return config;
1346
1389
  }
1347
1390
  function findConfigFile(name, cwd) {
@@ -1383,8 +1426,10 @@ async function parseArgs() {
1383
1426
  preid: args.preid,
1384
1427
  commit: args.commit,
1385
1428
  tag: args.tag,
1429
+ sign: args.sign,
1386
1430
  push: args.push,
1387
1431
  all: args.all,
1432
+ noGitCheck: args.noGitCheck,
1388
1433
  confirm: !args.yes,
1389
1434
  noVerify: !args.verify,
1390
1435
  files: [...args["--"] || [], ...resultArgs],
@@ -1402,7 +1447,7 @@ async function parseArgs() {
1402
1447
  }
1403
1448
  }
1404
1449
  if (parsedArgs.options.recursive && ((_a = parsedArgs.options.files) == null ? void 0 : _a.length))
1405
- console.log(import_picocolors3.default.yellow("The --recursive option is ignored when files are specified"));
1450
+ console.log(import_picocolors4.default.yellow("The --recursive option is ignored when files are specified"));
1406
1451
  return parsedArgs;
1407
1452
  } catch (error) {
1408
1453
  return errorHandler(error);
@@ -1410,7 +1455,7 @@ async function parseArgs() {
1410
1455
  }
1411
1456
  function loadCliArgs(argv = import_node_process7.default.argv) {
1412
1457
  const cli = (0, import_cac.default)("bumpp");
1413
- cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", `Include all files (default: ${bumpConfigDefaults.all})`).option("-c, --commit [msg]", "Commit message", { default: true }).option("--no-commit", "Skip commit", { default: false }).option("-t, --tag [tag]", "Tag name", { default: true }).option("--no-tag", "Skip tag", { default: false }).option("-p, --push", `Push to remote (default: ${bumpConfigDefaults.push})`).option("-y, --yes", `Skip confirmation (default: ${!bumpConfigDefaults.confirm})`).option("-r, --recursive", `Bump package.json files recursively (default: ${bumpConfigDefaults.recursive})`).option("--no-verify", "Skip git verification").option("--ignore-scripts", `Ignore scripts (default: ${bumpConfigDefaults.ignoreScripts})`).option("-q, --quiet", "Quiet mode").option("-v, --version <version>", "Target version").option("--current-version <version>", "Current version").option("--print-commits", "Print recent commits", { default: true }).option("-x, --execute <command>", "Commands to execute after version bumps").help();
1458
+ cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", `Include all files (default: ${bumpConfigDefaults.all})`).option("--no-git-check", `Skip git check`, { default: bumpConfigDefaults.noGitCheck }).option("-c, --commit [msg]", "Commit message", { default: true }).option("--no-commit", "Skip commit", { default: false }).option("-t, --tag [tag]", "Tag name", { default: true }).option("--no-tag", "Skip tag", { default: false }).option("--sign", "Sign commit and tag").option("-p, --push", `Push to remote (default: ${bumpConfigDefaults.push})`).option("-y, --yes", `Skip confirmation (default: ${!bumpConfigDefaults.confirm})`).option("-r, --recursive", `Bump package.json files recursively (default: ${bumpConfigDefaults.recursive})`).option("--no-verify", "Skip git verification").option("--ignore-scripts", `Ignore scripts (default: ${bumpConfigDefaults.ignoreScripts})`).option("-q, --quiet", "Quiet mode").option("-v, --version <version>", "Target version").option("--current-version <version>", "Current version").option("--print-commits", "Print recent commits", { default: true }).option("-x, --execute <command>", "Commands to execute after version bumps").help();
1414
1459
  const result = cli.parse(argv);
1415
1460
  const rawArgs = cli.rawArgs;
1416
1461
  const args = result.options;
@@ -1444,6 +1489,9 @@ async function main2() {
1444
1489
  console.log(version);
1445
1490
  import_node_process8.default.exit(0 /* Success */);
1446
1491
  } else {
1492
+ if (!options.all && !options.noGitCheck) {
1493
+ checkGitStatus();
1494
+ }
1447
1495
  if (!quiet)
1448
1496
  options.progress = options.progress ? options.progress : progress;
1449
1497
  await versionBump(options);
@@ -1452,6 +1500,13 @@ async function main2() {
1452
1500
  errorHandler2(error);
1453
1501
  }
1454
1502
  }
1503
+ function checkGitStatus() {
1504
+ const { stdout } = ezSpawn5.sync("git", ["status", "--porcelain"]);
1505
+ if (stdout.trim()) {
1506
+ throw new Error(`Git working tree is not clean:
1507
+ ${stdout}`);
1508
+ }
1509
+ }
1455
1510
  function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
1456
1511
  switch (event) {
1457
1512
  case "file updated" /* FileUpdated */:
@@ -1483,5 +1538,6 @@ function errorHandler2(error) {
1483
1538
  }
1484
1539
  // Annotate the CommonJS export names for ESM import in node:
1485
1540
  0 && (module.exports = {
1541
+ checkGitStatus,
1486
1542
  main
1487
1543
  });
@@ -10,13 +10,14 @@ import {
10
10
  log_symbols_default,
11
11
  require_picocolors,
12
12
  versionBump
13
- } from "../chunk-CNEN62NE.mjs";
13
+ } from "../chunk-EGVMKV3X.mjs";
14
14
 
15
15
  // src/cli/index.ts
16
16
  import process2 from "process";
17
+ import * as ezSpawn from "@jsdevtools/ez-spawn";
17
18
 
18
19
  // package.json
19
- var version = "9.6.0";
20
+ var version = "9.7.0";
20
21
 
21
22
  // src/cli/parse-args.ts
22
23
  var import_picocolors = __toESM(require_picocolors());
@@ -35,8 +36,10 @@ async function parseArgs() {
35
36
  preid: args.preid,
36
37
  commit: args.commit,
37
38
  tag: args.tag,
39
+ sign: args.sign,
38
40
  push: args.push,
39
41
  all: args.all,
42
+ noGitCheck: args.noGitCheck,
40
43
  confirm: !args.yes,
41
44
  noVerify: !args.verify,
42
45
  files: [...args["--"] || [], ...resultArgs],
@@ -62,7 +65,7 @@ async function parseArgs() {
62
65
  }
63
66
  function loadCliArgs(argv = process.argv) {
64
67
  const cli = cac("bumpp");
65
- cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", `Include all files (default: ${bumpConfigDefaults.all})`).option("-c, --commit [msg]", "Commit message", { default: true }).option("--no-commit", "Skip commit", { default: false }).option("-t, --tag [tag]", "Tag name", { default: true }).option("--no-tag", "Skip tag", { default: false }).option("-p, --push", `Push to remote (default: ${bumpConfigDefaults.push})`).option("-y, --yes", `Skip confirmation (default: ${!bumpConfigDefaults.confirm})`).option("-r, --recursive", `Bump package.json files recursively (default: ${bumpConfigDefaults.recursive})`).option("--no-verify", "Skip git verification").option("--ignore-scripts", `Ignore scripts (default: ${bumpConfigDefaults.ignoreScripts})`).option("-q, --quiet", "Quiet mode").option("-v, --version <version>", "Target version").option("--current-version <version>", "Current version").option("--print-commits", "Print recent commits", { default: true }).option("-x, --execute <command>", "Commands to execute after version bumps").help();
68
+ cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", `Include all files (default: ${bumpConfigDefaults.all})`).option("--no-git-check", `Skip git check`, { default: bumpConfigDefaults.noGitCheck }).option("-c, --commit [msg]", "Commit message", { default: true }).option("--no-commit", "Skip commit", { default: false }).option("-t, --tag [tag]", "Tag name", { default: true }).option("--no-tag", "Skip tag", { default: false }).option("--sign", "Sign commit and tag").option("-p, --push", `Push to remote (default: ${bumpConfigDefaults.push})`).option("-y, --yes", `Skip confirmation (default: ${!bumpConfigDefaults.confirm})`).option("-r, --recursive", `Bump package.json files recursively (default: ${bumpConfigDefaults.recursive})`).option("--no-verify", "Skip git verification").option("--ignore-scripts", `Ignore scripts (default: ${bumpConfigDefaults.ignoreScripts})`).option("-q, --quiet", "Quiet mode").option("-v, --version <version>", "Target version").option("--current-version <version>", "Current version").option("--print-commits", "Print recent commits", { default: true }).option("-x, --execute <command>", "Commands to execute after version bumps").help();
66
69
  const result = cli.parse(argv);
67
70
  const rawArgs = cli.rawArgs;
68
71
  const args = result.options;
@@ -96,6 +99,9 @@ async function main() {
96
99
  console.log(version);
97
100
  process2.exit(0 /* Success */);
98
101
  } else {
102
+ if (!options.all && !options.noGitCheck) {
103
+ checkGitStatus();
104
+ }
99
105
  if (!quiet)
100
106
  options.progress = options.progress ? options.progress : progress;
101
107
  await versionBump(options);
@@ -104,6 +110,13 @@ async function main() {
104
110
  errorHandler2(error);
105
111
  }
106
112
  }
113
+ function checkGitStatus() {
114
+ const { stdout } = ezSpawn.sync("git", ["status", "--porcelain"]);
115
+ if (stdout.trim()) {
116
+ throw new Error(`Git working tree is not clean:
117
+ ${stdout}`);
118
+ }
119
+ }
107
120
  function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
108
121
  switch (event) {
109
122
  case "file updated" /* FileUpdated */:
@@ -134,5 +147,6 @@ function errorHandler2(error) {
134
147
  process2.exit(1 /* FatalError */);
135
148
  }
136
149
  export {
150
+ checkGitStatus,
137
151
  main
138
152
  };
package/dist/index.d.mts CHANGED
@@ -112,6 +112,12 @@ interface VersionBumpOptions {
112
112
  * Defaults to `true`.
113
113
  */
114
114
  tag?: boolean | string;
115
+ /**
116
+ * Sign the git commit and tag with a configured key (GPG/SSH).
117
+ *
118
+ * Defaults to `false`.
119
+ */
120
+ sign?: boolean;
115
121
  /**
116
122
  * Indicates whether to push the git commit and tag.
117
123
  *
@@ -125,6 +131,12 @@ interface VersionBumpOptions {
125
131
  * Defaults to `false`.
126
132
  */
127
133
  all?: boolean;
134
+ /**
135
+ * Indicates whether the git working tree needs to be cleared before bumping.
136
+ *
137
+ * Defaults to `true`.
138
+ */
139
+ noGitCheck?: boolean;
128
140
  /**
129
141
  * Prompt for confirmation
130
142
  *
@@ -266,6 +278,7 @@ interface NormalizedOptions {
266
278
  tag?: {
267
279
  name: string;
268
280
  };
281
+ sign?: boolean;
269
282
  push: boolean;
270
283
  files: string[];
271
284
  cwd: string;
package/dist/index.d.ts CHANGED
@@ -112,6 +112,12 @@ interface VersionBumpOptions {
112
112
  * Defaults to `true`.
113
113
  */
114
114
  tag?: boolean | string;
115
+ /**
116
+ * Sign the git commit and tag with a configured key (GPG/SSH).
117
+ *
118
+ * Defaults to `false`.
119
+ */
120
+ sign?: boolean;
115
121
  /**
116
122
  * Indicates whether to push the git commit and tag.
117
123
  *
@@ -125,6 +131,12 @@ interface VersionBumpOptions {
125
131
  * Defaults to `false`.
126
132
  */
127
133
  all?: boolean;
134
+ /**
135
+ * Indicates whether the git working tree needs to be cleared before bumping.
136
+ *
137
+ * Defaults to `true`.
138
+ */
139
+ noGitCheck?: boolean;
128
140
  /**
129
141
  * Prompt for confirmation
130
142
  *
@@ -266,6 +278,7 @@ interface NormalizedOptions {
266
278
  tag?: {
267
279
  name: string;
268
280
  };
281
+ sign?: boolean;
269
282
  push: boolean;
270
283
  files: string[];
271
284
  cwd: string;