bumpp 9.4.2 → 9.5.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.
@@ -696,9 +696,9 @@ function getNextVersion(currentVersion, bump) {
696
696
  }
697
697
  function getNextVersions(currentVersion, preid) {
698
698
  const next = {};
699
- const parse = semver.parse(currentVersion);
700
- if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
701
- preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
699
+ const parse2 = semver.parse(currentVersion);
700
+ if (typeof (parse2 == null ? void 0 : parse2.prerelease[0]) === "string")
701
+ preid = (parse2 == null ? void 0 : parse2.prerelease[0]) || "preid";
702
702
  for (const type of releaseTypes)
703
703
  next[type] = getNextVersion(currentVersion, { type, preid });
704
704
  return next;
@@ -761,134 +761,20 @@ import { valid as isValidVersion2 } from "semver";
761
761
  // src/fs.ts
762
762
  import fs from "fs";
763
763
  import path from "path";
764
-
765
- // node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js
766
- var INDENT_REGEX = /^(?:( )+|\t+)/;
767
- var INDENT_TYPE_SPACE = "space";
768
- var INDENT_TYPE_TAB = "tab";
769
- function makeIndentsMap(string, ignoreSingleSpaces) {
770
- const indents = /* @__PURE__ */ new Map();
771
- let previousSize = 0;
772
- let previousIndentType;
773
- let key;
774
- for (const line of string.split(/\n/g)) {
775
- if (!line) {
776
- continue;
777
- }
778
- let indent;
779
- let indentType;
780
- let use;
781
- let weight;
782
- let entry;
783
- const matches = line.match(INDENT_REGEX);
784
- if (matches === null) {
785
- previousSize = 0;
786
- previousIndentType = "";
787
- } else {
788
- indent = matches[0].length;
789
- indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
790
- if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
791
- continue;
792
- }
793
- if (indentType !== previousIndentType) {
794
- previousSize = 0;
795
- }
796
- previousIndentType = indentType;
797
- use = 1;
798
- weight = 0;
799
- const indentDifference = indent - previousSize;
800
- previousSize = indent;
801
- if (indentDifference === 0) {
802
- use = 0;
803
- weight = 1;
804
- } else {
805
- const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
806
- key = encodeIndentsKey(indentType, absoluteIndentDifference);
807
- }
808
- entry = indents.get(key);
809
- entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight];
810
- indents.set(key, entry);
811
- }
812
- }
813
- return indents;
814
- }
815
- function encodeIndentsKey(indentType, indentAmount) {
816
- const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
817
- return typeCharacter + String(indentAmount);
818
- }
819
- function decodeIndentsKey(indentsKey) {
820
- const keyHasTypeSpace = indentsKey[0] === "s";
821
- const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
822
- const amount = Number(indentsKey.slice(1));
823
- return { type, amount };
824
- }
825
- function getMostUsedKey(indents) {
826
- let result;
827
- let maxUsed = 0;
828
- let maxWeight = 0;
829
- for (const [key, [usedCount, weight]] of indents) {
830
- if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
831
- maxUsed = usedCount;
832
- maxWeight = weight;
833
- result = key;
834
- }
835
- }
836
- return result;
837
- }
838
- function makeIndentString(type, amount) {
839
- const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
840
- return indentCharacter.repeat(amount);
841
- }
842
- function detectIndent(string) {
843
- if (typeof string !== "string") {
844
- throw new TypeError("Expected a string");
845
- }
846
- let indents = makeIndentsMap(string, true);
847
- if (indents.size === 0) {
848
- indents = makeIndentsMap(string, false);
849
- }
850
- const keyOfMostUsedIndent = getMostUsedKey(indents);
851
- let type;
852
- let amount = 0;
853
- let indent = "";
854
- if (keyOfMostUsedIndent !== void 0) {
855
- ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
856
- indent = makeIndentString(type, amount);
857
- }
858
- return {
859
- amount,
860
- type,
861
- indent
862
- };
863
- }
864
-
865
- // node_modules/.pnpm/detect-newline@4.0.1/node_modules/detect-newline/index.js
866
- function detectNewline(string) {
867
- if (typeof string !== "string") {
868
- throw new TypeError("Expected a string");
869
- }
870
- const newlines = string.match(/(?:\r?\n)/g) || [];
871
- if (newlines.length === 0) {
872
- return;
873
- }
874
- const crlf = newlines.filter((newline) => newline === "\r\n").length;
875
- const lf = newlines.length - crlf;
876
- return crlf > lf ? "\r\n" : "\n";
877
- }
878
-
879
- // src/fs.ts
880
- async function readJsonFile(name, cwd) {
764
+ import * as jsonc from "jsonc-parser";
765
+ async function readJsoncFile(name, cwd) {
881
766
  const file = await readTextFile(name, cwd);
882
- const data = JSON.parse(file.data);
883
- const indent = detectIndent(file.data).indent;
884
- const newline = detectNewline(file.data);
885
- return __spreadProps(__spreadValues({}, file), { data, indent, newline });
767
+ const data = jsonc.parse(file.data);
768
+ const modified = [];
769
+ return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
886
770
  }
887
- async function writeJsonFile(file) {
888
- let json = JSON.stringify(file.data, void 0, file.indent);
889
- if (file.newline)
890
- json += file.newline;
891
- return writeTextFile(__spreadProps(__spreadValues({}, file), { data: json }));
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);
776
+ }
777
+ return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
892
778
  }
