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