@vltpkg/cli-js 1.0.2 → 1.0.3
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/{access-DB347PPG.js → access-5WETTBDZ.js} +9 -7
- package/{bugs-QBKI62J6.js → bugs-KONFLIQQ.js} +19 -18
- package/{build-EFJ3FFGU.js → build-S7G2DU7I.js} +12 -10
- package/{cache-BQJCMDJN.js → cache-Z4OIMLXQ.js} +23 -21
- package/{chunk-RXNA2XCX.js → chunk-4KCU2KZL.js} +8 -1
- package/{chunk-3MBSXZ62.js → chunk-5B23EKN4.js} +4 -4
- package/{chunk-5OGQND6H.js → chunk-5QJEOGEM.js} +3 -1
- package/{chunk-DEMBZY23.js → chunk-5UPPEUG2.js} +11 -11
- package/chunk-BJBFEQRR.js +667 -0
- package/{chunk-L34LR5DV.js → chunk-DYCF76WI.js} +4 -4
- package/{chunk-ULCDRVY2.js → chunk-E737X73P.js} +38 -24
- package/{chunk-F2GLBPGQ.js → chunk-FFOXTPQA.js} +8 -6
- package/chunk-G7UPIJAP.js +903 -0
- package/{chunk-CNSTFT7U.js → chunk-HAYXR3MW.js} +1 -1
- package/{chunk-3HUTU5SO.js → chunk-HNCE3YE5.js} +1649 -1569
- package/{chunk-Q46JRSZU.js → chunk-IITIX4ID.js} +22 -3
- package/chunk-LPIBYUMT.js +854 -0
- package/{chunk-47IR6Z6C.js → chunk-LZGKX7JI.js} +87 -40
- package/{chunk-5PFGKHIS.js → chunk-NXEH3NQZ.js} +10 -10
- package/{chunk-FM5DQZVN.js → chunk-OCJDISSI.js} +2 -2
- package/chunk-RNJSI3NZ.js +75 -0
- package/{chunk-ONVLPT73.js → chunk-T4GYDWUJ.js} +1 -1
- package/{chunk-YDUHQU7N.js → chunk-TMBNGWXK.js} +3 -3
- package/{chunk-CTDFRLS4.js → chunk-UAAZW4N6.js} +4 -4
- package/{chunk-TM4LHSZV.js → chunk-UXIRAU5T.js} +3 -3
- package/{chunk-BSB4XGBB.js → chunk-VB3IWNHX.js} +1 -1
- package/chunk-VE6CCH33.js +3000 -0
- package/{chunk-42UTZKAU.js → chunk-W2Q5EIMH.js} +8 -8
- package/{chunk-YRMICBI4.js → chunk-XQSBCMSC.js} +5 -5
- package/{chunk-NS4VFXHX.js → chunk-XU5SMHXP.js} +1 -1
- package/{ci-A22A6TCQ.js → ci-RZZE375O.js} +17 -16
- package/cli-package.json +1 -1
- package/{config-JL4TW2AV.js → config-LL3RLMZG.js} +9 -12
- package/{config-VOLRKFYD.js → config-MDFY3ORD.js} +15 -18
- package/{create-SL7HEXCS.js → create-GVSDTOGQ.js} +23 -23
- package/{deprecate-ZK525LQW.js → deprecate-T4TQLGXQ.js} +16 -14
- package/{dist-tag-FY3FB5VH.js → dist-tag-GO46UQUN.js} +11 -9
- package/{docs-6BPWZJFW.js → docs-FJME563T.js} +19 -18
- package/{exec-JZ5J7DI7.js → exec-M22KBPCK.js} +23 -23
- package/{exec-cache-VGSXKZVF.js → exec-cache-3UNLDUAP.js} +22 -22
- package/{exec-local-GPZUSOSM.js → exec-local-YHVO5RLU.js} +20 -18
- package/{help-XI7TNIRU.js → help-ZEWMLOJX.js} +3 -3
- package/{init-6KWM7CDI.js → init-4HPZY2KN.js} +12 -10
- package/{install-4VLOKCWH.js → install-2TZIP4PJ.js} +18 -17
- package/{list-3VLGWGKU.js → list-NFFXER43.js} +20 -18
- package/{login-3DGPSWCG.js → login-KV5YC5Z2.js} +9 -7
- package/{logout-DBFMZC6J.js → logout-I2VT3NAR.js} +9 -7
- package/{pack-LHNYEZ5W.js → pack-47ZKFSHI.js} +16 -14
- package/package.json +1 -1
- package/{ping-VLLX5LIH.js → ping-Q7Y7QV63.js} +9 -7
- package/{pkg-FYPUMX7U.js → pkg-VTJS2ISJ.js} +13 -11
- package/{profile-FOQ74TB7.js → profile-YXZYVEUX.js} +9 -7
- package/{publish-DFURU7DW.js → publish-CBN67KN2.js} +21 -19
- package/{query-NC3EABMW.js → query-U3QHF3ZE.js} +20 -18
- package/{registry-5DUFCPD6.js → registry-CZPFR3OF.js} +3 -3
- package/registry-client-package.json +1 -1
- package/registry-client-src-revalidate.js +403 -328
- package/{repo-IZXACKQ2.js → repo-4UIQRBI7.js} +19 -18
- package/{chunk-UVZJFBYE.js → reporter-DKZTTACW.js} +5 -5
- package/{run-RDFVO7FY.js → run-5DUYI6GL.js} +20 -18
- package/{run-exec-OGMXEVN5.js → run-exec-HPNBVAXH.js} +20 -18
- package/security-archive-src-update-expired.js +11 -2
- package/{setup-KTJQPDJB.js → setup-23W5FQVW.js} +15 -13
- package/{src-BJU7XZNK.js → src-2NB67FPG.js} +22 -23
- package/{reporter-UU654STB.js → src-6OKPBJJT.js} +42 -7
- package/src-M5RRGKUM.js +913 -0
- package/{token-SKICECA4.js → token-SRCS5CRU.js} +9 -7
- package/{uninstall-MTZJ33TO.js → uninstall-JXHAFXZ2.js} +18 -17
- package/{unpublish-3QBJZFHQ.js → unpublish-GRYB5KQH.js} +12 -10
- package/{update-TH477PKA.js → update-GDLL4ER6.js} +17 -16
- package/{version-YIBQZLQS.js → version-JVG4CI4L.js} +13 -11
- package/{view-FG74OAOV.js → view-ABQLVL4L.js} +12 -14
- package/vlr.js +1 -1
- package/vlrx.js +1 -1
- package/vlt.js +1 -1
- package/vlx.js +1 -1
- package/vlxl.js +1 -1
- package/{whoami-LHJ4PRJQ.js → whoami-RCCZ7BXI.js} +9 -7
- package/chunk-7NHXV6AH.js +0 -4488
- package/chunk-WAFERMRI.js +0 -1663
- package/chunk-ZLZ4XF46.js +0 -75
- package/{chunk-Y7CQIZ7Y.js → chunk-FEIPJIEN.js} +3 -3
package/chunk-WAFERMRI.js
DELETED
|
@@ -1,1663 +0,0 @@
|
|
|
1
|
-
var global = globalThis;
|
|
2
|
-
import {Buffer} from "node:buffer";
|
|
3
|
-
import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
|
|
4
|
-
globalThis.setTimeout = _vlt_setTimeout;
|
|
5
|
-
globalThis.clearTimeout = _vlt_clearTimeout;
|
|
6
|
-
globalThis.setImmediate = _vlt_setImmediate;
|
|
7
|
-
globalThis.clearImmediate = _vlt_clearImmediate;
|
|
8
|
-
globalThis.setInterval = _vlt_setInterval;
|
|
9
|
-
globalThis.clearInterval = _vlt_clearInterval;
|
|
10
|
-
import {createRequire as _vlt_createRequire} from "node:module";
|
|
11
|
-
var require = _vlt_createRequire(import.meta.filename);
|
|
12
|
-
import {
|
|
13
|
-
Qn,
|
|
14
|
-
require_lib
|
|
15
|
-
} from "./chunk-FWKQ7YDF.js";
|
|
16
|
-
import {
|
|
17
|
-
Monorepo,
|
|
18
|
-
PackageJson,
|
|
19
|
-
clone,
|
|
20
|
-
pickManifest,
|
|
21
|
-
resolve,
|
|
22
|
-
revs
|
|
23
|
-
} from "./chunk-F2GLBPGQ.js";
|
|
24
|
-
import {
|
|
25
|
-
RegistryClient
|
|
26
|
-
} from "./chunk-3HUTU5SO.js";
|
|
27
|
-
import {
|
|
28
|
-
rimraf
|
|
29
|
-
} from "./chunk-7NHXV6AH.js";
|
|
30
|
-
import {
|
|
31
|
-
Spec
|
|
32
|
-
} from "./chunk-NS4VFXHX.js";
|
|
33
|
-
import {
|
|
34
|
-
asError,
|
|
35
|
-
asPackument
|
|
36
|
-
} from "./chunk-Q46JRSZU.js";
|
|
37
|
-
import {
|
|
38
|
-
XDG
|
|
39
|
-
} from "./chunk-XNLSTHDK.js";
|
|
40
|
-
import {
|
|
41
|
-
error
|
|
42
|
-
} from "./chunk-WZWDS3W4.js";
|
|
43
|
-
import {
|
|
44
|
-
__toESM
|
|
45
|
-
} from "./chunk-PZLD7RTK.js";
|
|
46
|
-
|
|
47
|
-
// ../../src/tar/src/unpack.ts
|
|
48
|
-
import { randomBytes } from "node:crypto";
|
|
49
|
-
import { lstat, mkdir, rename, writeFile } from "node:fs/promises";
|
|
50
|
-
import {
|
|
51
|
-
basename as basename2,
|
|
52
|
-
dirname,
|
|
53
|
-
isAbsolute,
|
|
54
|
-
relative,
|
|
55
|
-
resolve as resolve2,
|
|
56
|
-
sep
|
|
57
|
-
} from "node:path";
|
|
58
|
-
|
|
59
|
-
// ../../node_modules/.vlt/~npm~tar@7.5.20/node_modules/tar/dist/esm/header.js
|
|
60
|
-
import { posix as pathModule } from "node:path";
|
|
61
|
-
|
|
62
|
-
// ../../node_modules/.vlt/~npm~tar@7.5.20/node_modules/tar/dist/esm/large-numbers.js
|
|
63
|
-
var encode = (num, buf) => {
|
|
64
|
-
if (!Number.isSafeInteger(num)) {
|
|
65
|
-
throw Error("cannot encode number outside of javascript safe integer range");
|
|
66
|
-
} else if (num < 0) {
|
|
67
|
-
encodeNegative(num, buf);
|
|
68
|
-
} else {
|
|
69
|
-
encodePositive(num, buf);
|
|
70
|
-
}
|
|
71
|
-
return buf;
|
|
72
|
-
};
|
|
73
|
-
var encodePositive = (num, buf) => {
|
|
74
|
-
buf[0] = 128;
|
|
75
|
-
for (var i = buf.length; i > 1; i--) {
|
|
76
|
-
buf[i - 1] = num & 255;
|
|
77
|
-
num = Math.floor(num / 256);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var encodeNegative = (num, buf) => {
|
|
81
|
-
buf[0] = 255;
|
|
82
|
-
var flipped = false;
|
|
83
|
-
num = num * -1;
|
|
84
|
-
for (var i = buf.length; i > 1; i--) {
|
|
85
|
-
var byte = num & 255;
|
|
86
|
-
num = Math.floor(num / 256);
|
|
87
|
-
if (flipped) {
|
|
88
|
-
buf[i - 1] = onesComp(byte);
|
|
89
|
-
} else if (byte === 0) {
|
|
90
|
-
buf[i - 1] = 0;
|
|
91
|
-
} else {
|
|
92
|
-
flipped = true;
|
|
93
|
-
buf[i - 1] = twosComp(byte);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
var parse = (buf) => {
|
|
98
|
-
const pre = buf[0];
|
|
99
|
-
const value = pre === 128 ? pos(buf.subarray(1, buf.length)) : pre === 255 ? twos(buf) : null;
|
|
100
|
-
if (value === null) {
|
|
101
|
-
throw Error("invalid base256 encoding");
|
|
102
|
-
}
|
|
103
|
-
if (!Number.isSafeInteger(value)) {
|
|
104
|
-
throw Error("parsed number outside of javascript safe integer range");
|
|
105
|
-
}
|
|
106
|
-
return value;
|
|
107
|
-
};
|
|
108
|
-
var twos = (buf) => {
|
|
109
|
-
var len = buf.length;
|
|
110
|
-
var sum = 0;
|
|
111
|
-
var flipped = false;
|
|
112
|
-
for (var i = len - 1; i > -1; i--) {
|
|
113
|
-
var byte = Number(buf[i]);
|
|
114
|
-
var f;
|
|
115
|
-
if (flipped) {
|
|
116
|
-
f = onesComp(byte);
|
|
117
|
-
} else if (byte === 0) {
|
|
118
|
-
f = byte;
|
|
119
|
-
} else {
|
|
120
|
-
flipped = true;
|
|
121
|
-
f = twosComp(byte);
|
|
122
|
-
}
|
|
123
|
-
if (f !== 0) {
|
|
124
|
-
sum -= f * Math.pow(256, len - i - 1);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return sum;
|
|
128
|
-
};
|
|
129
|
-
var pos = (buf) => {
|
|
130
|
-
var len = buf.length;
|
|
131
|
-
var sum = 0;
|
|
132
|
-
for (var i = len - 1; i > -1; i--) {
|
|
133
|
-
var byte = Number(buf[i]);
|
|
134
|
-
if (byte !== 0) {
|
|
135
|
-
sum += byte * Math.pow(256, len - i - 1);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return sum;
|
|
139
|
-
};
|
|
140
|
-
var onesComp = (byte) => (255 ^ byte) & 255;
|
|
141
|
-
var twosComp = (byte) => (255 ^ byte) + 1 & 255;
|
|
142
|
-
|
|
143
|
-
// ../../node_modules/.vlt/~npm~tar@7.5.20/node_modules/tar/dist/esm/types.js
|
|
144
|
-
var isCode = (c) => name.has(c);
|
|
145
|
-
var normalFsTypes = /* @__PURE__ */ new Set([
|
|
146
|
-
"0",
|
|
147
|
-
"",
|
|
148
|
-
"1",
|
|
149
|
-
"2",
|
|
150
|
-
"3",
|
|
151
|
-
"4",
|
|
152
|
-
"5",
|
|
153
|
-
"6",
|
|
154
|
-
"7",
|
|
155
|
-
"D"
|
|
156
|
-
]);
|
|
157
|
-
var name = /* @__PURE__ */ new Map([
|
|
158
|
-
["0", "File"],
|
|
159
|
-
// same as File
|
|
160
|
-
["", "OldFile"],
|
|
161
|
-
["1", "Link"],
|
|
162
|
-
["2", "SymbolicLink"],
|
|
163
|
-
// Devices and FIFOs aren't fully supported
|
|
164
|
-
// they are parsed, but skipped when unpacking
|
|
165
|
-
["3", "CharacterDevice"],
|
|
166
|
-
["4", "BlockDevice"],
|
|
167
|
-
["5", "Directory"],
|
|
168
|
-
["6", "FIFO"],
|
|
169
|
-
// same as File
|
|
170
|
-
["7", "ContiguousFile"],
|
|
171
|
-
// pax headers
|
|
172
|
-
["g", "GlobalExtendedHeader"],
|
|
173
|
-
["x", "ExtendedHeader"],
|
|
174
|
-
// vendor-specific stuff
|
|
175
|
-
// skip
|
|
176
|
-
["A", "SolarisACL"],
|
|
177
|
-
// like 5, but with data, which should be skipped
|
|
178
|
-
["D", "GNUDumpDir"],
|
|
179
|
-
// metadata only, skip
|
|
180
|
-
["I", "Inode"],
|
|
181
|
-
// data = link path of next file
|
|
182
|
-
["K", "NextFileHasLongLinkpath"],
|
|
183
|
-
// data = path of next file
|
|
184
|
-
["L", "NextFileHasLongPath"],
|
|
185
|
-
// skip
|
|
186
|
-
["M", "ContinuationFile"],
|
|
187
|
-
// like L
|
|
188
|
-
["N", "OldGnuLongPath"],
|
|
189
|
-
// skip
|
|
190
|
-
["S", "SparseFile"],
|
|
191
|
-
// skip
|
|
192
|
-
["V", "TapeVolumeHeader"],
|
|
193
|
-
// like x
|
|
194
|
-
["X", "OldExtendedHeader"]
|
|
195
|
-
]);
|
|
196
|
-
var code = new Map(Array.from(name).map((kv) => [kv[1], kv[0]]));
|
|
197
|
-
|
|
198
|
-
// ../../node_modules/.vlt/~npm~tar@7.5.20/node_modules/tar/dist/esm/header.js
|
|
199
|
-
var notNegative = (n) => n === void 0 || n < 0 ? void 0 : n;
|
|
200
|
-
var Header = class {
|
|
201
|
-
cksumValid = false;
|
|
202
|
-
needPax = false;
|
|
203
|
-
nullBlock = false;
|
|
204
|
-
block;
|
|
205
|
-
path;
|
|
206
|
-
mode;
|
|
207
|
-
uid;
|
|
208
|
-
gid;
|
|
209
|
-
size;
|
|
210
|
-
cksum;
|
|
211
|
-
#type = "Unsupported";
|
|
212
|
-
linkpath;
|
|
213
|
-
uname;
|
|
214
|
-
gname;
|
|
215
|
-
devmaj = 0;
|
|
216
|
-
devmin = 0;
|
|
217
|
-
atime;
|
|
218
|
-
ctime;
|
|
219
|
-
mtime;
|
|
220
|
-
charset;
|
|
221
|
-
comment;
|
|
222
|
-
constructor(data, off = 0, ex, gex) {
|
|
223
|
-
if (Buffer.isBuffer(data)) {
|
|
224
|
-
this.decode(data, off || 0, ex, gex);
|
|
225
|
-
} else if (data) {
|
|
226
|
-
this.#slurp(data);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
decode(buf, off, ex, gex) {
|
|
230
|
-
if (!off) {
|
|
231
|
-
off = 0;
|
|
232
|
-
}
|
|
233
|
-
if (!buf || !(buf.length >= off + 512)) {
|
|
234
|
-
throw new Error("need 512 bytes for header");
|
|
235
|
-
}
|
|
236
|
-
const t = decString(buf, off + 156, 1);
|
|
237
|
-
const isNormalFS = normalFsTypes.has(t);
|
|
238
|
-
const exForFields = isNormalFS ? ex : void 0;
|
|
239
|
-
const gexForFields = isNormalFS ? gex : void 0;
|
|
240
|
-
this.path = exForFields?.path ?? decString(buf, off, 100);
|
|
241
|
-
this.mode = exForFields?.mode ?? gexForFields?.mode ?? decNumber(buf, off + 100, 8);
|
|
242
|
-
this.uid = exForFields?.uid ?? gexForFields?.uid ?? decNumber(buf, off + 108, 8);
|
|
243
|
-
this.gid = exForFields?.gid ?? gexForFields?.gid ?? decNumber(buf, off + 116, 8);
|
|
244
|
-
this.size = notNegative(exForFields?.size ?? gexForFields?.size ?? decNumber(buf, off + 124, 12));
|
|
245
|
-
this.mtime = exForFields?.mtime ?? gexForFields?.mtime ?? decDate(buf, off + 136, 12);
|
|
246
|
-
this.cksum = decNumber(buf, off + 148, 12);
|
|
247
|
-
if (gexForFields)
|
|
248
|
-
this.#slurp(gexForFields, true);
|
|
249
|
-
if (exForFields)
|
|
250
|
-
this.#slurp(exForFields);
|
|
251
|
-
if (isCode(t)) {
|
|
252
|
-
this.#type = t || "0";
|
|
253
|
-
}
|
|
254
|
-
if (this.#type === "0" && this.path.slice(-1) === "/") {
|
|
255
|
-
this.#type = "5";
|
|
256
|
-
}
|
|
257
|
-
if (this.#type === "5") {
|
|
258
|
-
this.size = 0;
|
|
259
|
-
}
|
|
260
|
-
this.linkpath = decString(buf, off + 157, 100);
|
|
261
|
-
if (buf.subarray(off + 257, off + 265).toString() === "ustar\x0000") {
|
|
262
|
-
this.uname = exForFields?.uname ?? gexForFields?.uname ?? decString(buf, off + 265, 32);
|
|
263
|
-
this.gname = exForFields?.gname ?? gexForFields?.gname ?? decString(buf, off + 297, 32);
|
|
264
|
-
this.devmaj = exForFields?.devmaj ?? gexForFields?.devmaj ?? decNumber(buf, off + 329, 8) ?? 0;
|
|
265
|
-
this.devmin = exForFields?.devmin ?? gexForFields?.devmin ?? decNumber(buf, off + 337, 8) ?? 0;
|
|
266
|
-
if (buf[off + 475] !== 0) {
|
|
267
|
-
const prefix = decString(buf, off + 345, 155);
|
|
268
|
-
this.path = prefix + "/" + this.path;
|
|
269
|
-
} else {
|
|
270
|
-
const prefix = decString(buf, off + 345, 130);
|
|
271
|
-
if (prefix) {
|
|
272
|
-
this.path = prefix + "/" + this.path;
|
|
273
|
-
}
|
|
274
|
-
this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12);
|
|
275
|
-
this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
let sum = 8 * 32;
|
|
279
|
-
for (let i = off; i < off + 148; i++) {
|
|
280
|
-
sum += buf[i];
|
|
281
|
-
}
|
|
282
|
-
for (let i = off + 156; i < off + 512; i++) {
|
|
283
|
-
sum += buf[i];
|
|
284
|
-
}
|
|
285
|
-
this.cksumValid = sum === this.cksum;
|
|
286
|
-
if (this.cksum === void 0 && sum === 8 * 32) {
|
|
287
|
-
this.nullBlock = true;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
#slurp(ex, gex = false) {
|
|
291
|
-
Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k, v]) => {
|
|
292
|
-
return !(v === null || v === void 0 || k === "size" && Number(v) < 0 || k === "path" && gex || k === "linkpath" && gex || k === "global");
|
|
293
|
-
})));
|
|
294
|
-
}
|
|
295
|
-
encode(buf, off = 0) {
|
|
296
|
-
if (!buf) {
|
|
297
|
-
buf = this.block = Buffer.alloc(512);
|
|
298
|
-
}
|
|
299
|
-
if (this.#type === "Unsupported") {
|
|
300
|
-
this.#type = "0";
|
|
301
|
-
}
|
|
302
|
-
if (!(buf.length >= off + 512)) {
|
|
303
|
-
throw new Error("need 512 bytes for header");
|
|
304
|
-
}
|
|
305
|
-
const prefixSize = this.ctime || this.atime ? 130 : 155;
|
|
306
|
-
const split = splitPrefix(this.path || "", prefixSize);
|
|
307
|
-
const path = split[0];
|
|
308
|
-
const prefix = split[1];
|
|
309
|
-
this.needPax = !!split[2];
|
|
310
|
-
this.needPax = encString(buf, off, 100, path) || this.needPax;
|
|
311
|
-
this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax;
|
|
312
|
-
this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax;
|
|
313
|
-
this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax;
|
|
314
|
-
this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax;
|
|
315
|
-
this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax;
|
|
316
|
-
buf[off + 156] = Number(this.#type.codePointAt(0));
|
|
317
|
-
this.needPax = encString(buf, off + 157, 100, this.linkpath) || this.needPax;
|
|
318
|
-
buf.write("ustar\x0000", off + 257, 8);
|
|
319
|
-
this.needPax = encString(buf, off + 265, 32, this.uname) || this.needPax;
|
|
320
|
-
this.needPax = encString(buf, off + 297, 32, this.gname) || this.needPax;
|
|
321
|
-
this.needPax = encNumber(buf, off + 329, 8, this.devmaj) || this.needPax;
|
|
322
|
-
this.needPax = encNumber(buf, off + 337, 8, this.devmin) || this.needPax;
|
|
323
|
-
this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax;
|
|
324
|
-
if (buf[off + 475] !== 0) {
|
|
325
|
-
this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax;
|
|
326
|
-
} else {
|
|
327
|
-
this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax;
|
|
328
|
-
this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax;
|
|
329
|
-
this.needPax = encDate(buf, off + 488, 12, this.ctime) || this.needPax;
|
|
330
|
-
}
|
|
331
|
-
let sum = 8 * 32;
|
|
332
|
-
for (let i = off; i < off + 148; i++) {
|
|
333
|
-
sum += buf[i];
|
|
334
|
-
}
|
|
335
|
-
for (let i = off + 156; i < off + 512; i++) {
|
|
336
|
-
sum += buf[i];
|
|
337
|
-
}
|
|
338
|
-
this.cksum = sum;
|
|
339
|
-
encNumber(buf, off + 148, 8, this.cksum);
|
|
340
|
-
this.cksumValid = true;
|
|
341
|
-
return this.needPax;
|
|
342
|
-
}
|
|
343
|
-
get type() {
|
|
344
|
-
return this.#type === "Unsupported" ? this.#type : name.get(this.#type);
|
|
345
|
-
}
|
|
346
|
-
get typeKey() {
|
|
347
|
-
return this.#type;
|
|
348
|
-
}
|
|
349
|
-
set type(type) {
|
|
350
|
-
const c = String(code.get(type));
|
|
351
|
-
if (isCode(c) || c === "Unsupported") {
|
|
352
|
-
this.#type = c;
|
|
353
|
-
} else if (isCode(type)) {
|
|
354
|
-
this.#type = type;
|
|
355
|
-
} else {
|
|
356
|
-
throw new TypeError("invalid entry type: " + type);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
var splitPrefix = (p, prefixSize) => {
|
|
361
|
-
const pathSize = 100;
|
|
362
|
-
let pp = p;
|
|
363
|
-
let prefix = "";
|
|
364
|
-
let ret = void 0;
|
|
365
|
-
const root = pathModule.parse(p).root || ".";
|
|
366
|
-
if (Buffer.byteLength(pp) < pathSize) {
|
|
367
|
-
ret = [pp, prefix, false];
|
|
368
|
-
} else {
|
|
369
|
-
prefix = pathModule.dirname(pp);
|
|
370
|
-
pp = pathModule.basename(pp);
|
|
371
|
-
do {
|
|
372
|
-
if (Buffer.byteLength(pp) <= pathSize && Buffer.byteLength(prefix) <= prefixSize) {
|
|
373
|
-
ret = [pp, prefix, false];
|
|
374
|
-
} else if (Buffer.byteLength(pp) > pathSize && Buffer.byteLength(prefix) <= prefixSize) {
|
|
375
|
-
ret = [pp.slice(0, pathSize - 1), prefix, true];
|
|
376
|
-
} else {
|
|
377
|
-
pp = pathModule.join(pathModule.basename(prefix), pp);
|
|
378
|
-
prefix = pathModule.dirname(prefix);
|
|
379
|
-
}
|
|
380
|
-
} while (prefix !== root && ret === void 0);
|
|
381
|
-
if (!ret) {
|
|
382
|
-
ret = [p.slice(0, pathSize - 1), "", true];
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return ret;
|
|
386
|
-
};
|
|
387
|
-
var decString = (buf, off, size) => buf.subarray(off, off + size).toString("utf8").replace(/\0.*/, "");
|
|
388
|
-
var decDate = (buf, off, size) => numToDate(decNumber(buf, off, size));
|
|
389
|
-
var numToDate = (num) => num === void 0 ? void 0 : new Date(num * 1e3);
|
|
390
|
-
var decNumber = (buf, off, size) => Number(buf[off]) & 128 ? parse(buf.subarray(off, off + size)) : decSmallNumber(buf, off, size);
|
|
391
|
-
var nanUndef = (value) => isNaN(value) ? void 0 : value;
|
|
392
|
-
var decSmallNumber = (buf, off, size) => nanUndef(parseInt(buf.subarray(off, off + size).toString("utf8").replace(/\0.*$/, "").trim(), 8));
|
|
393
|
-
var MAXNUM = {
|
|
394
|
-
12: 8589934591,
|
|
395
|
-
8: 2097151
|
|
396
|
-
};
|
|
397
|
-
var encNumber = (buf, off, size, num) => num === void 0 ? false : num > MAXNUM[size] || num < 0 ? (encode(num, buf.subarray(off, off + size)), true) : (encSmallNumber(buf, off, size, num), false);
|
|
398
|
-
var encSmallNumber = (buf, off, size, num) => buf.write(octalString(num, size), off, size, "ascii");
|
|
399
|
-
var octalString = (num, size) => padOctal(Math.floor(num).toString(8), size);
|
|
400
|
-
var padOctal = (str, size) => (str.length === size - 1 ? str : new Array(size - str.length - 1).join("0") + str + " ") + "\0";
|
|
401
|
-
var encDate = (buf, off, size, date) => date === void 0 ? false : encNumber(buf, off, size, date.getTime() / 1e3);
|
|
402
|
-
var NULLS = new Array(156).join("\0");
|
|
403
|
-
var encString = (buf, off, size, str) => str === void 0 ? false : (buf.write(str + NULLS, off, size, "utf8"), str.length !== Buffer.byteLength(str) || str.length > size);
|
|
404
|
-
|
|
405
|
-
// ../../node_modules/.vlt/~npm~tar@7.5.20/node_modules/tar/dist/esm/pax.js
|
|
406
|
-
import { basename } from "node:path";
|
|
407
|
-
var Pax = class _Pax {
|
|
408
|
-
atime;
|
|
409
|
-
mtime;
|
|
410
|
-
ctime;
|
|
411
|
-
charset;
|
|
412
|
-
comment;
|
|
413
|
-
gid;
|
|
414
|
-
uid;
|
|
415
|
-
gname;
|
|
416
|
-
uname;
|
|
417
|
-
linkpath;
|
|
418
|
-
dev;
|
|
419
|
-
ino;
|
|
420
|
-
nlink;
|
|
421
|
-
path;
|
|
422
|
-
size;
|
|
423
|
-
mode;
|
|
424
|
-
global;
|
|
425
|
-
constructor(obj, global = false) {
|
|
426
|
-
this.atime = obj.atime;
|
|
427
|
-
this.charset = obj.charset;
|
|
428
|
-
this.comment = obj.comment;
|
|
429
|
-
this.ctime = obj.ctime;
|
|
430
|
-
this.dev = obj.dev;
|
|
431
|
-
this.gid = obj.gid;
|
|
432
|
-
this.global = global;
|
|
433
|
-
this.gname = obj.gname;
|
|
434
|
-
this.ino = obj.ino;
|
|
435
|
-
this.linkpath = obj.linkpath;
|
|
436
|
-
this.mtime = obj.mtime;
|
|
437
|
-
this.nlink = obj.nlink;
|
|
438
|
-
this.path = obj.path;
|
|
439
|
-
this.size = obj.size;
|
|
440
|
-
this.uid = obj.uid;
|
|
441
|
-
this.uname = obj.uname;
|
|
442
|
-
}
|
|
443
|
-
encode() {
|
|
444
|
-
const body = this.encodeBody();
|
|
445
|
-
if (body === "") {
|
|
446
|
-
return Buffer.allocUnsafe(0);
|
|
447
|
-
}
|
|
448
|
-
const bodyLen = Buffer.byteLength(body);
|
|
449
|
-
const bufLen = 512 * Math.ceil(1 + bodyLen / 512);
|
|
450
|
-
const buf = Buffer.allocUnsafe(bufLen);
|
|
451
|
-
for (let i = 0; i < 512; i++) {
|
|
452
|
-
buf[i] = 0;
|
|
453
|
-
}
|
|
454
|
-
new Header({
|
|
455
|
-
// XXX split the path
|
|
456
|
-
// then the path should be PaxHeader + basename, but less than 99,
|
|
457
|
-
// prepend with the dirname
|
|
458
|
-
/* c8 ignore start */
|
|
459
|
-
path: ("PaxHeader/" + basename(this.path ?? "")).slice(0, 99),
|
|
460
|
-
/* c8 ignore stop */
|
|
461
|
-
mode: this.mode || 420,
|
|
462
|
-
uid: this.uid,
|
|
463
|
-
gid: this.gid,
|
|
464
|
-
size: bodyLen,
|
|
465
|
-
mtime: this.mtime,
|
|
466
|
-
type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
|
|
467
|
-
linkpath: "",
|
|
468
|
-
uname: this.uname || "",
|
|
469
|
-
gname: this.gname || "",
|
|
470
|
-
devmaj: 0,
|
|
471
|
-
devmin: 0,
|
|
472
|
-
atime: this.atime,
|
|
473
|
-
ctime: this.ctime
|
|
474
|
-
}).encode(buf);
|
|
475
|
-
buf.write(body, 512, bodyLen, "utf8");
|
|
476
|
-
for (let i = bodyLen + 512; i < buf.length; i++) {
|
|
477
|
-
buf[i] = 0;
|
|
478
|
-
}
|
|
479
|
-
return buf;
|
|
480
|
-
}
|
|
481
|
-
encodeBody() {
|
|
482
|
-
return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
|
|
483
|
-
}
|
|
484
|
-
encodeField(field) {
|
|
485
|
-
if (this[field] === void 0) {
|
|
486
|
-
return "";
|
|
487
|
-
}
|
|
488
|
-
const r = this[field];
|
|
489
|
-
const v = r instanceof Date ? r.getTime() / 1e3 : r;
|
|
490
|
-
const s = " " + (field === "dev" || field === "ino" || field === "nlink" ? "SCHILY." : "") + field + "=" + v + "\n";
|
|
491
|
-
const byteLen = Buffer.byteLength(s);
|
|
492
|
-
let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1;
|
|
493
|
-
if (byteLen + digits >= Math.pow(10, digits)) {
|
|
494
|
-
digits += 1;
|
|
495
|
-
}
|
|
496
|
-
const len = digits + byteLen;
|
|
497
|
-
return len + s;
|
|
498
|
-
}
|
|
499
|
-
static parse(str, ex, g = false) {
|
|
500
|
-
return new _Pax(merge(parseKV(str), ex), g);
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
var merge = (a, b) => b ? Object.assign({}, b, a) : a;
|
|
504
|
-
var parseKV = (str) => str.replace(/\n$/, "").split("\n").reduce(parseKVLine, /* @__PURE__ */ Object.create(null));
|
|
505
|
-
var parseKVLine = (set, line) => {
|
|
506
|
-
const n = parseInt(line, 10);
|
|
507
|
-
if (n !== Buffer.byteLength(line) + 1) {
|
|
508
|
-
return set;
|
|
509
|
-
}
|
|
510
|
-
line = line.slice((n + " ").length);
|
|
511
|
-
const kv = line.split("=");
|
|
512
|
-
const r = kv.shift();
|
|
513
|
-
if (!r) {
|
|
514
|
-
return set;
|
|
515
|
-
}
|
|
516
|
-
const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1");
|
|
517
|
-
const v = kv.join("=").replace(/\0.*/, "");
|
|
518
|
-
switch (k) {
|
|
519
|
-
case "path":
|
|
520
|
-
case "linkpath":
|
|
521
|
-
case "type":
|
|
522
|
-
case "charset":
|
|
523
|
-
case "comment":
|
|
524
|
-
case "gname":
|
|
525
|
-
case "uname":
|
|
526
|
-
set[k] = v;
|
|
527
|
-
break;
|
|
528
|
-
case "ctime":
|
|
529
|
-
case "atime":
|
|
530
|
-
case "mtime":
|
|
531
|
-
set[k] = new Date(Number(v) * 1e3);
|
|
532
|
-
break;
|
|
533
|
-
case "size":
|
|
534
|
-
const s = +v;
|
|
535
|
-
if (s >= 0)
|
|
536
|
-
set[k] = s;
|
|
537
|
-
break;
|
|
538
|
-
case "gid":
|
|
539
|
-
case "uid":
|
|
540
|
-
case "dev":
|
|
541
|
-
case "ino":
|
|
542
|
-
case "nlink":
|
|
543
|
-
case "mode":
|
|
544
|
-
set[k] = +v;
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
return set;
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
// ../../src/tar/src/unpack.ts
|
|
551
|
-
import { unzip as unzipCB } from "node:zlib";
|
|
552
|
-
|
|
553
|
-
// ../../src/tar/src/find-tar-dir.ts
|
|
554
|
-
var findTarDir = (path, tarDir) => {
|
|
555
|
-
if (tarDir !== void 0) return tarDir;
|
|
556
|
-
if (!path) return void 0;
|
|
557
|
-
const i = path.indexOf("/", path.startsWith("./") ? 2 : 0);
|
|
558
|
-
if (i === -1) return void 0;
|
|
559
|
-
const chomp = path.substring(0, i);
|
|
560
|
-
if (chomp === "." || chomp === ".." || chomp === "" || chomp === "./." || chomp === "./.." || chomp === "./") {
|
|
561
|
-
return void 0;
|
|
562
|
-
}
|
|
563
|
-
return chomp + "/";
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
// ../../src/tar/src/unpack.ts
|
|
567
|
-
var unzip = async (input) => new Promise(
|
|
568
|
-
(res, rej) => (
|
|
569
|
-
/* c8 ignore start */
|
|
570
|
-
unzipCB(input, (er, result) => er ? rej(er) : res(result))
|
|
571
|
-
)
|
|
572
|
-
/* c8 ignore stop */
|
|
573
|
-
);
|
|
574
|
-
var exists = async (path) => {
|
|
575
|
-
try {
|
|
576
|
-
await lstat(path);
|
|
577
|
-
return true;
|
|
578
|
-
} catch {
|
|
579
|
-
return false;
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
var id = 1;
|
|
583
|
-
var tmp = randomBytes(6).toString("hex") + ".";
|
|
584
|
-
var tmpSuffix = () => tmp + String(id++);
|
|
585
|
-
var checkFs = (h, tarDir, target) => {
|
|
586
|
-
if (!h.path) return false;
|
|
587
|
-
if (!tarDir) return false;
|
|
588
|
-
h.path = h.path.replace(/[\\/]+/g, "/");
|
|
589
|
-
if (!h.path.startsWith(tarDir)) return false;
|
|
590
|
-
const rel = relative(
|
|
591
|
-
target,
|
|
592
|
-
resolve2(target, h.path.slice(tarDir.length))
|
|
593
|
-
);
|
|
594
|
-
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
595
|
-
return false;
|
|
596
|
-
}
|
|
597
|
-
return true;
|
|
598
|
-
};
|
|
599
|
-
var write = async (path, body, executable = false) => {
|
|
600
|
-
await mkdirp(dirname(path));
|
|
601
|
-
await writeFile(path, body, {
|
|
602
|
-
mode: executable ? 511 : 438
|
|
603
|
-
});
|
|
604
|
-
};
|
|
605
|
-
var made = /* @__PURE__ */ new Set();
|
|
606
|
-
var making = /* @__PURE__ */ new Map();
|
|
607
|
-
var mkdirp = async (d) => {
|
|
608
|
-
if (!made.has(d)) {
|
|
609
|
-
const m = making.get(d) ?? mkdir(d, { recursive: true, mode: 511 }).then(
|
|
610
|
-
() => making.delete(d)
|
|
611
|
-
);
|
|
612
|
-
making.set(d, m);
|
|
613
|
-
await m;
|
|
614
|
-
made.add(d);
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
var unpack = async (tarData, target) => {
|
|
618
|
-
const isGzip = tarData[0] === 31 && tarData[1] === 139;
|
|
619
|
-
await unpackUnzipped(
|
|
620
|
-
isGzip ? await unzip(tarData) : tarData,
|
|
621
|
-
target
|
|
622
|
-
);
|
|
623
|
-
};
|
|
624
|
-
var unpackUnzipped = async (buffer, target) => {
|
|
625
|
-
const isGzip = buffer[0] === 31 && buffer[1] === 139;
|
|
626
|
-
if (isGzip) {
|
|
627
|
-
throw error("still gzipped after unzipping", {
|
|
628
|
-
found: isGzip,
|
|
629
|
-
wanted: false
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
if (buffer.length % 512 !== 0) {
|
|
633
|
-
throw error("Invalid tarball: length not divisible by 512", {
|
|
634
|
-
found: buffer.length
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
if (buffer.length < 1024) {
|
|
638
|
-
throw error(
|
|
639
|
-
"Invalid tarball: not terminated by 1024 null bytes",
|
|
640
|
-
{ found: buffer.length }
|
|
641
|
-
);
|
|
642
|
-
}
|
|
643
|
-
for (let i = buffer.length - 1024; i < buffer.length; i++) {
|
|
644
|
-
if (buffer[i] !== 0) {
|
|
645
|
-
throw error(
|
|
646
|
-
"Invalid tarball: not terminated by 1024 null bytes",
|
|
647
|
-
{ found: buffer.subarray(i, i + 10) }
|
|
648
|
-
);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
const tmp2 = dirname(target) + sep + "." + basename2(target) + "." + tmpSuffix();
|
|
652
|
-
const og = tmp2 + ".ORIGINAL";
|
|
653
|
-
await Promise.all([rimraf(tmp2), rimraf(og)]);
|
|
654
|
-
let succeeded = false;
|
|
655
|
-
try {
|
|
656
|
-
let tarDir = void 0;
|
|
657
|
-
let offset = 0;
|
|
658
|
-
let h;
|
|
659
|
-
let ex = void 0;
|
|
660
|
-
let gex = void 0;
|
|
661
|
-
while (offset < buffer.length && !(h = new Header(buffer, offset, ex, gex)).nullBlock) {
|
|
662
|
-
offset += 512;
|
|
663
|
-
ex = void 0;
|
|
664
|
-
gex = void 0;
|
|
665
|
-
const size = h.size ?? 0;
|
|
666
|
-
const body = buffer.subarray(offset, offset + size);
|
|
667
|
-
if (!h.cksumValid) continue;
|
|
668
|
-
offset += 512 * Math.ceil(size / 512);
|
|
669
|
-
switch (h.type) {
|
|
670
|
-
case "File":
|
|
671
|
-
if (!tarDir) tarDir = findTarDir(h.path, tarDir);
|
|
672
|
-
if (!tarDir) continue;
|
|
673
|
-
if (!checkFs(h, tarDir, tmp2)) continue;
|
|
674
|
-
await write(
|
|
675
|
-
resolve2(tmp2, h.path.substring(tarDir.length)),
|
|
676
|
-
body,
|
|
677
|
-
// if it's world-executable, it's an executable
|
|
678
|
-
// otherwise, make it read-only.
|
|
679
|
-
1 === ((h.mode ?? 1638) & 1)
|
|
680
|
-
);
|
|
681
|
-
break;
|
|
682
|
-
case "Directory":
|
|
683
|
-
if (!tarDir) tarDir = findTarDir(h.path, tarDir);
|
|
684
|
-
if (!tarDir) continue;
|
|
685
|
-
if (!checkFs(h, tarDir, tmp2)) continue;
|
|
686
|
-
await mkdirp(resolve2(tmp2, h.path.substring(tarDir.length)));
|
|
687
|
-
break;
|
|
688
|
-
case "GlobalExtendedHeader":
|
|
689
|
-
gex = Pax.parse(body.toString(), gex, true);
|
|
690
|
-
break;
|
|
691
|
-
case "ExtendedHeader":
|
|
692
|
-
case "OldExtendedHeader":
|
|
693
|
-
ex = Pax.parse(body.toString(), ex, false);
|
|
694
|
-
break;
|
|
695
|
-
case "NextFileHasLongPath":
|
|
696
|
-
case "OldGnuLongPath":
|
|
697
|
-
ex ??= /* @__PURE__ */ Object.create(null);
|
|
698
|
-
ex.path = body.toString().replace(/\0.*/, "");
|
|
699
|
-
break;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
const targetExists = await exists(target);
|
|
703
|
-
if (targetExists) await rename(target, og);
|
|
704
|
-
await rename(tmp2, target);
|
|
705
|
-
if (targetExists) await rimraf(og);
|
|
706
|
-
succeeded = true;
|
|
707
|
-
} finally {
|
|
708
|
-
if (!succeeded) {
|
|
709
|
-
if (await exists(og)) {
|
|
710
|
-
await rimraf(target);
|
|
711
|
-
await rename(og, target);
|
|
712
|
-
}
|
|
713
|
-
await rimraf(tmp2);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
};
|
|
717
|
-
|
|
718
|
-
// ../../src/tar/src/pool.ts
|
|
719
|
-
import os from "node:os";
|
|
720
|
-
|
|
721
|
-
// ../../src/tar/src/unpack-request.ts
|
|
722
|
-
var ID = 1;
|
|
723
|
-
var UnpackRequest = class {
|
|
724
|
-
id = ID++;
|
|
725
|
-
tarData;
|
|
726
|
-
target;
|
|
727
|
-
resolve;
|
|
728
|
-
reject;
|
|
729
|
-
promise = new Promise((res, rej) => {
|
|
730
|
-
this.resolve = res;
|
|
731
|
-
this.reject = rej;
|
|
732
|
-
});
|
|
733
|
-
constructor(tarData, target) {
|
|
734
|
-
this.tarData = tarData;
|
|
735
|
-
this.target = target;
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
|
|
739
|
-
// ../../src/tar/src/worker.ts
|
|
740
|
-
var isObj = (o) => !!o && typeof o === "object";
|
|
741
|
-
var isResponseOK = (o) => isObj(o) && typeof o.id === "number" && o.ok === true;
|
|
742
|
-
var Worker = class {
|
|
743
|
-
onMessage;
|
|
744
|
-
constructor(onMessage) {
|
|
745
|
-
this.onMessage = onMessage;
|
|
746
|
-
}
|
|
747
|
-
async process(req) {
|
|
748
|
-
const { target, tarData, id: id2 } = req;
|
|
749
|
-
try {
|
|
750
|
-
await unpack(tarData, target);
|
|
751
|
-
const m = { id: id2, ok: true };
|
|
752
|
-
this.onMessage(m);
|
|
753
|
-
} catch (error2) {
|
|
754
|
-
const m = { id: id2, error: error2 };
|
|
755
|
-
this.onMessage(m);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
};
|
|
759
|
-
|
|
760
|
-
// ../../src/tar/src/pool.ts
|
|
761
|
-
var Pool = class {
|
|
762
|
-
/**
|
|
763
|
-
* Number of workers to emplly. Defaults to 1 less than the number of
|
|
764
|
-
* CPUs, or 1.
|
|
765
|
-
*/
|
|
766
|
-
/* c8 ignore next */
|
|
767
|
-
jobs = 8 * (Math.max(os.availableParallelism(), 2) - 1);
|
|
768
|
-
/**
|
|
769
|
-
* Set of currently active worker threads
|
|
770
|
-
*/
|
|
771
|
-
workers = /* @__PURE__ */ new Set();
|
|
772
|
-
/**
|
|
773
|
-
* Queue of requests awaiting an available worker
|
|
774
|
-
*/
|
|
775
|
-
queue = [];
|
|
776
|
-
/**
|
|
777
|
-
* Requests that have been assigned to a worker, but have not yet
|
|
778
|
-
* been confirmed completed.
|
|
779
|
-
*/
|
|
780
|
-
pending = /* @__PURE__ */ new Map();
|
|
781
|
-
// handle a message from the worker
|
|
782
|
-
#onMessage(w, m) {
|
|
783
|
-
const { id: id2 } = m;
|
|
784
|
-
const ur = this.pending.get(id2);
|
|
785
|
-
if (!ur) return;
|
|
786
|
-
if (isResponseOK(m)) {
|
|
787
|
-
ur.resolve();
|
|
788
|
-
} else {
|
|
789
|
-
ur.reject(
|
|
790
|
-
error(
|
|
791
|
-
asError(m.error, "failed without error message").message,
|
|
792
|
-
{
|
|
793
|
-
found: m,
|
|
794
|
-
cause: m.error
|
|
795
|
-
}
|
|
796
|
-
)
|
|
797
|
-
);
|
|
798
|
-
}
|
|
799
|
-
const next = this.queue.shift();
|
|
800
|
-
if (!next) {
|
|
801
|
-
this.workers.delete(w);
|
|
802
|
-
} else {
|
|
803
|
-
void w.process(next);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
// create a new worker
|
|
807
|
-
#createWorker(req) {
|
|
808
|
-
const w = new Worker(
|
|
809
|
-
(m) => this.#onMessage(w, m)
|
|
810
|
-
);
|
|
811
|
-
this.workers.add(w);
|
|
812
|
-
void w.process(req);
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* Provide the tardata to be unpacked, and the location where it's to be
|
|
816
|
-
* placed. Will create a new worker up to the `jobs` value, and then start
|
|
817
|
-
* pushing in the queue for workers to pick up as they become available.
|
|
818
|
-
*
|
|
819
|
-
* Returned promise resolves when the provided tarball has been extracted.
|
|
820
|
-
*/
|
|
821
|
-
async unpack(tarData, target) {
|
|
822
|
-
const ur = new UnpackRequest(tarData, target);
|
|
823
|
-
this.pending.set(ur.id, ur);
|
|
824
|
-
if (this.workers.size < this.jobs) {
|
|
825
|
-
this.#createWorker(ur);
|
|
826
|
-
} else {
|
|
827
|
-
this.queue.push(ur);
|
|
828
|
-
}
|
|
829
|
-
return ur.promise;
|
|
830
|
-
}
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
// ../../src/package-info/src/index.ts
|
|
834
|
-
var import_ssri = __toESM(require_lib(), 1);
|
|
835
|
-
import { createHash, randomBytes as randomBytes2 } from "node:crypto";
|
|
836
|
-
import {
|
|
837
|
-
mkdir as mkdir2,
|
|
838
|
-
readFile,
|
|
839
|
-
rm as rm2,
|
|
840
|
-
stat,
|
|
841
|
-
symlink,
|
|
842
|
-
unlink,
|
|
843
|
-
writeFile as writeFile2
|
|
844
|
-
} from "node:fs/promises";
|
|
845
|
-
import {
|
|
846
|
-
basename as basename3,
|
|
847
|
-
dirname as dirname2,
|
|
848
|
-
resolve as pathResolve,
|
|
849
|
-
relative as relative2
|
|
850
|
-
} from "node:path";
|
|
851
|
-
|
|
852
|
-
// ../../src/package-info/src/rename.ts
|
|
853
|
-
import { rename as fsRename, rm } from "node:fs/promises";
|
|
854
|
-
var { platform } = process;
|
|
855
|
-
var rename2 = platform !== "win32" ? fsRename : (async function(oldPath, newPath) {
|
|
856
|
-
let retries = 3;
|
|
857
|
-
const retry = async (er) => {
|
|
858
|
-
if (retries > 0 && er.code === "EPERM") {
|
|
859
|
-
retries--;
|
|
860
|
-
await rm(newPath, { recursive: true, force: true });
|
|
861
|
-
return fsRename(oldPath, newPath).then(() => {
|
|
862
|
-
}, retry);
|
|
863
|
-
} else {
|
|
864
|
-
throw er;
|
|
865
|
-
}
|
|
866
|
-
};
|
|
867
|
-
return fsRename(oldPath, newPath).then(() => {
|
|
868
|
-
}, retry);
|
|
869
|
-
});
|
|
870
|
-
|
|
871
|
-
// ../../src/package-info/src/index.ts
|
|
872
|
-
var xdg = new XDG("vlt");
|
|
873
|
-
var delimiter = "~";
|
|
874
|
-
var manifestCacheMaxAge = 5 * 60 * 1e3;
|
|
875
|
-
var noRegistryError = (spec) => error(
|
|
876
|
-
'No registry configured to resolve this spec. Set "registry" in vlt.json, pass --registry, or run `vlt login --registry=<url>`. See https://docs.vlt.sh/cli',
|
|
877
|
-
{ code: "ECONFIG", spec }
|
|
878
|
-
);
|
|
879
|
-
var PackageInfoClient = class {
|
|
880
|
-
#registryClient;
|
|
881
|
-
#projectRoot;
|
|
882
|
-
#tarPool;
|
|
883
|
-
options;
|
|
884
|
-
#resolutions = /* @__PURE__ */ new Map();
|
|
885
|
-
packageJson;
|
|
886
|
-
monorepo;
|
|
887
|
-
#trustedIntegrities = /* @__PURE__ */ new Map();
|
|
888
|
-
#manifestCacheMinAge = Date.now() - manifestCacheMaxAge;
|
|
889
|
-
#cachePath;
|
|
890
|
-
#packumentPromises = /* @__PURE__ */ new Map();
|
|
891
|
-
get registryClient() {
|
|
892
|
-
if (!this.#registryClient) {
|
|
893
|
-
this.#registryClient = new RegistryClient(this.options);
|
|
894
|
-
}
|
|
895
|
-
return this.#registryClient;
|
|
896
|
-
}
|
|
897
|
-
get tarPool() {
|
|
898
|
-
if (!this.#tarPool) this.#tarPool = new Pool();
|
|
899
|
-
return this.#tarPool;
|
|
900
|
-
}
|
|
901
|
-
constructor(options = {}) {
|
|
902
|
-
this.options = options;
|
|
903
|
-
this.#projectRoot = options.projectRoot || process.cwd();
|
|
904
|
-
this.packageJson = options.packageJson ?? new PackageJson();
|
|
905
|
-
const wsLoad = {
|
|
906
|
-
...options.workspace?.length && { paths: options.workspace },
|
|
907
|
-
...options["workspace-group"]?.length && {
|
|
908
|
-
groups: options["workspace-group"]
|
|
909
|
-
}
|
|
910
|
-
};
|
|
911
|
-
this.monorepo = options.monorepo ?? Monorepo.maybeLoad(this.#projectRoot, {
|
|
912
|
-
load: wsLoad,
|
|
913
|
-
packageJson: this.packageJson
|
|
914
|
-
});
|
|
915
|
-
this.#cachePath = options.cache ?? xdg.cache();
|
|
916
|
-
void mkdir2(pathResolve(this.#cachePath, "package-info"), {
|
|
917
|
-
recursive: true
|
|
918
|
-
}).catch(() => {
|
|
919
|
-
});
|
|
920
|
-
}
|
|
921
|
-
async extract(spec, target, options = {}) {
|
|
922
|
-
if (typeof spec === "string")
|
|
923
|
-
spec = Spec.parse(spec, this.options);
|
|
924
|
-
const {
|
|
925
|
-
from = this.#projectRoot,
|
|
926
|
-
integrity,
|
|
927
|
-
resolved,
|
|
928
|
-
fromLockfile = false
|
|
929
|
-
} = options;
|
|
930
|
-
const f = spec.final;
|
|
931
|
-
const alreadyResolved = !!(integrity && resolved);
|
|
932
|
-
const r = alreadyResolved ? { resolved, integrity, spec } : await this.resolve(spec, options);
|
|
933
|
-
switch (f.type) {
|
|
934
|
-
case "git": {
|
|
935
|
-
const {
|
|
936
|
-
gitRemote,
|
|
937
|
-
gitCommittish,
|
|
938
|
-
remoteURL,
|
|
939
|
-
gitSelectorParsed
|
|
940
|
-
} = f;
|
|
941
|
-
if (!remoteURL) {
|
|
942
|
-
if (!gitRemote)
|
|
943
|
-
throw this.#resolveError(
|
|
944
|
-
spec,
|
|
945
|
-
options,
|
|
946
|
-
"no remote on git: specifier"
|
|
947
|
-
);
|
|
948
|
-
const { path } = gitSelectorParsed ?? {};
|
|
949
|
-
if (path !== void 0) {
|
|
950
|
-
const tmp2 = pathResolve(
|
|
951
|
-
dirname2(target),
|
|
952
|
-
`.TEMP.${basename3(target)}-${randomBytes2(6).toString("hex")}`
|
|
953
|
-
);
|
|
954
|
-
await clone(gitRemote, gitCommittish, tmp2, { spec });
|
|
955
|
-
const src = pathResolve(tmp2, path);
|
|
956
|
-
await rename2(src, target);
|
|
957
|
-
void rm2(tmp2, { recursive: true, force: true });
|
|
958
|
-
} else {
|
|
959
|
-
await clone(gitRemote, gitCommittish, target, { spec });
|
|
960
|
-
void rm2(target + "/.git", { recursive: true });
|
|
961
|
-
}
|
|
962
|
-
return r;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
case "registry": {
|
|
966
|
-
const fetchTarball = async (useCache) => {
|
|
967
|
-
const trustIntegrity = this.#trustedIntegrities.get(r.resolved) === r.integrity;
|
|
968
|
-
const response = await this.registryClient.request(
|
|
969
|
-
r.resolved,
|
|
970
|
-
{
|
|
971
|
-
integrity: r.integrity,
|
|
972
|
-
trustIntegrity,
|
|
973
|
-
...useCache === false ? { useCache } : {}
|
|
974
|
-
}
|
|
975
|
-
);
|
|
976
|
-
if (response.statusCode !== 200) {
|
|
977
|
-
throw this.#resolveError(
|
|
978
|
-
spec,
|
|
979
|
-
options,
|
|
980
|
-
`Registry returned HTTP ${response.statusCode} when fetching the tarball for ${spec}. The resolved version may have been unpublished, or the registry may be misconfigured or unreachable.`,
|
|
981
|
-
{
|
|
982
|
-
url: r.resolved,
|
|
983
|
-
response
|
|
984
|
-
}
|
|
985
|
-
);
|
|
986
|
-
}
|
|
987
|
-
if (!trustIntegrity && response.checkIntegrity({ spec, url: resolved })) {
|
|
988
|
-
this.#trustedIntegrities.set(
|
|
989
|
-
r.resolved,
|
|
990
|
-
response.integrity
|
|
991
|
-
);
|
|
992
|
-
}
|
|
993
|
-
const buf2 = response.buffer();
|
|
994
|
-
if (r.integrity && !fromLockfile) {
|
|
995
|
-
const hash = createHash("sha512");
|
|
996
|
-
hash.update(buf2);
|
|
997
|
-
const computed = `sha512-${hash.digest("base64")}`;
|
|
998
|
-
if (computed !== r.integrity) {
|
|
999
|
-
throw error("Tarball integrity check failed", {
|
|
1000
|
-
code: "EINTEGRITY",
|
|
1001
|
-
spec,
|
|
1002
|
-
url: r.resolved,
|
|
1003
|
-
wanted: r.integrity,
|
|
1004
|
-
found: computed
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
return buf2;
|
|
1009
|
-
};
|
|
1010
|
-
let buf;
|
|
1011
|
-
try {
|
|
1012
|
-
buf = await fetchTarball();
|
|
1013
|
-
} catch (er) {
|
|
1014
|
-
if (er instanceof Error && "cause" in er && er.cause?.code === "EINTEGRITY") {
|
|
1015
|
-
buf = await fetchTarball(false);
|
|
1016
|
-
} else {
|
|
1017
|
-
throw er;
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
try {
|
|
1021
|
-
await this.tarPool.unpack(buf, target);
|
|
1022
|
-
} catch (er) {
|
|
1023
|
-
throw this.#resolveError(
|
|
1024
|
-
spec,
|
|
1025
|
-
options,
|
|
1026
|
-
"tar unpack failed",
|
|
1027
|
-
{ cause: er }
|
|
1028
|
-
);
|
|
1029
|
-
}
|
|
1030
|
-
return r;
|
|
1031
|
-
}
|
|
1032
|
-
case "remote": {
|
|
1033
|
-
const response = await this.registryClient.request(r.resolved);
|
|
1034
|
-
if (response.statusCode !== 200) {
|
|
1035
|
-
throw this.#resolveError(
|
|
1036
|
-
spec,
|
|
1037
|
-
options,
|
|
1038
|
-
"failed to fetch remote tarball",
|
|
1039
|
-
{
|
|
1040
|
-
url: r.resolved,
|
|
1041
|
-
response
|
|
1042
|
-
}
|
|
1043
|
-
);
|
|
1044
|
-
}
|
|
1045
|
-
const buf = response.buffer();
|
|
1046
|
-
const computed = import_ssri.default.fromData(buf, { algorithms: ["sha512"] }).toString();
|
|
1047
|
-
if (r.integrity && r.integrity !== computed) {
|
|
1048
|
-
throw error("Integrity check failure", {
|
|
1049
|
-
code: "EINTEGRITY",
|
|
1050
|
-
spec,
|
|
1051
|
-
url: r.resolved,
|
|
1052
|
-
wanted: r.integrity,
|
|
1053
|
-
found: computed
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
r.integrity = computed;
|
|
1057
|
-
try {
|
|
1058
|
-
await this.tarPool.unpack(buf, target);
|
|
1059
|
-
} catch (er) {
|
|
1060
|
-
throw this.#resolveError(
|
|
1061
|
-
spec,
|
|
1062
|
-
options,
|
|
1063
|
-
"remote tar unpack failed",
|
|
1064
|
-
{ cause: er }
|
|
1065
|
-
);
|
|
1066
|
-
}
|
|
1067
|
-
return r;
|
|
1068
|
-
}
|
|
1069
|
-
case "file": {
|
|
1070
|
-
const { file } = f;
|
|
1071
|
-
if (file === void 0)
|
|
1072
|
-
throw this.#resolveError(spec, options, "no file path");
|
|
1073
|
-
const path = pathResolve(from, file);
|
|
1074
|
-
const st = await stat(path);
|
|
1075
|
-
if (st.isFile()) {
|
|
1076
|
-
try {
|
|
1077
|
-
await this.tarPool.unpack(
|
|
1078
|
-
await this.tarball(spec, options),
|
|
1079
|
-
target
|
|
1080
|
-
);
|
|
1081
|
-
} catch (er) {
|
|
1082
|
-
throw this.#resolveError(
|
|
1083
|
-
spec,
|
|
1084
|
-
options,
|
|
1085
|
-
"tar unpack failed",
|
|
1086
|
-
{ cause: er }
|
|
1087
|
-
);
|
|
1088
|
-
}
|
|
1089
|
-
} else if (st.isDirectory()) {
|
|
1090
|
-
const rel = relative2(dirname2(target), path);
|
|
1091
|
-
await symlink(rel, target, "dir");
|
|
1092
|
-
} else {
|
|
1093
|
-
throw this.#resolveError(
|
|
1094
|
-
spec,
|
|
1095
|
-
options,
|
|
1096
|
-
"file: specifier does not resolve to directory or tarball"
|
|
1097
|
-
);
|
|
1098
|
-
}
|
|
1099
|
-
return r;
|
|
1100
|
-
}
|
|
1101
|
-
case "workspace": {
|
|
1102
|
-
const ws = this.#getWS(spec, options);
|
|
1103
|
-
const rel = relative2(dirname2(target), ws.fullpath);
|
|
1104
|
-
await symlink(rel, target, "dir");
|
|
1105
|
-
return r;
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
#getWS(spec, options) {
|
|
1110
|
-
const { workspace } = spec;
|
|
1111
|
-
if (workspace === void 0)
|
|
1112
|
-
throw this.#resolveError(spec, options, "no workspace ID");
|
|
1113
|
-
if (!this.monorepo) {
|
|
1114
|
-
throw this.#resolveError(
|
|
1115
|
-
spec,
|
|
1116
|
-
options,
|
|
1117
|
-
"Not in a monorepo, cannot resolve workspace spec"
|
|
1118
|
-
);
|
|
1119
|
-
}
|
|
1120
|
-
const ws = this.monorepo.get(workspace);
|
|
1121
|
-
if (!ws) {
|
|
1122
|
-
throw this.#resolveError(spec, options, "workspace not found", {
|
|
1123
|
-
wanted: workspace
|
|
1124
|
-
});
|
|
1125
|
-
}
|
|
1126
|
-
return ws;
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
|
-
* Return the manifest cache key for a spec and the current options.
|
|
1130
|
-
*/
|
|
1131
|
-
#manifestCacheKey(spec, options) {
|
|
1132
|
-
let extra = "";
|
|
1133
|
-
if (options["node-version"]) {
|
|
1134
|
-
extra += `${delimiter}node-version:${options["node-version"]}`;
|
|
1135
|
-
}
|
|
1136
|
-
if (options.os) {
|
|
1137
|
-
extra += `${delimiter}os:${options.os}`;
|
|
1138
|
-
}
|
|
1139
|
-
if (options.arch) {
|
|
1140
|
-
extra += `${delimiter}arch:${options.arch}`;
|
|
1141
|
-
}
|
|
1142
|
-
return encodeURIComponent(
|
|
1143
|
-
`${spec.registry ?? ""}${delimiter}${spec}${extra}`
|
|
1144
|
-
);
|
|
1145
|
-
}
|
|
1146
|
-
/**
|
|
1147
|
-
* Conditionally return the path to the manifest cache file. The logic
|
|
1148
|
-
* to determine if caching should be skipped aligns with `pickManifest`
|
|
1149
|
-
* and is used to avoid caching manifest results that can be variable.
|
|
1150
|
-
*/
|
|
1151
|
-
_manifestCachePath(spec, options) {
|
|
1152
|
-
if (options.before) {
|
|
1153
|
-
return;
|
|
1154
|
-
}
|
|
1155
|
-
const f = spec.final;
|
|
1156
|
-
if (f.distTag || f.range?.isAny) {
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
const key = this.#manifestCacheKey(f, options);
|
|
1160
|
-
return pathResolve(this.#cachePath, "package-info", key);
|
|
1161
|
-
}
|
|
1162
|
-
async tarball(spec, options = {}) {
|
|
1163
|
-
if (typeof spec === "string")
|
|
1164
|
-
spec = Spec.parse(spec, this.options);
|
|
1165
|
-
const f = spec.final;
|
|
1166
|
-
switch (f.type) {
|
|
1167
|
-
case "registry": {
|
|
1168
|
-
const { dist } = await this.manifest(spec, options);
|
|
1169
|
-
if (!dist)
|
|
1170
|
-
throw this.#resolveError(
|
|
1171
|
-
spec,
|
|
1172
|
-
options,
|
|
1173
|
-
`The registry manifest for ${spec} has no "dist" section, so no tarball can be resolved. The package version may be malformed or unpublished.`
|
|
1174
|
-
);
|
|
1175
|
-
const { tarball, integrity } = dist;
|
|
1176
|
-
if (!tarball) {
|
|
1177
|
-
throw this.#resolveError(
|
|
1178
|
-
spec,
|
|
1179
|
-
options,
|
|
1180
|
-
`The registry manifest for ${spec} is missing a tarball URL (dist.tarball). The package version may be malformed or unpublished in this registry.`
|
|
1181
|
-
);
|
|
1182
|
-
}
|
|
1183
|
-
const fetchTarball = async (useCache) => {
|
|
1184
|
-
const trustIntegrity = this.#trustedIntegrities.get(tarball) === integrity;
|
|
1185
|
-
const response = await this.registryClient.request(
|
|
1186
|
-
tarball,
|
|
1187
|
-
{
|
|
1188
|
-
...options,
|
|
1189
|
-
integrity,
|
|
1190
|
-
trustIntegrity,
|
|
1191
|
-
...useCache === false ? { useCache } : {}
|
|
1192
|
-
}
|
|
1193
|
-
);
|
|
1194
|
-
if (response.statusCode !== 200) {
|
|
1195
|
-
throw this.#resolveError(
|
|
1196
|
-
spec,
|
|
1197
|
-
options,
|
|
1198
|
-
`Registry returned HTTP ${response.statusCode} when fetching the tarball for ${spec} at ${tarball}. The version may have been unpublished, or the registry may be misconfigured or unreachable.`,
|
|
1199
|
-
{ response, url: tarball }
|
|
1200
|
-
);
|
|
1201
|
-
}
|
|
1202
|
-
if (!trustIntegrity && response.checkIntegrity({ spec, url: tarball })) {
|
|
1203
|
-
this.#trustedIntegrities.set(tarball, response.integrity);
|
|
1204
|
-
}
|
|
1205
|
-
const buf = response.buffer();
|
|
1206
|
-
if (integrity) {
|
|
1207
|
-
const hash = createHash("sha512");
|
|
1208
|
-
hash.update(buf);
|
|
1209
|
-
const computed = `sha512-${hash.digest("base64")}`;
|
|
1210
|
-
if (computed !== integrity) {
|
|
1211
|
-
throw error("Tarball integrity check failed", {
|
|
1212
|
-
code: "EINTEGRITY",
|
|
1213
|
-
spec,
|
|
1214
|
-
url: tarball,
|
|
1215
|
-
wanted: integrity,
|
|
1216
|
-
found: computed
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
return buf;
|
|
1221
|
-
};
|
|
1222
|
-
try {
|
|
1223
|
-
return await fetchTarball();
|
|
1224
|
-
} catch (er) {
|
|
1225
|
-
if (er instanceof Error && "cause" in er && er.cause?.code === "EINTEGRITY") {
|
|
1226
|
-
return await fetchTarball(false);
|
|
1227
|
-
}
|
|
1228
|
-
throw er;
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
case "git": {
|
|
1232
|
-
const {
|
|
1233
|
-
remoteURL,
|
|
1234
|
-
gitRemote,
|
|
1235
|
-
gitCommittish,
|
|
1236
|
-
gitSelectorParsed
|
|
1237
|
-
} = f;
|
|
1238
|
-
const s = spec;
|
|
1239
|
-
if (!remoteURL) {
|
|
1240
|
-
if (!gitRemote) {
|
|
1241
|
-
throw this.#resolveError(
|
|
1242
|
-
spec,
|
|
1243
|
-
options,
|
|
1244
|
-
"no remote on git: specifier"
|
|
1245
|
-
);
|
|
1246
|
-
}
|
|
1247
|
-
const { path } = gitSelectorParsed ?? {};
|
|
1248
|
-
return await this.#tmpdir(async (dir) => {
|
|
1249
|
-
await clone(gitRemote, gitCommittish, dir + "/package", {
|
|
1250
|
-
spec: s
|
|
1251
|
-
});
|
|
1252
|
-
let cwd = dir;
|
|
1253
|
-
if (path !== void 0) {
|
|
1254
|
-
const src = pathResolve(dir, "package", path);
|
|
1255
|
-
cwd = dirname2(src);
|
|
1256
|
-
const pkg = pathResolve(cwd, "package");
|
|
1257
|
-
if (src !== pkg) {
|
|
1258
|
-
const rand = randomBytes2(6).toString("hex");
|
|
1259
|
-
await rename2(pkg, pkg + rand).catch(() => {
|
|
1260
|
-
});
|
|
1261
|
-
await rename2(src, pkg);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
return Qn({ cwd, gzip: true }, ["package"]).concat();
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
case "remote": {
|
|
1269
|
-
const { remoteURL } = f;
|
|
1270
|
-
if (!remoteURL) {
|
|
1271
|
-
throw this.#resolveError(spec, options);
|
|
1272
|
-
}
|
|
1273
|
-
const response = await this.registryClient.request(remoteURL);
|
|
1274
|
-
if (response.statusCode !== 200) {
|
|
1275
|
-
throw this.#resolveError(
|
|
1276
|
-
spec,
|
|
1277
|
-
options,
|
|
1278
|
-
"failed to fetch URL",
|
|
1279
|
-
{ response, url: remoteURL }
|
|
1280
|
-
);
|
|
1281
|
-
}
|
|
1282
|
-
return response.buffer();
|
|
1283
|
-
}
|
|
1284
|
-
case "file": {
|
|
1285
|
-
const { file } = f;
|
|
1286
|
-
if (file === void 0)
|
|
1287
|
-
throw this.#resolveError(spec, options, "no file path");
|
|
1288
|
-
const { from = this.#projectRoot } = options;
|
|
1289
|
-
const path = pathResolve(from, file);
|
|
1290
|
-
const st = await stat(path);
|
|
1291
|
-
if (st.isDirectory()) {
|
|
1292
|
-
const p = dirname2(path);
|
|
1293
|
-
const b = basename3(path);
|
|
1294
|
-
return Qn({ cwd: p, gzip: true }, [b]).concat();
|
|
1295
|
-
}
|
|
1296
|
-
return readFile(path);
|
|
1297
|
-
}
|
|
1298
|
-
case "workspace": {
|
|
1299
|
-
const ws = this.#getWS(spec, options);
|
|
1300
|
-
const p = dirname2(ws.fullpath);
|
|
1301
|
-
const b = basename3(ws.fullpath);
|
|
1302
|
-
return Qn({ cwd: p, gzip: true }, [b]).concat();
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
async manifest(spec, options = {}) {
|
|
1307
|
-
const { from = this.#projectRoot } = options;
|
|
1308
|
-
if (typeof spec === "string")
|
|
1309
|
-
spec = Spec.parse(spec, this.options);
|
|
1310
|
-
const f = spec.final;
|
|
1311
|
-
switch (f.type) {
|
|
1312
|
-
case "registry": {
|
|
1313
|
-
const cachePath = this._manifestCachePath(spec, options);
|
|
1314
|
-
if (cachePath) {
|
|
1315
|
-
try {
|
|
1316
|
-
const cached = await readFile(cachePath, "utf8");
|
|
1317
|
-
const json = JSON.parse(cached);
|
|
1318
|
-
const timestamp = json.__VLT_MANIFEST_CACHE_TIMESTAMP;
|
|
1319
|
-
delete json.__VLT_MANIFEST_CACHE_TIMESTAMP;
|
|
1320
|
-
if (timestamp != null && timestamp < this.#manifestCacheMinAge) {
|
|
1321
|
-
void unlink(cachePath).catch(() => {
|
|
1322
|
-
});
|
|
1323
|
-
throw new Error("manifest cache expired");
|
|
1324
|
-
}
|
|
1325
|
-
return json;
|
|
1326
|
-
} catch {
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
const mani = pickManifest(
|
|
1330
|
-
await this.packument(f, options),
|
|
1331
|
-
spec,
|
|
1332
|
-
options
|
|
1333
|
-
);
|
|
1334
|
-
if (!mani) throw this.#resolveError(spec, options);
|
|
1335
|
-
if (cachePath) {
|
|
1336
|
-
const json = JSON.stringify({
|
|
1337
|
-
...mani,
|
|
1338
|
-
// append a timestamp to the manifest so that we can quickly
|
|
1339
|
-
// check if the cache is still valid when loading it
|
|
1340
|
-
__VLT_MANIFEST_CACHE_TIMESTAMP: Date.now()
|
|
1341
|
-
});
|
|
1342
|
-
void writeFile2(cachePath, json, "utf8").catch(
|
|
1343
|
-
(err) => {
|
|
1344
|
-
if (err instanceof Error && "code" in err && err.code === "ENOENT") {
|
|
1345
|
-
void mkdir2(dirname2(cachePath), {
|
|
1346
|
-
recursive: true
|
|
1347
|
-
}).then(() => {
|
|
1348
|
-
void writeFile2(cachePath, json, "utf8");
|
|
1349
|
-
});
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
);
|
|
1353
|
-
}
|
|
1354
|
-
return mani;
|
|
1355
|
-
}
|
|
1356
|
-
case "git": {
|
|
1357
|
-
const {
|
|
1358
|
-
gitRemote,
|
|
1359
|
-
gitCommittish,
|
|
1360
|
-
remoteURL,
|
|
1361
|
-
gitSelectorParsed
|
|
1362
|
-
} = f;
|
|
1363
|
-
if (!remoteURL) {
|
|
1364
|
-
const s = spec;
|
|
1365
|
-
if (!gitRemote)
|
|
1366
|
-
throw this.#resolveError(spec, options, "no git remote");
|
|
1367
|
-
return await this.#tmpdir(async (dir) => {
|
|
1368
|
-
await clone(gitRemote, gitCommittish, dir, { spec: s });
|
|
1369
|
-
const { path } = gitSelectorParsed ?? {};
|
|
1370
|
-
const pkgDir = path !== void 0 ? pathResolve(dir, path) : dir;
|
|
1371
|
-
return this.#readExtracted(pkgDir, s, options);
|
|
1372
|
-
});
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
case "remote": {
|
|
1376
|
-
const { remoteURL } = f;
|
|
1377
|
-
if (!remoteURL) {
|
|
1378
|
-
throw this.#resolveError(
|
|
1379
|
-
spec,
|
|
1380
|
-
options,
|
|
1381
|
-
"no remoteURL on remote specifier"
|
|
1382
|
-
);
|
|
1383
|
-
}
|
|
1384
|
-
const s = spec;
|
|
1385
|
-
return await this.#tmpdir(async (dir) => {
|
|
1386
|
-
const response = await this.registryClient.request(remoteURL);
|
|
1387
|
-
if (response.statusCode !== 200) {
|
|
1388
|
-
throw this.#resolveError(
|
|
1389
|
-
s,
|
|
1390
|
-
options,
|
|
1391
|
-
"failed to fetch URL",
|
|
1392
|
-
{ response, url: remoteURL }
|
|
1393
|
-
);
|
|
1394
|
-
}
|
|
1395
|
-
const buf = response.buffer();
|
|
1396
|
-
const computed = import_ssri.default.fromData(buf, { algorithms: ["sha512"] }).toString();
|
|
1397
|
-
try {
|
|
1398
|
-
await this.tarPool.unpack(buf, dir);
|
|
1399
|
-
} catch (er) {
|
|
1400
|
-
throw this.#resolveError(
|
|
1401
|
-
s,
|
|
1402
|
-
options,
|
|
1403
|
-
"tar unpack failed",
|
|
1404
|
-
{ cause: er }
|
|
1405
|
-
);
|
|
1406
|
-
}
|
|
1407
|
-
const mani = this.#readExtracted(dir, s, options);
|
|
1408
|
-
mani.dist = { integrity: computed };
|
|
1409
|
-
return mani;
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
case "file": {
|
|
1413
|
-
const { file } = f;
|
|
1414
|
-
if (file === void 0)
|
|
1415
|
-
throw this.#resolveError(spec, options, "no file path");
|
|
1416
|
-
const path = pathResolve(from, file);
|
|
1417
|
-
const st = await stat(path);
|
|
1418
|
-
if (st.isDirectory()) {
|
|
1419
|
-
return this.packageJson.read(path);
|
|
1420
|
-
}
|
|
1421
|
-
const s = spec;
|
|
1422
|
-
return await this.#tmpdir(async (dir) => {
|
|
1423
|
-
try {
|
|
1424
|
-
await this.tarPool.unpack(await readFile(path), dir);
|
|
1425
|
-
} catch (er) {
|
|
1426
|
-
throw this.#resolveError(
|
|
1427
|
-
s,
|
|
1428
|
-
options,
|
|
1429
|
-
"tar unpack failed",
|
|
1430
|
-
{ cause: er }
|
|
1431
|
-
);
|
|
1432
|
-
}
|
|
1433
|
-
return this.#readExtracted(dir, s, options);
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
case "workspace": {
|
|
1437
|
-
return this.#getWS(spec, options).manifest;
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
async packument(spec, options = {}) {
|
|
1442
|
-
if (typeof spec === "string")
|
|
1443
|
-
spec = Spec.parse(spec, this.options);
|
|
1444
|
-
const f = spec.final;
|
|
1445
|
-
switch (f.type) {
|
|
1446
|
-
// RevDoc is the equivalent of a packument for a git repo
|
|
1447
|
-
case "git": {
|
|
1448
|
-
const { gitRemote } = f;
|
|
1449
|
-
if (!gitRemote) {
|
|
1450
|
-
throw this.#resolveError(
|
|
1451
|
-
spec,
|
|
1452
|
-
options,
|
|
1453
|
-
"git remote could not be determined"
|
|
1454
|
-
);
|
|
1455
|
-
}
|
|
1456
|
-
const revDoc = await revs(gitRemote, {
|
|
1457
|
-
cwd: this.options.projectRoot
|
|
1458
|
-
});
|
|
1459
|
-
if (!revDoc) throw this.#resolveError(spec, options);
|
|
1460
|
-
return asPackument(revDoc);
|
|
1461
|
-
}
|
|
1462
|
-
// these are all faked packuments
|
|
1463
|
-
case "file":
|
|
1464
|
-
case "workspace":
|
|
1465
|
-
case "remote": {
|
|
1466
|
-
const manifest = await this.manifest(f, options);
|
|
1467
|
-
return {
|
|
1468
|
-
name: manifest.name ?? "",
|
|
1469
|
-
"dist-tags": {
|
|
1470
|
-
latest: manifest.version ?? ""
|
|
1471
|
-
},
|
|
1472
|
-
versions: {
|
|
1473
|
-
[manifest.version ?? ""]: manifest
|
|
1474
|
-
}
|
|
1475
|
-
};
|
|
1476
|
-
}
|
|
1477
|
-
case "registry": {
|
|
1478
|
-
const { registry, name: name2 } = f;
|
|
1479
|
-
if (!registry) throw noRegistryError(spec);
|
|
1480
|
-
const packumentKey = `${registry}${name2}`;
|
|
1481
|
-
const inflight = this.#packumentPromises.get(packumentKey);
|
|
1482
|
-
if (inflight) return inflight;
|
|
1483
|
-
const pakuURL = new URL(name2, registry);
|
|
1484
|
-
const promise = this.#fetchPackument(spec, options, pakuURL);
|
|
1485
|
-
this.#packumentPromises.set(packumentKey, promise);
|
|
1486
|
-
promise.then(
|
|
1487
|
-
() => this.#packumentPromises.delete(packumentKey),
|
|
1488
|
-
() => this.#packumentPromises.delete(packumentKey)
|
|
1489
|
-
);
|
|
1490
|
-
return promise;
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
async #fetchPackument(spec, options, pakuURL) {
|
|
1495
|
-
const response = await this.registryClient.request(pakuURL, {
|
|
1496
|
-
headers: { accept: "application/json" }
|
|
1497
|
-
});
|
|
1498
|
-
if (response.statusCode !== 200) {
|
|
1499
|
-
throw this.#resolveError(
|
|
1500
|
-
spec,
|
|
1501
|
-
options,
|
|
1502
|
-
"failed to fetch packument",
|
|
1503
|
-
{
|
|
1504
|
-
url: pakuURL,
|
|
1505
|
-
response
|
|
1506
|
-
}
|
|
1507
|
-
);
|
|
1508
|
-
}
|
|
1509
|
-
return response.json();
|
|
1510
|
-
}
|
|
1511
|
-
async resolve(spec, options = {}) {
|
|
1512
|
-
const memoKey = String(spec);
|
|
1513
|
-
if (typeof spec === "string")
|
|
1514
|
-
spec = Spec.parse(spec, this.options);
|
|
1515
|
-
const memo = this.#resolutions.get(memoKey);
|
|
1516
|
-
if (memo) return memo;
|
|
1517
|
-
const f = spec.final;
|
|
1518
|
-
switch (f.type) {
|
|
1519
|
-
case "file": {
|
|
1520
|
-
const { file } = f;
|
|
1521
|
-
if (!file || !f.file) {
|
|
1522
|
-
throw this.#resolveError(
|
|
1523
|
-
spec,
|
|
1524
|
-
options,
|
|
1525
|
-
"no path on file: specifier"
|
|
1526
|
-
);
|
|
1527
|
-
}
|
|
1528
|
-
const { from = this.#projectRoot } = options;
|
|
1529
|
-
const resolved = pathResolve(from, f.file);
|
|
1530
|
-
const r = { resolved, spec };
|
|
1531
|
-
this.#resolutions.set(memoKey, r);
|
|
1532
|
-
return r;
|
|
1533
|
-
}
|
|
1534
|
-
case "remote": {
|
|
1535
|
-
const { remoteURL } = f;
|
|
1536
|
-
if (!remoteURL)
|
|
1537
|
-
throw this.#resolveError(
|
|
1538
|
-
spec,
|
|
1539
|
-
options,
|
|
1540
|
-
"no URL in remote specifier"
|
|
1541
|
-
);
|
|
1542
|
-
const r = { resolved: remoteURL, spec };
|
|
1543
|
-
this.#resolutions.set(memoKey, r);
|
|
1544
|
-
return r;
|
|
1545
|
-
}
|
|
1546
|
-
case "workspace": {
|
|
1547
|
-
const ws = this.#getWS(spec, options);
|
|
1548
|
-
return {
|
|
1549
|
-
resolved: ws.fullpath,
|
|
1550
|
-
spec
|
|
1551
|
-
};
|
|
1552
|
-
}
|
|
1553
|
-
case "registry": {
|
|
1554
|
-
const mani = await this.manifest(spec, options);
|
|
1555
|
-
if (mani.dist) {
|
|
1556
|
-
const { integrity, tarball, signatures } = mani.dist;
|
|
1557
|
-
if (tarball) {
|
|
1558
|
-
const r = {
|
|
1559
|
-
resolved: tarball,
|
|
1560
|
-
integrity,
|
|
1561
|
-
signatures,
|
|
1562
|
-
spec
|
|
1563
|
-
};
|
|
1564
|
-
this.#resolutions.set(memoKey, r);
|
|
1565
|
-
return r;
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
throw this.#resolveError(spec, options);
|
|
1569
|
-
}
|
|
1570
|
-
case "git": {
|
|
1571
|
-
const { gitRemote, remoteURL, gitSelectorParsed } = f;
|
|
1572
|
-
if (remoteURL && gitSelectorParsed?.path === void 0) {
|
|
1573
|
-
const r = { resolved: remoteURL, spec };
|
|
1574
|
-
this.#resolutions.set(memoKey, r);
|
|
1575
|
-
return r;
|
|
1576
|
-
}
|
|
1577
|
-
if (!gitRemote) {
|
|
1578
|
-
throw this.#resolveError(
|
|
1579
|
-
spec,
|
|
1580
|
-
options,
|
|
1581
|
-
"no remote on git specifier"
|
|
1582
|
-
);
|
|
1583
|
-
}
|
|
1584
|
-
const rev = await resolve(gitRemote, f.gitCommittish, {
|
|
1585
|
-
spec
|
|
1586
|
-
});
|
|
1587
|
-
if (rev) {
|
|
1588
|
-
const r = {
|
|
1589
|
-
resolved: `${gitRemote}#${rev.sha}`,
|
|
1590
|
-
spec
|
|
1591
|
-
};
|
|
1592
|
-
if (gitSelectorParsed) {
|
|
1593
|
-
r.resolved += Object.entries(gitSelectorParsed).filter(([_, v]) => v).map(([k, v]) => `::${k}:${v}`).join("");
|
|
1594
|
-
}
|
|
1595
|
-
this.#resolutions.set(memoKey, r);
|
|
1596
|
-
return r;
|
|
1597
|
-
}
|
|
1598
|
-
const s = spec;
|
|
1599
|
-
return this.#tmpdir(async (tmpdir) => {
|
|
1600
|
-
const sha = await clone(
|
|
1601
|
-
gitRemote,
|
|
1602
|
-
s.gitCommittish,
|
|
1603
|
-
tmpdir,
|
|
1604
|
-
{
|
|
1605
|
-
spec: s
|
|
1606
|
-
}
|
|
1607
|
-
);
|
|
1608
|
-
const r = {
|
|
1609
|
-
resolved: `${gitRemote}#${sha}`,
|
|
1610
|
-
spec: s
|
|
1611
|
-
};
|
|
1612
|
-
this.#resolutions.set(memoKey, r);
|
|
1613
|
-
return r;
|
|
1614
|
-
});
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
* Read the manifest out of a directory we cloned or unpacked. Failures are
|
|
1620
|
-
* labeled with the spec, because the internal directory says nothing about
|
|
1621
|
-
* which dependency is at fault.
|
|
1622
|
-
*/
|
|
1623
|
-
#readExtracted(dir, spec, options) {
|
|
1624
|
-
try {
|
|
1625
|
-
return this.packageJson.read(dir);
|
|
1626
|
-
} catch (er) {
|
|
1627
|
-
throw this.#resolveError(
|
|
1628
|
-
spec,
|
|
1629
|
-
options,
|
|
1630
|
-
"invalid package manifest",
|
|
1631
|
-
{ cause: er }
|
|
1632
|
-
);
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
async #tmpdir(fn) {
|
|
1636
|
-
const p = `package-info/${randomBytes2(6).toString("hex")}`;
|
|
1637
|
-
const dir = xdg.runtime(p);
|
|
1638
|
-
try {
|
|
1639
|
-
return await fn(dir);
|
|
1640
|
-
} finally {
|
|
1641
|
-
void rm2(dir, { recursive: true, force: true });
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
// error resolving
|
|
1645
|
-
#resolveError(spec, options = {}, message = "Could not resolve", extra = {}) {
|
|
1646
|
-
const { from = this.#projectRoot } = options;
|
|
1647
|
-
const er = error(
|
|
1648
|
-
message,
|
|
1649
|
-
{
|
|
1650
|
-
code: "ERESOLVE",
|
|
1651
|
-
spec,
|
|
1652
|
-
from,
|
|
1653
|
-
...extra
|
|
1654
|
-
},
|
|
1655
|
-
this.#resolveError
|
|
1656
|
-
);
|
|
1657
|
-
return er;
|
|
1658
|
-
}
|
|
1659
|
-
};
|
|
1660
|
-
|
|
1661
|
-
export {
|
|
1662
|
-
PackageInfoClient
|
|
1663
|
-
};
|