bumpp 10.0.3 → 10.1.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/cli.mjs +8 -6
- package/dist/index.mjs +6 -4
- package/dist/shared/bumpp.BYfOJvKL.mjs +7129 -0
- package/package.json +16 -17
- package/dist/shared/bumpp.B_9jg8A3.mjs +0 -941
|
@@ -1,941 +0,0 @@
|
|
|
1
|
-
import process$1 from 'node:process';
|
|
2
|
-
import { tokenizeArgs } from 'args-tokenizer';
|
|
3
|
-
import prompts from 'prompts';
|
|
4
|
-
import { execSync } from 'node:child_process';
|
|
5
|
-
import { x } from 'tinyexec';
|
|
6
|
-
import semver, { valid, SemVer, clean } from 'semver';
|
|
7
|
-
import fs, { existsSync } from 'node:fs';
|
|
8
|
-
import * as path from 'node:path';
|
|
9
|
-
import path__default, { dirname } from 'node:path';
|
|
10
|
-
import * as jsonc from 'jsonc-parser';
|
|
11
|
-
import fs$1 from 'node:fs/promises';
|
|
12
|
-
import yaml from 'js-yaml';
|
|
13
|
-
import { glob } from 'tinyglobby';
|
|
14
|
-
import { loadConfig } from 'c12';
|
|
15
|
-
import escalade from 'escalade/sync';
|
|
16
|
-
|
|
17
|
-
function getDefaultExportFromCjs (x) {
|
|
18
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var picocolors = {exports: {}};
|
|
22
|
-
|
|
23
|
-
var hasRequiredPicocolors;
|
|
24
|
-
|
|
25
|
-
function requirePicocolors () {
|
|
26
|
-
if (hasRequiredPicocolors) return picocolors.exports;
|
|
27
|
-
hasRequiredPicocolors = 1;
|
|
28
|
-
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
29
|
-
let isColorSupported =
|
|
30
|
-
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
31
|
-
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
32
|
-
|
|
33
|
-
let formatter = (open, close, replace = open) =>
|
|
34
|
-
input => {
|
|
35
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
36
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
let replaceClose = (string, close, replace, index) => {
|
|
40
|
-
let result = "", cursor = 0;
|
|
41
|
-
do {
|
|
42
|
-
result += string.substring(cursor, index) + replace;
|
|
43
|
-
cursor = index + close.length;
|
|
44
|
-
index = string.indexOf(close, cursor);
|
|
45
|
-
} while (~index)
|
|
46
|
-
return result + string.substring(cursor)
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
let createColors = (enabled = isColorSupported) => {
|
|
50
|
-
let f = enabled ? formatter : () => String;
|
|
51
|
-
return {
|
|
52
|
-
isColorSupported: enabled,
|
|
53
|
-
reset: f("\x1b[0m", "\x1b[0m"),
|
|
54
|
-
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
55
|
-
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
56
|
-
italic: f("\x1b[3m", "\x1b[23m"),
|
|
57
|
-
underline: f("\x1b[4m", "\x1b[24m"),
|
|
58
|
-
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
59
|
-
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
60
|
-
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
61
|
-
|
|
62
|
-
black: f("\x1b[30m", "\x1b[39m"),
|
|
63
|
-
red: f("\x1b[31m", "\x1b[39m"),
|
|
64
|
-
green: f("\x1b[32m", "\x1b[39m"),
|
|
65
|
-
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
66
|
-
blue: f("\x1b[34m", "\x1b[39m"),
|
|
67
|
-
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
68
|
-
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
69
|
-
white: f("\x1b[37m", "\x1b[39m"),
|
|
70
|
-
gray: f("\x1b[90m", "\x1b[39m"),
|
|
71
|
-
|
|
72
|
-
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
73
|
-
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
74
|
-
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
75
|
-
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
76
|
-
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
77
|
-
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
78
|
-
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
79
|
-
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
80
|
-
|
|
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
|
-
|
|
90
|
-
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
91
|
-
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
92
|
-
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
93
|
-
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
94
|
-
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
95
|
-
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
96
|
-
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
97
|
-
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
picocolors.exports = createColors();
|
|
102
|
-
picocolors.exports.createColors = createColors;
|
|
103
|
-
return picocolors.exports;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
var picocolorsExports = /*@__PURE__*/ requirePicocolors();
|
|
107
|
-
const c = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
108
|
-
|
|
109
|
-
function execCommand(cmd, options) {
|
|
110
|
-
try {
|
|
111
|
-
return execSync(cmd, { encoding: "utf8", cwd: options?.cwd }).trim();
|
|
112
|
-
} catch (error) {
|
|
113
|
-
return "";
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function getLastGitTag() {
|
|
117
|
-
return execCommand("git describe --tags --abbrev=0")?.split("\n").at(0) || undefined;
|
|
118
|
-
}
|
|
119
|
-
const GIT_LOG_FORMAT = "%h|%s|%an|%ae|%ad|%b[GIT_LOG_COMMIT_END]";
|
|
120
|
-
function getGitLog(from, to = "HEAD") {
|
|
121
|
-
return execCommand(`git --no-pager log "${from ? `${from}...${to}` : to}" --pretty="${GIT_LOG_FORMAT}"`).split("[GIT_LOG_COMMIT_END]\n").filter(Boolean);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const ConventionalCommitRegex = /(?<emoji>:.+:|(\uD83C[\uDF00-\uDFFF])|(\uD83D[\uDC00-\uDE4F\uDE80-\uDEFF])|[\u2600-\u2B55])?( *)(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
125
|
-
const CoAuthoredByRegex = /co-authored-by:\s*(?<name>.+)(<(?<email>.+)>)/gi;
|
|
126
|
-
const PullRequestRE = /\([ a-z]*(#\d+)\s*\)/g;
|
|
127
|
-
const IssueRE = /(#\d+)/g;
|
|
128
|
-
const BreakingRE = /breaking[ -]changes?:/i;
|
|
129
|
-
function parseRawCommit(commit) {
|
|
130
|
-
const [shortHash, message, authorName, authorEmail, data, ..._body] = commit.split("|");
|
|
131
|
-
const body = _body.filter(Boolean).join("\n");
|
|
132
|
-
return {
|
|
133
|
-
author: { name: authorName, email: authorEmail },
|
|
134
|
-
body,
|
|
135
|
-
data,
|
|
136
|
-
message,
|
|
137
|
-
shortHash
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function parseCommit(rawCommit) {
|
|
141
|
-
const { shortHash, message, body, data } = rawCommit;
|
|
142
|
-
const match = message.match(ConventionalCommitRegex);
|
|
143
|
-
const isConventional = match !== null;
|
|
144
|
-
const type = match?.groups?.type || "";
|
|
145
|
-
const scope = match?.groups?.scope || "";
|
|
146
|
-
let description = match?.groups?.description || message;
|
|
147
|
-
const hasBreakingBody = BreakingRE.test(body);
|
|
148
|
-
const isBreaking = Boolean(match?.groups?.breaking || hasBreakingBody);
|
|
149
|
-
const references = [];
|
|
150
|
-
for (const m of description.matchAll(PullRequestRE)) {
|
|
151
|
-
references.push({ type: "pull-request", value: m[1] });
|
|
152
|
-
}
|
|
153
|
-
for (const m of description.matchAll(IssueRE)) {
|
|
154
|
-
if (!references.some((i) => i.value === m[1])) {
|
|
155
|
-
references.push({ type: "issue", value: m[1] });
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
description = description.replace(PullRequestRE, "").trim();
|
|
159
|
-
const authors = [rawCommit.author];
|
|
160
|
-
for (const match2 of body.matchAll(CoAuthoredByRegex)) {
|
|
161
|
-
authors.push({
|
|
162
|
-
name: (match2.groups?.name || "").trim(),
|
|
163
|
-
email: (match2.groups?.email || "").trim()
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
authors,
|
|
168
|
-
body,
|
|
169
|
-
data,
|
|
170
|
-
description,
|
|
171
|
-
isBreaking,
|
|
172
|
-
isConventional,
|
|
173
|
-
message,
|
|
174
|
-
references,
|
|
175
|
-
scope,
|
|
176
|
-
shortHash,
|
|
177
|
-
type
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function getCommits(from, to) {
|
|
182
|
-
return getGitLog(from, to).map(parseRawCommit).map(parseCommit);
|
|
183
|
-
}
|
|
184
|
-
function getRecentCommits(from, to) {
|
|
185
|
-
if (!from)
|
|
186
|
-
from = getLastGitTag();
|
|
187
|
-
if (!to)
|
|
188
|
-
to = "HEAD";
|
|
189
|
-
return getCommits(from, to);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const symbols = {
|
|
193
|
-
success: c.green("\u2714"),
|
|
194
|
-
info: c.blue("\u2139")
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
async function readJsoncFile(name, cwd) {
|
|
198
|
-
const file = await readTextFile(name, cwd);
|
|
199
|
-
const data = jsonc.parse(file.data);
|
|
200
|
-
const modified = [];
|
|
201
|
-
return { ...file, data, modified, text: file.data };
|
|
202
|
-
}
|
|
203
|
-
async function writeJsoncFile(file) {
|
|
204
|
-
let newJSON = file.text;
|
|
205
|
-
for (const [key, value] of file.modified) {
|
|
206
|
-
const edit = jsonc.modify(newJSON, key, value, {});
|
|
207
|
-
newJSON = jsonc.applyEdits(newJSON, edit);
|
|
208
|
-
}
|
|
209
|
-
return writeTextFile({ ...file, data: newJSON });
|
|
210
|
-
}
|
|
211
|
-
function readTextFile(name, cwd) {
|
|
212
|
-
return new Promise((resolve, reject) => {
|
|
213
|
-
const filePath = path__default.join(cwd, name);
|
|
214
|
-
fs.readFile(filePath, "utf8", (err, text) => {
|
|
215
|
-
if (err) {
|
|
216
|
-
reject(err);
|
|
217
|
-
} else {
|
|
218
|
-
resolve({
|
|
219
|
-
path: filePath,
|
|
220
|
-
data: text
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
function writeTextFile(file) {
|
|
227
|
-
return new Promise((resolve, reject) => {
|
|
228
|
-
fs.writeFile(file.path, file.data, (err) => {
|
|
229
|
-
if (err)
|
|
230
|
-
reject(err);
|
|
231
|
-
else
|
|
232
|
-
resolve();
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function isManifest(obj) {
|
|
238
|
-
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
239
|
-
}
|
|
240
|
-
function isPackageLockManifest(manifest) {
|
|
241
|
-
return typeof manifest.packages?.[""]?.version === "string";
|
|
242
|
-
}
|
|
243
|
-
function isOptionalString(value) {
|
|
244
|
-
const type = typeof value;
|
|
245
|
-
return value === null || type === "undefined" || type === "string";
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async function getCurrentVersion(operation) {
|
|
249
|
-
if (operation.state.currentVersion)
|
|
250
|
-
return operation;
|
|
251
|
-
const { cwd, files } = operation.options;
|
|
252
|
-
const filesToCheck = files.filter((file) => file.endsWith(".json"));
|
|
253
|
-
if (!filesToCheck.includes("package.json"))
|
|
254
|
-
filesToCheck.push("package.json");
|
|
255
|
-
if (!filesToCheck.includes("deno.json"))
|
|
256
|
-
filesToCheck.push("deno.json");
|
|
257
|
-
if (!filesToCheck.includes("deno.jsonc"))
|
|
258
|
-
filesToCheck.push("deno.jsonc");
|
|
259
|
-
for (const file of filesToCheck) {
|
|
260
|
-
const version = await readVersion(file, cwd);
|
|
261
|
-
if (version) {
|
|
262
|
-
return operation.update({
|
|
263
|
-
currentVersionSource: file,
|
|
264
|
-
currentVersion: version
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
throw new Error(
|
|
269
|
-
`Unable to determine the current version number. Checked ${filesToCheck.join(", ")}.`
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
async function readVersion(file, cwd) {
|
|
273
|
-
try {
|
|
274
|
-
const { data: manifest } = await readJsoncFile(file, cwd);
|
|
275
|
-
if (isManifest(manifest)) {
|
|
276
|
-
if (valid(manifest.version))
|
|
277
|
-
return manifest.version;
|
|
278
|
-
}
|
|
279
|
-
} catch {
|
|
280
|
-
return undefined;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const prereleaseTypes = ["premajor", "preminor", "prepatch", "prerelease"];
|
|
285
|
-
const releaseTypes = prereleaseTypes.concat(["major", "minor", "patch", "next", "conventional"]);
|
|
286
|
-
function isPrerelease(value) {
|
|
287
|
-
return prereleaseTypes.includes(value);
|
|
288
|
-
}
|
|
289
|
-
function isReleaseType(value) {
|
|
290
|
-
return releaseTypes.includes(value);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
async function getNewVersion(operation, commits) {
|
|
294
|
-
const { release } = operation.options;
|
|
295
|
-
const { currentVersion } = operation.state;
|
|
296
|
-
switch (release.type) {
|
|
297
|
-
case "prompt":
|
|
298
|
-
return promptForNewVersion(operation, commits);
|
|
299
|
-
case "version":
|
|
300
|
-
return operation.update({
|
|
301
|
-
newVersion: new SemVer(release.version, true).version
|
|
302
|
-
});
|
|
303
|
-
default:
|
|
304
|
-
return operation.update({
|
|
305
|
-
release: release.type,
|
|
306
|
-
newVersion: getNextVersion(currentVersion, release, commits)
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
function getNextVersion(currentVersion, bump, commits) {
|
|
311
|
-
const oldSemVer = new SemVer(currentVersion);
|
|
312
|
-
let type;
|
|
313
|
-
if (bump.type === "next") {
|
|
314
|
-
type = oldSemVer.prerelease.length ? "prerelease" : "patch";
|
|
315
|
-
} else if (bump.type === "conventional") {
|
|
316
|
-
type = oldSemVer.prerelease.length ? "prerelease" : determineSemverChange(commits);
|
|
317
|
-
} else {
|
|
318
|
-
type = bump.type;
|
|
319
|
-
}
|
|
320
|
-
const newSemVer = oldSemVer.inc(type, bump.preid);
|
|
321
|
-
if (isPrerelease(bump.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === bump.preid && String(newSemVer.prerelease[1]) === "0") {
|
|
322
|
-
newSemVer.prerelease[1] = "1";
|
|
323
|
-
newSemVer.format();
|
|
324
|
-
}
|
|
325
|
-
return newSemVer.version;
|
|
326
|
-
}
|
|
327
|
-
function determineSemverChange(commits) {
|
|
328
|
-
let [hasMajor, hasMinor] = [false, false];
|
|
329
|
-
for (const commit of commits) {
|
|
330
|
-
if (commit.isBreaking) {
|
|
331
|
-
hasMajor = true;
|
|
332
|
-
} else if (commit.type === "feat") {
|
|
333
|
-
hasMinor = true;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return hasMajor ? "major" : hasMinor ? "minor" : "patch";
|
|
337
|
-
}
|
|
338
|
-
function getNextVersions(currentVersion, preid, commits) {
|
|
339
|
-
const next = {};
|
|
340
|
-
const parse = semver.parse(currentVersion);
|
|
341
|
-
if (typeof parse?.prerelease[0] === "string")
|
|
342
|
-
preid = parse?.prerelease[0] || "preid";
|
|
343
|
-
for (const type of releaseTypes)
|
|
344
|
-
next[type] = getNextVersion(currentVersion, { type, preid }, commits);
|
|
345
|
-
return next;
|
|
346
|
-
}
|
|
347
|
-
async function promptForNewVersion(operation, commits) {
|
|
348
|
-
const { currentVersion } = operation.state;
|
|
349
|
-
const release = operation.options.release;
|
|
350
|
-
const next = getNextVersions(currentVersion, release.preid, commits);
|
|
351
|
-
const configCustomVersion = await operation.options.customVersion?.(currentVersion, semver);
|
|
352
|
-
const PADDING = 13;
|
|
353
|
-
const answers = await prompts([
|
|
354
|
-
{
|
|
355
|
-
type: "autocomplete",
|
|
356
|
-
name: "release",
|
|
357
|
-
message: `Current version ${c.green(currentVersion)}`,
|
|
358
|
-
initial: configCustomVersion ? "config" : "next",
|
|
359
|
-
choices: [
|
|
360
|
-
{ value: "major", title: `${"major".padStart(PADDING, " ")} ${c.bold(next.major)}` },
|
|
361
|
-
{ value: "minor", title: `${"minor".padStart(PADDING, " ")} ${c.bold(next.minor)}` },
|
|
362
|
-
{ value: "patch", title: `${"patch".padStart(PADDING, " ")} ${c.bold(next.patch)}` },
|
|
363
|
-
{ value: "next", title: `${"next".padStart(PADDING, " ")} ${c.bold(next.next)}` },
|
|
364
|
-
{ value: "conventional", title: `${"conventional".padStart(PADDING, " ")} ${c.bold(next.conventional)}` },
|
|
365
|
-
...configCustomVersion ? [
|
|
366
|
-
{ value: "config", title: `${"from config".padStart(PADDING, " ")} ${c.bold(configCustomVersion)}` }
|
|
367
|
-
] : [],
|
|
368
|
-
{ value: "prepatch", title: `${"pre-patch".padStart(PADDING, " ")} ${c.bold(next.prepatch)}` },
|
|
369
|
-
{ value: "preminor", title: `${"pre-minor".padStart(PADDING, " ")} ${c.bold(next.preminor)}` },
|
|
370
|
-
{ value: "premajor", title: `${"pre-major".padStart(PADDING, " ")} ${c.bold(next.premajor)}` },
|
|
371
|
-
{ value: "none", title: `${"as-is".padStart(PADDING, " ")} ${c.bold(currentVersion)}` },
|
|
372
|
-
{ value: "custom", title: "custom ...".padStart(PADDING + 4, " ") }
|
|
373
|
-
]
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
type: (prev) => prev === "custom" ? "text" : null,
|
|
377
|
-
name: "custom",
|
|
378
|
-
message: "Enter the new version number:",
|
|
379
|
-
initial: currentVersion,
|
|
380
|
-
validate: (custom) => {
|
|
381
|
-
return valid(custom) ? true : "That's not a valid version number";
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
]);
|
|
385
|
-
const newVersion = answers.release === "none" ? currentVersion : answers.release === "custom" ? clean(answers.custom) : answers.release === "config" ? clean(configCustomVersion) : next[answers.release];
|
|
386
|
-
if (!newVersion)
|
|
387
|
-
process$1.exit(1);
|
|
388
|
-
switch (answers.release) {
|
|
389
|
-
case "custom":
|
|
390
|
-
case "config":
|
|
391
|
-
case "next":
|
|
392
|
-
case "conventional":
|
|
393
|
-
case "none":
|
|
394
|
-
return operation.update({ newVersion });
|
|
395
|
-
default:
|
|
396
|
-
return operation.update({ release: answers.release, newVersion });
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
|
|
401
|
-
ProgressEvent2["FileUpdated"] = "file updated";
|
|
402
|
-
ProgressEvent2["FileSkipped"] = "file skipped";
|
|
403
|
-
ProgressEvent2["GitCommit"] = "git commit";
|
|
404
|
-
ProgressEvent2["GitTag"] = "git tag";
|
|
405
|
-
ProgressEvent2["GitPush"] = "git push";
|
|
406
|
-
ProgressEvent2["NpmScript"] = "npm script";
|
|
407
|
-
return ProgressEvent2;
|
|
408
|
-
})(ProgressEvent || {});
|
|
409
|
-
var NpmScript = /* @__PURE__ */ ((NpmScript2) => {
|
|
410
|
-
NpmScript2["PreVersion"] = "preversion";
|
|
411
|
-
NpmScript2["Version"] = "version";
|
|
412
|
-
NpmScript2["PostVersion"] = "postversion";
|
|
413
|
-
return NpmScript2;
|
|
414
|
-
})(NpmScript || {});
|
|
415
|
-
|
|
416
|
-
async function gitCommit(operation) {
|
|
417
|
-
if (!operation.options.commit)
|
|
418
|
-
return operation;
|
|
419
|
-
const { all, noVerify, message } = operation.options.commit;
|
|
420
|
-
const { updatedFiles, newVersion } = operation.state;
|
|
421
|
-
let args = ["--allow-empty"];
|
|
422
|
-
if (all) {
|
|
423
|
-
args.push("--all");
|
|
424
|
-
}
|
|
425
|
-
if (noVerify) {
|
|
426
|
-
args.push("--no-verify");
|
|
427
|
-
}
|
|
428
|
-
if (operation.options.sign) {
|
|
429
|
-
args.push("--gpg-sign");
|
|
430
|
-
}
|
|
431
|
-
const commitMessage = formatVersionString(message, newVersion);
|
|
432
|
-
args.push("--message", commitMessage);
|
|
433
|
-
if (!all)
|
|
434
|
-
args = args.concat(updatedFiles);
|
|
435
|
-
await x("git", ["commit", ...args], { throwOnError: true });
|
|
436
|
-
return operation.update({ event: ProgressEvent.GitCommit, commitMessage });
|
|
437
|
-
}
|
|
438
|
-
async function gitTag(operation) {
|
|
439
|
-
if (!operation.options.tag)
|
|
440
|
-
return operation;
|
|
441
|
-
const { commit, tag } = operation.options;
|
|
442
|
-
const { newVersion } = operation.state;
|
|
443
|
-
const args = [
|
|
444
|
-
// Create an annotated tag, which is recommended for releases.
|
|
445
|
-
// See https://git-scm.com/docs/git-tag
|
|
446
|
-
"--annotate",
|
|
447
|
-
// Use the same commit message for the tag
|
|
448
|
-
"--message",
|
|
449
|
-
formatVersionString(commit.message, newVersion)
|
|
450
|
-
];
|
|
451
|
-
const tagName = formatVersionString(tag.name, newVersion);
|
|
452
|
-
args.push(tagName);
|
|
453
|
-
if (operation.options.sign) {
|
|
454
|
-
args.push("--sign");
|
|
455
|
-
}
|
|
456
|
-
await x("git", ["tag", ...args], { throwOnError: true });
|
|
457
|
-
return operation.update({ event: ProgressEvent.GitTag, tagName });
|
|
458
|
-
}
|
|
459
|
-
async function gitPush(operation) {
|
|
460
|
-
if (!operation.options.push)
|
|
461
|
-
return operation;
|
|
462
|
-
await x("git", ["push"], { throwOnError: true });
|
|
463
|
-
if (operation.options.tag) {
|
|
464
|
-
await x("git", ["push", "--tags"], { throwOnError: true });
|
|
465
|
-
}
|
|
466
|
-
return operation.update({ event: ProgressEvent.GitPush });
|
|
467
|
-
}
|
|
468
|
-
function formatVersionString(template, newVersion) {
|
|
469
|
-
if (template.includes("%s"))
|
|
470
|
-
return template.replace(/%s/g, newVersion);
|
|
471
|
-
else
|
|
472
|
-
return template + newVersion;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
async function normalizeOptions(raw) {
|
|
476
|
-
const preid = typeof raw.preid === "string" ? raw.preid : "beta";
|
|
477
|
-
const sign = Boolean(raw.sign);
|
|
478
|
-
const push = Boolean(raw.push);
|
|
479
|
-
const all = Boolean(raw.all);
|
|
480
|
-
const install = Boolean(raw.install);
|
|
481
|
-
const noVerify = Boolean(raw.noVerify);
|
|
482
|
-
const cwd = raw.cwd || process$1.cwd();
|
|
483
|
-
const ignoreScripts = Boolean(raw.ignoreScripts);
|
|
484
|
-
const execute = raw.execute;
|
|
485
|
-
const recursive = Boolean(raw.recursive);
|
|
486
|
-
let release;
|
|
487
|
-
if (!raw.release || raw.release === "prompt")
|
|
488
|
-
release = { type: "prompt", preid };
|
|
489
|
-
else if (isReleaseType(raw.release) || raw.release === "next")
|
|
490
|
-
release = { type: raw.release, preid };
|
|
491
|
-
else
|
|
492
|
-
release = { type: "version", version: raw.release };
|
|
493
|
-
let tag;
|
|
494
|
-
if (typeof raw.tag === "string")
|
|
495
|
-
tag = { name: raw.tag };
|
|
496
|
-
else if (raw.tag)
|
|
497
|
-
tag = { name: "v" };
|
|
498
|
-
let commit;
|
|
499
|
-
if (typeof raw.commit === "string")
|
|
500
|
-
commit = { all, noVerify, message: raw.commit };
|
|
501
|
-
else if (raw.commit || tag || push)
|
|
502
|
-
commit = { all, noVerify, message: "chore: release v" };
|
|
503
|
-
if (recursive && !raw.files?.length) {
|
|
504
|
-
raw.files = [
|
|
505
|
-
"package.json",
|
|
506
|
-
"package-lock.json",
|
|
507
|
-
"packages/**/package.json",
|
|
508
|
-
"jsr.json",
|
|
509
|
-
"jsr.jsonc",
|
|
510
|
-
"deno.json",
|
|
511
|
-
"deno.jsonc"
|
|
512
|
-
];
|
|
513
|
-
if (fs.existsSync("pnpm-workspace.yaml")) {
|
|
514
|
-
const pnpmWorkspace = await fs$1.readFile("pnpm-workspace.yaml", "utf8");
|
|
515
|
-
const workspaces = yaml.load(pnpmWorkspace);
|
|
516
|
-
const workspacesWithPackageJson = workspaces.packages.map((workspace) => `${workspace}/package.json`);
|
|
517
|
-
const withoutExcludedWorkspaces = workspacesWithPackageJson.filter((workspace) => !workspace.startsWith("!") && !raw.files?.includes(workspace));
|
|
518
|
-
raw.files = raw.files.concat(withoutExcludedWorkspaces);
|
|
519
|
-
}
|
|
520
|
-
} else {
|
|
521
|
-
raw.files = raw.files?.length ? raw.files : ["package.json", "package-lock.json", "jsr.json", "jsr.jsonc", "deno.json", "deno.jsonc"];
|
|
522
|
-
}
|
|
523
|
-
const files = await glob(
|
|
524
|
-
raw.files,
|
|
525
|
-
{
|
|
526
|
-
cwd,
|
|
527
|
-
onlyFiles: true,
|
|
528
|
-
expandDirectories: false,
|
|
529
|
-
ignore: [
|
|
530
|
-
"**/{.git,node_modules,bower_components,__tests__,fixtures,fixture}/**"
|
|
531
|
-
]
|
|
532
|
-
}
|
|
533
|
-
);
|
|
534
|
-
let ui;
|
|
535
|
-
if (raw.interface === false) {
|
|
536
|
-
ui = { input: false, output: false };
|
|
537
|
-
} else if (raw.interface === true || !raw.interface) {
|
|
538
|
-
ui = { input: process$1.stdin, output: process$1.stdout };
|
|
539
|
-
} else {
|
|
540
|
-
let { input, output, ...other } = raw.interface;
|
|
541
|
-
if (input === true || input !== false && !input)
|
|
542
|
-
input = process$1.stdin;
|
|
543
|
-
if (output === true || output !== false && !output)
|
|
544
|
-
output = process$1.stdout;
|
|
545
|
-
ui = { input, output, ...other };
|
|
546
|
-
}
|
|
547
|
-
if (release.type === "prompt" && !(ui.input && ui.output))
|
|
548
|
-
throw new Error("Cannot prompt for the version number because input or output has been disabled.");
|
|
549
|
-
return {
|
|
550
|
-
release,
|
|
551
|
-
commit,
|
|
552
|
-
tag,
|
|
553
|
-
sign,
|
|
554
|
-
push,
|
|
555
|
-
files,
|
|
556
|
-
cwd,
|
|
557
|
-
install,
|
|
558
|
-
interface: ui,
|
|
559
|
-
ignoreScripts,
|
|
560
|
-
execute,
|
|
561
|
-
printCommits: raw.printCommits ?? true,
|
|
562
|
-
customVersion: raw.customVersion,
|
|
563
|
-
currentVersion: raw.currentVersion
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
class Operation {
|
|
568
|
-
/**
|
|
569
|
-
* The options for this operation.
|
|
570
|
-
*/
|
|
571
|
-
options;
|
|
572
|
-
/**
|
|
573
|
-
* The current state of the operation.
|
|
574
|
-
*/
|
|
575
|
-
state = {
|
|
576
|
-
release: undefined,
|
|
577
|
-
currentVersion: "",
|
|
578
|
-
currentVersionSource: "",
|
|
579
|
-
newVersion: "",
|
|
580
|
-
commitMessage: "",
|
|
581
|
-
tagName: "",
|
|
582
|
-
updatedFiles: [],
|
|
583
|
-
skippedFiles: []
|
|
584
|
-
};
|
|
585
|
-
/**
|
|
586
|
-
* The results of the operation.
|
|
587
|
-
*/
|
|
588
|
-
get results() {
|
|
589
|
-
const options = this.options;
|
|
590
|
-
const state = this.state;
|
|
591
|
-
return {
|
|
592
|
-
release: state.release,
|
|
593
|
-
currentVersion: state.currentVersion,
|
|
594
|
-
newVersion: state.newVersion,
|
|
595
|
-
commit: options.commit ? state.commitMessage : false,
|
|
596
|
-
tag: options.tag ? state.tagName : false,
|
|
597
|
-
updatedFiles: state.updatedFiles.slice(),
|
|
598
|
-
skippedFiles: state.skippedFiles.slice()
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* The callback that's used to report the progress of the operation.
|
|
603
|
-
*/
|
|
604
|
-
_progress;
|
|
605
|
-
/**
|
|
606
|
-
* Private constructor. Use the `Operation.start()` static method instead.
|
|
607
|
-
*/
|
|
608
|
-
constructor(options, progress) {
|
|
609
|
-
this.options = options;
|
|
610
|
-
this._progress = progress;
|
|
611
|
-
if (options.currentVersion) {
|
|
612
|
-
this.update({
|
|
613
|
-
currentVersion: options.currentVersion,
|
|
614
|
-
currentVersionSource: "user"
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* Starts a new `versionBump()` operation.
|
|
620
|
-
*/
|
|
621
|
-
static async start(input) {
|
|
622
|
-
const options = await normalizeOptions(input);
|
|
623
|
-
return new Operation(options, input.progress);
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Updates the operation state and results, and reports the updated progress to the user.
|
|
627
|
-
*/
|
|
628
|
-
update({ event, script, ...newState }) {
|
|
629
|
-
Object.assign(this.state, newState);
|
|
630
|
-
if (event && this._progress) {
|
|
631
|
-
this._progress({ event, script, ...this.results });
|
|
632
|
-
}
|
|
633
|
-
return this;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
const messageColorMap = {
|
|
638
|
-
feat: c.green,
|
|
639
|
-
feature: c.green,
|
|
640
|
-
refactor: c.cyan,
|
|
641
|
-
style: c.cyan,
|
|
642
|
-
docs: c.blue,
|
|
643
|
-
doc: c.blue,
|
|
644
|
-
types: c.blue,
|
|
645
|
-
type: c.blue,
|
|
646
|
-
chore: c.gray,
|
|
647
|
-
ci: c.gray,
|
|
648
|
-
build: c.gray,
|
|
649
|
-
deps: c.gray,
|
|
650
|
-
dev: c.gray,
|
|
651
|
-
fix: c.yellow,
|
|
652
|
-
test: c.yellow,
|
|
653
|
-
perf: c.magenta,
|
|
654
|
-
revert: c.red,
|
|
655
|
-
breaking: c.red
|
|
656
|
-
};
|
|
657
|
-
function formatParsedCommits(commits) {
|
|
658
|
-
const typeLength = commits.map(({ type }) => type.length).reduce((a, b) => Math.max(a, b), 0);
|
|
659
|
-
const scopeLength = commits.map(({ scope }) => scope.length).reduce((a, b) => Math.max(a, b), 0);
|
|
660
|
-
return commits.map((commit) => {
|
|
661
|
-
let color = messageColorMap[commit.type] || ((c2) => c2);
|
|
662
|
-
if (commit.isBreaking) {
|
|
663
|
-
color = (s) => c.inverse(c.red(s));
|
|
664
|
-
}
|
|
665
|
-
const paddedType = commit.type.padStart(typeLength + 1, " ");
|
|
666
|
-
const paddedScope = !commit.scope ? " ".repeat(scopeLength ? scopeLength + 2 : 0) : c.dim("(") + commit.scope + c.dim(")") + " ".repeat(scopeLength - commit.scope.length);
|
|
667
|
-
return [
|
|
668
|
-
c.dim(commit.shortHash),
|
|
669
|
-
" ",
|
|
670
|
-
color === c.gray ? color(paddedType) : c.bold(color(paddedType)),
|
|
671
|
-
" ",
|
|
672
|
-
paddedScope,
|
|
673
|
-
c.dim(":"),
|
|
674
|
-
" ",
|
|
675
|
-
color === c.gray ? color(commit.description) : commit.description
|
|
676
|
-
].join("");
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
function printRecentCommits(commits) {
|
|
680
|
-
if (!commits.length) {
|
|
681
|
-
console.log();
|
|
682
|
-
console.log(c.blue(`i`) + c.gray(` No commits since the last version`));
|
|
683
|
-
console.log();
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
const prettified = formatParsedCommits(commits);
|
|
687
|
-
console.log();
|
|
688
|
-
console.log(
|
|
689
|
-
c.bold(
|
|
690
|
-
`${c.green(commits.length)} Commits since the last version:`
|
|
691
|
-
)
|
|
692
|
-
);
|
|
693
|
-
console.log();
|
|
694
|
-
console.log(prettified.join("\n"));
|
|
695
|
-
console.log();
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
async function runNpmScript(script, operation) {
|
|
699
|
-
const { cwd, ignoreScripts } = operation.options;
|
|
700
|
-
if (!ignoreScripts) {
|
|
701
|
-
const { data: manifest } = await readJsoncFile("package.json", cwd);
|
|
702
|
-
if (isManifest(manifest) && hasScript(manifest, script)) {
|
|
703
|
-
await x("npm", ["run", script, "--silent"], {
|
|
704
|
-
nodeOptions: { stdio: "inherit" }
|
|
705
|
-
});
|
|
706
|
-
operation.update({ event: ProgressEvent.NpmScript, script });
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
return operation;
|
|
710
|
-
}
|
|
711
|
-
function hasScript(manifest, script) {
|
|
712
|
-
const scripts = manifest.scripts;
|
|
713
|
-
if (scripts && typeof scripts === "object")
|
|
714
|
-
return Boolean(scripts[script]);
|
|
715
|
-
return false;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
async function updateFiles(operation) {
|
|
719
|
-
const { files } = operation.options;
|
|
720
|
-
for (const relPath of files) {
|
|
721
|
-
const modified = await updateFile(relPath, operation);
|
|
722
|
-
if (modified) {
|
|
723
|
-
operation.update({
|
|
724
|
-
event: ProgressEvent.FileUpdated,
|
|
725
|
-
updatedFiles: operation.state.updatedFiles.concat(relPath)
|
|
726
|
-
});
|
|
727
|
-
} else {
|
|
728
|
-
operation.update({
|
|
729
|
-
event: ProgressEvent.FileSkipped,
|
|
730
|
-
skippedFiles: operation.state.skippedFiles.concat(relPath)
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
return operation;
|
|
735
|
-
}
|
|
736
|
-
async function updateFile(relPath, operation) {
|
|
737
|
-
if (!existsSync(path.join(operation.options.cwd, relPath))) {
|
|
738
|
-
return false;
|
|
739
|
-
}
|
|
740
|
-
const name = path.basename(relPath).trim().toLowerCase();
|
|
741
|
-
switch (name) {
|
|
742
|
-
case "package.json":
|
|
743
|
-
case "package-lock.json":
|
|
744
|
-
case "bower.json":
|
|
745
|
-
case "component.json":
|
|
746
|
-
case "jsr.json":
|
|
747
|
-
case "jsr.jsonc":
|
|
748
|
-
case "deno.json":
|
|
749
|
-
case "deno.jsonc":
|
|
750
|
-
return updateManifestFile(relPath, operation);
|
|
751
|
-
default:
|
|
752
|
-
return updateTextFile(relPath, operation);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
async function updateManifestFile(relPath, operation) {
|
|
756
|
-
const { cwd } = operation.options;
|
|
757
|
-
const { newVersion } = operation.state;
|
|
758
|
-
let modified = false;
|
|
759
|
-
const file = await readJsoncFile(relPath, cwd);
|
|
760
|
-
if (!isManifest(file.data)) {
|
|
761
|
-
return modified;
|
|
762
|
-
}
|
|
763
|
-
if (file.data.version == null) {
|
|
764
|
-
return modified;
|
|
765
|
-
}
|
|
766
|
-
if (file.data.version !== newVersion) {
|
|
767
|
-
file.modified.push([["version"], newVersion]);
|
|
768
|
-
if (isPackageLockManifest(file.data))
|
|
769
|
-
file.modified.push([["packages", "", "version"], newVersion]);
|
|
770
|
-
await writeJsoncFile(file);
|
|
771
|
-
modified = true;
|
|
772
|
-
}
|
|
773
|
-
return modified;
|
|
774
|
-
}
|
|
775
|
-
async function updateTextFile(relPath, operation) {
|
|
776
|
-
const { cwd } = operation.options;
|
|
777
|
-
const { currentVersion, newVersion } = operation.state;
|
|
778
|
-
const modified = false;
|
|
779
|
-
const file = await readTextFile(relPath, cwd);
|
|
780
|
-
if (file.data.includes(currentVersion)) {
|
|
781
|
-
const sanitizedVersion = currentVersion.replace(/(\W)/g, "\\$1");
|
|
782
|
-
const replacePattern = new RegExp(`(\\b|v)${sanitizedVersion}\\b`, "g");
|
|
783
|
-
file.data = file.data.replace(replacePattern, `$1${newVersion}`);
|
|
784
|
-
await writeTextFile(file);
|
|
785
|
-
return true;
|
|
786
|
-
}
|
|
787
|
-
return modified;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
async function versionBump(arg = {}) {
|
|
791
|
-
if (typeof arg === "string")
|
|
792
|
-
arg = { release: arg };
|
|
793
|
-
const operation = await Operation.start(arg);
|
|
794
|
-
const commits = getRecentCommits();
|
|
795
|
-
if (operation.options.printCommits) {
|
|
796
|
-
printRecentCommits(commits);
|
|
797
|
-
}
|
|
798
|
-
await getCurrentVersion(operation);
|
|
799
|
-
await getNewVersion(operation, commits);
|
|
800
|
-
if (arg.confirm) {
|
|
801
|
-
printSummary(operation);
|
|
802
|
-
if (!await prompts({
|
|
803
|
-
name: "yes",
|
|
804
|
-
type: "confirm",
|
|
805
|
-
message: "Bump?",
|
|
806
|
-
initial: true
|
|
807
|
-
}).then((r) => r.yes)) {
|
|
808
|
-
process$1.exit(1);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
await runNpmScript(NpmScript.PreVersion, operation);
|
|
812
|
-
await updateFiles(operation);
|
|
813
|
-
if (operation.options.install) {
|
|
814
|
-
const { detect } = await import('package-manager-detector/detect');
|
|
815
|
-
const pm = await detect();
|
|
816
|
-
if (!pm?.name) {
|
|
817
|
-
throw new Error("Could not detect package manager, failed to run npm install");
|
|
818
|
-
}
|
|
819
|
-
const { COMMANDS, constructCommand } = await import('package-manager-detector/commands');
|
|
820
|
-
const command = constructCommand(COMMANDS[pm.name].install, []);
|
|
821
|
-
if (!command) {
|
|
822
|
-
throw new Error("Could not find install command for package manager");
|
|
823
|
-
}
|
|
824
|
-
console.log(symbols.info, "Installing dependencies with", `${command.command} ${command.args.join(" ")}`);
|
|
825
|
-
await x(command.command, command.args, {
|
|
826
|
-
throwOnError: true,
|
|
827
|
-
nodeOptions: {
|
|
828
|
-
stdio: "inherit",
|
|
829
|
-
cwd: operation.options.cwd
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
console.log(symbols.success, "Dependencies installed");
|
|
833
|
-
}
|
|
834
|
-
if (operation.options.execute) {
|
|
835
|
-
if (typeof operation.options.execute === "function") {
|
|
836
|
-
await operation.options.execute(operation);
|
|
837
|
-
} else {
|
|
838
|
-
const [command, ...args] = tokenizeArgs(operation.options.execute);
|
|
839
|
-
console.log(symbols.info, "Executing script", command, ...args);
|
|
840
|
-
await x(command, args, {
|
|
841
|
-
throwOnError: true,
|
|
842
|
-
nodeOptions: {
|
|
843
|
-
stdio: "inherit",
|
|
844
|
-
cwd: operation.options.cwd
|
|
845
|
-
}
|
|
846
|
-
});
|
|
847
|
-
console.log(symbols.success, "Script finished");
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
await runNpmScript(NpmScript.Version, operation);
|
|
851
|
-
await gitCommit(operation);
|
|
852
|
-
await gitTag(operation);
|
|
853
|
-
await runNpmScript(NpmScript.PostVersion, operation);
|
|
854
|
-
await gitPush(operation);
|
|
855
|
-
return operation.results;
|
|
856
|
-
}
|
|
857
|
-
function printSummary(operation) {
|
|
858
|
-
console.log();
|
|
859
|
-
console.log(` files ${operation.options.files.map((i) => c.bold(i)).join("\n ")}`);
|
|
860
|
-
if (operation.options.commit)
|
|
861
|
-
console.log(` commit ${c.bold(formatVersionString(operation.options.commit.message, operation.state.newVersion))}`);
|
|
862
|
-
if (operation.options.tag)
|
|
863
|
-
console.log(` tag ${c.bold(formatVersionString(operation.options.tag.name, operation.state.newVersion))}`);
|
|
864
|
-
if (operation.options.execute)
|
|
865
|
-
console.log(` execute ${c.bold(typeof operation.options.execute === "function" ? "function" : operation.options.execute)}`);
|
|
866
|
-
if (operation.options.push)
|
|
867
|
-
console.log(` push ${c.cyan(c.bold("yes"))}`);
|
|
868
|
-
if (operation.options.install)
|
|
869
|
-
console.log(` install ${c.cyan(c.bold("yes"))}`);
|
|
870
|
-
console.log();
|
|
871
|
-
console.log(` from ${c.bold(operation.state.currentVersion)}`);
|
|
872
|
-
console.log(` to ${c.green(c.bold(operation.state.newVersion))}`);
|
|
873
|
-
console.log();
|
|
874
|
-
}
|
|
875
|
-
async function versionBumpInfo(arg = {}) {
|
|
876
|
-
if (typeof arg === "string")
|
|
877
|
-
arg = { release: arg };
|
|
878
|
-
const operation = await Operation.start(arg);
|
|
879
|
-
const commits = getRecentCommits();
|
|
880
|
-
await getCurrentVersion(operation);
|
|
881
|
-
await getNewVersion(operation, commits);
|
|
882
|
-
return operation;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
const bumpConfigDefaults = {
|
|
886
|
-
commit: true,
|
|
887
|
-
push: true,
|
|
888
|
-
tag: true,
|
|
889
|
-
sign: false,
|
|
890
|
-
install: false,
|
|
891
|
-
recursive: false,
|
|
892
|
-
noVerify: false,
|
|
893
|
-
confirm: true,
|
|
894
|
-
ignoreScripts: false,
|
|
895
|
-
all: false,
|
|
896
|
-
noGitCheck: true,
|
|
897
|
-
files: []
|
|
898
|
-
};
|
|
899
|
-
async function loadBumpConfig(overrides, cwd = process$1.cwd()) {
|
|
900
|
-
const name = "bump";
|
|
901
|
-
const configFile = findConfigFile(name, cwd);
|
|
902
|
-
const { config } = await loadConfig({
|
|
903
|
-
name,
|
|
904
|
-
defaults: bumpConfigDefaults,
|
|
905
|
-
overrides: {
|
|
906
|
-
...overrides
|
|
907
|
-
},
|
|
908
|
-
cwd: configFile ? dirname(configFile) : cwd
|
|
909
|
-
});
|
|
910
|
-
return config;
|
|
911
|
-
}
|
|
912
|
-
function findConfigFile(name, cwd) {
|
|
913
|
-
let foundRepositoryRoot = false;
|
|
914
|
-
try {
|
|
915
|
-
const candidates = ["js", "mjs", "ts", "mts", "json"].map((ext) => `${name}.config.${ext}`);
|
|
916
|
-
return escalade(cwd, (_dir, files) => {
|
|
917
|
-
const match = files.find((file) => {
|
|
918
|
-
if (candidates.includes(file))
|
|
919
|
-
return true;
|
|
920
|
-
if (file === ".git")
|
|
921
|
-
foundRepositoryRoot = true;
|
|
922
|
-
return false;
|
|
923
|
-
});
|
|
924
|
-
if (match)
|
|
925
|
-
return match;
|
|
926
|
-
if (foundRepositoryRoot) {
|
|
927
|
-
throw null;
|
|
928
|
-
}
|
|
929
|
-
return false;
|
|
930
|
-
});
|
|
931
|
-
} catch (error) {
|
|
932
|
-
if (foundRepositoryRoot)
|
|
933
|
-
return null;
|
|
934
|
-
throw error;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
function defineConfig(config) {
|
|
938
|
-
return config;
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
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 };
|