893
779
  function readTextFile(name, cwd) {
894
780
  return new Promise((resolve, reject) => {
@@ -937,6 +823,8 @@ async function getCurrentVersion(operation) {
937
823
  const filesToCheck = files.filter((file) => file.endsWith(".json"));
938
824
  if (!filesToCheck.includes("package.json"))
939
825
  filesToCheck.push("package.json");
826
+ if (!filesToCheck.includes("deno.json"))
827
+ filesToCheck.push("deno.json");
940
828
  for (const file of filesToCheck) {
941
829
  const version = await readVersion(file, cwd);
942
830
  if (version) {
@@ -952,7 +840,7 @@ async function getCurrentVersion(operation) {
952
840
  }
953
841
  async function readVersion(file, cwd) {
954
842
  try {
955
- const { data: manifest } = await readJsonFile(file, cwd);
843
+ const { data: manifest } = await readJsoncFile(file, cwd);
956
844
  if (isManifest(manifest)) {
957
845
  if (isValidVersion2(manifest.version))
958
846
  return manifest.version;
@@ -1182,7 +1070,7 @@ import * as ezSpawn2 from "@jsdevtools/ez-spawn";
1182
1070
  async function runNpmScript(script, operation) {
1183
1071
  const { cwd, ignoreScripts } = operation.options;
1184
1072
  if (!ignoreScripts) {
1185
- const { data: manifest } = await readJsonFile("package.json", cwd);
1073
+ const { data: manifest } = await readJsoncFile("package.json", cwd);
1186
1074
  if (isManifest(manifest) && hasScript(manifest, script)) {
1187
1075
  await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
1188
1076
  operation.update({ event: "npm script" /* NpmScript */, script });
@@ -1225,7 +1113,9 @@ async function updateFile(relPath, operation) {
1225
1113
  case "bower.json":
1226
1114
  case "component.json":
1227
1115
  case "jsr.json":
1116
+ case "jsr.jsonc":
1228
1117
  case "deno.json":
1118
+ case "deno.jsonc":
1229
1119
  return updateManifestFile(relPath, operation);
1230
1120
  default:
1231
1121
  return updateTextFile(relPath, operation);
@@ -1235,12 +1125,12 @@ async function updateManifestFile(relPath, operation) {
1235
1125
  const { cwd } = operation.options;
1236
1126
  const { newVersion } = operation.state;
1237
1127
  let modified = false;
1238
- const file = await readJsonFile(relPath, cwd);
1128
+ const file = await readJsoncFile(relPath, cwd);
1239
1129
  if (isManifest(file.data) && file.data.version !== newVersion) {
1240
- file.data.version = newVersion;
1130
+ file.modified.push([["version"], newVersion]);
1241
1131
  if (isPackageLockManifest(file.data))
1242
- file.data.packages[""].version = newVersion;
1243
- await writeJsonFile(file);
1132
+ file.modified.push([["packages", "", "version"], newVersion]);
1133
+ await writeJsoncFile(file);
1244
1134
  modified = true;
1245
1135
  }
1246
1136
  return modified;
package/dist/cli/index.js CHANGED
@@ -636,7 +636,7 @@ var logSymbols = isUnicodeSupported() ? main : fallback;
636
636
  var log_symbols_default = logSymbols;
637
637
 
638
638
  // package.json
639
- var version = "9.4.2";
639
+ var version = "9.5.0";
640
640
 
641
641
  // src/version-bump.ts
642
642
  var import_node_process5 = __toESM(require("process"));
@@ -690,9 +690,9 @@ function getNextVersion(currentVersion, bump) {
690
690
  }
691
691
  function getNextVersions(currentVersion, preid) {
692
692
  const next = {};
693
- const parse = import_semver.default.parse(currentVersion);
694
- if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
695
- preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
693
+ const parse2 = import_semver.default.parse(currentVersion);
694
+ if (typeof (parse2 == null ? void 0 : parse2.prerelease[0]) === "string")
695
+ preid = (parse2 == null ? void 0 : parse2.prerelease[0]) || "preid";
696
696
  for (const type of releaseTypes)
697
697
  next[type] = getNextVersion(currentVersion, { type, preid });
698
698
  return next;
@@ -755,134 +755,20 @@ var import_semver2 = require("semver");
755
755
  // src/fs.ts
756
756
  var import_node_fs = __toESM(require("fs"));
757
757
  var import_node_path = __toESM(require("path"));
758
-
759
- // node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js
760
- var INDENT_REGEX = /^(?:( )+|\t+)/;
761
- var INDENT_TYPE_SPACE = "space";
762
- var INDENT_TYPE_TAB = "tab";
763
- function makeIndentsMap(string, ignoreSingleSpaces) {
764
- const indents = /* @__PURE__ */ new Map();
765
- let previousSize = 0;
766
- let previousIndentType;
767
- let key;
768
- for (const line of string.split(/\n/g)) {
769
- if (!line) {
770
- continue;
771
- }
772
- let indent;
773
- let indentType;
774
- let use;
775
- let weight;
776
- let entry;
777
- const matches = line.match(INDENT_REGEX);
778
- if (matches === null) {
779
- previousSize = 0;
780
- previousIndentType = "";
781
- } else {
782
- indent = matches[0].length;
783
- indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
784
- if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
785
- continue;
786
- }
787
- if (indentType !== previousIndentType) {
788
- previousSize = 0;
789
- }
790
- previousIndentType = indentType;
791
- use = 1;
792
- weight = 0;
793
- const indentDifference = indent - previousSize;
794
- previousSize = indent;
795
- if (indentDifference === 0) {
796
- use = 0;
797
- weight = 1;
798
- } else {
799
- const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
800
- key = encodeIndentsKey(indentType, absoluteIndentDifference);
801
- }
802
- entry = indents.get(key);
803
- entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight];
804
- indents.set(key, entry);
805
- }
806
- }
807
- return indents;
808
- }
809
- function encodeIndentsKey(indentType, indentAmount) {
810
- const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
811
- return typeCharacter + String(indentAmount);
812
- }
813
- function decodeIndentsKey(indentsKey) {
814
- const keyHasTypeSpace = indentsKey[0] === "s";
815
- const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
816
- const amount = Number(indentsKey.slice(1));
817
- return { type, amount };
818
- }
819
- function getMostUsedKey(indents) {
820
- let result;
821
- let maxUsed = 0;
822
- let maxWeight = 0;
823
- for (const [key, [usedCount, weight]] of indents) {
824
- if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
825
- maxUsed = usedCount;
826
- maxWeight = weight;
827
- result = key;
828
- }
829
- }
830
- return result;
831
- }
832
- function makeIndentString(type, amount) {
833
- const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
834
- return indentCharacter.repeat(amount);
835
- }
836
- function detectIndent(string) {
837
- if (typeof string !== "string") {
838
- throw new TypeError("Expected a string");
839
- }
840
- let indents = makeIndentsMap(string, true);
841
- if (indents.size === 0) {
842
- indents = makeIndentsMap(string, false);
843
- }
844
- const keyOfMostUsedIndent = getMostUsedKey(indents);
845
- let type;
846
- let amount = 0;
847
- let indent = "";
848
- if (keyOfMostUsedIndent !== void 0) {
849
- ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
850
- indent = makeIndentString(type, amount);
851
- }
852
- return {
853
- amount,
854
- type,
855
- indent
856
- };
857
- }
858
-
859
- // node_modules/.pnpm/detect-newline@4.0.1/node_modules/detect-newline/index.js
860
- function detectNewline(string) {
861
- if (typeof string !== "string") {
862
- throw new TypeError("Expected a string");
863
- }
864
- const newlines = string.match(/(?:\r?\n)/g) || [];
865
- if (newlines.length === 0) {
866
- return;
867
- }
868
- const crlf = newlines.filter((newline) => newline === "\r\n").length;
869
- const lf = newlines.length - crlf;
870
- return crlf > lf ? "\r\n" : "\n";
871
- }
872
-
873
- // src/fs.ts
874
- async function readJsonFile(name, cwd) {
758
+ var jsonc = __toESM(require("jsonc-parser"));
759
+ async function readJsoncFile(name, cwd) {
875
760
  const file = await readTextFile(name, cwd);
876
- const data = JSON.parse(file.data);
877
- const indent = detectIndent(file.data).indent;
878
- const newline = detectNewline(file.data);
879
- return __spreadProps(__spreadValues({}, file), { data, indent, newline });
761
+ const data = jsonc.parse(file.data);
762
+ const modified = [];
763
+ return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
880
764
  }
881
- async function writeJsonFile(file) {
882
- let json = JSON.stringify(file.data, void 0, file.indent);
883
- if (file.newline)
884
- json += file.newline;
885
- return writeTextFile(__spreadProps(__spreadValues({}, file), { data: json }));
765
+ async function writeJsoncFile(file) {
766
+ let newJSON = file.text;
767
+ for (const [key, value] of file.modified) {
768
+ const edit = jsonc.modify(file.text, key, value, {});
769
+ newJSON = jsonc.applyEdits(newJSON, edit);
770
+ }
771
+ return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
886
772
  }
887
773
  function readTextFile(name, cwd) {
888
774
  return new Promise((resolve, reject) => {
@@ -931,6 +817,8 @@ async function getCurrentVersion(operation) {
931
817
  const filesToCheck = files.filter((file) => file.endsWith(".json"));
932
818
  if (!filesToCheck.includes("package.json"))
933
819
  filesToCheck.push("package.json");
820
+ if (!filesToCheck.includes("deno.json"))
821
+ filesToCheck.push("deno.json");
934
822
  for (const file of filesToCheck) {
935
823
  const version2 = await readVersion(file, cwd);
936
824
  if (version2) {
@@ -946,7 +834,7 @@ async function getCurrentVersion(operation) {
946
834
  }
947
835
  async function readVersion(file, cwd) {
948
836
  try {
949
- const { data: manifest } = await readJsonFile(file, cwd);
837
+ const { data: manifest } = await readJsoncFile(file, cwd);
950
838
  if (isManifest(manifest)) {
951
839
  if ((0, import_semver2.valid)(manifest.version))
952
840
  return manifest.version;
@@ -1176,7 +1064,7 @@ var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));
1176
1064
  async function runNpmScript(script, operation) {
1177
1065
  const { cwd, ignoreScripts } = operation.options;
1178
1066
  if (!ignoreScripts) {
1179
- const { data: manifest } = await readJsonFile("package.json", cwd);
1067
+ const { data: manifest } = await readJsoncFile("package.json", cwd);
1180
1068
  if (isManifest(manifest) && hasScript(manifest, script)) {
1181
1069
  await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
1182
1070
  operation.update({ event: "npm script" /* NpmScript */, script });
@@ -1219,7 +1107,9 @@ async function updateFile(relPath, operation) {
1219
1107
  case "bower.json":
1220
1108
  case "component.json":
1221
1109
  case "jsr.json":
1110
+ case "jsr.jsonc":
1222
1111
  case "deno.json":
1112
+ case "deno.jsonc":
1223
1113
  return updateManifestFile(relPath, operation);
1224
1114
  default:
1225
1115
  return updateTextFile(relPath, operation);
@@ -1229,12 +1119,12 @@ async function updateManifestFile(relPath, operation) {
1229
1119
  const { cwd } = operation.options;
1230
1120
  const { newVersion } = operation.state;
1231
1121
  let modified = false;
1232
- const file = await readJsonFile(relPath, cwd);
1122
+ const file = await readJsoncFile(relPath, cwd);
1233
1123
  if (isManifest(file.data) && file.data.version !== newVersion) {
1234
- file.data.version = newVersion;
1124
+ file.modified.push([["version"], newVersion]);
1235
1125
  if (isPackageLockManifest(file.data))
1236
- file.data.packages[""].version = newVersion;
1237
- await writeJsonFile(file);
1126
+ file.modified.push([["packages", "", "version"], newVersion]);
1127
+ await writeJsoncFile(file);
1238
1128
  modified = true;
1239
1129
  }
1240
1130
  return modified;
@@ -10,13 +10,13 @@ import {
10
10
  log_symbols_default,
11
11
  require_picocolors,
12
12
  versionBump
13
- } from "../chunk-WWXZEF5W.mjs";
13
+ } from "../chunk-BWAJDQ77.mjs";
14
14
 
15
15
  // src/cli/index.ts
16
16
  import process2 from "process";
17
17
 
18
18
  // package.json
19
- var version = "9.4.2";
19
+ var version = "9.5.0";
20
20
 
21
21
  // src/cli/parse-args.ts
22
22
  var import_picocolors = __toESM(require_picocolors());
package/dist/index.js CHANGED
@@ -695,9 +695,9 @@ function getNextVersion(currentVersion, bump) {
695
695
  }
696
696
  function getNextVersions(currentVersion, preid) {
697
697
  const next = {};
698
- const parse = import_semver.default.parse(currentVersion);
699
- if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
700
- preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
698
+ const parse2 = import_semver.default.parse(currentVersion);
699
+ if (typeof (parse2 == null ? void 0 : parse2.prerelease[0]) === "string")
700
+ preid = (parse2 == null ? void 0 : parse2.prerelease[0]) || "preid";
701
701
  for (const type of releaseTypes)
702
702
  next[type] = getNextVersion(currentVersion, { type, preid });
703
703
  return next;
@@ -760,134 +760,20 @@ var import_semver2 = require("semver");
760
760
  // src/fs.ts
761
761
  var import_node_fs = __toESM(require("fs"));
762
762
  var import_node_path = __toESM(require("path"));
763
-
764
- // node_modules/.pnpm/detect-indent@7.0.1/node_modules/detect-indent/index.js
765
- var INDENT_REGEX = /^(?:( )+|\t+)/;
766
- var INDENT_TYPE_SPACE = "space";
767
- var INDENT_TYPE_TAB = "tab";
768
- function makeIndentsMap(string, ignoreSingleSpaces) {
769
- const indents = /* @__PURE__ */ new Map();
770
- let previousSize = 0;
771
- let previousIndentType;
772
- let key;
773
- for (const line of string.split(/\n/g)) {
774
- if (!line) {
775
- continue;
776
- }
777
- let indent;
778
- let indentType;
779
- let use;
780
- let weight;
781
- let entry;
782
- const matches = line.match(INDENT_REGEX);
783
- if (matches === null) {
784
- previousSize = 0;
785
- previousIndentType = "";
786
- } else {
787
- indent = matches[0].length;
788
- indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
789
- if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
790
- continue;
791
- }
792
- if (indentType !== previousIndentType) {
793
- previousSize = 0;
794
- }
795
- previousIndentType = indentType;
796
- use = 1;
797
- weight = 0;
798
- const indentDifference = indent - previousSize;
799
- previousSize = indent;
800
- if (indentDifference === 0) {
801
- use = 0;
802
- weight = 1;
803
- } else {
804
- const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
805
- key = encodeIndentsKey(indentType, absoluteIndentDifference);
806
- }
807
- entry = indents.get(key);
808
- entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight];
809
- indents.set(key, entry);
810
- }
811
- }
812
- return indents;
813
- }
814
- function encodeIndentsKey(indentType, indentAmount) {
815
- const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
816
- return typeCharacter + String(indentAmount);
817
- }
818
- function decodeIndentsKey(indentsKey) {
819
- const keyHasTypeSpace = indentsKey[0] === "s";
820
- const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
821
- const amount = Number(indentsKey.slice(1));
822
- return { type, amount };
823
- }
824
- function getMostUsedKey(indents) {
825
- let result;
826
- let maxUsed = 0;
827
- let maxWeight = 0;
828
- for (const [key, [usedCount, weight]] of indents) {
829
- if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
830
- maxUsed = usedCount;
831
- maxWeight = weight;
832
- result = key;
833
- }
834
- }
835
- return result;
836
- }
837
- function makeIndentString(type, amount) {
838
- const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
839
- return indentCharacter.repeat(amount);
840
- }
841
- function detectIndent(string) {
842
- if (typeof string !== "string") {
843
- throw new TypeError("Expected a string");
844
- }
845
- let indents = makeIndentsMap(string, true);
846
- if (indents.size === 0) {
847
- indents = makeIndentsMap(string, false);
848
- }
849
- const keyOfMostUsedIndent = getMostUsedKey(indents);
850
- let type;
851
- let amount = 0;
852
- let indent = "";
853
- if (keyOfMostUsedIndent !== void 0) {
854
- ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
855
- indent = makeIndentString(type, amount);
856
- }
857
- return {
858
- amount,
859
- type,
860
- indent
861
- };
862
- }
863
-
864
- // node_modules/.pnpm/detect-newline@4.0.1/node_modules/detect-newline/index.js
865
- function detectNewline(string) {
866
- if (typeof string !== "string") {
867
- throw new TypeError("Expected a string");
868
- }
869
- const newlines = string.match(/(?:\r?\n)/g) || [];
870
- if (newlines.length === 0) {
871
- return;
872
- }
873
- const crlf = newlines.filter((newline) => newline === "\r\n").length;
874
- const lf = newlines.length - crlf;
875
- return crlf > lf ? "\r\n" : "\n";
876
- }
877
-
878
- // src/fs.ts
879
- async function readJsonFile(name, cwd) {
763
+ var jsonc = __toESM(require("jsonc-parser"));
764
+ async function readJsoncFile(name, cwd) {
880
765
  const file = await readTextFile(name, cwd);
881
- const data = JSON.parse(file.data);
882
- const indent = detectIndent(file.data).indent;
883
- const newline = detectNewline(file.data);
884
- return __spreadProps(__spreadValues({}, file), { data, indent, newline });
766
+ const data = jsonc.parse(file.data);
767
+ const modified = [];
768
+ return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
885
769
  }
886
- async function writeJsonFile(file) {
887
- let json = JSON.stringify(file.data, void 0, file.indent);
888
- if (file.newline)
889
- json += file.newline;
890
- return writeTextFile(__spreadProps(__spreadValues({}, file), { data: json }));
770
+ async function writeJsoncFile(file) {
771
+ let newJSON = file.text;
772
+ for (const [key, value] of file.modified) {
773
+ const edit = jsonc.modify(file.text, key, value, {});
774
+ newJSON = jsonc.applyEdits(newJSON, edit);
775
+ }
776
+ return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
891
777
  }
892
778
  function readTextFile(name, cwd) {
893
779
  return new Promise((resolve, reject) => {
@@ -936,6 +822,8 @@ async function getCurrentVersion(operation) {
936
822
  const filesToCheck = files.filter((file) => file.endsWith(".json"));
937
823
  if (!filesToCheck.includes("package.json"))
938
824
  filesToCheck.push("package.json");
825
+ if (!filesToCheck.includes("deno.json"))
826
+ filesToCheck.push("deno.json");
939
827
  for (const file of filesToCheck) {
940
828
  const version = await readVersion(file, cwd);
941
829
  if (version) {
@@ -951,7 +839,7 @@ async function getCurrentVersion(operation) {
951
839
  }
952
840
  async function readVersion(file, cwd) {
953
841
  try {
954
- const { data: manifest } = await readJsonFile(file, cwd);
842
+ const { data: manifest } = await readJsoncFile(file, cwd);
955
843
  if (isManifest(manifest)) {
956
844
  if ((0, import_semver2.valid)(manifest.version))
957
845
  return manifest.version;
@@ -1200,7 +1088,7 @@ var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));
1200
1088
  async function runNpmScript(script, operation) {
1201
1089
  const { cwd, ignoreScripts } = operation.options;
1202
1090
  if (!ignoreScripts) {
1203
- const { data: manifest } = await readJsonFile("package.json", cwd);
1091
+ const { data: manifest } = await readJsoncFile("package.json", cwd);
1204
1092
  if (isManifest(manifest) && hasScript(manifest, script)) {
1205
1093
  await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
1206
1094
  operation.update({ event: "npm script" /* NpmScript */, script });
@@ -1243,7 +1131,9 @@ async function updateFile(relPath, operation) {
1243
1131
  case "bower.json":
1244
1132
  case "component.json":
1245
1133
  case "jsr.json":
1134
+ case "jsr.jsonc":
1246
1135
  case "deno.json":
1136
+ case "deno.jsonc":
1247
1137
  return updateManifestFile(relPath, operation);
1248
1138
  default:
1249
1139
  return updateTextFile(relPath, operation);
@@ -1253,12 +1143,12 @@ async function updateManifestFile(relPath, operation) {
1253
1143
  const { cwd } = operation.options;
1254
1144
  const { newVersion } = operation.state;
1255
1145
  let modified = false;
1256
- const file = await readJsonFile(relPath, cwd);
1146
+ const file = await readJsoncFile(relPath, cwd);
1257
1147
  if (isManifest(file.data) && file.data.version !== newVersion) {
1258
- file.data.version = newVersion;
1148
+ file.modified.push([["version"], newVersion]);
1259
1149
  if (isPackageLockManifest(file.data))
1260
- file.data.packages[""].version = newVersion;
1261
- await writeJsonFile(file);
1150
+ file.modified.push([["packages", "", "version"], newVersion]);
1151
+ await writeJsoncFile(file);
1262
1152
  modified = true;
1263
1153
  }
1264
1154
  return modified;
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  loadBumpConfig,
8
8
  versionBump,
9
9
  versionBumpInfo
10
- } from "./chunk-WWXZEF5W.mjs";
10
+ } from "./chunk-BWAJDQ77.mjs";
11
11
 
12
12
  // src/index.ts
13
13
  var src_default = versionBump;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bumpp",
3
- "version": "9.4.2",
4
- "packageManager": "pnpm@9.6.0",
3
+ "version": "9.5.0",
4
+ "packageManager": "pnpm@9.7.0",
5
5
  "description": "Bump version, commit changes, tag, and push to Git",
6
6
  "author": {
7
7
  "name": "James Messinger",
@@ -65,24 +65,23 @@
65
65
  "escalade": "^3.1.2",
66
66
  "fast-glob": "^3.3.2",
67
67
  "js-yaml": "^4.1.0",
68
+ "jsonc-parser": "^3.3.1",
68
69
  "prompts": "^2.4.2",
69
70
  "semver": "^7.6.3"
70
71
  },
71
72
  "devDependencies": {
72
- "@antfu/eslint-config": "^2.24.1",
73
+ "@antfu/eslint-config": "^2.25.1",
73
74
  "@types/js-yaml": "^4.0.9",
74
- "@types/node": "^22.0.2",
75
+ "@types/node": "^22.2.0",
75
76
  "@types/prompts": "^2.4.9",
76
77
  "@types/semver": "^7.5.8",
77
- "detect-indent": "^7.0.1",
78
- "detect-newline": "^4.0.1",
79
- "eslint": "^9.8.0",
78
+ "eslint": "^9.9.0",
80
79
  "esno": "^4.7.0",
81
80
  "log-symbols": "^6.0.0",
82
81
  "npm-check": "^6.0.1",
83
82
  "picocolors": "^1.0.1",
84
83
  "rimraf": "^6.0.1",
85
- "tsup": "^8.2.3",
84
+ "tsup": "^8.2.4",
86
85
  "typescript": "^5.5.4",
87
86
  "vitest": "^2.0.5"
88
87
  }