bumpp 9.3.1 → 9.4.1
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-2LHJGPFO.mjs → chunk-ZH3O6GQ3.mjs} +105 -41
- package/dist/cli/index.js +129 -75
- package/dist/cli/index.mjs +31 -35
- package/dist/index.d.mts +18 -11
- package/dist/index.d.ts +18 -11
- package/dist/index.js +103 -42
- package/dist/index.mjs +1 -1
- package/package.json +13 -9
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.1";
|
|
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
|
|
@@ -916,8 +915,10 @@ function isOptionalString(value) {
|
|
|
916
915
|
return value === null || type === "undefined" || type === "string";
|
|
917
916
|
}
|
|
918
917
|
|
|
919
|
-
// src/get-
|
|
920
|
-
async function
|
|
918
|
+
// src/get-current-version.ts
|
|
919
|
+
async function getCurrentVersion(operation) {
|
|
920
|
+
if (operation.state.currentVersion)
|
|
921
|
+
return operation;
|
|
921
922
|
const { cwd, files } = operation.options;
|
|
922
923
|
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
923
924
|
if (!filesToCheck.includes("package.json"))
|
|
@@ -926,8 +927,8 @@ async function getOldVersion(operation) {
|
|
|
926
927
|
const version2 = await readVersion(file, cwd);
|
|
927
928
|
if (version2) {
|
|
928
929
|
return operation.update({
|
|
929
|
-
|
|
930
|
-
|
|
930
|
+
currentVersionSource: file,
|
|
931
|
+
currentVersion: version2
|
|
931
932
|
});
|
|
932
933
|
}
|
|
933
934
|
}
|
|
@@ -1004,9 +1005,12 @@ function formatVersionString(template, newVersion) {
|
|
|
1004
1005
|
|
|
1005
1006
|
// src/normalize-options.ts
|
|
1006
1007
|
var import_node_process4 = __toESM(require("process"));
|
|
1008
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
1009
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
1007
1010
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
1011
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
1008
1012
|
async function normalizeOptions(raw) {
|
|
1009
|
-
var _a;
|
|
1013
|
+
var _a, _b;
|
|
1010
1014
|
const preid = typeof raw.preid === "string" ? raw.preid : "beta";
|
|
1011
1015
|
const push = Boolean(raw.push);
|
|
1012
1016
|
const all = Boolean(raw.all);
|
|
@@ -1014,10 +1018,11 @@ async function normalizeOptions(raw) {
|
|
|
1014
1018
|
const cwd = raw.cwd || import_node_process4.default.cwd();
|
|
1015
1019
|
const ignoreScripts = Boolean(raw.ignoreScripts);
|
|
1016
1020
|
const execute = raw.execute;
|
|
1021
|
+
const recursive = Boolean(raw.recursive);
|
|
1017
1022
|
let release;
|
|
1018
1023
|
if (!raw.release || raw.release === "prompt")
|
|
1019
1024
|
release = { type: "prompt", preid };
|
|
1020
|
-
else if (isReleaseType(raw.release))
|
|
1025
|
+
else if (isReleaseType(raw.release) || raw.release === "next")
|
|
1021
1026
|
release = { type: raw.release, preid };
|
|
1022
1027
|
else
|
|
1023
1028
|
release = { type: "version", version: raw.release };
|
|
@@ -1031,8 +1036,29 @@ async function normalizeOptions(raw) {
|
|
|
1031
1036
|
commit = { all, noVerify, message: raw.commit };
|
|
1032
1037
|
else if (raw.commit || tag || push)
|
|
1033
1038
|
commit = { all, noVerify, message: "chore: release v" };
|
|
1039
|
+
if (recursive && !((_a = raw.files) == null ? void 0 : _a.length)) {
|
|
1040
|
+
raw.files = [
|
|
1041
|
+
"package.json",
|
|
1042
|
+
"package-lock.json",
|
|
1043
|
+
"packages/**/package.json",
|
|
1044
|
+
"jsr.json",
|
|
1045
|
+
"jsr.jsonc"
|
|
1046
|
+
];
|
|
1047
|
+
if (import_node_fs2.default.existsSync("pnpm-workspace.yaml")) {
|
|
1048
|
+
const pnpmWorkspace = await import_promises.default.readFile("pnpm-workspace.yaml", "utf8");
|
|
1049
|
+
const workspaces = import_js_yaml.default.load(pnpmWorkspace);
|
|
1050
|
+
const workspacesWithPackageJson = workspaces.packages.map((workspace) => `${workspace}/package.json`);
|
|
1051
|
+
const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => {
|
|
1052
|
+
var _a2;
|
|
1053
|
+
return !workspace.startsWith("!") && !((_a2 = raw.files) == null ? void 0 : _a2.includes(workspace));
|
|
1054
|
+
});
|
|
1055
|
+
raw.files = raw.files.concat(withoutExcludedWorkspaces);
|
|
1056
|
+
}
|
|
1057
|
+
} else {
|
|
1058
|
+
raw.files = ((_b = raw.files) == null ? void 0 : _b.length) ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc"];
|
|
1059
|
+
}
|
|
1034
1060
|
const files = await (0, import_fast_glob.default)(
|
|
1035
|
-
|
|
1061
|
+
raw.files,
|
|
1036
1062
|
{
|
|
1037
1063
|
cwd,
|
|
1038
1064
|
onlyFiles: true,
|
|
@@ -1047,7 +1073,7 @@ async function normalizeOptions(raw) {
|
|
|
1047
1073
|
} else if (raw.interface === true || !raw.interface) {
|
|
1048
1074
|
ui = { input: import_node_process4.default.stdin, output: import_node_process4.default.stdout };
|
|
1049
1075
|
} else {
|
|
1050
|
-
let
|
|
1076
|
+
let _c = raw.interface, { input, output } = _c, other = __objRest(_c, ["input", "output"]);
|
|
1051
1077
|
if (input === true || input !== false && !input)
|
|
1052
1078
|
input = import_node_process4.default.stdin;
|
|
1053
1079
|
if (output === true || output !== false && !output)
|
|
@@ -1066,7 +1092,8 @@ async function normalizeOptions(raw) {
|
|
|
1066
1092
|
interface: ui,
|
|
1067
1093
|
ignoreScripts,
|
|
1068
1094
|
execute,
|
|
1069
|
-
customVersion: raw.customVersion
|
|
1095
|
+
customVersion: raw.customVersion,
|
|
1096
|
+
currentVersion: raw.currentVersion
|
|
1070
1097
|
};
|
|
1071
1098
|
}
|
|
1072
1099
|
|
|
@@ -1081,8 +1108,8 @@ var Operation = class _Operation {
|
|
|
1081
1108
|
*/
|
|
1082
1109
|
this.state = {
|
|
1083
1110
|
release: void 0,
|
|
1084
|
-
|
|
1085
|
-
|
|
1111
|
+
currentVersion: "",
|
|
1112
|
+
currentVersionSource: "",
|
|
1086
1113
|
newVersion: "",
|
|
1087
1114
|
commitMessage: "",
|
|
1088
1115
|
tagName: "",
|
|
@@ -1091,6 +1118,12 @@ var Operation = class _Operation {
|
|
|
1091
1118
|
};
|
|
1092
1119
|
this.options = options;
|
|
1093
1120
|
this._progress = progress2;
|
|
1121
|
+
if (options.currentVersion) {
|
|
1122
|
+
this.update({
|
|
1123
|
+
currentVersion: options.currentVersion,
|
|
1124
|
+
currentVersionSource: "user"
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1094
1127
|
}
|
|
1095
1128
|
/**
|
|
1096
1129
|
* The results of the operation.
|
|
@@ -1100,7 +1133,7 @@ var Operation = class _Operation {
|
|
|
1100
1133
|
const state = this.state;
|
|
1101
1134
|
return {
|
|
1102
1135
|
release: state.release,
|
|
1103
|
-
|
|
1136
|
+
currentVersion: state.currentVersion,
|
|
1104
1137
|
newVersion: state.newVersion,
|
|
1105
1138
|
commit: options.commit ? state.commitMessage : false,
|
|
1106
1139
|
tag: options.tag ? state.tagName : false,
|
|
@@ -1188,9 +1221,8 @@ async function updateManifestFile(relPath, operation) {
|
|
|
1188
1221
|
const file = await readJsonFile(relPath, cwd);
|
|
1189
1222
|
if (isManifest(file.data) && file.data.version !== newVersion) {
|
|
1190
1223
|
file.data.version = newVersion;
|
|
1191
|
-
if (isPackageLockManifest(file.data))
|
|
1224
|
+
if (isPackageLockManifest(file.data))
|
|
1192
1225
|
file.data.packages[""].version = newVersion;
|
|
1193
|
-
}
|
|
1194
1226
|
await writeJsonFile(file);
|
|
1195
1227
|
modified = true;
|
|
1196
1228
|
}
|
|
@@ -1198,11 +1230,11 @@ async function updateManifestFile(relPath, operation) {
|
|
|
1198
1230
|
}
|
|
1199
1231
|
async function updateTextFile(relPath, operation) {
|
|
1200
1232
|
const { cwd } = operation.options;
|
|
1201
|
-
const {
|
|
1233
|
+
const { currentVersion, newVersion } = operation.state;
|
|
1202
1234
|
const modified = false;
|
|
1203
1235
|
const file = await readTextFile(relPath, cwd);
|
|
1204
|
-
if (file.data.includes(
|
|
1205
|
-
const sanitizedVersion =
|
|
1236
|
+
if (file.data.includes(currentVersion)) {
|
|
1237
|
+
const sanitizedVersion = currentVersion.replace(/(\W)/g, "\\$1");
|
|
1206
1238
|
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
|
|
1207
1239
|
file.data = file.data.replace(replacePattern, `$1${newVersion}`);
|
|
1208
1240
|
await writeTextFile(file);
|
|
@@ -1216,7 +1248,7 @@ async function versionBump(arg = {}) {
|
|
|
1216
1248
|
if (typeof arg === "string")
|
|
1217
1249
|
arg = { release: arg };
|
|
1218
1250
|
const operation = await Operation.start(arg);
|
|
1219
|
-
await
|
|
1251
|
+
await getCurrentVersion(operation);
|
|
1220
1252
|
await getNewVersion(operation);
|
|
1221
1253
|
if (arg.confirm) {
|
|
1222
1254
|
printSummary(operation);
|
|
@@ -1254,23 +1286,22 @@ function printSummary(operation) {
|
|
|
1254
1286
|
if (operation.options.push)
|
|
1255
1287
|
console.log(` push ${import_picocolors2.default.cyan(import_picocolors2.default.bold("yes"))}`);
|
|
1256
1288
|
console.log();
|
|
1257
|
-
console.log(` from ${import_picocolors2.default.bold(operation.state.
|
|
1289
|
+
console.log(` from ${import_picocolors2.default.bold(operation.state.currentVersion)}`);
|
|
1258
1290
|
console.log(` to ${import_picocolors2.default.green(import_picocolors2.default.bold(operation.state.newVersion))}`);
|
|
1259
1291
|
console.log();
|
|
1260
1292
|
}
|
|
1261
1293
|
|
|
1262
1294
|
// src/cli/parse-args.ts
|
|
1263
1295
|
var import_node_process7 = __toESM(require("process"));
|
|
1264
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
1265
|
-
var import_node_fs2 = __toESM(require("fs"));
|
|
1266
1296
|
var import_semver3 = require("semver");
|
|
1267
1297
|
var import_cac = __toESM(require("cac"));
|
|
1268
1298
|
var import_picocolors3 = __toESM(require_picocolors());
|
|
1269
|
-
var import_js_yaml = __toESM(require("js-yaml"));
|
|
1270
1299
|
|
|
1271
1300
|
// src/config.ts
|
|
1272
1301
|
var import_node_process6 = __toESM(require("process"));
|
|
1302
|
+
var import_node_path2 = require("path");
|
|
1273
1303
|
var import_c12 = require("c12");
|
|
1304
|
+
var import_sync = __toESM(require("escalade/sync"));
|
|
1274
1305
|
var bumpConfigDefaults = {
|
|
1275
1306
|
commit: true,
|
|
1276
1307
|
push: true,
|
|
@@ -1283,37 +1314,62 @@ var bumpConfigDefaults = {
|
|
|
1283
1314
|
files: []
|
|
1284
1315
|
};
|
|
1285
1316
|
async function loadBumpConfig(overrides, cwd = import_node_process6.default.cwd()) {
|
|
1317
|
+
const name = "bump";
|
|
1318
|
+
const configFile = findConfigFile(name, cwd);
|
|
1286
1319
|
const { config } = await (0, import_c12.loadConfig)({
|
|
1287
|
-
name
|
|
1320
|
+
name,
|
|
1288
1321
|
defaults: bumpConfigDefaults,
|
|
1289
1322
|
overrides: __spreadValues({}, overrides),
|
|
1290
|
-
cwd
|
|
1323
|
+
cwd: configFile ? (0, import_node_path2.dirname)(configFile) : cwd
|
|
1291
1324
|
});
|
|
1292
1325
|
return config;
|
|
1293
1326
|
}
|
|
1327
|
+
function findConfigFile(name, cwd) {
|
|
1328
|
+
let foundRepositoryRoot = false;
|
|
1329
|
+
try {
|
|
1330
|
+
const candidates = ["js", "mjs", "ts", "mts", "json"].map((ext) => `${name}.config.${ext}`);
|
|
1331
|
+
return (0, import_sync.default)(cwd, (_dir, files) => {
|
|
1332
|
+
const match = files.find((file) => {
|
|
1333
|
+
if (candidates.includes(file))
|
|
1334
|
+
return true;
|
|
1335
|
+
if (file === ".git")
|
|
1336
|
+
foundRepositoryRoot = true;
|
|
1337
|
+
return false;
|
|
1338
|
+
});
|
|
1339
|
+
if (match)
|
|
1340
|
+
return match;
|
|
1341
|
+
if (foundRepositoryRoot) {
|
|
1342
|
+
throw null;
|
|
1343
|
+
}
|
|
1344
|
+
return false;
|
|
1345
|
+
});
|
|
1346
|
+
} catch (error) {
|
|
1347
|
+
if (foundRepositoryRoot)
|
|
1348
|
+
return null;
|
|
1349
|
+
throw error;
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1294
1352
|
|
|
1295
1353
|
// src/cli/parse-args.ts
|
|
1296
1354
|
async function parseArgs() {
|
|
1297
1355
|
var _a;
|
|
1298
1356
|
try {
|
|
1299
|
-
const
|
|
1300
|
-
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();
|
|
1301
|
-
const result = cli.parse();
|
|
1302
|
-
const args = result.options;
|
|
1357
|
+
const { args, resultArgs } = loadCliArgs();
|
|
1303
1358
|
const parsedArgs = {
|
|
1304
1359
|
help: args.help,
|
|
1305
1360
|
version: args.version,
|
|
1306
1361
|
quiet: args.quiet,
|
|
1307
1362
|
options: await loadBumpConfig({
|
|
1308
1363
|
preid: args.preid,
|
|
1309
|
-
commit:
|
|
1310
|
-
tag:
|
|
1364
|
+
commit: args.commit,
|
|
1365
|
+
tag: args.tag,
|
|
1311
1366
|
push: args.push,
|
|
1312
1367
|
all: args.all,
|
|
1313
1368
|
confirm: !args.yes,
|
|
1314
1369
|
noVerify: !args.verify,
|
|
1315
|
-
files: [...args["--"] || [], ...
|
|
1370
|
+
files: [...args["--"] || [], ...resultArgs],
|
|
1316
1371
|
ignoreScripts: args.ignoreScripts,
|
|
1372
|
+
currentVersion: args.currentVersion,
|
|
1317
1373
|
execute: args.execute,
|
|
1318
1374
|
recursive: !!args.recursive
|
|
1319
1375
|
})
|
|
@@ -1325,34 +1381,32 @@ async function parseArgs() {
|
|
|
1325
1381
|
parsedArgs.options.files.shift();
|
|
1326
1382
|
}
|
|
1327
1383
|
}
|
|
1328
|
-
if (parsedArgs.options.recursive)
|
|
1329
|
-
|
|
1330
|
-
console.log(import_picocolors3.default.yellow("The --recursive option is ignored when files are specified"));
|
|
1331
|
-
} else {
|
|
1332
|
-
parsedArgs.options.files = [
|
|
1333
|
-
"package.json",
|
|
1334
|
-
"package-lock.json",
|
|
1335
|
-
"packages/**/package.json",
|
|
1336
|
-
"jsr.json",
|
|
1337
|
-
"jsr.jsonc"
|
|
1338
|
-
];
|
|
1339
|
-
if (import_node_fs2.default.existsSync("pnpm-workspace.yaml")) {
|
|
1340
|
-
const pnpmWorkspace = await import_promises.default.readFile("pnpm-workspace.yaml", "utf8");
|
|
1341
|
-
const workspaces = import_js_yaml.default.load(pnpmWorkspace);
|
|
1342
|
-
const workspacesWithPackageJson = workspaces.packages.map((workspace) => `${workspace}/package.json`);
|
|
1343
|
-
const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => {
|
|
1344
|
-
var _a2;
|
|
1345
|
-
return !workspace.startsWith("!") && !((_a2 = parsedArgs.options.files) == null ? void 0 : _a2.includes(workspace));
|
|
1346
|
-
});
|
|
1347
|
-
parsedArgs.options.files = parsedArgs.options.files.concat(withoutExcludedWorkspaces);
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1384
|
+
if (parsedArgs.options.recursive && ((_a = parsedArgs.options.files) == null ? void 0 : _a.length))
|
|
1385
|
+
console.log(import_picocolors3.default.yellow("The --recursive option is ignored when files are specified"));
|
|
1351
1386
|
return parsedArgs;
|
|
1352
1387
|
} catch (error) {
|
|
1353
1388
|
return errorHandler(error);
|
|
1354
1389
|
}
|
|
1355
1390
|
}
|
|
1391
|
+
function loadCliArgs(argv = import_node_process7.default.argv) {
|
|
1392
|
+
const cli = (0, import_cac.default)("bumpp");
|
|
1393
|
+
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();
|
|
1394
|
+
const result = cli.parse(argv);
|
|
1395
|
+
const rawArgs = cli.rawArgs;
|
|
1396
|
+
const args = result.options;
|
|
1397
|
+
const COMMIT_REG = /(-c|--commit|--no-commit)(=.*|$)/;
|
|
1398
|
+
const TAG_REG = /(-t|--tag|--no-tag)(=.*|$)/;
|
|
1399
|
+
const hasCommitFlag = rawArgs.some((arg) => COMMIT_REG.test(arg));
|
|
1400
|
+
const hasTagFlag = rawArgs.some((arg) => TAG_REG.test(arg));
|
|
1401
|
+
const _a = args, { tag, commit } = _a, rest = __objRest(_a, ["tag", "commit"]);
|
|
1402
|
+
return {
|
|
1403
|
+
args: __spreadProps(__spreadValues({}, rest), {
|
|
1404
|
+
commit: hasCommitFlag ? commit : void 0,
|
|
1405
|
+
tag: hasTagFlag ? tag : void 0
|
|
1406
|
+
}),
|
|
1407
|
+
resultArgs: result.args
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1356
1410
|
function errorHandler(error) {
|
|
1357
1411
|
console.error(error.message);
|
|
1358
1412
|
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,43 +10,38 @@ import {
|
|
|
7
10
|
log_symbols_default,
|
|
8
11
|
require_picocolors,
|
|
9
12
|
versionBump
|
|
10
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-ZH3O6GQ3.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.1";
|
|
17
20
|
|
|
18
21
|
// src/cli/parse-args.ts
|
|
19
22
|
var import_picocolors = __toESM(require_picocolors());
|
|
20
23
|
import process from "process";
|
|
21
|
-
import fs from "fs/promises";
|
|
22
|
-
import fsSync from "fs";
|
|
23
24
|
import { valid as isValidVersion } from "semver";
|
|
24
25
|
import cac from "cac";
|
|
25
|
-
import yaml from "js-yaml";
|
|
26
26
|
async function parseArgs() {
|
|
27
27
|
var _a;
|
|
28
28
|
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;
|
|
29
|
+
const { args, resultArgs } = loadCliArgs();
|
|
33
30
|
const parsedArgs = {
|
|
34
31
|
help: args.help,
|
|
35
32
|
version: args.version,
|
|
36
33
|
quiet: args.quiet,
|
|
37
34
|
options: await loadBumpConfig({
|
|
38
35
|
preid: args.preid,
|
|
39
|
-
commit:
|
|
40
|
-
tag:
|
|
36
|
+
commit: args.commit,
|
|
37
|
+
tag: args.tag,
|
|
41
38
|
push: args.push,
|
|
42
39
|
all: args.all,
|
|
43
40
|
confirm: !args.yes,
|
|
44
41
|
noVerify: !args.verify,
|
|
45
|
-
files: [...args["--"] || [], ...
|
|
42
|
+
files: [...args["--"] || [], ...resultArgs],
|
|
46
43
|
ignoreScripts: args.ignoreScripts,
|
|
44
|
+
currentVersion: args.currentVersion,
|
|
47
45
|
execute: args.execute,
|
|
48
46
|
recursive: !!args.recursive
|
|
49
47
|
})
|
|
@@ -55,34 +53,32 @@ async function parseArgs() {
|
|
|
55
53
|
parsedArgs.options.files.shift();
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
if (parsedArgs.options.recursive)
|
|
59
|
-
|
|
60
|
-
console.log(import_picocolors.default.yellow("The --recursive option is ignored when files are specified"));
|
|
61
|
-
} else {
|
|
62
|
-
parsedArgs.options.files = [
|
|
63
|
-
"package.json",
|
|
64
|
-
"package-lock.json",
|
|
65
|
-
"packages/**/package.json",
|
|
66
|
-
"jsr.json",
|
|
67
|
-
"jsr.jsonc"
|
|
68
|
-
];
|
|
69
|
-
if (fsSync.existsSync("pnpm-workspace.yaml")) {
|
|
70
|
-
const pnpmWorkspace = await fs.readFile("pnpm-workspace.yaml", "utf8");
|
|
71
|
-
const workspaces = yaml.load(pnpmWorkspace);
|
|
72
|
-
const workspacesWithPackageJson = workspaces.packages.map((workspace) => `${workspace}/package.json`);
|
|
73
|
-
const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => {
|
|
74
|
-
var _a2;
|
|
75
|
-
return !workspace.startsWith("!") && !((_a2 = parsedArgs.options.files) == null ? void 0 : _a2.includes(workspace));
|
|
76
|
-
});
|
|
77
|
-
parsedArgs.options.files = parsedArgs.options.files.concat(withoutExcludedWorkspaces);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
56
|
+
if (parsedArgs.options.recursive && ((_a = parsedArgs.options.files) == null ? void 0 : _a.length))
|
|
57
|
+
console.log(import_picocolors.default.yellow("The --recursive option is ignored when files are specified"));
|
|
81
58
|
return parsedArgs;
|
|
82
59
|
} catch (error) {
|
|
83
60
|
return errorHandler(error);
|
|
84
61
|
}
|
|
85
62
|
}
|
|
63
|
+
function loadCliArgs(argv = process.argv) {
|
|
64
|
+
const cli = cac("bumpp");
|
|
65
|
+
cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", `Include all files (default: ${bumpConfigDefaults.all})`).option("-c, --commit [msg]", "Commit message", { default: true }).option("--no-commit", "Skip commit", { default: false }).option("-t, --tag [tag]", "Tag name", { default: true }).option("--no-tag", "Skip tag", { default: false }).option("-p, --push", `Push to remote (default: ${bumpConfigDefaults.push})`).option("-y, --yes", `Skip confirmation (default: ${!bumpConfigDefaults.confirm})`).option("-r, --recursive", `Bump package.json files recursively (default: ${bumpConfigDefaults.recursive})`).option("--no-verify", "Skip git verification").option("--ignore-scripts", `Ignore scripts (default: ${bumpConfigDefaults.ignoreScripts})`).option("-q, --quiet", "Quiet mode").option("-v, --version <version>", "Target version").option("--current-version <version>", "Current version").option("-x, --execute <command>", "Commands to execute after version bumps").help();
|
|
66
|
+
const result = cli.parse(argv);
|
|
67
|
+
const rawArgs = cli.rawArgs;
|
|
68
|
+
const args = result.options;
|
|
69
|
+
const COMMIT_REG = /(-c|--commit|--no-commit)(=.*|$)/;
|
|
70
|
+
const TAG_REG = /(-t|--tag|--no-tag)(=.*|$)/;
|
|
71
|
+
const hasCommitFlag = rawArgs.some((arg) => COMMIT_REG.test(arg));
|
|
72
|
+
const hasTagFlag = rawArgs.some((arg) => TAG_REG.test(arg));
|
|
73
|
+
const _a = args, { tag, commit } = _a, rest = __objRest(_a, ["tag", "commit"]);
|
|
74
|
+
return {
|
|
75
|
+
args: __spreadProps(__spreadValues({}, rest), {
|
|
76
|
+
commit: hasCommitFlag ? commit : void 0,
|
|
77
|
+
tag: hasTagFlag ? tag : void 0
|
|
78
|
+
}),
|
|
79
|
+
resultArgs: result.args
|
|
80
|
+
};
|
|
81
|
+
}
|
|
86
82
|
function errorHandler(error) {
|
|
87
83
|
console.error(error.message);
|
|
88
84
|
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
|
*
|
|
@@ -94,7 +100,7 @@ interface VersionBumpOptions {
|
|
|
94
100
|
* with the new version number. If the message string does _not_ contain any `%s` placeholders,
|
|
95
101
|
* then the new version number will be appended to the message.
|
|
96
102
|
*
|
|
97
|
-
* Defaults to `
|
|
103
|
+
* Defaults to `true`.
|
|
98
104
|
*/
|
|
99
105
|
commit?: boolean | string;
|
|
100
106
|
/**
|
|
@@ -103,13 +109,13 @@ interface VersionBumpOptions {
|
|
|
103
109
|
* with the new version number. If the tag string does _not_ contain any `%s` placeholders,
|
|
104
110
|
* then the new version number will be appended to the tag.
|
|
105
111
|
*
|
|
106
|
-
* Defaults to `
|
|
112
|
+
* Defaults to `true`.
|
|
107
113
|
*/
|
|
108
114
|
tag?: boolean | string;
|
|
109
115
|
/**
|
|
110
116
|
* Indicates whether to push the git commit and tag.
|
|
111
117
|
*
|
|
112
|
-
* Defaults to `
|
|
118
|
+
* Defaults to `true`.
|
|
113
119
|
*/
|
|
114
120
|
push?: boolean;
|
|
115
121
|
/**
|
|
@@ -122,7 +128,7 @@ interface VersionBumpOptions {
|
|
|
122
128
|
/**
|
|
123
129
|
* Prompt for confirmation
|
|
124
130
|
*
|
|
125
|
-
* @default
|
|
131
|
+
* @default true
|
|
126
132
|
*/
|
|
127
133
|
confirm?: boolean;
|
|
128
134
|
/**
|
|
@@ -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 };
|