@thisismanta/semantic-version 11.0.0 → 11.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/README.md +22 -7
- package/bin/lint-commit-message +1 -1
- package/bin/make-next-release +1 -1
- package/lib/index.d.ts +22 -0
- package/lib/index.js +10 -30
- package/lib/lint-commit-message.d.ts +1 -0
- package/lib/lint-commit-message.js +6 -7
- package/lib/make-next-release.d.ts +1 -0
- package/lib/make-next-release.js +154 -542
- package/lib/src.js +609 -0
- package/package.json +9 -7
- package/lib/chunk.js +0 -35
- package/lib/run.js +0 -27
package/lib/src.js
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let node_child_process = require("node:child_process");
|
|
25
|
+
node_child_process = __toESM(node_child_process);
|
|
26
|
+
let node_fs = require("node:fs");
|
|
27
|
+
node_fs = __toESM(node_fs);
|
|
28
|
+
//#region node_modules/semver/internal/debug.js
|
|
29
|
+
var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
30
|
+
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
31
|
+
}));
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region node_modules/semver/internal/constants.js
|
|
34
|
+
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
35
|
+
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
36
|
+
const MAX_LENGTH = 256;
|
|
37
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
38
|
+
module.exports = {
|
|
39
|
+
MAX_LENGTH,
|
|
40
|
+
MAX_SAFE_COMPONENT_LENGTH: 16,
|
|
41
|
+
MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
|
|
42
|
+
MAX_SAFE_INTEGER,
|
|
43
|
+
RELEASE_TYPES: [
|
|
44
|
+
"major",
|
|
45
|
+
"premajor",
|
|
46
|
+
"minor",
|
|
47
|
+
"preminor",
|
|
48
|
+
"patch",
|
|
49
|
+
"prepatch",
|
|
50
|
+
"prerelease"
|
|
51
|
+
],
|
|
52
|
+
SEMVER_SPEC_VERSION,
|
|
53
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
54
|
+
FLAG_LOOSE: 2
|
|
55
|
+
};
|
|
56
|
+
}));
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region node_modules/semver/internal/re.js
|
|
59
|
+
var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
60
|
+
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
61
|
+
const debug = require_debug();
|
|
62
|
+
exports = module.exports = {};
|
|
63
|
+
const re = exports.re = [];
|
|
64
|
+
const safeRe = exports.safeRe = [];
|
|
65
|
+
const src = exports.src = [];
|
|
66
|
+
const safeSrc = exports.safeSrc = [];
|
|
67
|
+
const t = exports.t = {};
|
|
68
|
+
let R = 0;
|
|
69
|
+
const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
70
|
+
const safeRegexReplacements = [
|
|
71
|
+
["\\s", 1],
|
|
72
|
+
["\\d", MAX_LENGTH],
|
|
73
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
74
|
+
];
|
|
75
|
+
const makeSafeRegex = (value) => {
|
|
76
|
+
for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
77
|
+
return value;
|
|
78
|
+
};
|
|
79
|
+
const createToken = (name, value, isGlobal) => {
|
|
80
|
+
const safe = makeSafeRegex(value);
|
|
81
|
+
const index = R++;
|
|
82
|
+
debug(name, index, value);
|
|
83
|
+
t[name] = index;
|
|
84
|
+
src[index] = value;
|
|
85
|
+
safeSrc[index] = safe;
|
|
86
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
87
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
88
|
+
};
|
|
89
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
90
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
91
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
92
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
93
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
94
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
95
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
96
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
97
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
98
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
99
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
100
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
101
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
102
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
103
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
104
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
105
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
106
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
107
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
108
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
109
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
110
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
111
|
+
createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
112
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
113
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
114
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
115
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
116
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
117
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
118
|
+
exports.tildeTrimReplace = "$1~";
|
|
119
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
120
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
121
|
+
createToken("LONECARET", "(?:\\^)");
|
|
122
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
123
|
+
exports.caretTrimReplace = "$1^";
|
|
124
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
125
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
126
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
127
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
128
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
129
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
130
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
131
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
132
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
133
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
134
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
135
|
+
}));
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region node_modules/semver/internal/parse-options.js
|
|
138
|
+
var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
139
|
+
const looseOption = Object.freeze({ loose: true });
|
|
140
|
+
const emptyOpts = Object.freeze({});
|
|
141
|
+
const parseOptions = (options) => {
|
|
142
|
+
if (!options) return emptyOpts;
|
|
143
|
+
if (typeof options !== "object") return looseOption;
|
|
144
|
+
return options;
|
|
145
|
+
};
|
|
146
|
+
module.exports = parseOptions;
|
|
147
|
+
}));
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region node_modules/semver/internal/identifiers.js
|
|
150
|
+
var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
151
|
+
const numeric = /^[0-9]+$/;
|
|
152
|
+
const compareIdentifiers = (a, b) => {
|
|
153
|
+
if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
|
|
154
|
+
const anum = numeric.test(a);
|
|
155
|
+
const bnum = numeric.test(b);
|
|
156
|
+
if (anum && bnum) {
|
|
157
|
+
a = +a;
|
|
158
|
+
b = +b;
|
|
159
|
+
}
|
|
160
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
161
|
+
};
|
|
162
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
163
|
+
module.exports = {
|
|
164
|
+
compareIdentifiers,
|
|
165
|
+
rcompareIdentifiers
|
|
166
|
+
};
|
|
167
|
+
}));
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region node_modules/semver/classes/semver.js
|
|
170
|
+
var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
171
|
+
const debug = require_debug();
|
|
172
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
173
|
+
const { safeRe: re, t } = require_re();
|
|
174
|
+
const parseOptions = require_parse_options();
|
|
175
|
+
const { compareIdentifiers } = require_identifiers();
|
|
176
|
+
module.exports = class SemVer {
|
|
177
|
+
constructor(version, options) {
|
|
178
|
+
options = parseOptions(options);
|
|
179
|
+
if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
|
|
180
|
+
else version = version.version;
|
|
181
|
+
else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
182
|
+
if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
183
|
+
debug("SemVer", version, options);
|
|
184
|
+
this.options = options;
|
|
185
|
+
this.loose = !!options.loose;
|
|
186
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
187
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
188
|
+
if (!m) throw new TypeError(`Invalid Version: ${version}`);
|
|
189
|
+
this.raw = version;
|
|
190
|
+
this.major = +m[1];
|
|
191
|
+
this.minor = +m[2];
|
|
192
|
+
this.patch = +m[3];
|
|
193
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
|
|
194
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
195
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
196
|
+
if (!m[4]) this.prerelease = [];
|
|
197
|
+
else this.prerelease = m[4].split(".").map((id) => {
|
|
198
|
+
if (/^[0-9]+$/.test(id)) {
|
|
199
|
+
const num = +id;
|
|
200
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
|
|
201
|
+
}
|
|
202
|
+
return id;
|
|
203
|
+
});
|
|
204
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
205
|
+
this.format();
|
|
206
|
+
}
|
|
207
|
+
format() {
|
|
208
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
209
|
+
if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
|
|
210
|
+
return this.version;
|
|
211
|
+
}
|
|
212
|
+
toString() {
|
|
213
|
+
return this.version;
|
|
214
|
+
}
|
|
215
|
+
compare(other) {
|
|
216
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
217
|
+
if (!(other instanceof SemVer)) {
|
|
218
|
+
if (typeof other === "string" && other === this.version) return 0;
|
|
219
|
+
other = new SemVer(other, this.options);
|
|
220
|
+
}
|
|
221
|
+
if (other.version === this.version) return 0;
|
|
222
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
223
|
+
}
|
|
224
|
+
compareMain(other) {
|
|
225
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
226
|
+
if (this.major < other.major) return -1;
|
|
227
|
+
if (this.major > other.major) return 1;
|
|
228
|
+
if (this.minor < other.minor) return -1;
|
|
229
|
+
if (this.minor > other.minor) return 1;
|
|
230
|
+
if (this.patch < other.patch) return -1;
|
|
231
|
+
if (this.patch > other.patch) return 1;
|
|
232
|
+
return 0;
|
|
233
|
+
}
|
|
234
|
+
comparePre(other) {
|
|
235
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
236
|
+
if (this.prerelease.length && !other.prerelease.length) return -1;
|
|
237
|
+
else if (!this.prerelease.length && other.prerelease.length) return 1;
|
|
238
|
+
else if (!this.prerelease.length && !other.prerelease.length) return 0;
|
|
239
|
+
let i = 0;
|
|
240
|
+
do {
|
|
241
|
+
const a = this.prerelease[i];
|
|
242
|
+
const b = other.prerelease[i];
|
|
243
|
+
debug("prerelease compare", i, a, b);
|
|
244
|
+
if (a === void 0 && b === void 0) return 0;
|
|
245
|
+
else if (b === void 0) return 1;
|
|
246
|
+
else if (a === void 0) return -1;
|
|
247
|
+
else if (a === b) continue;
|
|
248
|
+
else return compareIdentifiers(a, b);
|
|
249
|
+
} while (++i);
|
|
250
|
+
}
|
|
251
|
+
compareBuild(other) {
|
|
252
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
253
|
+
let i = 0;
|
|
254
|
+
do {
|
|
255
|
+
const a = this.build[i];
|
|
256
|
+
const b = other.build[i];
|
|
257
|
+
debug("build compare", i, a, b);
|
|
258
|
+
if (a === void 0 && b === void 0) return 0;
|
|
259
|
+
else if (b === void 0) return 1;
|
|
260
|
+
else if (a === void 0) return -1;
|
|
261
|
+
else if (a === b) continue;
|
|
262
|
+
else return compareIdentifiers(a, b);
|
|
263
|
+
} while (++i);
|
|
264
|
+
}
|
|
265
|
+
inc(release, identifier, identifierBase) {
|
|
266
|
+
if (release.startsWith("pre")) {
|
|
267
|
+
if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
|
|
268
|
+
if (identifier) {
|
|
269
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
270
|
+
if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
switch (release) {
|
|
274
|
+
case "premajor":
|
|
275
|
+
this.prerelease.length = 0;
|
|
276
|
+
this.patch = 0;
|
|
277
|
+
this.minor = 0;
|
|
278
|
+
this.major++;
|
|
279
|
+
this.inc("pre", identifier, identifierBase);
|
|
280
|
+
break;
|
|
281
|
+
case "preminor":
|
|
282
|
+
this.prerelease.length = 0;
|
|
283
|
+
this.patch = 0;
|
|
284
|
+
this.minor++;
|
|
285
|
+
this.inc("pre", identifier, identifierBase);
|
|
286
|
+
break;
|
|
287
|
+
case "prepatch":
|
|
288
|
+
this.prerelease.length = 0;
|
|
289
|
+
this.inc("patch", identifier, identifierBase);
|
|
290
|
+
this.inc("pre", identifier, identifierBase);
|
|
291
|
+
break;
|
|
292
|
+
case "prerelease":
|
|
293
|
+
if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
|
|
294
|
+
this.inc("pre", identifier, identifierBase);
|
|
295
|
+
break;
|
|
296
|
+
case "release":
|
|
297
|
+
if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
|
|
298
|
+
this.prerelease.length = 0;
|
|
299
|
+
break;
|
|
300
|
+
case "major":
|
|
301
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
|
|
302
|
+
this.minor = 0;
|
|
303
|
+
this.patch = 0;
|
|
304
|
+
this.prerelease = [];
|
|
305
|
+
break;
|
|
306
|
+
case "minor":
|
|
307
|
+
if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
|
|
308
|
+
this.patch = 0;
|
|
309
|
+
this.prerelease = [];
|
|
310
|
+
break;
|
|
311
|
+
case "patch":
|
|
312
|
+
if (this.prerelease.length === 0) this.patch++;
|
|
313
|
+
this.prerelease = [];
|
|
314
|
+
break;
|
|
315
|
+
case "pre": {
|
|
316
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
317
|
+
if (this.prerelease.length === 0) this.prerelease = [base];
|
|
318
|
+
else {
|
|
319
|
+
let i = this.prerelease.length;
|
|
320
|
+
while (--i >= 0) if (typeof this.prerelease[i] === "number") {
|
|
321
|
+
this.prerelease[i]++;
|
|
322
|
+
i = -2;
|
|
323
|
+
}
|
|
324
|
+
if (i === -1) {
|
|
325
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
|
|
326
|
+
this.prerelease.push(base);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (identifier) {
|
|
330
|
+
let prerelease = [identifier, base];
|
|
331
|
+
if (identifierBase === false) prerelease = [identifier];
|
|
332
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
333
|
+
if (isNaN(this.prerelease[1])) this.prerelease = prerelease;
|
|
334
|
+
} else this.prerelease = prerelease;
|
|
335
|
+
}
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
default: throw new Error(`invalid increment argument: ${release}`);
|
|
339
|
+
}
|
|
340
|
+
this.raw = this.format();
|
|
341
|
+
if (this.build.length) this.raw += `+${this.build.join(".")}`;
|
|
342
|
+
return this;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}));
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region node_modules/semver/functions/parse.js
|
|
348
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
349
|
+
const SemVer = require_semver();
|
|
350
|
+
const parse = (version, options, throwErrors = false) => {
|
|
351
|
+
if (version instanceof SemVer) return version;
|
|
352
|
+
try {
|
|
353
|
+
return new SemVer(version, options);
|
|
354
|
+
} catch (er) {
|
|
355
|
+
if (!throwErrors) return null;
|
|
356
|
+
throw er;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
module.exports = parse;
|
|
360
|
+
}));
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region node_modules/yn/lenient.js
|
|
363
|
+
var import_valid = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
364
|
+
const parse = require_parse();
|
|
365
|
+
const valid = (version, options) => {
|
|
366
|
+
const v = parse(version, options);
|
|
367
|
+
return v ? v.version : null;
|
|
368
|
+
};
|
|
369
|
+
module.exports = valid;
|
|
370
|
+
})))());
|
|
371
|
+
const YES_MATCH_SCORE_THRESHOLD = 2;
|
|
372
|
+
const NO_MATCH_SCORE_THRESHOLD = 1.25;
|
|
373
|
+
const yMatch = new Map([
|
|
374
|
+
[5, .25],
|
|
375
|
+
[6, .25],
|
|
376
|
+
[7, .25],
|
|
377
|
+
["t", .75],
|
|
378
|
+
["y", 1],
|
|
379
|
+
["u", .75],
|
|
380
|
+
["g", .25],
|
|
381
|
+
["h", .25],
|
|
382
|
+
["j", .25]
|
|
383
|
+
]);
|
|
384
|
+
const eMatch = new Map([
|
|
385
|
+
[2, .25],
|
|
386
|
+
[3, .25],
|
|
387
|
+
[4, .25],
|
|
388
|
+
["w", .75],
|
|
389
|
+
["e", 1],
|
|
390
|
+
["r", .75],
|
|
391
|
+
["s", .25],
|
|
392
|
+
["d", .25],
|
|
393
|
+
["f", .25]
|
|
394
|
+
]);
|
|
395
|
+
const sMatch = new Map([
|
|
396
|
+
["q", .25],
|
|
397
|
+
["w", .25],
|
|
398
|
+
["e", .25],
|
|
399
|
+
["a", .75],
|
|
400
|
+
["s", 1],
|
|
401
|
+
["d", .75],
|
|
402
|
+
["z", .25],
|
|
403
|
+
["x", .25],
|
|
404
|
+
["c", .25]
|
|
405
|
+
]);
|
|
406
|
+
const nMatch = new Map([
|
|
407
|
+
["h", .25],
|
|
408
|
+
["j", .25],
|
|
409
|
+
["k", .25],
|
|
410
|
+
["b", .75],
|
|
411
|
+
["n", 1],
|
|
412
|
+
["m", .75]
|
|
413
|
+
]);
|
|
414
|
+
const oMatch = new Map([
|
|
415
|
+
[9, .25],
|
|
416
|
+
[0, .25],
|
|
417
|
+
["i", .75],
|
|
418
|
+
["o", 1],
|
|
419
|
+
["p", .75],
|
|
420
|
+
["k", .25],
|
|
421
|
+
["l", .25]
|
|
422
|
+
]);
|
|
423
|
+
function getYesMatchScore(value) {
|
|
424
|
+
const [y, e, s] = value;
|
|
425
|
+
let score = 0;
|
|
426
|
+
if (yMatch.has(y)) score += yMatch.get(y);
|
|
427
|
+
if (eMatch.has(e)) score += eMatch.get(e);
|
|
428
|
+
if (sMatch.has(s)) score += sMatch.get(s);
|
|
429
|
+
return score;
|
|
430
|
+
}
|
|
431
|
+
function getNoMatchScore(value) {
|
|
432
|
+
const [n, o] = value;
|
|
433
|
+
let score = 0;
|
|
434
|
+
if (nMatch.has(n)) score += nMatch.get(n);
|
|
435
|
+
if (oMatch.has(o)) score += oMatch.get(o);
|
|
436
|
+
return score;
|
|
437
|
+
}
|
|
438
|
+
function lenient(input, default_) {
|
|
439
|
+
if (getYesMatchScore(input) >= YES_MATCH_SCORE_THRESHOLD) return true;
|
|
440
|
+
if (getNoMatchScore(input) >= NO_MATCH_SCORE_THRESHOLD) return false;
|
|
441
|
+
return default_;
|
|
442
|
+
}
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region node_modules/yn/index.js
|
|
445
|
+
function yn(value, { lenient: lenient$1 = false, default: default_ } = {}) {
|
|
446
|
+
if (default_ !== void 0 && typeof default_ !== "boolean") throw new TypeError(`Expected the \`default\` option to be of type \`boolean\`, got \`${typeof default_}\``);
|
|
447
|
+
if (value === void 0 || value === null) return default_;
|
|
448
|
+
value = String(value).trim();
|
|
449
|
+
if (/^(?:y|yes|t|true|1|on)$/i.test(value)) return true;
|
|
450
|
+
if (/^(?:n|no|f|false|0|off)$/i.test(value)) return false;
|
|
451
|
+
if (lenient$1 === true) return lenient(value, default_);
|
|
452
|
+
return default_;
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/index.ts
|
|
456
|
+
const debuggingEnabled = yn(process.env.DEBUG) || yn(process.env.ACTIONS_RUNNER_DEBUG) || yn(process.env.ACTIONS_STEP_DEBUG);
|
|
457
|
+
function debug(text) {
|
|
458
|
+
if (debuggingEnabled) console.log("::debug::" + text);
|
|
459
|
+
}
|
|
460
|
+
function run(command) {
|
|
461
|
+
return new Promise((resolve, reject) => {
|
|
462
|
+
node_child_process.exec(command, (error, stdout, stderr) => {
|
|
463
|
+
debug("> " + command);
|
|
464
|
+
stdout = stdout.trim();
|
|
465
|
+
if (stdout.length > 0) debug(stdout);
|
|
466
|
+
stderr = stderr.trim();
|
|
467
|
+
if (stderr.length > 0) debug(stderr);
|
|
468
|
+
if (error) reject(error);
|
|
469
|
+
else resolve(stdout);
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
const packageJSON = JSON.parse(node_fs.readFileSync("./package.json", { encoding: "utf-8" }));
|
|
474
|
+
const npm = packageJSON?.packageManager?.replace(/@.*$/, "") ?? packageJSON?.devEngines?.packageManager?.name ?? "npm";
|
|
475
|
+
const titlePattern = /^(?<type>\w+)(?<scope>\(.*?\))?(?<breaking>\!)?:(?<subject>.+)/;
|
|
476
|
+
const allowedTypes = [
|
|
477
|
+
"feat",
|
|
478
|
+
"fix",
|
|
479
|
+
"build",
|
|
480
|
+
"chore"
|
|
481
|
+
];
|
|
482
|
+
function checkConventionalMessage(message) {
|
|
483
|
+
const { type, scope, breaking, subject } = message.match(titlePattern)?.groups || {};
|
|
484
|
+
const errors = [
|
|
485
|
+
!type && "The pull request title must match the pattern of \"<type>[!]: <subject>\" which is a reduced set of https://www.conventionalcommits.org/en/v1.0.0/",
|
|
486
|
+
typeof type === "string" && allowedTypes.includes(type.toLowerCase()) === false && "The type in a pull request title must be one of " + allowedTypes.map((name) => "\"" + name + "\"").join(", ") + ".",
|
|
487
|
+
typeof type === "string" && /^[a-z]+$/.test(type) === false && "The type in a pull request title must be in lower case only.",
|
|
488
|
+
scope && "A scope in a pull request title is never allowed.",
|
|
489
|
+
typeof type === "string" && typeof subject !== "string" && "The subject in a pull request title must be provided.",
|
|
490
|
+
typeof subject === "string" && (subject.match(/^ +/)?.[0].length || 0) !== 1 && "A single space must be after \":\" symbol.",
|
|
491
|
+
typeof subject === "string" && /^[a-z]/.test(subject.trim()) === false && "The subject must start with a lower case latin alphabet.",
|
|
492
|
+
typeof subject === "string" && /[\s\.]+$/.test(subject) && /\.{3}$/.test(subject.trim()) === false && "The subject must not end with a period or a space."
|
|
493
|
+
].filter((error) => typeof error === "string");
|
|
494
|
+
return {
|
|
495
|
+
type: allowedTypes.includes(type) ? type : void 0,
|
|
496
|
+
breaking: !!breaking,
|
|
497
|
+
subject: typeof subject === "string" ? subject.trim().replace(/[\s\.]+$/, "") + (/\.{3}$/.test(subject.trim()) ? "..." : "") : message,
|
|
498
|
+
errors
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function getReleaseType(commits) {
|
|
502
|
+
if (commits.find(({ breaking }) => breaking)) return "major";
|
|
503
|
+
if (commits.find(({ type }) => type === "feat")) return "minor";
|
|
504
|
+
if (commits.find(({ type }) => type === "fix" || type === "build")) return "patch";
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
async function getCurrentPackageVersion() {
|
|
508
|
+
const version = JSON.parse(await run(`${npm} pkg get version`));
|
|
509
|
+
if (typeof version === "string" && (0, import_valid.default)(version)) return version;
|
|
510
|
+
else throw new Error("Expected a valid version field in package.json.");
|
|
511
|
+
}
|
|
512
|
+
async function getGitHistory(version) {
|
|
513
|
+
const tag = await run(`git tag --list v${version}`) || await run("git describe --tags --abbrev=0");
|
|
514
|
+
return getCommits(await run(`git --no-pager log ${tag ? tag + "..HEAD" : ""} --format=%H%s`));
|
|
515
|
+
}
|
|
516
|
+
function getCommits(gitLogs) {
|
|
517
|
+
return gitLogs.split("\n").filter((line) => line.length > 0).map((line) => ({
|
|
518
|
+
hash: line.substring(0, 40),
|
|
519
|
+
message: line.substring(40)
|
|
520
|
+
})).filter(({ message }) => (0, import_valid.default)(message) === null).map(({ hash, message }) => {
|
|
521
|
+
const { type, breaking, subject } = checkConventionalMessage(message);
|
|
522
|
+
return {
|
|
523
|
+
hash,
|
|
524
|
+
type,
|
|
525
|
+
breaking,
|
|
526
|
+
subject
|
|
527
|
+
};
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
function getReleaseNote(commits) {
|
|
531
|
+
const groups = {
|
|
532
|
+
"BREAKING CHANGES": [],
|
|
533
|
+
Features: [],
|
|
534
|
+
"Bug Fixes": [],
|
|
535
|
+
Others: []
|
|
536
|
+
};
|
|
537
|
+
for (const commit of commits) if (commit.breaking) groups["BREAKING CHANGES"].push(commit);
|
|
538
|
+
else if (commit.type === "feat") groups["Features"].push(commit);
|
|
539
|
+
else if (commit.type === "fix") groups["Bug Fixes"].push(commit);
|
|
540
|
+
else groups["Others"].push(commit);
|
|
541
|
+
return Object.entries(groups).filter(([title, commits]) => commits.length > 0).map(([title, commits]) => `### ${title}\n\n` + commits.map(({ subject, hash }) => `- ${subject} (${hash})`).join("\n")).join("\n\n");
|
|
542
|
+
}
|
|
543
|
+
//#endregion
|
|
544
|
+
Object.defineProperty(exports, "__commonJSMin", {
|
|
545
|
+
enumerable: true,
|
|
546
|
+
get: function() {
|
|
547
|
+
return __commonJSMin;
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
Object.defineProperty(exports, "__toESM", {
|
|
551
|
+
enumerable: true,
|
|
552
|
+
get: function() {
|
|
553
|
+
return __toESM;
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
Object.defineProperty(exports, "allowedTypes", {
|
|
557
|
+
enumerable: true,
|
|
558
|
+
get: function() {
|
|
559
|
+
return allowedTypes;
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
Object.defineProperty(exports, "checkConventionalMessage", {
|
|
563
|
+
enumerable: true,
|
|
564
|
+
get: function() {
|
|
565
|
+
return checkConventionalMessage;
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
Object.defineProperty(exports, "debug", {
|
|
569
|
+
enumerable: true,
|
|
570
|
+
get: function() {
|
|
571
|
+
return debug;
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
Object.defineProperty(exports, "getCurrentPackageVersion", {
|
|
575
|
+
enumerable: true,
|
|
576
|
+
get: function() {
|
|
577
|
+
return getCurrentPackageVersion;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
Object.defineProperty(exports, "getGitHistory", {
|
|
581
|
+
enumerable: true,
|
|
582
|
+
get: function() {
|
|
583
|
+
return getGitHistory;
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
Object.defineProperty(exports, "getReleaseNote", {
|
|
587
|
+
enumerable: true,
|
|
588
|
+
get: function() {
|
|
589
|
+
return getReleaseNote;
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
Object.defineProperty(exports, "getReleaseType", {
|
|
593
|
+
enumerable: true,
|
|
594
|
+
get: function() {
|
|
595
|
+
return getReleaseType;
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
Object.defineProperty(exports, "npm", {
|
|
599
|
+
enumerable: true,
|
|
600
|
+
get: function() {
|
|
601
|
+
return npm;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
Object.defineProperty(exports, "run", {
|
|
605
|
+
enumerable: true,
|
|
606
|
+
get: function() {
|
|
607
|
+
return run;
|
|
608
|
+
}
|
|
609
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisismanta/semantic-version",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Anantachai Saothong <thisismanta@gmail.com>",
|
|
6
6
|
"repository": {
|
|
@@ -18,20 +18,22 @@
|
|
|
18
18
|
"main": "lib/index.js",
|
|
19
19
|
"types": "lib/index.d.ts",
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "
|
|
22
|
-
"build": "rm -rf lib && find src -name '*.ts' ! -name '*.test.ts' | xargs npm exec rolldown -- --transform.target node22 --format commonjs --dir lib --chunk-file-names [name].js",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
21
|
+
"test": "vitest",
|
|
22
|
+
"build": "rm -rf lib && tsc --outDir lib && find src -name '*.ts' ! -name '*.test.ts' | xargs npm exec rolldown -- --transform.target node22 --format commonjs --dir lib --chunk-file-names [name].js",
|
|
23
|
+
"version": "npm run build",
|
|
24
|
+
"postversion": "npm publish --provenance --access public"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@actions/github": "^9.0.0",
|
|
28
28
|
"@types/node": "~24.12.2",
|
|
29
29
|
"@types/semver": "^7.7.1",
|
|
30
30
|
"lefthook": "^2.1.5",
|
|
31
|
+
"oxfmt": "^0.44.0",
|
|
31
32
|
"semver": "^7.7.4",
|
|
32
33
|
"typescript": "^6.0.2",
|
|
33
|
-
"vite": "^8.0.
|
|
34
|
-
"vitest": "^4.1.
|
|
34
|
+
"vite": "^8.0.7",
|
|
35
|
+
"vitest": "^4.1.3",
|
|
36
|
+
"yn": "^5.1.0"
|
|
35
37
|
},
|
|
36
38
|
"devEngines": {
|
|
37
39
|
"packageManager": {
|
package/lib/chunk.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
-
value: mod,
|
|
21
|
-
enumerable: true
|
|
22
|
-
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
|
-
Object.defineProperty(exports, "__commonJSMin", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function() {
|
|
27
|
-
return __commonJSMin;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "__toESM", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function() {
|
|
33
|
-
return __toESM;
|
|
34
|
-
}
|
|
35
|
-
});
|