@voidzero-dev/vite-plus-core 0.2.4 → 0.2.6
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 +36 -120
- package/dist/rolldown/cli.d.mts +1 -1
- package/dist/rolldown/cli.mjs +11 -8
- package/dist/rolldown/config.d.mts +22 -10
- package/dist/rolldown/config.mjs +2 -2
- package/dist/rolldown/experimental-index.d.mts +164 -155
- package/dist/rolldown/experimental-index.mjs +23 -14
- package/dist/rolldown/experimental-runtime-types.d.ts +111 -41
- package/dist/rolldown/filter-index.d.mts +6 -5
- package/dist/rolldown/get-log-filter.d.mts +2 -2
- package/dist/rolldown/index.d.mts +4 -4
- package/dist/rolldown/index.mjs +10 -4
- package/dist/rolldown/parallel-plugin-worker.d.mts +1 -1
- package/dist/rolldown/parallel-plugin-worker.mjs +2 -2
- package/dist/rolldown/parallel-plugin.d.mts +3 -4
- package/dist/rolldown/parse-ast-index.d.mts +19 -20
- package/dist/rolldown/parse-ast-index.mjs +2 -2
- package/dist/rolldown/plugins-index.d.mts +27 -28
- package/dist/rolldown/plugins-index.mjs +2 -2
- package/dist/rolldown/shared/{binding-B1q9aYT-.d.mts → binding-Dbbi0RbO.d.mts} +49 -25
- package/dist/rolldown/shared/{binding-BmkJW3Wy.mjs → binding-Dby9rwGk.mjs} +26 -26
- package/dist/rolldown/shared/{bindingify-input-options-Cmm60vfj.mjs → bindingify-input-options-DVQ4K-zY.mjs} +11 -13
- package/dist/rolldown/shared/{constructors-2i1T9YcF.d.mts → constructors-CSWbNgBZ.d.mts} +9 -10
- package/dist/rolldown/shared/{constructors-CE6zZSUt.mjs → constructors-CuGa75s-.mjs} +1 -1
- package/dist/rolldown/shared/define-config-B-IDOhDz.d.mts +4003 -0
- package/dist/rolldown/shared/dist-DX3cAjHx.mjs +154 -0
- package/dist/rolldown/shared/{error-BlQ0-ek7.mjs → error-DFGNOCle.mjs} +1 -1
- package/dist/rolldown/shared/get-log-filter-AjBknEEO.d.mts +34 -0
- package/dist/rolldown/shared/{load-config-CVVMWSlg.mjs → load-config-R0z2olkB.mjs} +19 -2
- package/dist/rolldown/shared/{logging-BSNejiLS.d.mts → logging-xuHO4mAy.d.mts} +6 -6
- package/dist/rolldown/shared/{logs-aMKUxRpj.mjs → logs-ZGEh6uhb.mjs} +6 -1
- package/dist/rolldown/shared/{normalize-string-or-regex-BYkbbGqQ.mjs → normalize-string-or-regex-SiXbePVH.mjs} +2 -2
- package/dist/rolldown/shared/{parse-Dphnedsw.mjs → parse-D5dkElpf.mjs} +2 -2
- package/dist/rolldown/shared/{prompt-Bgj-uEyc.mjs → prompt-pZFoa1TT.mjs} +59 -17
- package/dist/rolldown/shared/{resolve-tsconfig-CdIAR1Eb.mjs → resolve-tsconfig-2TXRF_zr.mjs} +2 -2
- package/dist/rolldown/shared/{rolldown-Bnp916iM.mjs → rolldown-BnV7isAX.mjs} +1 -1
- package/dist/rolldown/shared/{rolldown-build-Cs2iVJuw.mjs → rolldown-build-BGXNOfvH.mjs} +33 -13
- package/dist/rolldown/shared/transform-Cs2bUDRH.d.mts +148 -0
- package/dist/rolldown/shared/{watch-ECGr-_QS.mjs → watch-DVucf-VG.mjs} +5 -5
- package/dist/rolldown/utils-index.d.mts +29 -30
- package/dist/rolldown/utils-index.mjs +9 -9
- package/dist/tsdown/{build-B_nvJe4A-CvbtVBxy.js → build-oq13wECG-Bymq3jT5.js} +210 -1229
- package/dist/tsdown/debug-BntVTkRq-BGIoAiTa.js +159 -0
- package/dist/tsdown/{detect-B97OSl92-BJPZyIKJ.js → detect-DGhJGEqb-S-tkSzpt.js} +13 -2
- package/dist/tsdown/dist-CxIM8o7n.js +2613 -0
- package/dist/tsdown/dist-DCMiHFrJ.js +1061 -0
- package/dist/tsdown/index-types.d.ts +2106 -1895
- package/dist/tsdown/index.js +7 -4
- package/dist/tsdown/internal-C7ewSPAZ.js +3 -0
- package/dist/tsdown/load-tsc-BKULZsrs-BFmeD6Bu.js +18 -0
- package/dist/tsdown/{main-BlTcyuFi.js → main-BdzlWPt6.js} +214 -9
- package/dist/tsdown/npm_entry_picomatch.cjs +44 -15
- package/dist/tsdown/{resolver-DtsKFXi2-B8Z3WwZh.js → resolver-cwLsPb2o-oj1hqxK6.js} +4 -3
- package/dist/tsdown/run.js +4 -4
- package/dist/tsdown/{src-CISfE_A0.js → src-BV-UJr_R.js} +5 -5
- package/dist/tsdown/target-CNxIDvSz-eoHNdJNs.js +576 -0
- package/dist/tsdown/{tsc-context-CX_GXdyS.js → tsc-context-CA76SkkZ.js} +2 -2
- package/dist/tsdown/{tsc-CdZE7QwS.js → tsc-zcbB6ZVY.js} +58 -117
- package/dist/tsdown/tsdown-css.js +74 -23
- package/dist/tsdown/tsdown-exe.js +129 -876
- package/dist/vite/client/client.mjs +5 -5
- package/dist/vite/node/chunks/build.js +204 -94
- package/dist/vite/node/chunks/dist2.js +1 -1
- package/dist/vite/node/chunks/lib.js +1 -1
- package/dist/vite/node/chunks/moduleRunnerTransport.d.ts +25 -26
- package/dist/vite/node/chunks/node.js +552 -104
- package/dist/vite/node/chunks/postcss-import.js +11 -11
- package/dist/vite/node/cli.js +3 -4
- package/dist/vite/node/index.d.ts +1284 -1285
- package/dist/vite/node/index.js +1 -2
- package/dist/vite/node/module-runner.d.ts +76 -77
- package/dist/vite/node/module-runner.js +6 -7
- package/package.json +20 -18
- package/dist/rolldown/shared/define-config-BBz954-q.d.mts +0 -3901
- package/dist/rolldown/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
- package/dist/rolldown/shared/transform-CEmFsvJW.d.mts +0 -149
- package/dist/tsdown/debug-DLdR-9XB-DQZ6QLC0.js +0 -250
- package/dist/tsdown/dist-CZtGyfn3.js +0 -200
- package/dist/tsdown/dist-CqbVlnVq.js +0 -32057
- package/dist/tsdown/general-Cp4NiJNK-CbyrS9q1.js +0 -97
- package/dist/tsdown/internal-bfoxcI4F.js +0 -3
- package/dist/tsdown/npm_cjs_chunk_range.cjs +0 -474
- package/dist/tsdown/npm_cjs_chunk_semver.cjs +0 -357
- package/dist/tsdown/npm_entry_semver_functions_coerce.cjs +0 -52
- package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +0 -19
- package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +0 -46
- package/dist/tsdown/target-CqeSqtms-FAqYuGyB.js +0 -79
- package/dist/vite/node/chunks/logger.js +0 -361
|
@@ -1,848 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
5
|
-
import process$1 from "node:process";
|
|
1
|
+
import { r as createDebug, t as R } from "./main-BdzlWPt6.js";
|
|
2
|
+
import { O as fsExists, c as isGreaterOrEqual, f as tryParse, k as fsRemove, l as normalize$1, n as NODE_SEA_MIN_VERSION_PARSED, t as NODE_SEA_MIN_VERSION } from "./target-CNxIDvSz-eoHNdJNs.js";
|
|
3
|
+
import "./internal-C7ewSPAZ.js";
|
|
4
|
+
import process from "node:process";
|
|
6
5
|
import path from "node:path";
|
|
7
|
-
import {
|
|
6
|
+
import { pipeline } from "node:stream/promises";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
8
|
+
import { createReadStream, createWriteStream } from "node:fs";
|
|
9
|
+
import { chmod, mkdir, rename } from "node:fs/promises";
|
|
8
10
|
import os from "node:os";
|
|
9
|
-
import {
|
|
10
|
-
//#region ../../node_modules/.pnpm
|
|
11
|
-
var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
12
|
-
var LRUCache = class {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.max = 1e3;
|
|
15
|
-
this.map = /* @__PURE__ */ new Map();
|
|
16
|
-
}
|
|
17
|
-
get(key) {
|
|
18
|
-
const value = this.map.get(key);
|
|
19
|
-
if (value === void 0) return;
|
|
20
|
-
else {
|
|
21
|
-
this.map.delete(key);
|
|
22
|
-
this.map.set(key, value);
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
delete(key) {
|
|
27
|
-
return this.map.delete(key);
|
|
28
|
-
}
|
|
29
|
-
set(key, value) {
|
|
30
|
-
if (!this.delete(key) && value !== void 0) {
|
|
31
|
-
if (this.map.size >= this.max) {
|
|
32
|
-
const firstKey = this.map.keys().next().value;
|
|
33
|
-
this.delete(firstKey);
|
|
34
|
-
}
|
|
35
|
-
this.map.set(key, value);
|
|
36
|
-
}
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
module.exports = LRUCache;
|
|
41
|
-
}));
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/parse-options.js
|
|
44
|
-
var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
45
|
-
const looseOption = Object.freeze({ loose: true });
|
|
46
|
-
const emptyOpts = Object.freeze({});
|
|
47
|
-
const parseOptions = (options) => {
|
|
48
|
-
if (!options) return emptyOpts;
|
|
49
|
-
if (typeof options !== "object") return looseOption;
|
|
50
|
-
return options;
|
|
51
|
-
};
|
|
52
|
-
module.exports = parseOptions;
|
|
53
|
-
}));
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/constants.js
|
|
56
|
-
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
57
|
-
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
58
|
-
const MAX_LENGTH = 256;
|
|
59
|
-
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
60
|
-
module.exports = {
|
|
61
|
-
MAX_LENGTH,
|
|
62
|
-
MAX_SAFE_COMPONENT_LENGTH: 16,
|
|
63
|
-
MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
|
|
64
|
-
MAX_SAFE_INTEGER,
|
|
65
|
-
RELEASE_TYPES: [
|
|
66
|
-
"major",
|
|
67
|
-
"premajor",
|
|
68
|
-
"minor",
|
|
69
|
-
"preminor",
|
|
70
|
-
"patch",
|
|
71
|
-
"prepatch",
|
|
72
|
-
"prerelease"
|
|
73
|
-
],
|
|
74
|
-
SEMVER_SPEC_VERSION,
|
|
75
|
-
FLAG_INCLUDE_PRERELEASE: 1,
|
|
76
|
-
FLAG_LOOSE: 2
|
|
77
|
-
};
|
|
78
|
-
}));
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/debug.js
|
|
81
|
-
var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
82
|
-
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
83
|
-
}));
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/re.js
|
|
86
|
-
var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
87
|
-
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
88
|
-
const debug = require_debug();
|
|
89
|
-
exports = module.exports = {};
|
|
90
|
-
const re = exports.re = [];
|
|
91
|
-
const safeRe = exports.safeRe = [];
|
|
92
|
-
const src = exports.src = [];
|
|
93
|
-
const safeSrc = exports.safeSrc = [];
|
|
94
|
-
const t = exports.t = {};
|
|
95
|
-
let R = 0;
|
|
96
|
-
const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
97
|
-
const safeRegexReplacements = [
|
|
98
|
-
["\\s", 1],
|
|
99
|
-
["\\d", MAX_LENGTH],
|
|
100
|
-
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
101
|
-
];
|
|
102
|
-
const makeSafeRegex = (value) => {
|
|
103
|
-
for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
104
|
-
return value;
|
|
105
|
-
};
|
|
106
|
-
const createToken = (name, value, isGlobal) => {
|
|
107
|
-
const safe = makeSafeRegex(value);
|
|
108
|
-
const index = R++;
|
|
109
|
-
debug(name, index, value);
|
|
110
|
-
t[name] = index;
|
|
111
|
-
src[index] = value;
|
|
112
|
-
safeSrc[index] = safe;
|
|
113
|
-
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
114
|
-
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
115
|
-
};
|
|
116
|
-
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
117
|
-
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
118
|
-
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
119
|
-
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
120
|
-
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
121
|
-
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
122
|
-
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
123
|
-
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
124
|
-
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
125
|
-
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
126
|
-
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
127
|
-
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
128
|
-
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
129
|
-
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
130
|
-
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
131
|
-
createToken("GTLT", "((?:<|>)?=?)");
|
|
132
|
-
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
133
|
-
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
134
|
-
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
135
|
-
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
136
|
-
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
137
|
-
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
138
|
-
createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
139
|
-
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
140
|
-
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
141
|
-
createToken("COERCERTL", src[t.COERCE], true);
|
|
142
|
-
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
143
|
-
createToken("LONETILDE", "(?:~>?)");
|
|
144
|
-
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
145
|
-
exports.tildeTrimReplace = "$1~";
|
|
146
|
-
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
147
|
-
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
148
|
-
createToken("LONECARET", "(?:\\^)");
|
|
149
|
-
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
150
|
-
exports.caretTrimReplace = "$1^";
|
|
151
|
-
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
152
|
-
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
153
|
-
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
154
|
-
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
155
|
-
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
156
|
-
exports.comparatorTrimReplace = "$1$2$3";
|
|
157
|
-
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
158
|
-
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
159
|
-
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
160
|
-
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
161
|
-
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
162
|
-
}));
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/identifiers.js
|
|
165
|
-
var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
166
|
-
const numeric = /^[0-9]+$/;
|
|
167
|
-
const compareIdentifiers = (a, b) => {
|
|
168
|
-
if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
|
|
169
|
-
const anum = numeric.test(a);
|
|
170
|
-
const bnum = numeric.test(b);
|
|
171
|
-
if (anum && bnum) {
|
|
172
|
-
a = +a;
|
|
173
|
-
b = +b;
|
|
174
|
-
}
|
|
175
|
-
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
176
|
-
};
|
|
177
|
-
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
178
|
-
module.exports = {
|
|
179
|
-
compareIdentifiers,
|
|
180
|
-
rcompareIdentifiers
|
|
181
|
-
};
|
|
182
|
-
}));
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/classes/semver.js
|
|
185
|
-
var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
186
|
-
const debug = require_debug();
|
|
187
|
-
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
188
|
-
const { safeRe: re, t } = require_re();
|
|
189
|
-
const parseOptions = require_parse_options();
|
|
190
|
-
const { compareIdentifiers } = require_identifiers();
|
|
191
|
-
const isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
192
|
-
const identifiers = identifier.split(".");
|
|
193
|
-
if (identifiers.length > prerelease.length) return false;
|
|
194
|
-
for (let i = 0; i < identifiers.length; i++) if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) return false;
|
|
195
|
-
return true;
|
|
196
|
-
};
|
|
197
|
-
module.exports = class SemVer {
|
|
198
|
-
constructor(version, options) {
|
|
199
|
-
options = parseOptions(options);
|
|
200
|
-
if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
|
|
201
|
-
else version = version.version;
|
|
202
|
-
else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
203
|
-
if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
204
|
-
debug("SemVer", version, options);
|
|
205
|
-
this.options = options;
|
|
206
|
-
this.loose = !!options.loose;
|
|
207
|
-
this.includePrerelease = !!options.includePrerelease;
|
|
208
|
-
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
209
|
-
if (!m) throw new TypeError(`Invalid Version: ${version}`);
|
|
210
|
-
this.raw = version;
|
|
211
|
-
this.major = +m[1];
|
|
212
|
-
this.minor = +m[2];
|
|
213
|
-
this.patch = +m[3];
|
|
214
|
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
|
|
215
|
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
216
|
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
217
|
-
if (!m[4]) this.prerelease = [];
|
|
218
|
-
else this.prerelease = m[4].split(".").map((id) => {
|
|
219
|
-
if (/^[0-9]+$/.test(id)) {
|
|
220
|
-
const num = +id;
|
|
221
|
-
if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
|
|
222
|
-
}
|
|
223
|
-
return id;
|
|
224
|
-
});
|
|
225
|
-
this.build = m[5] ? m[5].split(".") : [];
|
|
226
|
-
this.format();
|
|
227
|
-
}
|
|
228
|
-
format() {
|
|
229
|
-
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
230
|
-
if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
|
|
231
|
-
return this.version;
|
|
232
|
-
}
|
|
233
|
-
toString() {
|
|
234
|
-
return this.version;
|
|
235
|
-
}
|
|
236
|
-
compare(other) {
|
|
237
|
-
debug("SemVer.compare", this.version, this.options, other);
|
|
238
|
-
if (!(other instanceof SemVer)) {
|
|
239
|
-
if (typeof other === "string" && other === this.version) return 0;
|
|
240
|
-
other = new SemVer(other, this.options);
|
|
241
|
-
}
|
|
242
|
-
if (other.version === this.version) return 0;
|
|
243
|
-
return this.compareMain(other) || this.comparePre(other);
|
|
244
|
-
}
|
|
245
|
-
compareMain(other) {
|
|
246
|
-
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
247
|
-
if (this.major < other.major) return -1;
|
|
248
|
-
if (this.major > other.major) return 1;
|
|
249
|
-
if (this.minor < other.minor) return -1;
|
|
250
|
-
if (this.minor > other.minor) return 1;
|
|
251
|
-
if (this.patch < other.patch) return -1;
|
|
252
|
-
if (this.patch > other.patch) return 1;
|
|
253
|
-
return 0;
|
|
254
|
-
}
|
|
255
|
-
comparePre(other) {
|
|
256
|
-
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
257
|
-
if (this.prerelease.length && !other.prerelease.length) return -1;
|
|
258
|
-
else if (!this.prerelease.length && other.prerelease.length) return 1;
|
|
259
|
-
else if (!this.prerelease.length && !other.prerelease.length) return 0;
|
|
260
|
-
let i = 0;
|
|
261
|
-
do {
|
|
262
|
-
const a = this.prerelease[i];
|
|
263
|
-
const b = other.prerelease[i];
|
|
264
|
-
debug("prerelease compare", i, a, b);
|
|
265
|
-
if (a === void 0 && b === void 0) return 0;
|
|
266
|
-
else if (b === void 0) return 1;
|
|
267
|
-
else if (a === void 0) return -1;
|
|
268
|
-
else if (a === b) continue;
|
|
269
|
-
else return compareIdentifiers(a, b);
|
|
270
|
-
} while (++i);
|
|
271
|
-
}
|
|
272
|
-
compareBuild(other) {
|
|
273
|
-
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
274
|
-
let i = 0;
|
|
275
|
-
do {
|
|
276
|
-
const a = this.build[i];
|
|
277
|
-
const b = other.build[i];
|
|
278
|
-
debug("build compare", i, a, b);
|
|
279
|
-
if (a === void 0 && b === void 0) return 0;
|
|
280
|
-
else if (b === void 0) return 1;
|
|
281
|
-
else if (a === void 0) return -1;
|
|
282
|
-
else if (a === b) continue;
|
|
283
|
-
else return compareIdentifiers(a, b);
|
|
284
|
-
} while (++i);
|
|
285
|
-
}
|
|
286
|
-
inc(release, identifier, identifierBase) {
|
|
287
|
-
if (release.startsWith("pre")) {
|
|
288
|
-
if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
|
|
289
|
-
if (identifier) {
|
|
290
|
-
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
291
|
-
if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
switch (release) {
|
|
295
|
-
case "premajor":
|
|
296
|
-
this.prerelease.length = 0;
|
|
297
|
-
this.patch = 0;
|
|
298
|
-
this.minor = 0;
|
|
299
|
-
this.major++;
|
|
300
|
-
this.inc("pre", identifier, identifierBase);
|
|
301
|
-
break;
|
|
302
|
-
case "preminor":
|
|
303
|
-
this.prerelease.length = 0;
|
|
304
|
-
this.patch = 0;
|
|
305
|
-
this.minor++;
|
|
306
|
-
this.inc("pre", identifier, identifierBase);
|
|
307
|
-
break;
|
|
308
|
-
case "prepatch":
|
|
309
|
-
this.prerelease.length = 0;
|
|
310
|
-
this.inc("patch", identifier, identifierBase);
|
|
311
|
-
this.inc("pre", identifier, identifierBase);
|
|
312
|
-
break;
|
|
313
|
-
case "prerelease":
|
|
314
|
-
if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
|
|
315
|
-
this.inc("pre", identifier, identifierBase);
|
|
316
|
-
break;
|
|
317
|
-
case "release":
|
|
318
|
-
if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
|
|
319
|
-
this.prerelease.length = 0;
|
|
320
|
-
break;
|
|
321
|
-
case "major":
|
|
322
|
-
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
|
|
323
|
-
this.minor = 0;
|
|
324
|
-
this.patch = 0;
|
|
325
|
-
this.prerelease = [];
|
|
326
|
-
break;
|
|
327
|
-
case "minor":
|
|
328
|
-
if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
|
|
329
|
-
this.patch = 0;
|
|
330
|
-
this.prerelease = [];
|
|
331
|
-
break;
|
|
332
|
-
case "patch":
|
|
333
|
-
if (this.prerelease.length === 0) this.patch++;
|
|
334
|
-
this.prerelease = [];
|
|
335
|
-
break;
|
|
336
|
-
case "pre": {
|
|
337
|
-
const base = Number(identifierBase) ? 1 : 0;
|
|
338
|
-
if (this.prerelease.length === 0) this.prerelease = [base];
|
|
339
|
-
else {
|
|
340
|
-
let i = this.prerelease.length;
|
|
341
|
-
while (--i >= 0) if (typeof this.prerelease[i] === "number") {
|
|
342
|
-
this.prerelease[i]++;
|
|
343
|
-
i = -2;
|
|
344
|
-
}
|
|
345
|
-
if (i === -1) {
|
|
346
|
-
if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
|
|
347
|
-
this.prerelease.push(base);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
if (identifier) {
|
|
351
|
-
let prerelease = [identifier, base];
|
|
352
|
-
if (identifierBase === false) prerelease = [identifier];
|
|
353
|
-
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
|
|
354
|
-
const prereleaseBase = this.prerelease[identifier.split(".").length];
|
|
355
|
-
if (isNaN(prereleaseBase)) this.prerelease = prerelease;
|
|
356
|
-
} else this.prerelease = prerelease;
|
|
357
|
-
}
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
default: throw new Error(`invalid increment argument: ${release}`);
|
|
361
|
-
}
|
|
362
|
-
this.raw = this.format();
|
|
363
|
-
if (this.build.length) this.raw += `+${this.build.join(".")}`;
|
|
364
|
-
return this;
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
}));
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/compare.js
|
|
370
|
-
var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
371
|
-
const SemVer = require_semver();
|
|
372
|
-
const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
373
|
-
module.exports = compare;
|
|
374
|
-
}));
|
|
375
|
-
//#endregion
|
|
376
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/eq.js
|
|
377
|
-
var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
378
|
-
const compare = require_compare();
|
|
379
|
-
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
380
|
-
module.exports = eq;
|
|
381
|
-
}));
|
|
382
|
-
//#endregion
|
|
383
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/neq.js
|
|
384
|
-
var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
385
|
-
const compare = require_compare();
|
|
386
|
-
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
387
|
-
module.exports = neq;
|
|
388
|
-
}));
|
|
389
|
-
//#endregion
|
|
390
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/gt.js
|
|
391
|
-
var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
392
|
-
const compare = require_compare();
|
|
393
|
-
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
394
|
-
module.exports = gt;
|
|
395
|
-
}));
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/gte.js
|
|
398
|
-
var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
399
|
-
const compare = require_compare();
|
|
400
|
-
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
401
|
-
module.exports = gte;
|
|
402
|
-
}));
|
|
403
|
-
//#endregion
|
|
404
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/lt.js
|
|
405
|
-
var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
406
|
-
const compare = require_compare();
|
|
407
|
-
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
408
|
-
module.exports = lt;
|
|
409
|
-
}));
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/lte.js
|
|
412
|
-
var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
413
|
-
const compare = require_compare();
|
|
414
|
-
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
415
|
-
module.exports = lte;
|
|
416
|
-
}));
|
|
417
|
-
//#endregion
|
|
418
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/cmp.js
|
|
419
|
-
var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
420
|
-
const eq = require_eq();
|
|
421
|
-
const neq = require_neq();
|
|
422
|
-
const gt = require_gt();
|
|
423
|
-
const gte = require_gte();
|
|
424
|
-
const lt = require_lt();
|
|
425
|
-
const lte = require_lte();
|
|
426
|
-
const cmp = (a, op, b, loose) => {
|
|
427
|
-
switch (op) {
|
|
428
|
-
case "===":
|
|
429
|
-
if (typeof a === "object") a = a.version;
|
|
430
|
-
if (typeof b === "object") b = b.version;
|
|
431
|
-
return a === b;
|
|
432
|
-
case "!==":
|
|
433
|
-
if (typeof a === "object") a = a.version;
|
|
434
|
-
if (typeof b === "object") b = b.version;
|
|
435
|
-
return a !== b;
|
|
436
|
-
case "":
|
|
437
|
-
case "=":
|
|
438
|
-
case "==": return eq(a, b, loose);
|
|
439
|
-
case "!=": return neq(a, b, loose);
|
|
440
|
-
case ">": return gt(a, b, loose);
|
|
441
|
-
case ">=": return gte(a, b, loose);
|
|
442
|
-
case "<": return lt(a, b, loose);
|
|
443
|
-
case "<=": return lte(a, b, loose);
|
|
444
|
-
default: throw new TypeError(`Invalid operator: ${op}`);
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
module.exports = cmp;
|
|
448
|
-
}));
|
|
449
|
-
//#endregion
|
|
450
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/classes/comparator.js
|
|
451
|
-
var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
452
|
-
const ANY = Symbol("SemVer ANY");
|
|
453
|
-
module.exports = class Comparator {
|
|
454
|
-
static get ANY() {
|
|
455
|
-
return ANY;
|
|
456
|
-
}
|
|
457
|
-
constructor(comp, options) {
|
|
458
|
-
options = parseOptions(options);
|
|
459
|
-
if (comp instanceof Comparator) if (comp.loose === !!options.loose) return comp;
|
|
460
|
-
else comp = comp.value;
|
|
461
|
-
comp = comp.trim().split(/\s+/).join(" ");
|
|
462
|
-
debug("comparator", comp, options);
|
|
463
|
-
this.options = options;
|
|
464
|
-
this.loose = !!options.loose;
|
|
465
|
-
this.parse(comp);
|
|
466
|
-
if (this.semver === ANY) this.value = "";
|
|
467
|
-
else this.value = this.operator + this.semver.version;
|
|
468
|
-
debug("comp", this);
|
|
469
|
-
}
|
|
470
|
-
parse(comp) {
|
|
471
|
-
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
472
|
-
const m = comp.match(r);
|
|
473
|
-
if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
|
|
474
|
-
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
475
|
-
if (this.operator === "=") this.operator = "";
|
|
476
|
-
if (!m[2]) this.semver = ANY;
|
|
477
|
-
else this.semver = new SemVer(m[2], this.options.loose);
|
|
478
|
-
}
|
|
479
|
-
toString() {
|
|
480
|
-
return this.value;
|
|
481
|
-
}
|
|
482
|
-
test(version) {
|
|
483
|
-
debug("Comparator.test", version, this.options.loose);
|
|
484
|
-
if (this.semver === ANY || version === ANY) return true;
|
|
485
|
-
if (typeof version === "string") try {
|
|
486
|
-
version = new SemVer(version, this.options);
|
|
487
|
-
} catch (er) {
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
return cmp(version, this.operator, this.semver, this.options);
|
|
491
|
-
}
|
|
492
|
-
intersects(comp, options) {
|
|
493
|
-
if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
|
|
494
|
-
if (this.operator === "") {
|
|
495
|
-
if (this.value === "") return true;
|
|
496
|
-
return new Range(comp.value, options).test(this.value);
|
|
497
|
-
} else if (comp.operator === "") {
|
|
498
|
-
if (comp.value === "") return true;
|
|
499
|
-
return new Range(this.value, options).test(comp.semver);
|
|
500
|
-
}
|
|
501
|
-
options = parseOptions(options);
|
|
502
|
-
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
|
|
503
|
-
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
|
|
504
|
-
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
|
|
505
|
-
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
|
|
506
|
-
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
|
|
507
|
-
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
|
|
508
|
-
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
|
|
509
|
-
return false;
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
const parseOptions = require_parse_options();
|
|
513
|
-
const { safeRe: re, t } = require_re();
|
|
514
|
-
const cmp = require_cmp();
|
|
515
|
-
const debug = require_debug();
|
|
516
|
-
const SemVer = require_semver();
|
|
517
|
-
const Range = require_range();
|
|
518
|
-
}));
|
|
519
|
-
//#endregion
|
|
520
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/classes/range.js
|
|
521
|
-
var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
522
|
-
const SPACE_CHARACTERS = /\s+/g;
|
|
523
|
-
module.exports = class Range {
|
|
524
|
-
constructor(range, options) {
|
|
525
|
-
options = parseOptions(options);
|
|
526
|
-
if (range instanceof Range) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
|
|
527
|
-
else return new Range(range.raw, options);
|
|
528
|
-
if (range instanceof Comparator) {
|
|
529
|
-
this.raw = range.value;
|
|
530
|
-
this.set = [[range]];
|
|
531
|
-
this.formatted = void 0;
|
|
532
|
-
return this;
|
|
533
|
-
}
|
|
534
|
-
this.options = options;
|
|
535
|
-
this.loose = !!options.loose;
|
|
536
|
-
this.includePrerelease = !!options.includePrerelease;
|
|
537
|
-
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
538
|
-
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
539
|
-
if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
540
|
-
if (this.set.length > 1) {
|
|
541
|
-
const first = this.set[0];
|
|
542
|
-
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
543
|
-
if (this.set.length === 0) this.set = [first];
|
|
544
|
-
else if (this.set.length > 1) {
|
|
545
|
-
for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
|
|
546
|
-
this.set = [c];
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
this.formatted = void 0;
|
|
552
|
-
}
|
|
553
|
-
get range() {
|
|
554
|
-
if (this.formatted === void 0) {
|
|
555
|
-
this.formatted = "";
|
|
556
|
-
for (let i = 0; i < this.set.length; i++) {
|
|
557
|
-
if (i > 0) this.formatted += "||";
|
|
558
|
-
const comps = this.set[i];
|
|
559
|
-
for (let k = 0; k < comps.length; k++) {
|
|
560
|
-
if (k > 0) this.formatted += " ";
|
|
561
|
-
this.formatted += comps[k].toString().trim();
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
return this.formatted;
|
|
566
|
-
}
|
|
567
|
-
format() {
|
|
568
|
-
return this.range;
|
|
569
|
-
}
|
|
570
|
-
toString() {
|
|
571
|
-
return this.range;
|
|
572
|
-
}
|
|
573
|
-
parseRange(range) {
|
|
574
|
-
range = range.replace(BUILDSTRIPRE, "");
|
|
575
|
-
const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
|
|
576
|
-
const cached = cache.get(memoKey);
|
|
577
|
-
if (cached) return cached;
|
|
578
|
-
const loose = this.options.loose;
|
|
579
|
-
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
580
|
-
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
581
|
-
debug("hyphen replace", range);
|
|
582
|
-
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
583
|
-
debug("comparator trim", range);
|
|
584
|
-
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
585
|
-
debug("tilde trim", range);
|
|
586
|
-
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
587
|
-
debug("caret trim", range);
|
|
588
|
-
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
589
|
-
if (loose) rangeList = rangeList.filter((comp) => {
|
|
590
|
-
debug("loose invalid filter", comp, this.options);
|
|
591
|
-
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
592
|
-
});
|
|
593
|
-
debug("range list", rangeList);
|
|
594
|
-
const rangeMap = /* @__PURE__ */ new Map();
|
|
595
|
-
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
596
|
-
for (const comp of comparators) {
|
|
597
|
-
if (isNullSet(comp)) return [comp];
|
|
598
|
-
rangeMap.set(comp.value, comp);
|
|
599
|
-
}
|
|
600
|
-
if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
|
|
601
|
-
const result = [...rangeMap.values()];
|
|
602
|
-
cache.set(memoKey, result);
|
|
603
|
-
return result;
|
|
604
|
-
}
|
|
605
|
-
intersects(range, options) {
|
|
606
|
-
if (!(range instanceof Range)) throw new TypeError("a Range is required");
|
|
607
|
-
return this.set.some((thisComparators) => {
|
|
608
|
-
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
609
|
-
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
610
|
-
return rangeComparators.every((rangeComparator) => {
|
|
611
|
-
return thisComparator.intersects(rangeComparator, options);
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
test(version) {
|
|
618
|
-
if (!version) return false;
|
|
619
|
-
if (typeof version === "string") try {
|
|
620
|
-
version = new SemVer(version, this.options);
|
|
621
|
-
} catch (er) {
|
|
622
|
-
return false;
|
|
623
|
-
}
|
|
624
|
-
for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
|
|
625
|
-
return false;
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
const cache = new (require_lrucache())();
|
|
629
|
-
const parseOptions = require_parse_options();
|
|
630
|
-
const Comparator = require_comparator();
|
|
631
|
-
const debug = require_debug();
|
|
632
|
-
const SemVer = require_semver();
|
|
633
|
-
const { safeRe: re, src, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
|
|
634
|
-
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
635
|
-
const BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
|
636
|
-
const isNullSet = (c) => c.value === "<0.0.0-0";
|
|
637
|
-
const isAny = (c) => c.value === "";
|
|
638
|
-
const isSatisfiable = (comparators, options) => {
|
|
639
|
-
let result = true;
|
|
640
|
-
const remainingComparators = comparators.slice();
|
|
641
|
-
let testComparator = remainingComparators.pop();
|
|
642
|
-
while (result && remainingComparators.length) {
|
|
643
|
-
result = remainingComparators.every((otherComparator) => {
|
|
644
|
-
return testComparator.intersects(otherComparator, options);
|
|
645
|
-
});
|
|
646
|
-
testComparator = remainingComparators.pop();
|
|
647
|
-
}
|
|
648
|
-
return result;
|
|
649
|
-
};
|
|
650
|
-
const parseComparator = (comp, options) => {
|
|
651
|
-
comp = comp.replace(re[t.BUILD], "");
|
|
652
|
-
debug("comp", comp, options);
|
|
653
|
-
comp = replaceCarets(comp, options);
|
|
654
|
-
debug("caret", comp);
|
|
655
|
-
comp = replaceTildes(comp, options);
|
|
656
|
-
debug("tildes", comp);
|
|
657
|
-
comp = replaceXRanges(comp, options);
|
|
658
|
-
debug("xrange", comp);
|
|
659
|
-
comp = replaceStars(comp, options);
|
|
660
|
-
debug("stars", comp);
|
|
661
|
-
return comp;
|
|
662
|
-
};
|
|
663
|
-
const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
664
|
-
const invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
665
|
-
const replaceTildes = (comp, options) => {
|
|
666
|
-
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
667
|
-
};
|
|
668
|
-
const replaceTilde = (comp, options) => {
|
|
669
|
-
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
670
|
-
return comp.replace(r, (_, M, m, p, pr) => {
|
|
671
|
-
debug("tilde", comp, _, M, m, p, pr);
|
|
672
|
-
let ret;
|
|
673
|
-
if (isX(M)) ret = "";
|
|
674
|
-
else if (isX(m)) ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
675
|
-
else if (isX(p)) ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
676
|
-
else if (pr) {
|
|
677
|
-
debug("replaceTilde pr", pr);
|
|
678
|
-
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
679
|
-
} else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
680
|
-
debug("tilde return", ret);
|
|
681
|
-
return ret;
|
|
682
|
-
});
|
|
683
|
-
};
|
|
684
|
-
const replaceCarets = (comp, options) => {
|
|
685
|
-
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
686
|
-
};
|
|
687
|
-
const replaceCaret = (comp, options) => {
|
|
688
|
-
debug("caret", comp, options);
|
|
689
|
-
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
690
|
-
const z = options.includePrerelease ? "-0" : "";
|
|
691
|
-
return comp.replace(r, (_, M, m, p, pr) => {
|
|
692
|
-
debug("caret", comp, _, M, m, p, pr);
|
|
693
|
-
let ret;
|
|
694
|
-
if (isX(M)) ret = "";
|
|
695
|
-
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
696
|
-
else if (isX(p)) if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
697
|
-
else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
698
|
-
else if (pr) {
|
|
699
|
-
debug("replaceCaret pr", pr);
|
|
700
|
-
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
701
|
-
else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
702
|
-
else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
703
|
-
} else {
|
|
704
|
-
debug("no pr");
|
|
705
|
-
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
706
|
-
else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
707
|
-
else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
708
|
-
}
|
|
709
|
-
debug("caret return", ret);
|
|
710
|
-
return ret;
|
|
711
|
-
});
|
|
712
|
-
};
|
|
713
|
-
const replaceXRanges = (comp, options) => {
|
|
714
|
-
debug("replaceXRanges", comp, options);
|
|
715
|
-
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
716
|
-
};
|
|
717
|
-
const replaceXRange = (comp, options) => {
|
|
718
|
-
comp = comp.trim();
|
|
719
|
-
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
720
|
-
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
721
|
-
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
722
|
-
if (invalidXRangeOrder(M, m, p)) return comp;
|
|
723
|
-
const xM = isX(M);
|
|
724
|
-
const xm = xM || isX(m);
|
|
725
|
-
const xp = xm || isX(p);
|
|
726
|
-
const anyX = xp;
|
|
727
|
-
if (gtlt === "=" && anyX) gtlt = "";
|
|
728
|
-
pr = options.includePrerelease ? "-0" : "";
|
|
729
|
-
if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
|
|
730
|
-
else ret = "*";
|
|
731
|
-
else if (gtlt && anyX) {
|
|
732
|
-
if (xm) m = 0;
|
|
733
|
-
p = 0;
|
|
734
|
-
if (gtlt === ">") {
|
|
735
|
-
gtlt = ">=";
|
|
736
|
-
if (xm) {
|
|
737
|
-
M = +M + 1;
|
|
738
|
-
m = 0;
|
|
739
|
-
p = 0;
|
|
740
|
-
} else {
|
|
741
|
-
m = +m + 1;
|
|
742
|
-
p = 0;
|
|
743
|
-
}
|
|
744
|
-
} else if (gtlt === "<=") {
|
|
745
|
-
gtlt = "<";
|
|
746
|
-
if (xm) M = +M + 1;
|
|
747
|
-
else m = +m + 1;
|
|
748
|
-
}
|
|
749
|
-
if (gtlt === "<") pr = "-0";
|
|
750
|
-
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
751
|
-
} else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
752
|
-
else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
753
|
-
debug("xRange return", ret);
|
|
754
|
-
return ret;
|
|
755
|
-
});
|
|
756
|
-
};
|
|
757
|
-
const replaceStars = (comp, options) => {
|
|
758
|
-
debug("replaceStars", comp, options);
|
|
759
|
-
return comp.trim().replace(re[t.STAR], "");
|
|
760
|
-
};
|
|
761
|
-
const replaceGTE0 = (comp, options) => {
|
|
762
|
-
debug("replaceGTE0", comp, options);
|
|
763
|
-
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
764
|
-
};
|
|
765
|
-
const hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
766
|
-
if (isX(fM)) from = "";
|
|
767
|
-
else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
768
|
-
else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
769
|
-
else if (fpr) from = `>=${from}`;
|
|
770
|
-
else from = `>=${from}${incPr ? "-0" : ""}`;
|
|
771
|
-
if (isX(tM)) to = "";
|
|
772
|
-
else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
|
|
773
|
-
else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
|
|
774
|
-
else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
775
|
-
else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
776
|
-
else to = `<=${to}`;
|
|
777
|
-
return `${from} ${to}`.trim();
|
|
778
|
-
};
|
|
779
|
-
const testSet = (set, version, options) => {
|
|
780
|
-
for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
|
|
781
|
-
if (version.prerelease.length && !options.includePrerelease) {
|
|
782
|
-
for (let i = 0; i < set.length; i++) {
|
|
783
|
-
debug(set[i].semver);
|
|
784
|
-
if (set[i].semver === Comparator.ANY) continue;
|
|
785
|
-
if (set[i].semver.prerelease.length > 0) {
|
|
786
|
-
const allowed = set[i].semver;
|
|
787
|
-
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
return false;
|
|
791
|
-
}
|
|
792
|
-
return true;
|
|
793
|
-
};
|
|
794
|
-
}));
|
|
795
|
-
//#endregion
|
|
796
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/satisfies.js
|
|
797
|
-
var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
798
|
-
const Range = require_range();
|
|
799
|
-
const satisfies = (version, range, options) => {
|
|
800
|
-
try {
|
|
801
|
-
range = new Range(range, options);
|
|
802
|
-
} catch (er) {
|
|
803
|
-
return false;
|
|
804
|
-
}
|
|
805
|
-
return range.test(version);
|
|
806
|
-
};
|
|
807
|
-
module.exports = satisfies;
|
|
808
|
-
}));
|
|
809
|
-
//#endregion
|
|
810
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/parse.js
|
|
811
|
-
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
812
|
-
const SemVer = require_semver();
|
|
813
|
-
const parse = (version, options, throwErrors = false) => {
|
|
814
|
-
if (version instanceof SemVer) return version;
|
|
815
|
-
try {
|
|
816
|
-
return new SemVer(version, options);
|
|
817
|
-
} catch (er) {
|
|
818
|
-
if (!throwErrors) return null;
|
|
819
|
-
throw er;
|
|
820
|
-
}
|
|
821
|
-
};
|
|
822
|
-
module.exports = parse;
|
|
823
|
-
}));
|
|
824
|
-
//#endregion
|
|
825
|
-
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/valid.js
|
|
826
|
-
var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
827
|
-
const parse = require_parse();
|
|
828
|
-
const valid = (version, options) => {
|
|
829
|
-
const v = parse(version, options);
|
|
830
|
-
return v ? v.version : null;
|
|
831
|
-
};
|
|
832
|
-
module.exports = valid;
|
|
833
|
-
}));
|
|
834
|
-
//#endregion
|
|
835
|
-
//#region ../../node_modules/.pnpm/@tsdown+exe@0.22.3_tsdown@0.22.3/node_modules/@tsdown/exe/dist/index.mjs
|
|
836
|
-
var import_satisfies = /* @__PURE__ */ __toESM(require_satisfies(), 1);
|
|
837
|
-
var import_valid = /* @__PURE__ */ __toESM(require_valid(), 1);
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
//#region ../../node_modules/.pnpm/@tsdown+exe@0.22.13_tsdown@0.22.13/node_modules/@tsdown/exe/dist/index.mjs
|
|
838
13
|
function getCacheDir() {
|
|
839
14
|
const home = os.homedir();
|
|
840
|
-
if (process
|
|
841
|
-
const localAppData = process
|
|
15
|
+
if (process.platform === "win32") {
|
|
16
|
+
const localAppData = process.env.LOCALAPPDATA || path.join(home, "AppData/Local");
|
|
842
17
|
return path.join(localAppData, "tsdown/Caches");
|
|
843
18
|
}
|
|
844
|
-
if (process
|
|
845
|
-
const xdgCache = process
|
|
19
|
+
if (process.platform === "darwin") return path.join(home, "Library/Caches/tsdown");
|
|
20
|
+
const xdgCache = process.env.XDG_CACHE_HOME || path.join(home, ".cache");
|
|
846
21
|
return path.join(xdgCache, "tsdown");
|
|
847
22
|
}
|
|
848
23
|
function getCachedBinaryPath(target) {
|
|
@@ -865,28 +40,28 @@ function getBinaryPathInArchive(target) {
|
|
|
865
40
|
if (platform === "win") return `${dirName}/node.exe`;
|
|
866
41
|
return `${dirName}/bin/node`;
|
|
867
42
|
}
|
|
868
|
-
|
|
869
|
-
async function resolveNodeVersion(nodeVersion) {
|
|
43
|
+
async function resolveNodeVersion(nodeVersion, nodeDistIndexUrl = "https://nodejs.org/dist/index.json") {
|
|
870
44
|
if (nodeVersion === "latest" || nodeVersion === "latest-lts") {
|
|
871
|
-
const response = await fetch(
|
|
872
|
-
if (!response.ok) throw new Error(`Failed to fetch Node.js releases: HTTP ${response.status} from ${
|
|
45
|
+
const response = await fetch(nodeDistIndexUrl);
|
|
46
|
+
if (!response.ok) throw new Error(`Failed to fetch Node.js releases: HTTP ${response.status} from ${nodeDistIndexUrl}`);
|
|
873
47
|
const releases = await response.json();
|
|
874
48
|
const release = nodeVersion === "latest" ? releases[0] : releases.find((r) => r.lts !== false);
|
|
875
49
|
if (!release) throw new Error(`No matching Node.js release found for "${nodeVersion}".`);
|
|
876
50
|
nodeVersion = release.version.replace(/^v/, "");
|
|
877
51
|
}
|
|
878
|
-
const version = (
|
|
52
|
+
const version = tryParse(nodeVersion);
|
|
879
53
|
if (!version) throw new Error(`Invalid Node.js version: ${nodeVersion}. Please provide a valid version string (e.g., "25.7.0").`);
|
|
880
|
-
if (!(
|
|
881
|
-
return version;
|
|
54
|
+
if (!isGreaterOrEqual(version, NODE_SEA_MIN_VERSION_PARSED)) throw new Error(`Node.js ${version} does not support SEA (Single Executable Applications). Required minimum version is ${NODE_SEA_MIN_VERSION}. Please update the nodeVersion in your target configuration.`);
|
|
55
|
+
return normalize$1(version);
|
|
882
56
|
}
|
|
883
57
|
function getTargetSuffix(target) {
|
|
884
58
|
return `-${target.platform}-${target.arch}`;
|
|
885
59
|
}
|
|
886
60
|
const debug = createDebug("tsdown:exe:download");
|
|
887
|
-
|
|
61
|
+
const shasumsManifestCache = /* @__PURE__ */ new Map();
|
|
62
|
+
async function resolveNodeBinary(target, options, logger) {
|
|
888
63
|
debug("Resolving Node.js binary for target: %O", target);
|
|
889
|
-
target.nodeVersion = await resolveNodeVersion(target.nodeVersion);
|
|
64
|
+
target.nodeVersion = await resolveNodeVersion(target.nodeVersion, options.nodeDistIndexUrl);
|
|
890
65
|
const cachedPath = getCachedBinaryPath(target);
|
|
891
66
|
debug("Cache path: %s", cachedPath);
|
|
892
67
|
if (await fsExists(cachedPath)) {
|
|
@@ -894,17 +69,13 @@ async function resolveNodeBinary(target, logger) {
|
|
|
894
69
|
logger?.info(`Using cached Node.js ${target.nodeVersion} for ${target.platform}-${target.arch}`);
|
|
895
70
|
return cachedPath;
|
|
896
71
|
}
|
|
897
|
-
const url = getDownloadUrl(target);
|
|
72
|
+
const url = await (options.getDownloadUrl ?? getDownloadUrl)(target);
|
|
898
73
|
debug("Cache miss, downloading from: %s", url);
|
|
899
74
|
logger?.info(`Downloading Node.js ${target.nodeVersion} for ${target.platform}-${target.arch}...`);
|
|
900
75
|
logger?.info(` ${url}`);
|
|
901
76
|
await mkdir(path.dirname(cachedPath), { recursive: true });
|
|
902
|
-
const response = await fetch(url);
|
|
903
|
-
if (!response.ok) throw new Error(`Failed to download Node.js binary: HTTP ${response.status} from ${url}`);
|
|
904
77
|
const archivePath = `${cachedPath}.download.${getArchiveExtension(target.platform)}`;
|
|
905
|
-
|
|
906
|
-
debug("Downloaded %d bytes, writing to: %s", buffer.length, archivePath);
|
|
907
|
-
await writeFile(archivePath, buffer);
|
|
78
|
+
await downloadArchive(url, archivePath, target.nodeVersion);
|
|
908
79
|
try {
|
|
909
80
|
await extractBinary(archivePath, cachedPath, target);
|
|
910
81
|
if (target.platform !== "win") await chmod(cachedPath, 493);
|
|
@@ -915,35 +86,117 @@ async function resolveNodeBinary(target, logger) {
|
|
|
915
86
|
}
|
|
916
87
|
return cachedPath;
|
|
917
88
|
}
|
|
89
|
+
async function downloadArchive(url, archivePath, nodeVersion) {
|
|
90
|
+
const expectedChecksum = await getExpectedArchiveChecksum(nodeVersion, path.posix.basename(new URL(url).pathname));
|
|
91
|
+
const response = await fetch(url);
|
|
92
|
+
if (!response.ok) throw new Error(`Failed to download Node.js binary: HTTP ${response.status} from ${url}`);
|
|
93
|
+
if (!response.body) throw new Error(`Failed to download Node.js binary: empty response from ${url}`);
|
|
94
|
+
const tempArchivePath = `${archivePath}.tmp-${process.pid}-${Date.now()}`;
|
|
95
|
+
try {
|
|
96
|
+
await pipeline(Readable.fromWeb(response.body), createWriteStream(tempArchivePath));
|
|
97
|
+
await verifyArchiveChecksum(tempArchivePath, expectedChecksum);
|
|
98
|
+
await rename(tempArchivePath, archivePath);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
await fsRemove(tempArchivePath);
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function getExpectedArchiveChecksum(nodeVersion, archiveName) {
|
|
105
|
+
const checksum = (await getShasumsManifest(nodeVersion)).get(archiveName);
|
|
106
|
+
if (!checksum) throw new Error(`Failed to find checksum for Node.js archive "${archiveName}" in SHASUMS256.txt.`);
|
|
107
|
+
return checksum;
|
|
108
|
+
}
|
|
109
|
+
async function getShasumsManifest(nodeVersion) {
|
|
110
|
+
const cachedManifest = shasumsManifestCache.get(nodeVersion);
|
|
111
|
+
if (cachedManifest) return cachedManifest;
|
|
112
|
+
const manifest = (async () => {
|
|
113
|
+
const url = `https://nodejs.org/dist/v${nodeVersion}/SHASUMS256.txt`;
|
|
114
|
+
const response = await fetch(url);
|
|
115
|
+
if (!response.ok) throw new Error(`Failed to download Node.js checksums: HTTP ${response.status} from ${url}`);
|
|
116
|
+
const checksums = /* @__PURE__ */ new Map();
|
|
117
|
+
const text = await response.text();
|
|
118
|
+
for (const line of text.split(/\r?\n/)) {
|
|
119
|
+
const trimmedLine = line.trim();
|
|
120
|
+
if (!trimmedLine) continue;
|
|
121
|
+
const separatorIndex = trimmedLine.search(/\s/);
|
|
122
|
+
if (separatorIndex === -1) continue;
|
|
123
|
+
const checksum = trimmedLine.slice(0, separatorIndex);
|
|
124
|
+
if (!/^[a-f0-9]{64}$/i.test(checksum)) continue;
|
|
125
|
+
const archiveName = trimmedLine.slice(separatorIndex).trimStart().replace(/^\*/, "");
|
|
126
|
+
if (!archiveName) continue;
|
|
127
|
+
checksums.set(archiveName, checksum.toLowerCase());
|
|
128
|
+
}
|
|
129
|
+
return checksums;
|
|
130
|
+
})();
|
|
131
|
+
shasumsManifestCache.set(nodeVersion, manifest);
|
|
132
|
+
try {
|
|
133
|
+
return await manifest;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
shasumsManifestCache.delete(nodeVersion);
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function verifyArchiveChecksum(archivePath, expectedChecksum) {
|
|
140
|
+
const hash = createHash("sha256");
|
|
141
|
+
const stream = createReadStream(archivePath);
|
|
142
|
+
for await (const chunk of stream) hash.update(chunk);
|
|
143
|
+
const actualChecksum = hash.digest("hex");
|
|
144
|
+
if (actualChecksum !== expectedChecksum) throw new Error(`Checksum mismatch for Node.js archive "${archivePath}": expected ${expectedChecksum}, received ${actualChecksum}.`);
|
|
145
|
+
}
|
|
918
146
|
async function extractBinary(archivePath, targetBinaryPath, target) {
|
|
919
147
|
const binaryInArchive = getBinaryPathInArchive(target);
|
|
920
148
|
const outDir = path.dirname(targetBinaryPath);
|
|
921
149
|
debug("Extracting %s from archive to %s", binaryInArchive, outDir);
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
});
|
|
933
|
-
else await R("tar", [
|
|
934
|
-
`-x${archivePath.endsWith(".tar.xz") ? "J" : "z"}f`,
|
|
935
|
-
archivePath,
|
|
936
|
-
"-C",
|
|
937
|
-
outDir,
|
|
938
|
-
"--strip-components=2",
|
|
939
|
-
binaryInArchive
|
|
940
|
-
], {
|
|
941
|
-
nodeOptions: { stdio: "inherit" },
|
|
942
|
-
throwOnError: true
|
|
943
|
-
});
|
|
150
|
+
const { command, args } = getExtractCommand(archivePath, outDir, binaryInArchive, target);
|
|
151
|
+
try {
|
|
152
|
+
await R(command, args, {
|
|
153
|
+
nodeOptions: { stdio: "inherit" },
|
|
154
|
+
throwOnError: true,
|
|
155
|
+
nodePath: false
|
|
156
|
+
});
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw new Error(`Failed to extract Node.js archive with \`${command}\`. Please ensure \`${command}\` is installed and available in PATH.`, { cause: error });
|
|
159
|
+
}
|
|
944
160
|
const extractedName = target.platform === "win" ? "node.exe" : "node";
|
|
945
161
|
const extractedPath = path.join(outDir, extractedName);
|
|
946
162
|
if (extractedPath !== targetBinaryPath) await rename(extractedPath, targetBinaryPath);
|
|
947
163
|
}
|
|
164
|
+
function getExtractCommand(archivePath, outDir, binaryInArchive, target, hostPlatform = process.platform) {
|
|
165
|
+
if (target.platform === "win") {
|
|
166
|
+
if (hostPlatform === "win32") return {
|
|
167
|
+
command: "tar",
|
|
168
|
+
args: [
|
|
169
|
+
"-xf",
|
|
170
|
+
archivePath,
|
|
171
|
+
"-C",
|
|
172
|
+
outDir,
|
|
173
|
+
"--strip-components=1",
|
|
174
|
+
binaryInArchive
|
|
175
|
+
]
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
command: "unzip",
|
|
179
|
+
args: [
|
|
180
|
+
"-j",
|
|
181
|
+
"-o",
|
|
182
|
+
archivePath,
|
|
183
|
+
binaryInArchive,
|
|
184
|
+
"-d",
|
|
185
|
+
outDir
|
|
186
|
+
]
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
command: "tar",
|
|
191
|
+
args: [
|
|
192
|
+
`-x${archivePath.endsWith(".tar.xz") ? "J" : "z"}f`,
|
|
193
|
+
archivePath,
|
|
194
|
+
"-C",
|
|
195
|
+
outDir,
|
|
196
|
+
"--strip-components=2",
|
|
197
|
+
binaryInArchive
|
|
198
|
+
]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
948
201
|
//#endregion
|
|
949
202
|
export { getCacheDir, getCachedBinaryPath, getTargetSuffix, resolveNodeBinary };
|