bumpp 7.0.0 → 7.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/bin/bumpp.js +0 -0
- package/dist/{chunk-TILHCTE7.mjs → chunk-2TP63A7S.mjs} +291 -192
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.js +783 -40
- package/dist/cli/index.mjs +44 -33
- package/dist/index.d.ts +219 -4
- package/dist/index.js +751 -6
- package/dist/index.mjs +11 -4
- package/package.json +27 -27
- package/dist/chunk-KWGIMQJU.js +0 -642
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
5
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
10
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
11
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -17,6 +21,14 @@ var __spreadValues = (a, b) => {
|
|
|
17
21
|
return a;
|
|
18
22
|
};
|
|
19
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
|
+
});
|
|
20
32
|
var __objRest = (source, exclude) => {
|
|
21
33
|
var target = {};
|
|
22
34
|
for (var prop in source)
|
|
@@ -29,104 +41,93 @@ var __objRest = (source, exclude) => {
|
|
|
29
41
|
}
|
|
30
42
|
return target;
|
|
31
43
|
};
|
|
32
|
-
var
|
|
33
|
-
return
|
|
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;
|
|
34
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
|
+
});
|
|
35
104
|
|
|
36
|
-
//
|
|
37
|
-
var
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"push",
|
|
53
|
-
"prompt"
|
|
54
|
-
],
|
|
55
|
-
author: {
|
|
56
|
-
name: "James Messinger",
|
|
57
|
-
url: "https://jamesmessinger.com"
|
|
58
|
-
},
|
|
59
|
-
license: "MIT",
|
|
60
|
-
homepage: "https://jstools.dev/version-bump-prompt",
|
|
61
|
-
repository: {
|
|
62
|
-
type: "git",
|
|
63
|
-
url: "https://github.com/antfu/bumpp.git"
|
|
64
|
-
},
|
|
65
|
-
main: "dist/index.js",
|
|
66
|
-
types: "dist/index.d.ts",
|
|
67
|
-
bin: {
|
|
68
|
-
bump: "bin/bumpp.js"
|
|
69
|
-
},
|
|
70
|
-
files: [
|
|
71
|
-
"bin",
|
|
72
|
-
"dist"
|
|
73
|
-
],
|
|
74
|
-
scripts: {
|
|
75
|
-
clean: "rimraf .nyc_output coverage dist",
|
|
76
|
-
lint: "eslint src test",
|
|
77
|
-
build: "tsup src/index.ts src/cli/index.ts --format esm,cjs --dts",
|
|
78
|
-
watch: "npm run build -- --watch src",
|
|
79
|
-
test: "mocha && npm run lint",
|
|
80
|
-
coverage: "nyc node_modules/mocha/bin/mocha",
|
|
81
|
-
upgrade: "npm-check -u && npm audit fix",
|
|
82
|
-
bump: "esno src/cli/run.ts --tag --push --all",
|
|
83
|
-
prepublishOnly: "npm run clean && npm run build",
|
|
84
|
-
release: "npm run bump && npm publish"
|
|
85
|
-
},
|
|
86
|
-
devDependencies: {
|
|
87
|
-
"@jsdevtools/chai-exec": "^2.1.1",
|
|
88
|
-
"@jsdevtools/eslint-config": "^1.1.4",
|
|
89
|
-
"@types/chai": "^4.2.12",
|
|
90
|
-
"@types/command-line-args": "^5.0.0",
|
|
91
|
-
"@types/globby": "^9.1.0",
|
|
92
|
-
"@types/inquirer": "^7.3.1",
|
|
93
|
-
"@types/mocha": "^8.0.3",
|
|
94
|
-
"@types/node": "^14.6.2",
|
|
95
|
-
"@types/semver": "^7.3.3",
|
|
96
|
-
chai: "^4.2.0",
|
|
97
|
-
del: "^5.1.0",
|
|
98
|
-
eslint: "^7.7.0",
|
|
99
|
-
esno: "^0.9.1",
|
|
100
|
-
mocha: "^8.1.3",
|
|
101
|
-
"npm-check": "^5.9.0",
|
|
102
|
-
nyc: "^15.1.0",
|
|
103
|
-
rimraf: "^3.0.2",
|
|
104
|
-
shx: "^0.3.2",
|
|
105
|
-
"strip-ansi": "^6.0.0",
|
|
106
|
-
tsup: "^4.14.0",
|
|
107
|
-
typescript: "^4.0.2"
|
|
108
|
-
},
|
|
109
|
-
dependencies: {
|
|
110
|
-
"@jsdevtools/ez-spawn": "^3.0.4",
|
|
111
|
-
"command-line-args": "^5.1.1",
|
|
112
|
-
"detect-indent": "^6.0.0",
|
|
113
|
-
"detect-newline": "^3.1.0",
|
|
114
|
-
globby: "^11.0.1",
|
|
115
|
-
inquirer: "^7.3.3",
|
|
116
|
-
"log-symbols": "^4.0.0",
|
|
117
|
-
semver: "^7.3.2"
|
|
118
|
-
},
|
|
119
|
-
engines: {
|
|
120
|
-
node: ">=10"
|
|
121
|
-
},
|
|
122
|
-
engineStrict: true
|
|
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";
|
|
123
121
|
};
|
|
122
|
+
module.exports = detectNewline2;
|
|
123
|
+
module.exports.graceful = (string) => typeof string === "string" && detectNewline2(string) || "\n";
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
// src/release-type.ts
|
|
128
|
+
init_esm_shims();
|
|
128
129
|
import { ReleaseType } from "semver";
|
|
129
|
-
var prereleaseTypes = ["
|
|
130
|
+
var prereleaseTypes = ["prerelease"];
|
|
130
131
|
var releaseTypes = prereleaseTypes.concat(["major", "minor", "patch"]);
|
|
131
132
|
function isPrerelease(value) {
|
|
132
133
|
return prereleaseTypes.includes(value);
|
|
@@ -135,48 +136,34 @@ function isReleaseType(value) {
|
|
|
135
136
|
return releaseTypes.includes(value);
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
// src/manifest.ts
|
|
139
|
-
var manifest = require_package();
|
|
140
|
-
function isManifest(obj) {
|
|
141
|
-
return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description);
|
|
142
|
-
}
|
|
143
|
-
function isOptionalString(value) {
|
|
144
|
-
let type = typeof value;
|
|
145
|
-
return value === null || type === "undefined" || type === "string";
|
|
146
|
-
}
|
|
147
|
-
|
|
148
139
|
// src/types/version-bump-progress.ts
|
|
149
|
-
|
|
150
|
-
(
|
|
140
|
+
init_esm_shims();
|
|
141
|
+
var ProgressEvent = /* @__PURE__ */ ((ProgressEvent2) => {
|
|
151
142
|
ProgressEvent2["FileUpdated"] = "file updated";
|
|
152
143
|
ProgressEvent2["FileSkipped"] = "file skipped";
|
|
153
144
|
ProgressEvent2["GitCommit"] = "git commit";
|
|
154
145
|
ProgressEvent2["GitTag"] = "git tag";
|
|
155
146
|
ProgressEvent2["GitPush"] = "git push";
|
|
156
147
|
ProgressEvent2["NpmScript"] = "npm script";
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
(
|
|
148
|
+
return ProgressEvent2;
|
|
149
|
+
})(ProgressEvent || {});
|
|
150
|
+
var NpmScript = /* @__PURE__ */ ((NpmScript3) => {
|
|
160
151
|
NpmScript3["PreVersion"] = "preversion";
|
|
161
152
|
NpmScript3["Version"] = "version";
|
|
162
153
|
NpmScript3["PostVersion"] = "postversion";
|
|
163
|
-
|
|
154
|
+
return NpmScript3;
|
|
155
|
+
})(NpmScript || {});
|
|
164
156
|
|
|
165
157
|
// src/version-bump.ts
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
} from "@jsdevtools/ez-spawn";
|
|
158
|
+
init_esm_shims();
|
|
159
|
+
import * as ezSpawn3 from "@jsdevtools/ez-spawn";
|
|
169
160
|
|
|
170
161
|
// src/get-new-version.ts
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
} from "
|
|
175
|
-
import {
|
|
176
|
-
clean,
|
|
177
|
-
valid
|
|
178
|
-
} from "semver";
|
|
179
|
-
import { SemVer } from "semver";
|
|
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";
|
|
180
167
|
async function getNewVersion(operation) {
|
|
181
168
|
let { release } = operation.options;
|
|
182
169
|
let { oldVersion } = operation.state;
|
|
@@ -205,80 +192,176 @@ function getNextVersion(oldVersion, bump) {
|
|
|
205
192
|
return newSemVer.version;
|
|
206
193
|
}
|
|
207
194
|
function getNextVersions(oldVersion, preid) {
|
|
195
|
+
var _a;
|
|
208
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
|
+
}
|
|
209
201
|
for (let type of releaseTypes) {
|
|
210
|
-
next[type] =
|
|
202
|
+
next[type] = semver.inc(oldVersion, type, preid);
|
|
211
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");
|
|
212
205
|
return next;
|
|
213
206
|
}
|
|
214
207
|
async function promptForNewVersion(operation) {
|
|
215
|
-
let { oldVersion
|
|
208
|
+
let { oldVersion } = operation.state;
|
|
216
209
|
let release = operation.options.release;
|
|
217
|
-
let prompts = createPromptModule(operation.options.interface);
|
|
218
210
|
let next = getNextVersions(oldVersion, release.preid);
|
|
219
211
|
let answers;
|
|
220
212
|
answers = await prompts([
|
|
221
213
|
{
|
|
222
|
-
type: "
|
|
214
|
+
type: "autocomplete",
|
|
223
215
|
name: "release",
|
|
224
|
-
message: `
|
|
225
|
-
|
|
226
|
-
How would you like to bump it?`,
|
|
227
|
-
default: "patch",
|
|
228
|
-
pageSize: 10,
|
|
216
|
+
message: `Current version: ${green(oldVersion)}`,
|
|
217
|
+
initial: "next",
|
|
229
218
|
choices: [
|
|
230
|
-
{ value: "major",
|
|
231
|
-
{ value: "minor",
|
|
232
|
-
{ value: "patch",
|
|
233
|
-
{ value: "
|
|
234
|
-
{ value: "
|
|
235
|
-
{ value: "
|
|
236
|
-
{ value: "
|
|
237
|
-
new Separator(),
|
|
238
|
-
{ value: "none", name: `leave as-is (${oldVersion})` },
|
|
239
|
-
{ value: "custom", name: "custom..." }
|
|
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..." }
|
|
240
226
|
]
|
|
241
227
|
},
|
|
242
228
|
{
|
|
243
|
-
type: "
|
|
244
|
-
name: "
|
|
229
|
+
type: (prev) => prev === "custom" ? "text" : null,
|
|
230
|
+
name: "custom",
|
|
245
231
|
message: "Enter the new version number:",
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
validate: (newVersion) => {
|
|
250
|
-
return valid(newVersion) ? true : "That's not a valid version number";
|
|
232
|
+
initial: oldVersion,
|
|
233
|
+
validate: (custom) => {
|
|
234
|
+
return isValidVersion(custom) ? true : "That's not a valid version number";
|
|
251
235
|
}
|
|
252
236
|
}
|
|
253
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
|
+
}
|
|
254
242
|
switch (answers.release) {
|
|
255
|
-
case "none":
|
|
256
|
-
return operation.update({ newVersion: oldVersion });
|
|
257
243
|
case "custom":
|
|
258
|
-
|
|
244
|
+
case "none":
|
|
245
|
+
return operation.update({ newVersion });
|
|
259
246
|
default:
|
|
260
|
-
return operation.update({
|
|
261
|
-
release: answers.release,
|
|
262
|
-
newVersion: next[answers.release]
|
|
263
|
-
});
|
|
247
|
+
return operation.update({ release: answers.release, newVersion });
|
|
264
248
|
}
|
|
265
249
|
}
|
|
266
250
|
|
|
267
251
|
// src/get-old-version.ts
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
} from "semver";
|
|
252
|
+
init_esm_shims();
|
|
253
|
+
import { valid as isValidVersion2 } from "semver";
|
|
271
254
|
|
|
272
255
|
// src/fs.ts
|
|
273
|
-
|
|
274
|
-
|
|
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());
|
|
275
358
|
import fs from "fs";
|
|
276
359
|
import path from "path";
|
|
277
360
|
async function readJsonFile(name, cwd) {
|
|
278
361
|
let file = await readTextFile(name, cwd);
|
|
279
362
|
let data = JSON.parse(file.data);
|
|
280
363
|
let indent = detectIndent(file.data).indent;
|
|
281
|
-
let newline =
|
|
364
|
+
let newline = (0, import_detect_newline.default)(file.data);
|
|
282
365
|
return __spreadProps(__spreadValues({}, file), { data, indent, newline });
|
|
283
366
|
}
|
|
284
367
|
async function writeJsonFile(file) {
|
|
@@ -315,6 +398,16 @@ function writeTextFile(file) {
|
|
|
315
398
|
});
|
|
316
399
|
}
|
|
317
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
|
+
|
|
318
411
|
// src/get-old-version.ts
|
|
319
412
|
async function getOldVersion(operation) {
|
|
320
413
|
let { cwd, files } = operation.options;
|
|
@@ -335,10 +428,10 @@ async function getOldVersion(operation) {
|
|
|
335
428
|
}
|
|
336
429
|
async function readVersion(file, cwd) {
|
|
337
430
|
try {
|
|
338
|
-
let { data:
|
|
339
|
-
if (isManifest(
|
|
340
|
-
if (
|
|
341
|
-
return
|
|
431
|
+
let { data: manifest } = await readJsonFile(file, cwd);
|
|
432
|
+
if (isManifest(manifest)) {
|
|
433
|
+
if (isValidVersion2(manifest.version)) {
|
|
434
|
+
return manifest.version;
|
|
342
435
|
}
|
|
343
436
|
}
|
|
344
437
|
} catch (error) {
|
|
@@ -347,9 +440,8 @@ async function readVersion(file, cwd) {
|
|
|
347
440
|
}
|
|
348
441
|
|
|
349
442
|
// src/git.ts
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
} from "@jsdevtools/ez-spawn";
|
|
443
|
+
init_esm_shims();
|
|
444
|
+
import * as ezSpawn from "@jsdevtools/ez-spawn";
|
|
353
445
|
async function gitCommit(operation) {
|
|
354
446
|
if (!operation.options.commit) {
|
|
355
447
|
return operation;
|
|
@@ -368,8 +460,8 @@ async function gitCommit(operation) {
|
|
|
368
460
|
if (!all) {
|
|
369
461
|
args = args.concat(updatedFiles);
|
|
370
462
|
}
|
|
371
|
-
await async("git", ["commit", ...args]);
|
|
372
|
-
return operation.update({ event:
|
|
463
|
+
await ezSpawn.async("git", ["commit", ...args]);
|
|
464
|
+
return operation.update({ event: "git commit" /* GitCommit */, commitMessage });
|
|
373
465
|
}
|
|
374
466
|
async function gitTag(operation) {
|
|
375
467
|
if (!operation.options.tag) {
|
|
@@ -384,18 +476,18 @@ async function gitTag(operation) {
|
|
|
384
476
|
];
|
|
385
477
|
let tagName = formatVersionString(tag.name, newVersion);
|
|
386
478
|
args.push(tagName);
|
|
387
|
-
await async("git", ["tag", ...args]);
|
|
388
|
-
return operation.update({ event:
|
|
479
|
+
await ezSpawn.async("git", ["tag", ...args]);
|
|
480
|
+
return operation.update({ event: "git tag" /* GitTag */, tagName });
|
|
389
481
|
}
|
|
390
482
|
async function gitPush(operation) {
|
|
391
483
|
if (!operation.options.push) {
|
|
392
484
|
return operation;
|
|
393
485
|
}
|
|
394
|
-
await async("git", "push");
|
|
486
|
+
await ezSpawn.async("git", "push");
|
|
395
487
|
if (operation.options.tag) {
|
|
396
|
-
await async("git", ["push", "--tags"]);
|
|
488
|
+
await ezSpawn.async("git", ["push", "--tags"]);
|
|
397
489
|
}
|
|
398
|
-
return operation.update({ event:
|
|
490
|
+
return operation.update({ event: "git push" /* GitPush */ });
|
|
399
491
|
}
|
|
400
492
|
function formatVersionString(template, newVersion) {
|
|
401
493
|
if (template.includes("%s")) {
|
|
@@ -405,7 +497,11 @@ function formatVersionString(template, newVersion) {
|
|
|
405
497
|
}
|
|
406
498
|
}
|
|
407
499
|
|
|
500
|
+
// src/operation.ts
|
|
501
|
+
init_esm_shims();
|
|
502
|
+
|
|
408
503
|
// src/normalize-options.ts
|
|
504
|
+
init_esm_shims();
|
|
409
505
|
import globby from "globby";
|
|
410
506
|
import { hasMagic } from "globby";
|
|
411
507
|
async function normalizeOptions(raw) {
|
|
@@ -464,7 +560,7 @@ async function normalizeOptions(raw) {
|
|
|
464
560
|
}
|
|
465
561
|
async function strictGlobMatches(files, options) {
|
|
466
562
|
let matches = await Promise.all(files.map((file) => strictGlobMatch(file, options)));
|
|
467
|
-
let matchedFiles = new Set();
|
|
563
|
+
let matchedFiles = /* @__PURE__ */ new Set();
|
|
468
564
|
for (let match of matches) {
|
|
469
565
|
for (let file of match) {
|
|
470
566
|
matchedFiles.add(file);
|
|
@@ -528,22 +624,21 @@ var Operation = class {
|
|
|
528
624
|
};
|
|
529
625
|
|
|
530
626
|
// src/run-npm-script.ts
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
} from "@jsdevtools/ez-spawn";
|
|
627
|
+
init_esm_shims();
|
|
628
|
+
import * as ezSpawn2 from "@jsdevtools/ez-spawn";
|
|
534
629
|
async function runNpmScript(script, operation) {
|
|
535
630
|
let { cwd, ignoreScripts } = operation.options;
|
|
536
631
|
if (!ignoreScripts) {
|
|
537
|
-
let { data:
|
|
538
|
-
if (isManifest(
|
|
539
|
-
await
|
|
540
|
-
operation.update({ event:
|
|
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 });
|
|
541
636
|
}
|
|
542
637
|
}
|
|
543
638
|
return operation;
|
|
544
639
|
}
|
|
545
|
-
function hasScript(
|
|
546
|
-
let scripts =
|
|
640
|
+
function hasScript(manifest, script) {
|
|
641
|
+
let scripts = manifest.scripts;
|
|
547
642
|
if (scripts && typeof scripts === "object") {
|
|
548
643
|
return Boolean(scripts[script]);
|
|
549
644
|
}
|
|
@@ -551,21 +646,20 @@ function hasScript(manifest2, script) {
|
|
|
551
646
|
}
|
|
552
647
|
|
|
553
648
|
// src/update-files.ts
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
} from "path";
|
|
649
|
+
init_esm_shims();
|
|
650
|
+
import * as path2 from "path";
|
|
557
651
|
async function updateFiles(operation) {
|
|
558
652
|
let { files } = operation.options;
|
|
559
653
|
for (let relPath of files) {
|
|
560
654
|
let modified = await updateFile(relPath, operation);
|
|
561
655
|
if (modified) {
|
|
562
656
|
operation.update({
|
|
563
|
-
event:
|
|
657
|
+
event: "file updated" /* FileUpdated */,
|
|
564
658
|
updatedFiles: operation.state.updatedFiles.concat(relPath)
|
|
565
659
|
});
|
|
566
660
|
} else {
|
|
567
661
|
operation.update({
|
|
568
|
-
event:
|
|
662
|
+
event: "file skipped" /* FileSkipped */,
|
|
569
663
|
skippedFiles: operation.state.skippedFiles.concat(relPath)
|
|
570
664
|
});
|
|
571
665
|
}
|
|
@@ -573,7 +667,7 @@ async function updateFiles(operation) {
|
|
|
573
667
|
return operation;
|
|
574
668
|
}
|
|
575
669
|
async function updateFile(relPath, operation) {
|
|
576
|
-
let name = basename(relPath).trim().toLowerCase();
|
|
670
|
+
let name = path2.basename(relPath).trim().toLowerCase();
|
|
577
671
|
switch (name) {
|
|
578
672
|
case "package.json":
|
|
579
673
|
case "package-lock.json":
|
|
@@ -612,6 +706,7 @@ async function updateTextFile(relPath, operation) {
|
|
|
612
706
|
}
|
|
613
707
|
|
|
614
708
|
// src/version-bump.ts
|
|
709
|
+
var import_log_symbols = __toESM(require_log_symbols());
|
|
615
710
|
async function versionBump(arg = {}) {
|
|
616
711
|
if (typeof arg === "string") {
|
|
617
712
|
arg = { release: arg };
|
|
@@ -619,24 +714,28 @@ async function versionBump(arg = {}) {
|
|
|
619
714
|
let operation = await Operation.start(arg);
|
|
620
715
|
await getOldVersion(operation);
|
|
621
716
|
await getNewVersion(operation);
|
|
622
|
-
await runNpmScript(
|
|
717
|
+
await runNpmScript("preversion" /* PreVersion */, operation);
|
|
623
718
|
await updateFiles(operation);
|
|
624
719
|
if (operation.options.execute) {
|
|
625
|
-
|
|
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");
|
|
626
723
|
}
|
|
627
|
-
await runNpmScript(
|
|
724
|
+
await runNpmScript("version" /* Version */, operation);
|
|
628
725
|
await gitCommit(operation);
|
|
629
726
|
await gitTag(operation);
|
|
630
|
-
await runNpmScript(
|
|
727
|
+
await runNpmScript("postversion" /* PostVersion */, operation);
|
|
631
728
|
await gitPush(operation);
|
|
632
729
|
return operation.results;
|
|
633
730
|
}
|
|
634
731
|
|
|
635
732
|
export {
|
|
733
|
+
__toESM,
|
|
734
|
+
init_esm_shims,
|
|
636
735
|
ReleaseType,
|
|
637
736
|
isReleaseType,
|
|
638
|
-
manifest,
|
|
639
737
|
ProgressEvent,
|
|
640
738
|
NpmScript,
|
|
739
|
+
require_log_symbols,
|
|
641
740
|
versionBump
|
|
642
741
|
};
|