bumpp 9.10.2 → 9.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-W5LZZJWM.mjs → chunk-BEM77VRK.js} +176 -251
- package/dist/cli/index.cjs +1161 -0
- package/dist/cli/index.js +44 -1126
- package/dist/index.cjs +1070 -0
- package/dist/{index.d.mts → index.d.cts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -1130
- package/package.json +7 -5
- package/dist/cli/index.mjs +0 -153
- package/dist/index.mjs +0 -23
- /package/dist/cli/{index.d.mts → index.d.cts} +0 -0
package/dist/cli/index.js
CHANGED
|
@@ -1,1111 +1,29 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 __objRest = (source, exclude) => {
|
|
25
|
-
var target = {};
|
|
26
|
-
for (var prop in source)
|
|
27
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
if (source != null && __getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
};
|
|
36
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
37
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
38
|
-
};
|
|
39
|
-
var __export = (target, all) => {
|
|
40
|
-
for (var name in all)
|
|
41
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
42
|
-
};
|
|
43
|
-
var __copyProps = (to, from, except, desc) => {
|
|
44
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
45
|
-
for (let key of __getOwnPropNames(from))
|
|
46
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
47
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
48
|
-
}
|
|
49
|
-
return to;
|
|
50
|
-
};
|
|
51
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
52
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
53
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
54
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
55
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
56
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
57
|
-
mod
|
|
58
|
-
));
|
|
59
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
60
|
-
|
|
61
|
-
// node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
62
|
-
var require_picocolors = __commonJS({
|
|
63
|
-
"node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
64
|
-
var p = process || {};
|
|
65
|
-
var argv = p.argv || [];
|
|
66
|
-
var env = p.env || {};
|
|
67
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
68
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
69
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
70
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
71
|
-
};
|
|
72
|
-
var replaceClose = (string, close, replace, index) => {
|
|
73
|
-
let result = "", cursor = 0;
|
|
74
|
-
do {
|
|
75
|
-
result += string.substring(cursor, index) + replace;
|
|
76
|
-
cursor = index + close.length;
|
|
77
|
-
index = string.indexOf(close, cursor);
|
|
78
|
-
} while (~index);
|
|
79
|
-
return result + string.substring(cursor);
|
|
80
|
-
};
|
|
81
|
-
var createColors = (enabled = isColorSupported) => {
|
|
82
|
-
let f = enabled ? formatter : () => String;
|
|
83
|
-
return {
|
|
84
|
-
isColorSupported: enabled,
|
|
85
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
86
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
87
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
88
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
89
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
90
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
91
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
92
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
93
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
94
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
95
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
96
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
97
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
98
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
99
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
100
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
101
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
102
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
103
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
104
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
105
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
106
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
107
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
108
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
109
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
110
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
111
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
112
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
113
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
114
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
115
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
116
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
117
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
118
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
119
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
120
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
121
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
122
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
123
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
124
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
125
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
module2.exports = createColors();
|
|
129
|
-
module2.exports.createColors = createColors;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// src/cli/index.ts
|
|
134
|
-
var cli_exports = {};
|
|
135
|
-
__export(cli_exports, {
|
|
136
|
-
checkGitStatus: () => checkGitStatus,
|
|
137
|
-
main: () => main
|
|
138
|
-
});
|
|
139
|
-
module.exports = __toCommonJS(cli_exports);
|
|
140
|
-
var import_node_process7 = __toESM(require("process"));
|
|
141
|
-
|
|
142
|
-
// node_modules/.pnpm/log-symbols@7.0.0/node_modules/log-symbols/symbols.js
|
|
143
|
-
var symbols_exports = {};
|
|
144
|
-
__export(symbols_exports, {
|
|
145
|
-
error: () => error,
|
|
146
|
-
info: () => info,
|
|
147
|
-
success: () => success,
|
|
148
|
-
warning: () => warning
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// node_modules/.pnpm/yoctocolors@2.1.1/node_modules/yoctocolors/base.js
|
|
152
|
-
var import_node_tty = __toESM(require("tty"), 1);
|
|
153
|
-
var _a, _b, _c, _d, _e;
|
|
154
|
-
var hasColors = (_e = (_d = (_c = (_b = (_a = import_node_tty.default) == null ? void 0 : _a.WriteStream) == null ? void 0 : _b.prototype) == null ? void 0 : _c.hasColors) == null ? void 0 : _d.call(_c)) != null ? _e : false;
|
|
155
|
-
var format = (open, close) => {
|
|
156
|
-
if (!hasColors) {
|
|
157
|
-
return (input) => input;
|
|
158
|
-
}
|
|
159
|
-
const openCode = `\x1B[${open}m`;
|
|
160
|
-
const closeCode = `\x1B[${close}m`;
|
|
161
|
-
return (input) => {
|
|
162
|
-
const string = input + "";
|
|
163
|
-
let index = string.indexOf(closeCode);
|
|
164
|
-
if (index === -1) {
|
|
165
|
-
return openCode + string + closeCode;
|
|
166
|
-
}
|
|
167
|
-
let result = openCode;
|
|
168
|
-
let lastIndex = 0;
|
|
169
|
-
while (index !== -1) {
|
|
170
|
-
result += string.slice(lastIndex, index) + openCode;
|
|
171
|
-
lastIndex = index + closeCode.length;
|
|
172
|
-
index = string.indexOf(closeCode, lastIndex);
|
|
173
|
-
}
|
|
174
|
-
result += string.slice(lastIndex) + closeCode;
|
|
175
|
-
return result;
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
var reset = format(0, 0);
|
|
179
|
-
var bold = format(1, 22);
|
|
180
|
-
var dim = format(2, 22);
|
|
181
|
-
var italic = format(3, 23);
|
|
182
|
-
var underline = format(4, 24);
|
|
183
|
-
var overline = format(53, 55);
|
|
184
|
-
var inverse = format(7, 27);
|
|
185
|
-
var hidden = format(8, 28);
|
|
186
|
-
var strikethrough = format(9, 29);
|
|
187
|
-
var black = format(30, 39);
|
|
188
|
-
var red = format(31, 39);
|
|
189
|
-
var green = format(32, 39);
|
|
190
|
-
var yellow = format(33, 39);
|
|
191
|
-
var blue = format(34, 39);
|
|
192
|
-
var magenta = format(35, 39);
|
|
193
|
-
var cyan = format(36, 39);
|
|
194
|
-
var white = format(37, 39);
|
|
195
|
-
var gray = format(90, 39);
|
|
196
|
-
var bgBlack = format(40, 49);
|
|
197
|
-
var bgRed = format(41, 49);
|
|
198
|
-
var bgGreen = format(42, 49);
|
|
199
|
-
var bgYellow = format(43, 49);
|
|
200
|
-
var bgBlue = format(44, 49);
|
|
201
|
-
var bgMagenta = format(45, 49);
|
|
202
|
-
var bgCyan = format(46, 49);
|
|
203
|
-
var bgWhite = format(47, 49);
|
|
204
|
-
var bgGray = format(100, 49);
|
|
205
|
-
var redBright = format(91, 39);
|
|
206
|
-
var greenBright = format(92, 39);
|
|
207
|
-
var yellowBright = format(93, 39);
|
|
208
|
-
var blueBright = format(94, 39);
|
|
209
|
-
var magentaBright = format(95, 39);
|
|
210
|
-
var cyanBright = format(96, 39);
|
|
211
|
-
var whiteBright = format(97, 39);
|
|
212
|
-
var bgRedBright = format(101, 49);
|
|
213
|
-
var bgGreenBright = format(102, 49);
|
|
214
|
-
var bgYellowBright = format(103, 49);
|
|
215
|
-
var bgBlueBright = format(104, 49);
|
|
216
|
-
var bgMagentaBright = format(105, 49);
|
|
217
|
-
var bgCyanBright = format(106, 49);
|
|
218
|
-
var bgWhiteBright = format(107, 49);
|
|
219
|
-
|
|
220
|
-
// node_modules/.pnpm/is-unicode-supported@2.1.0/node_modules/is-unicode-supported/index.js
|
|
221
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
222
|
-
function isUnicodeSupported() {
|
|
223
|
-
const { env } = import_node_process.default;
|
|
224
|
-
const { TERM, TERM_PROGRAM } = env;
|
|
225
|
-
if (import_node_process.default.platform !== "win32") {
|
|
226
|
-
return TERM !== "linux";
|
|
227
|
-
}
|
|
228
|
-
return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// node_modules/.pnpm/log-symbols@7.0.0/node_modules/log-symbols/symbols.js
|
|
232
|
-
var _isUnicodeSupported = isUnicodeSupported();
|
|
233
|
-
var info = blue(_isUnicodeSupported ? "\u2139" : "i");
|
|
234
|
-
var success = green(_isUnicodeSupported ? "\u2714" : "\u221A");
|
|
235
|
-
var warning = yellow(_isUnicodeSupported ? "\u26A0" : "\u203C");
|
|
236
|
-
var error = red(_isUnicodeSupported ? "\u2716\uFE0F" : "\xD7");
|
|
1
|
+
import {createRequire as __createRequire} from 'module';var require=__createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
__toESM,
|
|
4
|
+
bumpConfigDefaults,
|
|
5
|
+
isReleaseType,
|
|
6
|
+
loadBumpConfig,
|
|
7
|
+
require_picocolors,
|
|
8
|
+
symbols_exports,
|
|
9
|
+
versionBump
|
|
10
|
+
} from "../chunk-BEM77VRK.js";
|
|
237
11
|
|
|
238
12
|
// src/cli/index.ts
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
// src/version-bump.ts
|
|
242
|
-
var import_node_process4 = __toESM(require("process"));
|
|
243
|
-
|
|
244
|
-
// node_modules/.pnpm/args-tokenizer@0.3.0/node_modules/args-tokenizer/dist/args-tokenizer.js
|
|
245
|
-
var spaceRegex = /\s/;
|
|
246
|
-
var tokenizeArgs = (argsString, options) => {
|
|
247
|
-
const tokens = [];
|
|
248
|
-
let currentToken = "";
|
|
249
|
-
let openningQuote;
|
|
250
|
-
let escaped = false;
|
|
251
|
-
for (let index = 0; index < argsString.length; index += 1) {
|
|
252
|
-
const char = argsString[index];
|
|
253
|
-
if (escaped) {
|
|
254
|
-
escaped = false;
|
|
255
|
-
if (openningQuote || char !== "\n") {
|
|
256
|
-
currentToken += char;
|
|
257
|
-
}
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
if (char === "\\") {
|
|
261
|
-
escaped = true;
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
if (openningQuote === void 0 && spaceRegex.test(char)) {
|
|
265
|
-
if (currentToken.length > 0) {
|
|
266
|
-
tokens.push(currentToken);
|
|
267
|
-
currentToken = "";
|
|
268
|
-
}
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
if (char === "'" || char === '"') {
|
|
272
|
-
if (openningQuote === void 0) {
|
|
273
|
-
openningQuote = char;
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
if (openningQuote === char) {
|
|
277
|
-
openningQuote = void 0;
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
currentToken += char;
|
|
282
|
-
}
|
|
283
|
-
if (currentToken.length > 0) {
|
|
284
|
-
tokens.push(currentToken);
|
|
285
|
-
}
|
|
286
|
-
if (options == null ? void 0 : options.loose) {
|
|
287
|
-
return tokens;
|
|
288
|
-
}
|
|
289
|
-
if (openningQuote) {
|
|
290
|
-
throw Error("Unexpected end of string. Closing quote is missing.");
|
|
291
|
-
}
|
|
292
|
-
return tokens;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
// src/version-bump.ts
|
|
296
|
-
var import_picocolors3 = __toESM(require_picocolors());
|
|
297
|
-
var import_prompts2 = __toESM(require("prompts"));
|
|
298
|
-
var import_tinyexec4 = require("tinyexec");
|
|
299
|
-
|
|
300
|
-
// src/get-current-version.ts
|
|
301
|
-
var import_semver = require("semver");
|
|
302
|
-
|
|
303
|
-
// src/fs.ts
|
|
304
|
-
var import_node_fs = __toESM(require("fs"));
|
|
305
|
-
var import_node_path = __toESM(require("path"));
|
|
306
|
-
var jsonc = __toESM(require("jsonc-parser"));
|
|
307
|
-
async function readJsoncFile(name, cwd) {
|
|
308
|
-
const file = await readTextFile(name, cwd);
|
|
309
|
-
const data = jsonc.parse(file.data);
|
|
310
|
-
const modified = [];
|
|
311
|
-
return __spreadProps(__spreadValues({}, file), { data, modified, text: file.data });
|
|
312
|
-
}
|
|
313
|
-
async function writeJsoncFile(file) {
|
|
314
|
-
let newJSON = file.text;
|
|
315
|
-
for (const [key, value] of file.modified) {
|
|
316
|
-
const edit = jsonc.modify(newJSON, key, value, {});
|
|
317
|
-
newJSON = jsonc.applyEdits(newJSON, edit);
|
|
318
|
-
}
|
|
319
|
-
return writeTextFile(__spreadProps(__spreadValues({}, file), { data: newJSON }));
|
|
320
|
-
}
|
|
321
|
-
function readTextFile(name, cwd) {
|
|
322
|
-
return new Promise((resolve, reject) => {
|
|
323
|
-
const filePath = import_node_path.default.join(cwd, name);
|
|
324
|
-
import_node_fs.default.readFile(filePath, "utf8", (err, text) => {
|
|
325
|
-
if (err) {
|
|
326
|
-
reject(err);
|
|
327
|
-
} else {
|
|
328
|
-
resolve({
|
|
329
|
-
path: filePath,
|
|
330
|
-
data: text
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
function writeTextFile(file) {
|
|
337
|
-
return new Promise((resolve, reject) => {
|
|
338
|
-
import_node_fs.default.writeFile(file.path, file.data, (err) => {
|
|
339
|
-
if (err)
|
|
340
|
-
reject(err);
|
|
341
|
-
else
|
|
342
|
-
resolve();
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// src/manifest.ts
|
|
348
|
-
function isManifest(obj) {
|
|
349
|
-
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
350
|
-
}
|
|
351
|
-
function isPackageLockManifest(manifest) {
|
|
352
|
-
var _a2, _b2;
|
|
353
|
-
return typeof ((_b2 = (_a2 = manifest.packages) == null ? void 0 : _a2[""]) == null ? void 0 : _b2.version) === "string";
|
|
354
|
-
}
|
|
355
|
-
function isOptionalString(value) {
|
|
356
|
-
const type = typeof value;
|
|
357
|
-
return value === null || type === "undefined" || type === "string";
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// src/get-current-version.ts
|
|
361
|
-
async function getCurrentVersion(operation) {
|
|
362
|
-
if (operation.state.currentVersion)
|
|
363
|
-
return operation;
|
|
364
|
-
const { cwd, files } = operation.options;
|
|
365
|
-
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
366
|
-
if (!filesToCheck.includes("package.json"))
|
|
367
|
-
filesToCheck.push("package.json");
|
|
368
|
-
if (!filesToCheck.includes("deno.json"))
|
|
369
|
-
filesToCheck.push("deno.json");
|
|
370
|
-
if (!filesToCheck.includes("deno.jsonc"))
|
|
371
|
-
filesToCheck.push("deno.jsonc");
|
|
372
|
-
for (const file of filesToCheck) {
|
|
373
|
-
const version2 = await readVersion(file, cwd);
|
|
374
|
-
if (version2) {
|
|
375
|
-
return operation.update({
|
|
376
|
-
currentVersionSource: file,
|
|
377
|
-
currentVersion: version2
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
throw new Error(
|
|
382
|
-
`Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
async function readVersion(file, cwd) {
|
|
386
|
-
try {
|
|
387
|
-
const { data: manifest } = await readJsoncFile(file, cwd);
|
|
388
|
-
if (isManifest(manifest)) {
|
|
389
|
-
if ((0, import_semver.valid)(manifest.version))
|
|
390
|
-
return manifest.version;
|
|
391
|
-
}
|
|
392
|
-
} catch (e) {
|
|
393
|
-
return void 0;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// src/get-new-version.ts
|
|
398
|
-
var import_node_process2 = __toESM(require("process"));
|
|
399
|
-
var import_picocolors2 = __toESM(require_picocolors());
|
|
400
|
-
var import_prompts = __toESM(require("prompts"));
|
|
401
|
-
var import_semver2 = __toESM(require("semver"));
|
|
402
|
-
|
|
403
|
-
// src/print-commits.ts
|
|
404
|
-
var import_picocolors = __toESM(require_picocolors());
|
|
405
|
-
var import_tinyexec = require("tinyexec");
|
|
406
|
-
var messageColorMap = {
|
|
407
|
-
feat: import_picocolors.default.green,
|
|
408
|
-
feature: import_picocolors.default.green,
|
|
409
|
-
refactor: import_picocolors.default.cyan,
|
|
410
|
-
style: import_picocolors.default.cyan,
|
|
411
|
-
docs: import_picocolors.default.blue,
|
|
412
|
-
doc: import_picocolors.default.blue,
|
|
413
|
-
types: import_picocolors.default.blue,
|
|
414
|
-
type: import_picocolors.default.blue,
|
|
415
|
-
chore: import_picocolors.default.gray,
|
|
416
|
-
ci: import_picocolors.default.gray,
|
|
417
|
-
build: import_picocolors.default.gray,
|
|
418
|
-
deps: import_picocolors.default.gray,
|
|
419
|
-
dev: import_picocolors.default.gray,
|
|
420
|
-
fix: import_picocolors.default.yellow,
|
|
421
|
-
test: import_picocolors.default.yellow,
|
|
422
|
-
perf: import_picocolors.default.magenta,
|
|
423
|
-
revert: import_picocolors.default.red,
|
|
424
|
-
breaking: import_picocolors.default.red
|
|
425
|
-
};
|
|
426
|
-
function parseCommits(raw) {
|
|
427
|
-
const lines = raw.toString().trim().split(/\n/g);
|
|
428
|
-
if (!lines.length) {
|
|
429
|
-
return [];
|
|
430
|
-
}
|
|
431
|
-
return lines.map((line) => {
|
|
432
|
-
const [hash, ...parts] = line.split(" ");
|
|
433
|
-
const message = parts.join(" ");
|
|
434
|
-
const match = message.match(/^(\w+)(!)?(\([^)]+\))?(!)?:(.*)$/);
|
|
435
|
-
if (match) {
|
|
436
|
-
let color = messageColorMap[match[1].toLowerCase()] || ((c5) => c5);
|
|
437
|
-
const breaking = match[2] === "!" || match[4] === "!";
|
|
438
|
-
if (breaking) {
|
|
439
|
-
color = (s) => import_picocolors.default.inverse(import_picocolors.default.red(s));
|
|
440
|
-
}
|
|
441
|
-
const tag = [match[1], match[2], match[4]].filter(Boolean).join("");
|
|
442
|
-
const scope = match[3] || "";
|
|
443
|
-
return {
|
|
444
|
-
hash,
|
|
445
|
-
tag,
|
|
446
|
-
message: match[5].trim(),
|
|
447
|
-
scope,
|
|
448
|
-
breaking,
|
|
449
|
-
color
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
return {
|
|
453
|
-
hash,
|
|
454
|
-
tag: "",
|
|
455
|
-
message,
|
|
456
|
-
scope: "",
|
|
457
|
-
color: (c5) => c5
|
|
458
|
-
};
|
|
459
|
-
}).reverse();
|
|
460
|
-
}
|
|
461
|
-
function formatParsedCommits(commits) {
|
|
462
|
-
const tagLength = commits.map(({ tag }) => tag.length).reduce((a, b) => Math.max(a, b), 0);
|
|
463
|
-
let scopeLength = commits.map(({ scope }) => scope.length).reduce((a, b) => Math.max(a, b), 0);
|
|
464
|
-
if (scopeLength)
|
|
465
|
-
scopeLength += 2;
|
|
466
|
-
return commits.map(({ hash, tag, message, scope, color }) => {
|
|
467
|
-
const paddedTag = tag.padStart(tagLength + 1, " ");
|
|
468
|
-
const paddedScope = !scope ? " ".repeat(scopeLength) : import_picocolors.default.dim("(") + scope.slice(1, -1) + import_picocolors.default.dim(")") + " ".repeat(scopeLength - scope.length);
|
|
469
|
-
return [
|
|
470
|
-
import_picocolors.default.dim(hash),
|
|
471
|
-
" ",
|
|
472
|
-
color === import_picocolors.default.gray ? color(paddedTag) : import_picocolors.default.bold(color(paddedTag)),
|
|
473
|
-
" ",
|
|
474
|
-
paddedScope,
|
|
475
|
-
import_picocolors.default.dim(":"),
|
|
476
|
-
" ",
|
|
477
|
-
color === import_picocolors.default.gray ? color(message) : message
|
|
478
|
-
].join("");
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
async function printRecentCommits(operation) {
|
|
482
|
-
let sha;
|
|
483
|
-
sha || (sha = await (0, import_tinyexec.x)(
|
|
484
|
-
"git",
|
|
485
|
-
["rev-list", "-n", "1", `v${operation.state.currentVersion}`],
|
|
486
|
-
{ nodeOptions: { stdio: "pipe" }, throwOnError: false }
|
|
487
|
-
).then((res) => res.stdout.trim()));
|
|
488
|
-
sha || (sha = await (0, import_tinyexec.x)(
|
|
489
|
-
"git",
|
|
490
|
-
["rev-list", "-n", "1", operation.state.currentVersion],
|
|
491
|
-
{ nodeOptions: { stdio: "pipe" }, throwOnError: false }
|
|
492
|
-
).then((res) => res.stdout.trim()));
|
|
493
|
-
if (!sha) {
|
|
494
|
-
console.log(
|
|
495
|
-
import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` Failed to locate the previous tag ${import_picocolors.default.yellow(`v${operation.state.currentVersion}`)}`)
|
|
496
|
-
);
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
const { stdout } = await (0, import_tinyexec.x)(
|
|
500
|
-
"git",
|
|
501
|
-
[
|
|
502
|
-
"--no-pager",
|
|
503
|
-
"log",
|
|
504
|
-
`${sha}..HEAD`,
|
|
505
|
-
"--oneline"
|
|
506
|
-
],
|
|
507
|
-
{
|
|
508
|
-
nodeOptions: {
|
|
509
|
-
stdio: "pipe"
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
);
|
|
513
|
-
const parsed = parseCommits(stdout.toString().trim());
|
|
514
|
-
const prettified = formatParsedCommits(parsed);
|
|
515
|
-
if (!parsed.length) {
|
|
516
|
-
console.log();
|
|
517
|
-
console.log(import_picocolors.default.blue(`i`) + import_picocolors.default.gray(` No commits since ${operation.state.currentVersion}`));
|
|
518
|
-
console.log();
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
console.log();
|
|
522
|
-
console.log(
|
|
523
|
-
import_picocolors.default.bold(
|
|
524
|
-
`${import_picocolors.default.green(parsed.length)} Commits since ${import_picocolors.default.gray(sha.slice(0, 7))}:`
|
|
525
|
-
)
|
|
526
|
-
);
|
|
527
|
-
console.log();
|
|
528
|
-
console.log(prettified.join("\n"));
|
|
529
|
-
console.log();
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// src/release-type.ts
|
|
533
|
-
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
534
|
-
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next"]);
|
|
535
|
-
function isPrerelease(value) {
|
|
536
|
-
return prereleaseTypes.includes(value);
|
|
537
|
-
}
|
|
538
|
-
function isReleaseType(value) {
|
|
539
|
-
return releaseTypes.includes(value);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// src/get-new-version.ts
|
|
543
|
-
async function getNewVersion(operation) {
|
|
544
|
-
const { release } = operation.options;
|
|
545
|
-
const { currentVersion } = operation.state;
|
|
546
|
-
switch (release.type) {
|
|
547
|
-
case "prompt":
|
|
548
|
-
return promptForNewVersion(operation);
|
|
549
|
-
case "version":
|
|
550
|
-
return operation.update({
|
|
551
|
-
newVersion: new import_semver2.SemVer(release.version, true).version
|
|
552
|
-
});
|
|
553
|
-
default:
|
|
554
|
-
return operation.update({
|
|
555
|
-
release: release.type,
|
|
556
|
-
newVersion: getNextVersion(currentVersion, release)
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function getNextVersion(currentVersion, bump) {
|
|
561
|
-
const oldSemVer = new import_semver2.SemVer(currentVersion);
|
|
562
|
-
const type = bump.type === "next" ? oldSemVer.prerelease.length ? "prerelease" : "patch" : bump.type;
|
|
563
|
-
const newSemVer = oldSemVer.inc(type, bump.preid);
|
|
564
|
-
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
|
|
565
|
-
newSemVer.prerelease[1] = "1";
|
|
566
|
-
newSemVer.format();
|
|
567
|
-
}
|
|
568
|
-
return newSemVer.version;
|
|
569
|
-
}
|
|
570
|
-
function getNextVersions(currentVersion, preid) {
|
|
571
|
-
const next = {};
|
|
572
|
-
const parse2 = import_semver2.default.parse(currentVersion);
|
|
573
|
-
if (typeof (parse2 == null ? void 0 : parse2.prerelease[0]) === "string")
|
|
574
|
-
preid = (parse2 == null ? void 0 : parse2.prerelease[0]) || "preid";
|
|
575
|
-
for (const type of releaseTypes)
|
|
576
|
-
next[type] = getNextVersion(currentVersion, { type, preid });
|
|
577
|
-
return next;
|
|
578
|
-
}
|
|
579
|
-
async function promptForNewVersion(operation) {
|
|
580
|
-
var _a2, _b2;
|
|
581
|
-
const { currentVersion } = operation.state;
|
|
582
|
-
const release = operation.options.release;
|
|
583
|
-
const next = getNextVersions(currentVersion, release.preid);
|
|
584
|
-
const configCustomVersion = await ((_b2 = (_a2 = operation.options).customVersion) == null ? void 0 : _b2.call(_a2, currentVersion, import_semver2.default));
|
|
585
|
-
if (operation.options.printCommits) {
|
|
586
|
-
await printRecentCommits(operation);
|
|
587
|
-
}
|
|
588
|
-
const PADDING = 13;
|
|
589
|
-
const answers = await (0, import_prompts.default)([
|
|
590
|
-
{
|
|
591
|
-
type: "autocomplete",
|
|
592
|
-
name: "release",
|
|
593
|
-
message: `Current version ${import_picocolors2.default.green(currentVersion)}`,
|
|
594
|
-
initial: configCustomVersion ? "config" : "next",
|
|
595
|
-
choices: [
|
|
596
|
-
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.major)}` },
|
|
597
|
-
{ value: "minor", title: `${"minor".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.minor)}` },
|
|
598
|
-
{ value: "patch", title: `${"patch".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.patch)}` },
|
|
599
|
-
{ value: "next", title: `${"next".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.next)}` },
|
|
600
|
-
...configCustomVersion ? [
|
|
601
|
-
{ value: "config", title: `${"from config".padStart(PADDING, " ")} ${import_picocolors2.default.bold(configCustomVersion)}` }
|
|
602
|
-
] : [],
|
|
603
|
-
{ value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.prepatch)}` },
|
|
604
|
-
{ value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.preminor)}` },
|
|
605
|
-
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${import_picocolors2.default.bold(next.premajor)}` },
|
|
606
|
-
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${import_picocolors2.default.bold(currentVersion)}` },
|
|
607
|
-
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
|
|
608
|
-
]
|
|
609
|
-
},
|
|
610
|
-
{
|
|
611
|
-
type: (prev) => prev === "custom" ? "text" : null,
|
|
612
|
-
name: "custom",
|
|
613
|
-
message: "Enter the new version number:",
|
|
614
|
-
initial: currentVersion,
|
|
615
|
-
validate: (custom) => {
|
|
616
|
-
return (0, import_semver2.valid)(custom) ? true : "That's not a valid version number";
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
]);
|
|
620
|
-
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? (0, import_semver2.clean)(answers.custom) : answers.release === "config" ? (0, import_semver2.clean)(configCustomVersion) : next[answers.release];
|
|
621
|
-
if (!newVersion)
|
|
622
|
-
import_node_process2.default.exit(1);
|
|
623
|
-
switch (answers.release) {
|
|
624
|
-
case "custom":
|
|
625
|
-
case "config":
|
|
626
|
-
case "next":
|
|
627
|
-
case "none":
|
|
628
|
-
return operation.update({ newVersion });
|
|
629
|
-
default:
|
|
630
|
-
return operation.update({ release: answers.release, newVersion });
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
// src/git.ts
|
|
635
|
-
var import_tinyexec2 = require("tinyexec");
|
|
636
|
-
async function gitCommit(operation) {
|
|
637
|
-
if (!operation.options.commit)
|
|
638
|
-
return operation;
|
|
639
|
-
const { all, noVerify, message } = operation.options.commit;
|
|
640
|
-
const { updatedFiles, newVersion } = operation.state;
|
|
641
|
-
let args = ["--allow-empty"];
|
|
642
|
-
if (all) {
|
|
643
|
-
args.push("--all");
|
|
644
|
-
}
|
|
645
|
-
if (noVerify) {
|
|
646
|
-
args.push("--no-verify");
|
|
647
|
-
}
|
|
648
|
-
if (operation.options.sign) {
|
|
649
|
-
args.push("--gpg-sign");
|
|
650
|
-
}
|
|
651
|
-
const commitMessage = formatVersionString(message, newVersion);
|
|
652
|
-
args.push("--message", commitMessage);
|
|
653
|
-
if (!all)
|
|
654
|
-
args = args.concat(updatedFiles);
|
|
655
|
-
await (0, import_tinyexec2.x)("git", ["commit", ...args], { throwOnError: true });
|
|
656
|
-
return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
|
|
657
|
-
}
|
|
658
|
-
async function gitTag(operation) {
|
|
659
|
-
if (!operation.options.tag)
|
|
660
|
-
return operation;
|
|
661
|
-
const { commit, tag } = operation.options;
|
|
662
|
-
const { newVersion } = operation.state;
|
|
663
|
-
const args = [
|
|
664
|
-
// Create an annotated tag, which is recommended for releases.
|
|
665
|
-
// See https://git-scm.com/docs/git-tag
|
|
666
|
-
"--annotate",
|
|
667
|
-
// Use the same commit message for the tag
|
|
668
|
-
"--message",
|
|
669
|
-
formatVersionString(commit.message, newVersion)
|
|
670
|
-
];
|
|
671
|
-
const tagName = formatVersionString(tag.name, newVersion);
|
|
672
|
-
args.push(tagName);
|
|
673
|
-
if (operation.options.sign) {
|
|
674
|
-
args.push("--sign");
|
|
675
|
-
}
|
|
676
|
-
await (0, import_tinyexec2.x)("git", ["tag", ...args], { throwOnError: true });
|
|
677
|
-
return operation.update({ event: "git tag" /* GitTag */, tagName });
|
|
678
|
-
}
|
|
679
|
-
async function gitPush(operation) {
|
|
680
|
-
if (!operation.options.push)
|
|
681
|
-
return operation;
|
|
682
|
-
await (0, import_tinyexec2.x)("git", ["push"], { throwOnError: true });
|
|
683
|
-
if (operation.options.tag) {
|
|
684
|
-
await (0, import_tinyexec2.x)("git", ["push", "--tags"], { throwOnError: true });
|
|
685
|
-
}
|
|
686
|
-
return operation.update({ event: "git push" /* GitPush */ });
|
|
687
|
-
}
|
|
688
|
-
function formatVersionString(template, newVersion) {
|
|
689
|
-
if (template.includes("%s"))
|
|
690
|
-
return template.replace(/%s/g, newVersion);
|
|
691
|
-
else
|
|
692
|
-
return template + newVersion;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
// src/normalize-options.ts
|
|
696
|
-
var import_node_fs2 = __toESM(require("fs"));
|
|
697
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
698
|
-
var import_node_process3 = __toESM(require("process"));
|
|
699
|
-
var import_js_yaml = __toESM(require("js-yaml"));
|
|
700
|
-
var import_tinyglobby = require("tinyglobby");
|
|
701
|
-
async function normalizeOptions(raw) {
|
|
702
|
-
var _a2, _b2, _d2;
|
|
703
|
-
const preid = typeof raw.preid === "string" ? raw.preid : "beta";
|
|
704
|
-
const sign = Boolean(raw.sign);
|
|
705
|
-
const push = Boolean(raw.push);
|
|
706
|
-
const all = Boolean(raw.all);
|
|
707
|
-
const install = Boolean(raw.install);
|
|
708
|
-
const noVerify = Boolean(raw.noVerify);
|
|
709
|
-
const cwd = raw.cwd || import_node_process3.default.cwd();
|
|
710
|
-
const ignoreScripts = Boolean(raw.ignoreScripts);
|
|
711
|
-
const execute = raw.execute;
|
|
712
|
-
const recursive = Boolean(raw.recursive);
|
|
713
|
-
let release;
|
|
714
|
-
if (!raw.release || raw.release === "prompt")
|
|
715
|
-
release = { type: "prompt", preid };
|
|
716
|
-
else if (isReleaseType(raw.release) || raw.release === "next")
|
|
717
|
-
release = { type: raw.release, preid };
|
|
718
|
-
else
|
|
719
|
-
release = { type: "version", version: raw.release };
|
|
720
|
-
let tag;
|
|
721
|
-
if (typeof raw.tag === "string")
|
|
722
|
-
tag = { name: raw.tag };
|
|
723
|
-
else if (raw.tag)
|
|
724
|
-
tag = { name: "v" };
|
|
725
|
-
let commit;
|
|
726
|
-
if (typeof raw.commit === "string")
|
|
727
|
-
commit = { all, noVerify, message: raw.commit };
|
|
728
|
-
else if (raw.commit || tag || push)
|
|
729
|
-
commit = { all, noVerify, message: "chore: release v" };
|
|
730
|
-
if (recursive && !((_a2 = raw.files) == null ? void 0 : _a2.length)) {
|
|
731
|
-
raw.files = [
|
|
732
|
-
"package.json",
|
|
733
|
-
"package-lock.json",
|
|
734
|
-
"packages/**/package.json",
|
|
735
|
-
"jsr.json",
|
|
736
|
-
"jsr.jsonc",
|
|
737
|
-
"deno.json",
|
|
738
|
-
"deno.jsonc"
|
|
739
|
-
];
|
|
740
|
-
if (import_node_fs2.default.existsSync("pnpm-workspace.yaml")) {
|
|
741
|
-
const pnpmWorkspace = await import_promises.default.readFile("pnpm-workspace.yaml", "utf8");
|
|
742
|
-
const workspaces = import_js_yaml.default.load(pnpmWorkspace);
|
|
743
|
-
const workspacesWithPackageJson = workspaces.packages.map((workspace) => `${workspace}/package.json`);
|
|
744
|
-
const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => {
|
|
745
|
-
var _a3;
|
|
746
|
-
return !workspace.startsWith("!") && !((_a3 = raw.files) == null ? void 0 : _a3.includes(workspace));
|
|
747
|
-
});
|
|
748
|
-
raw.files = raw.files.concat(withoutExcludedWorkspaces);
|
|
749
|
-
}
|
|
750
|
-
} else {
|
|
751
|
-
raw.files = ((_b2 = raw.files) == null ? void 0 : _b2.length) ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc", "deno.json", "deno.jsonc"];
|
|
752
|
-
}
|
|
753
|
-
const files = await (0, import_tinyglobby.glob)(
|
|
754
|
-
raw.files,
|
|
755
|
-
{
|
|
756
|
-
cwd,
|
|
757
|
-
onlyFiles: true,
|
|
758
|
-
expandDirectories: false,
|
|
759
|
-
ignore: [
|
|
760
|
-
"**/{.git,node_modules,bower_components,__tests__,fixtures,fixture}/**"
|
|
761
|
-
]
|
|
762
|
-
}
|
|
763
|
-
);
|
|
764
|
-
let ui;
|
|
765
|
-
if (raw.interface === false) {
|
|
766
|
-
ui = { input: false, output: false };
|
|
767
|
-
} else if (raw.interface === true || !raw.interface) {
|
|
768
|
-
ui = { input: import_node_process3.default.stdin, output: import_node_process3.default.stdout };
|
|
769
|
-
} else {
|
|
770
|
-
let _c2 = raw.interface, { input, output } = _c2, other = __objRest(_c2, ["input", "output"]);
|
|
771
|
-
if (input === true || input !== false && !input)
|
|
772
|
-
input = import_node_process3.default.stdin;
|
|
773
|
-
if (output === true || output !== false && !output)
|
|
774
|
-
output = import_node_process3.default.stdout;
|
|
775
|
-
ui = __spreadValues({ input, output }, other);
|
|
776
|
-
}
|
|
777
|
-
if (release.type === "prompt" && !(ui.input && ui.output))
|
|
778
|
-
throw new Error("Cannot prompt for the version number because input or output has been disabled.");
|
|
779
|
-
return {
|
|
780
|
-
release,
|
|
781
|
-
commit,
|
|
782
|
-
tag,
|
|
783
|
-
sign,
|
|
784
|
-
push,
|
|
785
|
-
files,
|
|
786
|
-
cwd,
|
|
787
|
-
install,
|
|
788
|
-
interface: ui,
|
|
789
|
-
ignoreScripts,
|
|
790
|
-
execute,
|
|
791
|
-
printCommits: (_d2 = raw.printCommits) != null ? _d2 : true,
|
|
792
|
-
customVersion: raw.customVersion,
|
|
793
|
-
currentVersion: raw.currentVersion
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
// src/operation.ts
|
|
798
|
-
var Operation = class _Operation {
|
|
799
|
-
/**
|
|
800
|
-
* Private constructor. Use the `Operation.start()` static method instead.
|
|
801
|
-
*/
|
|
802
|
-
constructor(options, progress2) {
|
|
803
|
-
/**
|
|
804
|
-
* The current state of the operation.
|
|
805
|
-
*/
|
|
806
|
-
this.state = {
|
|
807
|
-
release: void 0,
|
|
808
|
-
currentVersion: "",
|
|
809
|
-
currentVersionSource: "",
|
|
810
|
-
newVersion: "",
|
|
811
|
-
commitMessage: "",
|
|
812
|
-
tagName: "",
|
|
813
|
-
updatedFiles: [],
|
|
814
|
-
skippedFiles: []
|
|
815
|
-
};
|
|
816
|
-
this.options = options;
|
|
817
|
-
this._progress = progress2;
|
|
818
|
-
if (options.currentVersion) {
|
|
819
|
-
this.update({
|
|
820
|
-
currentVersion: options.currentVersion,
|
|
821
|
-
currentVersionSource: "user"
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* The results of the operation.
|
|
827
|
-
*/
|
|
828
|
-
get results() {
|
|
829
|
-
const options = this.options;
|
|
830
|
-
const state = this.state;
|
|
831
|
-
return {
|
|
832
|
-
release: state.release,
|
|
833
|
-
currentVersion: state.currentVersion,
|
|
834
|
-
newVersion: state.newVersion,
|
|
835
|
-
commit: options.commit ? state.commitMessage : false,
|
|
836
|
-
tag: options.tag ? state.tagName : false,
|
|
837
|
-
updatedFiles: state.updatedFiles.slice(),
|
|
838
|
-
skippedFiles: state.skippedFiles.slice()
|
|
839
|
-
};
|
|
840
|
-
}
|
|
841
|
-
/**
|
|
842
|
-
* Starts a new `versionBump()` operation.
|
|
843
|
-
*/
|
|
844
|
-
static async start(input) {
|
|
845
|
-
const options = await normalizeOptions(input);
|
|
846
|
-
return new _Operation(options, input.progress);
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Updates the operation state and results, and reports the updated progress to the user.
|
|
850
|
-
*/
|
|
851
|
-
update(_a2) {
|
|
852
|
-
var _b2 = _a2, { event, script } = _b2, newState = __objRest(_b2, ["event", "script"]);
|
|
853
|
-
Object.assign(this.state, newState);
|
|
854
|
-
if (event && this._progress) {
|
|
855
|
-
this._progress(__spreadValues({ event, script }, this.results));
|
|
856
|
-
}
|
|
857
|
-
return this;
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
// src/run-npm-script.ts
|
|
862
|
-
var import_tinyexec3 = require("tinyexec");
|
|
863
|
-
async function runNpmScript(script, operation) {
|
|
864
|
-
const { cwd, ignoreScripts } = operation.options;
|
|
865
|
-
if (!ignoreScripts) {
|
|
866
|
-
const { data: manifest } = await readJsoncFile("package.json", cwd);
|
|
867
|
-
if (isManifest(manifest) && hasScript(manifest, script)) {
|
|
868
|
-
await (0, import_tinyexec3.x)("npm", ["run", script, "--silent"], {
|
|
869
|
-
nodeOptions: { stdio: "inherit" }
|
|
870
|
-
});
|
|
871
|
-
operation.update({ event: "npm script" /* NpmScript */, script });
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
return operation;
|
|
875
|
-
}
|
|
876
|
-
function hasScript(manifest, script) {
|
|
877
|
-
const scripts = manifest.scripts;
|
|
878
|
-
if (scripts && typeof scripts === "object")
|
|
879
|
-
return Boolean(scripts[script]);
|
|
880
|
-
return false;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
// src/update-files.ts
|
|
884
|
-
var import_node_fs3 = require("fs");
|
|
885
|
-
var path2 = __toESM(require("path"));
|
|
886
|
-
async function updateFiles(operation) {
|
|
887
|
-
const { files } = operation.options;
|
|
888
|
-
for (const relPath of files) {
|
|
889
|
-
const modified = await updateFile(relPath, operation);
|
|
890
|
-
if (modified) {
|
|
891
|
-
operation.update({
|
|
892
|
-
event: "file updated" /* FileUpdated */,
|
|
893
|
-
updatedFiles: operation.state.updatedFiles.concat(relPath)
|
|
894
|
-
});
|
|
895
|
-
} else {
|
|
896
|
-
operation.update({
|
|
897
|
-
event: "file skipped" /* FileSkipped */,
|
|
898
|
-
skippedFiles: operation.state.skippedFiles.concat(relPath)
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
return operation;
|
|
903
|
-
}
|
|
904
|
-
async function updateFile(relPath, operation) {
|
|
905
|
-
if (!(0, import_node_fs3.existsSync)(path2.join(operation.options.cwd, relPath))) {
|
|
906
|
-
return false;
|
|
907
|
-
}
|
|
908
|
-
const name = path2.basename(relPath).trim().toLowerCase();
|
|
909
|
-
switch (name) {
|
|
910
|
-
case "package.json":
|
|
911
|
-
case "package-lock.json":
|
|
912
|
-
case "bower.json":
|
|
913
|
-
case "component.json":
|
|
914
|
-
case "jsr.json":
|
|
915
|
-
case "jsr.jsonc":
|
|
916
|
-
case "deno.json":
|
|
917
|
-
case "deno.jsonc":
|
|
918
|
-
return updateManifestFile(relPath, operation);
|
|
919
|
-
default:
|
|
920
|
-
return updateTextFile(relPath, operation);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
async function updateManifestFile(relPath, operation) {
|
|
924
|
-
const { cwd } = operation.options;
|
|
925
|
-
const { newVersion } = operation.state;
|
|
926
|
-
let modified = false;
|
|
927
|
-
const file = await readJsoncFile(relPath, cwd);
|
|
928
|
-
if (!isManifest(file.data)) {
|
|
929
|
-
return modified;
|
|
930
|
-
}
|
|
931
|
-
if (file.data.version == null) {
|
|
932
|
-
return modified;
|
|
933
|
-
}
|
|
934
|
-
if (file.data.version !== newVersion) {
|
|
935
|
-
file.modified.push([["version"], newVersion]);
|
|
936
|
-
if (isPackageLockManifest(file.data))
|
|
937
|
-
file.modified.push([["packages", "", "version"], newVersion]);
|
|
938
|
-
await writeJsoncFile(file);
|
|
939
|
-
modified = true;
|
|
940
|
-
}
|
|
941
|
-
return modified;
|
|
942
|
-
}
|
|
943
|
-
async function updateTextFile(relPath, operation) {
|
|
944
|
-
const { cwd } = operation.options;
|
|
945
|
-
const { currentVersion, newVersion } = operation.state;
|
|
946
|
-
const modified = false;
|
|
947
|
-
const file = await readTextFile(relPath, cwd);
|
|
948
|
-
if (file.data.includes(currentVersion)) {
|
|
949
|
-
const sanitizedVersion = currentVersion.replace(/(\W)/g, "\\$1");
|
|
950
|
-
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
|
|
951
|
-
file.data = file.data.replace(replacePattern, `$1${newVersion}`);
|
|
952
|
-
await writeTextFile(file);
|
|
953
|
-
return true;
|
|
954
|
-
}
|
|
955
|
-
return modified;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
// src/version-bump.ts
|
|
959
|
-
async function versionBump(arg = {}) {
|
|
960
|
-
if (typeof arg === "string")
|
|
961
|
-
arg = { release: arg };
|
|
962
|
-
const operation = await Operation.start(arg);
|
|
963
|
-
await getCurrentVersion(operation);
|
|
964
|
-
await getNewVersion(operation);
|
|
965
|
-
if (arg.confirm) {
|
|
966
|
-
printSummary(operation);
|
|
967
|
-
if (!await (0, import_prompts2.default)({
|
|
968
|
-
name: "yes",
|
|
969
|
-
type: "confirm",
|
|
970
|
-
message: "Bump?",
|
|
971
|
-
initial: true
|
|
972
|
-
}).then((r) => r.yes)) {
|
|
973
|
-
import_node_process4.default.exit(1);
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
await runNpmScript("preversion" /* PreVersion */, operation);
|
|
977
|
-
await updateFiles(operation);
|
|
978
|
-
if (operation.options.install) {
|
|
979
|
-
const { detect } = await import("package-manager-detector/detect");
|
|
980
|
-
const pm = await detect();
|
|
981
|
-
if (!(pm == null ? void 0 : pm.name)) {
|
|
982
|
-
throw new Error("Could not detect package manager, failed to run npm install");
|
|
983
|
-
}
|
|
984
|
-
const { COMMANDS, constructCommand } = await import("package-manager-detector/commands");
|
|
985
|
-
const command = constructCommand(COMMANDS[pm.name].install, []);
|
|
986
|
-
if (!command) {
|
|
987
|
-
throw new Error("Could not find install command for package manager");
|
|
988
|
-
}
|
|
989
|
-
console.log(symbols_exports.info, "Installing dependencies with", `${command.command} ${command.args.join(" ")}`);
|
|
990
|
-
await (0, import_tinyexec4.x)(command.command, command.args, {
|
|
991
|
-
throwOnError: true,
|
|
992
|
-
nodeOptions: {
|
|
993
|
-
stdio: "inherit",
|
|
994
|
-
cwd: operation.options.cwd
|
|
995
|
-
}
|
|
996
|
-
});
|
|
997
|
-
console.log(symbols_exports.success, "Dependencies installed");
|
|
998
|
-
}
|
|
999
|
-
if (operation.options.execute) {
|
|
1000
|
-
if (typeof operation.options.execute === "function") {
|
|
1001
|
-
await operation.options.execute(operation);
|
|
1002
|
-
} else {
|
|
1003
|
-
const [command, ...args] = tokenizeArgs(operation.options.execute);
|
|
1004
|
-
console.log(symbols_exports.info, "Executing script", command, ...args);
|
|
1005
|
-
await (0, import_tinyexec4.x)(command, args, {
|
|
1006
|
-
throwOnError: true,
|
|
1007
|
-
nodeOptions: {
|
|
1008
|
-
stdio: "inherit",
|
|
1009
|
-
cwd: operation.options.cwd
|
|
1010
|
-
}
|
|
1011
|
-
});
|
|
1012
|
-
console.log(symbols_exports.success, "Script finished");
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
await runNpmScript("version" /* Version */, operation);
|
|
1016
|
-
await gitCommit(operation);
|
|
1017
|
-
await gitTag(operation);
|
|
1018
|
-
await runNpmScript("postversion" /* PostVersion */, operation);
|
|
1019
|
-
await gitPush(operation);
|
|
1020
|
-
return operation.results;
|
|
1021
|
-
}
|
|
1022
|
-
function printSummary(operation) {
|
|
1023
|
-
console.log();
|
|
1024
|
-
console.log(` files ${operation.options.files.map((i) => import_picocolors3.default.bold(i)).join("\n ")}`);
|
|
1025
|
-
if (operation.options.commit)
|
|
1026
|
-
console.log(` commit ${import_picocolors3.default.bold(formatVersionString(operation.options.commit.message, operation.state.newVersion))}`);
|
|
1027
|
-
if (operation.options.tag)
|
|
1028
|
-
console.log(` tag ${import_picocolors3.default.bold(formatVersionString(operation.options.tag.name, operation.state.newVersion))}`);
|
|
1029
|
-
if (operation.options.execute)
|
|
1030
|
-
console.log(` execute ${import_picocolors3.default.bold(typeof operation.options.execute === "function" ? "function" : operation.options.execute)}`);
|
|
1031
|
-
if (operation.options.push)
|
|
1032
|
-
console.log(` push ${import_picocolors3.default.cyan(import_picocolors3.default.bold("yes"))}`);
|
|
1033
|
-
if (operation.options.install)
|
|
1034
|
-
console.log(` install ${import_picocolors3.default.cyan(import_picocolors3.default.bold("yes"))}`);
|
|
1035
|
-
console.log();
|
|
1036
|
-
console.log(` from ${import_picocolors3.default.bold(operation.state.currentVersion)}`);
|
|
1037
|
-
console.log(` to ${import_picocolors3.default.green(import_picocolors3.default.bold(operation.state.newVersion))}`);
|
|
1038
|
-
console.log();
|
|
1039
|
-
}
|
|
13
|
+
import process2 from "node:process";
|
|
14
|
+
import { x } from "tinyexec";
|
|
1040
15
|
|
|
1041
16
|
// src/cli/parse-args.ts
|
|
1042
|
-
var
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
17
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
18
|
+
import process from "node:process";
|
|
19
|
+
import cac from "cac";
|
|
20
|
+
import { valid as isValidVersion } from "semver";
|
|
1046
21
|
|
|
1047
22
|
// package.json
|
|
1048
|
-
var version = "9.
|
|
1049
|
-
|
|
1050
|
-
// src/config.ts
|
|
1051
|
-
var import_node_path2 = require("path");
|
|
1052
|
-
var import_node_process5 = __toESM(require("process"));
|
|
1053
|
-
var import_c12 = require("c12");
|
|
1054
|
-
var import_sync = __toESM(require("escalade/sync"));
|
|
1055
|
-
var bumpConfigDefaults = {
|
|
1056
|
-
commit: true,
|
|
1057
|
-
push: true,
|
|
1058
|
-
tag: true,
|
|
1059
|
-
sign: false,
|
|
1060
|
-
install: false,
|
|
1061
|
-
recursive: false,
|
|
1062
|
-
noVerify: false,
|
|
1063
|
-
confirm: true,
|
|
1064
|
-
ignoreScripts: false,
|
|
1065
|
-
all: false,
|
|
1066
|
-
noGitCheck: true,
|
|
1067
|
-
files: []
|
|
1068
|
-
};
|
|
1069
|
-
async function loadBumpConfig(overrides, cwd = import_node_process5.default.cwd()) {
|
|
1070
|
-
const name = "bump";
|
|
1071
|
-
const configFile = findConfigFile(name, cwd);
|
|
1072
|
-
const { config } = await (0, import_c12.loadConfig)({
|
|
1073
|
-
name,
|
|
1074
|
-
defaults: bumpConfigDefaults,
|
|
1075
|
-
overrides: __spreadValues({}, overrides),
|
|
1076
|
-
cwd: configFile ? (0, import_node_path2.dirname)(configFile) : cwd
|
|
1077
|
-
});
|
|
1078
|
-
return config;
|
|
1079
|
-
}
|
|
1080
|
-
function findConfigFile(name, cwd) {
|
|
1081
|
-
let foundRepositoryRoot = false;
|
|
1082
|
-
try {
|
|
1083
|
-
const candidates = ["js", "mjs", "ts", "mts", "json"].map((ext) => `${name}.config.${ext}`);
|
|
1084
|
-
return (0, import_sync.default)(cwd, (_dir, files) => {
|
|
1085
|
-
const match = files.find((file) => {
|
|
1086
|
-
if (candidates.includes(file))
|
|
1087
|
-
return true;
|
|
1088
|
-
if (file === ".git")
|
|
1089
|
-
foundRepositoryRoot = true;
|
|
1090
|
-
return false;
|
|
1091
|
-
});
|
|
1092
|
-
if (match)
|
|
1093
|
-
return match;
|
|
1094
|
-
if (foundRepositoryRoot) {
|
|
1095
|
-
throw null;
|
|
1096
|
-
}
|
|
1097
|
-
return false;
|
|
1098
|
-
});
|
|
1099
|
-
} catch (error2) {
|
|
1100
|
-
if (foundRepositoryRoot)
|
|
1101
|
-
return null;
|
|
1102
|
-
throw error2;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
23
|
+
var version = "9.11.0";
|
|
1105
24
|
|
|
1106
25
|
// src/cli/parse-args.ts
|
|
1107
26
|
async function parseArgs() {
|
|
1108
|
-
var _a2;
|
|
1109
27
|
try {
|
|
1110
28
|
const { args, resultArgs } = loadCliArgs();
|
|
1111
29
|
const parsedArgs = {
|
|
@@ -1133,20 +51,20 @@ async function parseArgs() {
|
|
|
1133
51
|
};
|
|
1134
52
|
if (parsedArgs.options.files && parsedArgs.options.files.length > 0) {
|
|
1135
53
|
const firstArg = parsedArgs.options.files[0];
|
|
1136
|
-
if (firstArg === "prompt" || isReleaseType(firstArg) || (
|
|
54
|
+
if (firstArg === "prompt" || isReleaseType(firstArg) || isValidVersion(firstArg)) {
|
|
1137
55
|
parsedArgs.options.release = firstArg;
|
|
1138
56
|
parsedArgs.options.files.shift();
|
|
1139
57
|
}
|
|
1140
58
|
}
|
|
1141
|
-
if (parsedArgs.options.recursive &&
|
|
1142
|
-
console.log(
|
|
59
|
+
if (parsedArgs.options.recursive && parsedArgs.options.files?.length)
|
|
60
|
+
console.log(import_picocolors.default.yellow("The --recursive option is ignored when files are specified"));
|
|
1143
61
|
return parsedArgs;
|
|
1144
|
-
} catch (
|
|
1145
|
-
return errorHandler(
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return errorHandler(error);
|
|
1146
64
|
}
|
|
1147
65
|
}
|
|
1148
|
-
function loadCliArgs(argv =
|
|
1149
|
-
const cli = (
|
|
66
|
+
function loadCliArgs(argv = process.argv) {
|
|
67
|
+
const cli = cac("bumpp");
|
|
1150
68
|
cli.version(version).usage("[...files]").option("--preid <preid>", "ID for prerelease").option("--all", `Include all files (default: ${bumpConfigDefaults.all})`).option("--no-git-check", `Skip git check`, { default: bumpConfigDefaults.noGitCheck }).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("--sign", "Sign commit and tag").option("--install", `Run 'npm install' after bumping version (default: ${bumpConfigDefaults.install})`, { 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("--current-version <version>", "Current version").option("--print-commits", "Print recent commits").option("-x, --execute <command>", "Commands to execute after version bumps").help();
|
|
1151
69
|
const result = cli.parse(argv);
|
|
1152
70
|
const rawArgs = cli.rawArgs;
|
|
@@ -1155,28 +73,29 @@ function loadCliArgs(argv = import_node_process6.default.argv) {
|
|
|
1155
73
|
const TAG_REG = /(?:-t|--tag|--no-tag)(?:=.*|$)/;
|
|
1156
74
|
const hasCommitFlag = rawArgs.some((arg) => COMMIT_REG.test(arg));
|
|
1157
75
|
const hasTagFlag = rawArgs.some((arg) => TAG_REG.test(arg));
|
|
1158
|
-
const
|
|
76
|
+
const { tag, commit, ...rest } = args;
|
|
1159
77
|
return {
|
|
1160
|
-
args:
|
|
78
|
+
args: {
|
|
79
|
+
...rest,
|
|
1161
80
|
commit: hasCommitFlag ? commit : void 0,
|
|
1162
81
|
tag: hasTagFlag ? tag : void 0
|
|
1163
|
-
}
|
|
82
|
+
},
|
|
1164
83
|
resultArgs: result.args
|
|
1165
84
|
};
|
|
1166
85
|
}
|
|
1167
|
-
function errorHandler(
|
|
1168
|
-
console.error(
|
|
1169
|
-
return
|
|
86
|
+
function errorHandler(error) {
|
|
87
|
+
console.error(error.message);
|
|
88
|
+
return process.exit(9 /* InvalidArgument */);
|
|
1170
89
|
}
|
|
1171
90
|
|
|
1172
91
|
// src/cli/index.ts
|
|
1173
92
|
async function main() {
|
|
1174
93
|
try {
|
|
1175
|
-
|
|
1176
|
-
|
|
94
|
+
process2.on("uncaughtException", errorHandler2);
|
|
95
|
+
process2.on("unhandledRejection", errorHandler2);
|
|
1177
96
|
const { help, version: version2, quiet, options } = await parseArgs();
|
|
1178
97
|
if (help || version2) {
|
|
1179
|
-
|
|
98
|
+
process2.exit(0 /* Success */);
|
|
1180
99
|
} else {
|
|
1181
100
|
if (!options.all && !options.noGitCheck) {
|
|
1182
101
|
await checkGitStatus();
|
|
@@ -1185,12 +104,12 @@ async function main() {
|
|
|
1185
104
|
options.progress = options.progress ? options.progress : progress;
|
|
1186
105
|
await versionBump(options);
|
|
1187
106
|
}
|
|
1188
|
-
} catch (
|
|
1189
|
-
errorHandler2(
|
|
107
|
+
} catch (error) {
|
|
108
|
+
errorHandler2(error);
|
|
1190
109
|
}
|
|
1191
110
|
}
|
|
1192
111
|
async function checkGitStatus() {
|
|
1193
|
-
const { stdout } = await
|
|
112
|
+
const { stdout } = await x("git", ["status", "--porcelain"]);
|
|
1194
113
|
if (stdout.trim()) {
|
|
1195
114
|
throw new Error(`Git working tree is not clean:
|
|
1196
115
|
${stdout}`);
|
|
@@ -1218,15 +137,14 @@ function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
|
|
|
1218
137
|
break;
|
|
1219
138
|
}
|
|
1220
139
|
}
|
|
1221
|
-
function errorHandler2(
|
|
1222
|
-
let message =
|
|
1223
|
-
if (
|
|
1224
|
-
message =
|
|
140
|
+
function errorHandler2(error) {
|
|
141
|
+
let message = error.message || String(error);
|
|
142
|
+
if (process2.env.DEBUG || process2.env.NODE_ENV === "development")
|
|
143
|
+
message = error.stack || message;
|
|
1225
144
|
console.error(message);
|
|
1226
|
-
|
|
145
|
+
process2.exit(1 /* FatalError */);
|
|
1227
146
|
}
|
|
1228
|
-
|
|
1229
|
-
0 && (module.exports = {
|
|
147
|
+
export {
|
|
1230
148
|
checkGitStatus,
|
|
1231
149
|
main
|
|
1232
|
-
}
|
|
150
|
+
};
|