bumpp 7.1.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-OYIBSTEN.mjs → chunk-HM6FRF4P.mjs} +214 -186
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.js +783 -67
- package/dist/cli/index.mjs +35 -51
- package/dist/index.d.ts +225 -4
- package/dist/index.js +751 -6
- package/dist/index.mjs +11 -4
- package/package.json +31 -31
- package/dist/chunk-XF5JTHA6.js +0 -713
|
@@ -22,11 +22,13 @@ var __spreadValues = (a, b) => {
|
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
24
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
-
var __require = (x) => {
|
|
25
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
26
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
27
|
+
}) : x)(function(x) {
|
|
26
28
|
if (typeof require !== "undefined")
|
|
27
|
-
return require(
|
|
29
|
+
return require.apply(this, arguments);
|
|
28
30
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
29
|
-
};
|
|
31
|
+
});
|
|
30
32
|
var __objRest = (source, exclude) => {
|
|
31
33
|
var target = {};
|
|
32
34
|
for (var prop in source)
|
|
@@ -39,25 +41,35 @@ var __objRest = (source, exclude) => {
|
|
|
39
41
|
}
|
|
40
42
|
return target;
|
|
41
43
|
};
|
|
44
|
+
var __esm = (fn, res) => function __init() {
|
|
45
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
46
|
+
};
|
|
42
47
|
var __commonJS = (cb, mod) => function __require2() {
|
|
43
|
-
return mod || (0, cb[
|
|
48
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
44
49
|
};
|
|
45
|
-
var __reExport = (target, module, desc) => {
|
|
50
|
+
var __reExport = (target, module, copyDefault, desc) => {
|
|
46
51
|
if (module && typeof module === "object" || typeof module === "function") {
|
|
47
52
|
for (let key of __getOwnPropNames(module))
|
|
48
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
53
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
49
54
|
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
|
50
55
|
}
|
|
51
56
|
return target;
|
|
52
57
|
};
|
|
53
|
-
var
|
|
54
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default",
|
|
58
|
+
var __toESM = (module, isNodeMode) => {
|
|
59
|
+
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", !isNodeMode && module && module.__esModule ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
55
60
|
};
|
|
56
61
|
|
|
57
|
-
// node_modules/
|
|
62
|
+
// node_modules/.pnpm/tsup@5.11.9_typescript@4.5.4/node_modules/tsup/assets/esm_shims.js
|
|
63
|
+
var init_esm_shims = __esm({
|
|
64
|
+
"node_modules/.pnpm/tsup@5.11.9_typescript@4.5.4/node_modules/tsup/assets/esm_shims.js"() {
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js
|
|
58
69
|
var require_is_unicode_supported = __commonJS({
|
|
59
|
-
"node_modules/is-unicode-supported/index.js"(exports, module) {
|
|
70
|
+
"node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js"(exports, module) {
|
|
60
71
|
"use strict";
|
|
72
|
+
init_esm_shims();
|
|
61
73
|
module.exports = () => {
|
|
62
74
|
if (process.platform !== "win32") {
|
|
63
75
|
return true;
|
|
@@ -67,10 +79,11 @@ var require_is_unicode_supported = __commonJS({
|
|
|
67
79
|
}
|
|
68
80
|
});
|
|
69
81
|
|
|
70
|
-
// node_modules/log-symbols/index.js
|
|
82
|
+
// node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js
|
|
71
83
|
var require_log_symbols = __commonJS({
|
|
72
|
-
"node_modules/log-symbols/index.js"(exports, module) {
|
|
84
|
+
"node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js"(exports, module) {
|
|
73
85
|
"use strict";
|
|
86
|
+
init_esm_shims();
|
|
74
87
|
var chalk = __require("chalk");
|
|
75
88
|
var isUnicodeSupported = require_is_unicode_supported();
|
|
76
89
|
var main = {
|
|
@@ -89,10 +102,11 @@ var require_log_symbols = __commonJS({
|
|
|
89
102
|
}
|
|
90
103
|
});
|
|
91
104
|
|
|
92
|
-
// node_modules/detect-newline/index.js
|
|
105
|
+
// node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js
|
|
93
106
|
var require_detect_newline = __commonJS({
|
|
94
|
-
"node_modules/detect-newline/index.js"(exports, module) {
|
|
107
|
+
"node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js"(exports, module) {
|
|
95
108
|
"use strict";
|
|
109
|
+
init_esm_shims();
|
|
96
110
|
var detectNewline2 = (string) => {
|
|
97
111
|
if (typeof string !== "string") {
|
|
98
112
|
throw new TypeError("Expected a string");
|
|
@@ -111,6 +125,7 @@ var require_detect_newline = __commonJS({
|
|
|
111
125
|
});
|
|
112
126
|
|
|
113
127
|
// src/release-type.ts
|
|
128
|
+
init_esm_shims();
|
|
114
129
|
import { ReleaseType } from "semver";
|
|
115
130
|
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
116
131
|
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
|
|
@@ -122,42 +137,44 @@ function isReleaseType(value) {
|
|
|
122
137
|
}
|
|
123
138
|
|
|
124
139
|
// src/types/version-bump-progress.ts
|
|
125
|
-
|
|
126
|
-
(
|
|
140
|
+
init_esm_shims();
|
|
141
|
+
var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
|
|
127
142
|
ProgressEvent2["FileUpdated"] = "file updated";
|
|
128
143
|
ProgressEvent2["FileSkipped"] = "file skipped";
|
|
129
144
|
ProgressEvent2["GitCommit"] = "git commit";
|
|
130
145
|
ProgressEvent2["GitTag"] = "git tag";
|
|
131
146
|
ProgressEvent2["GitPush"] = "git push";
|
|
132
147
|
ProgressEvent2["NpmScript"] = "npm script";
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
return ProgressEvent2;
|
|
149
|
+
})(ProgressEvent || {});
|
|
150
|
+
var NpmScript = /* @__PURE__ */ ((NpmScript2) => {
|
|
151
|
+
NpmScript2["PreVersion"] = "preversion";
|
|
152
|
+
NpmScript2["Version"] = "version";
|
|
153
|
+
NpmScript2["PostVersion"] = "postversion";
|
|
154
|
+
return NpmScript2;
|
|
155
|
+
})(NpmScript || {});
|
|
140
156
|
|
|
141
157
|
// src/version-bump.ts
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
158
|
+
init_esm_shims();
|
|
159
|
+
var import_log_symbols = __toESM(require_log_symbols());
|
|
160
|
+
import * as ezSpawn3 from "@jsdevtools/ez-spawn";
|
|
161
|
+
import { bold as bold2, cyan, green as green2 } from "chalk";
|
|
162
|
+
import prompts2 from "prompts";
|
|
145
163
|
|
|
146
164
|
// src/get-new-version.ts
|
|
165
|
+
init_esm_shims();
|
|
147
166
|
import { bold, green } from "chalk";
|
|
148
167
|
import prompts from "prompts";
|
|
149
|
-
import {
|
|
150
|
-
import { SemVer } from "semver";
|
|
168
|
+
import semver, { SemVer, clean as cleanVersion, valid as isValidVersion } from "semver";
|
|
151
169
|
async function getNewVersion(operation) {
|
|
152
|
-
|
|
153
|
-
|
|
170
|
+
const { release } = operation.options;
|
|
171
|
+
const { oldVersion } = operation.state;
|
|
154
172
|
switch (release.type) {
|
|
155
173
|
case "prompt":
|
|
156
174
|
return promptForNewVersion(operation);
|
|
157
175
|
case "version":
|
|
158
|
-
let newSemVer = new SemVer(release.version, true);
|
|
159
176
|
return operation.update({
|
|
160
|
-
newVersion:
|
|
177
|
+
newVersion: new SemVer(release.version, true).version
|
|
161
178
|
});
|
|
162
179
|
default:
|
|
163
180
|
return operation.update({
|
|
@@ -167,8 +184,8 @@ async function getNewVersion(operation) {
|
|
|
167
184
|
}
|
|
168
185
|
}
|
|
169
186
|
function getNextVersion(oldVersion, bump) {
|
|
170
|
-
|
|
171
|
-
|
|
187
|
+
const oldSemVer = new SemVer(oldVersion);
|
|
188
|
+
const newSemVer = oldSemVer.inc(bump.type, bump.preid);
|
|
172
189
|
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
|
|
173
190
|
newSemVer.prerelease[1] = "1";
|
|
174
191
|
newSemVer.format();
|
|
@@ -176,33 +193,35 @@ function getNextVersion(oldVersion, bump) {
|
|
|
176
193
|
return newSemVer.version;
|
|
177
194
|
}
|
|
178
195
|
function getNextVersions(oldVersion, preid) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
196
|
+
var _a;
|
|
197
|
+
const next = {};
|
|
198
|
+
const parse = semver.parse(oldVersion);
|
|
199
|
+
if (typeof (parse == null ? void 0 : parse.prerelease[0]) === "string")
|
|
200
|
+
preid = (parse == null ? void 0 : parse.prerelease[0]) || "preid";
|
|
201
|
+
for (const type of releaseTypes)
|
|
202
|
+
next[type] = semver.inc(oldVersion, type, preid);
|
|
203
|
+
next.next = ((_a = parse == null ? void 0 : parse.prerelease) == null ? void 0 : _a.length) ? semver.inc(oldVersion, "prerelease", preid) : semver.inc(oldVersion, "patch");
|
|
183
204
|
return next;
|
|
184
205
|
}
|
|
185
206
|
async function promptForNewVersion(operation) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
answers = await prompts([
|
|
207
|
+
const { oldVersion } = operation.state;
|
|
208
|
+
const release = operation.options.release;
|
|
209
|
+
const next = getNextVersions(oldVersion, release.preid);
|
|
210
|
+
const PADDING = 13;
|
|
211
|
+
const answers = await prompts([
|
|
191
212
|
{
|
|
192
213
|
type: "autocomplete",
|
|
193
214
|
name: "release",
|
|
194
|
-
message: `Current version
|
|
195
|
-
initial: "
|
|
215
|
+
message: `Current version ${green(oldVersion)}`,
|
|
216
|
+
initial: "next",
|
|
196
217
|
choices: [
|
|
197
|
-
{ value: "major", title: "major
|
|
198
|
-
{ value: "minor", title: "minor
|
|
199
|
-
{ value: "patch", title: "patch
|
|
200
|
-
{ value: "
|
|
201
|
-
{ value: "
|
|
202
|
-
{ value: "
|
|
203
|
-
{ value: "
|
|
204
|
-
{ value: "none", title: "leave as-is - " + bold(oldVersion) },
|
|
205
|
-
{ value: "custom", title: "custom..." }
|
|
218
|
+
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${bold(next.major)}` },
|
|
219
|
+
{ value: "minor", title: `${"minor".padStart(PADDING, " ")} ${bold(next.minor)}` },
|
|
220
|
+
{ value: "patch", title: `${"patch".padStart(PADDING, " ")} ${bold(next.patch)}` },
|
|
221
|
+
{ value: "next", title: `${"next".padStart(PADDING, " ")} ${bold(next.next)}` },
|
|
222
|
+
{ value: "prerelease", title: `${"pre-release".padStart(PADDING, " ")} ${bold(next.prerelease)}` },
|
|
223
|
+
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${bold(oldVersion)}` },
|
|
224
|
+
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
|
|
206
225
|
]
|
|
207
226
|
},
|
|
208
227
|
{
|
|
@@ -216,11 +235,11 @@ async function promptForNewVersion(operation) {
|
|
|
216
235
|
}
|
|
217
236
|
]);
|
|
218
237
|
const newVersion = answers.release === "none" ? oldVersion : answers.release === "custom" ? cleanVersion(answers.custom) : next[answers.release];
|
|
219
|
-
if (!newVersion)
|
|
238
|
+
if (!newVersion)
|
|
220
239
|
process.exit(1);
|
|
221
|
-
}
|
|
222
240
|
switch (answers.release) {
|
|
223
241
|
case "custom":
|
|
242
|
+
case "next":
|
|
224
243
|
case "none":
|
|
225
244
|
return operation.update({ newVersion });
|
|
226
245
|
default:
|
|
@@ -229,14 +248,21 @@ async function promptForNewVersion(operation) {
|
|
|
229
248
|
}
|
|
230
249
|
|
|
231
250
|
// src/get-old-version.ts
|
|
251
|
+
init_esm_shims();
|
|
232
252
|
import { valid as isValidVersion2 } from "semver";
|
|
233
253
|
|
|
234
|
-
//
|
|
254
|
+
// src/fs.ts
|
|
255
|
+
init_esm_shims();
|
|
256
|
+
import fs from "fs";
|
|
257
|
+
import path from "path";
|
|
258
|
+
|
|
259
|
+
// node_modules/.pnpm/detect-indent@7.0.0/node_modules/detect-indent/index.js
|
|
260
|
+
init_esm_shims();
|
|
235
261
|
var INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
236
262
|
var INDENT_TYPE_SPACE = "space";
|
|
237
263
|
var INDENT_TYPE_TAB = "tab";
|
|
238
264
|
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
239
|
-
const indents = new Map();
|
|
265
|
+
const indents = /* @__PURE__ */ new Map();
|
|
240
266
|
let previousSize = 0;
|
|
241
267
|
let previousIndentType;
|
|
242
268
|
let key;
|
|
@@ -329,26 +355,23 @@ function detectIndent(string) {
|
|
|
329
355
|
}
|
|
330
356
|
|
|
331
357
|
// src/fs.ts
|
|
332
|
-
var import_detect_newline =
|
|
333
|
-
import fs from "fs";
|
|
334
|
-
import path from "path";
|
|
358
|
+
var import_detect_newline = __toESM(require_detect_newline());
|
|
335
359
|
async function readJsonFile(name, cwd) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
360
|
+
const file = await readTextFile(name, cwd);
|
|
361
|
+
const data = JSON.parse(file.data);
|
|
362
|
+
const indent = detectIndent(file.data).indent;
|
|
363
|
+
const newline = (0, import_detect_newline.default)(file.data);
|
|
340
364
|
return __spreadProps(__spreadValues({}, file), { data, indent, newline });
|
|
341
365
|
}
|
|
342
366
|
async function writeJsonFile(file) {
|
|
343
367
|
let json = JSON.stringify(file.data, void 0, file.indent);
|
|
344
|
-
if (file.newline)
|
|
368
|
+
if (file.newline)
|
|
345
369
|
json += file.newline;
|
|
346
|
-
}
|
|
347
370
|
return writeTextFile(__spreadProps(__spreadValues({}, file), { data: json }));
|
|
348
371
|
}
|
|
349
372
|
function readTextFile(name, cwd) {
|
|
350
373
|
return new Promise((resolve, reject) => {
|
|
351
|
-
|
|
374
|
+
const filePath = path.join(cwd, name);
|
|
352
375
|
fs.readFile(filePath, "utf8", (err, text) => {
|
|
353
376
|
if (err) {
|
|
354
377
|
reject(err);
|
|
@@ -364,33 +387,32 @@ function readTextFile(name, cwd) {
|
|
|
364
387
|
function writeTextFile(file) {
|
|
365
388
|
return new Promise((resolve, reject) => {
|
|
366
389
|
fs.writeFile(file.path, file.data, (err) => {
|
|
367
|
-
if (err)
|
|
390
|
+
if (err)
|
|
368
391
|
reject(err);
|
|
369
|
-
|
|
392
|
+
else
|
|
370
393
|
resolve();
|
|
371
|
-
}
|
|
372
394
|
});
|
|
373
395
|
});
|
|
374
396
|
}
|
|
375
397
|
|
|
376
398
|
// src/manifest.ts
|
|
399
|
+
init_esm_shims();
|
|
377
400
|
function isManifest(obj) {
|
|
378
401
|
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
379
402
|
}
|
|
380
403
|
function isOptionalString(value) {
|
|
381
|
-
|
|
404
|
+
const type = typeof value;
|
|
382
405
|
return value === null || type === "undefined" || type === "string";
|
|
383
406
|
}
|
|
384
407
|
|
|
385
408
|
// src/get-old-version.ts
|
|
386
409
|
async function getOldVersion(operation) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
if (!filesToCheck.includes("package.json"))
|
|
410
|
+
const { cwd, files } = operation.options;
|
|
411
|
+
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
412
|
+
if (!filesToCheck.includes("package.json"))
|
|
390
413
|
filesToCheck.push("package.json");
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
let version = await readVersion(file, cwd);
|
|
414
|
+
for (const file of filesToCheck) {
|
|
415
|
+
const version = await readVersion(file, cwd);
|
|
394
416
|
if (version) {
|
|
395
417
|
return operation.update({
|
|
396
418
|
oldVersionSource: file,
|
|
@@ -402,11 +424,10 @@ async function getOldVersion(operation) {
|
|
|
402
424
|
}
|
|
403
425
|
async function readVersion(file, cwd) {
|
|
404
426
|
try {
|
|
405
|
-
|
|
427
|
+
const { data: manifest } = await readJsonFile(file, cwd);
|
|
406
428
|
if (isManifest(manifest)) {
|
|
407
|
-
if (isValidVersion2(manifest.version))
|
|
429
|
+
if (isValidVersion2(manifest.version))
|
|
408
430
|
return manifest.version;
|
|
409
|
-
}
|
|
410
431
|
}
|
|
411
432
|
} catch (error) {
|
|
412
433
|
return void 0;
|
|
@@ -414,15 +435,13 @@ async function readVersion(file, cwd) {
|
|
|
414
435
|
}
|
|
415
436
|
|
|
416
437
|
// src/git.ts
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
} from "@jsdevtools/ez-spawn";
|
|
438
|
+
init_esm_shims();
|
|
439
|
+
import * as ezSpawn from "@jsdevtools/ez-spawn";
|
|
420
440
|
async function gitCommit(operation) {
|
|
421
|
-
if (!operation.options.commit)
|
|
441
|
+
if (!operation.options.commit)
|
|
422
442
|
return operation;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
let { updatedFiles, newVersion } = operation.state;
|
|
443
|
+
const { all, noVerify, message } = operation.options.commit;
|
|
444
|
+
const { updatedFiles, newVersion } = operation.state;
|
|
426
445
|
let args = [];
|
|
427
446
|
if (all) {
|
|
428
447
|
args.push("--all");
|
|
@@ -430,79 +449,75 @@ async function gitCommit(operation) {
|
|
|
430
449
|
if (noVerify) {
|
|
431
450
|
args.push("--no-verify");
|
|
432
451
|
}
|
|
433
|
-
|
|
452
|
+
const commitMessage = formatVersionString(message, newVersion);
|
|
434
453
|
args.push("--message", commitMessage);
|
|
435
|
-
if (!all)
|
|
454
|
+
if (!all)
|
|
436
455
|
args = args.concat(updatedFiles);
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return operation.update({ event: ProgressEvent.GitCommit, commitMessage });
|
|
456
|
+
await ezSpawn.async("git", ["commit", ...args]);
|
|
457
|
+
return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
|
|
440
458
|
}
|
|
441
459
|
async function gitTag(operation) {
|
|
442
|
-
if (!operation.options.tag)
|
|
460
|
+
if (!operation.options.tag)
|
|
443
461
|
return operation;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
let args = [
|
|
462
|
+
const { commit, tag } = operation.options;
|
|
463
|
+
const { newVersion } = operation.state;
|
|
464
|
+
const args = [
|
|
448
465
|
"--annotate",
|
|
449
466
|
"--message",
|
|
450
467
|
formatVersionString(commit.message, newVersion)
|
|
451
468
|
];
|
|
452
|
-
|
|
469
|
+
const tagName = formatVersionString(tag.name, newVersion);
|
|
453
470
|
args.push(tagName);
|
|
454
|
-
await async("git", ["tag", ...args]);
|
|
455
|
-
return operation.update({ event:
|
|
471
|
+
await ezSpawn.async("git", ["tag", ...args]);
|
|
472
|
+
return operation.update({ event: "git tag" /* GitTag */, tagName });
|
|
456
473
|
}
|
|
457
474
|
async function gitPush(operation) {
|
|
458
|
-
if (!operation.options.push)
|
|
475
|
+
if (!operation.options.push)
|
|
459
476
|
return operation;
|
|
460
|
-
|
|
461
|
-
await async("git", "push");
|
|
477
|
+
await ezSpawn.async("git", "push");
|
|
462
478
|
if (operation.options.tag) {
|
|
463
|
-
await async("git", ["push", "--tags"]);
|
|
479
|
+
await ezSpawn.async("git", ["push", "--tags"]);
|
|
464
480
|
}
|
|
465
|
-
return operation.update({ event:
|
|
481
|
+
return operation.update({ event: "git push" /* GitPush */ });
|
|
466
482
|
}
|
|
467
483
|
function formatVersionString(template, newVersion) {
|
|
468
|
-
if (template.includes("%s"))
|
|
484
|
+
if (template.includes("%s"))
|
|
469
485
|
return template.replace(/%s/g, newVersion);
|
|
470
|
-
|
|
486
|
+
else
|
|
471
487
|
return template + newVersion;
|
|
472
|
-
}
|
|
473
488
|
}
|
|
474
489
|
|
|
490
|
+
// src/operation.ts
|
|
491
|
+
init_esm_shims();
|
|
492
|
+
|
|
475
493
|
// src/normalize-options.ts
|
|
476
|
-
|
|
477
|
-
import { hasMagic } from "globby";
|
|
494
|
+
init_esm_shims();
|
|
495
|
+
import globby, { hasMagic } from "globby";
|
|
478
496
|
async function normalizeOptions(raw) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
497
|
+
const preid = typeof raw.preid === "string" ? raw.preid : "beta";
|
|
498
|
+
const push = Boolean(raw.push);
|
|
499
|
+
const all = Boolean(raw.all);
|
|
500
|
+
const noVerify = Boolean(raw.noVerify);
|
|
501
|
+
const cwd = raw.cwd || process.cwd();
|
|
502
|
+
const ignoreScripts = Boolean(raw.ignoreScripts);
|
|
503
|
+
const execute = raw.execute;
|
|
486
504
|
let release;
|
|
487
|
-
if (!raw.release || raw.release === "prompt")
|
|
505
|
+
if (!raw.release || raw.release === "prompt")
|
|
488
506
|
release = { type: "prompt", preid };
|
|
489
|
-
|
|
507
|
+
else if (isReleaseType(raw.release))
|
|
490
508
|
release = { type: raw.release, preid };
|
|
491
|
-
|
|
509
|
+
else
|
|
492
510
|
release = { type: "version", version: raw.release };
|
|
493
|
-
}
|
|
494
511
|
let tag;
|
|
495
|
-
if (typeof raw.tag === "string")
|
|
512
|
+
if (typeof raw.tag === "string")
|
|
496
513
|
tag = { name: raw.tag };
|
|
497
|
-
|
|
514
|
+
else if (raw.tag)
|
|
498
515
|
tag = { name: "v" };
|
|
499
|
-
}
|
|
500
516
|
let commit;
|
|
501
|
-
if (typeof raw.commit === "string")
|
|
517
|
+
if (typeof raw.commit === "string")
|
|
502
518
|
commit = { all, noVerify, message: raw.commit };
|
|
503
|
-
|
|
504
|
-
commit = { all, noVerify, message: "release v" };
|
|
505
|
-
}
|
|
519
|
+
else if (raw.commit || tag || push)
|
|
520
|
+
commit = { all, noVerify, message: "chore: release v" };
|
|
506
521
|
let files;
|
|
507
522
|
if (Array.isArray(raw.files) && raw.files.length > 0) {
|
|
508
523
|
files = await strictGlobMatches(raw.files, { cwd });
|
|
@@ -516,37 +531,32 @@ async function normalizeOptions(raw) {
|
|
|
516
531
|
ui = { input: process.stdin, output: process.stdout };
|
|
517
532
|
} else {
|
|
518
533
|
let _a = raw.interface, { input, output } = _a, other = __objRest(_a, ["input", "output"]);
|
|
519
|
-
if (input === true || input !== false && !input)
|
|
534
|
+
if (input === true || input !== false && !input)
|
|
520
535
|
input = process.stdin;
|
|
521
|
-
|
|
522
|
-
if (output === true || output !== false && !output) {
|
|
536
|
+
if (output === true || output !== false && !output)
|
|
523
537
|
output = process.stdout;
|
|
524
|
-
}
|
|
525
538
|
ui = __spreadValues({ input, output }, other);
|
|
526
539
|
}
|
|
527
|
-
if (release.type === "prompt" && !(ui.input && ui.output))
|
|
540
|
+
if (release.type === "prompt" && !(ui.input && ui.output))
|
|
528
541
|
throw new Error("Cannot prompt for the version number because input or output has been disabled.");
|
|
529
|
-
}
|
|
530
542
|
return { release, commit, tag, push, files, cwd, interface: ui, ignoreScripts, execute };
|
|
531
543
|
}
|
|
532
544
|
async function strictGlobMatches(files, options) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
for (
|
|
536
|
-
for (
|
|
545
|
+
const matches = await Promise.all(files.map((file) => strictGlobMatch(file, options)));
|
|
546
|
+
const matchedFiles = /* @__PURE__ */ new Set();
|
|
547
|
+
for (const match of matches) {
|
|
548
|
+
for (const file of match)
|
|
537
549
|
matchedFiles.add(file);
|
|
538
|
-
}
|
|
539
550
|
}
|
|
540
551
|
return [...matchedFiles];
|
|
541
552
|
}
|
|
542
553
|
async function strictGlobMatch(file, options) {
|
|
543
|
-
|
|
554
|
+
const matches = await globby(file, options);
|
|
544
555
|
if (matches.length === 0) {
|
|
545
|
-
if (hasMagic(file))
|
|
556
|
+
if (hasMagic(file))
|
|
546
557
|
throw new Error(`Could not find any files matching "${file}".`);
|
|
547
|
-
|
|
558
|
+
else
|
|
548
559
|
throw new Error(`Could not find file: ${file}.`);
|
|
549
|
-
}
|
|
550
560
|
}
|
|
551
561
|
return matches.sort();
|
|
552
562
|
}
|
|
@@ -568,8 +578,8 @@ var Operation = class {
|
|
|
568
578
|
this._progress = progress;
|
|
569
579
|
}
|
|
570
580
|
get results() {
|
|
571
|
-
|
|
572
|
-
|
|
581
|
+
const options = this.options;
|
|
582
|
+
const state = this.state;
|
|
573
583
|
return {
|
|
574
584
|
release: state.release,
|
|
575
585
|
oldVersion: state.oldVersion,
|
|
@@ -581,7 +591,7 @@ var Operation = class {
|
|
|
581
591
|
};
|
|
582
592
|
}
|
|
583
593
|
static async start(input) {
|
|
584
|
-
|
|
594
|
+
const options = await normalizeOptions(input);
|
|
585
595
|
return new Operation(options, input.progress);
|
|
586
596
|
}
|
|
587
597
|
update(_a) {
|
|
@@ -595,44 +605,41 @@ var Operation = class {
|
|
|
595
605
|
};
|
|
596
606
|
|
|
597
607
|
// src/run-npm-script.ts
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
} from "@jsdevtools/ez-spawn";
|
|
608
|
+
init_esm_shims();
|
|
609
|
+
import * as ezSpawn2 from "@jsdevtools/ez-spawn";
|
|
601
610
|
async function runNpmScript(script, operation) {
|
|
602
|
-
|
|
611
|
+
const { cwd, ignoreScripts } = operation.options;
|
|
603
612
|
if (!ignoreScripts) {
|
|
604
|
-
|
|
613
|
+
const { data: manifest } = await readJsonFile("package.json", cwd);
|
|
605
614
|
if (isManifest(manifest) && hasScript(manifest, script)) {
|
|
606
|
-
await
|
|
607
|
-
operation.update({ event:
|
|
615
|
+
await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
|
|
616
|
+
operation.update({ event: "npm script" /* NpmScript */, script });
|
|
608
617
|
}
|
|
609
618
|
}
|
|
610
619
|
return operation;
|
|
611
620
|
}
|
|
612
621
|
function hasScript(manifest, script) {
|
|
613
|
-
|
|
614
|
-
if (scripts && typeof scripts === "object")
|
|
622
|
+
const scripts = manifest.scripts;
|
|
623
|
+
if (scripts && typeof scripts === "object")
|
|
615
624
|
return Boolean(scripts[script]);
|
|
616
|
-
}
|
|
617
625
|
return false;
|
|
618
626
|
}
|
|
619
627
|
|
|
620
628
|
// src/update-files.ts
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
} from "path";
|
|
629
|
+
init_esm_shims();
|
|
630
|
+
import * as path2 from "path";
|
|
624
631
|
async function updateFiles(operation) {
|
|
625
|
-
|
|
626
|
-
for (
|
|
627
|
-
|
|
632
|
+
const { files } = operation.options;
|
|
633
|
+
for (const relPath of files) {
|
|
634
|
+
const modified = await updateFile(relPath, operation);
|
|
628
635
|
if (modified) {
|
|
629
636
|
operation.update({
|
|
630
|
-
event:
|
|
637
|
+
event: "file updated" /* FileUpdated */,
|
|
631
638
|
updatedFiles: operation.state.updatedFiles.concat(relPath)
|
|
632
639
|
});
|
|
633
640
|
} else {
|
|
634
641
|
operation.update({
|
|
635
|
-
event:
|
|
642
|
+
event: "file skipped" /* FileSkipped */,
|
|
636
643
|
skippedFiles: operation.state.skippedFiles.concat(relPath)
|
|
637
644
|
});
|
|
638
645
|
}
|
|
@@ -640,7 +647,7 @@ async function updateFiles(operation) {
|
|
|
640
647
|
return operation;
|
|
641
648
|
}
|
|
642
649
|
async function updateFile(relPath, operation) {
|
|
643
|
-
|
|
650
|
+
const name = path2.basename(relPath).trim().toLowerCase();
|
|
644
651
|
switch (name) {
|
|
645
652
|
case "package.json":
|
|
646
653
|
case "package-lock.json":
|
|
@@ -652,10 +659,10 @@ async function updateFile(relPath, operation) {
|
|
|
652
659
|
}
|
|
653
660
|
}
|
|
654
661
|
async function updateManifestFile(relPath, operation) {
|
|
655
|
-
|
|
656
|
-
|
|
662
|
+
const { cwd } = operation.options;
|
|
663
|
+
const { newVersion } = operation.state;
|
|
657
664
|
let modified = false;
|
|
658
|
-
|
|
665
|
+
const file = await readJsonFile(relPath, cwd);
|
|
659
666
|
if (isManifest(file.data) && file.data.version !== newVersion) {
|
|
660
667
|
file.data.version = newVersion;
|
|
661
668
|
await writeJsonFile(file);
|
|
@@ -664,14 +671,14 @@ async function updateManifestFile(relPath, operation) {
|
|
|
664
671
|
return modified;
|
|
665
672
|
}
|
|
666
673
|
async function updateTextFile(relPath, operation) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
674
|
+
const { cwd } = operation.options;
|
|
675
|
+
const { oldVersion, newVersion } = operation.state;
|
|
676
|
+
const modified = false;
|
|
677
|
+
const file = await readTextFile(relPath, cwd);
|
|
671
678
|
if (file.data.includes(oldVersion)) {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
file.data = file.data.replace(replacePattern,
|
|
679
|
+
const sanitizedVersion = oldVersion.replace(/(\W)/g, "\\$1");
|
|
680
|
+
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
|
|
681
|
+
file.data = file.data.replace(replacePattern, `$1${newVersion}`);
|
|
675
682
|
await writeTextFile(file);
|
|
676
683
|
return true;
|
|
677
684
|
}
|
|
@@ -679,35 +686,56 @@ async function updateTextFile(relPath, operation) {
|
|
|
679
686
|
}
|
|
680
687
|
|
|
681
688
|
// src/version-bump.ts
|
|
682
|
-
var import_log_symbols = __toModule(require_log_symbols());
|
|
683
689
|
async function versionBump(arg = {}) {
|
|
684
|
-
if (typeof arg === "string")
|
|
690
|
+
if (typeof arg === "string")
|
|
685
691
|
arg = { release: arg };
|
|
686
|
-
|
|
687
|
-
let operation = await Operation.start(arg);
|
|
692
|
+
const operation = await Operation.start(arg);
|
|
688
693
|
await getOldVersion(operation);
|
|
689
694
|
await getNewVersion(operation);
|
|
690
|
-
|
|
695
|
+
if (arg.confirm) {
|
|
696
|
+
console.log();
|
|
697
|
+
console.log(` files ${operation.options.files.map((i) => bold2(i)).join(", ")}`);
|
|
698
|
+
if (operation.options.commit)
|
|
699
|
+
console.log(` commit ${bold2(formatVersionString(operation.options.commit.message, operation.state.newVersion))}`);
|
|
700
|
+
if (operation.options.tag)
|
|
701
|
+
console.log(` tag ${bold2(formatVersionString(operation.options.tag.name, operation.state.newVersion))}`);
|
|
702
|
+
if (operation.options.execute)
|
|
703
|
+
console.log(` execute ${bold2(operation.options.execute)}`);
|
|
704
|
+
if (operation.options.push)
|
|
705
|
+
console.log(` push ${cyan(bold2("yes"))}`);
|
|
706
|
+
console.log();
|
|
707
|
+
console.log(` from ${bold2(operation.state.oldVersion)}`);
|
|
708
|
+
console.log(` to ${green2(bold2(operation.state.newVersion))}`);
|
|
709
|
+
console.log();
|
|
710
|
+
if (!await prompts2({
|
|
711
|
+
name: "yes",
|
|
712
|
+
type: "confirm",
|
|
713
|
+
message: "Bump"
|
|
714
|
+
}).then((r) => r.yes))
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
await runNpmScript("preversion" /* PreVersion */, operation);
|
|
691
718
|
await updateFiles(operation);
|
|
692
719
|
if (operation.options.execute) {
|
|
693
720
|
console.log(import_log_symbols.info, "Executing script", operation.options.execute);
|
|
694
|
-
await
|
|
721
|
+
await ezSpawn3.async(operation.options.execute, { stdio: "inherit" });
|
|
695
722
|
console.log(import_log_symbols.success, "Script finished");
|
|
696
723
|
}
|
|
697
|
-
await runNpmScript(
|
|
724
|
+
await runNpmScript("version" /* Version */, operation);
|
|
698
725
|
await gitCommit(operation);
|
|
699
726
|
await gitTag(operation);
|
|
700
|
-
await runNpmScript(
|
|
727
|
+
await runNpmScript("postversion" /* PostVersion */, operation);
|
|
701
728
|
await gitPush(operation);
|
|
702
729
|
return operation.results;
|
|
703
730
|
}
|
|
704
731
|
|
|
705
732
|
export {
|
|
706
|
-
|
|
733
|
+
__toESM,
|
|
734
|
+
init_esm_shims,
|
|
735
|
+
require_log_symbols,
|
|
707
736
|
ReleaseType,
|
|
708
737
|
isReleaseType,
|
|
709
738
|
ProgressEvent,
|
|
710
739
|
NpmScript,
|
|
711
|
-
require_log_symbols,
|
|
712
740
|
versionBump
|
|
713
741
|
};
|