bumpp 9.11.1 → 10.0.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/bin/{bumpp.js → bumpp.mjs} +1 -1
- package/dist/{cli.js → cli.mjs} +52 -55
- package/dist/index.mjs +19 -0
- package/dist/{chunk-K27IS2ON.js → shared/bumpp.BiZDmkNc.mjs} +309 -374
- package/package.json +32 -34
- package/dist/cli.cjs +0 -1163
- package/dist/index.cjs +0 -1070
- package/dist/index.js +0 -23
- /package/dist/{cli.d.cts → cli.d.mts} +0 -0
- /package/dist/{index.d.cts → index.d.mts} +0 -0
|
@@ -1,137 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
|
|
32
|
-
// node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
33
|
-
var require_picocolors = __commonJS({
|
|
34
|
-
"node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
35
|
-
var p = process || {};
|
|
36
|
-
var argv = p.argv || [];
|
|
37
|
-
var env = p.env || {};
|
|
38
|
-
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);
|
|
39
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
40
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
41
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
42
|
-
};
|
|
43
|
-
var replaceClose = (string, close, replace, index) => {
|
|
44
|
-
let result = "", cursor = 0;
|
|
45
|
-
do {
|
|
46
|
-
result += string.substring(cursor, index) + replace;
|
|
47
|
-
cursor = index + close.length;
|
|
48
|
-
index = string.indexOf(close, cursor);
|
|
49
|
-
} while (~index);
|
|
50
|
-
return result + string.substring(cursor);
|
|
51
|
-
};
|
|
52
|
-
var createColors = (enabled = isColorSupported) => {
|
|
53
|
-
let f = enabled ? formatter : () => String;
|
|
54
|
-
return {
|
|
55
|
-
isColorSupported: enabled,
|
|
56
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
57
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
58
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
59
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
60
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
61
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
62
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
63
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
64
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
65
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
66
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
67
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
68
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
69
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
70
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
71
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
72
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
73
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
74
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
75
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
76
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
77
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
78
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
79
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
80
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
81
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
82
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
83
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
84
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
85
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
86
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
87
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
88
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
89
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
90
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
91
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
92
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
93
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
94
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
95
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
96
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
module.exports = createColors();
|
|
100
|
-
module.exports.createColors = createColors;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
1
|
+
import process$1 from 'node:process';
|
|
2
|
+
import prompts from 'prompts';
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import { x } from 'tinyexec';
|
|
5
|
+
import semver, { valid, SemVer, clean } from 'semver';
|
|
6
|
+
import fs, { existsSync } from 'node:fs';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import path__default, { dirname } from 'node:path';
|
|
9
|
+
import * as jsonc from 'jsonc-parser';
|
|
10
|
+
import fs$1 from 'node:fs/promises';
|
|
11
|
+
import yaml from 'js-yaml';
|
|
12
|
+
import { glob } from 'tinyglobby';
|
|
13
|
+
import { loadConfig } from 'c12';
|
|
14
|
+
import escalade from 'escalade/sync';
|
|
103
15
|
|
|
104
|
-
// src/
|
|
105
|
-
var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
|
|
106
|
-
ProgressEvent2["FileUpdated"] = "file updated";
|
|
107
|
-
ProgressEvent2["FileSkipped"] = "file skipped";
|
|
108
|
-
ProgressEvent2["GitCommit"] = "git commit";
|
|
109
|
-
ProgressEvent2["GitTag"] = "git tag";
|
|
110
|
-
ProgressEvent2["GitPush"] = "git push";
|
|
111
|
-
ProgressEvent2["NpmScript"] = "npm script";
|
|
112
|
-
return ProgressEvent2;
|
|
113
|
-
})(ProgressEvent || {});
|
|
114
|
-
var NpmScript = /* @__PURE__ */ ((NpmScript2) => {
|
|
115
|
-
NpmScript2["PreVersion"] = "preversion";
|
|
116
|
-
NpmScript2["Version"] = "version";
|
|
117
|
-
NpmScript2["PostVersion"] = "postversion";
|
|
118
|
-
return NpmScript2;
|
|
119
|
-
})(NpmScript || {});
|
|
120
|
-
|
|
121
|
-
// src/release-type.ts
|
|
122
|
-
var prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
123
|
-
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next", "conventional"]);
|
|
124
|
-
function isPrerelease(value) {
|
|
125
|
-
return prereleaseTypes.includes(value);
|
|
126
|
-
}
|
|
127
|
-
function isReleaseType(value) {
|
|
128
|
-
return releaseTypes.includes(value);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/version-bump.ts
|
|
132
|
-
import process5 from "node:process";
|
|
133
|
-
|
|
134
|
-
// node_modules/.pnpm/args-tokenizer@0.3.0/node_modules/args-tokenizer/dist/args-tokenizer.js
|
|
16
|
+
// src/args-tokenizer.ts
|
|
135
17
|
var spaceRegex = /\s/;
|
|
136
18
|
var tokenizeArgs = (argsString, options) => {
|
|
137
19
|
const tokens = [];
|
|
@@ -151,7 +33,7 @@ var tokenizeArgs = (argsString, options) => {
|
|
|
151
33
|
escaped = true;
|
|
152
34
|
continue;
|
|
153
35
|
}
|
|
154
|
-
if (openningQuote ===
|
|
36
|
+
if (openningQuote === undefined && spaceRegex.test(char)) {
|
|
155
37
|
if (currentToken.length > 0) {
|
|
156
38
|
tokens.push(currentToken);
|
|
157
39
|
currentToken = "";
|
|
@@ -159,12 +41,12 @@ var tokenizeArgs = (argsString, options) => {
|
|
|
159
41
|
continue;
|
|
160
42
|
}
|
|
161
43
|
if (char === "'" || char === '"') {
|
|
162
|
-
if (openningQuote ===
|
|
44
|
+
if (openningQuote === undefined) {
|
|
163
45
|
openningQuote = char;
|
|
164
46
|
continue;
|
|
165
47
|
}
|
|
166
48
|
if (openningQuote === char) {
|
|
167
|
-
openningQuote =
|
|
49
|
+
openningQuote = undefined;
|
|
168
50
|
continue;
|
|
169
51
|
}
|
|
170
52
|
}
|
|
@@ -173,123 +55,192 @@ var tokenizeArgs = (argsString, options) => {
|
|
|
173
55
|
if (currentToken.length > 0) {
|
|
174
56
|
tokens.push(currentToken);
|
|
175
57
|
}
|
|
176
|
-
if (options?.loose) {
|
|
177
|
-
return tokens;
|
|
178
|
-
}
|
|
179
58
|
if (openningQuote) {
|
|
180
59
|
throw Error("Unexpected end of string. Closing quote is missing.");
|
|
181
60
|
}
|
|
182
61
|
return tokens;
|
|
183
62
|
};
|
|
184
63
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
error: () => error,
|
|
189
|
-
info: () => info,
|
|
190
|
-
success: () => success,
|
|
191
|
-
warning: () => warning
|
|
192
|
-
});
|
|
64
|
+
function getDefaultExportFromCjs (x) {
|
|
65
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
66
|
+
}
|
|
193
67
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
var
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
var whiteBright = format(97, 39);
|
|
254
|
-
var bgRedBright = format(101, 49);
|
|
255
|
-
var bgGreenBright = format(102, 49);
|
|
256
|
-
var bgYellowBright = format(103, 49);
|
|
257
|
-
var bgBlueBright = format(104, 49);
|
|
258
|
-
var bgMagentaBright = format(105, 49);
|
|
259
|
-
var bgCyanBright = format(106, 49);
|
|
260
|
-
var bgWhiteBright = format(107, 49);
|
|
68
|
+
var picocolors = {exports: {}};
|
|
69
|
+
|
|
70
|
+
var hasRequiredPicocolors;
|
|
71
|
+
|
|
72
|
+
function requirePicocolors () {
|
|
73
|
+
if (hasRequiredPicocolors) return picocolors.exports;
|
|
74
|
+
hasRequiredPicocolors = 1;
|
|
75
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
76
|
+
let isColorSupported =
|
|
77
|
+
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
78
|
+
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
79
|
+
|
|
80
|
+
let formatter = (open, close, replace = open) =>
|
|
81
|
+
input => {
|
|
82
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
83
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
let replaceClose = (string, close, replace, index) => {
|
|
87
|
+
let result = "", cursor = 0;
|
|
88
|
+
do {
|
|
89
|
+
result += string.substring(cursor, index) + replace;
|
|
90
|
+
cursor = index + close.length;
|
|
91
|
+
index = string.indexOf(close, cursor);
|
|
92
|
+
} while (~index)
|
|
93
|
+
return result + string.substring(cursor)
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
let createColors = (enabled = isColorSupported) => {
|
|
97
|
+
let f = enabled ? formatter : () => String;
|
|
98
|
+
return {
|
|
99
|
+
isColorSupported: enabled,
|
|
100
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
101
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
102
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
103
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
104
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
105
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
106
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
107
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
108
|
+
|
|
109
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
110
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
111
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
112
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
113
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
114
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
115
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
116
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
117
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
118
|
+
|
|
119
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
120
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
121
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
122
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
123
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
124
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
125
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
126
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
261
127
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
128
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
129
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
130
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
131
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
132
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
133
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
134
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
135
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
136
|
+
|
|
137
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
138
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
139
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
140
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
141
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
142
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
143
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
144
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
picocolors.exports = createColors();
|
|
149
|
+
picocolors.exports.createColors = createColors;
|
|
150
|
+
return picocolors.exports;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
var picocolorsExports = /*@__PURE__*/ requirePicocolors();
|
|
154
|
+
const c = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
155
|
+
|
|
156
|
+
function execCommand(cmd, options) {
|
|
157
|
+
try {
|
|
158
|
+
return execSync(cmd, { encoding: "utf8", cwd: options?.cwd }).trim();
|
|
159
|
+
} catch (error) {
|
|
160
|
+
return "";
|
|
269
161
|
}
|
|
270
|
-
|
|
162
|
+
}
|
|
163
|
+
function getLastGitTag() {
|
|
164
|
+
return execCommand("git describe --tags --abbrev=0")?.split("\n").at(0) || undefined;
|
|
165
|
+
}
|
|
166
|
+
const GIT_LOG_FORMAT = "%h|%s|%an|%ae|%ad|%b[GIT_LOG_COMMIT_END]";
|
|
167
|
+
function getGitLog(from, to = "HEAD") {
|
|
168
|
+
return execCommand(`git --no-pager log "${from ? `${from}...${to}` : to}" --pretty="${GIT_LOG_FORMAT}"`).split("[GIT_LOG_COMMIT_END]\n").filter(Boolean);
|
|
271
169
|
}
|
|
272
170
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
171
|
+
const ConventionalCommitRegex = /(?<emoji>:.+:|(\uD83C[\uDF00-\uDFFF])|(\uD83D[\uDC00-\uDE4F\uDE80-\uDEFF])|[\u2600-\u2B55])?( *)(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
172
|
+
const CoAuthoredByRegex = /co-authored-by:\s*(?<name>.+)(<(?<email>.+)>)/gi;
|
|
173
|
+
const PullRequestRE = /\([ a-z]*(#\d+)\s*\)/g;
|
|
174
|
+
const IssueRE = /(#\d+)/g;
|
|
175
|
+
const BreakingRE = /breaking[ -]changes?:/i;
|
|
176
|
+
function parseRawCommit(commit) {
|
|
177
|
+
const [shortHash, message, authorName, authorEmail, data, ..._body] = commit.split("|");
|
|
178
|
+
const body = _body.filter(Boolean).join("\n");
|
|
179
|
+
return {
|
|
180
|
+
author: { name: authorName, email: authorEmail },
|
|
181
|
+
body,
|
|
182
|
+
data,
|
|
183
|
+
message,
|
|
184
|
+
shortHash
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function parseCommit(rawCommit) {
|
|
188
|
+
const { shortHash, message, body, data } = rawCommit;
|
|
189
|
+
const match = message.match(ConventionalCommitRegex);
|
|
190
|
+
const isConventional = match !== null;
|
|
191
|
+
const type = match?.groups?.type || "";
|
|
192
|
+
const scope = match?.groups?.scope || "";
|
|
193
|
+
let description = match?.groups?.description || message;
|
|
194
|
+
const hasBreakingBody = BreakingRE.test(body);
|
|
195
|
+
const isBreaking = Boolean(match?.groups?.breaking || hasBreakingBody);
|
|
196
|
+
const references = [];
|
|
197
|
+
for (const m of description.matchAll(PullRequestRE)) {
|
|
198
|
+
references.push({ type: "pull-request", value: m[1] });
|
|
199
|
+
}
|
|
200
|
+
for (const m of description.matchAll(IssueRE)) {
|
|
201
|
+
if (!references.some((i) => i.value === m[1])) {
|
|
202
|
+
references.push({ type: "issue", value: m[1] });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
description = description.replace(PullRequestRE, "").trim();
|
|
206
|
+
const authors = [rawCommit.author];
|
|
207
|
+
for (const match2 of body.matchAll(CoAuthoredByRegex)) {
|
|
208
|
+
authors.push({
|
|
209
|
+
name: (match2.groups?.name || "").trim(),
|
|
210
|
+
email: (match2.groups?.email || "").trim()
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
authors,
|
|
215
|
+
body,
|
|
216
|
+
data,
|
|
217
|
+
description,
|
|
218
|
+
isBreaking,
|
|
219
|
+
isConventional,
|
|
220
|
+
message,
|
|
221
|
+
references,
|
|
222
|
+
scope,
|
|
223
|
+
shortHash,
|
|
224
|
+
type
|
|
225
|
+
};
|
|
226
|
+
}
|
|
279
227
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
228
|
+
function getCommits(from, to) {
|
|
229
|
+
return getGitLog(from, to).map(parseRawCommit).map(parseCommit);
|
|
230
|
+
}
|
|
231
|
+
function getRecentCommits(from, to) {
|
|
232
|
+
if (!from)
|
|
233
|
+
from = getLastGitTag();
|
|
234
|
+
if (!to)
|
|
235
|
+
to = "HEAD";
|
|
236
|
+
return getCommits(from, to);
|
|
237
|
+
}
|
|
285
238
|
|
|
286
|
-
|
|
287
|
-
|
|
239
|
+
const symbols = {
|
|
240
|
+
success: c.green("\u2714"),
|
|
241
|
+
info: c.blue("\u2139")
|
|
242
|
+
};
|
|
288
243
|
|
|
289
|
-
// src/fs.ts
|
|
290
|
-
import fs from "node:fs";
|
|
291
|
-
import path from "node:path";
|
|
292
|
-
import * as jsonc from "jsonc-parser";
|
|
293
244
|
async function readJsoncFile(name, cwd) {
|
|
294
245
|
const file = await readTextFile(name, cwd);
|
|
295
246
|
const data = jsonc.parse(file.data);
|
|
@@ -306,7 +257,7 @@ async function writeJsoncFile(file) {
|
|
|
306
257
|
}
|
|
307
258
|
function readTextFile(name, cwd) {
|
|
308
259
|
return new Promise((resolve, reject) => {
|
|
309
|
-
const filePath =
|
|
260
|
+
const filePath = path__default.join(cwd, name);
|
|
310
261
|
fs.readFile(filePath, "utf8", (err, text) => {
|
|
311
262
|
if (err) {
|
|
312
263
|
reject(err);
|
|
@@ -330,7 +281,6 @@ function writeTextFile(file) {
|
|
|
330
281
|
});
|
|
331
282
|
}
|
|
332
283
|
|
|
333
|
-
// src/manifest.ts
|
|
334
284
|
function isManifest(obj) {
|
|
335
285
|
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
336
286
|
}
|
|
@@ -342,7 +292,6 @@ function isOptionalString(value) {
|
|
|
342
292
|
return value === null || type === "undefined" || type === "string";
|
|
343
293
|
}
|
|
344
294
|
|
|
345
|
-
// src/get-current-version.ts
|
|
346
295
|
async function getCurrentVersion(operation) {
|
|
347
296
|
if (operation.state.currentVersion)
|
|
348
297
|
return operation;
|
|
@@ -371,19 +320,23 @@ async function readVersion(file, cwd) {
|
|
|
371
320
|
try {
|
|
372
321
|
const { data: manifest } = await readJsoncFile(file, cwd);
|
|
373
322
|
if (isManifest(manifest)) {
|
|
374
|
-
if (
|
|
323
|
+
if (valid(manifest.version))
|
|
375
324
|
return manifest.version;
|
|
376
325
|
}
|
|
377
326
|
} catch {
|
|
378
|
-
return
|
|
327
|
+
return undefined;
|
|
379
328
|
}
|
|
380
329
|
}
|
|
381
330
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
331
|
+
const prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
332
|
+
const releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next", "conventional"]);
|
|
333
|
+
function isPrerelease(value) {
|
|
334
|
+
return prereleaseTypes.includes(value);
|
|
335
|
+
}
|
|
336
|
+
function isReleaseType(value) {
|
|
337
|
+
return releaseTypes.includes(value);
|
|
338
|
+
}
|
|
339
|
+
|
|
387
340
|
async function getNewVersion(operation, commits) {
|
|
388
341
|
const { release } = operation.options;
|
|
389
342
|
const { currentVersion } = operation.state;
|
|
@@ -431,9 +384,9 @@ function determineSemverChange(commits) {
|
|
|
431
384
|
}
|
|
432
385
|
function getNextVersions(currentVersion, preid, commits) {
|
|
433
386
|
const next = {};
|
|
434
|
-
const
|
|
435
|
-
if (typeof
|
|
436
|
-
preid =
|
|
387
|
+
const parse = semver.parse(currentVersion);
|
|
388
|
+
if (typeof parse?.prerelease[0] === "string")
|
|
389
|
+
preid = parse?.prerelease[0] || "preid";
|
|
437
390
|
for (const type of releaseTypes)
|
|
438
391
|
next[type] = getNextVersion(currentVersion, { type, preid }, commits);
|
|
439
392
|
return next;
|
|
@@ -448,21 +401,21 @@ async function promptForNewVersion(operation, commits) {
|
|
|
448
401
|
{
|
|
449
402
|
type: "autocomplete",
|
|
450
403
|
name: "release",
|
|
451
|
-
message: `Current version ${
|
|
404
|
+
message: `Current version ${c.green(currentVersion)}`,
|
|
452
405
|
initial: configCustomVersion ? "config" : "next",
|
|
453
406
|
choices: [
|
|
454
|
-
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${
|
|
455
|
-
{ value: "minor", title: `${"minor".padStart(PADDING, " ")} ${
|
|
456
|
-
{ value: "patch", title: `${"patch".padStart(PADDING, " ")} ${
|
|
457
|
-
{ value: "next", title: `${"next".padStart(PADDING, " ")} ${
|
|
458
|
-
{ value: "conventional", title: `${"conventional".padStart(PADDING, " ")} ${
|
|
407
|
+
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${c.bold(next.major)}` },
|
|
408
|
+
{ value: "minor", title: `${"minor".padStart(PADDING, " ")} ${c.bold(next.minor)}` },
|
|
409
|
+
{ value: "patch", title: `${"patch".padStart(PADDING, " ")} ${c.bold(next.patch)}` },
|
|
410
|
+
{ value: "next", title: `${"next".padStart(PADDING, " ")} ${c.bold(next.next)}` },
|
|
411
|
+
{ value: "conventional", title: `${"conventional".padStart(PADDING, " ")} ${c.bold(next.conventional)}` },
|
|
459
412
|
...configCustomVersion ? [
|
|
460
|
-
{ value: "config", title: `${"from config".padStart(PADDING, " ")} ${
|
|
413
|
+
{ value: "config", title: `${"from config".padStart(PADDING, " ")} ${c.bold(configCustomVersion)}` }
|
|
461
414
|
] : [],
|
|
462
|
-
{ value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${
|
|
463
|
-
{ value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${
|
|
464
|
-
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${
|
|
465
|
-
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${
|
|
415
|
+
{ value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${c.bold(next.prepatch)}` },
|
|
416
|
+
{ value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${c.bold(next.preminor)}` },
|
|
417
|
+
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${c.bold(next.premajor)}` },
|
|
418
|
+
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${c.bold(currentVersion)}` },
|
|
466
419
|
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
|
|
467
420
|
]
|
|
468
421
|
},
|
|
@@ -472,13 +425,13 @@ async function promptForNewVersion(operation, commits) {
|
|
|
472
425
|
message: "Enter the new version number:",
|
|
473
426
|
initial: currentVersion,
|
|
474
427
|
validate: (custom) => {
|
|
475
|
-
return
|
|
428
|
+
return valid(custom) ? true : "That's not a valid version number";
|
|
476
429
|
}
|
|
477
430
|
}
|
|
478
431
|
]);
|
|
479
|
-
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ?
|
|
432
|
+
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? clean(answers.custom) : answers.release === "config" ? clean(configCustomVersion) : next[answers.release];
|
|
480
433
|
if (!newVersion)
|
|
481
|
-
|
|
434
|
+
process$1.exit(1);
|
|
482
435
|
switch (answers.release) {
|
|
483
436
|
case "custom":
|
|
484
437
|
case "config":
|
|
@@ -491,8 +444,22 @@ async function promptForNewVersion(operation, commits) {
|
|
|
491
444
|
}
|
|
492
445
|
}
|
|
493
446
|
|
|
494
|
-
|
|
495
|
-
|
|
447
|
+
var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
|
|
448
|
+
ProgressEvent2["FileUpdated"] = "file updated";
|
|
449
|
+
ProgressEvent2["FileSkipped"] = "file skipped";
|
|
450
|
+
ProgressEvent2["GitCommit"] = "git commit";
|
|
451
|
+
ProgressEvent2["GitTag"] = "git tag";
|
|
452
|
+
ProgressEvent2["GitPush"] = "git push";
|
|
453
|
+
ProgressEvent2["NpmScript"] = "npm script";
|
|
454
|
+
return ProgressEvent2;
|
|
455
|
+
})(ProgressEvent || {});
|
|
456
|
+
var NpmScript = /* @__PURE__ */ ((NpmScript2) => {
|
|
457
|
+
NpmScript2["PreVersion"] = "preversion";
|
|
458
|
+
NpmScript2["Version"] = "version";
|
|
459
|
+
NpmScript2["PostVersion"] = "postversion";
|
|
460
|
+
return NpmScript2;
|
|
461
|
+
})(NpmScript || {});
|
|
462
|
+
|
|
496
463
|
async function gitCommit(operation) {
|
|
497
464
|
if (!operation.options.commit)
|
|
498
465
|
return operation;
|
|
@@ -513,7 +480,7 @@ async function gitCommit(operation) {
|
|
|
513
480
|
if (!all)
|
|
514
481
|
args = args.concat(updatedFiles);
|
|
515
482
|
await x("git", ["commit", ...args], { throwOnError: true });
|
|
516
|
-
return operation.update({ event:
|
|
483
|
+
return operation.update({ event: ProgressEvent.GitCommit, commitMessage });
|
|
517
484
|
}
|
|
518
485
|
async function gitTag(operation) {
|
|
519
486
|
if (!operation.options.tag)
|
|
@@ -534,7 +501,7 @@ async function gitTag(operation) {
|
|
|
534
501
|
args.push("--sign");
|
|
535
502
|
}
|
|
536
503
|
await x("git", ["tag", ...args], { throwOnError: true });
|
|
537
|
-
return operation.update({ event:
|
|
504
|
+
return operation.update({ event: ProgressEvent.GitTag, tagName });
|
|
538
505
|
}
|
|
539
506
|
async function gitPush(operation) {
|
|
540
507
|
if (!operation.options.push)
|
|
@@ -543,7 +510,7 @@ async function gitPush(operation) {
|
|
|
543
510
|
if (operation.options.tag) {
|
|
544
511
|
await x("git", ["push", "--tags"], { throwOnError: true });
|
|
545
512
|
}
|
|
546
|
-
return operation.update({ event:
|
|
513
|
+
return operation.update({ event: ProgressEvent.GitPush });
|
|
547
514
|
}
|
|
548
515
|
function formatVersionString(template, newVersion) {
|
|
549
516
|
if (template.includes("%s"))
|
|
@@ -552,12 +519,6 @@ function formatVersionString(template, newVersion) {
|
|
|
552
519
|
return template + newVersion;
|
|
553
520
|
}
|
|
554
521
|
|
|
555
|
-
// src/normalize-options.ts
|
|
556
|
-
import fsSync from "node:fs";
|
|
557
|
-
import fs2 from "node:fs/promises";
|
|
558
|
-
import process4 from "node:process";
|
|
559
|
-
import yaml from "js-yaml";
|
|
560
|
-
import { glob } from "tinyglobby";
|
|
561
522
|
async function normalizeOptions(raw) {
|
|
562
523
|
const preid = typeof raw.preid === "string" ? raw.preid : "beta";
|
|
563
524
|
const sign = Boolean(raw.sign);
|
|
@@ -565,7 +526,7 @@ async function normalizeOptions(raw) {
|
|
|
565
526
|
const all = Boolean(raw.all);
|
|
566
527
|
const install = Boolean(raw.install);
|
|
567
528
|
const noVerify = Boolean(raw.noVerify);
|
|
568
|
-
const cwd = raw.cwd ||
|
|
529
|
+
const cwd = raw.cwd || process$1.cwd();
|
|
569
530
|
const ignoreScripts = Boolean(raw.ignoreScripts);
|
|
570
531
|
const execute = raw.execute;
|
|
571
532
|
const recursive = Boolean(raw.recursive);
|
|
@@ -596,8 +557,8 @@ async function normalizeOptions(raw) {
|
|
|
596
557
|
"deno.json",
|
|
597
558
|
"deno.jsonc"
|
|
598
559
|
];
|
|
599
|
-
if (
|
|
600
|
-
const pnpmWorkspace = await
|
|
560
|
+
if (fs.existsSync("pnpm-workspace.yaml")) {
|
|
561
|
+
const pnpmWorkspace = await fs$1.readFile("pnpm-workspace.yaml", "utf8");
|
|
601
562
|
const workspaces = yaml.load(pnpmWorkspace);
|
|
602
563
|
const workspacesWithPackageJson = workspaces.packages.map((workspace) => `${workspace}/package.json`);
|
|
603
564
|
const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => !workspace.startsWith("!") && !raw.files?.includes(workspace));
|
|
@@ -621,13 +582,13 @@ async function normalizeOptions(raw) {
|
|
|
621
582
|
if (raw.interface === false) {
|
|
622
583
|
ui = { input: false, output: false };
|
|
623
584
|
} else if (raw.interface === true || !raw.interface) {
|
|
624
|
-
ui = { input:
|
|
585
|
+
ui = { input: process$1.stdin, output: process$1.stdout };
|
|
625
586
|
} else {
|
|
626
587
|
let { input, output, ...other } = raw.interface;
|
|
627
588
|
if (input === true || input !== false && !input)
|
|
628
|
-
input =
|
|
589
|
+
input = process$1.stdin;
|
|
629
590
|
if (output === true || output !== false && !output)
|
|
630
|
-
output =
|
|
591
|
+
output = process$1.stdout;
|
|
631
592
|
ui = { input, output, ...other };
|
|
632
593
|
}
|
|
633
594
|
if (release.type === "prompt" && !(ui.input && ui.output))
|
|
@@ -650,8 +611,7 @@ async function normalizeOptions(raw) {
|
|
|
650
611
|
};
|
|
651
612
|
}
|
|
652
613
|
|
|
653
|
-
|
|
654
|
-
var Operation = class _Operation {
|
|
614
|
+
class Operation {
|
|
655
615
|
/**
|
|
656
616
|
* The options for this operation.
|
|
657
617
|
*/
|
|
@@ -660,7 +620,7 @@ var Operation = class _Operation {
|
|
|
660
620
|
* The current state of the operation.
|
|
661
621
|
*/
|
|
662
622
|
state = {
|
|
663
|
-
release:
|
|
623
|
+
release: undefined,
|
|
664
624
|
currentVersion: "",
|
|
665
625
|
currentVersionSource: "",
|
|
666
626
|
newVersion: "",
|
|
@@ -707,7 +667,7 @@ var Operation = class _Operation {
|
|
|
707
667
|
*/
|
|
708
668
|
static async start(input) {
|
|
709
669
|
const options = await normalizeOptions(input);
|
|
710
|
-
return new
|
|
670
|
+
return new Operation(options, input.progress);
|
|
711
671
|
}
|
|
712
672
|
/**
|
|
713
673
|
* Updates the operation state and results, and reports the updated progress to the user.
|
|
@@ -719,64 +679,62 @@ var Operation = class _Operation {
|
|
|
719
679
|
}
|
|
720
680
|
return this;
|
|
721
681
|
}
|
|
722
|
-
}
|
|
682
|
+
}
|
|
723
683
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
revert: import_picocolors2.default.red,
|
|
744
|
-
breaking: import_picocolors2.default.red
|
|
684
|
+
const messageColorMap = {
|
|
685
|
+
feat: c.green,
|
|
686
|
+
feature: c.green,
|
|
687
|
+
refactor: c.cyan,
|
|
688
|
+
style: c.cyan,
|
|
689
|
+
docs: c.blue,
|
|
690
|
+
doc: c.blue,
|
|
691
|
+
types: c.blue,
|
|
692
|
+
type: c.blue,
|
|
693
|
+
chore: c.gray,
|
|
694
|
+
ci: c.gray,
|
|
695
|
+
build: c.gray,
|
|
696
|
+
deps: c.gray,
|
|
697
|
+
dev: c.gray,
|
|
698
|
+
fix: c.yellow,
|
|
699
|
+
test: c.yellow,
|
|
700
|
+
perf: c.magenta,
|
|
701
|
+
revert: c.red,
|
|
702
|
+
breaking: c.red
|
|
745
703
|
};
|
|
746
704
|
function formatParsedCommits(commits) {
|
|
747
705
|
const typeLength = commits.map(({ type }) => type.length).reduce((a, b) => Math.max(a, b), 0);
|
|
748
706
|
const scopeLength = commits.map(({ scope }) => scope.length).reduce((a, b) => Math.max(a, b), 0);
|
|
749
707
|
return commits.map((commit) => {
|
|
750
|
-
let color = messageColorMap[commit.type] || ((
|
|
708
|
+
let color = messageColorMap[commit.type] || ((c2) => c2);
|
|
751
709
|
if (commit.isBreaking) {
|
|
752
|
-
color = (s) =>
|
|
710
|
+
color = (s) => c.inverse(c.red(s));
|
|
753
711
|
}
|
|
754
712
|
const paddedType = commit.type.padStart(typeLength + 1, " ");
|
|
755
|
-
const paddedScope = !commit.scope ? " ".repeat(scopeLength ? scopeLength + 2 : 0) :
|
|
713
|
+
const paddedScope = !commit.scope ? " ".repeat(scopeLength ? scopeLength + 2 : 0) : c.dim("(") + commit.scope + c.dim(")") + " ".repeat(scopeLength - commit.scope.length);
|
|
756
714
|
return [
|
|
757
|
-
|
|
715
|
+
c.dim(commit.shortHash),
|
|
758
716
|
" ",
|
|
759
|
-
color ===
|
|
717
|
+
color === c.gray ? color(paddedType) : c.bold(color(paddedType)),
|
|
760
718
|
" ",
|
|
761
719
|
paddedScope,
|
|
762
|
-
|
|
720
|
+
c.dim(":"),
|
|
763
721
|
" ",
|
|
764
|
-
color ===
|
|
722
|
+
color === c.gray ? color(commit.description) : commit.description
|
|
765
723
|
].join("");
|
|
766
724
|
});
|
|
767
725
|
}
|
|
768
726
|
function printRecentCommits(commits) {
|
|
769
727
|
if (!commits.length) {
|
|
770
728
|
console.log();
|
|
771
|
-
console.log(
|
|
729
|
+
console.log(c.blue(`i`) + c.gray(` No commits since the last version`));
|
|
772
730
|
console.log();
|
|
773
731
|
return;
|
|
774
732
|
}
|
|
775
733
|
const prettified = formatParsedCommits(commits);
|
|
776
734
|
console.log();
|
|
777
735
|
console.log(
|
|
778
|
-
|
|
779
|
-
`${
|
|
736
|
+
c.bold(
|
|
737
|
+
`${c.green(commits.length)} Commits since the last version:`
|
|
780
738
|
)
|
|
781
739
|
);
|
|
782
740
|
console.log();
|
|
@@ -784,17 +742,15 @@ function printRecentCommits(commits) {
|
|
|
784
742
|
console.log();
|
|
785
743
|
}
|
|
786
744
|
|
|
787
|
-
// src/run-npm-script.ts
|
|
788
|
-
import { x as x2 } from "tinyexec";
|
|
789
745
|
async function runNpmScript(script, operation) {
|
|
790
746
|
const { cwd, ignoreScripts } = operation.options;
|
|
791
747
|
if (!ignoreScripts) {
|
|
792
748
|
const { data: manifest } = await readJsoncFile("package.json", cwd);
|
|
793
749
|
if (isManifest(manifest) && hasScript(manifest, script)) {
|
|
794
|
-
await
|
|
750
|
+
await x("npm", ["run", script, "--silent"], {
|
|
795
751
|
nodeOptions: { stdio: "inherit" }
|
|
796
752
|
});
|
|
797
|
-
operation.update({ event:
|
|
753
|
+
operation.update({ event: ProgressEvent.NpmScript, script });
|
|
798
754
|
}
|
|
799
755
|
}
|
|
800
756
|
return operation;
|
|
@@ -806,21 +762,18 @@ function hasScript(manifest, script) {
|
|
|
806
762
|
return false;
|
|
807
763
|
}
|
|
808
764
|
|
|
809
|
-
// src/update-files.ts
|
|
810
|
-
import { existsSync } from "node:fs";
|
|
811
|
-
import * as path2 from "node:path";
|
|
812
765
|
async function updateFiles(operation) {
|
|
813
766
|
const { files } = operation.options;
|
|
814
767
|
for (const relPath of files) {
|
|
815
768
|
const modified = await updateFile(relPath, operation);
|
|
816
769
|
if (modified) {
|
|
817
770
|
operation.update({
|
|
818
|
-
event:
|
|
771
|
+
event: ProgressEvent.FileUpdated,
|
|
819
772
|
updatedFiles: operation.state.updatedFiles.concat(relPath)
|
|
820
773
|
});
|
|
821
774
|
} else {
|
|
822
775
|
operation.update({
|
|
823
|
-
event:
|
|
776
|
+
event: ProgressEvent.FileSkipped,
|
|
824
777
|
skippedFiles: operation.state.skippedFiles.concat(relPath)
|
|
825
778
|
});
|
|
826
779
|
}
|
|
@@ -828,10 +781,10 @@ async function updateFiles(operation) {
|
|
|
828
781
|
return operation;
|
|
829
782
|
}
|
|
830
783
|
async function updateFile(relPath, operation) {
|
|
831
|
-
if (!existsSync(
|
|
784
|
+
if (!existsSync(path.join(operation.options.cwd, relPath))) {
|
|
832
785
|
return false;
|
|
833
786
|
}
|
|
834
|
-
const name =
|
|
787
|
+
const name = path.basename(relPath).trim().toLowerCase();
|
|
835
788
|
switch (name) {
|
|
836
789
|
case "package.json":
|
|
837
790
|
case "package-lock.json":
|
|
@@ -881,7 +834,6 @@ async function updateTextFile(relPath, operation) {
|
|
|
881
834
|
return modified;
|
|
882
835
|
}
|
|
883
836
|
|
|
884
|
-
// src/version-bump.ts
|
|
885
837
|
async function versionBump(arg = {}) {
|
|
886
838
|
if (typeof arg === "string")
|
|
887
839
|
arg = { release: arg };
|
|
@@ -894,77 +846,77 @@ async function versionBump(arg = {}) {
|
|
|
894
846
|
await getNewVersion(operation, commits);
|
|
895
847
|
if (arg.confirm) {
|
|
896
848
|
printSummary(operation);
|
|
897
|
-
if (!await
|
|
849
|
+
if (!await prompts({
|
|
898
850
|
name: "yes",
|
|
899
851
|
type: "confirm",
|
|
900
852
|
message: "Bump?",
|
|
901
853
|
initial: true
|
|
902
854
|
}).then((r) => r.yes)) {
|
|
903
|
-
|
|
855
|
+
process$1.exit(1);
|
|
904
856
|
}
|
|
905
857
|
}
|
|
906
|
-
await runNpmScript(
|
|
858
|
+
await runNpmScript(NpmScript.PreVersion, operation);
|
|
907
859
|
await updateFiles(operation);
|
|
908
860
|
if (operation.options.install) {
|
|
909
|
-
const { detect } = await import(
|
|
861
|
+
const { detect } = await import('package-manager-detector/detect');
|
|
910
862
|
const pm = await detect();
|
|
911
863
|
if (!pm?.name) {
|
|
912
864
|
throw new Error("Could not detect package manager, failed to run npm install");
|
|
913
865
|
}
|
|
914
|
-
const { COMMANDS, constructCommand } = await import(
|
|
866
|
+
const { COMMANDS, constructCommand } = await import('package-manager-detector/commands');
|
|
915
867
|
const command = constructCommand(COMMANDS[pm.name].install, []);
|
|
916
868
|
if (!command) {
|
|
917
869
|
throw new Error("Could not find install command for package manager");
|
|
918
870
|
}
|
|
919
|
-
console.log(
|
|
920
|
-
await
|
|
871
|
+
console.log(symbols.info, "Installing dependencies with", `${command.command} ${command.args.join(" ")}`);
|
|
872
|
+
await x(command.command, command.args, {
|
|
921
873
|
throwOnError: true,
|
|
922
874
|
nodeOptions: {
|
|
923
875
|
stdio: "inherit",
|
|
924
876
|
cwd: operation.options.cwd
|
|
925
877
|
}
|
|
926
878
|
});
|
|
927
|
-
console.log(
|
|
879
|
+
console.log(symbols.success, "Dependencies installed");
|
|
928
880
|
}
|
|
929
881
|
if (operation.options.execute) {
|
|
930
882
|
if (typeof operation.options.execute === "function") {
|
|
931
883
|
await operation.options.execute(operation);
|
|
932
884
|
} else {
|
|
933
885
|
const [command, ...args] = tokenizeArgs(operation.options.execute);
|
|
934
|
-
console.log(
|
|
935
|
-
await
|
|
886
|
+
console.log(symbols.info, "Executing script", command, ...args);
|
|
887
|
+
await x(command, args, {
|
|
936
888
|
throwOnError: true,
|
|
937
889
|
nodeOptions: {
|
|
938
890
|
stdio: "inherit",
|
|
939
891
|
cwd: operation.options.cwd
|
|
940
892
|
}
|
|
941
893
|
});
|
|
942
|
-
console.log(
|
|
894
|
+
console.log(symbols.success, "Script finished");
|
|
943
895
|
}
|
|
944
896
|
}
|
|
945
|
-
await runNpmScript(
|
|
897
|
+
await runNpmScript(NpmScript.Version, operation);
|
|
946
898
|
await gitCommit(operation);
|
|
947
899
|
await gitTag(operation);
|
|
948
|
-
await runNpmScript(
|
|
900
|
+
await runNpmScript(NpmScript.PostVersion, operation);
|
|
949
901
|
await gitPush(operation);
|
|
950
902
|
return operation.results;
|
|
951
903
|
}
|
|
952
904
|
function printSummary(operation) {
|
|
953
905
|
console.log();
|
|
954
|
-
console.log(` files ${operation.options.files.map((i) =>
|
|
906
|
+
console.log(` files ${operation.options.files.map((i) => c.bold(i)).join("\n ")}`);
|
|
955
907
|
if (operation.options.commit)
|
|
956
|
-
console.log(` commit ${
|
|
908
|
+
console.log(` commit ${c.bold(formatVersionString(operation.options.commit.message, operation.state.newVersion))}`);
|
|
957
909
|
if (operation.options.tag)
|
|
958
|
-
console.log(` tag ${
|
|
910
|
+
console.log(` tag ${c.bold(formatVersionString(operation.options.tag.name, operation.state.newVersion))}`);
|
|
959
911
|
if (operation.options.execute)
|
|
960
|
-
console.log(` execute ${
|
|
912
|
+
console.log(` execute ${c.bold(typeof operation.options.execute === "function" ? "function" : operation.options.execute)}`);
|
|
961
913
|
if (operation.options.push)
|
|
962
|
-
console.log(` push ${
|
|
914
|
+
console.log(` push ${c.cyan(c.bold("yes"))}`);
|
|
963
915
|
if (operation.options.install)
|
|
964
|
-
console.log(` install ${
|
|
916
|
+
console.log(` install ${c.cyan(c.bold("yes"))}`);
|
|
965
917
|
console.log();
|
|
966
|
-
console.log(` from ${
|
|
967
|
-
console.log(` to ${
|
|
918
|
+
console.log(` from ${c.bold(operation.state.currentVersion)}`);
|
|
919
|
+
console.log(` to ${c.green(c.bold(operation.state.newVersion))}`);
|
|
968
920
|
console.log();
|
|
969
921
|
}
|
|
970
922
|
async function versionBumpInfo(arg = {}) {
|
|
@@ -977,12 +929,7 @@ async function versionBumpInfo(arg = {}) {
|
|
|
977
929
|
return operation;
|
|
978
930
|
}
|
|
979
931
|
|
|
980
|
-
|
|
981
|
-
import { dirname } from "node:path";
|
|
982
|
-
import process6 from "node:process";
|
|
983
|
-
import { loadConfig } from "c12";
|
|
984
|
-
import escalade from "escalade/sync";
|
|
985
|
-
var bumpConfigDefaults = {
|
|
932
|
+
const bumpConfigDefaults = {
|
|
986
933
|
commit: true,
|
|
987
934
|
push: true,
|
|
988
935
|
tag: true,
|
|
@@ -996,7 +943,7 @@ var bumpConfigDefaults = {
|
|
|
996
943
|
noGitCheck: true,
|
|
997
944
|
files: []
|
|
998
945
|
};
|
|
999
|
-
async function loadBumpConfig(overrides, cwd =
|
|
946
|
+
async function loadBumpConfig(overrides, cwd = process$1.cwd()) {
|
|
1000
947
|
const name = "bump";
|
|
1001
948
|
const configFile = findConfigFile(name, cwd);
|
|
1002
949
|
const { config } = await loadConfig({
|
|
@@ -1028,26 +975,14 @@ function findConfigFile(name, cwd) {
|
|
|
1028
975
|
}
|
|
1029
976
|
return false;
|
|
1030
977
|
});
|
|
1031
|
-
} catch (
|
|
978
|
+
} catch (error) {
|
|
1032
979
|
if (foundRepositoryRoot)
|
|
1033
980
|
return null;
|
|
1034
|
-
throw
|
|
981
|
+
throw error;
|
|
1035
982
|
}
|
|
1036
983
|
}
|
|
1037
984
|
function defineConfig(config) {
|
|
1038
985
|
return config;
|
|
1039
986
|
}
|
|
1040
987
|
|
|
1041
|
-
export {
|
|
1042
|
-
__toESM,
|
|
1043
|
-
symbols_exports,
|
|
1044
|
-
ProgressEvent,
|
|
1045
|
-
NpmScript,
|
|
1046
|
-
require_picocolors,
|
|
1047
|
-
isReleaseType,
|
|
1048
|
-
versionBump,
|
|
1049
|
-
versionBumpInfo,
|
|
1050
|
-
bumpConfigDefaults,
|
|
1051
|
-
loadBumpConfig,
|
|
1052
|
-
defineConfig
|
|
1053
|
-
};
|
|
988
|
+
export { NpmScript as N, ProgressEvent as P, versionBumpInfo as a, bumpConfigDefaults as b, c, defineConfig as d, isReleaseType as i, loadBumpConfig as l, symbols as s, versionBump as v };
|