bumpp 9.5.2 → 9.6.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/bin/bumpp.js CHANGED
File without changes
@@ -60,9 +60,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
60
60
  mod
61
61
  ));
62
62
 
63
- // node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
63
+ // node_modules/.pnpm/picocolors@1.1.0/node_modules/picocolors/picocolors.js
64
64
  var require_picocolors = __commonJS({
65
- "node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports, module) {
65
+ "node_modules/.pnpm/picocolors@1.1.0/node_modules/picocolors/picocolors.js"(exports, module) {
66
66
  var argv = process.argv || [];
67
67
  var env2 = process.env;
68
68
  var isColorSupported = !("NO_COLOR" in env2 || argv.includes("--no-color")) && ("FORCE_COLOR" in env2 || argv.includes("--color") || process.platform === "win32" || __require != null && __require("tty").isatty(1) && env2.TERM !== "dumb" || "CI" in env2);
@@ -109,7 +109,23 @@ var require_picocolors = __commonJS({
109
109
  bgBlue: init("\x1B[44m", "\x1B[49m"),
110
110
  bgMagenta: init("\x1B[45m", "\x1B[49m"),
111
111
  bgCyan: init("\x1B[46m", "\x1B[49m"),
112
- bgWhite: init("\x1B[47m", "\x1B[49m")
112
+ bgWhite: init("\x1B[47m", "\x1B[49m"),
113
+ blackBright: init("\x1B[90m", "\x1B[39m"),
114
+ redBright: init("\x1B[91m", "\x1B[39m"),
115
+ greenBright: init("\x1B[92m", "\x1B[39m"),
116
+ yellowBright: init("\x1B[93m", "\x1B[39m"),
117
+ blueBright: init("\x1B[94m", "\x1B[39m"),
118
+ magentaBright: init("\x1B[95m", "\x1B[39m"),
119
+ cyanBright: init("\x1B[96m", "\x1B[39m"),
120
+ whiteBright: init("\x1B[97m", "\x1B[39m"),
121
+ bgBlackBright: init("\x1B[100m", "\x1B[49m"),
122
+ bgRedBright: init("\x1B[101m", "\x1B[49m"),
123
+ bgGreenBright: init("\x1B[102m", "\x1B[49m"),
124
+ bgYellowBright: init("\x1B[103m", "\x1B[49m"),
125
+ bgBlueBright: init("\x1B[104m", "\x1B[49m"),
126
+ bgMagentaBright: init("\x1B[105m", "\x1B[49m"),
127
+ bgCyanBright: init("\x1B[106m", "\x1B[49m"),
128
+ bgWhiteBright: init("\x1B[107m", "\x1B[49m")
113
129
  };
114
130
  };
115
131
  module.exports = createColors();
@@ -657,16 +673,114 @@ var NpmScript = /* @__PURE__ */ ((NpmScript2) => {
657
673
  })(NpmScript || {});
658
674
 
659
675
  // src/version-bump.ts
660
- var import_picocolors2 = __toESM(require_picocolors());
661
676
  import process6 from "process";
662
- import * as ezSpawn3 from "@jsdevtools/ez-spawn";
677
+ import * as ezSpawn4 from "@jsdevtools/ez-spawn";
678
+ var import_picocolors2 = __toESM(require_picocolors());
663
679
  import prompts2 from "prompts";
664
680
 
681
+ // src/get-current-version.ts
682
+ import { valid as isValidVersion } from "semver";
683
+
684
+ // src/fs.ts
685
+ import fs from "fs";
686
+ import path from "path";
687
+ import * as jsonc from "jsonc-parser";
688
+ async function readJsoncFile(name, cwd) {
689
+ const file = await readTextFile(name, cwd);
690
+ const data = jsonc.parse(file.data);
691
+ const modified = [];
692
+ return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
693
+ }
694
+ async function writeJsoncFile(file) {
695
+ let newJSON = file.text;
696
+ for (const [key, value] of file.modified) {
697
+ const edit = jsonc.modify(file.text, key, value, {});
698
+ newJSON = jsonc.applyEdits(newJSON, edit);
699
+ }
700
+ return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
701
+ }
702
+ function readTextFile(name, cwd) {
703
+ return new Promise((resolve, reject) => {
704
+ const filePath = path.join(cwd, name);
705
+ fs.readFile(filePath, "utf8", (err, text) => {
706
+ if (err) {
707
+ reject(err);
708
+ } else {
709
+ resolve({
710
+ path: filePath,
711
+ data: text
712
+ });
713
+ }
714
+ });
715
+ });
716
+ }
717
+ function writeTextFile(file) {
718
+ return new Promise((resolve, reject) => {
719
+ fs.writeFile(file.path, file.data, (err) => {
720
+ if (err)
721
+ reject(err);
722
+ else
723
+ resolve();
724
+ });
725
+ });
726
+ }
727
+
728
+ // src/manifest.ts
729
+ function isManifest(obj) {
730
+ return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
731
+ }
732
+ function isPackageLockManifest(manifest) {
733
+ var _a, _b;
734
+ return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
735
+ }
736
+ function isOptionalString(value) {
737
+ const type = typeof value;
738
+ return value === null || type === "undefined" || type === "string";
739
+ }
740
+
741
+ // src/get-current-version.ts
742
+ async function getCurrentVersion(operation) {
743
+ if (operation.state.currentVersion)
744
+ return operation;
745
+ const { cwd, files } = operation.options;
746
+ const filesToCheck = files.filter((file) => file.endsWith(".json"));
747
+ if (!filesToCheck.includes("package.json"))
748
+ filesToCheck.push("package.json");
749
+ if (!filesToCheck.includes("deno.json"))
750
+ filesToCheck.push("deno.json");
751
+ if (!filesToCheck.includes("deno.jsonc"))
752
+ filesToCheck.push("deno.jsonc");
753
+ for (const file of filesToCheck) {
754
+ const version = await readVersion(file, cwd);
755
+ if (version) {
756
+ return operation.update({
757
+ currentVersionSource: file,
758
+ currentVersion: version
759
+ });
760
+ }
761
+ }
762
+ throw new Error(
763
+ `Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
764
+ );
765
+ }
766
+ async function readVersion(file, cwd) {
767
+ try {
768
+ const { data: manifest } = await readJsoncFile(file, cwd);
769
+ if (isManifest(manifest)) {
770
+ if (isValidVersion(manifest.version))
771
+ return manifest.version;
772
+ }
773
+ } catch (e) {
774
+ return void 0;
775
+ }
776
+ }
777
+
665
778
  // src/get-new-version.ts
666
779
  var import_picocolors = __toESM(require_picocolors());
667
780
  import process4 from "process";
781
+ import * as ezSpawn from "@jsdevtools/ez-spawn";
668
782
  import prompts from "prompts";
669
- import semver, { SemVer, clean as cleanVersion, valid as isValidVersion } from "semver";
783
+ import semver, { clean as cleanVersion, valid as isValidVersion2, SemVer } from "semver";
670
784
  async function getNewVersion(operation) {
671
785
  const { release } = operation.options;
672
786
  const { currentVersion } = operation.state;
@@ -709,6 +823,9 @@ async function promptForNewVersion(operation) {
709
823
  const release = operation.options.release;
710
824
  const next = getNextVersions(currentVersion, release.preid);
711
825
  const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, currentVersion, semver));
826
+ if (operation.options.printCommits) {
827
+ await printRecentCommits(operation);
828
+ }
712
829
  const PADDING = 13;
713
830
  const answers = await prompts([
714
831
  {
@@ -737,7 +854,7 @@ async function promptForNewVersion(operation) {
737
854
  message: "Enter the new version number:",
738
855
  initial: currentVersion,
739
856
  validate: (custom) => {
740
- return isValidVersion(custom) ? true : "That's not a valid version number";
857
+ return isValidVersion2(custom) ? true : "That's not a valid version number";
741
858
  }
742
859
  }
743
860
  ]);
@@ -754,106 +871,100 @@ async function promptForNewVersion(operation) {
754
871
  return operation.update({ release: answers.release, newVersion });
755
872
  }
756
873
  }
757
-
758
- // src/get-current-version.ts
759
- import { valid as isValidVersion2 } from "semver";
760
-
761
- // src/fs.ts
762
- import fs from "fs";
763
- import path from "path";
764
- import * as jsonc from "jsonc-parser";
765
- async function readJsoncFile(name, cwd) {
766
- const file = await readTextFile(name, cwd);
767
- const data = jsonc.parse(file.data);
768
- const modified = [];
769
- return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
770
- }
771
- async function writeJsoncFile(file) {
772
- let newJSON = file.text;
773
- for (const [key, value] of file.modified) {
774
- const edit = jsonc.modify(file.text, key, value, {});
775
- newJSON = jsonc.applyEdits(newJSON, edit);
874
+ var messageColorMap = {
875
+ chore: import_picocolors.default.gray,
876
+ fix: import_picocolors.default.yellow,
877
+ feat: import_picocolors.default.green,
878
+ refactor: import_picocolors.default.cyan,
879
+ docs: import_picocolors.default.blue,
880
+ doc: import_picocolors.default.blue,
881
+ ci: import_picocolors.default.gray,
882
+ build: import_picocolors.default.gray
883
+ };
884
+ async function printRecentCommits(operation) {
885
+ let sha;
886
+ sha || (sha = await ezSpawn.async(
887
+ "git",
888
+ ["rev-list", "-n", "1", `v${operation.state.currentVersion}`],
889
+ { stdio: "pipe" }
890
+ ).then((res) => res.stdout.trim()).catch(() => void 0));
891
+ sha || (sha = await ezSpawn.async(
892
+ "git",
893
+ ["rev-list", "-n", "1", operation.state.currentVersion],
894
+ { stdio: "pipe" }
895
+ ).then((res) => res.stdout.trim()).catch(() => void 0));
896
+ if (!sha) {
897
+ console.log(
898
+ import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` Failed to locate the previous tag ${import_picocolors.default.yellow(`v${operation.state.currentVersion}`)}`)
899
+ );
900
+ return;
776
901
  }
777
- return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
778
- }
779
- function readTextFile(name, cwd) {
780
- return new Promise((resolve, reject) => {
781
- const filePath = path.join(cwd, name);
782
- fs.readFile(filePath, "utf8", (err, text) => {
783
- if (err) {
784
- reject(err);
785
- } else {
786
- resolve({
787
- path: filePath,
788
- data: text
789
- });
902
+ const message = await ezSpawn.async(
903
+ "git",
904
+ [
905
+ "--no-pager",
906
+ "log",
907
+ `${sha}..HEAD`,
908
+ "--oneline"
909
+ ],
910
+ { stdio: "pipe" }
911
+ );
912
+ const lines = message.stdout.toString().trim().split(/\n/g);
913
+ if (!lines.length) {
914
+ console.log();
915
+ console.log(import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` No commits since ${operation.state.currentVersion}`));
916
+ console.log();
917
+ return;
918
+ }
919
+ const parsed = lines.map((line) => {
920
+ const [hash, ...parts] = line.split(" ");
921
+ const message2 = parts.join(" ");
922
+ const match = message2.match(/^(\w+)(\([^)]+\))?(!)?:(.*)$/);
923
+ if (match) {
924
+ let color = messageColorMap[match[1].toLowerCase()] || ((c3) => c3);
925
+ if (match[3] === "!") {
926
+ color = import_picocolors.default.red;
790
927
  }
791
- });
928
+ const tag = [match[1], match[2], match[3]].filter(Boolean).join("");
929
+ return {
930
+ hash,
931
+ tag,
932
+ message: match[4].trim(),
933
+ color
934
+ };
935
+ }
936
+ return {
937
+ hash,
938
+ tag: "",
939
+ message: message2,
940
+ color: (c3) => c3
941
+ };
792
942
  });
793
- }
794
- function writeTextFile(file) {
795
- return new Promise((resolve, reject) => {
796
- fs.writeFile(file.path, file.data, (err) => {
797
- if (err)
798
- reject(err);
799
- else
800
- resolve();
801
- });
943
+ const tagLength = parsed.map(({ tag }) => tag.length).reduce((a, b) => Math.max(a, b), 0);
944
+ const prettified = parsed.map(({ hash, tag, message: message2, color }) => {
945
+ const paddedTag = tag.padStart(tagLength + 2, " ");
946
+ return [
947
+ import_picocolors.default.dim(hash),
948
+ " ",
949
+ color === import_picocolors.default.gray ? color(paddedTag) : import_picocolors.default.bold(color(paddedTag)),
950
+ import_picocolors.default.dim(":"),
951
+ " ",
952
+ color === import_picocolors.default.gray ? color(message2) : message2
953
+ ].join("");
802
954
  });
803
- }
804
-
805
- // src/manifest.ts
806
- function isManifest(obj) {
807
- return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
808
- }
809
- function isPackageLockManifest(manifest) {
810
- var _a, _b;
811
- return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
812
- }
813
- function isOptionalString(value) {
814
- const type = typeof value;
815
- return value === null || type === "undefined" || type === "string";
816
- }
817
-
818
- // src/get-current-version.ts
819
- async function getCurrentVersion(operation) {
820
- if (operation.state.currentVersion)
821
- return operation;
822
- const { cwd, files } = operation.options;
823
- const filesToCheck = files.filter((file) => file.endsWith(".json"));
824
- if (!filesToCheck.includes("package.json"))
825
- filesToCheck.push("package.json");
826
- if (!filesToCheck.includes("deno.json"))
827
- filesToCheck.push("deno.json");
828
- if (!filesToCheck.includes("deno.jsonc"))
829
- filesToCheck.push("deno.jsonc");
830
- for (const file of filesToCheck) {
831
- const version = await readVersion(file, cwd);
832
- if (version) {
833
- return operation.update({
834
- currentVersionSource: file,
835
- currentVersion: version
836
- });
837
- }
838
- }
839
- throw new Error(
840
- `Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
955
+ console.log();
956
+ console.log(
957
+ import_picocolors.default.bold(
958
+ `${import_picocolors.default.green(lines.length)} Commits since ${import_picocolors.default.gray(sha.slice(0, 7))}:`
959
+ )
841
960
  );
842
- }
843
- async function readVersion(file, cwd) {
844
- try {
845
- const { data: manifest } = await readJsoncFile(file, cwd);
846
- if (isManifest(manifest)) {
847
- if (isValidVersion2(manifest.version))
848
- return manifest.version;
849
- }
850
- } catch (e) {
851
- return void 0;
852
- }
961
+ console.log();
962
+ console.log(prettified.reverse().join("\n"));
963
+ console.log();
853
964
  }
854
965
 
855
966
  // src/git.ts
856
- import * as ezSpawn from "@jsdevtools/ez-spawn";
967
+ import * as ezSpawn2 from "@jsdevtools/ez-spawn";
857
968
  async function gitCommit(operation) {
858
969
  if (!operation.options.commit)
859
970
  return operation;
@@ -870,7 +981,7 @@ async function gitCommit(operation) {
870
981
  args.push("--message", commitMessage);
871
982
  if (!all)
872
983
  args = args.concat(updatedFiles);
873
- await ezSpawn.async("git", ["commit", ...args]);
984
+ await ezSpawn2.async("git", ["commit", ...args]);
874
985
  return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
875
986
  }
876
987
  async function gitTag(operation) {
@@ -888,15 +999,15 @@ async function gitTag(operation) {
888
999
  ];
889
1000
  const tagName = formatVersionString(tag.name, newVersion);
890
1001
  args.push(tagName);
891
- await ezSpawn.async("git", ["tag", ...args]);
1002
+ await ezSpawn2.async("git", ["tag", ...args]);
892
1003
  return operation.update({ event: "git tag" /* GitTag */, tagName });
893
1004
  }
894
1005
  async function gitPush(operation) {
895
1006
  if (!operation.options.push)
896
1007
  return operation;
897
- await ezSpawn.async("git", "push");
1008
+ await ezSpawn2.async("git", "push");
898
1009
  if (operation.options.tag) {
899
- await ezSpawn.async("git", ["push", "--tags"]);
1010
+ await ezSpawn2.async("git", ["push", "--tags"]);
900
1011
  }
901
1012
  return operation.update({ event: "git push" /* GitPush */ });
902
1013
  }
@@ -908,13 +1019,13 @@ function formatVersionString(template, newVersion) {
908
1019
  }
909
1020
 
910
1021
  // src/normalize-options.ts
911
- import process5 from "process";
912
- import fs2 from "fs/promises";
913
1022
  import fsSync from "fs";
1023
+ import fs2 from "fs/promises";
1024
+ import process5 from "process";
914
1025
  import fg from "fast-glob";
915
1026
  import yaml from "js-yaml";
916
1027
  async function normalizeOptions(raw) {
917
- var _a, _b;
1028
+ var _a, _b, _d;
918
1029
  const preid = typeof raw.preid === "string" ? raw.preid : "beta";
919
1030
  const push = Boolean(raw.push);
920
1031
  const all = Boolean(raw.all);
@@ -998,6 +1109,7 @@ async function normalizeOptions(raw) {
998
1109
  interface: ui,
999
1110
  ignoreScripts,
1000
1111
  execute,
1112
+ printCommits: (_d = raw.printCommits) != null ? _d : true,
1001
1113
  customVersion: raw.customVersion,
1002
1114
  currentVersion: raw.currentVersion
1003
1115
  };
@@ -1068,13 +1180,13 @@ var Operation = class _Operation {
1068
1180
  };
1069
1181
 
1070
1182
  // src/run-npm-script.ts
1071
- import * as ezSpawn2 from "@jsdevtools/ez-spawn";
1183
+ import * as ezSpawn3 from "@jsdevtools/ez-spawn";
1072
1184
  async function runNpmScript(script, operation) {
1073
1185
  const { cwd, ignoreScripts } = operation.options;
1074
1186
  if (!ignoreScripts) {
1075
1187
  const { data: manifest } = await readJsoncFile("package.json", cwd);
1076
1188
  if (isManifest(manifest) && hasScript(manifest, script)) {
1077
- await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
1189
+ await ezSpawn3.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
1078
1190
  operation.update({ event: "npm script" /* NpmScript */, script });
1079
1191
  }
1080
1192
  }
@@ -1088,8 +1200,8 @@ function hasScript(manifest, script) {
1088
1200
  }
1089
1201
 
1090
1202
  // src/update-files.ts
1091
- import * as path2 from "path";
1092
1203
  import { existsSync } from "fs";
1204
+ import * as path2 from "path";
1093
1205
  async function updateFiles(operation) {
1094
1206
  const { files } = operation.options;
1095
1207
  for (const relPath of files) {
@@ -1178,7 +1290,7 @@ async function versionBump(arg = {}) {
1178
1290
  await updateFiles(operation);
1179
1291
  if (operation.options.execute) {
1180
1292
  console.log(log_symbols_default.info, "Executing script", operation.options.execute);
1181
- await ezSpawn3.async(operation.options.execute, { stdio: "inherit" });
1293
+ await ezSpawn4.async(operation.options.execute, { stdio: "inherit" });
1182
1294
  console.log(log_symbols_default.success, "Script finished");
1183
1295
  }
1184
1296
  await runNpmScript("version" /* Version */, operation);
@@ -1214,8 +1326,8 @@ async function versionBumpInfo(arg = {}) {
1214
1326
  }
1215
1327
 
1216
1328
  // src/config.ts
1217
- import process7 from "process";
1218
1329
  import { dirname } from "path";
1330
+ import process7 from "process";
1219
1331
  import { loadConfig } from "c12";
1220
1332
  import escalade from "escalade/sync";
1221
1333
  var bumpConfigDefaults = {
@@ -1274,8 +1386,8 @@ export {
1274
1386
  __spreadProps,
1275
1387
  __objRest,
1276
1388
  __toESM,
1277
- require_picocolors,
1278
1389
  log_symbols_default,
1390
+ require_picocolors,
1279
1391
  isReleaseType,
1280
1392
  ProgressEvent,
1281
1393
  NpmScript,