bumpp 8.0.0 → 8.2.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/LICENSE +1 -0
- package/README.md +0 -269
- package/bin/bumpp.js +1 -1
- package/dist/chunk-DW6HTJ47.mjs +2281 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1600 -149
- package/dist/cli/index.mjs +8 -88
- package/dist/index.d.ts +104 -1
- package/dist/index.js +1597 -56
- package/dist/index.mjs +5 -3
- package/package.json +14 -17
- package/dist/chunk-HM6FRF4P.mjs +0 -741
package/dist/chunk-HM6FRF4P.mjs
DELETED
|
@@ -1,741 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
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) {
|
|
28
|
-
if (typeof require !== "undefined")
|
|
29
|
-
return require.apply(this, arguments);
|
|
30
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
31
|
-
});
|
|
32
|
-
var __objRest = (source, exclude) => {
|
|
33
|
-
var target = {};
|
|
34
|
-
for (var prop in source)
|
|
35
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
36
|
-
target[prop] = source[prop];
|
|
37
|
-
if (source != null && __getOwnPropSymbols)
|
|
38
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
39
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
40
|
-
target[prop] = source[prop];
|
|
41
|
-
}
|
|
42
|
-
return target;
|
|
43
|
-
};
|
|
44
|
-
var __esm = (fn, res) => function __init() {
|
|
45
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
46
|
-
};
|
|
47
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
48
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
49
|
-
};
|
|
50
|
-
var __reExport = (target, module, copyDefault, desc) => {
|
|
51
|
-
if (module && typeof module === "object" || typeof module === "function") {
|
|
52
|
-
for (let key of __getOwnPropNames(module))
|
|
53
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
54
|
-
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
};
|
|
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);
|
|
60
|
-
};
|
|
61
|
-
|
|
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
|
|
69
|
-
var require_is_unicode_supported = __commonJS({
|
|
70
|
-
"node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js"(exports, module) {
|
|
71
|
-
"use strict";
|
|
72
|
-
init_esm_shims();
|
|
73
|
-
module.exports = () => {
|
|
74
|
-
if (process.platform !== "win32") {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty";
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js
|
|
83
|
-
var require_log_symbols = __commonJS({
|
|
84
|
-
"node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js"(exports, module) {
|
|
85
|
-
"use strict";
|
|
86
|
-
init_esm_shims();
|
|
87
|
-
var chalk = __require("chalk");
|
|
88
|
-
var isUnicodeSupported = require_is_unicode_supported();
|
|
89
|
-
var main = {
|
|
90
|
-
info: chalk.blue("\u2139"),
|
|
91
|
-
success: chalk.green("\u2714"),
|
|
92
|
-
warning: chalk.yellow("\u26A0"),
|
|
93
|
-
error: chalk.red("\u2716")
|
|
94
|
-
};
|
|
95
|
-
var fallback = {
|
|
96
|
-
info: chalk.blue("i"),
|
|
97
|
-
success: chalk.green("\u221A"),
|
|
98
|
-
warning: chalk.yellow("\u203C"),
|
|
99
|
-
error: chalk.red("\xD7")
|
|
100
|
-
};
|
|
101
|
-
module.exports = isUnicodeSupported() ? main : fallback;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js
|
|
106
|
-
var require_detect_newline = __commonJS({
|
|
107
|
-
"node_modules/.pnpm/detect-newline@3.1.0/node_modules/detect-newline/index.js"(exports, module) {
|
|
108
|
-
"use strict";
|
|
109
|
-
init_esm_shims();
|
|
110
|
-
var detectNewline2 = (string) => {
|
|
111
|
-
if (typeof string !== "string") {
|
|
112
|
-
throw new TypeError("Expected a string");
|
|
113
|
-
}
|
|
114
|
-
const newlines = string.match(/(?:\r?\n)/g) || [];
|
|
115
|
-
if (newlines.length === 0) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const crlf = newlines.filter((newline) => newline === "\r\n").length;
|
|
119
|
-
const lf = newlines.length - crlf;
|
|
120
|
-
return crlf > lf ? "\r\n" : "\n";
|
|
121
|
-
};
|
|
122
|
-
module.exports = detectNewline2;
|
|
123
|
-
module.exports.graceful = (string) => typeof string === "string" && detectNewline2(string) || "\n";
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// src/release-type.ts
|
|
128
|
-
init_esm_shims();
|
|
129
|
-
import { ReleaseType } from "semver";
|
|
130
|
-
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
131
|
-
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
|
|
132
|
-
function isPrerelease(value) {
|
|
133
|
-
return prereleaseTypes.includes(value);
|
|
134
|
-
}
|
|
135
|
-
function isReleaseType(value) {
|
|
136
|
-
return releaseTypes.includes(value);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/types/version-bump-progress.ts
|
|
140
|
-
init_esm_shims();
|
|
141
|
-
var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
|
|
142
|
-
ProgressEvent2["FileUpdated"] = "file updated";
|
|
143
|
-
ProgressEvent2["FileSkipped"] = "file skipped";
|
|
144
|
-
ProgressEvent2["GitCommit"] = "git commit";
|
|
145
|
-
ProgressEvent2["GitTag"] = "git tag";
|
|
146
|
-
ProgressEvent2["GitPush"] = "git push";
|
|
147
|
-
ProgressEvent2["NpmScript"] = "npm script";
|
|
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 || {});
|
|
156
|
-
|
|
157
|
-
// src/version-bump.ts
|
|
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";
|
|
163
|
-
|
|
164
|
-
// src/get-new-version.ts
|
|
165
|
-
init_esm_shims();
|
|
166
|
-
import { bold, green } from "chalk";
|
|
167
|
-
import prompts from "prompts";
|
|
168
|
-
import semver, { SemVer, clean as cleanVersion, valid as isValidVersion } from "semver";
|
|
169
|
-
async function getNewVersion(operation) {
|
|
170
|
-
const { release } = operation.options;
|
|
171
|
-
const { oldVersion } = operation.state;
|
|
172
|
-
switch (release.type) {
|
|
173
|
-
case "prompt":
|
|
174
|
-
return promptForNewVersion(operation);
|
|
175
|
-
case "version":
|
|
176
|
-
return operation.update({
|
|
177
|
-
newVersion: new SemVer(release.version, true).version
|
|
178
|
-
});
|
|
179
|
-
default:
|
|
180
|
-
return operation.update({
|
|
181
|
-
release: release.type,
|
|
182
|
-
newVersion: getNextVersion(oldVersion, release)
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function getNextVersion(oldVersion, bump) {
|
|
187
|
-
const oldSemVer = new SemVer(oldVersion);
|
|
188
|
-
const newSemVer = oldSemVer.inc(bump.type, bump.preid);
|
|
189
|
-
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
|
|
190
|
-
newSemVer.prerelease[1] = "1";
|
|
191
|
-
newSemVer.format();
|
|
192
|
-
}
|
|
193
|
-
return newSemVer.version;
|
|
194
|
-
}
|
|
195
|
-
function getNextVersions(oldVersion, preid) {
|
|
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");
|
|
204
|
-
return next;
|
|
205
|
-
}
|
|
206
|
-
async function promptForNewVersion(operation) {
|
|
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([
|
|
212
|
-
{
|
|
213
|
-
type: "autocomplete",
|
|
214
|
-
name: "release",
|
|
215
|
-
message: `Current version ${green(oldVersion)}`,
|
|
216
|
-
initial: "next",
|
|
217
|
-
choices: [
|
|
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, " ") }
|
|
225
|
-
]
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
type: (prev) => prev === "custom" ? "text" : null,
|
|
229
|
-
name: "custom",
|
|
230
|
-
message: "Enter the new version number:",
|
|
231
|
-
initial: oldVersion,
|
|
232
|
-
validate: (custom) => {
|
|
233
|
-
return isValidVersion(custom) ? true : "That's not a valid version number";
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
]);
|
|
237
|
-
const newVersion = answers.release === "none" ? oldVersion : answers.release === "custom" ? cleanVersion(answers.custom) : next[answers.release];
|
|
238
|
-
if (!newVersion)
|
|
239
|
-
process.exit(1);
|
|
240
|
-
switch (answers.release) {
|
|
241
|
-
case "custom":
|
|
242
|
-
case "next":
|
|
243
|
-
case "none":
|
|
244
|
-
return operation.update({ newVersion });
|
|
245
|
-
default:
|
|
246
|
-
return operation.update({ release: answers.release, newVersion });
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// src/get-old-version.ts
|
|
251
|
-
init_esm_shims();
|
|
252
|
-
import { valid as isValidVersion2 } from "semver";
|
|
253
|
-
|
|
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();
|
|
261
|
-
var INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
262
|
-
var INDENT_TYPE_SPACE = "space";
|
|
263
|
-
var INDENT_TYPE_TAB = "tab";
|
|
264
|
-
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
265
|
-
const indents = /* @__PURE__ */ new Map();
|
|
266
|
-
let previousSize = 0;
|
|
267
|
-
let previousIndentType;
|
|
268
|
-
let key;
|
|
269
|
-
for (const line of string.split(/\n/g)) {
|
|
270
|
-
if (!line) {
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
let indent;
|
|
274
|
-
let indentType;
|
|
275
|
-
let weight;
|
|
276
|
-
let entry;
|
|
277
|
-
const matches = line.match(INDENT_REGEX);
|
|
278
|
-
if (matches === null) {
|
|
279
|
-
previousSize = 0;
|
|
280
|
-
previousIndentType = "";
|
|
281
|
-
} else {
|
|
282
|
-
indent = matches[0].length;
|
|
283
|
-
indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
284
|
-
if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
if (indentType !== previousIndentType) {
|
|
288
|
-
previousSize = 0;
|
|
289
|
-
}
|
|
290
|
-
previousIndentType = indentType;
|
|
291
|
-
weight = 0;
|
|
292
|
-
const indentDifference = indent - previousSize;
|
|
293
|
-
previousSize = indent;
|
|
294
|
-
if (indentDifference === 0) {
|
|
295
|
-
weight++;
|
|
296
|
-
} else {
|
|
297
|
-
const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
|
|
298
|
-
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
299
|
-
}
|
|
300
|
-
entry = indents.get(key);
|
|
301
|
-
entry = entry === void 0 ? [1, 0] : [++entry[0], entry[1] + weight];
|
|
302
|
-
indents.set(key, entry);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return indents;
|
|
306
|
-
}
|
|
307
|
-
function encodeIndentsKey(indentType, indentAmount) {
|
|
308
|
-
const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
|
|
309
|
-
return typeCharacter + String(indentAmount);
|
|
310
|
-
}
|
|
311
|
-
function decodeIndentsKey(indentsKey) {
|
|
312
|
-
const keyHasTypeSpace = indentsKey[0] === "s";
|
|
313
|
-
const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
314
|
-
const amount = Number(indentsKey.slice(1));
|
|
315
|
-
return { type, amount };
|
|
316
|
-
}
|
|
317
|
-
function getMostUsedKey(indents) {
|
|
318
|
-
let result;
|
|
319
|
-
let maxUsed = 0;
|
|
320
|
-
let maxWeight = 0;
|
|
321
|
-
for (const [key, [usedCount, weight]] of indents) {
|
|
322
|
-
if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
|
|
323
|
-
maxUsed = usedCount;
|
|
324
|
-
maxWeight = weight;
|
|
325
|
-
result = key;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return result;
|
|
329
|
-
}
|
|
330
|
-
function makeIndentString(type, amount) {
|
|
331
|
-
const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
|
|
332
|
-
return indentCharacter.repeat(amount);
|
|
333
|
-
}
|
|
334
|
-
function detectIndent(string) {
|
|
335
|
-
if (typeof string !== "string") {
|
|
336
|
-
throw new TypeError("Expected a string");
|
|
337
|
-
}
|
|
338
|
-
let indents = makeIndentsMap(string, true);
|
|
339
|
-
if (indents.size === 0) {
|
|
340
|
-
indents = makeIndentsMap(string, false);
|
|
341
|
-
}
|
|
342
|
-
const keyOfMostUsedIndent = getMostUsedKey(indents);
|
|
343
|
-
let type;
|
|
344
|
-
let amount = 0;
|
|
345
|
-
let indent = "";
|
|
346
|
-
if (keyOfMostUsedIndent !== void 0) {
|
|
347
|
-
({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
|
|
348
|
-
indent = makeIndentString(type, amount);
|
|
349
|
-
}
|
|
350
|
-
return {
|
|
351
|
-
amount,
|
|
352
|
-
type,
|
|
353
|
-
indent
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// src/fs.ts
|
|
358
|
-
var import_detect_newline = __toESM(require_detect_newline());
|
|
359
|
-
async function readJsonFile(name, cwd) {
|
|
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);
|
|
364
|
-
return __spreadProps(__spreadValues({}, file), { data, indent, newline });
|
|
365
|
-
}
|
|
366
|
-
async function writeJsonFile(file) {
|
|
367
|
-
let json = JSON.stringify(file.data, void 0, file.indent);
|
|
368
|
-
if (file.newline)
|
|
369
|
-
json += file.newline;
|
|
370
|
-
return writeTextFile(__spreadProps(__spreadValues({}, file), { data: json }));
|
|
371
|
-
}
|
|
372
|
-
function readTextFile(name, cwd) {
|
|
373
|
-
return new Promise((resolve, reject) => {
|
|
374
|
-
const filePath = path.join(cwd, name);
|
|
375
|
-
fs.readFile(filePath, "utf8", (err, text) => {
|
|
376
|
-
if (err) {
|
|
377
|
-
reject(err);
|
|
378
|
-
} else {
|
|
379
|
-
resolve({
|
|
380
|
-
path: filePath,
|
|
381
|
-
data: text
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
function writeTextFile(file) {
|
|
388
|
-
return new Promise((resolve, reject) => {
|
|
389
|
-
fs.writeFile(file.path, file.data, (err) => {
|
|
390
|
-
if (err)
|
|
391
|
-
reject(err);
|
|
392
|
-
else
|
|
393
|
-
resolve();
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// src/manifest.ts
|
|
399
|
-
init_esm_shims();
|
|
400
|
-
function isManifest(obj) {
|
|
401
|
-
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
402
|
-
}
|
|
403
|
-
function isOptionalString(value) {
|
|
404
|
-
const type = typeof value;
|
|
405
|
-
return value === null || type === "undefined" || type === "string";
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// src/get-old-version.ts
|
|
409
|
-
async function getOldVersion(operation) {
|
|
410
|
-
const { cwd, files } = operation.options;
|
|
411
|
-
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
412
|
-
if (!filesToCheck.includes("package.json"))
|
|
413
|
-
filesToCheck.push("package.json");
|
|
414
|
-
for (const file of filesToCheck) {
|
|
415
|
-
const version = await readVersion(file, cwd);
|
|
416
|
-
if (version) {
|
|
417
|
-
return operation.update({
|
|
418
|
-
oldVersionSource: file,
|
|
419
|
-
oldVersion: version
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
throw new Error(`Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`);
|
|
424
|
-
}
|
|
425
|
-
async function readVersion(file, cwd) {
|
|
426
|
-
try {
|
|
427
|
-
const { data: manifest } = await readJsonFile(file, cwd);
|
|
428
|
-
if (isManifest(manifest)) {
|
|
429
|
-
if (isValidVersion2(manifest.version))
|
|
430
|
-
return manifest.version;
|
|
431
|
-
}
|
|
432
|
-
} catch (error) {
|
|
433
|
-
return void 0;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// src/git.ts
|
|
438
|
-
init_esm_shims();
|
|
439
|
-
import * as ezSpawn from "@jsdevtools/ez-spawn";
|
|
440
|
-
async function gitCommit(operation) {
|
|
441
|
-
if (!operation.options.commit)
|
|
442
|
-
return operation;
|
|
443
|
-
const { all, noVerify, message } = operation.options.commit;
|
|
444
|
-
const { updatedFiles, newVersion } = operation.state;
|
|
445
|
-
let args = [];
|
|
446
|
-
if (all) {
|
|
447
|
-
args.push("--all");
|
|
448
|
-
}
|
|
449
|
-
if (noVerify) {
|
|
450
|
-
args.push("--no-verify");
|
|
451
|
-
}
|
|
452
|
-
const commitMessage = formatVersionString(message, newVersion);
|
|
453
|
-
args.push("--message", commitMessage);
|
|
454
|
-
if (!all)
|
|
455
|
-
args = args.concat(updatedFiles);
|
|
456
|
-
await ezSpawn.async("git", ["commit", ...args]);
|
|
457
|
-
return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
|
|
458
|
-
}
|
|
459
|
-
async function gitTag(operation) {
|
|
460
|
-
if (!operation.options.tag)
|
|
461
|
-
return operation;
|
|
462
|
-
const { commit, tag } = operation.options;
|
|
463
|
-
const { newVersion } = operation.state;
|
|
464
|
-
const args = [
|
|
465
|
-
"--annotate",
|
|
466
|
-
"--message",
|
|
467
|
-
formatVersionString(commit.message, newVersion)
|
|
468
|
-
];
|
|
469
|
-
const tagName = formatVersionString(tag.name, newVersion);
|
|
470
|
-
args.push(tagName);
|
|
471
|
-
await ezSpawn.async("git", ["tag", ...args]);
|
|
472
|
-
return operation.update({ event: "git tag" /* GitTag */, tagName });
|
|
473
|
-
}
|
|
474
|
-
async function gitPush(operation) {
|
|
475
|
-
if (!operation.options.push)
|
|
476
|
-
return operation;
|
|
477
|
-
await ezSpawn.async("git", "push");
|
|
478
|
-
if (operation.options.tag) {
|
|
479
|
-
await ezSpawn.async("git", ["push", "--tags"]);
|
|
480
|
-
}
|
|
481
|
-
return operation.update({ event: "git push" /* GitPush */ });
|
|
482
|
-
}
|
|
483
|
-
function formatVersionString(template, newVersion) {
|
|
484
|
-
if (template.includes("%s"))
|
|
485
|
-
return template.replace(/%s/g, newVersion);
|
|
486
|
-
else
|
|
487
|
-
return template + newVersion;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// src/operation.ts
|
|
491
|
-
init_esm_shims();
|
|
492
|
-
|
|
493
|
-
// src/normalize-options.ts
|
|
494
|
-
init_esm_shims();
|
|
495
|
-
import globby, { hasMagic } from "globby";
|
|
496
|
-
async function normalizeOptions(raw) {
|
|
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;
|
|
504
|
-
let release;
|
|
505
|
-
if (!raw.release || raw.release === "prompt")
|
|
506
|
-
release = { type: "prompt", preid };
|
|
507
|
-
else if (isReleaseType(raw.release))
|
|
508
|
-
release = { type: raw.release, preid };
|
|
509
|
-
else
|
|
510
|
-
release = { type: "version", version: raw.release };
|
|
511
|
-
let tag;
|
|
512
|
-
if (typeof raw.tag === "string")
|
|
513
|
-
tag = { name: raw.tag };
|
|
514
|
-
else if (raw.tag)
|
|
515
|
-
tag = { name: "v" };
|
|
516
|
-
let commit;
|
|
517
|
-
if (typeof raw.commit === "string")
|
|
518
|
-
commit = { all, noVerify, message: raw.commit };
|
|
519
|
-
else if (raw.commit || tag || push)
|
|
520
|
-
commit = { all, noVerify, message: "chore: release v" };
|
|
521
|
-
let files;
|
|
522
|
-
if (Array.isArray(raw.files) && raw.files.length > 0) {
|
|
523
|
-
files = await strictGlobMatches(raw.files, { cwd });
|
|
524
|
-
} else {
|
|
525
|
-
files = await globby(["package.json", "package-lock.json"], { cwd });
|
|
526
|
-
}
|
|
527
|
-
let ui;
|
|
528
|
-
if (raw.interface === false) {
|
|
529
|
-
ui = { input: false, outut: false };
|
|
530
|
-
} else if (raw.interface === true || !raw.interface) {
|
|
531
|
-
ui = { input: process.stdin, output: process.stdout };
|
|
532
|
-
} else {
|
|
533
|
-
let _a = raw.interface, { input, output } = _a, other = __objRest(_a, ["input", "output"]);
|
|
534
|
-
if (input === true || input !== false && !input)
|
|
535
|
-
input = process.stdin;
|
|
536
|
-
if (output === true || output !== false && !output)
|
|
537
|
-
output = process.stdout;
|
|
538
|
-
ui = __spreadValues({ input, output }, other);
|
|
539
|
-
}
|
|
540
|
-
if (release.type === "prompt" && !(ui.input && ui.output))
|
|
541
|
-
throw new Error("Cannot prompt for the version number because input or output has been disabled.");
|
|
542
|
-
return { release, commit, tag, push, files, cwd, interface: ui, ignoreScripts, execute };
|
|
543
|
-
}
|
|
544
|
-
async function strictGlobMatches(files, options) {
|
|
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)
|
|
549
|
-
matchedFiles.add(file);
|
|
550
|
-
}
|
|
551
|
-
return [...matchedFiles];
|
|
552
|
-
}
|
|
553
|
-
async function strictGlobMatch(file, options) {
|
|
554
|
-
const matches = await globby(file, options);
|
|
555
|
-
if (matches.length === 0) {
|
|
556
|
-
if (hasMagic(file))
|
|
557
|
-
throw new Error(`Could not find any files matching "${file}".`);
|
|
558
|
-
else
|
|
559
|
-
throw new Error(`Could not find file: ${file}.`);
|
|
560
|
-
}
|
|
561
|
-
return matches.sort();
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// src/operation.ts
|
|
565
|
-
var Operation = class {
|
|
566
|
-
constructor(options, progress) {
|
|
567
|
-
this.state = {
|
|
568
|
-
release: void 0,
|
|
569
|
-
oldVersion: "",
|
|
570
|
-
oldVersionSource: "",
|
|
571
|
-
newVersion: "",
|
|
572
|
-
commitMessage: "",
|
|
573
|
-
tagName: "",
|
|
574
|
-
updatedFiles: [],
|
|
575
|
-
skippedFiles: []
|
|
576
|
-
};
|
|
577
|
-
this.options = options;
|
|
578
|
-
this._progress = progress;
|
|
579
|
-
}
|
|
580
|
-
get results() {
|
|
581
|
-
const options = this.options;
|
|
582
|
-
const state = this.state;
|
|
583
|
-
return {
|
|
584
|
-
release: state.release,
|
|
585
|
-
oldVersion: state.oldVersion,
|
|
586
|
-
newVersion: state.newVersion,
|
|
587
|
-
commit: options.commit ? state.commitMessage : false,
|
|
588
|
-
tag: options.tag ? state.tagName : false,
|
|
589
|
-
updatedFiles: state.updatedFiles.slice(),
|
|
590
|
-
skippedFiles: state.skippedFiles.slice()
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
static async start(input) {
|
|
594
|
-
const options = await normalizeOptions(input);
|
|
595
|
-
return new Operation(options, input.progress);
|
|
596
|
-
}
|
|
597
|
-
update(_a) {
|
|
598
|
-
var _b = _a, { event, script } = _b, newState = __objRest(_b, ["event", "script"]);
|
|
599
|
-
Object.assign(this.state, newState);
|
|
600
|
-
if (event && this._progress) {
|
|
601
|
-
this._progress(__spreadValues({ event, script }, this.results));
|
|
602
|
-
}
|
|
603
|
-
return this;
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
|
|
607
|
-
// src/run-npm-script.ts
|
|
608
|
-
init_esm_shims();
|
|
609
|
-
import * as ezSpawn2 from "@jsdevtools/ez-spawn";
|
|
610
|
-
async function runNpmScript(script, operation) {
|
|
611
|
-
const { cwd, ignoreScripts } = operation.options;
|
|
612
|
-
if (!ignoreScripts) {
|
|
613
|
-
const { data: manifest } = await readJsonFile("package.json", cwd);
|
|
614
|
-
if (isManifest(manifest) && hasScript(manifest, script)) {
|
|
615
|
-
await ezSpawn2.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
|
|
616
|
-
operation.update({ event: "npm script" /* NpmScript */, script });
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
return operation;
|
|
620
|
-
}
|
|
621
|
-
function hasScript(manifest, script) {
|
|
622
|
-
const scripts = manifest.scripts;
|
|
623
|
-
if (scripts && typeof scripts === "object")
|
|
624
|
-
return Boolean(scripts[script]);
|
|
625
|
-
return false;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// src/update-files.ts
|
|
629
|
-
init_esm_shims();
|
|
630
|
-
import * as path2 from "path";
|
|
631
|
-
async function updateFiles(operation) {
|
|
632
|
-
const { files } = operation.options;
|
|
633
|
-
for (const relPath of files) {
|
|
634
|
-
const modified = await updateFile(relPath, operation);
|
|
635
|
-
if (modified) {
|
|
636
|
-
operation.update({
|
|
637
|
-
event: "file updated" /* FileUpdated */,
|
|
638
|
-
updatedFiles: operation.state.updatedFiles.concat(relPath)
|
|
639
|
-
});
|
|
640
|
-
} else {
|
|
641
|
-
operation.update({
|
|
642
|
-
event: "file skipped" /* FileSkipped */,
|
|
643
|
-
skippedFiles: operation.state.skippedFiles.concat(relPath)
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
return operation;
|
|
648
|
-
}
|
|
649
|
-
async function updateFile(relPath, operation) {
|
|
650
|
-
const name = path2.basename(relPath).trim().toLowerCase();
|
|
651
|
-
switch (name) {
|
|
652
|
-
case "package.json":
|
|
653
|
-
case "package-lock.json":
|
|
654
|
-
case "bower.json":
|
|
655
|
-
case "component.json":
|
|
656
|
-
return updateManifestFile(relPath, operation);
|
|
657
|
-
default:
|
|
658
|
-
return updateTextFile(relPath, operation);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
async function updateManifestFile(relPath, operation) {
|
|
662
|
-
const { cwd } = operation.options;
|
|
663
|
-
const { newVersion } = operation.state;
|
|
664
|
-
let modified = false;
|
|
665
|
-
const file = await readJsonFile(relPath, cwd);
|
|
666
|
-
if (isManifest(file.data) && file.data.version !== newVersion) {
|
|
667
|
-
file.data.version = newVersion;
|
|
668
|
-
await writeJsonFile(file);
|
|
669
|
-
modified = true;
|
|
670
|
-
}
|
|
671
|
-
return modified;
|
|
672
|
-
}
|
|
673
|
-
async function updateTextFile(relPath, operation) {
|
|
674
|
-
const { cwd } = operation.options;
|
|
675
|
-
const { oldVersion, newVersion } = operation.state;
|
|
676
|
-
const modified = false;
|
|
677
|
-
const file = await readTextFile(relPath, cwd);
|
|
678
|
-
if (file.data.includes(oldVersion)) {
|
|
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}`);
|
|
682
|
-
await writeTextFile(file);
|
|
683
|
-
return true;
|
|
684
|
-
}
|
|
685
|
-
return modified;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// src/version-bump.ts
|
|
689
|
-
async function versionBump(arg = {}) {
|
|
690
|
-
if (typeof arg === "string")
|
|
691
|
-
arg = { release: arg };
|
|
692
|
-
const operation = await Operation.start(arg);
|
|
693
|
-
await getOldVersion(operation);
|
|
694
|
-
await getNewVersion(operation);
|
|
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);
|
|
718
|
-
await updateFiles(operation);
|
|
719
|
-
if (operation.options.execute) {
|
|
720
|
-
console.log(import_log_symbols.info, "Executing script", operation.options.execute);
|
|
721
|
-
await ezSpawn3.async(operation.options.execute, { stdio: "inherit" });
|
|
722
|
-
console.log(import_log_symbols.success, "Script finished");
|
|
723
|
-
}
|
|
724
|
-
await runNpmScript("version" /* Version */, operation);
|
|
725
|
-
await gitCommit(operation);
|
|
726
|
-
await gitTag(operation);
|
|
727
|
-
await runNpmScript("postversion" /* PostVersion */, operation);
|
|
728
|
-
await gitPush(operation);
|
|
729
|
-
return operation.results;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
export {
|
|
733
|
-
__toESM,
|
|
734
|
-
init_esm_shims,
|
|
735
|
-
require_log_symbols,
|
|
736
|
-
ReleaseType,
|
|
737
|
-
isReleaseType,
|
|
738
|
-
ProgressEvent,
|
|
739
|
-
NpmScript,
|
|
740
|
-
versionBump
|
|
741
|
-
};
|