bumpp 7.2.0 → 8.0.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/README.md +7 -7
- package/bin/bumpp.js +3 -3
- package/dist/{chunk-2TP63A7S.mjs → chunk-HM6FRF4P.mjs} +136 -136
- package/dist/cli/index.js +154 -175
- package/dist/cli/index.mjs +15 -36
- package/dist/index.d.ts +6 -0
- package/dist/index.js +160 -160
- package/dist/index.mjs +1 -1
- package/package.json +27 -27
package/dist/index.js
CHANGED
|
@@ -67,28 +67,6 @@ var init_cjs_shims = __esm({
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
// node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js
|
|
71
|
-
var require_detect_newline = __commonJS({
|
|
72
|
-
"node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js"(exports, module2) {
|
|
73
|
-
"use strict";
|
|
74
|
-
init_cjs_shims();
|
|
75
|
-
var detectNewline2 = (string) => {
|
|
76
|
-
if (typeof string !== "string") {
|
|
77
|
-
throw new TypeError("Expected a string");
|
|
78
|
-
}
|
|
79
|
-
const newlines = string.match(/(?:\r?\n)/g) || [];
|
|
80
|
-
if (newlines.length === 0) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const crlf = newlines.filter((newline) => newline === "\r\n").length;
|
|
84
|
-
const lf = newlines.length - crlf;
|
|
85
|
-
return crlf > lf ? "\r\n" : "\n";
|
|
86
|
-
};
|
|
87
|
-
module2.exports = detectNewline2;
|
|
88
|
-
module2.exports.graceful = (string) => typeof string === "string" && detectNewline2(string) || "\n";
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
70
|
// node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js
|
|
93
71
|
var require_is_unicode_supported = __commonJS({
|
|
94
72
|
"node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js"(exports, module2) {
|
|
@@ -126,6 +104,28 @@ var require_log_symbols = __commonJS({
|
|
|
126
104
|
}
|
|
127
105
|
});
|
|
128
106
|
|
|
107
|
+
// node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js
|
|
108
|
+
var require_detect_newline = __commonJS({
|
|
109
|
+
"node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js"(exports, module2) {
|
|
110
|
+
"use strict";
|
|
111
|
+
init_cjs_shims();
|
|
112
|
+
var detectNewline2 = (string) => {
|
|
113
|
+
if (typeof string !== "string") {
|
|
114
|
+
throw new TypeError("Expected a string");
|
|
115
|
+
}
|
|
116
|
+
const newlines = string.match(/(?:\r?\n)/g) || [];
|
|
117
|
+
if (newlines.length === 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const crlf = newlines.filter((newline) => newline === "\r\n").length;
|
|
121
|
+
const lf = newlines.length - crlf;
|
|
122
|
+
return crlf > lf ? "\r\n" : "\n";
|
|
123
|
+
};
|
|
124
|
+
module2.exports = detectNewline2;
|
|
125
|
+
module2.exports.graceful = (string) => typeof string === "string" && detectNewline2(string) || "\n";
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
129
|
// src/index.ts
|
|
130
130
|
var src_exports = {};
|
|
131
131
|
__export(src_exports, {
|
|
@@ -140,18 +140,20 @@ init_cjs_shims();
|
|
|
140
140
|
// src/version-bump.ts
|
|
141
141
|
init_cjs_shims();
|
|
142
142
|
var ezSpawn3 = __toESM(require("@jsdevtools/ez-spawn"));
|
|
143
|
+
var import_chalk2 = require("chalk");
|
|
144
|
+
var import_log_symbols = __toESM(require_log_symbols());
|
|
145
|
+
var import_prompts2 = __toESM(require("prompts"));
|
|
143
146
|
|
|
144
147
|
// src/get-new-version.ts
|
|
145
148
|
init_cjs_shims();
|
|
146
149
|
var import_chalk = require("chalk");
|
|
147
150
|
var import_prompts = __toESM(require("prompts"));
|
|
148
|
-
var import_semver2 = require("semver");
|
|
149
|
-
var import_semver3 = __toESM(require("semver"));
|
|
151
|
+
var import_semver2 = __toESM(require("semver"));
|
|
150
152
|
|
|
151
153
|
// src/release-type.ts
|
|
152
154
|
init_cjs_shims();
|
|
153
155
|
var import_semver = require("semver");
|
|
154
|
-
var prereleaseTypes = ["prerelease"];
|
|
156
|
+
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
155
157
|
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
|
|
156
158
|
function isPrerelease(value) {
|
|
157
159
|
return prereleaseTypes.includes(value);
|
|
@@ -162,15 +164,14 @@ function isReleaseType(value) {
|
|
|
162
164
|
|
|
163
165
|
// src/get-new-version.ts
|
|
164
166
|
async function getNewVersion(operation) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
const { release } = operation.options;
|
|
168
|
+
const { oldVersion } = operation.state;
|
|
167
169
|
switch (release.type) {
|
|
168
170
|
case "prompt":
|
|
169
171
|
return promptForNewVersion(operation);
|
|
170
172
|
case "version":
|
|
171
|
-
let newSemVer = new import_semver3.SemVer(release.version, true);
|
|
172
173
|
return operation.update({
|
|
173
|
-
newVersion:
|
|
174
|
+
newVersion: new import_semver2.SemVer(release.version, true).version
|
|
174
175
|
});
|
|
175
176
|
default:
|
|
176
177
|
return operation.update({
|
|
@@ -180,8 +181,8 @@ async function getNewVersion(operation) {
|
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
function getNextVersion(oldVersion, bump) {
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
const oldSemVer = new import_semver2.SemVer(oldVersion);
|
|
185
|
+
const newSemVer = oldSemVer.inc(bump.type, bump.preid);
|
|
185
186
|
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
|
|
186
187
|
newSemVer.prerelease[1] = "1";
|
|
187
188
|
newSemVer.format();
|
|
@@ -190,36 +191,34 @@ function getNextVersion(oldVersion, bump) {
|
|
|
190
191
|
}
|
|
191
192
|
function getNextVersions(oldVersion, preid) {
|
|
192
193
|
var _a;
|
|
193
|
-
|
|
194
|
-
const parse =
|
|
195
|
-
if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
|
|
194
|
+
const next = {};
|
|
195
|
+
const parse = import_semver2.default.parse(oldVersion);
|
|
196
|
+
if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
|
|
196
197
|
preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? import_semver3.default.inc(oldVersion, "prerelease", preid) : import_semver3.default.inc(oldVersion, "patch");
|
|
198
|
+
for (const type of releaseTypes)
|
|
199
|
+
next[type] = import_semver2.default.inc(oldVersion, type, preid);
|
|
200
|
+
next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? import_semver2.default.inc(oldVersion, "prerelease", preid) : import_semver2.default.inc(oldVersion, "patch");
|
|
202
201
|
return next;
|
|
203
202
|
}
|
|
204
203
|
async function promptForNewVersion(operation) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
answers = await (0, import_prompts.default)([
|
|
204
|
+
const { oldVersion } = operation.state;
|
|
205
|
+
const release = operation.options.release;
|
|
206
|
+
const next = getNextVersions(oldVersion, release.preid);
|
|
207
|
+
const PADDING = 13;
|
|
208
|
+
const answers = await (0, import_prompts.default)([
|
|
210
209
|
{
|
|
211
210
|
type: "autocomplete",
|
|
212
211
|
name: "release",
|
|
213
|
-
message: `Current version
|
|
212
|
+
message: `Current version ${(0, import_chalk.green)(oldVersion)}`,
|
|
214
213
|
initial: "next",
|
|
215
214
|
choices: [
|
|
216
|
-
{ value: "major", title: "major
|
|
217
|
-
{ value: "minor", title: "minor
|
|
218
|
-
{ value: "patch", title: "patch
|
|
219
|
-
{ value: "next", title: "next
|
|
220
|
-
{ value: "prerelease", title: "pre-release
|
|
221
|
-
{ value: "none", title: "as-is
|
|
222
|
-
{ value: "custom", title: "custom..." }
|
|
215
|
+
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${(0, import_chalk.bold)(next.major)}` },
|
|
216
|
+
{ value: "minor", title: `${"minor".padStart(PADDING, " ")} ${(0, import_chalk.bold)(next.minor)}` },
|
|
217
|
+
{ value: "patch", title: `${"patch".padStart(PADDING, " ")} ${(0, import_chalk.bold)(next.patch)}` },
|
|
218
|
+
{ value: "next", title: `${"next".padStart(PADDING, " ")} ${(0, import_chalk.bold)(next.next)}` },
|
|
219
|
+
{ value: "prerelease", title: `${"pre-release".padStart(PADDING, " ")} ${(0, import_chalk.bold)(next.prerelease)}` },
|
|
220
|
+
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${(0, import_chalk.bold)(oldVersion)}` },
|
|
221
|
+
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
|
|
223
222
|
]
|
|
224
223
|
},
|
|
225
224
|
{
|
|
@@ -233,11 +232,11 @@ async function promptForNewVersion(operation) {
|
|
|
233
232
|
}
|
|
234
233
|
]);
|
|
235
234
|
const newVersion = answers.release === "none" ? oldVersion : answers.release === "custom" ? (0, import_semver2.clean)(answers.custom) : next[answers.release];
|
|
236
|
-
if (!newVersion)
|
|
235
|
+
if (!newVersion)
|
|
237
236
|
process.exit(1);
|
|
238
|
-
}
|
|
239
237
|
switch (answers.release) {
|
|
240
238
|
case "custom":
|
|
239
|
+
case "next":
|
|
241
240
|
case "none":
|
|
242
241
|
return operation.update({ newVersion });
|
|
243
242
|
default:
|
|
@@ -247,10 +246,12 @@ async function promptForNewVersion(operation) {
|
|
|
247
246
|
|
|
248
247
|
// src/get-old-version.ts
|
|
249
248
|
init_cjs_shims();
|
|
250
|
-
var
|
|
249
|
+
var import_semver3 = require("semver");
|
|
251
250
|
|
|
252
251
|
// src/fs.ts
|
|
253
252
|
init_cjs_shims();
|
|
253
|
+
var import_fs = __toESM(require("fs"));
|
|
254
|
+
var import_path = __toESM(require("path"));
|
|
254
255
|
|
|
255
256
|
// node_modules/.pnpm/detect-indent@7.0.0/node_modules/detect-indent/index.js
|
|
256
257
|
init_cjs_shims();
|
|
@@ -352,25 +353,22 @@ function detectIndent(string) {
|
|
|
352
353
|
|
|
353
354
|
// src/fs.ts
|
|
354
355
|
var import_detect_newline = __toESM(require_detect_newline());
|
|
355
|
-
var import_fs = __toESM(require("fs"));
|
|
356
|
-
var import_path = __toESM(require("path"));
|
|
357
356
|
async function readJsonFile(name, cwd) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
357
|
+
const file = await readTextFile(name, cwd);
|
|
358
|
+
const data = JSON.parse(file.data);
|
|
359
|
+
const indent = detectIndent(file.data).indent;
|
|
360
|
+
const newline = (0, import_detect_newline.default)(file.data);
|
|
362
361
|
return __spreadProps(__spreadValues({}, file), { data, indent, newline });
|
|
363
362
|
}
|
|
364
363
|
async function writeJsonFile(file) {
|
|
365
364
|
let json = JSON.stringify(file.data, void 0, file.indent);
|
|
366
|
-
if (file.newline)
|
|
365
|
+
if (file.newline)
|
|
367
366
|
json += file.newline;
|
|
368
|
-
}
|
|
369
367
|
return writeTextFile(__spreadProps(__spreadValues({}, file), { data: json }));
|
|
370
368
|
}
|
|
371
369
|
function readTextFile(name, cwd) {
|
|
372
370
|
return new Promise((resolve, reject) => {
|
|
373
|
-
|
|
371
|
+
const filePath = import_path.default.join(cwd, name);
|
|
374
372
|
import_fs.default.readFile(filePath, "utf8", (err, text) => {
|
|
375
373
|
if (err) {
|
|
376
374
|
reject(err);
|
|
@@ -386,11 +384,10 @@ function readTextFile(name, cwd) {
|
|
|
386
384
|
function writeTextFile(file) {
|
|
387
385
|
return new Promise((resolve, reject) => {
|
|
388
386
|
import_fs.default.writeFile(file.path, file.data, (err) => {
|
|
389
|
-
if (err)
|
|
387
|
+
if (err)
|
|
390
388
|
reject(err);
|
|
391
|
-
|
|
389
|
+
else
|
|
392
390
|
resolve();
|
|
393
|
-
}
|
|
394
391
|
});
|
|
395
392
|
});
|
|
396
393
|
}
|
|
@@ -401,19 +398,18 @@ function isManifest(obj) {
|
|
|
401
398
|
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
402
399
|
}
|
|
403
400
|
function isOptionalString(value) {
|
|
404
|
-
|
|
401
|
+
const type = typeof value;
|
|
405
402
|
return value === null || type === "undefined" || type === "string";
|
|
406
403
|
}
|
|
407
404
|
|
|
408
405
|
// src/get-old-version.ts
|
|
409
406
|
async function getOldVersion(operation) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if (!filesToCheck.includes("package.json"))
|
|
407
|
+
const { cwd, files } = operation.options;
|
|
408
|
+
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
409
|
+
if (!filesToCheck.includes("package.json"))
|
|
413
410
|
filesToCheck.push("package.json");
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
let version = await readVersion(file, cwd);
|
|
411
|
+
for (const file of filesToCheck) {
|
|
412
|
+
const version = await readVersion(file, cwd);
|
|
417
413
|
if (version) {
|
|
418
414
|
return operation.update({
|
|
419
415
|
oldVersionSource: file,
|
|
@@ -425,11 +421,10 @@ async function getOldVersion(operation) {
|
|
|
425
421
|
}
|
|
426
422
|
async function readVersion(file, cwd) {
|
|
427
423
|
try {
|
|
428
|
-
|
|
424
|
+
const { data: manifest } = await readJsonFile(file, cwd);
|
|
429
425
|
if (isManifest(manifest)) {
|
|
430
|
-
if ((0,
|
|
426
|
+
if ((0, import_semver3.valid)(manifest.version))
|
|
431
427
|
return manifest.version;
|
|
432
|
-
}
|
|
433
428
|
}
|
|
434
429
|
} catch (error) {
|
|
435
430
|
return void 0;
|
|
@@ -451,20 +446,19 @@ var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
|
|
|
451
446
|
ProgressEvent2["NpmScript"] = "npm script";
|
|
452
447
|
return ProgressEvent2;
|
|
453
448
|
})(ProgressEvent || {});
|
|
454
|
-
var NpmScript = /* @__PURE__ */ ((
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
return
|
|
449
|
+
var NpmScript = /* @__PURE__ */ ((NpmScript2) => {
|
|
450
|
+
NpmScript2["PreVersion"] = "preversion";
|
|
451
|
+
NpmScript2["Version"] = "version";
|
|
452
|
+
NpmScript2["PostVersion"] = "postversion";
|
|
453
|
+
return NpmScript2;
|
|
459
454
|
})(NpmScript || {});
|
|
460
455
|
|
|
461
456
|
// src/git.ts
|
|
462
457
|
async function gitCommit(operation) {
|
|
463
|
-
if (!operation.options.commit)
|
|
458
|
+
if (!operation.options.commit)
|
|
464
459
|
return operation;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
let { updatedFiles, newVersion } = operation.state;
|
|
460
|
+
const { all, noVerify, message } = operation.options.commit;
|
|
461
|
+
const { updatedFiles, newVersion } = operation.state;
|
|
468
462
|
let args = [];
|
|
469
463
|
if (all) {
|
|
470
464
|
args.push("--all");
|
|
@@ -472,34 +466,31 @@ async function gitCommit(operation) {
|
|
|
472
466
|
if (noVerify) {
|
|
473
467
|
args.push("--no-verify");
|
|
474
468
|
}
|
|
475
|
-
|
|
469
|
+
const commitMessage = formatVersionString(message, newVersion);
|
|
476
470
|
args.push("--message", commitMessage);
|
|
477
|
-
if (!all)
|
|
471
|
+
if (!all)
|
|
478
472
|
args = args.concat(updatedFiles);
|
|
479
|
-
}
|
|
480
473
|
await ezSpawn.async("git", ["commit", ...args]);
|
|
481
474
|
return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
|
|
482
475
|
}
|
|
483
476
|
async function gitTag(operation) {
|
|
484
|
-
if (!operation.options.tag)
|
|
477
|
+
if (!operation.options.tag)
|
|
485
478
|
return operation;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
let args = [
|
|
479
|
+
const { commit, tag } = operation.options;
|
|
480
|
+
const { newVersion } = operation.state;
|
|
481
|
+
const args = [
|
|
490
482
|
"--annotate",
|
|
491
483
|
"--message",
|
|
492
484
|
formatVersionString(commit.message, newVersion)
|
|
493
485
|
];
|
|
494
|
-
|
|
486
|
+
const tagName = formatVersionString(tag.name, newVersion);
|
|
495
487
|
args.push(tagName);
|
|
496
488
|
await ezSpawn.async("git", ["tag", ...args]);
|
|
497
489
|
return operation.update({ event: "git tag" /* GitTag */, tagName });
|
|
498
490
|
}
|
|
499
491
|
async function gitPush(operation) {
|
|
500
|
-
if (!operation.options.push)
|
|
492
|
+
if (!operation.options.push)
|
|
501
493
|
return operation;
|
|
502
|
-
}
|
|
503
494
|
await ezSpawn.async("git", "push");
|
|
504
495
|
if (operation.options.tag) {
|
|
505
496
|
await ezSpawn.async("git", ["push", "--tags"]);
|
|
@@ -507,11 +498,10 @@ async function gitPush(operation) {
|
|
|
507
498
|
return operation.update({ event: "git push" /* GitPush */ });
|
|
508
499
|
}
|
|
509
500
|
function formatVersionString(template, newVersion) {
|
|
510
|
-
if (template.includes("%s"))
|
|
501
|
+
if (template.includes("%s"))
|
|
511
502
|
return template.replace(/%s/g, newVersion);
|
|
512
|
-
|
|
503
|
+
else
|
|
513
504
|
return template + newVersion;
|
|
514
|
-
}
|
|
515
505
|
}
|
|
516
506
|
|
|
517
507
|
// src/operation.ts
|
|
@@ -520,35 +510,31 @@ init_cjs_shims();
|
|
|
520
510
|
// src/normalize-options.ts
|
|
521
511
|
init_cjs_shims();
|
|
522
512
|
var import_globby = __toESM(require("globby"));
|
|
523
|
-
var import_globby2 = require("globby");
|
|
524
513
|
async function normalizeOptions(raw) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
514
|
+
const preid = typeof raw.preid === "string" ? raw.preid : "beta";
|
|
515
|
+
const push = Boolean(raw.push);
|
|
516
|
+
const all = Boolean(raw.all);
|
|
517
|
+
const noVerify = Boolean(raw.noVerify);
|
|
518
|
+
const cwd = raw.cwd || process.cwd();
|
|
519
|
+
const ignoreScripts = Boolean(raw.ignoreScripts);
|
|
520
|
+
const execute = raw.execute;
|
|
532
521
|
let release;
|
|
533
|
-
if (!raw.release || raw.release === "prompt")
|
|
522
|
+
if (!raw.release || raw.release === "prompt")
|
|
534
523
|
release = { type: "prompt", preid };
|
|
535
|
-
|
|
524
|
+
else if (isReleaseType(raw.release))
|
|
536
525
|
release = { type: raw.release, preid };
|
|
537
|
-
|
|
526
|
+
else
|
|
538
527
|
release = { type: "version", version: raw.release };
|
|
539
|
-
}
|
|
540
528
|
let tag;
|
|
541
|
-
if (typeof raw.tag === "string")
|
|
529
|
+
if (typeof raw.tag === "string")
|
|
542
530
|
tag = { name: raw.tag };
|
|
543
|
-
|
|
531
|
+
else if (raw.tag)
|
|
544
532
|
tag = { name: "v" };
|
|
545
|
-
}
|
|
546
533
|
let commit;
|
|
547
|
-
if (typeof raw.commit === "string")
|
|
534
|
+
if (typeof raw.commit === "string")
|
|
548
535
|
commit = { all, noVerify, message: raw.commit };
|
|
549
|
-
|
|
550
|
-
commit = { all, noVerify, message: "release v" };
|
|
551
|
-
}
|
|
536
|
+
else if (raw.commit || tag || push)
|
|
537
|
+
commit = { all, noVerify, message: "chore: release v" };
|
|
552
538
|
let files;
|
|
553
539
|
if (Array.isArray(raw.files) && raw.files.length > 0) {
|
|
554
540
|
files = await strictGlobMatches(raw.files, { cwd });
|
|
@@ -562,37 +548,32 @@ async function normalizeOptions(raw) {
|
|
|
562
548
|
ui = { input: process.stdin, output: process.stdout };
|
|
563
549
|
} else {
|
|
564
550
|
let _a = raw.interface, { input, output } = _a, other = __objRest(_a, ["input", "output"]);
|
|
565
|
-
if (input === true || input !== false && !input)
|
|
551
|
+
if (input === true || input !== false && !input)
|
|
566
552
|
input = process.stdin;
|
|
567
|
-
|
|
568
|
-
if (output === true || output !== false && !output) {
|
|
553
|
+
if (output === true || output !== false && !output)
|
|
569
554
|
output = process.stdout;
|
|
570
|
-
}
|
|
571
555
|
ui = __spreadValues({ input, output }, other);
|
|
572
556
|
}
|
|
573
|
-
if (release.type === "prompt" && !(ui.input && ui.output))
|
|
557
|
+
if (release.type === "prompt" && !(ui.input && ui.output))
|
|
574
558
|
throw new Error("Cannot prompt for the version number because input or output has been disabled.");
|
|
575
|
-
}
|
|
576
559
|
return { release, commit, tag, push, files, cwd, interface: ui, ignoreScripts, execute };
|
|
577
560
|
}
|
|
578
561
|
async function strictGlobMatches(files, options) {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
for (
|
|
582
|
-
for (
|
|
562
|
+
const matches = await Promise.all(files.map((file) => strictGlobMatch(file, options)));
|
|
563
|
+
const matchedFiles = /* @__PURE__ */ new Set();
|
|
564
|
+
for (const match of matches) {
|
|
565
|
+
for (const file of match)
|
|
583
566
|
matchedFiles.add(file);
|
|
584
|
-
}
|
|
585
567
|
}
|
|
586
568
|
return [...matchedFiles];
|
|
587
569
|
}
|
|
588
570
|
async function strictGlobMatch(file, options) {
|
|
589
|
-
|
|
571
|
+
const matches = await (0, import_globby.default)(file, options);
|
|
590
572
|
if (matches.length === 0) {
|
|
591
|
-
if ((0,
|
|
573
|
+
if ((0, import_globby.hasMagic)(file))
|
|
592
574
|
throw new Error(`Could not find any files matching "${file}".`);
|
|
593
|
-
|
|
575
|
+
else
|
|
594
576
|
throw new Error(`Could not find file: ${file}.`);
|
|
595
|
-
}
|
|
596
577
|
}
|
|
597
578
|
return matches.sort();
|
|
598
579
|
}
|
|
@@ -614,8 +595,8 @@ var Operation = class {
|
|
|
614
595
|
this._progress = progress;
|
|
615
596
|
}
|
|
616
597
|
get results() {
|
|
617
|
-
|
|
618
|
-
|
|
598
|
+
const options = this.options;
|
|
599
|
+
const state = this.state;
|
|
619
600
|
return {
|
|
620
601
|
release: state.release,
|
|
621
602
|
oldVersion: state.oldVersion,
|
|
@@ -627,7 +608,7 @@ var Operation = class {
|
|
|
627
608
|
};
|
|
628
609
|
}
|
|
629
610
|
static async start(input) {
|
|
630
|
-
|
|
611
|
+
const options = await normalizeOptions(input);
|
|
631
612
|
return new Operation(options, input.progress);
|
|
632
613
|
}
|
|
633
614
|
update(_a) {
|
|
@@ -644,9 +625,9 @@ var Operation = class {
|
|
|
644
625
|
init_cjs_shims();
|
|
645
626
|
var ezSpawn2 = __toESM(require("@jsdevtools/ez-spawn"));
|
|
646
627
|
async function runNpmScript(script, operation) {
|
|
647
|
-
|
|
628
|
+
const { cwd, ignoreScripts } = operation.options;
|
|
648
629
|
if (!ignoreScripts) {
|
|
649
|
-
|
|
630
|
+
const { data: manifest } = await readJsonFile("package.json", cwd);
|
|
650
631
|
if (isManifest(manifest) && hasScript(manifest, script)) {
|
|
651
632
|
await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
|
|
652
633
|
operation.update({ event: "npm script" /* NpmScript */, script });
|
|
@@ -655,10 +636,9 @@ async function runNpmScript(script, operation) {
|
|
|
655
636
|
return operation;
|
|
656
637
|
}
|
|
657
638
|
function hasScript(manifest, script) {
|
|
658
|
-
|
|
659
|
-
if (scripts && typeof scripts === "object")
|
|
639
|
+
const scripts = manifest.scripts;
|
|
640
|
+
if (scripts && typeof scripts === "object")
|
|
660
641
|
return Boolean(scripts[script]);
|
|
661
|
-
}
|
|
662
642
|
return false;
|
|
663
643
|
}
|
|
664
644
|
|
|
@@ -666,9 +646,9 @@ function hasScript(manifest, script) {
|
|
|
666
646
|
init_cjs_shims();
|
|
667
647
|
var path2 = __toESM(require("path"));
|
|
668
648
|
async function updateFiles(operation) {
|
|
669
|
-
|
|
670
|
-
for (
|
|
671
|
-
|
|
649
|
+
const { files } = operation.options;
|
|
650
|
+
for (const relPath of files) {
|
|
651
|
+
const modified = await updateFile(relPath, operation);
|
|
672
652
|
if (modified) {
|
|
673
653
|
operation.update({
|
|
674
654
|
event: "file updated" /* FileUpdated */,
|
|
@@ -684,7 +664,7 @@ async function updateFiles(operation) {
|
|
|
684
664
|
return operation;
|
|
685
665
|
}
|
|
686
666
|
async function updateFile(relPath, operation) {
|
|
687
|
-
|
|
667
|
+
const name = path2.basename(relPath).trim().toLowerCase();
|
|
688
668
|
switch (name) {
|
|
689
669
|
case "package.json":
|
|
690
670
|
case "package-lock.json":
|
|
@@ -696,10 +676,10 @@ async function updateFile(relPath, operation) {
|
|
|
696
676
|
}
|
|
697
677
|
}
|
|
698
678
|
async function updateManifestFile(relPath, operation) {
|
|
699
|
-
|
|
700
|
-
|
|
679
|
+
const { cwd } = operation.options;
|
|
680
|
+
const { newVersion } = operation.state;
|
|
701
681
|
let modified = false;
|
|
702
|
-
|
|
682
|
+
const file = await readJsonFile(relPath, cwd);
|
|
703
683
|
if (isManifest(file.data) && file.data.version !== newVersion) {
|
|
704
684
|
file.data.version = newVersion;
|
|
705
685
|
await writeJsonFile(file);
|
|
@@ -708,14 +688,14 @@ async function updateManifestFile(relPath, operation) {
|
|
|
708
688
|
return modified;
|
|
709
689
|
}
|
|
710
690
|
async function updateTextFile(relPath, operation) {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
691
|
+
const { cwd } = operation.options;
|
|
692
|
+
const { oldVersion, newVersion } = operation.state;
|
|
693
|
+
const modified = false;
|
|
694
|
+
const file = await readTextFile(relPath, cwd);
|
|
715
695
|
if (file.data.includes(oldVersion)) {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
file.data = file.data.replace(replacePattern,
|
|
696
|
+
const sanitizedVersion = oldVersion.replace(/(\W)/g, "\\$1");
|
|
697
|
+
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
|
|
698
|
+
file.data = file.data.replace(replacePattern, `$1${newVersion}`);
|
|
719
699
|
await writeTextFile(file);
|
|
720
700
|
return true;
|
|
721
701
|
}
|
|
@@ -723,14 +703,34 @@ async function updateTextFile(relPath, operation) {
|
|
|
723
703
|
}
|
|
724
704
|
|
|
725
705
|
// src/version-bump.ts
|
|
726
|
-
var import_log_symbols = __toESM(require_log_symbols());
|
|
727
706
|
async function versionBump(arg = {}) {
|
|
728
|
-
if (typeof arg === "string")
|
|
707
|
+
if (typeof arg === "string")
|
|
729
708
|
arg = { release: arg };
|
|
730
|
-
|
|
731
|
-
let operation = await Operation.start(arg);
|
|
709
|
+
const operation = await Operation.start(arg);
|
|
732
710
|
await getOldVersion(operation);
|
|
733
711
|
await getNewVersion(operation);
|
|
712
|
+
if (arg.confirm) {
|
|
713
|
+
console.log();
|
|
714
|
+
console.log(` files ${operation.options.files.map((i) => (0, import_chalk2.bold)(i)).join(", ")}`);
|
|
715
|
+
if (operation.options.commit)
|
|
716
|
+
console.log(` commit ${(0, import_chalk2.bold)(formatVersionString(operation.options.commit.message, operation.state.newVersion))}`);
|
|
717
|
+
if (operation.options.tag)
|
|
718
|
+
console.log(` tag ${(0, import_chalk2.bold)(formatVersionString(operation.options.tag.name, operation.state.newVersion))}`);
|
|
719
|
+
if (operation.options.execute)
|
|
720
|
+
console.log(` execute ${(0, import_chalk2.bold)(operation.options.execute)}`);
|
|
721
|
+
if (operation.options.push)
|
|
722
|
+
console.log(` push ${(0, import_chalk2.cyan)((0, import_chalk2.bold)("yes"))}`);
|
|
723
|
+
console.log();
|
|
724
|
+
console.log(` from ${(0, import_chalk2.bold)(operation.state.oldVersion)}`);
|
|
725
|
+
console.log(` to ${(0, import_chalk2.green)((0, import_chalk2.bold)(operation.state.newVersion))}`);
|
|
726
|
+
console.log();
|
|
727
|
+
if (!await (0, import_prompts2.default)({
|
|
728
|
+
name: "yes",
|
|
729
|
+
type: "confirm",
|
|
730
|
+
message: "Bump"
|
|
731
|
+
}).then((r) => r.yes))
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
734
|
await runNpmScript("preversion" /* PreVersion */, operation);
|
|
735
735
|
await updateFiles(operation);
|
|
736
736
|
if (operation.options.execute) {
|