bumpp 9.3.0 → 9.4.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/{chunk-ZY4OVS4D.mjs → chunk-OMAU23UL.mjs} +84 -37
- package/dist/cli/index.js +111 -46
- package/dist/cli/index.mjs +34 -10
- package/dist/index.d.mts +15 -8
- package/dist/index.d.ts +15 -8
- package/dist/index.js +82 -38
- package/dist/index.mjs +1 -1
- package/package.json +16 -12
|
@@ -624,7 +624,7 @@ var log_symbols_default = logSymbols;
|
|
|
624
624
|
|
|
625
625
|
// src/release-type.ts
|
|
626
626
|
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
627
|
-
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
|
|
627
|
+
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]);
|
|
628
628
|
function isPrerelease(value) {
|
|
629
629
|
return prereleaseTypes.includes(value);
|
|
630
630
|
}
|
|
@@ -662,7 +662,7 @@ import prompts from "prompts";
|
|
|
662
662
|
import semver, { SemVer, clean as cleanVersion, valid as isValidVersion } from "semver";
|
|
663
663
|
async function getNewVersion(operation) {
|
|
664
664
|
const { release } = operation.options;
|
|
665
|
-
const {
|
|
665
|
+
const { currentVersion } = operation.state;
|
|
666
666
|
switch (release.type) {
|
|
667
667
|
case "prompt":
|
|
668
668
|
return promptForNewVersion(operation);
|
|
@@ -673,42 +673,41 @@ async function getNewVersion(operation) {
|
|
|
673
673
|
default:
|
|
674
674
|
return operation.update({
|
|
675
675
|
release: release.type,
|
|
676
|
-
newVersion: getNextVersion(
|
|
676
|
+
newVersion: getNextVersion(currentVersion, release)
|
|
677
677
|
});
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
|
-
function getNextVersion(
|
|
681
|
-
const oldSemVer = new SemVer(
|
|
682
|
-
const
|
|
680
|
+
function getNextVersion(currentVersion, bump) {
|
|
681
|
+
const oldSemVer = new SemVer(currentVersion);
|
|
682
|
+
const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type;
|
|
683
|
+
const newSemVer = oldSemVer.inc(type, bump.preid);
|
|
683
684
|
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
|
|
684
685
|
newSemVer.prerelease[1] = "1";
|
|
685
686
|
newSemVer.format();
|
|
686
687
|
}
|
|
687
688
|
return newSemVer.version;
|
|
688
689
|
}
|
|
689
|
-
function getNextVersions(
|
|
690
|
-
var _a;
|
|
690
|
+
function getNextVersions(currentVersion, preid) {
|
|
691
691
|
const next = {};
|
|
692
|
-
const parse = semver.parse(
|
|
692
|
+
const parse = semver.parse(currentVersion);
|
|
693
693
|
if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
|
|
694
694
|
preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
|
|
695
695
|
for (const type of releaseTypes)
|
|
696
|
-
next[type] =
|
|
697
|
-
next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? semver.inc(oldVersion, "prerelease", preid) : semver.inc(oldVersion, "patch");
|
|
696
|
+
next[type] = getNextVersion(currentVersion, { type, preid });
|
|
698
697
|
return next;
|
|
699
698
|
}
|
|
700
699
|
async function promptForNewVersion(operation) {
|
|
701
700
|
var _a, _b;
|
|
702
|
-
const {
|
|
701
|
+
const { currentVersion } = operation.state;
|
|
703
702
|
const release = operation.options.release;
|
|
704
|
-
const next = getNextVersions(
|
|
705
|
-
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a,
|
|
703
|
+
const next = getNextVersions(currentVersion, release.preid);
|
|
704
|
+
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, currentVersion, semver));
|
|
706
705
|
const PADDING = 13;
|
|
707
706
|
const answers = await prompts([
|
|
708
707
|
{
|
|
709
708
|
type: "autocomplete",
|
|
710
709
|
name: "release",
|
|
711
|
-
message: `Current version ${import_picocolors.default.green(
|
|
710
|
+
message: `Current version ${import_picocolors.default.green(currentVersion)}`,
|
|
712
711
|
initial: configCustomVersion ? "config" : "next",
|
|
713
712
|
choices: [
|
|
714
713
|
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.major)}` },
|
|
@@ -721,7 +720,7 @@ async function promptForNewVersion(operation) {
|
|
|
721
720
|
{ value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.prepatch)}` },
|
|
722
721
|
{ value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.preminor)}` },
|
|
723
722
|
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` },
|
|
724
|
-
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(
|
|
723
|
+
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(currentVersion)}` },
|
|
725
724
|
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
|
|
726
725
|
]
|
|
727
726
|
},
|
|
@@ -729,13 +728,13 @@ async function promptForNewVersion(operation) {
|
|
|
729
728
|
type: (prev) => prev === "custom" ? "text" : null,
|
|
730
729
|
name: "custom",
|
|
731
730
|
message: "Enter the new version number:",
|
|
732
|
-
initial:
|
|
731
|
+
initial: currentVersion,
|
|
733
732
|
validate: (custom) => {
|
|
734
733
|
return isValidVersion(custom) ? true : "That's not a valid version number";
|
|
735
734
|
}
|
|
736
735
|
}
|
|
737
736
|
]);
|
|
738
|
-
const newVersion = answers.release === "none" ?
|
|
737
|
+
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? cleanVersion(answers.custom) : answers.release === "config" ? cleanVersion(configCustomVersion) : next[answers.release];
|
|
739
738
|
if (!newVersion)
|
|
740
739
|
process4.exit(1);
|
|
741
740
|
switch (answers.release) {
|
|
@@ -749,7 +748,7 @@ async function promptForNewVersion(operation) {
|
|
|
749
748
|
}
|
|
750
749
|
}
|
|
751
750
|
|
|
752
|
-
// src/get-
|
|
751
|
+
// src/get-current-version.ts
|
|
753
752
|
import { valid as isValidVersion2 } from "semver";
|
|
754
753
|
|
|
755
754
|
// src/fs.ts
|
|
@@ -914,13 +913,19 @@ function writeTextFile(file) {
|
|
|
914
913
|
function isManifest(obj) {
|
|
915
914
|
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
916
915
|
}
|
|
916
|
+
function isPackageLockManifest(manifest) {
|
|
917
|
+
var _a, _b;
|
|
918
|
+
return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
|
|
919
|
+
}
|
|
917
920
|
function isOptionalString(value) {
|
|
918
921
|
const type = typeof value;
|
|
919
922
|
return value === null || type === "undefined" || type === "string";
|
|
920
923
|
}
|
|
921
924
|
|
|
922
|
-
// src/get-
|
|
923
|
-
async function
|
|
925
|
+
// src/get-current-version.ts
|
|
926
|
+
async function getCurrentVersion(operation) {
|
|
927
|
+
if (operation.state.currentVersion)
|
|
928
|
+
return operation;
|
|
924
929
|
const { cwd, files } = operation.options;
|
|
925
930
|
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
926
931
|
if (!filesToCheck.includes("package.json"))
|
|
@@ -929,8 +934,8 @@ async function getOldVersion(operation) {
|
|
|
929
934
|
const version = await readVersion(file, cwd);
|
|
930
935
|
if (version) {
|
|
931
936
|
return operation.update({
|
|
932
|
-
|
|
933
|
-
|
|
937
|
+
currentVersionSource: file,
|
|
938
|
+
currentVersion: version
|
|
934
939
|
});
|
|
935
940
|
}
|
|
936
941
|
}
|
|
@@ -1020,7 +1025,7 @@ async function normalizeOptions(raw) {
|
|
|
1020
1025
|
let release;
|
|
1021
1026
|
if (!raw.release || raw.release === "prompt")
|
|
1022
1027
|
release = { type: "prompt", preid };
|
|
1023
|
-
else if (isReleaseType(raw.release))
|
|
1028
|
+
else if (isReleaseType(raw.release) || raw.release === "next")
|
|
1024
1029
|
release = { type: raw.release, preid };
|
|
1025
1030
|
else
|
|
1026
1031
|
release = { type: "version", version: raw.release };
|
|
@@ -1035,7 +1040,7 @@ async function normalizeOptions(raw) {
|
|
|
1035
1040
|
else if (raw.commit || tag || push)
|
|
1036
1041
|
commit = { all, noVerify, message: "chore: release v" };
|
|
1037
1042
|
const files = await fg(
|
|
1038
|
-
((_a = raw.files) == null ? void 0 : _a.length) ? raw.files : ["package.json", "package-lock.json"],
|
|
1043
|
+
((_a = raw.files) == null ? void 0 : _a.length) ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc"],
|
|
1039
1044
|
{
|
|
1040
1045
|
cwd,
|
|
1041
1046
|
onlyFiles: true,
|
|
@@ -1069,7 +1074,8 @@ async function normalizeOptions(raw) {
|
|
|
1069
1074
|
interface: ui,
|
|
1070
1075
|
ignoreScripts,
|
|
1071
1076
|
execute,
|
|
1072
|
-
customVersion: raw.customVersion
|
|
1077
|
+
customVersion: raw.customVersion,
|
|
1078
|
+
currentVersion: raw.currentVersion
|
|
1073
1079
|
};
|
|
1074
1080
|
}
|
|
1075
1081
|
|
|
@@ -1084,8 +1090,8 @@ var Operation = class _Operation {
|
|
|
1084
1090
|
*/
|
|
1085
1091
|
this.state = {
|
|
1086
1092
|
release: void 0,
|
|
1087
|
-
|
|
1088
|
-
|
|
1093
|
+
currentVersion: "",
|
|
1094
|
+
currentVersionSource: "",
|
|
1089
1095
|
newVersion: "",
|
|
1090
1096
|
commitMessage: "",
|
|
1091
1097
|
tagName: "",
|
|
@@ -1094,6 +1100,12 @@ var Operation = class _Operation {
|
|
|
1094
1100
|
};
|
|
1095
1101
|
this.options = options;
|
|
1096
1102
|
this._progress = progress;
|
|
1103
|
+
if (options.currentVersion) {
|
|
1104
|
+
this.update({
|
|
1105
|
+
currentVersion: options.currentVersion,
|
|
1106
|
+
currentVersionSource: "user"
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1097
1109
|
}
|
|
1098
1110
|
/**
|
|
1099
1111
|
* The results of the operation.
|
|
@@ -1103,7 +1115,7 @@ var Operation = class _Operation {
|
|
|
1103
1115
|
const state = this.state;
|
|
1104
1116
|
return {
|
|
1105
1117
|
release: state.release,
|
|
1106
|
-
|
|
1118
|
+
currentVersion: state.currentVersion,
|
|
1107
1119
|
newVersion: state.newVersion,
|
|
1108
1120
|
commit: options.commit ? state.commitMessage : false,
|
|
1109
1121
|
tag: options.tag ? state.tagName : false,
|
|
@@ -1178,6 +1190,7 @@ async function updateFile(relPath, operation) {
|
|
|
1178
1190
|
case "package-lock.json":
|
|
1179
1191
|
case "bower.json":
|
|
1180
1192
|
case "component.json":
|
|
1193
|
+
case "jsr.json":
|
|
1181
1194
|
return updateManifestFile(relPath, operation);
|
|
1182
1195
|
default:
|
|
1183
1196
|
return updateTextFile(relPath, operation);
|
|
@@ -1190,6 +1203,8 @@ async function updateManifestFile(relPath, operation) {
|
|
|
1190
1203
|
const file = await readJsonFile(relPath, cwd);
|
|
1191
1204
|
if (isManifest(file.data) && file.data.version !== newVersion) {
|
|
1192
1205
|
file.data.version = newVersion;
|
|
1206
|
+
if (isPackageLockManifest(file.data))
|
|
1207
|
+
file.data.packages[""].version = newVersion;
|
|
1193
1208
|
await writeJsonFile(file);
|
|
1194
1209
|
modified = true;
|
|
1195
1210
|
}
|
|
@@ -1197,11 +1212,11 @@ async function updateManifestFile(relPath, operation) {
|
|
|
1197
1212
|
}
|
|
1198
1213
|
async function updateTextFile(relPath, operation) {
|
|
1199
1214
|
const { cwd } = operation.options;
|
|
1200
|
-
const {
|
|
1215
|
+
const { currentVersion, newVersion } = operation.state;
|
|
1201
1216
|
const modified = false;
|
|
1202
1217
|
const file = await readTextFile(relPath, cwd);
|
|
1203
|
-
if (file.data.includes(
|
|
1204
|
-
const sanitizedVersion =
|
|
1218
|
+
if (file.data.includes(currentVersion)) {
|
|
1219
|
+
const sanitizedVersion = currentVersion.replace(/(\W)/g, "\\$1");
|
|
1205
1220
|
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
|
|
1206
1221
|
file.data = file.data.replace(replacePattern, `$1${newVersion}`);
|
|
1207
1222
|
await writeTextFile(file);
|
|
@@ -1215,7 +1230,7 @@ async function versionBump(arg = {}) {
|
|
|
1215
1230
|
if (typeof arg === "string")
|
|
1216
1231
|
arg = { release: arg };
|
|
1217
1232
|
const operation = await Operation.start(arg);
|
|
1218
|
-
await
|
|
1233
|
+
await getCurrentVersion(operation);
|
|
1219
1234
|
await getNewVersion(operation);
|
|
1220
1235
|
if (arg.confirm) {
|
|
1221
1236
|
printSummary(operation);
|
|
@@ -1253,7 +1268,7 @@ function printSummary(operation) {
|
|
|
1253
1268
|
if (operation.options.push)
|
|
1254
1269
|
console.log(` push ${import_picocolors2.default.cyan(import_picocolors2.default.bold("yes"))}`);
|
|
1255
1270
|
console.log();
|
|
1256
|
-
console.log(` from ${import_picocolors2.default.bold(operation.state.
|
|
1271
|
+
console.log(` from ${import_picocolors2.default.bold(operation.state.currentVersion)}`);
|
|
1257
1272
|
console.log(` to ${import_picocolors2.default.green(import_picocolors2.default.bold(operation.state.newVersion))}`);
|
|
1258
1273
|
console.log();
|
|
1259
1274
|
}
|
|
@@ -1261,14 +1276,16 @@ async function versionBumpInfo(arg = {}) {
|
|
|
1261
1276
|
if (typeof arg === "string")
|
|
1262
1277
|
arg = { release: arg };
|
|
1263
1278
|
const operation = await Operation.start(arg);
|
|
1264
|
-
await
|
|
1279
|
+
await getCurrentVersion(operation);
|
|
1265
1280
|
await getNewVersion(operation);
|
|
1266
1281
|
return operation;
|
|
1267
1282
|
}
|
|
1268
1283
|
|
|
1269
1284
|
// src/config.ts
|
|
1270
1285
|
import process7 from "process";
|
|
1286
|
+
import { dirname } from "path";
|
|
1271
1287
|
import { loadConfig } from "c12";
|
|
1288
|
+
import escalade from "escalade/sync";
|
|
1272
1289
|
var bumpConfigDefaults = {
|
|
1273
1290
|
commit: true,
|
|
1274
1291
|
push: true,
|
|
@@ -1281,19 +1298,49 @@ var bumpConfigDefaults = {
|
|
|
1281
1298
|
files: []
|
|
1282
1299
|
};
|
|
1283
1300
|
async function loadBumpConfig(overrides, cwd = process7.cwd()) {
|
|
1301
|
+
const name = "bump";
|
|
1302
|
+
const configFile = findConfigFile(name, cwd);
|
|
1284
1303
|
const { config } = await loadConfig({
|
|
1285
|
-
name
|
|
1304
|
+
name,
|
|
1286
1305
|
defaults: bumpConfigDefaults,
|
|
1287
1306
|
overrides: __spreadValues({}, overrides),
|
|
1288
|
-
cwd
|
|
1307
|
+
cwd: configFile ? dirname(configFile) : cwd
|
|
1289
1308
|
});
|
|
1290
1309
|
return config;
|
|
1291
1310
|
}
|
|
1311
|
+
function findConfigFile(name, cwd) {
|
|
1312
|
+
let foundRepositoryRoot = false;
|
|
1313
|
+
try {
|
|
1314
|
+
const candidates = ["js", "mjs", "ts", "mts", "json"].map((ext) => `${name}.config.${ext}`);
|
|
1315
|
+
return escalade(cwd, (_dir, files) => {
|
|
1316
|
+
const match = files.find((file) => {
|
|
1317
|
+
if (candidates.includes(file))
|
|
1318
|
+
return true;
|
|
1319
|
+
if (file === ".git")
|
|
1320
|
+
foundRepositoryRoot = true;
|
|
1321
|
+
return false;
|
|
1322
|
+
});
|
|
1323
|
+
if (match)
|
|
1324
|
+
return match;
|
|
1325
|
+
if (foundRepositoryRoot) {
|
|
1326
|
+
throw null;
|
|
1327
|
+
}
|
|
1328
|
+
return false;
|
|
1329
|
+
});
|
|
1330
|
+
} catch (error) {
|
|
1331
|
+
if (foundRepositoryRoot)
|
|
1332
|
+
return null;
|
|
1333
|
+
throw error;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1292
1336
|
function defineConfig(config) {
|
|
1293
1337
|
return config;
|
|
1294
1338
|
}
|
|
1295
1339
|
|
|
1296
1340
|
export {
|
|
1341
|
+
__spreadValues,
|
|
1342
|
+
__spreadProps,
|
|
1343
|
+
__objRest,
|
|
1297
1344
|
__toESM,
|
|
1298
1345
|
require_picocolors,
|
|
1299
1346
|
log_symbols_default,
|
package/dist/cli/index.js
CHANGED
|
@@ -60,7 +60,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
60
60
|
|
|
61
61
|
// node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js
|
|
62
62
|
var require_picocolors = __commonJS({
|
|
63
|
-
"node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(
|
|
63
|
+
"node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
64
64
|
var tty2 = require("tty");
|
|
65
65
|
var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
|
|
66
66
|
var formatter = (open, close, replace = open) => (input) => {
|
|
@@ -628,7 +628,7 @@ var logSymbols = isUnicodeSupported() ? main : fallback;
|
|
|
628
628
|
var log_symbols_default = logSymbols;
|
|
629
629
|
|
|
630
630
|
// package.json
|
|
631
|
-
var version = "9.
|
|
631
|
+
var version = "9.4.0";
|
|
632
632
|
|
|
633
633
|
// src/version-bump.ts
|
|
634
634
|
var import_node_process5 = __toESM(require("process"));
|
|
@@ -644,7 +644,7 @@ var import_semver = __toESM(require("semver"));
|
|
|
644
644
|
|
|
645
645
|
// src/release-type.ts
|
|
646
646
|
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
647
|
-
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
|
|
647
|
+
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]);
|
|
648
648
|
function isPrerelease(value) {
|
|
649
649
|
return prereleaseTypes.includes(value);
|
|
650
650
|
}
|
|
@@ -655,7 +655,7 @@ function isReleaseType(value) {
|
|
|
655
655
|
// src/get-new-version.ts
|
|
656
656
|
async function getNewVersion(operation) {
|
|
657
657
|
const { release } = operation.options;
|
|
658
|
-
const {
|
|
658
|
+
const { currentVersion } = operation.state;
|
|
659
659
|
switch (release.type) {
|
|
660
660
|
case "prompt":
|
|
661
661
|
return promptForNewVersion(operation);
|
|
@@ -666,42 +666,41 @@ async function getNewVersion(operation) {
|
|
|
666
666
|
default:
|
|
667
667
|
return operation.update({
|
|
668
668
|
release: release.type,
|
|
669
|
-
newVersion: getNextVersion(
|
|
669
|
+
newVersion: getNextVersion(currentVersion, release)
|
|
670
670
|
});
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
|
-
function getNextVersion(
|
|
674
|
-
const oldSemVer = new import_semver.SemVer(
|
|
675
|
-
const
|
|
673
|
+
function getNextVersion(currentVersion, bump) {
|
|
674
|
+
const oldSemVer = new import_semver.SemVer(currentVersion);
|
|
675
|
+
const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type;
|
|
676
|
+
const newSemVer = oldSemVer.inc(type, bump.preid);
|
|
676
677
|
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
|
|
677
678
|
newSemVer.prerelease[1] = "1";
|
|
678
679
|
newSemVer.format();
|
|
679
680
|
}
|
|
680
681
|
return newSemVer.version;
|
|
681
682
|
}
|
|
682
|
-
function getNextVersions(
|
|
683
|
-
var _a;
|
|
683
|
+
function getNextVersions(currentVersion, preid) {
|
|
684
684
|
const next = {};
|
|
685
|
-
const parse = import_semver.default.parse(
|
|
685
|
+
const parse = import_semver.default.parse(currentVersion);
|
|
686
686
|
if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
|
|
687
687
|
preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
|
|
688
688
|
for (const type of releaseTypes)
|
|
689
|
-
next[type] =
|
|
690
|
-
next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? import_semver.default.inc(oldVersion, "prerelease", preid) : import_semver.default.inc(oldVersion, "patch");
|
|
689
|
+
next[type] = getNextVersion(currentVersion, { type, preid });
|
|
691
690
|
return next;
|
|
692
691
|
}
|
|
693
692
|
async function promptForNewVersion(operation) {
|
|
694
693
|
var _a, _b;
|
|
695
|
-
const {
|
|
694
|
+
const { currentVersion } = operation.state;
|
|
696
695
|
const release = operation.options.release;
|
|
697
|
-
const next = getNextVersions(
|
|
698
|
-
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a,
|
|
696
|
+
const next = getNextVersions(currentVersion, release.preid);
|
|
697
|
+
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, currentVersion, import_semver.default));
|
|
699
698
|
const PADDING = 13;
|
|
700
699
|
const answers = await (0, import_prompts.default)([
|
|
701
700
|
{
|
|
702
701
|
type: "autocomplete",
|
|
703
702
|
name: "release",
|
|
704
|
-
message: `Current version ${import_picocolors.default.green(
|
|
703
|
+
message: `Current version ${import_picocolors.default.green(currentVersion)}`,
|
|
705
704
|
initial: configCustomVersion ? "config" : "next",
|
|
706
705
|
choices: [
|
|
707
706
|
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.major)}` },
|
|
@@ -714,7 +713,7 @@ async function promptForNewVersion(operation) {
|
|
|
714
713
|
{ value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.prepatch)}` },
|
|
715
714
|
{ value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.preminor)}` },
|
|
716
715
|
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` },
|
|
717
|
-
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(
|
|
716
|
+
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(currentVersion)}` },
|
|
718
717
|
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
|
|
719
718
|
]
|
|
720
719
|
},
|
|
@@ -722,13 +721,13 @@ async function promptForNewVersion(operation) {
|
|
|
722
721
|
type: (prev) => prev === "custom" ? "text" : null,
|
|
723
722
|
name: "custom",
|
|
724
723
|
message: "Enter the new version number:",
|
|
725
|
-
initial:
|
|
724
|
+
initial: currentVersion,
|
|
726
725
|
validate: (custom) => {
|
|
727
726
|
return (0, import_semver.valid)(custom) ? true : "That's not a valid version number";
|
|
728
727
|
}
|
|
729
728
|
}
|
|
730
729
|
]);
|
|
731
|
-
const newVersion = answers.release === "none" ?
|
|
730
|
+
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? (0, import_semver.clean)(answers.custom) : answers.release === "config" ? (0, import_semver.clean)(configCustomVersion) : next[answers.release];
|
|
732
731
|
if (!newVersion)
|
|
733
732
|
import_node_process3.default.exit(1);
|
|
734
733
|
switch (answers.release) {
|
|
@@ -742,7 +741,7 @@ async function promptForNewVersion(operation) {
|
|
|
742
741
|
}
|
|
743
742
|
}
|
|
744
743
|
|
|
745
|
-
// src/get-
|
|
744
|
+
// src/get-current-version.ts
|
|
746
745
|
var import_semver2 = require("semver");
|
|
747
746
|
|
|
748
747
|
// src/fs.ts
|
|
@@ -907,13 +906,19 @@ function writeTextFile(file) {
|
|
|
907
906
|
function isManifest(obj) {
|
|
908
907
|
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
909
908
|
}
|
|
909
|
+
function isPackageLockManifest(manifest) {
|
|
910
|
+
var _a, _b;
|
|
911
|
+
return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
|
|
912
|
+
}
|
|
910
913
|
function isOptionalString(value) {
|
|
911
914
|
const type = typeof value;
|
|
912
915
|
return value === null || type === "undefined" || type === "string";
|
|
913
916
|
}
|
|
914
917
|
|
|
915
|
-
// src/get-
|
|
916
|
-
async function
|
|
918
|
+
// src/get-current-version.ts
|
|
919
|
+
async function getCurrentVersion(operation) {
|
|
920
|
+
if (operation.state.currentVersion)
|
|
921
|
+
return operation;
|
|
917
922
|
const { cwd, files } = operation.options;
|
|
918
923
|
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
919
924
|
if (!filesToCheck.includes("package.json"))
|
|
@@ -922,8 +927,8 @@ async function getOldVersion(operation) {
|
|
|
922
927
|
const version2 = await readVersion(file, cwd);
|
|
923
928
|
if (version2) {
|
|
924
929
|
return operation.update({
|
|
925
|
-
|
|
926
|
-
|
|
930
|
+
currentVersionSource: file,
|
|
931
|
+
currentVersion: version2
|
|
927
932
|
});
|
|
928
933
|
}
|
|
929
934
|
}
|
|
@@ -1013,7 +1018,7 @@ async function normalizeOptions(raw) {
|
|
|
1013
1018
|
let release;
|
|
1014
1019
|
if (!raw.release || raw.release === "prompt")
|
|
1015
1020
|
release = { type: "prompt", preid };
|
|
1016
|
-
else if (isReleaseType(raw.release))
|
|
1021
|
+
else if (isReleaseType(raw.release) || raw.release === "next")
|
|
1017
1022
|
release = { type: raw.release, preid };
|
|
1018
1023
|
else
|
|
1019
1024
|
release = { type: "version", version: raw.release };
|
|
@@ -1028,7 +1033,7 @@ async function normalizeOptions(raw) {
|
|
|
1028
1033
|
else if (raw.commit || tag || push)
|
|
1029
1034
|
commit = { all, noVerify, message: "chore: release v" };
|
|
1030
1035
|
const files = await (0, import_fast_glob.default)(
|
|
1031
|
-
((_a = raw.files) == null ? void 0 : _a.length) ? raw.files : ["package.json", "package-lock.json"],
|
|
1036
|
+
((_a = raw.files) == null ? void 0 : _a.length) ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc"],
|
|
1032
1037
|
{
|
|
1033
1038
|
cwd,
|
|
1034
1039
|
onlyFiles: true,
|
|
@@ -1062,7 +1067,8 @@ async function normalizeOptions(raw) {
|
|
|
1062
1067
|
interface: ui,
|
|
1063
1068
|
ignoreScripts,
|
|
1064
1069
|
execute,
|
|
1065
|
-
customVersion: raw.customVersion
|
|
1070
|
+
customVersion: raw.customVersion,
|
|
1071
|
+
currentVersion: raw.currentVersion
|
|
1066
1072
|
};
|
|
1067
1073
|
}
|
|
1068
1074
|
|
|
@@ -1077,8 +1083,8 @@ var Operation = class _Operation {
|
|
|
1077
1083
|
*/
|
|
1078
1084
|
this.state = {
|
|
1079
1085
|
release: void 0,
|
|
1080
|
-
|
|
1081
|
-
|
|
1086
|
+
currentVersion: "",
|
|
1087
|
+
currentVersionSource: "",
|
|
1082
1088
|
newVersion: "",
|
|
1083
1089
|
commitMessage: "",
|
|
1084
1090
|
tagName: "",
|
|
@@ -1087,6 +1093,12 @@ var Operation = class _Operation {
|
|
|
1087
1093
|
};
|
|
1088
1094
|
this.options = options;
|
|
1089
1095
|
this._progress = progress2;
|
|
1096
|
+
if (options.currentVersion) {
|
|
1097
|
+
this.update({
|
|
1098
|
+
currentVersion: options.currentVersion,
|
|
1099
|
+
currentVersionSource: "user"
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1090
1102
|
}
|
|
1091
1103
|
/**
|
|
1092
1104
|
* The results of the operation.
|
|
@@ -1096,7 +1108,7 @@ var Operation = class _Operation {
|
|
|
1096
1108
|
const state = this.state;
|
|
1097
1109
|
return {
|
|
1098
1110
|
release: state.release,
|
|
1099
|
-
|
|
1111
|
+
currentVersion: state.currentVersion,
|
|
1100
1112
|
newVersion: state.newVersion,
|
|
1101
1113
|
commit: options.commit ? state.commitMessage : false,
|
|
1102
1114
|
tag: options.tag ? state.tagName : false,
|
|
@@ -1171,6 +1183,7 @@ async function updateFile(relPath, operation) {
|
|
|
1171
1183
|
case "package-lock.json":
|
|
1172
1184
|
case "bower.json":
|
|
1173
1185
|
case "component.json":
|
|
1186
|
+
case "jsr.json":
|
|
1174
1187
|
return updateManifestFile(relPath, operation);
|
|
1175
1188
|
default:
|
|
1176
1189
|
return updateTextFile(relPath, operation);
|
|
@@ -1183,6 +1196,8 @@ async function updateManifestFile(relPath, operation) {
|
|
|
1183
1196
|
const file = await readJsonFile(relPath, cwd);
|
|
1184
1197
|
if (isManifest(file.data) && file.data.version !== newVersion) {
|
|
1185
1198
|
file.data.version = newVersion;
|
|
1199
|
+
if (isPackageLockManifest(file.data))
|
|
1200
|
+
file.data.packages[""].version = newVersion;
|
|
1186
1201
|
await writeJsonFile(file);
|
|
1187
1202
|
modified = true;
|
|
1188
1203
|
}
|
|
@@ -1190,11 +1205,11 @@ async function updateManifestFile(relPath, operation) {
|
|
|
1190
1205
|
}
|
|
1191
1206
|
async function updateTextFile(relPath, operation) {
|
|
1192
1207
|
const { cwd } = operation.options;
|
|
1193
|
-
const {
|
|
1208
|
+
const { currentVersion, newVersion } = operation.state;
|
|
1194
1209
|
const modified = false;
|
|
1195
1210
|
const file = await readTextFile(relPath, cwd);
|
|
1196
|
-
if (file.data.includes(
|
|
1197
|
-
const sanitizedVersion =
|
|
1211
|
+
if (file.data.includes(currentVersion)) {
|
|
1212
|
+
const sanitizedVersion = currentVersion.replace(/(\W)/g, "\\$1");
|
|
1198
1213
|
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
|
|
1199
1214
|
file.data = file.data.replace(replacePattern, `$1${newVersion}`);
|
|
1200
1215
|
await writeTextFile(file);
|
|
@@ -1208,7 +1223,7 @@ async function versionBump(arg = {}) {
|
|
|
1208
1223
|
if (typeof arg === "string")
|
|
1209
1224
|
arg = { release: arg };
|
|
1210
1225
|
const operation = await Operation.start(arg);
|
|
1211
|
-
await
|
|
1226
|
+
await getCurrentVersion(operation);
|
|
1212
1227
|
await getNewVersion(operation);
|
|
1213
1228
|
if (arg.confirm) {
|
|
1214
1229
|
printSummary(operation);
|
|
@@ -1246,7 +1261,7 @@ function printSummary(operation) {
|
|
|
1246
1261
|
if (operation.options.push)
|
|
1247
1262
|
console.log(` push ${import_picocolors2.default.cyan(import_picocolors2.default.bold("yes"))}`);
|
|
1248
1263
|
console.log();
|
|
1249
|
-
console.log(` from ${import_picocolors2.default.bold(operation.state.
|
|
1264
|
+
console.log(` from ${import_picocolors2.default.bold(operation.state.currentVersion)}`);
|
|
1250
1265
|
console.log(` to ${import_picocolors2.default.green(import_picocolors2.default.bold(operation.state.newVersion))}`);
|
|
1251
1266
|
console.log();
|
|
1252
1267
|
}
|
|
@@ -1262,7 +1277,9 @@ var import_js_yaml = __toESM(require("js-yaml"));
|
|
|
1262
1277
|
|
|
1263
1278
|
// src/config.ts
|
|
1264
1279
|
var import_node_process6 = __toESM(require("process"));
|
|
1280
|
+
var import_node_path2 = require("path");
|
|
1265
1281
|
var import_c12 = require("c12");
|
|
1282
|
+
var import_sync = __toESM(require("escalade/sync"));
|
|
1266
1283
|
var bumpConfigDefaults = {
|
|
1267
1284
|
commit: true,
|
|
1268
1285
|
push: true,
|
|
@@ -1275,37 +1292,62 @@ var bumpConfigDefaults = {
|
|
|
1275
1292
|
files: []
|
|
1276
1293
|
};
|
|
1277
1294
|
async function loadBumpConfig(overrides, cwd = import_node_process6.default.cwd()) {
|
|
1295
|
+
const name = "bump";
|
|
1296
|
+
const configFile = findConfigFile(name, cwd);
|
|
1278
1297
|
const { config } = await (0, import_c12.loadConfig)({
|
|
1279
|
-
name
|
|
1298
|
+
name,
|
|
1280
1299
|
defaults: bumpConfigDefaults,
|
|
1281
1300
|
overrides: __spreadValues({}, overrides),
|
|
1282
|
-
cwd
|
|
1301
|
+
cwd: configFile ? (0, import_node_path2.dirname)(configFile) : cwd
|
|
1283
1302
|
});
|
|
1284
1303
|
return config;
|
|
1285
1304
|
}
|
|
1305
|
+
function findConfigFile(name, cwd) {
|
|
1306
|
+
let foundRepositoryRoot = false;
|
|
1307
|
+
try {
|
|
1308
|
+
const candidates = ["js", "mjs", "ts", "mts", "json"].map((ext) => `${name}.config.${ext}`);
|
|
1309
|
+
return (0, import_sync.default)(cwd, (_dir, files) => {
|
|
1310
|
+
const match = files.find((file) => {
|
|
1311
|
+
if (candidates.includes(file))
|
|
1312
|
+
return true;
|
|
1313
|
+
if (file === ".git")
|
|
1314
|
+
foundRepositoryRoot = true;
|
|
1315
|
+
return false;
|
|
1316
|
+
});
|
|
1317
|
+
if (match)
|
|
1318
|
+
return match;
|
|
1319
|
+
if (foundRepositoryRoot) {
|
|
1320
|
+
throw null;
|
|
1321
|
+
}
|
|
1322
|
+
return false;
|
|
1323
|
+
});
|
|
1324
|
+
} catch (error) {
|
|
1325
|
+
if (foundRepositoryRoot)
|
|
1326
|
+
return null;
|
|
1327
|
+
throw error;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1286
1330
|
|
|
1287
1331
|
// src/cli/parse-args.ts
|
|
1288
1332
|
async function parseArgs() {
|
|
1289
1333
|
var _a;
|
|
1290
1334
|
try {
|
|
1291
|
-
const
|
|
1292
|
-
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: ${bumpConfigDefaults.commit})`).option("--no-commit", "Skip commit").option("-t, --tag [tag]", `Tag name (default: ${bumpConfigDefaults.tag})`).option("--no-tag", "Skip 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("-x, --execute <command>", "Commands to execute after version bumps").help();
|
|
1293
|
-
const result = cli.parse();
|
|
1294
|
-
const args = result.options;
|
|
1335
|
+
const { args, resultArgs } = loadCliArgs();
|
|
1295
1336
|
const parsedArgs = {
|
|
1296
1337
|
help: args.help,
|
|
1297
1338
|
version: args.version,
|
|
1298
1339
|
quiet: args.quiet,
|
|
1299
1340
|
options: await loadBumpConfig({
|
|
1300
1341
|
preid: args.preid,
|
|
1301
|
-
commit:
|
|
1302
|
-
tag:
|
|
1342
|
+
commit: args.commit,
|
|
1343
|
+
tag: args.tag,
|
|
1303
1344
|
push: args.push,
|
|
1304
1345
|
all: args.all,
|
|
1305
1346
|
confirm: !args.yes,
|
|
1306
1347
|
noVerify: !args.verify,
|
|
1307
|
-
files: [...args["--"] || [], ...
|
|
1348
|
+
files: [...args["--"] || [], ...resultArgs],
|
|
1308
1349
|
ignoreScripts: args.ignoreScripts,
|
|
1350
|
+
currentVersion: args.currentVersion,
|
|
1309
1351
|
execute: args.execute,
|
|
1310
1352
|
recursive: !!args.recursive
|
|
1311
1353
|
})
|
|
@@ -1321,7 +1363,13 @@ async function parseArgs() {
|
|
|
1321
1363
|
if ((_a = parsedArgs.options.files) == null ? void 0 : _a.length) {
|
|
1322
1364
|
console.log(import_picocolors3.default.yellow("The --recursive option is ignored when files are specified"));
|
|
1323
1365
|
} else {
|
|
1324
|
-
parsedArgs.options.files = [
|
|
1366
|
+
parsedArgs.options.files = [
|
|
1367
|
+
"package.json",
|
|
1368
|
+
"package-lock.json",
|
|
1369
|
+
"packages/**/package.json",
|
|
1370
|
+
"jsr.json",
|
|
1371
|
+
"jsr.jsonc"
|
|
1372
|
+
];
|
|
1325
1373
|
if (import_node_fs2.default.existsSync("pnpm-workspace.yaml")) {
|
|
1326
1374
|
const pnpmWorkspace = await import_promises.default.readFile("pnpm-workspace.yaml", "utf8");
|
|
1327
1375
|
const workspaces = import_js_yaml.default.load(pnpmWorkspace);
|
|
@@ -1339,6 +1387,23 @@ async function parseArgs() {
|
|
|
1339
1387
|
return errorHandler(error);
|
|
1340
1388
|
}
|
|
1341
1389
|
}
|
|
1390
|
+
function loadCliArgs(argv = import_node_process7.default.argv) {
|
|
1391
|
+
const cli = (0, import_cac.default)("bumpp");
|
|
1392
|
+
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("-x, --execute <command>", "Commands to execute after version bumps").help();
|
|
1393
|
+
const result = cli.parse(argv);
|
|
1394
|
+
const rawArgs = cli.rawArgs;
|
|
1395
|
+
const args = result.options;
|
|
1396
|
+
const hasCommitFlag = rawArgs.some((arg) => ["-c", "--commit", "--no-commit"].includes(arg));
|
|
1397
|
+
const hasTagFlag = rawArgs.some((arg) => ["-t", "--tag", "--no-tag"].includes(arg));
|
|
1398
|
+
const _a = args, { tag, commit } = _a, rest = __objRest(_a, ["tag", "commit"]);
|
|
1399
|
+
return {
|
|
1400
|
+
args: __spreadProps(__spreadValues({}, rest), {
|
|
1401
|
+
commit: hasCommitFlag ? commit : void 0,
|
|
1402
|
+
tag: hasTagFlag ? tag : void 0
|
|
1403
|
+
}),
|
|
1404
|
+
resultArgs: result.args
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1342
1407
|
function errorHandler(error) {
|
|
1343
1408
|
console.error(error.message);
|
|
1344
1409
|
return import_node_process7.default.exit(9 /* InvalidArgument */);
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues,
|
|
3
6
|
__toESM,
|
|
4
7
|
bumpConfigDefaults,
|
|
5
8
|
isReleaseType,
|
|
@@ -7,13 +10,13 @@ import {
|
|
|
7
10
|
log_symbols_default,
|
|
8
11
|
require_picocolors,
|
|
9
12
|
versionBump
|
|
10
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-OMAU23UL.mjs";
|
|
11
14
|
|
|
12
15
|
// src/cli/index.ts
|
|
13
16
|
import process2 from "process";
|
|
14
17
|
|
|
15
18
|
// package.json
|
|
16
|
-
var version = "9.
|
|
19
|
+
var version = "9.4.0";
|
|
17
20
|
|
|
18
21
|
// src/cli/parse-args.ts
|
|
19
22
|
var import_picocolors = __toESM(require_picocolors());
|
|
@@ -26,24 +29,22 @@ import yaml from "js-yaml";
|
|
|
26
29
|
async function parseArgs() {
|
|
27
30
|
var _a;
|
|
28
31
|
try {
|
|
29
|
-
const
|
|
30
|
-
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: ${bumpConfigDefaults.commit})`).option("--no-commit", "Skip commit").option("-t, --tag [tag]", `Tag name (default: ${bumpConfigDefaults.tag})`).option("--no-tag", "Skip 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("-x, --execute <command>", "Commands to execute after version bumps").help();
|
|
31
|
-
const result = cli.parse();
|
|
32
|
-
const args = result.options;
|
|
32
|
+
const { args, resultArgs } = loadCliArgs();
|
|
33
33
|
const parsedArgs = {
|
|
34
34
|
help: args.help,
|
|
35
35
|
version: args.version,
|
|
36
36
|
quiet: args.quiet,
|
|
37
37
|
options: await loadBumpConfig({
|
|
38
38
|
preid: args.preid,
|
|
39
|
-
commit:
|
|
40
|
-
tag:
|
|
39
|
+
commit: args.commit,
|
|
40
|
+
tag: args.tag,
|
|
41
41
|
push: args.push,
|
|
42
42
|
all: args.all,
|
|
43
43
|
confirm: !args.yes,
|
|
44
44
|
noVerify: !args.verify,
|
|
45
|
-
files: [...args["--"] || [], ...
|
|
45
|
+
files: [...args["--"] || [], ...resultArgs],
|
|
46
46
|
ignoreScripts: args.ignoreScripts,
|
|
47
|
+
currentVersion: args.currentVersion,
|
|
47
48
|
execute: args.execute,
|
|
48
49
|
recursive: !!args.recursive
|
|
49
50
|
})
|
|
@@ -59,7 +60,13 @@ async function parseArgs() {
|
|
|
59
60
|
if ((_a = parsedArgs.options.files) == null ? void 0 : _a.length) {
|
|
60
61
|
console.log(import_picocolors.default.yellow("The --recursive option is ignored when files are specified"));
|
|
61
62
|
} else {
|
|
62
|
-
parsedArgs.options.files = [
|
|
63
|
+
parsedArgs.options.files = [
|
|
64
|
+
"package.json",
|
|
65
|
+
"package-lock.json",
|
|
66
|
+
"packages/**/package.json",
|
|
67
|
+
"jsr.json",
|
|
68
|
+
"jsr.jsonc"
|
|
69
|
+
];
|
|
63
70
|
if (fsSync.existsSync("pnpm-workspace.yaml")) {
|
|
64
71
|
const pnpmWorkspace = await fs.readFile("pnpm-workspace.yaml", "utf8");
|
|
65
72
|
const workspaces = yaml.load(pnpmWorkspace);
|
|
@@ -77,6 +84,23 @@ async function parseArgs() {
|
|
|
77
84
|
return errorHandler(error);
|
|
78
85
|
}
|
|
79
86
|
}
|
|
87
|
+
function loadCliArgs(argv = process.argv) {
|
|
88
|
+
const cli = cac("bumpp");
|
|
89
|
+
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("-x, --execute <command>", "Commands to execute after version bumps").help();
|
|
90
|
+
const result = cli.parse(argv);
|
|
91
|
+
const rawArgs = cli.rawArgs;
|
|
92
|
+
const args = result.options;
|
|
93
|
+
const hasCommitFlag = rawArgs.some((arg) => ["-c", "--commit", "--no-commit"].includes(arg));
|
|
94
|
+
const hasTagFlag = rawArgs.some((arg) => ["-t", "--tag", "--no-tag"].includes(arg));
|
|
95
|
+
const _a = args, { tag, commit } = _a, rest = __objRest(_a, ["tag", "commit"]);
|
|
96
|
+
return {
|
|
97
|
+
args: __spreadProps(__spreadValues({}, rest), {
|
|
98
|
+
commit: hasCommitFlag ? commit : void 0,
|
|
99
|
+
tag: hasTagFlag ? tag : void 0
|
|
100
|
+
}),
|
|
101
|
+
resultArgs: result.args
|
|
102
|
+
};
|
|
103
|
+
}
|
|
80
104
|
function errorHandler(error) {
|
|
81
105
|
console.error(error.message);
|
|
82
106
|
return process.exit(9 /* InvalidArgument */);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import _semver, { ReleaseType } from 'semver';
|
|
2
|
-
|
|
1
|
+
import _semver, { ReleaseType as ReleaseType$1 } from 'semver';
|
|
2
|
+
|
|
3
|
+
type ReleaseType = ReleaseType$1 | 'next';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Information about the work that was performed by the `versionBump()` function.
|
|
@@ -12,7 +13,7 @@ interface VersionBumpResults {
|
|
|
12
13
|
/**
|
|
13
14
|
* The previous version number in package.json.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
currentVersion: string;
|
|
16
17
|
/**
|
|
17
18
|
* The new version number.
|
|
18
19
|
*/
|
|
@@ -82,6 +83,11 @@ interface VersionBumpOptions {
|
|
|
82
83
|
* Defaults to "prompt".
|
|
83
84
|
*/
|
|
84
85
|
release?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The current version number to be bumpped.
|
|
88
|
+
* If not provide, it will be read from the first file in the `files` array.
|
|
89
|
+
*/
|
|
90
|
+
currentVersion?: string;
|
|
85
91
|
/**
|
|
86
92
|
* The prerelease type (e.g. "alpha", "beta", "next").
|
|
87
93
|
*
|
|
@@ -137,7 +143,7 @@ interface VersionBumpOptions {
|
|
|
137
143
|
* (ReadMe files, config files, source code, etc.) it will simply do a global replacement
|
|
138
144
|
* of the old version number with the new version number.
|
|
139
145
|
*
|
|
140
|
-
* Defaults to ["package.json", "package-lock.json"]
|
|
146
|
+
* Defaults to ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc"]
|
|
141
147
|
*/
|
|
142
148
|
files?: string[];
|
|
143
149
|
/**
|
|
@@ -165,7 +171,7 @@ interface VersionBumpOptions {
|
|
|
165
171
|
/**
|
|
166
172
|
* A callback that is provides information about the progress of the `versionBump()` function.
|
|
167
173
|
*/
|
|
168
|
-
progress
|
|
174
|
+
progress?: (progress: VersionBumpProgress) => void;
|
|
169
175
|
/**
|
|
170
176
|
* Excute additional command after bumping and before commiting
|
|
171
177
|
*/
|
|
@@ -263,12 +269,13 @@ interface NormalizedOptions {
|
|
|
263
269
|
ignoreScripts: boolean;
|
|
264
270
|
execute?: string;
|
|
265
271
|
customVersion?: VersionBumpOptions['customVersion'];
|
|
272
|
+
currentVersion?: string;
|
|
266
273
|
}
|
|
267
274
|
|
|
268
275
|
interface OperationState {
|
|
269
276
|
release: ReleaseType | undefined;
|
|
270
|
-
|
|
271
|
-
|
|
277
|
+
currentVersionSource: string;
|
|
278
|
+
currentVersion: string;
|
|
272
279
|
newVersion: string;
|
|
273
280
|
commitMessage: string;
|
|
274
281
|
tagName: string;
|
|
@@ -344,4 +351,4 @@ declare const bumpConfigDefaults: VersionBumpOptions;
|
|
|
344
351
|
declare function loadBumpConfig(overrides?: Partial<VersionBumpOptions>, cwd?: string): Promise<VersionBumpOptions>;
|
|
345
352
|
declare function defineConfig(config: Partial<VersionBumpOptions>): Partial<VersionBumpOptions>;
|
|
346
353
|
|
|
347
|
-
export { type InterfaceOptions, NpmScript, ProgressEvent, type VersionBumpOptions, type VersionBumpProgress, type VersionBumpResults, bumpConfigDefaults, versionBump as default, defineConfig, loadBumpConfig, versionBump, versionBumpInfo };
|
|
354
|
+
export { type InterfaceOptions, NpmScript, ProgressEvent, type ReleaseType, type VersionBumpOptions, type VersionBumpProgress, type VersionBumpResults, bumpConfigDefaults, versionBump as default, defineConfig, loadBumpConfig, versionBump, versionBumpInfo };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import _semver, { ReleaseType } from 'semver';
|
|
2
|
-
|
|
1
|
+
import _semver, { ReleaseType as ReleaseType$1 } from 'semver';
|
|
2
|
+
|
|
3
|
+
type ReleaseType = ReleaseType$1 | 'next';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Information about the work that was performed by the `versionBump()` function.
|
|
@@ -12,7 +13,7 @@ interface VersionBumpResults {
|
|
|
12
13
|
/**
|
|
13
14
|
* The previous version number in package.json.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
currentVersion: string;
|
|
16
17
|
/**
|
|
17
18
|
* The new version number.
|
|
18
19
|
*/
|
|
@@ -82,6 +83,11 @@ interface VersionBumpOptions {
|
|
|
82
83
|
* Defaults to "prompt".
|
|
83
84
|
*/
|
|
84
85
|
release?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The current version number to be bumpped.
|
|
88
|
+
* If not provide, it will be read from the first file in the `files` array.
|
|
89
|
+
*/
|
|
90
|
+
currentVersion?: string;
|
|
85
91
|
/**
|
|
86
92
|
* The prerelease type (e.g. "alpha", "beta", "next").
|
|
87
93
|
*
|
|
@@ -137,7 +143,7 @@ interface VersionBumpOptions {
|
|
|
137
143
|
* (ReadMe files, config files, source code, etc.) it will simply do a global replacement
|
|
138
144
|
* of the old version number with the new version number.
|
|
139
145
|
*
|
|
140
|
-
* Defaults to ["package.json", "package-lock.json"]
|
|
146
|
+
* Defaults to ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc"]
|
|
141
147
|
*/
|
|
142
148
|
files?: string[];
|
|
143
149
|
/**
|
|
@@ -165,7 +171,7 @@ interface VersionBumpOptions {
|
|
|
165
171
|
/**
|
|
166
172
|
* A callback that is provides information about the progress of the `versionBump()` function.
|
|
167
173
|
*/
|
|
168
|
-
progress
|
|
174
|
+
progress?: (progress: VersionBumpProgress) => void;
|
|
169
175
|
/**
|
|
170
176
|
* Excute additional command after bumping and before commiting
|
|
171
177
|
*/
|
|
@@ -263,12 +269,13 @@ interface NormalizedOptions {
|
|
|
263
269
|
ignoreScripts: boolean;
|
|
264
270
|
execute?: string;
|
|
265
271
|
customVersion?: VersionBumpOptions['customVersion'];
|
|
272
|
+
currentVersion?: string;
|
|
266
273
|
}
|
|
267
274
|
|
|
268
275
|
interface OperationState {
|
|
269
276
|
release: ReleaseType | undefined;
|
|
270
|
-
|
|
271
|
-
|
|
277
|
+
currentVersionSource: string;
|
|
278
|
+
currentVersion: string;
|
|
272
279
|
newVersion: string;
|
|
273
280
|
commitMessage: string;
|
|
274
281
|
tagName: string;
|
|
@@ -344,4 +351,4 @@ declare const bumpConfigDefaults: VersionBumpOptions;
|
|
|
344
351
|
declare function loadBumpConfig(overrides?: Partial<VersionBumpOptions>, cwd?: string): Promise<VersionBumpOptions>;
|
|
345
352
|
declare function defineConfig(config: Partial<VersionBumpOptions>): Partial<VersionBumpOptions>;
|
|
346
353
|
|
|
347
|
-
export { type InterfaceOptions, NpmScript, ProgressEvent, type VersionBumpOptions, type VersionBumpProgress, type VersionBumpResults, bumpConfigDefaults, versionBump as default, defineConfig, loadBumpConfig, versionBump, versionBumpInfo };
|
|
354
|
+
export { type InterfaceOptions, NpmScript, ProgressEvent, type ReleaseType, type VersionBumpOptions, type VersionBumpProgress, type VersionBumpResults, bumpConfigDefaults, versionBump as default, defineConfig, loadBumpConfig, versionBump, versionBumpInfo };
|
package/dist/index.js
CHANGED
|
@@ -60,7 +60,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
60
60
|
|
|
61
61
|
// node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js
|
|
62
62
|
var require_picocolors = __commonJS({
|
|
63
|
-
"node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(
|
|
63
|
+
"node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
64
64
|
var tty2 = require("tty");
|
|
65
65
|
var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env);
|
|
66
66
|
var formatter = (open, close, replace = open) => (input) => {
|
|
@@ -649,7 +649,7 @@ var import_semver = __toESM(require("semver"));
|
|
|
649
649
|
|
|
650
650
|
// src/release-type.ts
|
|
651
651
|
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
652
|
-
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
|
|
652
|
+
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]);
|
|
653
653
|
function isPrerelease(value) {
|
|
654
654
|
return prereleaseTypes.includes(value);
|
|
655
655
|
}
|
|
@@ -660,7 +660,7 @@ function isReleaseType(value) {
|
|
|
660
660
|
// src/get-new-version.ts
|
|
661
661
|
async function getNewVersion(operation) {
|
|
662
662
|
const { release } = operation.options;
|
|
663
|
-
const {
|
|
663
|
+
const { currentVersion } = operation.state;
|
|
664
664
|
switch (release.type) {
|
|
665
665
|
case "prompt":
|
|
666
666
|
return promptForNewVersion(operation);
|
|
@@ -671,42 +671,41 @@ async function getNewVersion(operation) {
|
|
|
671
671
|
default:
|
|
672
672
|
return operation.update({
|
|
673
673
|
release: release.type,
|
|
674
|
-
newVersion: getNextVersion(
|
|
674
|
+
newVersion: getNextVersion(currentVersion, release)
|
|
675
675
|
});
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
|
-
function getNextVersion(
|
|
679
|
-
const oldSemVer = new import_semver.SemVer(
|
|
680
|
-
const
|
|
678
|
+
function getNextVersion(currentVersion, bump) {
|
|
679
|
+
const oldSemVer = new import_semver.SemVer(currentVersion);
|
|
680
|
+
const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type;
|
|
681
|
+
const newSemVer = oldSemVer.inc(type, bump.preid);
|
|
681
682
|
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
|
|
682
683
|
newSemVer.prerelease[1] = "1";
|
|
683
684
|
newSemVer.format();
|
|
684
685
|
}
|
|
685
686
|
return newSemVer.version;
|
|
686
687
|
}
|
|
687
|
-
function getNextVersions(
|
|
688
|
-
var _a;
|
|
688
|
+
function getNextVersions(currentVersion, preid) {
|
|
689
689
|
const next = {};
|
|
690
|
-
const parse = import_semver.default.parse(
|
|
690
|
+
const parse = import_semver.default.parse(currentVersion);
|
|
691
691
|
if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
|
|
692
692
|
preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
|
|
693
693
|
for (const type of releaseTypes)
|
|
694
|
-
next[type] =
|
|
695
|
-
next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? import_semver.default.inc(oldVersion, "prerelease", preid) : import_semver.default.inc(oldVersion, "patch");
|
|
694
|
+
next[type] = getNextVersion(currentVersion, { type, preid });
|
|
696
695
|
return next;
|
|
697
696
|
}
|
|
698
697
|
async function promptForNewVersion(operation) {
|
|
699
698
|
var _a, _b;
|
|
700
|
-
const {
|
|
699
|
+
const { currentVersion } = operation.state;
|
|
701
700
|
const release = operation.options.release;
|
|
702
|
-
const next = getNextVersions(
|
|
703
|
-
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a,
|
|
701
|
+
const next = getNextVersions(currentVersion, release.preid);
|
|
702
|
+
const configCustomVersion = await ((_b = (_a = operation.options).customVersion) == null ? void 0 : _b.call(_a, currentVersion, import_semver.default));
|
|
704
703
|
const PADDING = 13;
|
|
705
704
|
const answers = await (0, import_prompts.default)([
|
|
706
705
|
{
|
|
707
706
|
type: "autocomplete",
|
|
708
707
|
name: "release",
|
|
709
|
-
message: `Current version ${import_picocolors.default.green(
|
|
708
|
+
message: `Current version ${import_picocolors.default.green(currentVersion)}`,
|
|
710
709
|
initial: configCustomVersion ? "config" : "next",
|
|
711
710
|
choices: [
|
|
712
711
|
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.major)}` },
|
|
@@ -719,7 +718,7 @@ async function promptForNewVersion(operation) {
|
|
|
719
718
|
{ value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.prepatch)}` },
|
|
720
719
|
{ value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.preminor)}` },
|
|
721
720
|
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors.default.bold(next.premajor)}` },
|
|
722
|
-
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(
|
|
721
|
+
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors.default.bold(currentVersion)}` },
|
|
723
722
|
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
|
|
724
723
|
]
|
|
725
724
|
},
|
|
@@ -727,13 +726,13 @@ async function promptForNewVersion(operation) {
|
|
|
727
726
|
type: (prev) => prev === "custom" ? "text" : null,
|
|
728
727
|
name: "custom",
|
|
729
728
|
message: "Enter the new version number:",
|
|
730
|
-
initial:
|
|
729
|
+
initial: currentVersion,
|
|
731
730
|
validate: (custom) => {
|
|
732
731
|
return (0, import_semver.valid)(custom) ? true : "That's not a valid version number";
|
|
733
732
|
}
|
|
734
733
|
}
|
|
735
734
|
]);
|
|
736
|
-
const newVersion = answers.release === "none" ?
|
|
735
|
+
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? (0, import_semver.clean)(answers.custom) : answers.release === "config" ? (0, import_semver.clean)(configCustomVersion) : next[answers.release];
|
|
737
736
|
if (!newVersion)
|
|
738
737
|
import_node_process3.default.exit(1);
|
|
739
738
|
switch (answers.release) {
|
|
@@ -747,7 +746,7 @@ async function promptForNewVersion(operation) {
|
|
|
747
746
|
}
|
|
748
747
|
}
|
|
749
748
|
|
|
750
|
-
// src/get-
|
|
749
|
+
// src/get-current-version.ts
|
|
751
750
|
var import_semver2 = require("semver");
|
|
752
751
|
|
|
753
752
|
// src/fs.ts
|
|
@@ -912,13 +911,19 @@ function writeTextFile(file) {
|
|
|
912
911
|
function isManifest(obj) {
|
|
913
912
|
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
914
913
|
}
|
|
914
|
+
function isPackageLockManifest(manifest) {
|
|
915
|
+
var _a, _b;
|
|
916
|
+
return typeof ((_b = (_a = manifest.packages) == null ? void 0 : _a[""]) == null ? void 0 : _b.version) === "string";
|
|
917
|
+
}
|
|
915
918
|
function isOptionalString(value) {
|
|
916
919
|
const type = typeof value;
|
|
917
920
|
return value === null || type === "undefined" || type === "string";
|
|
918
921
|
}
|
|
919
922
|
|
|
920
|
-
// src/get-
|
|
921
|
-
async function
|
|
923
|
+
// src/get-current-version.ts
|
|
924
|
+
async function getCurrentVersion(operation) {
|
|
925
|
+
if (operation.state.currentVersion)
|
|
926
|
+
return operation;
|
|
922
927
|
const { cwd, files } = operation.options;
|
|
923
928
|
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
924
929
|
if (!filesToCheck.includes("package.json"))
|
|
@@ -927,8 +932,8 @@ async function getOldVersion(operation) {
|
|
|
927
932
|
const version = await readVersion(file, cwd);
|
|
928
933
|
if (version) {
|
|
929
934
|
return operation.update({
|
|
930
|
-
|
|
931
|
-
|
|
935
|
+
currentVersionSource: file,
|
|
936
|
+
currentVersion: version
|
|
932
937
|
});
|
|
933
938
|
}
|
|
934
939
|
}
|
|
@@ -1037,7 +1042,7 @@ async function normalizeOptions(raw) {
|
|
|
1037
1042
|
let release;
|
|
1038
1043
|
if (!raw.release || raw.release === "prompt")
|
|
1039
1044
|
release = { type: "prompt", preid };
|
|
1040
|
-
else if (isReleaseType(raw.release))
|
|
1045
|
+
else if (isReleaseType(raw.release) || raw.release === "next")
|
|
1041
1046
|
release = { type: raw.release, preid };
|
|
1042
1047
|
else
|
|
1043
1048
|
release = { type: "version", version: raw.release };
|
|
@@ -1052,7 +1057,7 @@ async function normalizeOptions(raw) {
|
|
|
1052
1057
|
else if (raw.commit || tag || push)
|
|
1053
1058
|
commit = { all, noVerify, message: "chore: release v" };
|
|
1054
1059
|
const files = await (0, import_fast_glob.default)(
|
|
1055
|
-
((_a = raw.files) == null ? void 0 : _a.length) ? raw.files : ["package.json", "package-lock.json"],
|
|
1060
|
+
((_a = raw.files) == null ? void 0 : _a.length) ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc"],
|
|
1056
1061
|
{
|
|
1057
1062
|
cwd,
|
|
1058
1063
|
onlyFiles: true,
|
|
@@ -1086,7 +1091,8 @@ async function normalizeOptions(raw) {
|
|
|
1086
1091
|
interface: ui,
|
|
1087
1092
|
ignoreScripts,
|
|
1088
1093
|
execute,
|
|
1089
|
-
customVersion: raw.customVersion
|
|
1094
|
+
customVersion: raw.customVersion,
|
|
1095
|
+
currentVersion: raw.currentVersion
|
|
1090
1096
|
};
|
|
1091
1097
|
}
|
|
1092
1098
|
|
|
@@ -1101,8 +1107,8 @@ var Operation = class _Operation {
|
|
|
1101
1107
|
*/
|
|
1102
1108
|
this.state = {
|
|
1103
1109
|
release: void 0,
|
|
1104
|
-
|
|
1105
|
-
|
|
1110
|
+
currentVersion: "",
|
|
1111
|
+
currentVersionSource: "",
|
|
1106
1112
|
newVersion: "",
|
|
1107
1113
|
commitMessage: "",
|
|
1108
1114
|
tagName: "",
|
|
@@ -1111,6 +1117,12 @@ var Operation = class _Operation {
|
|
|
1111
1117
|
};
|
|
1112
1118
|
this.options = options;
|
|
1113
1119
|
this._progress = progress;
|
|
1120
|
+
if (options.currentVersion) {
|
|
1121
|
+
this.update({
|
|
1122
|
+
currentVersion: options.currentVersion,
|
|
1123
|
+
currentVersionSource: "user"
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1114
1126
|
}
|
|
1115
1127
|
/**
|
|
1116
1128
|
* The results of the operation.
|
|
@@ -1120,7 +1132,7 @@ var Operation = class _Operation {
|
|
|
1120
1132
|
const state = this.state;
|
|
1121
1133
|
return {
|
|
1122
1134
|
release: state.release,
|
|
1123
|
-
|
|
1135
|
+
currentVersion: state.currentVersion,
|
|
1124
1136
|
newVersion: state.newVersion,
|
|
1125
1137
|
commit: options.commit ? state.commitMessage : false,
|
|
1126
1138
|
tag: options.tag ? state.tagName : false,
|
|
@@ -1195,6 +1207,7 @@ async function updateFile(relPath, operation) {
|
|
|
1195
1207
|
case "package-lock.json":
|
|
1196
1208
|
case "bower.json":
|
|
1197
1209
|
case "component.json":
|
|
1210
|
+
case "jsr.json":
|
|
1198
1211
|
return updateManifestFile(relPath, operation);
|
|
1199
1212
|
default:
|
|
1200
1213
|
return updateTextFile(relPath, operation);
|
|
@@ -1207,6 +1220,8 @@ async function updateManifestFile(relPath, operation) {
|
|
|
1207
1220
|
const file = await readJsonFile(relPath, cwd);
|
|
1208
1221
|
if (isManifest(file.data) && file.data.version !== newVersion) {
|
|
1209
1222
|
file.data.version = newVersion;
|
|
1223
|
+
if (isPackageLockManifest(file.data))
|
|
1224
|
+
file.data.packages[""].version = newVersion;
|
|
1210
1225
|
await writeJsonFile(file);
|
|
1211
1226
|
modified = true;
|
|
1212
1227
|
}
|
|
@@ -1214,11 +1229,11 @@ async function updateManifestFile(relPath, operation) {
|
|
|
1214
1229
|
}
|
|
1215
1230
|
async function updateTextFile(relPath, operation) {
|
|
1216
1231
|
const { cwd } = operation.options;
|
|
1217
|
-
const {
|
|
1232
|
+
const { currentVersion, newVersion } = operation.state;
|
|
1218
1233
|
const modified = false;
|
|
1219
1234
|
const file = await readTextFile(relPath, cwd);
|
|
1220
|
-
if (file.data.includes(
|
|
1221
|
-
const sanitizedVersion =
|
|
1235
|
+
if (file.data.includes(currentVersion)) {
|
|
1236
|
+
const sanitizedVersion = currentVersion.replace(/(\W)/g, "\\$1");
|
|
1222
1237
|
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
|
|
1223
1238
|
file.data = file.data.replace(replacePattern, `$1${newVersion}`);
|
|
1224
1239
|
await writeTextFile(file);
|
|
@@ -1232,7 +1247,7 @@ async function versionBump(arg = {}) {
|
|
|
1232
1247
|
if (typeof arg === "string")
|
|
1233
1248
|
arg = { release: arg };
|
|
1234
1249
|
const operation = await Operation.start(arg);
|
|
1235
|
-
await
|
|
1250
|
+
await getCurrentVersion(operation);
|
|
1236
1251
|
await getNewVersion(operation);
|
|
1237
1252
|
if (arg.confirm) {
|
|
1238
1253
|
printSummary(operation);
|
|
@@ -1270,7 +1285,7 @@ function printSummary(operation) {
|
|
|
1270
1285
|
if (operation.options.push)
|
|
1271
1286
|
console.log(` push ${import_picocolors2.default.cyan(import_picocolors2.default.bold("yes"))}`);
|
|
1272
1287
|
console.log();
|
|
1273
|
-
console.log(` from ${import_picocolors2.default.bold(operation.state.
|
|
1288
|
+
console.log(` from ${import_picocolors2.default.bold(operation.state.currentVersion)}`);
|
|
1274
1289
|
console.log(` to ${import_picocolors2.default.green(import_picocolors2.default.bold(operation.state.newVersion))}`);
|
|
1275
1290
|
console.log();
|
|
1276
1291
|
}
|
|
@@ -1278,14 +1293,16 @@ async function versionBumpInfo(arg = {}) {
|
|
|
1278
1293
|
if (typeof arg === "string")
|
|
1279
1294
|
arg = { release: arg };
|
|
1280
1295
|
const operation = await Operation.start(arg);
|
|
1281
|
-
await
|
|
1296
|
+
await getCurrentVersion(operation);
|
|
1282
1297
|
await getNewVersion(operation);
|
|
1283
1298
|
return operation;
|
|
1284
1299
|
}
|
|
1285
1300
|
|
|
1286
1301
|
// src/config.ts
|
|
1287
1302
|
var import_node_process6 = __toESM(require("process"));
|
|
1303
|
+
var import_node_path2 = require("path");
|
|
1288
1304
|
var import_c12 = require("c12");
|
|
1305
|
+
var import_sync = __toESM(require("escalade/sync"));
|
|
1289
1306
|
var bumpConfigDefaults = {
|
|
1290
1307
|
commit: true,
|
|
1291
1308
|
push: true,
|
|
@@ -1298,14 +1315,41 @@ var bumpConfigDefaults = {
|
|
|
1298
1315
|
files: []
|
|
1299
1316
|
};
|
|
1300
1317
|
async function loadBumpConfig(overrides, cwd = import_node_process6.default.cwd()) {
|
|
1318
|
+
const name = "bump";
|
|
1319
|
+
const configFile = findConfigFile(name, cwd);
|
|
1301
1320
|
const { config } = await (0, import_c12.loadConfig)({
|
|
1302
|
-
name
|
|
1321
|
+
name,
|
|
1303
1322
|
defaults: bumpConfigDefaults,
|
|
1304
1323
|
overrides: __spreadValues({}, overrides),
|
|
1305
|
-
cwd
|
|
1324
|
+
cwd: configFile ? (0, import_node_path2.dirname)(configFile) : cwd
|
|
1306
1325
|
});
|
|
1307
1326
|
return config;
|
|
1308
1327
|
}
|
|
1328
|
+
function findConfigFile(name, cwd) {
|
|
1329
|
+
let foundRepositoryRoot = false;
|
|
1330
|
+
try {
|
|
1331
|
+
const candidates = ["js", "mjs", "ts", "mts", "json"].map((ext) => `${name}.config.${ext}`);
|
|
1332
|
+
return (0, import_sync.default)(cwd, (_dir, files) => {
|
|
1333
|
+
const match = files.find((file) => {
|
|
1334
|
+
if (candidates.includes(file))
|
|
1335
|
+
return true;
|
|
1336
|
+
if (file === ".git")
|
|
1337
|
+
foundRepositoryRoot = true;
|
|
1338
|
+
return false;
|
|
1339
|
+
});
|
|
1340
|
+
if (match)
|
|
1341
|
+
return match;
|
|
1342
|
+
if (foundRepositoryRoot) {
|
|
1343
|
+
throw null;
|
|
1344
|
+
}
|
|
1345
|
+
return false;
|
|
1346
|
+
});
|
|
1347
|
+
} catch (error) {
|
|
1348
|
+
if (foundRepositoryRoot)
|
|
1349
|
+
return null;
|
|
1350
|
+
throw error;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1309
1353
|
function defineConfig(config) {
|
|
1310
1354
|
return config;
|
|
1311
1355
|
}
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bumpp",
|
|
3
|
-
"version": "9.
|
|
4
|
-
"packageManager": "pnpm@8.
|
|
3
|
+
"version": "9.4.0",
|
|
4
|
+
"packageManager": "pnpm@8.15.4",
|
|
5
5
|
"description": "Bump version, commit changes, tag, and push to Git",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "James Messinger",
|
|
@@ -51,35 +51,39 @@
|
|
|
51
51
|
"build": "tsup src/index.ts src/cli/index.ts --format esm,cjs --dts --clean",
|
|
52
52
|
"watch": "npm run build -- --watch src",
|
|
53
53
|
"start": "esno src/cli/run.ts",
|
|
54
|
+
"test": "vitest",
|
|
54
55
|
"upgrade": "npm-check -u && npm audit fix",
|
|
55
56
|
"bumpp": "esno src/cli/run.ts",
|
|
56
57
|
"prepublishOnly": "npm run clean && npm run build",
|
|
57
|
-
"release": "npm run bumpp && npm publish"
|
|
58
|
+
"release": "npm run bumpp && npm publish",
|
|
59
|
+
"typecheck": "tsc --noEmit"
|
|
58
60
|
},
|
|
59
61
|
"dependencies": {
|
|
60
62
|
"@jsdevtools/ez-spawn": "^3.0.4",
|
|
61
|
-
"c12": "^1.
|
|
63
|
+
"c12": "^1.9.0",
|
|
62
64
|
"cac": "^6.7.14",
|
|
65
|
+
"escalade": "^3.1.2",
|
|
63
66
|
"fast-glob": "^3.3.2",
|
|
64
67
|
"js-yaml": "^4.1.0",
|
|
65
68
|
"prompts": "^2.4.2",
|
|
66
|
-
"semver": "^7.
|
|
69
|
+
"semver": "^7.6.0"
|
|
67
70
|
},
|
|
68
71
|
"devDependencies": {
|
|
69
|
-
"@antfu/eslint-config": "^2.
|
|
72
|
+
"@antfu/eslint-config": "^2.7.0",
|
|
70
73
|
"@types/js-yaml": "^4.0.9",
|
|
71
|
-
"@types/node": "^20.11.
|
|
74
|
+
"@types/node": "^20.11.24",
|
|
72
75
|
"@types/prompts": "^2.4.9",
|
|
73
|
-
"@types/semver": "^7.5.
|
|
76
|
+
"@types/semver": "^7.5.8",
|
|
74
77
|
"detect-indent": "^7.0.1",
|
|
75
78
|
"detect-newline": "^4.0.1",
|
|
76
|
-
"eslint": "^8.
|
|
77
|
-
"esno": "^4.
|
|
79
|
+
"eslint": "^8.57.0",
|
|
80
|
+
"esno": "^4.7.0",
|
|
78
81
|
"log-symbols": "^6.0.0",
|
|
79
82
|
"npm-check": "^6.0.1",
|
|
80
83
|
"picocolors": "^1.0.0",
|
|
81
84
|
"rimraf": "^5.0.5",
|
|
82
|
-
"tsup": "^8.0.
|
|
83
|
-
"typescript": "^5.3.3"
|
|
85
|
+
"tsup": "^8.0.2",
|
|
86
|
+
"typescript": "^5.3.3",
|
|
87
|
+
"vitest": "^1.3.1"
|
|
84
88
|
}
|
|
85
89
|
}
|