create-blaze 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3353 -0
- package/package.json +28 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3353 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import {
|
|
5
|
+
createWriteStream,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
readFileSync,
|
|
8
|
+
readdirSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
statSync,
|
|
11
|
+
writeFileSync
|
|
12
|
+
} from "node:fs";
|
|
13
|
+
import { get } from "node:https";
|
|
14
|
+
import { tmpdir } from "node:os";
|
|
15
|
+
import { basename, extname, join } from "node:path";
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/.bun/tar@7.5.13/node_modules/tar/dist/esm/index.min.js
|
|
18
|
+
import Kr from "events";
|
|
19
|
+
import I from "fs";
|
|
20
|
+
import { EventEmitter as Ti } from "node:events";
|
|
21
|
+
import Ns from "node:stream";
|
|
22
|
+
import { StringDecoder as Mr } from "node:string_decoder";
|
|
23
|
+
import nr from "node:path";
|
|
24
|
+
import Vt from "node:fs";
|
|
25
|
+
import { dirname as xn, parse as Ln } from "path";
|
|
26
|
+
import { EventEmitter as _n } from "events";
|
|
27
|
+
import Mi from "assert";
|
|
28
|
+
import { Buffer as gt } from "buffer";
|
|
29
|
+
import * as ks from "zlib";
|
|
30
|
+
import qr from "zlib";
|
|
31
|
+
import { posix as Zt } from "node:path";
|
|
32
|
+
import { basename as wn } from "node:path";
|
|
33
|
+
import fi from "fs";
|
|
34
|
+
import $ from "fs";
|
|
35
|
+
import $s from "path";
|
|
36
|
+
import { win32 as In } from "node:path";
|
|
37
|
+
import sr from "path";
|
|
38
|
+
import Cr from "node:fs";
|
|
39
|
+
import so from "node:assert";
|
|
40
|
+
import { randomBytes as Ir } from "node:crypto";
|
|
41
|
+
import u from "node:fs";
|
|
42
|
+
import R from "node:path";
|
|
43
|
+
import cr from "fs";
|
|
44
|
+
import mi from "node:fs";
|
|
45
|
+
import Ee from "node:path";
|
|
46
|
+
import k from "node:fs";
|
|
47
|
+
import jn from "node:fs/promises";
|
|
48
|
+
import pi from "node:path";
|
|
49
|
+
import { join as br } from "node:path";
|
|
50
|
+
import v from "node:fs";
|
|
51
|
+
import Fr from "node:path";
|
|
52
|
+
var kr = Object.defineProperty;
|
|
53
|
+
var vr = (s, t) => {
|
|
54
|
+
for (var e in t)
|
|
55
|
+
kr(s, e, { get: t[e], enumerable: true });
|
|
56
|
+
};
|
|
57
|
+
var Os = typeof process == "object" && process ? process : { stdout: null, stderr: null };
|
|
58
|
+
var Br = (s) => !!s && typeof s == "object" && (s instanceof D || s instanceof Ns || Pr(s) || zr(s));
|
|
59
|
+
var Pr = (s) => !!s && typeof s == "object" && s instanceof Ti && typeof s.pipe == "function" && s.pipe !== Ns.Writable.prototype.pipe;
|
|
60
|
+
var zr = (s) => !!s && typeof s == "object" && s instanceof Ti && typeof s.write == "function" && typeof s.end == "function";
|
|
61
|
+
var q = Symbol("EOF");
|
|
62
|
+
var j = Symbol("maybeEmitEnd");
|
|
63
|
+
var rt = Symbol("emittedEnd");
|
|
64
|
+
var Le = Symbol("emittingEnd");
|
|
65
|
+
var jt = Symbol("emittedError");
|
|
66
|
+
var Ne = Symbol("closed");
|
|
67
|
+
var Ts = Symbol("read");
|
|
68
|
+
var Ae = Symbol("flush");
|
|
69
|
+
var xs = Symbol("flushChunk");
|
|
70
|
+
var z = Symbol("encoding");
|
|
71
|
+
var Mt = Symbol("decoder");
|
|
72
|
+
var b = Symbol("flowing");
|
|
73
|
+
var Qt = Symbol("paused");
|
|
74
|
+
var Bt = Symbol("resume");
|
|
75
|
+
var _ = Symbol("buffer");
|
|
76
|
+
var A = Symbol("pipes");
|
|
77
|
+
var g = Symbol("bufferLength");
|
|
78
|
+
var yi = Symbol("bufferPush");
|
|
79
|
+
var De = Symbol("bufferShift");
|
|
80
|
+
var L = Symbol("objectMode");
|
|
81
|
+
var w = Symbol("destroyed");
|
|
82
|
+
var Ri = Symbol("error");
|
|
83
|
+
var bi = Symbol("emitData");
|
|
84
|
+
var Ls = Symbol("emitEnd");
|
|
85
|
+
var _i = Symbol("emitEnd2");
|
|
86
|
+
var Z = Symbol("async");
|
|
87
|
+
var gi = Symbol("abort");
|
|
88
|
+
var Ie = Symbol("aborted");
|
|
89
|
+
var Jt = Symbol("signal");
|
|
90
|
+
var yt = Symbol("dataListeners");
|
|
91
|
+
var C = Symbol("discarded");
|
|
92
|
+
var te = (s) => Promise.resolve().then(s);
|
|
93
|
+
var Ur = (s) => s();
|
|
94
|
+
var Hr = (s) => s === "end" || s === "finish" || s === "prefinish";
|
|
95
|
+
var Wr = (s) => s instanceof ArrayBuffer || !!s && typeof s == "object" && s.constructor && s.constructor.name === "ArrayBuffer" && s.byteLength >= 0;
|
|
96
|
+
var Gr = (s) => !Buffer.isBuffer(s) && ArrayBuffer.isView(s);
|
|
97
|
+
var Ce = class {
|
|
98
|
+
src;
|
|
99
|
+
dest;
|
|
100
|
+
opts;
|
|
101
|
+
ondrain;
|
|
102
|
+
constructor(t, e, i) {
|
|
103
|
+
this.src = t, this.dest = e, this.opts = i, this.ondrain = () => t[Bt](), this.dest.on("drain", this.ondrain);
|
|
104
|
+
}
|
|
105
|
+
unpipe() {
|
|
106
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
107
|
+
}
|
|
108
|
+
proxyErrors(t) {}
|
|
109
|
+
end() {
|
|
110
|
+
this.unpipe(), this.opts.end && this.dest.end();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var Oi = class extends Ce {
|
|
114
|
+
unpipe() {
|
|
115
|
+
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
116
|
+
}
|
|
117
|
+
constructor(t, e, i) {
|
|
118
|
+
super(t, e, i), this.proxyErrors = (r) => this.dest.emit("error", r), t.on("error", this.proxyErrors);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var Zr = (s) => !!s.objectMode;
|
|
122
|
+
var Yr = (s) => !s.objectMode && !!s.encoding && s.encoding !== "buffer";
|
|
123
|
+
var D = class extends Ti {
|
|
124
|
+
[b] = false;
|
|
125
|
+
[Qt] = false;
|
|
126
|
+
[A] = [];
|
|
127
|
+
[_] = [];
|
|
128
|
+
[L];
|
|
129
|
+
[z];
|
|
130
|
+
[Z];
|
|
131
|
+
[Mt];
|
|
132
|
+
[q] = false;
|
|
133
|
+
[rt] = false;
|
|
134
|
+
[Le] = false;
|
|
135
|
+
[Ne] = false;
|
|
136
|
+
[jt] = null;
|
|
137
|
+
[g] = 0;
|
|
138
|
+
[w] = false;
|
|
139
|
+
[Jt];
|
|
140
|
+
[Ie] = false;
|
|
141
|
+
[yt] = 0;
|
|
142
|
+
[C] = false;
|
|
143
|
+
writable = true;
|
|
144
|
+
readable = true;
|
|
145
|
+
constructor(...t) {
|
|
146
|
+
let e = t[0] || {};
|
|
147
|
+
if (super(), e.objectMode && typeof e.encoding == "string")
|
|
148
|
+
throw new TypeError("Encoding and objectMode may not be used together");
|
|
149
|
+
Zr(e) ? (this[L] = true, this[z] = null) : Yr(e) ? (this[z] = e.encoding, this[L] = false) : (this[L] = false, this[z] = null), this[Z] = !!e.async, this[Mt] = this[z] ? new Mr(this[z]) : null, e && e.debugExposeBuffer === true && Object.defineProperty(this, "buffer", { get: () => this[_] }), e && e.debugExposePipes === true && Object.defineProperty(this, "pipes", { get: () => this[A] });
|
|
150
|
+
let { signal: i } = e;
|
|
151
|
+
i && (this[Jt] = i, i.aborted ? this[gi]() : i.addEventListener("abort", () => this[gi]()));
|
|
152
|
+
}
|
|
153
|
+
get bufferLength() {
|
|
154
|
+
return this[g];
|
|
155
|
+
}
|
|
156
|
+
get encoding() {
|
|
157
|
+
return this[z];
|
|
158
|
+
}
|
|
159
|
+
set encoding(t) {
|
|
160
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
161
|
+
}
|
|
162
|
+
setEncoding(t) {
|
|
163
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
164
|
+
}
|
|
165
|
+
get objectMode() {
|
|
166
|
+
return this[L];
|
|
167
|
+
}
|
|
168
|
+
set objectMode(t) {
|
|
169
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
170
|
+
}
|
|
171
|
+
get async() {
|
|
172
|
+
return this[Z];
|
|
173
|
+
}
|
|
174
|
+
set async(t) {
|
|
175
|
+
this[Z] = this[Z] || !!t;
|
|
176
|
+
}
|
|
177
|
+
[gi]() {
|
|
178
|
+
this[Ie] = true, this.emit("abort", this[Jt]?.reason), this.destroy(this[Jt]?.reason);
|
|
179
|
+
}
|
|
180
|
+
get aborted() {
|
|
181
|
+
return this[Ie];
|
|
182
|
+
}
|
|
183
|
+
set aborted(t) {}
|
|
184
|
+
write(t, e, i) {
|
|
185
|
+
if (this[Ie])
|
|
186
|
+
return false;
|
|
187
|
+
if (this[q])
|
|
188
|
+
throw new Error("write after end");
|
|
189
|
+
if (this[w])
|
|
190
|
+
return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), true;
|
|
191
|
+
typeof e == "function" && (i = e, e = "utf8"), e || (e = "utf8");
|
|
192
|
+
let r = this[Z] ? te : Ur;
|
|
193
|
+
if (!this[L] && !Buffer.isBuffer(t)) {
|
|
194
|
+
if (Gr(t))
|
|
195
|
+
t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
|
|
196
|
+
else if (Wr(t))
|
|
197
|
+
t = Buffer.from(t);
|
|
198
|
+
else if (typeof t != "string")
|
|
199
|
+
throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
200
|
+
}
|
|
201
|
+
return this[L] ? (this[b] && this[g] !== 0 && this[Ae](true), this[b] ? this.emit("data", t) : this[yi](t), this[g] !== 0 && this.emit("readable"), i && r(i), this[b]) : t.length ? (typeof t == "string" && !(e === this[z] && !this[Mt]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[Mt].write(t)), this[b] && this[g] !== 0 && this[Ae](true), this[b] ? this.emit("data", t) : this[yi](t), this[g] !== 0 && this.emit("readable"), i && r(i), this[b]) : (this[g] !== 0 && this.emit("readable"), i && r(i), this[b]);
|
|
202
|
+
}
|
|
203
|
+
read(t) {
|
|
204
|
+
if (this[w])
|
|
205
|
+
return null;
|
|
206
|
+
if (this[C] = false, this[g] === 0 || t === 0 || t && t > this[g])
|
|
207
|
+
return this[j](), null;
|
|
208
|
+
this[L] && (t = null), this[_].length > 1 && !this[L] && (this[_] = [this[z] ? this[_].join("") : Buffer.concat(this[_], this[g])]);
|
|
209
|
+
let e = this[Ts](t || null, this[_][0]);
|
|
210
|
+
return this[j](), e;
|
|
211
|
+
}
|
|
212
|
+
[Ts](t, e) {
|
|
213
|
+
if (this[L])
|
|
214
|
+
this[De]();
|
|
215
|
+
else {
|
|
216
|
+
let i = e;
|
|
217
|
+
t === i.length || t === null ? this[De]() : typeof i == "string" ? (this[_][0] = i.slice(t), e = i.slice(0, t), this[g] -= t) : (this[_][0] = i.subarray(t), e = i.subarray(0, t), this[g] -= t);
|
|
218
|
+
}
|
|
219
|
+
return this.emit("data", e), !this[_].length && !this[q] && this.emit("drain"), e;
|
|
220
|
+
}
|
|
221
|
+
end(t, e, i) {
|
|
222
|
+
return typeof t == "function" && (i = t, t = undefined), typeof e == "function" && (i = e, e = "utf8"), t !== undefined && this.write(t, e), i && this.once("end", i), this[q] = true, this.writable = false, (this[b] || !this[Qt]) && this[j](), this;
|
|
223
|
+
}
|
|
224
|
+
[Bt]() {
|
|
225
|
+
this[w] || (!this[yt] && !this[A].length && (this[C] = true), this[Qt] = false, this[b] = true, this.emit("resume"), this[_].length ? this[Ae]() : this[q] ? this[j]() : this.emit("drain"));
|
|
226
|
+
}
|
|
227
|
+
resume() {
|
|
228
|
+
return this[Bt]();
|
|
229
|
+
}
|
|
230
|
+
pause() {
|
|
231
|
+
this[b] = false, this[Qt] = true, this[C] = false;
|
|
232
|
+
}
|
|
233
|
+
get destroyed() {
|
|
234
|
+
return this[w];
|
|
235
|
+
}
|
|
236
|
+
get flowing() {
|
|
237
|
+
return this[b];
|
|
238
|
+
}
|
|
239
|
+
get paused() {
|
|
240
|
+
return this[Qt];
|
|
241
|
+
}
|
|
242
|
+
[yi](t) {
|
|
243
|
+
this[L] ? this[g] += 1 : this[g] += t.length, this[_].push(t);
|
|
244
|
+
}
|
|
245
|
+
[De]() {
|
|
246
|
+
return this[L] ? this[g] -= 1 : this[g] -= this[_][0].length, this[_].shift();
|
|
247
|
+
}
|
|
248
|
+
[Ae](t = false) {
|
|
249
|
+
do
|
|
250
|
+
;
|
|
251
|
+
while (this[xs](this[De]()) && this[_].length);
|
|
252
|
+
!t && !this[_].length && !this[q] && this.emit("drain");
|
|
253
|
+
}
|
|
254
|
+
[xs](t) {
|
|
255
|
+
return this.emit("data", t), this[b];
|
|
256
|
+
}
|
|
257
|
+
pipe(t, e) {
|
|
258
|
+
if (this[w])
|
|
259
|
+
return t;
|
|
260
|
+
this[C] = false;
|
|
261
|
+
let i = this[rt];
|
|
262
|
+
return e = e || {}, t === Os.stdout || t === Os.stderr ? e.end = false : e.end = e.end !== false, e.proxyErrors = !!e.proxyErrors, i ? e.end && t.end() : (this[A].push(e.proxyErrors ? new Oi(this, t, e) : new Ce(this, t, e)), this[Z] ? te(() => this[Bt]()) : this[Bt]()), t;
|
|
263
|
+
}
|
|
264
|
+
unpipe(t) {
|
|
265
|
+
let e = this[A].find((i) => i.dest === t);
|
|
266
|
+
e && (this[A].length === 1 ? (this[b] && this[yt] === 0 && (this[b] = false), this[A] = []) : this[A].splice(this[A].indexOf(e), 1), e.unpipe());
|
|
267
|
+
}
|
|
268
|
+
addListener(t, e) {
|
|
269
|
+
return this.on(t, e);
|
|
270
|
+
}
|
|
271
|
+
on(t, e) {
|
|
272
|
+
let i = super.on(t, e);
|
|
273
|
+
if (t === "data")
|
|
274
|
+
this[C] = false, this[yt]++, !this[A].length && !this[b] && this[Bt]();
|
|
275
|
+
else if (t === "readable" && this[g] !== 0)
|
|
276
|
+
super.emit("readable");
|
|
277
|
+
else if (Hr(t) && this[rt])
|
|
278
|
+
super.emit(t), this.removeAllListeners(t);
|
|
279
|
+
else if (t === "error" && this[jt]) {
|
|
280
|
+
let r = e;
|
|
281
|
+
this[Z] ? te(() => r.call(this, this[jt])) : r.call(this, this[jt]);
|
|
282
|
+
}
|
|
283
|
+
return i;
|
|
284
|
+
}
|
|
285
|
+
removeListener(t, e) {
|
|
286
|
+
return this.off(t, e);
|
|
287
|
+
}
|
|
288
|
+
off(t, e) {
|
|
289
|
+
let i = super.off(t, e);
|
|
290
|
+
return t === "data" && (this[yt] = this.listeners("data").length, this[yt] === 0 && !this[C] && !this[A].length && (this[b] = false)), i;
|
|
291
|
+
}
|
|
292
|
+
removeAllListeners(t) {
|
|
293
|
+
let e = super.removeAllListeners(t);
|
|
294
|
+
return (t === "data" || t === undefined) && (this[yt] = 0, !this[C] && !this[A].length && (this[b] = false)), e;
|
|
295
|
+
}
|
|
296
|
+
get emittedEnd() {
|
|
297
|
+
return this[rt];
|
|
298
|
+
}
|
|
299
|
+
[j]() {
|
|
300
|
+
!this[Le] && !this[rt] && !this[w] && this[_].length === 0 && this[q] && (this[Le] = true, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Ne] && this.emit("close"), this[Le] = false);
|
|
301
|
+
}
|
|
302
|
+
emit(t, ...e) {
|
|
303
|
+
let i = e[0];
|
|
304
|
+
if (t !== "error" && t !== "close" && t !== w && this[w])
|
|
305
|
+
return false;
|
|
306
|
+
if (t === "data")
|
|
307
|
+
return !this[L] && !i ? false : this[Z] ? (te(() => this[bi](i)), true) : this[bi](i);
|
|
308
|
+
if (t === "end")
|
|
309
|
+
return this[Ls]();
|
|
310
|
+
if (t === "close") {
|
|
311
|
+
if (this[Ne] = true, !this[rt] && !this[w])
|
|
312
|
+
return false;
|
|
313
|
+
let n = super.emit("close");
|
|
314
|
+
return this.removeAllListeners("close"), n;
|
|
315
|
+
} else if (t === "error") {
|
|
316
|
+
this[jt] = i, super.emit(Ri, i);
|
|
317
|
+
let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : false;
|
|
318
|
+
return this[j](), n;
|
|
319
|
+
} else if (t === "resume") {
|
|
320
|
+
let n = super.emit("resume");
|
|
321
|
+
return this[j](), n;
|
|
322
|
+
} else if (t === "finish" || t === "prefinish") {
|
|
323
|
+
let n = super.emit(t);
|
|
324
|
+
return this.removeAllListeners(t), n;
|
|
325
|
+
}
|
|
326
|
+
let r = super.emit(t, ...e);
|
|
327
|
+
return this[j](), r;
|
|
328
|
+
}
|
|
329
|
+
[bi](t) {
|
|
330
|
+
for (let i of this[A])
|
|
331
|
+
i.dest.write(t) === false && this.pause();
|
|
332
|
+
let e = this[C] ? false : super.emit("data", t);
|
|
333
|
+
return this[j](), e;
|
|
334
|
+
}
|
|
335
|
+
[Ls]() {
|
|
336
|
+
return this[rt] ? false : (this[rt] = true, this.readable = false, this[Z] ? (te(() => this[_i]()), true) : this[_i]());
|
|
337
|
+
}
|
|
338
|
+
[_i]() {
|
|
339
|
+
if (this[Mt]) {
|
|
340
|
+
let e = this[Mt].end();
|
|
341
|
+
if (e) {
|
|
342
|
+
for (let i of this[A])
|
|
343
|
+
i.dest.write(e);
|
|
344
|
+
this[C] || super.emit("data", e);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
for (let e of this[A])
|
|
348
|
+
e.end();
|
|
349
|
+
let t = super.emit("end");
|
|
350
|
+
return this.removeAllListeners("end"), t;
|
|
351
|
+
}
|
|
352
|
+
async collect() {
|
|
353
|
+
let t = Object.assign([], { dataLength: 0 });
|
|
354
|
+
this[L] || (t.dataLength = 0);
|
|
355
|
+
let e = this.promise();
|
|
356
|
+
return this.on("data", (i) => {
|
|
357
|
+
t.push(i), this[L] || (t.dataLength += i.length);
|
|
358
|
+
}), await e, t;
|
|
359
|
+
}
|
|
360
|
+
async concat() {
|
|
361
|
+
if (this[L])
|
|
362
|
+
throw new Error("cannot concat in objectMode");
|
|
363
|
+
let t = await this.collect();
|
|
364
|
+
return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
|
|
365
|
+
}
|
|
366
|
+
async promise() {
|
|
367
|
+
return new Promise((t, e) => {
|
|
368
|
+
this.on(w, () => e(new Error("stream destroyed"))), this.on("error", (i) => e(i)), this.on("end", () => t());
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
[Symbol.asyncIterator]() {
|
|
372
|
+
this[C] = false;
|
|
373
|
+
let t = false, e = async () => (this.pause(), t = true, { value: undefined, done: true });
|
|
374
|
+
return { next: () => {
|
|
375
|
+
if (t)
|
|
376
|
+
return e();
|
|
377
|
+
let r = this.read();
|
|
378
|
+
if (r !== null)
|
|
379
|
+
return Promise.resolve({ done: false, value: r });
|
|
380
|
+
if (this[q])
|
|
381
|
+
return e();
|
|
382
|
+
let n, o, h = (d) => {
|
|
383
|
+
this.off("data", a), this.off("end", l), this.off(w, c), e(), o(d);
|
|
384
|
+
}, a = (d) => {
|
|
385
|
+
this.off("error", h), this.off("end", l), this.off(w, c), this.pause(), n({ value: d, done: !!this[q] });
|
|
386
|
+
}, l = () => {
|
|
387
|
+
this.off("error", h), this.off("data", a), this.off(w, c), e(), n({ done: true, value: undefined });
|
|
388
|
+
}, c = () => h(new Error("stream destroyed"));
|
|
389
|
+
return new Promise((d, S) => {
|
|
390
|
+
o = S, n = d, this.once(w, c), this.once("error", h), this.once("end", l), this.once("data", a);
|
|
391
|
+
});
|
|
392
|
+
}, throw: e, return: e, [Symbol.asyncIterator]() {
|
|
393
|
+
return this;
|
|
394
|
+
}, [Symbol.asyncDispose]: async () => {} };
|
|
395
|
+
}
|
|
396
|
+
[Symbol.iterator]() {
|
|
397
|
+
this[C] = false;
|
|
398
|
+
let t = false, e = () => (this.pause(), this.off(Ri, e), this.off(w, e), this.off("end", e), t = true, { done: true, value: undefined }), i = () => {
|
|
399
|
+
if (t)
|
|
400
|
+
return e();
|
|
401
|
+
let r = this.read();
|
|
402
|
+
return r === null ? e() : { done: false, value: r };
|
|
403
|
+
};
|
|
404
|
+
return this.once("end", e), this.once(Ri, e), this.once(w, e), { next: i, throw: e, return: e, [Symbol.iterator]() {
|
|
405
|
+
return this;
|
|
406
|
+
}, [Symbol.dispose]: () => {} };
|
|
407
|
+
}
|
|
408
|
+
destroy(t) {
|
|
409
|
+
if (this[w])
|
|
410
|
+
return t ? this.emit("error", t) : this.emit(w), this;
|
|
411
|
+
this[w] = true, this[C] = true, this[_].length = 0, this[g] = 0;
|
|
412
|
+
let e = this;
|
|
413
|
+
return typeof e.close == "function" && !this[Ne] && e.close(), t ? this.emit("error", t) : this.emit(w), this;
|
|
414
|
+
}
|
|
415
|
+
static get isStream() {
|
|
416
|
+
return Br;
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
var Vr = I.writev;
|
|
420
|
+
var ot = Symbol("_autoClose");
|
|
421
|
+
var H = Symbol("_close");
|
|
422
|
+
var ee = Symbol("_ended");
|
|
423
|
+
var m = Symbol("_fd");
|
|
424
|
+
var xi = Symbol("_finished");
|
|
425
|
+
var J = Symbol("_flags");
|
|
426
|
+
var Li = Symbol("_flush");
|
|
427
|
+
var Ii = Symbol("_handleChunk");
|
|
428
|
+
var Ci = Symbol("_makeBuf");
|
|
429
|
+
var se = Symbol("_mode");
|
|
430
|
+
var Fe = Symbol("_needDrain");
|
|
431
|
+
var Ut = Symbol("_onerror");
|
|
432
|
+
var Ht = Symbol("_onopen");
|
|
433
|
+
var Ni = Symbol("_onread");
|
|
434
|
+
var Pt = Symbol("_onwrite");
|
|
435
|
+
var ht = Symbol("_open");
|
|
436
|
+
var U = Symbol("_path");
|
|
437
|
+
var nt = Symbol("_pos");
|
|
438
|
+
var Y = Symbol("_queue");
|
|
439
|
+
var zt = Symbol("_read");
|
|
440
|
+
var Ai = Symbol("_readSize");
|
|
441
|
+
var Q = Symbol("_reading");
|
|
442
|
+
var ie = Symbol("_remain");
|
|
443
|
+
var Di = Symbol("_size");
|
|
444
|
+
var ke = Symbol("_write");
|
|
445
|
+
var Rt = Symbol("_writing");
|
|
446
|
+
var ve = Symbol("_defaultFlag");
|
|
447
|
+
var bt = Symbol("_errored");
|
|
448
|
+
var _t = class extends D {
|
|
449
|
+
[bt] = false;
|
|
450
|
+
[m];
|
|
451
|
+
[U];
|
|
452
|
+
[Ai];
|
|
453
|
+
[Q] = false;
|
|
454
|
+
[Di];
|
|
455
|
+
[ie];
|
|
456
|
+
[ot];
|
|
457
|
+
constructor(t, e) {
|
|
458
|
+
if (e = e || {}, super(e), this.readable = true, this.writable = false, typeof t != "string")
|
|
459
|
+
throw new TypeError("path must be a string");
|
|
460
|
+
this[bt] = false, this[m] = typeof e.fd == "number" ? e.fd : undefined, this[U] = t, this[Ai] = e.readSize || 16 * 1024 * 1024, this[Q] = false, this[Di] = typeof e.size == "number" ? e.size : 1 / 0, this[ie] = this[Di], this[ot] = typeof e.autoClose == "boolean" ? e.autoClose : true, typeof this[m] == "number" ? this[zt]() : this[ht]();
|
|
461
|
+
}
|
|
462
|
+
get fd() {
|
|
463
|
+
return this[m];
|
|
464
|
+
}
|
|
465
|
+
get path() {
|
|
466
|
+
return this[U];
|
|
467
|
+
}
|
|
468
|
+
write() {
|
|
469
|
+
throw new TypeError("this is a readable stream");
|
|
470
|
+
}
|
|
471
|
+
end() {
|
|
472
|
+
throw new TypeError("this is a readable stream");
|
|
473
|
+
}
|
|
474
|
+
[ht]() {
|
|
475
|
+
I.open(this[U], "r", (t, e) => this[Ht](t, e));
|
|
476
|
+
}
|
|
477
|
+
[Ht](t, e) {
|
|
478
|
+
t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[zt]());
|
|
479
|
+
}
|
|
480
|
+
[Ci]() {
|
|
481
|
+
return Buffer.allocUnsafe(Math.min(this[Ai], this[ie]));
|
|
482
|
+
}
|
|
483
|
+
[zt]() {
|
|
484
|
+
if (!this[Q]) {
|
|
485
|
+
this[Q] = true;
|
|
486
|
+
let t = this[Ci]();
|
|
487
|
+
if (t.length === 0)
|
|
488
|
+
return process.nextTick(() => this[Ni](null, 0, t));
|
|
489
|
+
I.read(this[m], t, 0, t.length, null, (e, i, r) => this[Ni](e, i, r));
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
[Ni](t, e, i) {
|
|
493
|
+
this[Q] = false, t ? this[Ut](t) : this[Ii](e, i) && this[zt]();
|
|
494
|
+
}
|
|
495
|
+
[H]() {
|
|
496
|
+
if (this[ot] && typeof this[m] == "number") {
|
|
497
|
+
let t = this[m];
|
|
498
|
+
this[m] = undefined, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
[Ut](t) {
|
|
502
|
+
this[Q] = true, this[H](), this.emit("error", t);
|
|
503
|
+
}
|
|
504
|
+
[Ii](t, e) {
|
|
505
|
+
let i = false;
|
|
506
|
+
return this[ie] -= t, t > 0 && (i = super.write(t < e.length ? e.subarray(0, t) : e)), (t === 0 || this[ie] <= 0) && (i = false, this[H](), super.end()), i;
|
|
507
|
+
}
|
|
508
|
+
emit(t, ...e) {
|
|
509
|
+
switch (t) {
|
|
510
|
+
case "prefinish":
|
|
511
|
+
case "finish":
|
|
512
|
+
return false;
|
|
513
|
+
case "drain":
|
|
514
|
+
return typeof this[m] == "number" && this[zt](), false;
|
|
515
|
+
case "error":
|
|
516
|
+
return this[bt] ? false : (this[bt] = true, super.emit(t, ...e));
|
|
517
|
+
default:
|
|
518
|
+
return super.emit(t, ...e);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
var Me = class extends _t {
|
|
523
|
+
[ht]() {
|
|
524
|
+
let t = true;
|
|
525
|
+
try {
|
|
526
|
+
this[Ht](null, I.openSync(this[U], "r")), t = false;
|
|
527
|
+
} finally {
|
|
528
|
+
t && this[H]();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
[zt]() {
|
|
532
|
+
let t = true;
|
|
533
|
+
try {
|
|
534
|
+
if (!this[Q]) {
|
|
535
|
+
this[Q] = true;
|
|
536
|
+
do {
|
|
537
|
+
let e = this[Ci](), i = e.length === 0 ? 0 : I.readSync(this[m], e, 0, e.length, null);
|
|
538
|
+
if (!this[Ii](i, e))
|
|
539
|
+
break;
|
|
540
|
+
} while (true);
|
|
541
|
+
this[Q] = false;
|
|
542
|
+
}
|
|
543
|
+
t = false;
|
|
544
|
+
} finally {
|
|
545
|
+
t && this[H]();
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
[H]() {
|
|
549
|
+
if (this[ot] && typeof this[m] == "number") {
|
|
550
|
+
let t = this[m];
|
|
551
|
+
this[m] = undefined, I.closeSync(t), this.emit("close");
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
var tt = class extends Kr {
|
|
556
|
+
readable = false;
|
|
557
|
+
writable = true;
|
|
558
|
+
[bt] = false;
|
|
559
|
+
[Rt] = false;
|
|
560
|
+
[ee] = false;
|
|
561
|
+
[Y] = [];
|
|
562
|
+
[Fe] = false;
|
|
563
|
+
[U];
|
|
564
|
+
[se];
|
|
565
|
+
[ot];
|
|
566
|
+
[m];
|
|
567
|
+
[ve];
|
|
568
|
+
[J];
|
|
569
|
+
[xi] = false;
|
|
570
|
+
[nt];
|
|
571
|
+
constructor(t, e) {
|
|
572
|
+
e = e || {}, super(e), this[U] = t, this[m] = typeof e.fd == "number" ? e.fd : undefined, this[se] = e.mode === undefined ? 438 : e.mode, this[nt] = typeof e.start == "number" ? e.start : undefined, this[ot] = typeof e.autoClose == "boolean" ? e.autoClose : true;
|
|
573
|
+
let i = this[nt] !== undefined ? "r+" : "w";
|
|
574
|
+
this[ve] = e.flags === undefined, this[J] = e.flags === undefined ? i : e.flags, this[m] === undefined && this[ht]();
|
|
575
|
+
}
|
|
576
|
+
emit(t, ...e) {
|
|
577
|
+
if (t === "error") {
|
|
578
|
+
if (this[bt])
|
|
579
|
+
return false;
|
|
580
|
+
this[bt] = true;
|
|
581
|
+
}
|
|
582
|
+
return super.emit(t, ...e);
|
|
583
|
+
}
|
|
584
|
+
get fd() {
|
|
585
|
+
return this[m];
|
|
586
|
+
}
|
|
587
|
+
get path() {
|
|
588
|
+
return this[U];
|
|
589
|
+
}
|
|
590
|
+
[Ut](t) {
|
|
591
|
+
this[H](), this[Rt] = true, this.emit("error", t);
|
|
592
|
+
}
|
|
593
|
+
[ht]() {
|
|
594
|
+
I.open(this[U], this[J], this[se], (t, e) => this[Ht](t, e));
|
|
595
|
+
}
|
|
596
|
+
[Ht](t, e) {
|
|
597
|
+
this[ve] && this[J] === "r+" && t && t.code === "ENOENT" ? (this[J] = "w", this[ht]()) : t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[Rt] || this[Li]());
|
|
598
|
+
}
|
|
599
|
+
end(t, e) {
|
|
600
|
+
return t && this.write(t, e), this[ee] = true, !this[Rt] && !this[Y].length && typeof this[m] == "number" && this[Pt](null, 0), this;
|
|
601
|
+
}
|
|
602
|
+
write(t, e) {
|
|
603
|
+
return typeof t == "string" && (t = Buffer.from(t, e)), this[ee] ? (this.emit("error", new Error("write() after end()")), false) : this[m] === undefined || this[Rt] || this[Y].length ? (this[Y].push(t), this[Fe] = true, false) : (this[Rt] = true, this[ke](t), true);
|
|
604
|
+
}
|
|
605
|
+
[ke](t) {
|
|
606
|
+
I.write(this[m], t, 0, t.length, this[nt], (e, i) => this[Pt](e, i));
|
|
607
|
+
}
|
|
608
|
+
[Pt](t, e) {
|
|
609
|
+
t ? this[Ut](t) : (this[nt] !== undefined && typeof e == "number" && (this[nt] += e), this[Y].length ? this[Li]() : (this[Rt] = false, this[ee] && !this[xi] ? (this[xi] = true, this[H](), this.emit("finish")) : this[Fe] && (this[Fe] = false, this.emit("drain"))));
|
|
610
|
+
}
|
|
611
|
+
[Li]() {
|
|
612
|
+
if (this[Y].length === 0)
|
|
613
|
+
this[ee] && this[Pt](null, 0);
|
|
614
|
+
else if (this[Y].length === 1)
|
|
615
|
+
this[ke](this[Y].pop());
|
|
616
|
+
else {
|
|
617
|
+
let t = this[Y];
|
|
618
|
+
this[Y] = [], Vr(this[m], t, this[nt], (e, i) => this[Pt](e, i));
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
[H]() {
|
|
622
|
+
if (this[ot] && typeof this[m] == "number") {
|
|
623
|
+
let t = this[m];
|
|
624
|
+
this[m] = undefined, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
var Wt = class extends tt {
|
|
629
|
+
[ht]() {
|
|
630
|
+
let t;
|
|
631
|
+
if (this[ve] && this[J] === "r+")
|
|
632
|
+
try {
|
|
633
|
+
t = I.openSync(this[U], this[J], this[se]);
|
|
634
|
+
} catch (e) {
|
|
635
|
+
if (e?.code === "ENOENT")
|
|
636
|
+
return this[J] = "w", this[ht]();
|
|
637
|
+
throw e;
|
|
638
|
+
}
|
|
639
|
+
else
|
|
640
|
+
t = I.openSync(this[U], this[J], this[se]);
|
|
641
|
+
this[Ht](null, t);
|
|
642
|
+
}
|
|
643
|
+
[H]() {
|
|
644
|
+
if (this[ot] && typeof this[m] == "number") {
|
|
645
|
+
let t = this[m];
|
|
646
|
+
this[m] = undefined, I.closeSync(t), this.emit("close");
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
[ke](t) {
|
|
650
|
+
let e = true;
|
|
651
|
+
try {
|
|
652
|
+
this[Pt](null, I.writeSync(this[m], t, 0, t.length, this[nt])), e = false;
|
|
653
|
+
} finally {
|
|
654
|
+
if (e)
|
|
655
|
+
try {
|
|
656
|
+
this[H]();
|
|
657
|
+
} catch {}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
var $r = new Map([["C", "cwd"], ["f", "file"], ["z", "gzip"], ["P", "preservePaths"], ["U", "unlink"], ["strip-components", "strip"], ["stripComponents", "strip"], ["keep-newer", "newer"], ["keepNewer", "newer"], ["keep-newer-files", "newer"], ["keepNewerFiles", "newer"], ["k", "keep"], ["keep-existing", "keep"], ["keepExisting", "keep"], ["m", "noMtime"], ["no-mtime", "noMtime"], ["p", "preserveOwner"], ["L", "follow"], ["h", "follow"], ["onentry", "onReadEntry"]]);
|
|
662
|
+
var As = (s) => !!s.sync && !!s.file;
|
|
663
|
+
var Ds = (s) => !s.sync && !!s.file;
|
|
664
|
+
var Is = (s) => !!s.sync && !s.file;
|
|
665
|
+
var Cs = (s) => !s.sync && !s.file;
|
|
666
|
+
var Fs = (s) => !!s.file;
|
|
667
|
+
var Xr = (s) => {
|
|
668
|
+
let t = $r.get(s);
|
|
669
|
+
return t || s;
|
|
670
|
+
};
|
|
671
|
+
var re = (s = {}) => {
|
|
672
|
+
if (!s)
|
|
673
|
+
return {};
|
|
674
|
+
let t = {};
|
|
675
|
+
for (let [e, i] of Object.entries(s)) {
|
|
676
|
+
let r = Xr(e);
|
|
677
|
+
t[r] = i;
|
|
678
|
+
}
|
|
679
|
+
return t.chmod === undefined && t.noChmod === false && (t.chmod = true), delete t.noChmod, t;
|
|
680
|
+
};
|
|
681
|
+
var K = (s, t, e, i, r) => Object.assign((n = [], o, h) => {
|
|
682
|
+
Array.isArray(n) && (o = n, n = {}), typeof o == "function" && (h = o, o = undefined), o = o ? Array.from(o) : [];
|
|
683
|
+
let a = re(n);
|
|
684
|
+
if (r?.(a, o), As(a)) {
|
|
685
|
+
if (typeof h == "function")
|
|
686
|
+
throw new TypeError("callback not supported for sync tar functions");
|
|
687
|
+
return s(a, o);
|
|
688
|
+
} else if (Ds(a)) {
|
|
689
|
+
let l = t(a, o);
|
|
690
|
+
return h ? l.then(() => h(), h) : l;
|
|
691
|
+
} else if (Is(a)) {
|
|
692
|
+
if (typeof h == "function")
|
|
693
|
+
throw new TypeError("callback not supported for sync tar functions");
|
|
694
|
+
return e(a, o);
|
|
695
|
+
} else if (Cs(a)) {
|
|
696
|
+
if (typeof h == "function")
|
|
697
|
+
throw new TypeError("callback only supported with file option");
|
|
698
|
+
return i(a, o);
|
|
699
|
+
}
|
|
700
|
+
throw new Error("impossible options??");
|
|
701
|
+
}, { syncFile: s, asyncFile: t, syncNoFile: e, asyncNoFile: i, validate: r });
|
|
702
|
+
var jr = qr.constants || { ZLIB_VERNUM: 4736 };
|
|
703
|
+
var M = Object.freeze(Object.assign(Object.create(null), { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_MEM_ERROR: -4, Z_BUF_ERROR: -5, Z_VERSION_ERROR: -6, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, DEFLATE: 1, INFLATE: 2, GZIP: 3, GUNZIP: 4, DEFLATERAW: 5, INFLATERAW: 6, UNZIP: 7, BROTLI_DECODE: 8, BROTLI_ENCODE: 9, Z_MIN_WINDOWBITS: 8, Z_MAX_WINDOWBITS: 15, Z_DEFAULT_WINDOWBITS: 15, Z_MIN_CHUNK: 64, Z_MAX_CHUNK: 1 / 0, Z_DEFAULT_CHUNK: 16384, Z_MIN_MEMLEVEL: 1, Z_MAX_MEMLEVEL: 9, Z_DEFAULT_MEMLEVEL: 8, Z_MIN_LEVEL: -1, Z_MAX_LEVEL: 9, Z_DEFAULT_LEVEL: -1, BROTLI_OPERATION_PROCESS: 0, BROTLI_OPERATION_FLUSH: 1, BROTLI_OPERATION_FINISH: 2, BROTLI_OPERATION_EMIT_METADATA: 3, BROTLI_MODE_GENERIC: 0, BROTLI_MODE_TEXT: 1, BROTLI_MODE_FONT: 2, BROTLI_DEFAULT_MODE: 0, BROTLI_MIN_QUALITY: 0, BROTLI_MAX_QUALITY: 11, BROTLI_DEFAULT_QUALITY: 11, BROTLI_MIN_WINDOW_BITS: 10, BROTLI_MAX_WINDOW_BITS: 24, BROTLI_LARGE_MAX_WINDOW_BITS: 30, BROTLI_DEFAULT_WINDOW: 22, BROTLI_MIN_INPUT_BLOCK_BITS: 16, BROTLI_MAX_INPUT_BLOCK_BITS: 24, BROTLI_PARAM_MODE: 0, BROTLI_PARAM_QUALITY: 1, BROTLI_PARAM_LGWIN: 2, BROTLI_PARAM_LGBLOCK: 3, BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4, BROTLI_PARAM_SIZE_HINT: 5, BROTLI_PARAM_LARGE_WINDOW: 6, BROTLI_PARAM_NPOSTFIX: 7, BROTLI_PARAM_NDIRECT: 8, BROTLI_DECODER_RESULT_ERROR: 0, BROTLI_DECODER_RESULT_SUCCESS: 1, BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2, BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3, BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0, BROTLI_DECODER_PARAM_LARGE_WINDOW: 1, BROTLI_DECODER_NO_ERROR: 0, BROTLI_DECODER_SUCCESS: 1, BROTLI_DECODER_NEEDS_MORE_INPUT: 2, BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1, BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5, BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6, BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7, BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10, BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11, BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12, BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13, BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14, BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15, BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16, BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19, BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21, BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27, BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30, BROTLI_DECODER_ERROR_UNREACHABLE: -31 }, jr));
|
|
704
|
+
var Qr = gt.concat;
|
|
705
|
+
var vs = Object.getOwnPropertyDescriptor(gt, "concat");
|
|
706
|
+
var Jr = (s) => s;
|
|
707
|
+
var ki = vs?.writable === true || vs?.set !== undefined ? (s) => {
|
|
708
|
+
gt.concat = s ? Jr : Qr;
|
|
709
|
+
} : (s) => {};
|
|
710
|
+
var Ot = Symbol("_superWrite");
|
|
711
|
+
var Gt = class extends Error {
|
|
712
|
+
code;
|
|
713
|
+
errno;
|
|
714
|
+
constructor(t, e) {
|
|
715
|
+
super("zlib: " + t.message, { cause: t }), this.code = t.code, this.errno = t.errno, this.code || (this.code = "ZLIB_ERROR"), this.message = "zlib: " + t.message, Error.captureStackTrace(this, e ?? this.constructor);
|
|
716
|
+
}
|
|
717
|
+
get name() {
|
|
718
|
+
return "ZlibError";
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
var vi = Symbol("flushFlag");
|
|
722
|
+
var ne = class extends D {
|
|
723
|
+
#t = false;
|
|
724
|
+
#i = false;
|
|
725
|
+
#s;
|
|
726
|
+
#n;
|
|
727
|
+
#r;
|
|
728
|
+
#e;
|
|
729
|
+
#o;
|
|
730
|
+
get sawError() {
|
|
731
|
+
return this.#t;
|
|
732
|
+
}
|
|
733
|
+
get handle() {
|
|
734
|
+
return this.#e;
|
|
735
|
+
}
|
|
736
|
+
get flushFlag() {
|
|
737
|
+
return this.#s;
|
|
738
|
+
}
|
|
739
|
+
constructor(t, e) {
|
|
740
|
+
if (!t || typeof t != "object")
|
|
741
|
+
throw new TypeError("invalid options for ZlibBase constructor");
|
|
742
|
+
if (super(t), this.#s = t.flush ?? 0, this.#n = t.finishFlush ?? 0, this.#r = t.fullFlushFlag ?? 0, typeof ks[e] != "function")
|
|
743
|
+
throw new TypeError("Compression method not supported: " + e);
|
|
744
|
+
try {
|
|
745
|
+
this.#e = new ks[e](t);
|
|
746
|
+
} catch (i) {
|
|
747
|
+
throw new Gt(i, this.constructor);
|
|
748
|
+
}
|
|
749
|
+
this.#o = (i) => {
|
|
750
|
+
this.#t || (this.#t = true, this.close(), this.emit("error", i));
|
|
751
|
+
}, this.#e?.on("error", (i) => this.#o(new Gt(i))), this.once("end", () => this.close);
|
|
752
|
+
}
|
|
753
|
+
close() {
|
|
754
|
+
this.#e && (this.#e.close(), this.#e = undefined, this.emit("close"));
|
|
755
|
+
}
|
|
756
|
+
reset() {
|
|
757
|
+
if (!this.#t)
|
|
758
|
+
return Mi(this.#e, "zlib binding closed"), this.#e.reset?.();
|
|
759
|
+
}
|
|
760
|
+
flush(t) {
|
|
761
|
+
this.ended || (typeof t != "number" && (t = this.#r), this.write(Object.assign(gt.alloc(0), { [vi]: t })));
|
|
762
|
+
}
|
|
763
|
+
end(t, e, i) {
|
|
764
|
+
return typeof t == "function" && (i = t, e = undefined, t = undefined), typeof e == "function" && (i = e, e = undefined), t && (e ? this.write(t, e) : this.write(t)), this.flush(this.#n), this.#i = true, super.end(i);
|
|
765
|
+
}
|
|
766
|
+
get ended() {
|
|
767
|
+
return this.#i;
|
|
768
|
+
}
|
|
769
|
+
[Ot](t) {
|
|
770
|
+
return super.write(t);
|
|
771
|
+
}
|
|
772
|
+
write(t, e, i) {
|
|
773
|
+
if (typeof e == "function" && (i = e, e = "utf8"), typeof t == "string" && (t = gt.from(t, e)), this.#t)
|
|
774
|
+
return;
|
|
775
|
+
Mi(this.#e, "zlib binding closed");
|
|
776
|
+
let r = this.#e._handle, n = r.close;
|
|
777
|
+
r.close = () => {};
|
|
778
|
+
let o = this.#e.close;
|
|
779
|
+
this.#e.close = () => {}, ki(true);
|
|
780
|
+
let h;
|
|
781
|
+
try {
|
|
782
|
+
let l = typeof t[vi] == "number" ? t[vi] : this.#s;
|
|
783
|
+
h = this.#e._processChunk(t, l), ki(false);
|
|
784
|
+
} catch (l) {
|
|
785
|
+
ki(false), this.#o(new Gt(l, this.write));
|
|
786
|
+
} finally {
|
|
787
|
+
this.#e && (this.#e._handle = r, r.close = n, this.#e.close = o, this.#e.removeAllListeners("error"));
|
|
788
|
+
}
|
|
789
|
+
this.#e && this.#e.on("error", (l) => this.#o(new Gt(l, this.write)));
|
|
790
|
+
let a;
|
|
791
|
+
if (h)
|
|
792
|
+
if (Array.isArray(h) && h.length > 0) {
|
|
793
|
+
let l = h[0];
|
|
794
|
+
a = this[Ot](gt.from(l));
|
|
795
|
+
for (let c = 1;c < h.length; c++)
|
|
796
|
+
a = this[Ot](h[c]);
|
|
797
|
+
} else
|
|
798
|
+
a = this[Ot](gt.from(h));
|
|
799
|
+
return i && i(), a;
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
var Be = class extends ne {
|
|
803
|
+
#t;
|
|
804
|
+
#i;
|
|
805
|
+
constructor(t, e) {
|
|
806
|
+
t = t || {}, t.flush = t.flush || M.Z_NO_FLUSH, t.finishFlush = t.finishFlush || M.Z_FINISH, t.fullFlushFlag = M.Z_FULL_FLUSH, super(t, e), this.#t = t.level, this.#i = t.strategy;
|
|
807
|
+
}
|
|
808
|
+
params(t, e) {
|
|
809
|
+
if (!this.sawError) {
|
|
810
|
+
if (!this.handle)
|
|
811
|
+
throw new Error("cannot switch params when binding is closed");
|
|
812
|
+
if (!this.handle.params)
|
|
813
|
+
throw new Error("not supported in this implementation");
|
|
814
|
+
if (this.#t !== t || this.#i !== e) {
|
|
815
|
+
this.flush(M.Z_SYNC_FLUSH), Mi(this.handle, "zlib binding closed");
|
|
816
|
+
let i = this.handle.flush;
|
|
817
|
+
this.handle.flush = (r, n) => {
|
|
818
|
+
typeof r == "function" && (n = r, r = this.flushFlag), this.flush(r), n?.();
|
|
819
|
+
};
|
|
820
|
+
try {
|
|
821
|
+
this.handle.params(t, e);
|
|
822
|
+
} finally {
|
|
823
|
+
this.handle.flush = i;
|
|
824
|
+
}
|
|
825
|
+
this.handle && (this.#t = t, this.#i = e);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
var Pe = class extends Be {
|
|
831
|
+
#t;
|
|
832
|
+
constructor(t) {
|
|
833
|
+
super(t, "Gzip"), this.#t = t && !!t.portable;
|
|
834
|
+
}
|
|
835
|
+
[Ot](t) {
|
|
836
|
+
return this.#t ? (this.#t = false, t[9] = 255, super[Ot](t)) : super[Ot](t);
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
var ze = class extends Be {
|
|
840
|
+
constructor(t) {
|
|
841
|
+
super(t, "Unzip");
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
var Ue = class extends ne {
|
|
845
|
+
constructor(t, e) {
|
|
846
|
+
t = t || {}, t.flush = t.flush || M.BROTLI_OPERATION_PROCESS, t.finishFlush = t.finishFlush || M.BROTLI_OPERATION_FINISH, t.fullFlushFlag = M.BROTLI_OPERATION_FLUSH, super(t, e);
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
var He = class extends Ue {
|
|
850
|
+
constructor(t) {
|
|
851
|
+
super(t, "BrotliCompress");
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
var We = class extends Ue {
|
|
855
|
+
constructor(t) {
|
|
856
|
+
super(t, "BrotliDecompress");
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
var Ge = class extends ne {
|
|
860
|
+
constructor(t, e) {
|
|
861
|
+
t = t || {}, t.flush = t.flush || M.ZSTD_e_continue, t.finishFlush = t.finishFlush || M.ZSTD_e_end, t.fullFlushFlag = M.ZSTD_e_flush, super(t, e);
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
var Ze = class extends Ge {
|
|
865
|
+
constructor(t) {
|
|
866
|
+
super(t, "ZstdCompress");
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
var Ye = class extends Ge {
|
|
870
|
+
constructor(t) {
|
|
871
|
+
super(t, "ZstdDecompress");
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
var Ms = (s, t) => {
|
|
875
|
+
if (Number.isSafeInteger(s))
|
|
876
|
+
s < 0 ? sn(s, t) : en(s, t);
|
|
877
|
+
else
|
|
878
|
+
throw Error("cannot encode number outside of javascript safe integer range");
|
|
879
|
+
return t;
|
|
880
|
+
};
|
|
881
|
+
var en = (s, t) => {
|
|
882
|
+
t[0] = 128;
|
|
883
|
+
for (var e = t.length;e > 1; e--)
|
|
884
|
+
t[e - 1] = s & 255, s = Math.floor(s / 256);
|
|
885
|
+
};
|
|
886
|
+
var sn = (s, t) => {
|
|
887
|
+
t[0] = 255;
|
|
888
|
+
var e = false;
|
|
889
|
+
s = s * -1;
|
|
890
|
+
for (var i = t.length;i > 1; i--) {
|
|
891
|
+
var r = s & 255;
|
|
892
|
+
s = Math.floor(s / 256), e ? t[i - 1] = Ps(r) : r === 0 ? t[i - 1] = 0 : (e = true, t[i - 1] = zs(r));
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
var Bs = (s) => {
|
|
896
|
+
let t = s[0], e = t === 128 ? nn(s.subarray(1, s.length)) : t === 255 ? rn(s) : null;
|
|
897
|
+
if (e === null)
|
|
898
|
+
throw Error("invalid base256 encoding");
|
|
899
|
+
if (!Number.isSafeInteger(e))
|
|
900
|
+
throw Error("parsed number outside of javascript safe integer range");
|
|
901
|
+
return e;
|
|
902
|
+
};
|
|
903
|
+
var rn = (s) => {
|
|
904
|
+
for (var t = s.length, e = 0, i = false, r = t - 1;r > -1; r--) {
|
|
905
|
+
var n = Number(s[r]), o;
|
|
906
|
+
i ? o = Ps(n) : n === 0 ? o = n : (i = true, o = zs(n)), o !== 0 && (e -= o * Math.pow(256, t - r - 1));
|
|
907
|
+
}
|
|
908
|
+
return e;
|
|
909
|
+
};
|
|
910
|
+
var nn = (s) => {
|
|
911
|
+
for (var t = s.length, e = 0, i = t - 1;i > -1; i--) {
|
|
912
|
+
var r = Number(s[i]);
|
|
913
|
+
r !== 0 && (e += r * Math.pow(256, t - i - 1));
|
|
914
|
+
}
|
|
915
|
+
return e;
|
|
916
|
+
};
|
|
917
|
+
var Ps = (s) => (255 ^ s) & 255;
|
|
918
|
+
var zs = (s) => (255 ^ s) + 1 & 255;
|
|
919
|
+
var Bi = {};
|
|
920
|
+
vr(Bi, { code: () => Ke, isCode: () => oe, isName: () => hn, name: () => he });
|
|
921
|
+
var oe = (s) => he.has(s);
|
|
922
|
+
var hn = (s) => Ke.has(s);
|
|
923
|
+
var he = new Map([["0", "File"], ["", "OldFile"], ["1", "Link"], ["2", "SymbolicLink"], ["3", "CharacterDevice"], ["4", "BlockDevice"], ["5", "Directory"], ["6", "FIFO"], ["7", "ContiguousFile"], ["g", "GlobalExtendedHeader"], ["x", "ExtendedHeader"], ["A", "SolarisACL"], ["D", "GNUDumpDir"], ["I", "Inode"], ["K", "NextFileHasLongLinkpath"], ["L", "NextFileHasLongPath"], ["M", "ContinuationFile"], ["N", "OldGnuLongPath"], ["S", "SparseFile"], ["V", "TapeVolumeHeader"], ["X", "OldExtendedHeader"]]);
|
|
924
|
+
var Ke = new Map(Array.from(he).map((s) => [s[1], s[0]]));
|
|
925
|
+
var F = class {
|
|
926
|
+
cksumValid = false;
|
|
927
|
+
needPax = false;
|
|
928
|
+
nullBlock = false;
|
|
929
|
+
block;
|
|
930
|
+
path;
|
|
931
|
+
mode;
|
|
932
|
+
uid;
|
|
933
|
+
gid;
|
|
934
|
+
size;
|
|
935
|
+
cksum;
|
|
936
|
+
#t = "Unsupported";
|
|
937
|
+
linkpath;
|
|
938
|
+
uname;
|
|
939
|
+
gname;
|
|
940
|
+
devmaj = 0;
|
|
941
|
+
devmin = 0;
|
|
942
|
+
atime;
|
|
943
|
+
ctime;
|
|
944
|
+
mtime;
|
|
945
|
+
charset;
|
|
946
|
+
comment;
|
|
947
|
+
constructor(t, e = 0, i, r) {
|
|
948
|
+
Buffer.isBuffer(t) ? this.decode(t, e || 0, i, r) : t && this.#i(t);
|
|
949
|
+
}
|
|
950
|
+
decode(t, e, i, r) {
|
|
951
|
+
if (e || (e = 0), !t || !(t.length >= e + 512))
|
|
952
|
+
throw new Error("need 512 bytes for header");
|
|
953
|
+
this.path = i?.path ?? Tt(t, e, 100), this.mode = i?.mode ?? r?.mode ?? at(t, e + 100, 8), this.uid = i?.uid ?? r?.uid ?? at(t, e + 108, 8), this.gid = i?.gid ?? r?.gid ?? at(t, e + 116, 8), this.size = i?.size ?? r?.size ?? at(t, e + 124, 12), this.mtime = i?.mtime ?? r?.mtime ?? Pi(t, e + 136, 12), this.cksum = at(t, e + 148, 12), r && this.#i(r, true), i && this.#i(i);
|
|
954
|
+
let n = Tt(t, e + 156, 1);
|
|
955
|
+
if (oe(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = Tt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000")
|
|
956
|
+
if (this.uname = i?.uname ?? r?.uname ?? Tt(t, e + 265, 32), this.gname = i?.gname ?? r?.gname ?? Tt(t, e + 297, 32), this.devmaj = i?.devmaj ?? r?.devmaj ?? at(t, e + 329, 8) ?? 0, this.devmin = i?.devmin ?? r?.devmin ?? at(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
|
|
957
|
+
let h = Tt(t, e + 345, 155);
|
|
958
|
+
this.path = h + "/" + this.path;
|
|
959
|
+
} else {
|
|
960
|
+
let h = Tt(t, e + 345, 130);
|
|
961
|
+
h && (this.path = h + "/" + this.path), this.atime = i?.atime ?? r?.atime ?? Pi(t, e + 476, 12), this.ctime = i?.ctime ?? r?.ctime ?? Pi(t, e + 488, 12);
|
|
962
|
+
}
|
|
963
|
+
let o = 256;
|
|
964
|
+
for (let h = e;h < e + 148; h++)
|
|
965
|
+
o += t[h];
|
|
966
|
+
for (let h = e + 156;h < e + 512; h++)
|
|
967
|
+
o += t[h];
|
|
968
|
+
this.cksumValid = o === this.cksum, this.cksum === undefined && o === 256 && (this.nullBlock = true);
|
|
969
|
+
}
|
|
970
|
+
#i(t, e = false) {
|
|
971
|
+
Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e || i === "linkpath" && e || i === "global"))));
|
|
972
|
+
}
|
|
973
|
+
encode(t, e = 0) {
|
|
974
|
+
if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e + 512))
|
|
975
|
+
throw new Error("need 512 bytes for header");
|
|
976
|
+
let i = this.ctime || this.atime ? 130 : 155, r = an(this.path || "", i), n = r[0], o = r[1];
|
|
977
|
+
this.needPax = !!r[2], this.needPax = xt(t, e, 100, n) || this.needPax, this.needPax = lt(t, e + 100, 8, this.mode) || this.needPax, this.needPax = lt(t, e + 108, 8, this.uid) || this.needPax, this.needPax = lt(t, e + 116, 8, this.gid) || this.needPax, this.needPax = lt(t, e + 124, 12, this.size) || this.needPax, this.needPax = zi(t, e + 136, 12, this.mtime) || this.needPax, t[e + 156] = Number(this.#t.codePointAt(0)), this.needPax = xt(t, e + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e + 257, 8), this.needPax = xt(t, e + 265, 32, this.uname) || this.needPax, this.needPax = xt(t, e + 297, 32, this.gname) || this.needPax, this.needPax = lt(t, e + 329, 8, this.devmaj) || this.needPax, this.needPax = lt(t, e + 337, 8, this.devmin) || this.needPax, this.needPax = xt(t, e + 345, i, o) || this.needPax, t[e + 475] !== 0 ? this.needPax = xt(t, e + 345, 155, o) || this.needPax : (this.needPax = xt(t, e + 345, 130, o) || this.needPax, this.needPax = zi(t, e + 476, 12, this.atime) || this.needPax, this.needPax = zi(t, e + 488, 12, this.ctime) || this.needPax);
|
|
978
|
+
let h = 256;
|
|
979
|
+
for (let a = e;a < e + 148; a++)
|
|
980
|
+
h += t[a];
|
|
981
|
+
for (let a = e + 156;a < e + 512; a++)
|
|
982
|
+
h += t[a];
|
|
983
|
+
return this.cksum = h, lt(t, e + 148, 8, this.cksum), this.cksumValid = true, this.needPax;
|
|
984
|
+
}
|
|
985
|
+
get type() {
|
|
986
|
+
return this.#t === "Unsupported" ? this.#t : he.get(this.#t);
|
|
987
|
+
}
|
|
988
|
+
get typeKey() {
|
|
989
|
+
return this.#t;
|
|
990
|
+
}
|
|
991
|
+
set type(t) {
|
|
992
|
+
let e = String(Ke.get(t));
|
|
993
|
+
if (oe(e) || e === "Unsupported")
|
|
994
|
+
this.#t = e;
|
|
995
|
+
else if (oe(t))
|
|
996
|
+
this.#t = t;
|
|
997
|
+
else
|
|
998
|
+
throw new TypeError("invalid entry type: " + t);
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
var an = (s, t) => {
|
|
1002
|
+
let i = s, r = "", n, o = Zt.parse(s).root || ".";
|
|
1003
|
+
if (Buffer.byteLength(i) < 100)
|
|
1004
|
+
n = [i, r, false];
|
|
1005
|
+
else {
|
|
1006
|
+
r = Zt.dirname(i), i = Zt.basename(i);
|
|
1007
|
+
do
|
|
1008
|
+
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i = Zt.join(Zt.basename(r), i), r = Zt.dirname(r));
|
|
1009
|
+
while (r !== o && n === undefined);
|
|
1010
|
+
n || (n = [s.slice(0, 99), "", true]);
|
|
1011
|
+
}
|
|
1012
|
+
return n;
|
|
1013
|
+
};
|
|
1014
|
+
var Tt = (s, t, e) => s.subarray(t, t + e).toString("utf8").replace(/\0.*/, "");
|
|
1015
|
+
var Pi = (s, t, e) => ln(at(s, t, e));
|
|
1016
|
+
var ln = (s) => s === undefined ? undefined : new Date(s * 1000);
|
|
1017
|
+
var at = (s, t, e) => Number(s[t]) & 128 ? Bs(s.subarray(t, t + e)) : fn(s, t, e);
|
|
1018
|
+
var cn = (s) => isNaN(s) ? undefined : s;
|
|
1019
|
+
var fn = (s, t, e) => cn(parseInt(s.subarray(t, t + e).toString("utf8").replace(/\0.*$/, "").trim(), 8));
|
|
1020
|
+
var dn = { 12: 8589934591, 8: 2097151 };
|
|
1021
|
+
var lt = (s, t, e, i) => i === undefined ? false : i > dn[e] || i < 0 ? (Ms(i, s.subarray(t, t + e)), true) : (un(s, t, e, i), false);
|
|
1022
|
+
var un = (s, t, e, i) => s.write(mn(i, e), t, e, "ascii");
|
|
1023
|
+
var mn = (s, t) => pn(Math.floor(s).toString(8), t);
|
|
1024
|
+
var pn = (s, t) => (s.length === t - 1 ? s : new Array(t - s.length - 1).join("0") + s + " ") + "\x00";
|
|
1025
|
+
var zi = (s, t, e, i) => i === undefined ? false : lt(s, t, e, i.getTime() / 1000);
|
|
1026
|
+
var En = new Array(156).join("\x00");
|
|
1027
|
+
var xt = (s, t, e, i) => i === undefined ? false : (s.write(i + En, t, e, "utf8"), i.length !== Buffer.byteLength(i) || i.length > e);
|
|
1028
|
+
var ct = class s {
|
|
1029
|
+
atime;
|
|
1030
|
+
mtime;
|
|
1031
|
+
ctime;
|
|
1032
|
+
charset;
|
|
1033
|
+
comment;
|
|
1034
|
+
gid;
|
|
1035
|
+
uid;
|
|
1036
|
+
gname;
|
|
1037
|
+
uname;
|
|
1038
|
+
linkpath;
|
|
1039
|
+
dev;
|
|
1040
|
+
ino;
|
|
1041
|
+
nlink;
|
|
1042
|
+
path;
|
|
1043
|
+
size;
|
|
1044
|
+
mode;
|
|
1045
|
+
global;
|
|
1046
|
+
constructor(t, e = false) {
|
|
1047
|
+
this.atime = t.atime, this.charset = t.charset, this.comment = t.comment, this.ctime = t.ctime, this.dev = t.dev, this.gid = t.gid, this.global = e, this.gname = t.gname, this.ino = t.ino, this.linkpath = t.linkpath, this.mtime = t.mtime, this.nlink = t.nlink, this.path = t.path, this.size = t.size, this.uid = t.uid, this.uname = t.uname;
|
|
1048
|
+
}
|
|
1049
|
+
encode() {
|
|
1050
|
+
let t = this.encodeBody();
|
|
1051
|
+
if (t === "")
|
|
1052
|
+
return Buffer.allocUnsafe(0);
|
|
1053
|
+
let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
|
|
1054
|
+
for (let n = 0;n < 512; n++)
|
|
1055
|
+
r[n] = 0;
|
|
1056
|
+
new F({ path: ("PaxHeader/" + wn(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t, 512, e, "utf8");
|
|
1057
|
+
for (let n = e + 512;n < r.length; n++)
|
|
1058
|
+
r[n] = 0;
|
|
1059
|
+
return r;
|
|
1060
|
+
}
|
|
1061
|
+
encodeBody() {
|
|
1062
|
+
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");
|
|
1063
|
+
}
|
|
1064
|
+
encodeField(t) {
|
|
1065
|
+
if (this[t] === undefined)
|
|
1066
|
+
return "";
|
|
1067
|
+
let e = this[t], i = e instanceof Date ? e.getTime() / 1000 : e, r = " " + (t === "dev" || t === "ino" || t === "nlink" ? "SCHILY." : "") + t + "=" + i + `
|
|
1068
|
+
`, n = Buffer.byteLength(r), o = Math.floor(Math.log(n) / Math.log(10)) + 1;
|
|
1069
|
+
return n + o >= Math.pow(10, o) && (o += 1), o + n + r;
|
|
1070
|
+
}
|
|
1071
|
+
static parse(t, e, i = false) {
|
|
1072
|
+
return new s(Sn(yn(t), e), i);
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
var Sn = (s2, t) => t ? Object.assign({}, t, s2) : s2;
|
|
1076
|
+
var yn = (s2) => s2.replace(/\n$/, "").split(`
|
|
1077
|
+
`).reduce(Rn, Object.create(null));
|
|
1078
|
+
var Rn = (s2, t) => {
|
|
1079
|
+
let e = parseInt(t, 10);
|
|
1080
|
+
if (e !== Buffer.byteLength(t) + 1)
|
|
1081
|
+
return s2;
|
|
1082
|
+
t = t.slice((e + " ").length);
|
|
1083
|
+
let i = t.split("="), r = i.shift();
|
|
1084
|
+
if (!r)
|
|
1085
|
+
return s2;
|
|
1086
|
+
let n = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1"), o = i.join("=");
|
|
1087
|
+
return s2[n] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n) ? new Date(Number(o) * 1000) : /^[0-9]+$/.test(o) ? +o : o, s2;
|
|
1088
|
+
};
|
|
1089
|
+
var bn = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
1090
|
+
var f = bn !== "win32" ? (s2) => s2 : (s2) => s2 && s2.replaceAll(/\\/g, "/");
|
|
1091
|
+
var Yt = class extends D {
|
|
1092
|
+
extended;
|
|
1093
|
+
globalExtended;
|
|
1094
|
+
header;
|
|
1095
|
+
startBlockSize;
|
|
1096
|
+
blockRemain;
|
|
1097
|
+
remain;
|
|
1098
|
+
type;
|
|
1099
|
+
meta = false;
|
|
1100
|
+
ignore = false;
|
|
1101
|
+
path;
|
|
1102
|
+
mode;
|
|
1103
|
+
uid;
|
|
1104
|
+
gid;
|
|
1105
|
+
uname;
|
|
1106
|
+
gname;
|
|
1107
|
+
size = 0;
|
|
1108
|
+
mtime;
|
|
1109
|
+
atime;
|
|
1110
|
+
ctime;
|
|
1111
|
+
linkpath;
|
|
1112
|
+
dev;
|
|
1113
|
+
ino;
|
|
1114
|
+
nlink;
|
|
1115
|
+
invalid = false;
|
|
1116
|
+
absolute;
|
|
1117
|
+
unsupported = false;
|
|
1118
|
+
constructor(t, e, i) {
|
|
1119
|
+
switch (super({}), this.pause(), this.extended = e, this.globalExtended = i, this.header = t, this.remain = t.size ?? 0, this.startBlockSize = 512 * Math.ceil(this.remain / 512), this.blockRemain = this.startBlockSize, this.type = t.type, this.type) {
|
|
1120
|
+
case "File":
|
|
1121
|
+
case "OldFile":
|
|
1122
|
+
case "Link":
|
|
1123
|
+
case "SymbolicLink":
|
|
1124
|
+
case "CharacterDevice":
|
|
1125
|
+
case "BlockDevice":
|
|
1126
|
+
case "Directory":
|
|
1127
|
+
case "FIFO":
|
|
1128
|
+
case "ContiguousFile":
|
|
1129
|
+
case "GNUDumpDir":
|
|
1130
|
+
break;
|
|
1131
|
+
case "NextFileHasLongLinkpath":
|
|
1132
|
+
case "NextFileHasLongPath":
|
|
1133
|
+
case "OldGnuLongPath":
|
|
1134
|
+
case "GlobalExtendedHeader":
|
|
1135
|
+
case "ExtendedHeader":
|
|
1136
|
+
case "OldExtendedHeader":
|
|
1137
|
+
this.meta = true;
|
|
1138
|
+
break;
|
|
1139
|
+
default:
|
|
1140
|
+
this.ignore = true;
|
|
1141
|
+
}
|
|
1142
|
+
if (!t.path)
|
|
1143
|
+
throw new Error("no path provided for tar.ReadEntry");
|
|
1144
|
+
this.path = f(t.path), this.mode = t.mode, this.mode && (this.mode = this.mode & 4095), this.uid = t.uid, this.gid = t.gid, this.uname = t.uname, this.gname = t.gname, this.size = this.remain, this.mtime = t.mtime, this.atime = t.atime, this.ctime = t.ctime, this.linkpath = t.linkpath ? f(t.linkpath) : undefined, this.uname = t.uname, this.gname = t.gname, e && this.#t(e), i && this.#t(i, true);
|
|
1145
|
+
}
|
|
1146
|
+
write(t) {
|
|
1147
|
+
let e = t.length;
|
|
1148
|
+
if (e > this.blockRemain)
|
|
1149
|
+
throw new Error("writing more to entry than is appropriate");
|
|
1150
|
+
let i = this.remain, r = this.blockRemain;
|
|
1151
|
+
return this.remain = Math.max(0, i - e), this.blockRemain = Math.max(0, r - e), this.ignore ? true : i >= e ? super.write(t) : super.write(t.subarray(0, i));
|
|
1152
|
+
}
|
|
1153
|
+
#t(t, e = false) {
|
|
1154
|
+
t.path && (t.path = f(t.path)), t.linkpath && (t.linkpath = f(t.linkpath)), Object.assign(this, Object.fromEntries(Object.entries(t).filter(([i, r]) => !(r == null || i === "path" && e))));
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
var Lt = (s2, t, e, i = {}) => {
|
|
1158
|
+
s2.file && (i.file = s2.file), s2.cwd && (i.cwd = s2.cwd), i.code = e instanceof Error && e.code || t, i.tarCode = t, !s2.strict && i.recoverable !== false ? (e instanceof Error && (i = Object.assign(e, i), e = e.message), s2.emit("warn", t, e, i)) : e instanceof Error ? s2.emit("error", Object.assign(e, i)) : s2.emit("error", Object.assign(new Error(`${t}: ${e}`), i));
|
|
1159
|
+
};
|
|
1160
|
+
var gn = 1024 * 1024;
|
|
1161
|
+
var Zi = Buffer.from([31, 139]);
|
|
1162
|
+
var Yi = Buffer.from([40, 181, 47, 253]);
|
|
1163
|
+
var On = Math.max(Zi.length, Yi.length);
|
|
1164
|
+
var B = Symbol("state");
|
|
1165
|
+
var Nt = Symbol("writeEntry");
|
|
1166
|
+
var et = Symbol("readEntry");
|
|
1167
|
+
var Ui = Symbol("nextEntry");
|
|
1168
|
+
var Us = Symbol("processEntry");
|
|
1169
|
+
var V = Symbol("extendedHeader");
|
|
1170
|
+
var ae = Symbol("globalExtendedHeader");
|
|
1171
|
+
var ft = Symbol("meta");
|
|
1172
|
+
var Hs = Symbol("emitMeta");
|
|
1173
|
+
var p = Symbol("buffer");
|
|
1174
|
+
var it = Symbol("queue");
|
|
1175
|
+
var dt = Symbol("ended");
|
|
1176
|
+
var Hi = Symbol("emittedEnd");
|
|
1177
|
+
var At = Symbol("emit");
|
|
1178
|
+
var y = Symbol("unzip");
|
|
1179
|
+
var Ve = Symbol("consumeChunk");
|
|
1180
|
+
var $e = Symbol("consumeChunkSub");
|
|
1181
|
+
var Wi = Symbol("consumeBody");
|
|
1182
|
+
var Ws = Symbol("consumeMeta");
|
|
1183
|
+
var Gs = Symbol("consumeHeader");
|
|
1184
|
+
var le = Symbol("consuming");
|
|
1185
|
+
var Gi = Symbol("bufferConcat");
|
|
1186
|
+
var Xe = Symbol("maybeEnd");
|
|
1187
|
+
var Kt = Symbol("writing");
|
|
1188
|
+
var ut = Symbol("aborted");
|
|
1189
|
+
var qe = Symbol("onDone");
|
|
1190
|
+
var Dt = Symbol("sawValidEntry");
|
|
1191
|
+
var je = Symbol("sawNullBlock");
|
|
1192
|
+
var Qe = Symbol("sawEOF");
|
|
1193
|
+
var Zs = Symbol("closeStream");
|
|
1194
|
+
var Tn = () => true;
|
|
1195
|
+
var st = class extends _n {
|
|
1196
|
+
file;
|
|
1197
|
+
strict;
|
|
1198
|
+
maxMetaEntrySize;
|
|
1199
|
+
filter;
|
|
1200
|
+
brotli;
|
|
1201
|
+
zstd;
|
|
1202
|
+
writable = true;
|
|
1203
|
+
readable = false;
|
|
1204
|
+
[it] = [];
|
|
1205
|
+
[p];
|
|
1206
|
+
[et];
|
|
1207
|
+
[Nt];
|
|
1208
|
+
[B] = "begin";
|
|
1209
|
+
[ft] = "";
|
|
1210
|
+
[V];
|
|
1211
|
+
[ae];
|
|
1212
|
+
[dt] = false;
|
|
1213
|
+
[y];
|
|
1214
|
+
[ut] = false;
|
|
1215
|
+
[Dt];
|
|
1216
|
+
[je] = false;
|
|
1217
|
+
[Qe] = false;
|
|
1218
|
+
[Kt] = false;
|
|
1219
|
+
[le] = false;
|
|
1220
|
+
[Hi] = false;
|
|
1221
|
+
constructor(t = {}) {
|
|
1222
|
+
super(), this.file = t.file || "", this.on(qe, () => {
|
|
1223
|
+
(this[B] === "begin" || this[Dt] === false) && this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
|
|
1224
|
+
}), t.ondone ? this.on(qe, t.ondone) : this.on(qe, () => {
|
|
1225
|
+
this.emit("prefinish"), this.emit("finish"), this.emit("end");
|
|
1226
|
+
}), this.strict = !!t.strict, this.maxMetaEntrySize = t.maxMetaEntrySize || gn, this.filter = typeof t.filter == "function" ? t.filter : Tn;
|
|
1227
|
+
let e = t.file && (t.file.endsWith(".tar.br") || t.file.endsWith(".tbr"));
|
|
1228
|
+
this.brotli = !(t.gzip || t.zstd) && t.brotli !== undefined ? t.brotli : e ? undefined : false;
|
|
1229
|
+
let i = t.file && (t.file.endsWith(".tar.zst") || t.file.endsWith(".tzst"));
|
|
1230
|
+
this.zstd = !(t.gzip || t.brotli) && t.zstd !== undefined ? t.zstd : i ? true : undefined, this.on("end", () => this[Zs]()), typeof t.onwarn == "function" && this.on("warn", t.onwarn), typeof t.onReadEntry == "function" && this.on("entry", t.onReadEntry);
|
|
1231
|
+
}
|
|
1232
|
+
warn(t, e, i = {}) {
|
|
1233
|
+
Lt(this, t, e, i);
|
|
1234
|
+
}
|
|
1235
|
+
[Gs](t, e) {
|
|
1236
|
+
this[Dt] === undefined && (this[Dt] = false);
|
|
1237
|
+
let i;
|
|
1238
|
+
try {
|
|
1239
|
+
i = new F(t, e, this[V], this[ae]);
|
|
1240
|
+
} catch (r) {
|
|
1241
|
+
return this.warn("TAR_ENTRY_INVALID", r);
|
|
1242
|
+
}
|
|
1243
|
+
if (i.nullBlock)
|
|
1244
|
+
this[je] ? (this[Qe] = true, this[B] === "begin" && (this[B] = "header"), this[At]("eof")) : (this[je] = true, this[At]("nullBlock"));
|
|
1245
|
+
else if (this[je] = false, !i.cksumValid)
|
|
1246
|
+
this.warn("TAR_ENTRY_INVALID", "checksum failure", { header: i });
|
|
1247
|
+
else if (!i.path)
|
|
1248
|
+
this.warn("TAR_ENTRY_INVALID", "path is required", { header: i });
|
|
1249
|
+
else {
|
|
1250
|
+
let r = i.type;
|
|
1251
|
+
if (/^(Symbolic)?Link$/.test(r) && !i.linkpath)
|
|
1252
|
+
this.warn("TAR_ENTRY_INVALID", "linkpath required", { header: i });
|
|
1253
|
+
else if (!/^(Symbolic)?Link$/.test(r) && !/^(Global)?ExtendedHeader$/.test(r) && i.linkpath)
|
|
1254
|
+
this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", { header: i });
|
|
1255
|
+
else {
|
|
1256
|
+
let n = this[Nt] = new Yt(i, this[V], this[ae]);
|
|
1257
|
+
if (!this[Dt])
|
|
1258
|
+
if (n.remain) {
|
|
1259
|
+
let o = () => {
|
|
1260
|
+
n.invalid || (this[Dt] = true);
|
|
1261
|
+
};
|
|
1262
|
+
n.on("end", o);
|
|
1263
|
+
} else
|
|
1264
|
+
this[Dt] = true;
|
|
1265
|
+
n.meta ? n.size > this.maxMetaEntrySize ? (n.ignore = true, this[At]("ignoredEntry", n), this[B] = "ignore", n.resume()) : n.size > 0 && (this[ft] = "", n.on("data", (o) => this[ft] += o), this[B] = "meta") : (this[V] = undefined, n.ignore = n.ignore || !this.filter(n.path, n), n.ignore ? (this[At]("ignoredEntry", n), this[B] = n.remain ? "ignore" : "header", n.resume()) : (n.remain ? this[B] = "body" : (this[B] = "header", n.end()), this[et] ? this[it].push(n) : (this[it].push(n), this[Ui]())));
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
[Zs]() {
|
|
1270
|
+
queueMicrotask(() => this.emit("close"));
|
|
1271
|
+
}
|
|
1272
|
+
[Us](t) {
|
|
1273
|
+
let e = true;
|
|
1274
|
+
if (!t)
|
|
1275
|
+
this[et] = undefined, e = false;
|
|
1276
|
+
else if (Array.isArray(t)) {
|
|
1277
|
+
let [i, ...r] = t;
|
|
1278
|
+
this.emit(i, ...r);
|
|
1279
|
+
} else
|
|
1280
|
+
this[et] = t, this.emit("entry", t), t.emittedEnd || (t.on("end", () => this[Ui]()), e = false);
|
|
1281
|
+
return e;
|
|
1282
|
+
}
|
|
1283
|
+
[Ui]() {
|
|
1284
|
+
do
|
|
1285
|
+
;
|
|
1286
|
+
while (this[Us](this[it].shift()));
|
|
1287
|
+
if (this[it].length === 0) {
|
|
1288
|
+
let t = this[et];
|
|
1289
|
+
!t || t.flowing || t.size === t.remain ? this[Kt] || this.emit("drain") : t.once("drain", () => this.emit("drain"));
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
[Wi](t, e) {
|
|
1293
|
+
let i = this[Nt];
|
|
1294
|
+
if (!i)
|
|
1295
|
+
throw new Error("attempt to consume body without entry??");
|
|
1296
|
+
let r = i.blockRemain ?? 0, n = r >= t.length && e === 0 ? t : t.subarray(e, e + r);
|
|
1297
|
+
return i.write(n), i.blockRemain || (this[B] = "header", this[Nt] = undefined, i.end()), n.length;
|
|
1298
|
+
}
|
|
1299
|
+
[Ws](t, e) {
|
|
1300
|
+
let i = this[Nt], r = this[Wi](t, e);
|
|
1301
|
+
return !this[Nt] && i && this[Hs](i), r;
|
|
1302
|
+
}
|
|
1303
|
+
[At](t, e, i) {
|
|
1304
|
+
this[it].length === 0 && !this[et] ? this.emit(t, e, i) : this[it].push([t, e, i]);
|
|
1305
|
+
}
|
|
1306
|
+
[Hs](t) {
|
|
1307
|
+
switch (this[At]("meta", this[ft]), t.type) {
|
|
1308
|
+
case "ExtendedHeader":
|
|
1309
|
+
case "OldExtendedHeader":
|
|
1310
|
+
this[V] = ct.parse(this[ft], this[V], false);
|
|
1311
|
+
break;
|
|
1312
|
+
case "GlobalExtendedHeader":
|
|
1313
|
+
this[ae] = ct.parse(this[ft], this[ae], true);
|
|
1314
|
+
break;
|
|
1315
|
+
case "NextFileHasLongPath":
|
|
1316
|
+
case "OldGnuLongPath": {
|
|
1317
|
+
let e = this[V] ?? Object.create(null);
|
|
1318
|
+
this[V] = e, e.path = this[ft].replace(/\0.*/, "");
|
|
1319
|
+
break;
|
|
1320
|
+
}
|
|
1321
|
+
case "NextFileHasLongLinkpath": {
|
|
1322
|
+
let e = this[V] || Object.create(null);
|
|
1323
|
+
this[V] = e, e.linkpath = this[ft].replace(/\0.*/, "");
|
|
1324
|
+
break;
|
|
1325
|
+
}
|
|
1326
|
+
default:
|
|
1327
|
+
throw new Error("unknown meta: " + t.type);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
abort(t) {
|
|
1331
|
+
this[ut] = true, this.emit("abort", t), this.warn("TAR_ABORT", t, { recoverable: false });
|
|
1332
|
+
}
|
|
1333
|
+
write(t, e, i) {
|
|
1334
|
+
if (typeof e == "function" && (i = e, e = undefined), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this[ut])
|
|
1335
|
+
return i?.(), false;
|
|
1336
|
+
if ((this[y] === undefined || this.brotli === undefined && this[y] === false) && t) {
|
|
1337
|
+
if (this[p] && (t = Buffer.concat([this[p], t]), this[p] = undefined), t.length < On)
|
|
1338
|
+
return this[p] = t, i?.(), true;
|
|
1339
|
+
for (let a = 0;this[y] === undefined && a < Zi.length; a++)
|
|
1340
|
+
t[a] !== Zi[a] && (this[y] = false);
|
|
1341
|
+
let o = false;
|
|
1342
|
+
if (this[y] === false && this.zstd !== false) {
|
|
1343
|
+
o = true;
|
|
1344
|
+
for (let a = 0;a < Yi.length; a++)
|
|
1345
|
+
if (t[a] !== Yi[a]) {
|
|
1346
|
+
o = false;
|
|
1347
|
+
break;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
let h = this.brotli === undefined && !o;
|
|
1351
|
+
if (this[y] === false && h)
|
|
1352
|
+
if (t.length < 512)
|
|
1353
|
+
if (this[dt])
|
|
1354
|
+
this.brotli = true;
|
|
1355
|
+
else
|
|
1356
|
+
return this[p] = t, i?.(), true;
|
|
1357
|
+
else
|
|
1358
|
+
try {
|
|
1359
|
+
new F(t.subarray(0, 512)), this.brotli = false;
|
|
1360
|
+
} catch {
|
|
1361
|
+
this.brotli = true;
|
|
1362
|
+
}
|
|
1363
|
+
if (this[y] === undefined || this[y] === false && (this.brotli || o)) {
|
|
1364
|
+
let a = this[dt];
|
|
1365
|
+
this[dt] = false, this[y] = this[y] === undefined ? new ze({}) : o ? new Ye({}) : new We({}), this[y].on("data", (c) => this[Ve](c)), this[y].on("error", (c) => this.abort(c)), this[y].on("end", () => {
|
|
1366
|
+
this[dt] = true, this[Ve]();
|
|
1367
|
+
}), this[Kt] = true;
|
|
1368
|
+
let l = !!this[y][a ? "end" : "write"](t);
|
|
1369
|
+
return this[Kt] = false, i?.(), l;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
this[Kt] = true, this[y] ? this[y].write(t) : this[Ve](t), this[Kt] = false;
|
|
1373
|
+
let n = this[it].length > 0 ? false : this[et] ? this[et].flowing : true;
|
|
1374
|
+
return !n && this[it].length === 0 && this[et]?.once("drain", () => this.emit("drain")), i?.(), n;
|
|
1375
|
+
}
|
|
1376
|
+
[Gi](t) {
|
|
1377
|
+
t && !this[ut] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
|
|
1378
|
+
}
|
|
1379
|
+
[Xe]() {
|
|
1380
|
+
if (this[dt] && !this[Hi] && !this[ut] && !this[le]) {
|
|
1381
|
+
this[Hi] = true;
|
|
1382
|
+
let t = this[Nt];
|
|
1383
|
+
if (t && t.blockRemain) {
|
|
1384
|
+
let e = this[p] ? this[p].length : 0;
|
|
1385
|
+
this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`, { entry: t }), this[p] && t.write(this[p]), t.end();
|
|
1386
|
+
}
|
|
1387
|
+
this[At](qe);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
[Ve](t) {
|
|
1391
|
+
if (this[le] && t)
|
|
1392
|
+
this[Gi](t);
|
|
1393
|
+
else if (!t && !this[p])
|
|
1394
|
+
this[Xe]();
|
|
1395
|
+
else if (t) {
|
|
1396
|
+
if (this[le] = true, this[p]) {
|
|
1397
|
+
this[Gi](t);
|
|
1398
|
+
let e = this[p];
|
|
1399
|
+
this[p] = undefined, this[$e](e);
|
|
1400
|
+
} else
|
|
1401
|
+
this[$e](t);
|
|
1402
|
+
for (;this[p] && this[p]?.length >= 512 && !this[ut] && !this[Qe]; ) {
|
|
1403
|
+
let e = this[p];
|
|
1404
|
+
this[p] = undefined, this[$e](e);
|
|
1405
|
+
}
|
|
1406
|
+
this[le] = false;
|
|
1407
|
+
}
|
|
1408
|
+
(!this[p] || this[dt]) && this[Xe]();
|
|
1409
|
+
}
|
|
1410
|
+
[$e](t) {
|
|
1411
|
+
let e = 0, i = t.length;
|
|
1412
|
+
for (;e + 512 <= i && !this[ut] && !this[Qe]; )
|
|
1413
|
+
switch (this[B]) {
|
|
1414
|
+
case "begin":
|
|
1415
|
+
case "header":
|
|
1416
|
+
this[Gs](t, e), e += 512;
|
|
1417
|
+
break;
|
|
1418
|
+
case "ignore":
|
|
1419
|
+
case "body":
|
|
1420
|
+
e += this[Wi](t, e);
|
|
1421
|
+
break;
|
|
1422
|
+
case "meta":
|
|
1423
|
+
e += this[Ws](t, e);
|
|
1424
|
+
break;
|
|
1425
|
+
default:
|
|
1426
|
+
throw new Error("invalid state: " + this[B]);
|
|
1427
|
+
}
|
|
1428
|
+
e < i && (this[p] = this[p] ? Buffer.concat([t.subarray(e), this[p]]) : t.subarray(e));
|
|
1429
|
+
}
|
|
1430
|
+
end(t, e, i) {
|
|
1431
|
+
return typeof t == "function" && (i = t, e = undefined, t = undefined), typeof e == "function" && (i = e, e = undefined), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[ut] || (this[y] ? (t && this[y].write(t), this[y].end()) : (this[dt] = true, (this.brotli === undefined || this.zstd === undefined) && (t = t || Buffer.alloc(0)), t && this.write(t), this[Xe]())), this;
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
var mt = (s2) => {
|
|
1435
|
+
let t = s2.length - 1, e = -1;
|
|
1436
|
+
for (;t > -1 && s2.charAt(t) === "/"; )
|
|
1437
|
+
e = t, t--;
|
|
1438
|
+
return e === -1 ? s2 : s2.slice(0, e);
|
|
1439
|
+
};
|
|
1440
|
+
var Nn = (s2) => {
|
|
1441
|
+
let t = s2.onReadEntry;
|
|
1442
|
+
s2.onReadEntry = t ? (e) => {
|
|
1443
|
+
t(e), e.resume();
|
|
1444
|
+
} : (e) => e.resume();
|
|
1445
|
+
};
|
|
1446
|
+
var Ki = (s2, t) => {
|
|
1447
|
+
let e = new Map(t.map((n) => [mt(n), true])), i = s2.filter, r = (n, o = "") => {
|
|
1448
|
+
let h = o || Ln(n).root || ".", a;
|
|
1449
|
+
if (n === h)
|
|
1450
|
+
a = false;
|
|
1451
|
+
else {
|
|
1452
|
+
let l = e.get(n);
|
|
1453
|
+
a = l !== undefined ? l : r(xn(n), h);
|
|
1454
|
+
}
|
|
1455
|
+
return e.set(n, a), a;
|
|
1456
|
+
};
|
|
1457
|
+
s2.filter = i ? (n, o) => i(n, o) && r(mt(n)) : (n) => r(mt(n));
|
|
1458
|
+
};
|
|
1459
|
+
var An = (s2) => {
|
|
1460
|
+
let t = new st(s2), e = s2.file, i;
|
|
1461
|
+
try {
|
|
1462
|
+
i = Vt.openSync(e, "r");
|
|
1463
|
+
let r = Vt.fstatSync(i), n = s2.maxReadSize || 16 * 1024 * 1024;
|
|
1464
|
+
if (r.size < n) {
|
|
1465
|
+
let o = Buffer.allocUnsafe(r.size), h = Vt.readSync(i, o, 0, r.size, 0);
|
|
1466
|
+
t.end(h === o.byteLength ? o : o.subarray(0, h));
|
|
1467
|
+
} else {
|
|
1468
|
+
let o = 0, h = Buffer.allocUnsafe(n);
|
|
1469
|
+
for (;o < r.size; ) {
|
|
1470
|
+
let a = Vt.readSync(i, h, 0, n, o);
|
|
1471
|
+
if (a === 0)
|
|
1472
|
+
break;
|
|
1473
|
+
o += a, t.write(h.subarray(0, a));
|
|
1474
|
+
}
|
|
1475
|
+
t.end();
|
|
1476
|
+
}
|
|
1477
|
+
} finally {
|
|
1478
|
+
if (typeof i == "number")
|
|
1479
|
+
try {
|
|
1480
|
+
Vt.closeSync(i);
|
|
1481
|
+
} catch {}
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
var Dn = (s2, t) => {
|
|
1485
|
+
let e = new st(s2), i = s2.maxReadSize || 16 * 1024 * 1024, r = s2.file;
|
|
1486
|
+
return new Promise((o, h) => {
|
|
1487
|
+
e.on("error", h), e.on("end", o), Vt.stat(r, (a, l) => {
|
|
1488
|
+
if (a)
|
|
1489
|
+
h(a);
|
|
1490
|
+
else {
|
|
1491
|
+
let c = new _t(r, { readSize: i, size: l.size });
|
|
1492
|
+
c.on("error", h), c.pipe(e);
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
});
|
|
1496
|
+
};
|
|
1497
|
+
var It = K(An, Dn, (s2) => new st(s2), (s2) => new st(s2), (s2, t) => {
|
|
1498
|
+
t?.length && Ki(s2, t), s2.noResume || Nn(s2);
|
|
1499
|
+
});
|
|
1500
|
+
var Vi = (s2, t, e) => (s2 &= 4095, e && (s2 = (s2 | 384) & -19), t && (s2 & 256 && (s2 |= 64), s2 & 32 && (s2 |= 8), s2 & 4 && (s2 |= 1)), s2);
|
|
1501
|
+
var { isAbsolute: Cn, parse: Ys } = In;
|
|
1502
|
+
var ce = (s2) => {
|
|
1503
|
+
let t = "", e = Ys(s2);
|
|
1504
|
+
for (;Cn(s2) || e.root; ) {
|
|
1505
|
+
let i = s2.charAt(0) === "/" && s2.slice(0, 4) !== "//?/" ? "/" : e.root;
|
|
1506
|
+
s2 = s2.slice(i.length), t += i, e = Ys(s2);
|
|
1507
|
+
}
|
|
1508
|
+
return [t, s2];
|
|
1509
|
+
};
|
|
1510
|
+
var Je = ["|", "<", ">", "?", ":"];
|
|
1511
|
+
var $i = Je.map((s2) => String.fromCodePoint(61440 + Number(s2.codePointAt(0))));
|
|
1512
|
+
var Fn = new Map(Je.map((s2, t) => [s2, $i[t]]));
|
|
1513
|
+
var kn = new Map($i.map((s2, t) => [s2, Je[t]]));
|
|
1514
|
+
var Xi = (s2) => Je.reduce((t, e) => t.split(e).join(Fn.get(e)), s2);
|
|
1515
|
+
var Ks = (s2) => $i.reduce((t, e) => t.split(e).join(kn.get(e)), s2);
|
|
1516
|
+
var Js = (s2, t) => t ? (s2 = f(s2).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s2) : f(s2);
|
|
1517
|
+
var vn = 16 * 1024 * 1024;
|
|
1518
|
+
var Xs = Symbol("process");
|
|
1519
|
+
var qs = Symbol("file");
|
|
1520
|
+
var js = Symbol("directory");
|
|
1521
|
+
var ji = Symbol("symlink");
|
|
1522
|
+
var Qs = Symbol("hardlink");
|
|
1523
|
+
var fe = Symbol("header");
|
|
1524
|
+
var ti = Symbol("read");
|
|
1525
|
+
var Qi = Symbol("lstat");
|
|
1526
|
+
var ei = Symbol("onlstat");
|
|
1527
|
+
var Ji = Symbol("onread");
|
|
1528
|
+
var ts = Symbol("onreadlink");
|
|
1529
|
+
var es = Symbol("openfile");
|
|
1530
|
+
var is = Symbol("onopenfile");
|
|
1531
|
+
var pt = Symbol("close");
|
|
1532
|
+
var ii = Symbol("mode");
|
|
1533
|
+
var ss = Symbol("awaitDrain");
|
|
1534
|
+
var qi = Symbol("ondrain");
|
|
1535
|
+
var X = Symbol("prefix");
|
|
1536
|
+
var de = class extends D {
|
|
1537
|
+
path;
|
|
1538
|
+
portable;
|
|
1539
|
+
myuid = process.getuid && process.getuid() || 0;
|
|
1540
|
+
myuser = process.env.USER || "";
|
|
1541
|
+
maxReadSize;
|
|
1542
|
+
linkCache;
|
|
1543
|
+
statCache;
|
|
1544
|
+
preservePaths;
|
|
1545
|
+
cwd;
|
|
1546
|
+
strict;
|
|
1547
|
+
mtime;
|
|
1548
|
+
noPax;
|
|
1549
|
+
noMtime;
|
|
1550
|
+
prefix;
|
|
1551
|
+
fd;
|
|
1552
|
+
blockLen = 0;
|
|
1553
|
+
blockRemain = 0;
|
|
1554
|
+
buf;
|
|
1555
|
+
pos = 0;
|
|
1556
|
+
remain = 0;
|
|
1557
|
+
length = 0;
|
|
1558
|
+
offset = 0;
|
|
1559
|
+
win32;
|
|
1560
|
+
absolute;
|
|
1561
|
+
header;
|
|
1562
|
+
type;
|
|
1563
|
+
linkpath;
|
|
1564
|
+
stat;
|
|
1565
|
+
onWriteEntry;
|
|
1566
|
+
#t = false;
|
|
1567
|
+
constructor(t, e = {}) {
|
|
1568
|
+
let i = re(e);
|
|
1569
|
+
super(), this.path = f(t), this.portable = !!i.portable, this.maxReadSize = i.maxReadSize || vn, this.linkCache = i.linkCache || new Map, this.statCache = i.statCache || new Map, this.preservePaths = !!i.preservePaths, this.cwd = f(i.cwd || process.cwd()), this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.mtime = i.mtime, this.prefix = i.prefix ? f(i.prefix) : undefined, this.onWriteEntry = i.onWriteEntry, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
1570
|
+
let r = false;
|
|
1571
|
+
if (!this.preservePaths) {
|
|
1572
|
+
let [o, h] = ce(this.path);
|
|
1573
|
+
o && typeof h == "string" && (this.path = h, r = o);
|
|
1574
|
+
}
|
|
1575
|
+
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Ks(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || $s.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, { entry: this, path: r + this.path });
|
|
1576
|
+
let n = this.statCache.get(this.absolute);
|
|
1577
|
+
n ? this[ei](n) : this[Qi]();
|
|
1578
|
+
}
|
|
1579
|
+
warn(t, e, i = {}) {
|
|
1580
|
+
return Lt(this, t, e, i);
|
|
1581
|
+
}
|
|
1582
|
+
emit(t, ...e) {
|
|
1583
|
+
return t === "error" && (this.#t = true), super.emit(t, ...e);
|
|
1584
|
+
}
|
|
1585
|
+
[Qi]() {
|
|
1586
|
+
$.lstat(this.absolute, (t, e) => {
|
|
1587
|
+
if (t)
|
|
1588
|
+
return this.emit("error", t);
|
|
1589
|
+
this[ei](e);
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
[ei](t) {
|
|
1593
|
+
this.statCache.set(this.absolute, t), this.stat = t, t.isFile() || (t.size = 0), this.type = Mn(t), this.emit("stat", t), this[Xs]();
|
|
1594
|
+
}
|
|
1595
|
+
[Xs]() {
|
|
1596
|
+
switch (this.type) {
|
|
1597
|
+
case "File":
|
|
1598
|
+
return this[qs]();
|
|
1599
|
+
case "Directory":
|
|
1600
|
+
return this[js]();
|
|
1601
|
+
case "SymbolicLink":
|
|
1602
|
+
return this[ji]();
|
|
1603
|
+
default:
|
|
1604
|
+
return this.end();
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
[ii](t) {
|
|
1608
|
+
return Vi(t, this.type === "Directory", this.portable);
|
|
1609
|
+
}
|
|
1610
|
+
[X](t) {
|
|
1611
|
+
return Js(t, this.prefix);
|
|
1612
|
+
}
|
|
1613
|
+
[fe]() {
|
|
1614
|
+
if (!this.stat)
|
|
1615
|
+
throw new Error("cannot write header before stat");
|
|
1616
|
+
this.type === "Directory" && this.portable && (this.noMtime = true), this.onWriteEntry?.(this), this.header = new F({ path: this[X](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X](this.linkpath) : this.linkpath, mode: this[ii](this.stat.mode), uid: this.portable ? undefined : this.stat.uid, gid: this.portable ? undefined : this.stat.gid, size: this.stat.size, mtime: this.noMtime ? undefined : this.mtime || this.stat.mtime, type: this.type === "Unsupported" ? undefined : this.type, uname: this.portable ? undefined : this.stat.uid === this.myuid ? this.myuser : "", atime: this.portable ? undefined : this.stat.atime, ctime: this.portable ? undefined : this.stat.ctime }), this.header.encode() && !this.noPax && super.write(new ct({ atime: this.portable ? undefined : this.header.atime, ctime: this.portable ? undefined : this.header.ctime, gid: this.portable ? undefined : this.header.gid, mtime: this.noMtime ? undefined : this.mtime || this.header.mtime, path: this[X](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X](this.linkpath) : this.linkpath, size: this.header.size, uid: this.portable ? undefined : this.header.uid, uname: this.portable ? undefined : this.header.uname, dev: this.portable ? undefined : this.stat.dev, ino: this.portable ? undefined : this.stat.ino, nlink: this.portable ? undefined : this.stat.nlink }).encode());
|
|
1617
|
+
let t = this.header?.block;
|
|
1618
|
+
if (!t)
|
|
1619
|
+
throw new Error("failed to encode header");
|
|
1620
|
+
super.write(t);
|
|
1621
|
+
}
|
|
1622
|
+
[js]() {
|
|
1623
|
+
if (!this.stat)
|
|
1624
|
+
throw new Error("cannot create directory entry without stat");
|
|
1625
|
+
this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
|
|
1626
|
+
}
|
|
1627
|
+
[ji]() {
|
|
1628
|
+
$.readlink(this.absolute, (t, e) => {
|
|
1629
|
+
if (t)
|
|
1630
|
+
return this.emit("error", t);
|
|
1631
|
+
this[ts](e);
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
[ts](t) {
|
|
1635
|
+
this.linkpath = f(t), this[fe](), this.end();
|
|
1636
|
+
}
|
|
1637
|
+
[Qs](t) {
|
|
1638
|
+
if (!this.stat)
|
|
1639
|
+
throw new Error("cannot create link entry without stat");
|
|
1640
|
+
this.type = "Link", this.linkpath = f($s.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
|
|
1641
|
+
}
|
|
1642
|
+
[qs]() {
|
|
1643
|
+
if (!this.stat)
|
|
1644
|
+
throw new Error("cannot create file entry without stat");
|
|
1645
|
+
if (this.stat.nlink > 1) {
|
|
1646
|
+
let t = `${this.stat.dev}:${this.stat.ino}`, e = this.linkCache.get(t);
|
|
1647
|
+
if (e?.indexOf(this.cwd) === 0)
|
|
1648
|
+
return this[Qs](e);
|
|
1649
|
+
this.linkCache.set(t, this.absolute);
|
|
1650
|
+
}
|
|
1651
|
+
if (this[fe](), this.stat.size === 0)
|
|
1652
|
+
return this.end();
|
|
1653
|
+
this[es]();
|
|
1654
|
+
}
|
|
1655
|
+
[es]() {
|
|
1656
|
+
$.open(this.absolute, "r", (t, e) => {
|
|
1657
|
+
if (t)
|
|
1658
|
+
return this.emit("error", t);
|
|
1659
|
+
this[is](e);
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
[is](t) {
|
|
1663
|
+
if (this.fd = t, this.#t)
|
|
1664
|
+
return this[pt]();
|
|
1665
|
+
if (!this.stat)
|
|
1666
|
+
throw new Error("should stat before calling onopenfile");
|
|
1667
|
+
this.blockLen = 512 * Math.ceil(this.stat.size / 512), this.blockRemain = this.blockLen;
|
|
1668
|
+
let e = Math.min(this.blockLen, this.maxReadSize);
|
|
1669
|
+
this.buf = Buffer.allocUnsafe(e), this.offset = 0, this.pos = 0, this.remain = this.stat.size, this.length = this.buf.length, this[ti]();
|
|
1670
|
+
}
|
|
1671
|
+
[ti]() {
|
|
1672
|
+
let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
|
|
1673
|
+
if (t === undefined || e === undefined)
|
|
1674
|
+
throw new Error("cannot read file without first opening");
|
|
1675
|
+
$.read(t, e, i, r, n, (o, h) => {
|
|
1676
|
+
if (o)
|
|
1677
|
+
return this[pt](() => this.emit("error", o));
|
|
1678
|
+
this[Ji](h);
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
[pt](t = () => {}) {
|
|
1682
|
+
this.fd !== undefined && $.close(this.fd, t);
|
|
1683
|
+
}
|
|
1684
|
+
[Ji](t) {
|
|
1685
|
+
if (t <= 0 && this.remain > 0) {
|
|
1686
|
+
let r = Object.assign(new Error("encountered unexpected EOF"), { path: this.absolute, syscall: "read", code: "EOF" });
|
|
1687
|
+
return this[pt](() => this.emit("error", r));
|
|
1688
|
+
}
|
|
1689
|
+
if (t > this.remain) {
|
|
1690
|
+
let r = Object.assign(new Error("did not encounter expected EOF"), { path: this.absolute, syscall: "read", code: "EOF" });
|
|
1691
|
+
return this[pt](() => this.emit("error", r));
|
|
1692
|
+
}
|
|
1693
|
+
if (!this.buf)
|
|
1694
|
+
throw new Error("should have created buffer prior to reading");
|
|
1695
|
+
if (t === this.remain)
|
|
1696
|
+
for (let r = t;r < this.length && t < this.blockRemain; r++)
|
|
1697
|
+
this.buf[r + this.offset] = 0, t++, this.remain++;
|
|
1698
|
+
let e = this.offset === 0 && t === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + t);
|
|
1699
|
+
this.write(e) ? this[qi]() : this[ss](() => this[qi]());
|
|
1700
|
+
}
|
|
1701
|
+
[ss](t) {
|
|
1702
|
+
this.once("drain", t);
|
|
1703
|
+
}
|
|
1704
|
+
write(t, e, i) {
|
|
1705
|
+
if (typeof e == "function" && (i = e, e = undefined), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8")), this.blockRemain < t.length) {
|
|
1706
|
+
let r = Object.assign(new Error("writing more data than expected"), { path: this.absolute });
|
|
1707
|
+
return this.emit("error", r);
|
|
1708
|
+
}
|
|
1709
|
+
return this.remain -= t.length, this.blockRemain -= t.length, this.pos += t.length, this.offset += t.length, super.write(t, null, i);
|
|
1710
|
+
}
|
|
1711
|
+
[qi]() {
|
|
1712
|
+
if (!this.remain)
|
|
1713
|
+
return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), this[pt]((t) => t ? this.emit("error", t) : this.end());
|
|
1714
|
+
if (!this.buf)
|
|
1715
|
+
throw new Error("buffer lost somehow in ONDRAIN");
|
|
1716
|
+
this.offset >= this.length && (this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length)), this.offset = 0), this.length = this.buf.length - this.offset, this[ti]();
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
var si = class extends de {
|
|
1720
|
+
sync = true;
|
|
1721
|
+
[Qi]() {
|
|
1722
|
+
this[ei]($.lstatSync(this.absolute));
|
|
1723
|
+
}
|
|
1724
|
+
[ji]() {
|
|
1725
|
+
this[ts]($.readlinkSync(this.absolute));
|
|
1726
|
+
}
|
|
1727
|
+
[es]() {
|
|
1728
|
+
this[is]($.openSync(this.absolute, "r"));
|
|
1729
|
+
}
|
|
1730
|
+
[ti]() {
|
|
1731
|
+
let t = true;
|
|
1732
|
+
try {
|
|
1733
|
+
let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
|
|
1734
|
+
if (e === undefined || i === undefined)
|
|
1735
|
+
throw new Error("fd and buf must be set in READ method");
|
|
1736
|
+
let h = $.readSync(e, i, r, n, o);
|
|
1737
|
+
this[Ji](h), t = false;
|
|
1738
|
+
} finally {
|
|
1739
|
+
if (t)
|
|
1740
|
+
try {
|
|
1741
|
+
this[pt](() => {});
|
|
1742
|
+
} catch {}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
[ss](t) {
|
|
1746
|
+
t();
|
|
1747
|
+
}
|
|
1748
|
+
[pt](t = () => {}) {
|
|
1749
|
+
this.fd !== undefined && $.closeSync(this.fd), t();
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
var ri = class extends D {
|
|
1753
|
+
blockLen = 0;
|
|
1754
|
+
blockRemain = 0;
|
|
1755
|
+
buf = 0;
|
|
1756
|
+
pos = 0;
|
|
1757
|
+
remain = 0;
|
|
1758
|
+
length = 0;
|
|
1759
|
+
preservePaths;
|
|
1760
|
+
portable;
|
|
1761
|
+
strict;
|
|
1762
|
+
noPax;
|
|
1763
|
+
noMtime;
|
|
1764
|
+
readEntry;
|
|
1765
|
+
type;
|
|
1766
|
+
prefix;
|
|
1767
|
+
path;
|
|
1768
|
+
mode;
|
|
1769
|
+
uid;
|
|
1770
|
+
gid;
|
|
1771
|
+
uname;
|
|
1772
|
+
gname;
|
|
1773
|
+
header;
|
|
1774
|
+
mtime;
|
|
1775
|
+
atime;
|
|
1776
|
+
ctime;
|
|
1777
|
+
linkpath;
|
|
1778
|
+
size;
|
|
1779
|
+
onWriteEntry;
|
|
1780
|
+
warn(t, e, i = {}) {
|
|
1781
|
+
return Lt(this, t, e, i);
|
|
1782
|
+
}
|
|
1783
|
+
constructor(t, e = {}) {
|
|
1784
|
+
let i = re(e);
|
|
1785
|
+
super(), this.preservePaths = !!i.preservePaths, this.portable = !!i.portable, this.strict = !!i.strict, this.noPax = !!i.noPax, this.noMtime = !!i.noMtime, this.onWriteEntry = i.onWriteEntry, this.readEntry = t;
|
|
1786
|
+
let { type: r } = t;
|
|
1787
|
+
if (r === "Unsupported")
|
|
1788
|
+
throw new Error("writing entry that should be ignored");
|
|
1789
|
+
this.type = r, this.type === "Directory" && this.portable && (this.noMtime = true), this.prefix = i.prefix, this.path = f(t.path), this.mode = t.mode !== undefined ? this[ii](t.mode) : undefined, this.uid = this.portable ? undefined : t.uid, this.gid = this.portable ? undefined : t.gid, this.uname = this.portable ? undefined : t.uname, this.gname = this.portable ? undefined : t.gname, this.size = t.size, this.mtime = this.noMtime ? undefined : i.mtime || t.mtime, this.atime = this.portable ? undefined : t.atime, this.ctime = this.portable ? undefined : t.ctime, this.linkpath = t.linkpath !== undefined ? f(t.linkpath) : undefined, typeof i.onwarn == "function" && this.on("warn", i.onwarn);
|
|
1790
|
+
let n = false;
|
|
1791
|
+
if (!this.preservePaths) {
|
|
1792
|
+
let [h, a] = ce(this.path);
|
|
1793
|
+
h && typeof a == "string" && (this.path = a, n = h);
|
|
1794
|
+
}
|
|
1795
|
+
this.remain = t.size, this.blockRemain = t.startBlockSize, this.onWriteEntry?.(this), this.header = new F({ path: this[X](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X](this.linkpath) : this.linkpath, mode: this.mode, uid: this.portable ? undefined : this.uid, gid: this.portable ? undefined : this.gid, size: this.size, mtime: this.noMtime ? undefined : this.mtime, type: this.type, uname: this.portable ? undefined : this.uname, atime: this.portable ? undefined : this.atime, ctime: this.portable ? undefined : this.ctime }), n && this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute path`, { entry: this, path: n + this.path }), this.header.encode() && !this.noPax && super.write(new ct({ atime: this.portable ? undefined : this.atime, ctime: this.portable ? undefined : this.ctime, gid: this.portable ? undefined : this.gid, mtime: this.noMtime ? undefined : this.mtime, path: this[X](this.path), linkpath: this.type === "Link" && this.linkpath !== undefined ? this[X](this.linkpath) : this.linkpath, size: this.size, uid: this.portable ? undefined : this.uid, uname: this.portable ? undefined : this.uname, dev: this.portable ? undefined : this.readEntry.dev, ino: this.portable ? undefined : this.readEntry.ino, nlink: this.portable ? undefined : this.readEntry.nlink }).encode());
|
|
1796
|
+
let o = this.header?.block;
|
|
1797
|
+
if (!o)
|
|
1798
|
+
throw new Error("failed to encode header");
|
|
1799
|
+
super.write(o), t.pipe(this);
|
|
1800
|
+
}
|
|
1801
|
+
[X](t) {
|
|
1802
|
+
return Js(t, this.prefix);
|
|
1803
|
+
}
|
|
1804
|
+
[ii](t) {
|
|
1805
|
+
return Vi(t, this.type === "Directory", this.portable);
|
|
1806
|
+
}
|
|
1807
|
+
write(t, e, i) {
|
|
1808
|
+
typeof e == "function" && (i = e, e = undefined), typeof t == "string" && (t = Buffer.from(t, typeof e == "string" ? e : "utf8"));
|
|
1809
|
+
let r = t.length;
|
|
1810
|
+
if (r > this.blockRemain)
|
|
1811
|
+
throw new Error("writing more to entry than is appropriate");
|
|
1812
|
+
return this.blockRemain -= r, super.write(t, i);
|
|
1813
|
+
}
|
|
1814
|
+
end(t, e, i) {
|
|
1815
|
+
return this.blockRemain && super.write(Buffer.alloc(this.blockRemain)), typeof t == "function" && (i = t, e = undefined, t = undefined), typeof e == "function" && (i = e, e = undefined), typeof t == "string" && (t = Buffer.from(t, e ?? "utf8")), i && this.once("finish", i), t ? super.end(t, i) : super.end(i), this;
|
|
1816
|
+
}
|
|
1817
|
+
};
|
|
1818
|
+
var Mn = (s2) => s2.isFile() ? "File" : s2.isDirectory() ? "Directory" : s2.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
|
|
1819
|
+
var ni = class s2 {
|
|
1820
|
+
tail;
|
|
1821
|
+
head;
|
|
1822
|
+
length = 0;
|
|
1823
|
+
static create(t = []) {
|
|
1824
|
+
return new s2(t);
|
|
1825
|
+
}
|
|
1826
|
+
constructor(t = []) {
|
|
1827
|
+
for (let e of t)
|
|
1828
|
+
this.push(e);
|
|
1829
|
+
}
|
|
1830
|
+
*[Symbol.iterator]() {
|
|
1831
|
+
for (let t = this.head;t; t = t.next)
|
|
1832
|
+
yield t.value;
|
|
1833
|
+
}
|
|
1834
|
+
removeNode(t) {
|
|
1835
|
+
if (t.list !== this)
|
|
1836
|
+
throw new Error("removing node which does not belong to this list");
|
|
1837
|
+
let { next: e, prev: i } = t;
|
|
1838
|
+
return e && (e.prev = i), i && (i.next = e), t === this.head && (this.head = e), t === this.tail && (this.tail = i), this.length--, t.next = undefined, t.prev = undefined, t.list = undefined, e;
|
|
1839
|
+
}
|
|
1840
|
+
unshiftNode(t) {
|
|
1841
|
+
if (t === this.head)
|
|
1842
|
+
return;
|
|
1843
|
+
t.list && t.list.removeNode(t);
|
|
1844
|
+
let e = this.head;
|
|
1845
|
+
t.list = this, t.next = e, e && (e.prev = t), this.head = t, this.tail || (this.tail = t), this.length++;
|
|
1846
|
+
}
|
|
1847
|
+
pushNode(t) {
|
|
1848
|
+
if (t === this.tail)
|
|
1849
|
+
return;
|
|
1850
|
+
t.list && t.list.removeNode(t);
|
|
1851
|
+
let e = this.tail;
|
|
1852
|
+
t.list = this, t.prev = e, e && (e.next = t), this.tail = t, this.head || (this.head = t), this.length++;
|
|
1853
|
+
}
|
|
1854
|
+
push(...t) {
|
|
1855
|
+
for (let e = 0, i = t.length;e < i; e++)
|
|
1856
|
+
Pn(this, t[e]);
|
|
1857
|
+
return this.length;
|
|
1858
|
+
}
|
|
1859
|
+
unshift(...t) {
|
|
1860
|
+
for (var e = 0, i = t.length;e < i; e++)
|
|
1861
|
+
zn(this, t[e]);
|
|
1862
|
+
return this.length;
|
|
1863
|
+
}
|
|
1864
|
+
pop() {
|
|
1865
|
+
if (!this.tail)
|
|
1866
|
+
return;
|
|
1867
|
+
let t = this.tail.value, e = this.tail;
|
|
1868
|
+
return this.tail = this.tail.prev, this.tail ? this.tail.next = undefined : this.head = undefined, e.list = undefined, this.length--, t;
|
|
1869
|
+
}
|
|
1870
|
+
shift() {
|
|
1871
|
+
if (!this.head)
|
|
1872
|
+
return;
|
|
1873
|
+
let t = this.head.value, e = this.head;
|
|
1874
|
+
return this.head = this.head.next, this.head ? this.head.prev = undefined : this.tail = undefined, e.list = undefined, this.length--, t;
|
|
1875
|
+
}
|
|
1876
|
+
forEach(t, e) {
|
|
1877
|
+
e = e || this;
|
|
1878
|
+
for (let i = this.head, r = 0;i; r++)
|
|
1879
|
+
t.call(e, i.value, r, this), i = i.next;
|
|
1880
|
+
}
|
|
1881
|
+
forEachReverse(t, e) {
|
|
1882
|
+
e = e || this;
|
|
1883
|
+
for (let i = this.tail, r = this.length - 1;i; r--)
|
|
1884
|
+
t.call(e, i.value, r, this), i = i.prev;
|
|
1885
|
+
}
|
|
1886
|
+
get(t) {
|
|
1887
|
+
let e = 0, i = this.head;
|
|
1888
|
+
for (;i && e < t; e++)
|
|
1889
|
+
i = i.next;
|
|
1890
|
+
if (e === t && i)
|
|
1891
|
+
return i.value;
|
|
1892
|
+
}
|
|
1893
|
+
getReverse(t) {
|
|
1894
|
+
let e = 0, i = this.tail;
|
|
1895
|
+
for (;i && e < t; e++)
|
|
1896
|
+
i = i.prev;
|
|
1897
|
+
if (e === t && i)
|
|
1898
|
+
return i.value;
|
|
1899
|
+
}
|
|
1900
|
+
map(t, e) {
|
|
1901
|
+
e = e || this;
|
|
1902
|
+
let i = new s2;
|
|
1903
|
+
for (let r = this.head;r; )
|
|
1904
|
+
i.push(t.call(e, r.value, this)), r = r.next;
|
|
1905
|
+
return i;
|
|
1906
|
+
}
|
|
1907
|
+
mapReverse(t, e) {
|
|
1908
|
+
e = e || this;
|
|
1909
|
+
var i = new s2;
|
|
1910
|
+
for (let r = this.tail;r; )
|
|
1911
|
+
i.push(t.call(e, r.value, this)), r = r.prev;
|
|
1912
|
+
return i;
|
|
1913
|
+
}
|
|
1914
|
+
reduce(t, e) {
|
|
1915
|
+
let i, r = this.head;
|
|
1916
|
+
if (arguments.length > 1)
|
|
1917
|
+
i = e;
|
|
1918
|
+
else if (this.head)
|
|
1919
|
+
r = this.head.next, i = this.head.value;
|
|
1920
|
+
else
|
|
1921
|
+
throw new TypeError("Reduce of empty list with no initial value");
|
|
1922
|
+
for (var n = 0;r; n++)
|
|
1923
|
+
i = t(i, r.value, n), r = r.next;
|
|
1924
|
+
return i;
|
|
1925
|
+
}
|
|
1926
|
+
reduceReverse(t, e) {
|
|
1927
|
+
let i, r = this.tail;
|
|
1928
|
+
if (arguments.length > 1)
|
|
1929
|
+
i = e;
|
|
1930
|
+
else if (this.tail)
|
|
1931
|
+
r = this.tail.prev, i = this.tail.value;
|
|
1932
|
+
else
|
|
1933
|
+
throw new TypeError("Reduce of empty list with no initial value");
|
|
1934
|
+
for (let n = this.length - 1;r; n--)
|
|
1935
|
+
i = t(i, r.value, n), r = r.prev;
|
|
1936
|
+
return i;
|
|
1937
|
+
}
|
|
1938
|
+
toArray() {
|
|
1939
|
+
let t = new Array(this.length);
|
|
1940
|
+
for (let e = 0, i = this.head;i; e++)
|
|
1941
|
+
t[e] = i.value, i = i.next;
|
|
1942
|
+
return t;
|
|
1943
|
+
}
|
|
1944
|
+
toArrayReverse() {
|
|
1945
|
+
let t = new Array(this.length);
|
|
1946
|
+
for (let e = 0, i = this.tail;i; e++)
|
|
1947
|
+
t[e] = i.value, i = i.prev;
|
|
1948
|
+
return t;
|
|
1949
|
+
}
|
|
1950
|
+
slice(t = 0, e = this.length) {
|
|
1951
|
+
e < 0 && (e += this.length), t < 0 && (t += this.length);
|
|
1952
|
+
let i = new s2;
|
|
1953
|
+
if (e < t || e < 0)
|
|
1954
|
+
return i;
|
|
1955
|
+
t < 0 && (t = 0), e > this.length && (e = this.length);
|
|
1956
|
+
let r = this.head, n = 0;
|
|
1957
|
+
for (n = 0;r && n < t; n++)
|
|
1958
|
+
r = r.next;
|
|
1959
|
+
for (;r && n < e; n++, r = r.next)
|
|
1960
|
+
i.push(r.value);
|
|
1961
|
+
return i;
|
|
1962
|
+
}
|
|
1963
|
+
sliceReverse(t = 0, e = this.length) {
|
|
1964
|
+
e < 0 && (e += this.length), t < 0 && (t += this.length);
|
|
1965
|
+
let i = new s2;
|
|
1966
|
+
if (e < t || e < 0)
|
|
1967
|
+
return i;
|
|
1968
|
+
t < 0 && (t = 0), e > this.length && (e = this.length);
|
|
1969
|
+
let r = this.length, n = this.tail;
|
|
1970
|
+
for (;n && r > e; r--)
|
|
1971
|
+
n = n.prev;
|
|
1972
|
+
for (;n && r > t; r--, n = n.prev)
|
|
1973
|
+
i.push(n.value);
|
|
1974
|
+
return i;
|
|
1975
|
+
}
|
|
1976
|
+
splice(t, e = 0, ...i) {
|
|
1977
|
+
t > this.length && (t = this.length - 1), t < 0 && (t = this.length + t);
|
|
1978
|
+
let r = this.head;
|
|
1979
|
+
for (let o = 0;r && o < t; o++)
|
|
1980
|
+
r = r.next;
|
|
1981
|
+
let n = [];
|
|
1982
|
+
for (let o = 0;r && o < e; o++)
|
|
1983
|
+
n.push(r.value), r = this.removeNode(r);
|
|
1984
|
+
r ? r !== this.tail && (r = r.prev) : r = this.tail;
|
|
1985
|
+
for (let o of i)
|
|
1986
|
+
r = Bn(this, r, o);
|
|
1987
|
+
return n;
|
|
1988
|
+
}
|
|
1989
|
+
reverse() {
|
|
1990
|
+
let t = this.head, e = this.tail;
|
|
1991
|
+
for (let i = t;i; i = i.prev) {
|
|
1992
|
+
let r = i.prev;
|
|
1993
|
+
i.prev = i.next, i.next = r;
|
|
1994
|
+
}
|
|
1995
|
+
return this.head = e, this.tail = t, this;
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
function Bn(s3, t, e) {
|
|
1999
|
+
let i = t, r = t ? t.next : s3.head, n = new ue(e, i, r, s3);
|
|
2000
|
+
return n.next === undefined && (s3.tail = n), n.prev === undefined && (s3.head = n), s3.length++, n;
|
|
2001
|
+
}
|
|
2002
|
+
function Pn(s3, t) {
|
|
2003
|
+
s3.tail = new ue(t, s3.tail, undefined, s3), s3.head || (s3.head = s3.tail), s3.length++;
|
|
2004
|
+
}
|
|
2005
|
+
function zn(s3, t) {
|
|
2006
|
+
s3.head = new ue(t, undefined, s3.head, s3), s3.tail || (s3.tail = s3.head), s3.length++;
|
|
2007
|
+
}
|
|
2008
|
+
var ue = class {
|
|
2009
|
+
list;
|
|
2010
|
+
next;
|
|
2011
|
+
prev;
|
|
2012
|
+
value;
|
|
2013
|
+
constructor(t, e, i, r) {
|
|
2014
|
+
this.list = r, this.value = t, e ? (e.next = this, this.prev = e) : this.prev = undefined, i ? (i.prev = this, this.next = i) : this.next = undefined;
|
|
2015
|
+
}
|
|
2016
|
+
};
|
|
2017
|
+
var di = class {
|
|
2018
|
+
path;
|
|
2019
|
+
absolute;
|
|
2020
|
+
entry;
|
|
2021
|
+
stat;
|
|
2022
|
+
readdir;
|
|
2023
|
+
pending = false;
|
|
2024
|
+
ignore = false;
|
|
2025
|
+
piped = false;
|
|
2026
|
+
constructor(t, e) {
|
|
2027
|
+
this.path = t || "./", this.absolute = e;
|
|
2028
|
+
}
|
|
2029
|
+
};
|
|
2030
|
+
var tr = Buffer.alloc(1024);
|
|
2031
|
+
var oi = Symbol("onStat");
|
|
2032
|
+
var me = Symbol("ended");
|
|
2033
|
+
var W = Symbol("queue");
|
|
2034
|
+
var Ct = Symbol("current");
|
|
2035
|
+
var Ft = Symbol("process");
|
|
2036
|
+
var pe = Symbol("processing");
|
|
2037
|
+
var rs = Symbol("processJob");
|
|
2038
|
+
var G = Symbol("jobs");
|
|
2039
|
+
var ns = Symbol("jobDone");
|
|
2040
|
+
var hi = Symbol("addFSEntry");
|
|
2041
|
+
var er = Symbol("addTarEntry");
|
|
2042
|
+
var as = Symbol("stat");
|
|
2043
|
+
var ls = Symbol("readdir");
|
|
2044
|
+
var ai = Symbol("onreaddir");
|
|
2045
|
+
var li = Symbol("pipe");
|
|
2046
|
+
var ir = Symbol("entry");
|
|
2047
|
+
var os = Symbol("entryOpt");
|
|
2048
|
+
var ci = Symbol("writeEntryClass");
|
|
2049
|
+
var rr = Symbol("write");
|
|
2050
|
+
var hs = Symbol("ondrain");
|
|
2051
|
+
var Et = class extends D {
|
|
2052
|
+
sync = false;
|
|
2053
|
+
opt;
|
|
2054
|
+
cwd;
|
|
2055
|
+
maxReadSize;
|
|
2056
|
+
preservePaths;
|
|
2057
|
+
strict;
|
|
2058
|
+
noPax;
|
|
2059
|
+
prefix;
|
|
2060
|
+
linkCache;
|
|
2061
|
+
statCache;
|
|
2062
|
+
file;
|
|
2063
|
+
portable;
|
|
2064
|
+
zip;
|
|
2065
|
+
readdirCache;
|
|
2066
|
+
noDirRecurse;
|
|
2067
|
+
follow;
|
|
2068
|
+
noMtime;
|
|
2069
|
+
mtime;
|
|
2070
|
+
filter;
|
|
2071
|
+
jobs;
|
|
2072
|
+
[ci];
|
|
2073
|
+
onWriteEntry;
|
|
2074
|
+
[W];
|
|
2075
|
+
[G] = 0;
|
|
2076
|
+
[pe] = false;
|
|
2077
|
+
[me] = false;
|
|
2078
|
+
constructor(t = {}) {
|
|
2079
|
+
if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f(t.prefix || ""), this.linkCache = t.linkCache || new Map, this.statCache = t.statCache || new Map, this.readdirCache = t.readdirCache || new Map, this.onWriteEntry = t.onWriteEntry, this[ci] = de, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
|
|
2080
|
+
if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1)
|
|
2081
|
+
throw new TypeError("gzip, brotli, zstd are mutually exclusive");
|
|
2082
|
+
if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = true), this.zip = new Pe(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new He(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ze(t.zstd)), !this.zip)
|
|
2083
|
+
throw new Error("impossible");
|
|
2084
|
+
let e = this.zip;
|
|
2085
|
+
e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[hs]()), this.on("resume", () => e.resume());
|
|
2086
|
+
} else
|
|
2087
|
+
this.on("drain", this[hs]);
|
|
2088
|
+
this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => true, this[W] = new ni, this[G] = 0, this.jobs = Number(t.jobs) || 4, this[pe] = false, this[me] = false;
|
|
2089
|
+
}
|
|
2090
|
+
[rr](t) {
|
|
2091
|
+
return super.write(t);
|
|
2092
|
+
}
|
|
2093
|
+
add(t) {
|
|
2094
|
+
return this.write(t), this;
|
|
2095
|
+
}
|
|
2096
|
+
end(t, e, i) {
|
|
2097
|
+
return typeof t == "function" && (i = t, t = undefined), typeof e == "function" && (i = e, e = undefined), t && this.add(t), this[me] = true, this[Ft](), i && i(), this;
|
|
2098
|
+
}
|
|
2099
|
+
write(t) {
|
|
2100
|
+
if (this[me])
|
|
2101
|
+
throw new Error("write after end");
|
|
2102
|
+
return t instanceof Yt ? this[er](t) : this[hi](t), this.flowing;
|
|
2103
|
+
}
|
|
2104
|
+
[er](t) {
|
|
2105
|
+
let e = f(sr.resolve(this.cwd, t.path));
|
|
2106
|
+
if (!this.filter(t.path, t))
|
|
2107
|
+
t.resume();
|
|
2108
|
+
else {
|
|
2109
|
+
let i = new di(t.path, e);
|
|
2110
|
+
i.entry = new ri(t, this[os](i)), i.entry.on("end", () => this[ns](i)), this[G] += 1, this[W].push(i);
|
|
2111
|
+
}
|
|
2112
|
+
this[Ft]();
|
|
2113
|
+
}
|
|
2114
|
+
[hi](t) {
|
|
2115
|
+
let e = f(sr.resolve(this.cwd, t));
|
|
2116
|
+
this[W].push(new di(t, e)), this[Ft]();
|
|
2117
|
+
}
|
|
2118
|
+
[as](t) {
|
|
2119
|
+
t.pending = true, this[G] += 1;
|
|
2120
|
+
let e = this.follow ? "stat" : "lstat";
|
|
2121
|
+
fi[e](t.absolute, (i, r) => {
|
|
2122
|
+
t.pending = false, this[G] -= 1, i ? this.emit("error", i) : this[oi](t, r);
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
[oi](t, e) {
|
|
2126
|
+
this.statCache.set(t.absolute, e), t.stat = e, this.filter(t.path, e) ? e.isFile() && e.nlink > 1 && t === this[Ct] && !this.linkCache.get(`${e.dev}:${e.ino}`) && !this.sync && this[rs](t) : t.ignore = true, this[Ft]();
|
|
2127
|
+
}
|
|
2128
|
+
[ls](t) {
|
|
2129
|
+
t.pending = true, this[G] += 1, fi.readdir(t.absolute, (e, i) => {
|
|
2130
|
+
if (t.pending = false, this[G] -= 1, e)
|
|
2131
|
+
return this.emit("error", e);
|
|
2132
|
+
this[ai](t, i);
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
[ai](t, e) {
|
|
2136
|
+
this.readdirCache.set(t.absolute, e), t.readdir = e, this[Ft]();
|
|
2137
|
+
}
|
|
2138
|
+
[Ft]() {
|
|
2139
|
+
if (!this[pe]) {
|
|
2140
|
+
this[pe] = true;
|
|
2141
|
+
for (let t = this[W].head;t && this[G] < this.jobs; t = t.next)
|
|
2142
|
+
if (this[rs](t.value), t.value.ignore) {
|
|
2143
|
+
let e = t.next;
|
|
2144
|
+
this[W].removeNode(t), t.next = e;
|
|
2145
|
+
}
|
|
2146
|
+
this[pe] = false, this[me] && this[W].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(tr) : (super.write(tr), super.end()));
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
get [Ct]() {
|
|
2150
|
+
return this[W] && this[W].head && this[W].head.value;
|
|
2151
|
+
}
|
|
2152
|
+
[ns](t) {
|
|
2153
|
+
this[W].shift(), this[G] -= 1, this[Ft]();
|
|
2154
|
+
}
|
|
2155
|
+
[rs](t) {
|
|
2156
|
+
if (!t.pending) {
|
|
2157
|
+
if (t.entry) {
|
|
2158
|
+
t === this[Ct] && !t.piped && this[li](t);
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
if (!t.stat) {
|
|
2162
|
+
let e = this.statCache.get(t.absolute);
|
|
2163
|
+
e ? this[oi](t, e) : this[as](t);
|
|
2164
|
+
}
|
|
2165
|
+
if (t.stat && !t.ignore) {
|
|
2166
|
+
if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
|
|
2167
|
+
let e = this.readdirCache.get(t.absolute);
|
|
2168
|
+
if (e ? this[ai](t, e) : this[ls](t), !t.readdir)
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
if (t.entry = this[ir](t), !t.entry) {
|
|
2172
|
+
t.ignore = true;
|
|
2173
|
+
return;
|
|
2174
|
+
}
|
|
2175
|
+
t === this[Ct] && !t.piped && this[li](t);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
[os](t) {
|
|
2180
|
+
return { onwarn: (e, i, r) => this.warn(e, i, r), noPax: this.noPax, cwd: this.cwd, absolute: t.absolute, preservePaths: this.preservePaths, maxReadSize: this.maxReadSize, strict: this.strict, portable: this.portable, linkCache: this.linkCache, statCache: this.statCache, noMtime: this.noMtime, mtime: this.mtime, prefix: this.prefix, onWriteEntry: this.onWriteEntry };
|
|
2181
|
+
}
|
|
2182
|
+
[ir](t) {
|
|
2183
|
+
this[G] += 1;
|
|
2184
|
+
try {
|
|
2185
|
+
return new this[ci](t.path, this[os](t)).on("end", () => this[ns](t)).on("error", (i) => this.emit("error", i));
|
|
2186
|
+
} catch (e) {
|
|
2187
|
+
this.emit("error", e);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
[hs]() {
|
|
2191
|
+
this[Ct] && this[Ct].entry && this[Ct].entry.resume();
|
|
2192
|
+
}
|
|
2193
|
+
[li](t) {
|
|
2194
|
+
t.piped = true, t.readdir && t.readdir.forEach((r) => {
|
|
2195
|
+
let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
|
|
2196
|
+
this[hi](o + r);
|
|
2197
|
+
});
|
|
2198
|
+
let e = t.entry, i = this.zip;
|
|
2199
|
+
if (!e)
|
|
2200
|
+
throw new Error("cannot pipe without source");
|
|
2201
|
+
i ? e.on("data", (r) => {
|
|
2202
|
+
i.write(r) || e.pause();
|
|
2203
|
+
}) : e.on("data", (r) => {
|
|
2204
|
+
super.write(r) || e.pause();
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
pause() {
|
|
2208
|
+
return this.zip && this.zip.pause(), super.pause();
|
|
2209
|
+
}
|
|
2210
|
+
warn(t, e, i = {}) {
|
|
2211
|
+
Lt(this, t, e, i);
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
var kt = class extends Et {
|
|
2215
|
+
sync = true;
|
|
2216
|
+
constructor(t) {
|
|
2217
|
+
super(t), this[ci] = si;
|
|
2218
|
+
}
|
|
2219
|
+
pause() {}
|
|
2220
|
+
resume() {}
|
|
2221
|
+
[as](t) {
|
|
2222
|
+
let e = this.follow ? "statSync" : "lstatSync";
|
|
2223
|
+
this[oi](t, fi[e](t.absolute));
|
|
2224
|
+
}
|
|
2225
|
+
[ls](t) {
|
|
2226
|
+
this[ai](t, fi.readdirSync(t.absolute));
|
|
2227
|
+
}
|
|
2228
|
+
[li](t) {
|
|
2229
|
+
let e = t.entry, i = this.zip;
|
|
2230
|
+
if (t.readdir && t.readdir.forEach((r) => {
|
|
2231
|
+
let n = t.path, o = n === "./" ? "" : n.replace(/\/*$/, "/");
|
|
2232
|
+
this[hi](o + r);
|
|
2233
|
+
}), !e)
|
|
2234
|
+
throw new Error("Cannot pipe without source");
|
|
2235
|
+
i ? e.on("data", (r) => {
|
|
2236
|
+
i.write(r);
|
|
2237
|
+
}) : e.on("data", (r) => {
|
|
2238
|
+
super[rr](r);
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
};
|
|
2242
|
+
var Un = (s3, t) => {
|
|
2243
|
+
let e = new kt(s3), i = new Wt(s3.file, { mode: s3.mode || 438 });
|
|
2244
|
+
e.pipe(i), or(e, t);
|
|
2245
|
+
};
|
|
2246
|
+
var Hn = (s3, t) => {
|
|
2247
|
+
let e = new Et(s3), i = new tt(s3.file, { mode: s3.mode || 438 });
|
|
2248
|
+
e.pipe(i);
|
|
2249
|
+
let r = new Promise((n, o) => {
|
|
2250
|
+
i.on("error", o), i.on("close", n), e.on("error", o);
|
|
2251
|
+
});
|
|
2252
|
+
return hr(e, t).catch((n) => e.emit("error", n)), r;
|
|
2253
|
+
};
|
|
2254
|
+
var or = (s3, t) => {
|
|
2255
|
+
t.forEach((e) => {
|
|
2256
|
+
e.charAt(0) === "@" ? It({ file: nr.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
2257
|
+
}), s3.end();
|
|
2258
|
+
};
|
|
2259
|
+
var hr = async (s3, t) => {
|
|
2260
|
+
for (let e of t)
|
|
2261
|
+
e.charAt(0) === "@" ? await It({ file: nr.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
|
|
2262
|
+
s3.add(i);
|
|
2263
|
+
} }) : s3.add(e);
|
|
2264
|
+
s3.end();
|
|
2265
|
+
};
|
|
2266
|
+
var Wn = (s3, t) => {
|
|
2267
|
+
let e = new kt(s3);
|
|
2268
|
+
return or(e, t), e;
|
|
2269
|
+
};
|
|
2270
|
+
var Gn = (s3, t) => {
|
|
2271
|
+
let e = new Et(s3);
|
|
2272
|
+
return hr(e, t).catch((i) => e.emit("error", i)), e;
|
|
2273
|
+
};
|
|
2274
|
+
var Zn = K(Un, Hn, Wn, Gn, (s3, t) => {
|
|
2275
|
+
if (!t?.length)
|
|
2276
|
+
throw new TypeError("no paths specified to add to archive");
|
|
2277
|
+
});
|
|
2278
|
+
var Yn = process.env.__FAKE_PLATFORM__ || process.platform;
|
|
2279
|
+
var fr = Yn === "win32";
|
|
2280
|
+
var { O_CREAT: dr, O_NOFOLLOW: ar, O_TRUNC: ur, O_WRONLY: mr } = cr.constants;
|
|
2281
|
+
var pr = Number(process.env.__FAKE_FS_O_FILENAME__) || cr.constants.UV_FS_O_FILEMAP || 0;
|
|
2282
|
+
var Kn = fr && !!pr;
|
|
2283
|
+
var Vn = 512 * 1024;
|
|
2284
|
+
var $n = pr | ur | dr | mr;
|
|
2285
|
+
var lr = !fr && typeof ar == "number" ? ar | ur | dr | mr : null;
|
|
2286
|
+
var cs = lr !== null ? () => lr : Kn ? (s3) => s3 < Vn ? $n : "w" : () => "w";
|
|
2287
|
+
var fs = (s3, t, e) => {
|
|
2288
|
+
try {
|
|
2289
|
+
return mi.lchownSync(s3, t, e);
|
|
2290
|
+
} catch (i) {
|
|
2291
|
+
if (i?.code !== "ENOENT")
|
|
2292
|
+
throw i;
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
var ui = (s3, t, e, i) => {
|
|
2296
|
+
mi.lchown(s3, t, e, (r) => {
|
|
2297
|
+
i(r && r?.code !== "ENOENT" ? r : null);
|
|
2298
|
+
});
|
|
2299
|
+
};
|
|
2300
|
+
var Xn = (s3, t, e, i, r) => {
|
|
2301
|
+
if (t.isDirectory())
|
|
2302
|
+
ds(Ee.resolve(s3, t.name), e, i, (n) => {
|
|
2303
|
+
if (n)
|
|
2304
|
+
return r(n);
|
|
2305
|
+
let o = Ee.resolve(s3, t.name);
|
|
2306
|
+
ui(o, e, i, r);
|
|
2307
|
+
});
|
|
2308
|
+
else {
|
|
2309
|
+
let n = Ee.resolve(s3, t.name);
|
|
2310
|
+
ui(n, e, i, r);
|
|
2311
|
+
}
|
|
2312
|
+
};
|
|
2313
|
+
var ds = (s3, t, e, i) => {
|
|
2314
|
+
mi.readdir(s3, { withFileTypes: true }, (r, n) => {
|
|
2315
|
+
if (r) {
|
|
2316
|
+
if (r.code === "ENOENT")
|
|
2317
|
+
return i();
|
|
2318
|
+
if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP")
|
|
2319
|
+
return i(r);
|
|
2320
|
+
}
|
|
2321
|
+
if (r || !n.length)
|
|
2322
|
+
return ui(s3, t, e, i);
|
|
2323
|
+
let o = n.length, h = null, a = (l) => {
|
|
2324
|
+
if (!h) {
|
|
2325
|
+
if (l)
|
|
2326
|
+
return i(h = l);
|
|
2327
|
+
if (--o === 0)
|
|
2328
|
+
return ui(s3, t, e, i);
|
|
2329
|
+
}
|
|
2330
|
+
};
|
|
2331
|
+
for (let l of n)
|
|
2332
|
+
Xn(s3, l, t, e, a);
|
|
2333
|
+
});
|
|
2334
|
+
};
|
|
2335
|
+
var qn = (s3, t, e, i) => {
|
|
2336
|
+
t.isDirectory() && us(Ee.resolve(s3, t.name), e, i), fs(Ee.resolve(s3, t.name), e, i);
|
|
2337
|
+
};
|
|
2338
|
+
var us = (s3, t, e) => {
|
|
2339
|
+
let i;
|
|
2340
|
+
try {
|
|
2341
|
+
i = mi.readdirSync(s3, { withFileTypes: true });
|
|
2342
|
+
} catch (r) {
|
|
2343
|
+
let n = r;
|
|
2344
|
+
if (n?.code === "ENOENT")
|
|
2345
|
+
return;
|
|
2346
|
+
if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP")
|
|
2347
|
+
return fs(s3, t, e);
|
|
2348
|
+
throw n;
|
|
2349
|
+
}
|
|
2350
|
+
for (let r of i)
|
|
2351
|
+
qn(s3, r, t, e);
|
|
2352
|
+
return fs(s3, t, e);
|
|
2353
|
+
};
|
|
2354
|
+
var we = class extends Error {
|
|
2355
|
+
path;
|
|
2356
|
+
code;
|
|
2357
|
+
syscall = "chdir";
|
|
2358
|
+
constructor(t, e) {
|
|
2359
|
+
super(`${e}: Cannot cd into '${t}'`), this.path = t, this.code = e;
|
|
2360
|
+
}
|
|
2361
|
+
get name() {
|
|
2362
|
+
return "CwdError";
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
var wt = class extends Error {
|
|
2366
|
+
path;
|
|
2367
|
+
symlink;
|
|
2368
|
+
syscall = "symlink";
|
|
2369
|
+
code = "TAR_SYMLINK_ERROR";
|
|
2370
|
+
constructor(t, e) {
|
|
2371
|
+
super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"), this.symlink = t, this.path = e;
|
|
2372
|
+
}
|
|
2373
|
+
get name() {
|
|
2374
|
+
return "SymlinkError";
|
|
2375
|
+
}
|
|
2376
|
+
};
|
|
2377
|
+
var Qn = (s3, t) => {
|
|
2378
|
+
k.stat(s3, (e, i) => {
|
|
2379
|
+
(e || !i.isDirectory()) && (e = new we(s3, e?.code || "ENOTDIR")), t(e);
|
|
2380
|
+
});
|
|
2381
|
+
};
|
|
2382
|
+
var Er = (s3, t, e) => {
|
|
2383
|
+
s3 = f(s3);
|
|
2384
|
+
let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, h = t.gid, a = typeof o == "number" && typeof h == "number" && (o !== t.processUid || h !== t.processGid), l = t.preserve, c = t.unlink, d = f(t.cwd), S = (E, x) => {
|
|
2385
|
+
E ? e(E) : x && a ? ds(x, o, h, (xe) => S(xe)) : n ? k.chmod(s3, r, e) : e();
|
|
2386
|
+
};
|
|
2387
|
+
if (s3 === d)
|
|
2388
|
+
return Qn(s3, S);
|
|
2389
|
+
if (l)
|
|
2390
|
+
return jn.mkdir(s3, { mode: r, recursive: true }).then((E) => S(null, E ?? undefined), S);
|
|
2391
|
+
let N = f(pi.relative(d, s3)).split("/");
|
|
2392
|
+
ms(d, N, r, c, d, undefined, S);
|
|
2393
|
+
};
|
|
2394
|
+
var ms = (s3, t, e, i, r, n, o) => {
|
|
2395
|
+
if (t.length === 0)
|
|
2396
|
+
return o(null, n);
|
|
2397
|
+
let h = t.shift(), a = f(pi.resolve(s3 + "/" + h));
|
|
2398
|
+
k.mkdir(a, e, wr(a, t, e, i, r, n, o));
|
|
2399
|
+
};
|
|
2400
|
+
var wr = (s3, t, e, i, r, n, o) => (h) => {
|
|
2401
|
+
h ? k.lstat(s3, (a, l) => {
|
|
2402
|
+
if (a)
|
|
2403
|
+
a.path = a.path && f(a.path), o(a);
|
|
2404
|
+
else if (l.isDirectory())
|
|
2405
|
+
ms(s3, t, e, i, r, n, o);
|
|
2406
|
+
else if (i)
|
|
2407
|
+
k.unlink(s3, (c) => {
|
|
2408
|
+
if (c)
|
|
2409
|
+
return o(c);
|
|
2410
|
+
k.mkdir(s3, e, wr(s3, t, e, i, r, n, o));
|
|
2411
|
+
});
|
|
2412
|
+
else {
|
|
2413
|
+
if (l.isSymbolicLink())
|
|
2414
|
+
return o(new wt(s3, s3 + "/" + t.join("/")));
|
|
2415
|
+
o(h);
|
|
2416
|
+
}
|
|
2417
|
+
}) : (n = n || s3, ms(s3, t, e, i, r, n, o));
|
|
2418
|
+
};
|
|
2419
|
+
var Jn = (s3) => {
|
|
2420
|
+
let t = false, e;
|
|
2421
|
+
try {
|
|
2422
|
+
t = k.statSync(s3).isDirectory();
|
|
2423
|
+
} catch (i) {
|
|
2424
|
+
e = i?.code;
|
|
2425
|
+
} finally {
|
|
2426
|
+
if (!t)
|
|
2427
|
+
throw new we(s3, e ?? "ENOTDIR");
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
var Sr = (s3, t) => {
|
|
2431
|
+
s3 = f(s3);
|
|
2432
|
+
let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, h = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), a = t.preserve, l = t.unlink, c = f(t.cwd), d = (E) => {
|
|
2433
|
+
E && h && us(E, n, o), r && k.chmodSync(s3, i);
|
|
2434
|
+
};
|
|
2435
|
+
if (s3 === c)
|
|
2436
|
+
return Jn(c), d();
|
|
2437
|
+
if (a)
|
|
2438
|
+
return d(k.mkdirSync(s3, { mode: i, recursive: true }) ?? undefined);
|
|
2439
|
+
let T = f(pi.relative(c, s3)).split("/"), N;
|
|
2440
|
+
for (let E = T.shift(), x = c;E && (x += "/" + E); E = T.shift()) {
|
|
2441
|
+
x = f(pi.resolve(x));
|
|
2442
|
+
try {
|
|
2443
|
+
k.mkdirSync(x, i), N = N || x;
|
|
2444
|
+
} catch {
|
|
2445
|
+
let xe = k.lstatSync(x);
|
|
2446
|
+
if (xe.isDirectory())
|
|
2447
|
+
continue;
|
|
2448
|
+
if (l) {
|
|
2449
|
+
k.unlinkSync(x), k.mkdirSync(x, i), N = N || x;
|
|
2450
|
+
continue;
|
|
2451
|
+
} else if (xe.isSymbolicLink())
|
|
2452
|
+
return new wt(x, x + "/" + T.join("/"));
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
return d(N);
|
|
2456
|
+
};
|
|
2457
|
+
var ps = Object.create(null);
|
|
2458
|
+
var yr = 1e4;
|
|
2459
|
+
var $t = new Set;
|
|
2460
|
+
var Rr = (s3) => {
|
|
2461
|
+
$t.has(s3) ? $t.delete(s3) : ps[s3] = s3.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"), $t.add(s3);
|
|
2462
|
+
let t = ps[s3], e = $t.size - yr;
|
|
2463
|
+
if (e > yr / 10) {
|
|
2464
|
+
for (let i of $t)
|
|
2465
|
+
if ($t.delete(i), delete ps[i], --e <= 0)
|
|
2466
|
+
break;
|
|
2467
|
+
}
|
|
2468
|
+
return t;
|
|
2469
|
+
};
|
|
2470
|
+
var to = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
2471
|
+
var eo = to === "win32";
|
|
2472
|
+
var io = (s3) => s3.split("/").slice(0, -1).reduce((e, i) => {
|
|
2473
|
+
let r = e.at(-1);
|
|
2474
|
+
return r !== undefined && (i = br(r, i)), e.push(i || "/"), e;
|
|
2475
|
+
}, []);
|
|
2476
|
+
var Ei = class {
|
|
2477
|
+
#t = new Map;
|
|
2478
|
+
#i = new Map;
|
|
2479
|
+
#s = new Set;
|
|
2480
|
+
reserve(t, e) {
|
|
2481
|
+
t = eo ? ["win32 parallelization disabled"] : t.map((r) => mt(br(Rr(r))));
|
|
2482
|
+
let i = new Set(t.map((r) => io(r)).reduce((r, n) => r.concat(n)));
|
|
2483
|
+
this.#i.set(e, { dirs: i, paths: t });
|
|
2484
|
+
for (let r of t) {
|
|
2485
|
+
let n = this.#t.get(r);
|
|
2486
|
+
n ? n.push(e) : this.#t.set(r, [e]);
|
|
2487
|
+
}
|
|
2488
|
+
for (let r of i) {
|
|
2489
|
+
let n = this.#t.get(r);
|
|
2490
|
+
if (!n)
|
|
2491
|
+
this.#t.set(r, [new Set([e])]);
|
|
2492
|
+
else {
|
|
2493
|
+
let o = n.at(-1);
|
|
2494
|
+
o instanceof Set ? o.add(e) : n.push(new Set([e]));
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
return this.#r(e);
|
|
2498
|
+
}
|
|
2499
|
+
#n(t) {
|
|
2500
|
+
let e = this.#i.get(t);
|
|
2501
|
+
if (!e)
|
|
2502
|
+
throw new Error("function does not have any path reservations");
|
|
2503
|
+
return { paths: e.paths.map((i) => this.#t.get(i)), dirs: [...e.dirs].map((i) => this.#t.get(i)) };
|
|
2504
|
+
}
|
|
2505
|
+
check(t) {
|
|
2506
|
+
let { paths: e, dirs: i } = this.#n(t);
|
|
2507
|
+
return e.every((r) => r && r[0] === t) && i.every((r) => r && r[0] instanceof Set && r[0].has(t));
|
|
2508
|
+
}
|
|
2509
|
+
#r(t) {
|
|
2510
|
+
return this.#s.has(t) || !this.check(t) ? false : (this.#s.add(t), t(() => this.#e(t)), true);
|
|
2511
|
+
}
|
|
2512
|
+
#e(t) {
|
|
2513
|
+
if (!this.#s.has(t))
|
|
2514
|
+
return false;
|
|
2515
|
+
let e = this.#i.get(t);
|
|
2516
|
+
if (!e)
|
|
2517
|
+
throw new Error("invalid reservation");
|
|
2518
|
+
let { paths: i, dirs: r } = e, n = new Set;
|
|
2519
|
+
for (let o of i) {
|
|
2520
|
+
let h = this.#t.get(o);
|
|
2521
|
+
if (!h || h?.[0] !== t)
|
|
2522
|
+
continue;
|
|
2523
|
+
let a = h[1];
|
|
2524
|
+
if (!a) {
|
|
2525
|
+
this.#t.delete(o);
|
|
2526
|
+
continue;
|
|
2527
|
+
}
|
|
2528
|
+
if (h.shift(), typeof a == "function")
|
|
2529
|
+
n.add(a);
|
|
2530
|
+
else
|
|
2531
|
+
for (let l of a)
|
|
2532
|
+
n.add(l);
|
|
2533
|
+
}
|
|
2534
|
+
for (let o of r) {
|
|
2535
|
+
let h = this.#t.get(o), a = h?.[0];
|
|
2536
|
+
if (!(!h || !(a instanceof Set)))
|
|
2537
|
+
if (a.size === 1 && h.length === 1) {
|
|
2538
|
+
this.#t.delete(o);
|
|
2539
|
+
continue;
|
|
2540
|
+
} else if (a.size === 1) {
|
|
2541
|
+
h.shift();
|
|
2542
|
+
let l = h[0];
|
|
2543
|
+
typeof l == "function" && n.add(l);
|
|
2544
|
+
} else
|
|
2545
|
+
a.delete(t);
|
|
2546
|
+
}
|
|
2547
|
+
return this.#s.delete(t), n.forEach((o) => this.#r(o)), true;
|
|
2548
|
+
}
|
|
2549
|
+
};
|
|
2550
|
+
var _r = () => process.umask();
|
|
2551
|
+
var gr = Symbol("onEntry");
|
|
2552
|
+
var ys = Symbol("checkFs");
|
|
2553
|
+
var Or = Symbol("checkFs2");
|
|
2554
|
+
var Rs = Symbol("isReusable");
|
|
2555
|
+
var P = Symbol("makeFs");
|
|
2556
|
+
var bs = Symbol("file");
|
|
2557
|
+
var _s = Symbol("directory");
|
|
2558
|
+
var Si = Symbol("link");
|
|
2559
|
+
var Tr = Symbol("symlink");
|
|
2560
|
+
var xr = Symbol("hardlink");
|
|
2561
|
+
var ye = Symbol("ensureNoSymlink");
|
|
2562
|
+
var Lr = Symbol("unsupported");
|
|
2563
|
+
var Nr = Symbol("checkPath");
|
|
2564
|
+
var Es = Symbol("stripAbsolutePath");
|
|
2565
|
+
var St = Symbol("mkdir");
|
|
2566
|
+
var O = Symbol("onError");
|
|
2567
|
+
var wi = Symbol("pending");
|
|
2568
|
+
var Ar = Symbol("pend");
|
|
2569
|
+
var Xt = Symbol("unpend");
|
|
2570
|
+
var ws = Symbol("ended");
|
|
2571
|
+
var Ss = Symbol("maybeClose");
|
|
2572
|
+
var gs = Symbol("skip");
|
|
2573
|
+
var Re = Symbol("doChown");
|
|
2574
|
+
var be = Symbol("uid");
|
|
2575
|
+
var _e = Symbol("gid");
|
|
2576
|
+
var ge = Symbol("checkedCwd");
|
|
2577
|
+
var ro = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
2578
|
+
var Oe = ro === "win32";
|
|
2579
|
+
var no = 1024;
|
|
2580
|
+
var oo = (s3, t) => {
|
|
2581
|
+
if (!Oe)
|
|
2582
|
+
return u.unlink(s3, t);
|
|
2583
|
+
let e = s3 + ".DELETE." + Ir(16).toString("hex");
|
|
2584
|
+
u.rename(s3, e, (i) => {
|
|
2585
|
+
if (i)
|
|
2586
|
+
return t(i);
|
|
2587
|
+
u.unlink(e, t);
|
|
2588
|
+
});
|
|
2589
|
+
};
|
|
2590
|
+
var ho = (s3) => {
|
|
2591
|
+
if (!Oe)
|
|
2592
|
+
return u.unlinkSync(s3);
|
|
2593
|
+
let t = s3 + ".DELETE." + Ir(16).toString("hex");
|
|
2594
|
+
u.renameSync(s3, t), u.unlinkSync(t);
|
|
2595
|
+
};
|
|
2596
|
+
var Dr = (s3, t, e) => s3 !== undefined && s3 === s3 >>> 0 ? s3 : t !== undefined && t === t >>> 0 ? t : e;
|
|
2597
|
+
var qt = class extends st {
|
|
2598
|
+
[ws] = false;
|
|
2599
|
+
[ge] = false;
|
|
2600
|
+
[wi] = 0;
|
|
2601
|
+
reservations = new Ei;
|
|
2602
|
+
transform;
|
|
2603
|
+
writable = true;
|
|
2604
|
+
readable = false;
|
|
2605
|
+
uid;
|
|
2606
|
+
gid;
|
|
2607
|
+
setOwner;
|
|
2608
|
+
preserveOwner;
|
|
2609
|
+
processGid;
|
|
2610
|
+
processUid;
|
|
2611
|
+
maxDepth;
|
|
2612
|
+
forceChown;
|
|
2613
|
+
win32;
|
|
2614
|
+
newer;
|
|
2615
|
+
keep;
|
|
2616
|
+
noMtime;
|
|
2617
|
+
preservePaths;
|
|
2618
|
+
unlink;
|
|
2619
|
+
cwd;
|
|
2620
|
+
strip;
|
|
2621
|
+
processUmask;
|
|
2622
|
+
umask;
|
|
2623
|
+
dmode;
|
|
2624
|
+
fmode;
|
|
2625
|
+
chmod;
|
|
2626
|
+
constructor(t = {}) {
|
|
2627
|
+
if (t.ondone = () => {
|
|
2628
|
+
this[ws] = true, this[Ss]();
|
|
2629
|
+
}, super(t), this.transform = t.transform, this.chmod = !!t.chmod, typeof t.uid == "number" || typeof t.gid == "number") {
|
|
2630
|
+
if (typeof t.uid != "number" || typeof t.gid != "number")
|
|
2631
|
+
throw new TypeError("cannot set owner without number uid and gid");
|
|
2632
|
+
if (t.preserveOwner)
|
|
2633
|
+
throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
|
|
2634
|
+
this.uid = t.uid, this.gid = t.gid, this.setOwner = true;
|
|
2635
|
+
} else
|
|
2636
|
+
this.uid = undefined, this.gid = undefined, this.setOwner = false;
|
|
2637
|
+
this.preserveOwner = t.preserveOwner === undefined && typeof t.uid != "number" ? !!(process.getuid && process.getuid() === 0) : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : undefined, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : undefined, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : no, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Oe, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(R.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : _r() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[gr](e));
|
|
2638
|
+
}
|
|
2639
|
+
warn(t, e, i = {}) {
|
|
2640
|
+
return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = false), super.warn(t, e, i);
|
|
2641
|
+
}
|
|
2642
|
+
[Ss]() {
|
|
2643
|
+
this[ws] && this[wi] === 0 && (this.emit("prefinish"), this.emit("finish"), this.emit("end"));
|
|
2644
|
+
}
|
|
2645
|
+
[Es](t, e) {
|
|
2646
|
+
let i = t[e], { type: r } = t;
|
|
2647
|
+
if (!i || this.preservePaths)
|
|
2648
|
+
return true;
|
|
2649
|
+
let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
|
|
2650
|
+
if (h.includes("..") || Oe && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
|
|
2651
|
+
if (e === "path" || r === "Link")
|
|
2652
|
+
return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, { entry: t, [e]: i }), false;
|
|
2653
|
+
let a = R.posix.dirname(t.path), l = R.posix.normalize(R.posix.join(a, h.join("/")));
|
|
2654
|
+
if (l.startsWith("../") || l === "..")
|
|
2655
|
+
return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, { entry: t, [e]: i }), false;
|
|
2656
|
+
}
|
|
2657
|
+
return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, { entry: t, [e]: i })), true;
|
|
2658
|
+
}
|
|
2659
|
+
[Nr](t) {
|
|
2660
|
+
let e = f(t.path), i = e.split("/");
|
|
2661
|
+
if (this.strip) {
|
|
2662
|
+
if (i.length < this.strip)
|
|
2663
|
+
return false;
|
|
2664
|
+
if (t.type === "Link") {
|
|
2665
|
+
let r = f(String(t.linkpath)).split("/");
|
|
2666
|
+
if (r.length >= this.strip)
|
|
2667
|
+
t.linkpath = r.slice(this.strip).join("/");
|
|
2668
|
+
else
|
|
2669
|
+
return false;
|
|
2670
|
+
}
|
|
2671
|
+
i.splice(0, this.strip), t.path = i.join("/");
|
|
2672
|
+
}
|
|
2673
|
+
if (isFinite(this.maxDepth) && i.length > this.maxDepth)
|
|
2674
|
+
return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: t, path: e, depth: i.length, maxDepth: this.maxDepth }), false;
|
|
2675
|
+
if (!this[Es](t, "path") || !this[Es](t, "linkpath"))
|
|
2676
|
+
return false;
|
|
2677
|
+
if (t.absolute = R.isAbsolute(t.path) ? f(R.resolve(t.path)) : f(R.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd)
|
|
2678
|
+
return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t, path: f(t.path), resolvedPath: t.absolute, cwd: this.cwd }), false;
|
|
2679
|
+
if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir")
|
|
2680
|
+
return false;
|
|
2681
|
+
if (this.win32) {
|
|
2682
|
+
let { root: r } = R.win32.parse(String(t.absolute));
|
|
2683
|
+
t.absolute = r + Xi(String(t.absolute).slice(r.length));
|
|
2684
|
+
let { root: n } = R.win32.parse(t.path);
|
|
2685
|
+
t.path = n + Xi(t.path.slice(n.length));
|
|
2686
|
+
}
|
|
2687
|
+
return true;
|
|
2688
|
+
}
|
|
2689
|
+
[gr](t) {
|
|
2690
|
+
if (!this[Nr](t))
|
|
2691
|
+
return t.resume();
|
|
2692
|
+
switch (so.equal(typeof t.absolute, "string"), t.type) {
|
|
2693
|
+
case "Directory":
|
|
2694
|
+
case "GNUDumpDir":
|
|
2695
|
+
t.mode && (t.mode = t.mode | 448);
|
|
2696
|
+
case "File":
|
|
2697
|
+
case "OldFile":
|
|
2698
|
+
case "ContiguousFile":
|
|
2699
|
+
case "Link":
|
|
2700
|
+
case "SymbolicLink":
|
|
2701
|
+
return this[ys](t);
|
|
2702
|
+
default:
|
|
2703
|
+
return this[Lr](t);
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
[O](t, e) {
|
|
2707
|
+
t.name === "CwdError" ? this.emit("error", t) : (this.warn("TAR_ENTRY_ERROR", t, { entry: e }), this[Xt](), e.resume());
|
|
2708
|
+
}
|
|
2709
|
+
[St](t, e, i) {
|
|
2710
|
+
Er(f(t), { uid: this.uid, gid: this.gid, processUid: this.processUid, processGid: this.processGid, umask: this.processUmask, preserve: this.preservePaths, unlink: this.unlink, cwd: this.cwd, mode: e }, i);
|
|
2711
|
+
}
|
|
2712
|
+
[Re](t) {
|
|
2713
|
+
return this.forceChown || this.preserveOwner && (typeof t.uid == "number" && t.uid !== this.processUid || typeof t.gid == "number" && t.gid !== this.processGid) || typeof this.uid == "number" && this.uid !== this.processUid || typeof this.gid == "number" && this.gid !== this.processGid;
|
|
2714
|
+
}
|
|
2715
|
+
[be](t) {
|
|
2716
|
+
return Dr(this.uid, t.uid, this.processUid);
|
|
2717
|
+
}
|
|
2718
|
+
[_e](t) {
|
|
2719
|
+
return Dr(this.gid, t.gid, this.processGid);
|
|
2720
|
+
}
|
|
2721
|
+
[bs](t, e) {
|
|
2722
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new tt(String(t.absolute), { flags: cs(t.size), mode: i, autoClose: false });
|
|
2723
|
+
r.on("error", (a) => {
|
|
2724
|
+
r.fd && u.close(r.fd, () => {}), r.write = () => true, this[O](a, t), e();
|
|
2725
|
+
});
|
|
2726
|
+
let n = 1, o = (a) => {
|
|
2727
|
+
if (a) {
|
|
2728
|
+
r.fd && u.close(r.fd, () => {}), this[O](a, t), e();
|
|
2729
|
+
return;
|
|
2730
|
+
}
|
|
2731
|
+
--n === 0 && r.fd !== undefined && u.close(r.fd, (l) => {
|
|
2732
|
+
l ? this[O](l, t) : this[Xt](), e();
|
|
2733
|
+
});
|
|
2734
|
+
};
|
|
2735
|
+
r.on("finish", () => {
|
|
2736
|
+
let a = String(t.absolute), l = r.fd;
|
|
2737
|
+
if (typeof l == "number" && t.mtime && !this.noMtime) {
|
|
2738
|
+
n++;
|
|
2739
|
+
let c = t.atime || new Date, d = t.mtime;
|
|
2740
|
+
u.futimes(l, c, d, (S) => S ? u.utimes(a, c, d, (T) => o(T && S)) : o());
|
|
2741
|
+
}
|
|
2742
|
+
if (typeof l == "number" && this[Re](t)) {
|
|
2743
|
+
n++;
|
|
2744
|
+
let c = this[be](t), d = this[_e](t);
|
|
2745
|
+
typeof c == "number" && typeof d == "number" && u.fchown(l, c, d, (S) => S ? u.chown(a, c, d, (T) => o(T && S)) : o());
|
|
2746
|
+
}
|
|
2747
|
+
o();
|
|
2748
|
+
});
|
|
2749
|
+
let h = this.transform && this.transform(t) || t;
|
|
2750
|
+
h !== t && (h.on("error", (a) => {
|
|
2751
|
+
this[O](a, t), e();
|
|
2752
|
+
}), t.pipe(h)), h.pipe(r);
|
|
2753
|
+
}
|
|
2754
|
+
[_s](t, e) {
|
|
2755
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode;
|
|
2756
|
+
this[St](String(t.absolute), i, (r) => {
|
|
2757
|
+
if (r) {
|
|
2758
|
+
this[O](r, t), e();
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
let n = 1, o = () => {
|
|
2762
|
+
--n === 0 && (e(), this[Xt](), t.resume());
|
|
2763
|
+
};
|
|
2764
|
+
t.mtime && !this.noMtime && (n++, u.utimes(String(t.absolute), t.atime || new Date, t.mtime, o)), this[Re](t) && (n++, u.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
[Lr](t) {
|
|
2768
|
+
t.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
|
|
2769
|
+
}
|
|
2770
|
+
[Tr](t, e) {
|
|
2771
|
+
let i = f(R.relative(this.cwd, R.resolve(R.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
|
|
2772
|
+
this[ye](t, this.cwd, i, () => this[Si](t, String(t.linkpath), "symlink", e), (r) => {
|
|
2773
|
+
this[O](r, t), e();
|
|
2774
|
+
});
|
|
2775
|
+
}
|
|
2776
|
+
[xr](t, e) {
|
|
2777
|
+
let i = f(R.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
|
|
2778
|
+
this[ye](t, this.cwd, r, () => this[Si](t, i, "link", e), (n) => {
|
|
2779
|
+
this[O](n, t), e();
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
[ye](t, e, i, r, n) {
|
|
2783
|
+
let o = i.shift();
|
|
2784
|
+
if (this.preservePaths || o === undefined)
|
|
2785
|
+
return r();
|
|
2786
|
+
let h = R.resolve(e, o);
|
|
2787
|
+
u.lstat(h, (a, l) => {
|
|
2788
|
+
if (a)
|
|
2789
|
+
return r();
|
|
2790
|
+
if (l?.isSymbolicLink())
|
|
2791
|
+
return n(new wt(h, R.resolve(h, i.join("/"))));
|
|
2792
|
+
this[ye](t, h, i, r, n);
|
|
2793
|
+
});
|
|
2794
|
+
}
|
|
2795
|
+
[Ar]() {
|
|
2796
|
+
this[wi]++;
|
|
2797
|
+
}
|
|
2798
|
+
[Xt]() {
|
|
2799
|
+
this[wi]--, this[Ss]();
|
|
2800
|
+
}
|
|
2801
|
+
[gs](t) {
|
|
2802
|
+
this[Xt](), t.resume();
|
|
2803
|
+
}
|
|
2804
|
+
[Rs](t, e) {
|
|
2805
|
+
return t.type === "File" && !this.unlink && e.isFile() && e.nlink <= 1 && !Oe;
|
|
2806
|
+
}
|
|
2807
|
+
[ys](t) {
|
|
2808
|
+
this[Ar]();
|
|
2809
|
+
let e = [t.path];
|
|
2810
|
+
t.linkpath && e.push(t.linkpath), this.reservations.reserve(e, (i) => this[Or](t, i));
|
|
2811
|
+
}
|
|
2812
|
+
[Or](t, e) {
|
|
2813
|
+
let i = (h) => {
|
|
2814
|
+
e(h);
|
|
2815
|
+
}, r = () => {
|
|
2816
|
+
this[St](this.cwd, this.dmode, (h) => {
|
|
2817
|
+
if (h) {
|
|
2818
|
+
this[O](h, t), i();
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
this[ge] = true, n();
|
|
2822
|
+
});
|
|
2823
|
+
}, n = () => {
|
|
2824
|
+
if (t.absolute !== this.cwd) {
|
|
2825
|
+
let h = f(R.dirname(String(t.absolute)));
|
|
2826
|
+
if (h !== this.cwd)
|
|
2827
|
+
return this[St](h, this.dmode, (a) => {
|
|
2828
|
+
if (a) {
|
|
2829
|
+
this[O](a, t), i();
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2832
|
+
o();
|
|
2833
|
+
});
|
|
2834
|
+
}
|
|
2835
|
+
o();
|
|
2836
|
+
}, o = () => {
|
|
2837
|
+
u.lstat(String(t.absolute), (h, a) => {
|
|
2838
|
+
if (a && (this.keep || this.newer && a.mtime > (t.mtime ?? a.mtime))) {
|
|
2839
|
+
this[gs](t), i();
|
|
2840
|
+
return;
|
|
2841
|
+
}
|
|
2842
|
+
if (h || this[Rs](t, a))
|
|
2843
|
+
return this[P](null, t, i);
|
|
2844
|
+
if (a.isDirectory()) {
|
|
2845
|
+
if (t.type === "Directory") {
|
|
2846
|
+
let l = this.chmod && t.mode && (a.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
|
|
2847
|
+
return l ? u.chmod(String(t.absolute), Number(t.mode), c) : c();
|
|
2848
|
+
}
|
|
2849
|
+
if (t.absolute !== this.cwd)
|
|
2850
|
+
return u.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
2851
|
+
}
|
|
2852
|
+
if (t.absolute === this.cwd)
|
|
2853
|
+
return this[P](null, t, i);
|
|
2854
|
+
oo(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
2855
|
+
});
|
|
2856
|
+
};
|
|
2857
|
+
this[ge] ? n() : r();
|
|
2858
|
+
}
|
|
2859
|
+
[P](t, e, i) {
|
|
2860
|
+
if (t) {
|
|
2861
|
+
this[O](t, e), i();
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
switch (e.type) {
|
|
2865
|
+
case "File":
|
|
2866
|
+
case "OldFile":
|
|
2867
|
+
case "ContiguousFile":
|
|
2868
|
+
return this[bs](e, i);
|
|
2869
|
+
case "Link":
|
|
2870
|
+
return this[xr](e, i);
|
|
2871
|
+
case "SymbolicLink":
|
|
2872
|
+
return this[Tr](e, i);
|
|
2873
|
+
case "Directory":
|
|
2874
|
+
case "GNUDumpDir":
|
|
2875
|
+
return this[_s](e, i);
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
[Si](t, e, i, r) {
|
|
2879
|
+
u[i](e, String(t.absolute), (n) => {
|
|
2880
|
+
n ? this[O](n, t) : (this[Xt](), t.resume()), r();
|
|
2881
|
+
});
|
|
2882
|
+
}
|
|
2883
|
+
};
|
|
2884
|
+
var Se = (s3) => {
|
|
2885
|
+
try {
|
|
2886
|
+
return [null, s3()];
|
|
2887
|
+
} catch (t) {
|
|
2888
|
+
return [t, null];
|
|
2889
|
+
}
|
|
2890
|
+
};
|
|
2891
|
+
var Te = class extends qt {
|
|
2892
|
+
sync = true;
|
|
2893
|
+
[P](t, e) {
|
|
2894
|
+
return super[P](t, e, () => {});
|
|
2895
|
+
}
|
|
2896
|
+
[ys](t) {
|
|
2897
|
+
if (!this[ge]) {
|
|
2898
|
+
let n = this[St](this.cwd, this.dmode);
|
|
2899
|
+
if (n)
|
|
2900
|
+
return this[O](n, t);
|
|
2901
|
+
this[ge] = true;
|
|
2902
|
+
}
|
|
2903
|
+
if (t.absolute !== this.cwd) {
|
|
2904
|
+
let n = f(R.dirname(String(t.absolute)));
|
|
2905
|
+
if (n !== this.cwd) {
|
|
2906
|
+
let o = this[St](n, this.dmode);
|
|
2907
|
+
if (o)
|
|
2908
|
+
return this[O](o, t);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
let [e, i] = Se(() => u.lstatSync(String(t.absolute)));
|
|
2912
|
+
if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime)))
|
|
2913
|
+
return this[gs](t);
|
|
2914
|
+
if (e || this[Rs](t, i))
|
|
2915
|
+
return this[P](null, t);
|
|
2916
|
+
if (i.isDirectory()) {
|
|
2917
|
+
if (t.type === "Directory") {
|
|
2918
|
+
let o = this.chmod && t.mode && (i.mode & 4095) !== t.mode, [h] = o ? Se(() => {
|
|
2919
|
+
u.chmodSync(String(t.absolute), Number(t.mode));
|
|
2920
|
+
}) : [];
|
|
2921
|
+
return this[P](h, t);
|
|
2922
|
+
}
|
|
2923
|
+
let [n] = Se(() => u.rmdirSync(String(t.absolute)));
|
|
2924
|
+
this[P](n, t);
|
|
2925
|
+
}
|
|
2926
|
+
let [r] = t.absolute === this.cwd ? [] : Se(() => ho(String(t.absolute)));
|
|
2927
|
+
this[P](r, t);
|
|
2928
|
+
}
|
|
2929
|
+
[bs](t, e) {
|
|
2930
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (h) => {
|
|
2931
|
+
let a;
|
|
2932
|
+
try {
|
|
2933
|
+
u.closeSync(n);
|
|
2934
|
+
} catch (l) {
|
|
2935
|
+
a = l;
|
|
2936
|
+
}
|
|
2937
|
+
(h || a) && this[O](h || a, t), e();
|
|
2938
|
+
}, n;
|
|
2939
|
+
try {
|
|
2940
|
+
n = u.openSync(String(t.absolute), cs(t.size), i);
|
|
2941
|
+
} catch (h) {
|
|
2942
|
+
return r(h);
|
|
2943
|
+
}
|
|
2944
|
+
let o = this.transform && this.transform(t) || t;
|
|
2945
|
+
o !== t && (o.on("error", (h) => this[O](h, t)), t.pipe(o)), o.on("data", (h) => {
|
|
2946
|
+
try {
|
|
2947
|
+
u.writeSync(n, h, 0, h.length);
|
|
2948
|
+
} catch (a) {
|
|
2949
|
+
r(a);
|
|
2950
|
+
}
|
|
2951
|
+
}), o.on("end", () => {
|
|
2952
|
+
let h = null;
|
|
2953
|
+
if (t.mtime && !this.noMtime) {
|
|
2954
|
+
let a = t.atime || new Date, l = t.mtime;
|
|
2955
|
+
try {
|
|
2956
|
+
u.futimesSync(n, a, l);
|
|
2957
|
+
} catch (c) {
|
|
2958
|
+
try {
|
|
2959
|
+
u.utimesSync(String(t.absolute), a, l);
|
|
2960
|
+
} catch {
|
|
2961
|
+
h = c;
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
if (this[Re](t)) {
|
|
2966
|
+
let a = this[be](t), l = this[_e](t);
|
|
2967
|
+
try {
|
|
2968
|
+
u.fchownSync(n, Number(a), Number(l));
|
|
2969
|
+
} catch (c) {
|
|
2970
|
+
try {
|
|
2971
|
+
u.chownSync(String(t.absolute), Number(a), Number(l));
|
|
2972
|
+
} catch {
|
|
2973
|
+
h = h || c;
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
r(h);
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2980
|
+
[_s](t, e) {
|
|
2981
|
+
let i = typeof t.mode == "number" ? t.mode & 4095 : this.dmode, r = this[St](String(t.absolute), i);
|
|
2982
|
+
if (r) {
|
|
2983
|
+
this[O](r, t), e();
|
|
2984
|
+
return;
|
|
2985
|
+
}
|
|
2986
|
+
if (t.mtime && !this.noMtime)
|
|
2987
|
+
try {
|
|
2988
|
+
u.utimesSync(String(t.absolute), t.atime || new Date, t.mtime);
|
|
2989
|
+
} catch {}
|
|
2990
|
+
if (this[Re](t))
|
|
2991
|
+
try {
|
|
2992
|
+
u.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
|
|
2993
|
+
} catch {}
|
|
2994
|
+
e(), t.resume();
|
|
2995
|
+
}
|
|
2996
|
+
[St](t, e) {
|
|
2997
|
+
try {
|
|
2998
|
+
return Sr(f(t), { uid: this.uid, gid: this.gid, processUid: this.processUid, processGid: this.processGid, umask: this.processUmask, preserve: this.preservePaths, unlink: this.unlink, cwd: this.cwd, mode: e });
|
|
2999
|
+
} catch (i) {
|
|
3000
|
+
return i;
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
[ye](t, e, i, r, n) {
|
|
3004
|
+
if (this.preservePaths || i.length === 0)
|
|
3005
|
+
return r();
|
|
3006
|
+
let o = e;
|
|
3007
|
+
for (let h of i) {
|
|
3008
|
+
o = R.resolve(o, h);
|
|
3009
|
+
let [a, l] = Se(() => u.lstatSync(o));
|
|
3010
|
+
if (a)
|
|
3011
|
+
return r();
|
|
3012
|
+
if (l.isSymbolicLink())
|
|
3013
|
+
return n(new wt(o, R.resolve(e, i.join("/"))));
|
|
3014
|
+
}
|
|
3015
|
+
r();
|
|
3016
|
+
}
|
|
3017
|
+
[Si](t, e, i, r) {
|
|
3018
|
+
let n = `${i}Sync`;
|
|
3019
|
+
try {
|
|
3020
|
+
u[n](e, String(t.absolute)), r(), t.resume();
|
|
3021
|
+
} catch (o) {
|
|
3022
|
+
return this[O](o, t);
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
};
|
|
3026
|
+
var ao = (s3) => {
|
|
3027
|
+
let t = new Te(s3), e = s3.file, i = Cr.statSync(e), r = s3.maxReadSize || 16 * 1024 * 1024;
|
|
3028
|
+
new Me(e, { readSize: r, size: i.size }).pipe(t);
|
|
3029
|
+
};
|
|
3030
|
+
var lo = (s3, t) => {
|
|
3031
|
+
let e = new qt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
|
|
3032
|
+
return new Promise((o, h) => {
|
|
3033
|
+
e.on("error", h), e.on("close", o), Cr.stat(r, (a, l) => {
|
|
3034
|
+
if (a)
|
|
3035
|
+
h(a);
|
|
3036
|
+
else {
|
|
3037
|
+
let c = new _t(r, { readSize: i, size: l.size });
|
|
3038
|
+
c.on("error", h), c.pipe(e);
|
|
3039
|
+
}
|
|
3040
|
+
});
|
|
3041
|
+
});
|
|
3042
|
+
};
|
|
3043
|
+
var co = K(ao, lo, (s3) => new Te(s3), (s3) => new qt(s3), (s3, t) => {
|
|
3044
|
+
t?.length && Ki(s3, t);
|
|
3045
|
+
});
|
|
3046
|
+
var fo = (s3, t) => {
|
|
3047
|
+
let e = new kt(s3), i = true, r, n;
|
|
3048
|
+
try {
|
|
3049
|
+
try {
|
|
3050
|
+
r = v.openSync(s3.file, "r+");
|
|
3051
|
+
} catch (a) {
|
|
3052
|
+
if (a?.code === "ENOENT")
|
|
3053
|
+
r = v.openSync(s3.file, "w+");
|
|
3054
|
+
else
|
|
3055
|
+
throw a;
|
|
3056
|
+
}
|
|
3057
|
+
let o = v.fstatSync(r), h = Buffer.alloc(512);
|
|
3058
|
+
t:
|
|
3059
|
+
for (n = 0;n < o.size; n += 512) {
|
|
3060
|
+
for (let c = 0, d = 0;c < 512; c += d) {
|
|
3061
|
+
if (d = v.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139)
|
|
3062
|
+
throw new Error("cannot append to compressed archives");
|
|
3063
|
+
if (!d)
|
|
3064
|
+
break t;
|
|
3065
|
+
}
|
|
3066
|
+
let a = new F(h);
|
|
3067
|
+
if (!a.cksumValid)
|
|
3068
|
+
break;
|
|
3069
|
+
let l = 512 * Math.ceil((a.size || 0) / 512);
|
|
3070
|
+
if (n + l + 512 > o.size)
|
|
3071
|
+
break;
|
|
3072
|
+
n += l, s3.mtimeCache && a.mtime && s3.mtimeCache.set(String(a.path), a.mtime);
|
|
3073
|
+
}
|
|
3074
|
+
i = false, uo(s3, e, n, r, t);
|
|
3075
|
+
} finally {
|
|
3076
|
+
if (i)
|
|
3077
|
+
try {
|
|
3078
|
+
v.closeSync(r);
|
|
3079
|
+
} catch {}
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
var uo = (s3, t, e, i, r) => {
|
|
3083
|
+
let n = new Wt(s3.file, { fd: i, start: e });
|
|
3084
|
+
t.pipe(n), po(t, r);
|
|
3085
|
+
};
|
|
3086
|
+
var mo = (s3, t) => {
|
|
3087
|
+
t = Array.from(t);
|
|
3088
|
+
let e = new Et(s3), i = (n, o, h) => {
|
|
3089
|
+
let a = (T, N) => {
|
|
3090
|
+
T ? v.close(n, (E) => h(T)) : h(null, N);
|
|
3091
|
+
}, l = 0;
|
|
3092
|
+
if (o === 0)
|
|
3093
|
+
return a(null, 0);
|
|
3094
|
+
let c = 0, d = Buffer.alloc(512), S = (T, N) => {
|
|
3095
|
+
if (T || N === undefined)
|
|
3096
|
+
return a(T);
|
|
3097
|
+
if (c += N, c < 512 && N)
|
|
3098
|
+
return v.read(n, d, c, d.length - c, l + c, S);
|
|
3099
|
+
if (l === 0 && d[0] === 31 && d[1] === 139)
|
|
3100
|
+
return a(new Error("cannot append to compressed archives"));
|
|
3101
|
+
if (c < 512)
|
|
3102
|
+
return a(null, l);
|
|
3103
|
+
let E = new F(d);
|
|
3104
|
+
if (!E.cksumValid)
|
|
3105
|
+
return a(null, l);
|
|
3106
|
+
let x = 512 * Math.ceil((E.size ?? 0) / 512);
|
|
3107
|
+
if (l + x + 512 > o || (l += x + 512, l >= o))
|
|
3108
|
+
return a(null, l);
|
|
3109
|
+
s3.mtimeCache && E.mtime && s3.mtimeCache.set(String(E.path), E.mtime), c = 0, v.read(n, d, 0, 512, l, S);
|
|
3110
|
+
};
|
|
3111
|
+
v.read(n, d, 0, 512, l, S);
|
|
3112
|
+
};
|
|
3113
|
+
return new Promise((n, o) => {
|
|
3114
|
+
e.on("error", o);
|
|
3115
|
+
let h = "r+", a = (l, c) => {
|
|
3116
|
+
if (l && l.code === "ENOENT" && h === "r+")
|
|
3117
|
+
return h = "w+", v.open(s3.file, h, a);
|
|
3118
|
+
if (l || !c)
|
|
3119
|
+
return o(l);
|
|
3120
|
+
v.fstat(c, (d, S) => {
|
|
3121
|
+
if (d)
|
|
3122
|
+
return v.close(c, () => o(d));
|
|
3123
|
+
i(c, S.size, (T, N) => {
|
|
3124
|
+
if (T)
|
|
3125
|
+
return o(T);
|
|
3126
|
+
let E = new tt(s3.file, { fd: c, start: N });
|
|
3127
|
+
e.pipe(E), E.on("error", o), E.on("close", n), Eo(e, t);
|
|
3128
|
+
});
|
|
3129
|
+
});
|
|
3130
|
+
};
|
|
3131
|
+
v.open(s3.file, h, a);
|
|
3132
|
+
});
|
|
3133
|
+
};
|
|
3134
|
+
var po = (s3, t) => {
|
|
3135
|
+
t.forEach((e) => {
|
|
3136
|
+
e.charAt(0) === "@" ? It({ file: Fr.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
3137
|
+
}), s3.end();
|
|
3138
|
+
};
|
|
3139
|
+
var Eo = async (s3, t) => {
|
|
3140
|
+
for (let e of t)
|
|
3141
|
+
e.charAt(0) === "@" ? await It({ file: Fr.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
3142
|
+
s3.end();
|
|
3143
|
+
};
|
|
3144
|
+
var vt = K(fo, mo, () => {
|
|
3145
|
+
throw new TypeError("file is required");
|
|
3146
|
+
}, () => {
|
|
3147
|
+
throw new TypeError("file is required");
|
|
3148
|
+
}, (s3, t) => {
|
|
3149
|
+
if (!Fs(s3))
|
|
3150
|
+
throw new TypeError("file is required");
|
|
3151
|
+
if (s3.gzip || s3.brotli || s3.zstd || s3.file.endsWith(".br") || s3.file.endsWith(".tbr"))
|
|
3152
|
+
throw new TypeError("cannot append to compressed archives");
|
|
3153
|
+
if (!t?.length)
|
|
3154
|
+
throw new TypeError("no paths specified to add/replace");
|
|
3155
|
+
});
|
|
3156
|
+
var wo = K(vt.syncFile, vt.asyncFile, vt.syncNoFile, vt.asyncNoFile, (s3, t = []) => {
|
|
3157
|
+
vt.validate?.(s3, t), So(s3);
|
|
3158
|
+
});
|
|
3159
|
+
var So = (s3) => {
|
|
3160
|
+
let t = s3.filter;
|
|
3161
|
+
s3.mtimeCache || (s3.mtimeCache = new Map), s3.filter = t ? (e, i) => t(e, i) && !((s3.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e, i) => !((s3.mtimeCache?.get(e) ?? i.mtime ?? 0) > (i.mtime ?? 0));
|
|
3162
|
+
};
|
|
3163
|
+
|
|
3164
|
+
// src/index.ts
|
|
3165
|
+
var REPO_OWNER = "Alshahriah";
|
|
3166
|
+
var REPO_NAME = "blazestack";
|
|
3167
|
+
var REPO_BRANCH = "main";
|
|
3168
|
+
var EXCLUDE = new Set(["node_modules", ".git", "bun.lock", "packages/create-blaze"]);
|
|
3169
|
+
var TEXT_EXTENSIONS = new Set([
|
|
3170
|
+
".ts",
|
|
3171
|
+
".tsx",
|
|
3172
|
+
".js",
|
|
3173
|
+
".jsx",
|
|
3174
|
+
".json",
|
|
3175
|
+
".jsonc",
|
|
3176
|
+
".toml",
|
|
3177
|
+
".md",
|
|
3178
|
+
".yml",
|
|
3179
|
+
".yaml",
|
|
3180
|
+
".css",
|
|
3181
|
+
".html",
|
|
3182
|
+
".env",
|
|
3183
|
+
".txt",
|
|
3184
|
+
".gitignore",
|
|
3185
|
+
".gitattributes"
|
|
3186
|
+
]);
|
|
3187
|
+
function isTextFile(filePath) {
|
|
3188
|
+
const ext = extname(filePath);
|
|
3189
|
+
const base = basename(filePath);
|
|
3190
|
+
if (ext === "" || base.startsWith("."))
|
|
3191
|
+
return true;
|
|
3192
|
+
return TEXT_EXTENSIONS.has(ext);
|
|
3193
|
+
}
|
|
3194
|
+
function sanitizeName(name) {
|
|
3195
|
+
return name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "");
|
|
3196
|
+
}
|
|
3197
|
+
function toDbName(name) {
|
|
3198
|
+
return name.replace(/-/g, "_");
|
|
3199
|
+
}
|
|
3200
|
+
function toBundleId(name) {
|
|
3201
|
+
const safe = name.replace(/-/g, "");
|
|
3202
|
+
return `com.${safe}.app`;
|
|
3203
|
+
}
|
|
3204
|
+
function replaceTokens(content, name) {
|
|
3205
|
+
const dbName = toDbName(name);
|
|
3206
|
+
const bundleId = toBundleId(name);
|
|
3207
|
+
return content.replace(/blazestack-api\.your-subdomain/g, `${name}-api.your-subdomain`).replace(/@blazestack\//g, `@${name}/`).replace(/blazestack-api/g, `${name}-api`).replace(/blazestack-web/g, `${name}-web`).replace(/blazestack-pg/g, `${name}-pg`).replace(/blazestack_db/g, `${dbName}_db`).replace(/com\.blazestack\.app/g, bundleId).replace(/"name": "blazestack"/g, `"name": "${name}"`).replace(/# blazestack\b/g, `# ${name}`).replace(/# Contributing to blazestack/g, `# Contributing to ${name}`).replace(/^blazestack\/$/gm, `${name}/`).replace(/cd blazestack\b/g, `cd ${name}`);
|
|
3208
|
+
}
|
|
3209
|
+
function shouldExclude(relPath) {
|
|
3210
|
+
const parts = relPath.split(/[\/\\]/);
|
|
3211
|
+
if (EXCLUDE.has(parts[0]))
|
|
3212
|
+
return true;
|
|
3213
|
+
if (parts[0] === "packages" && parts[1] === "create-blaze")
|
|
3214
|
+
return true;
|
|
3215
|
+
return false;
|
|
3216
|
+
}
|
|
3217
|
+
function copyDir(src, dest, name) {
|
|
3218
|
+
mkdirSync(dest, { recursive: true });
|
|
3219
|
+
const entries = readdirSync(src);
|
|
3220
|
+
for (const entry of entries) {
|
|
3221
|
+
const srcPath = join(src, entry);
|
|
3222
|
+
const destPath = join(dest, entry);
|
|
3223
|
+
const stat = statSync(srcPath);
|
|
3224
|
+
if (stat.isDirectory()) {
|
|
3225
|
+
copyDir(srcPath, destPath, name);
|
|
3226
|
+
} else {
|
|
3227
|
+
if (isTextFile(srcPath)) {
|
|
3228
|
+
const content = readFileSync(srcPath, "utf8");
|
|
3229
|
+
writeFileSync(destPath, replaceTokens(content, name), "utf8");
|
|
3230
|
+
} else {
|
|
3231
|
+
const buf = readFileSync(srcPath);
|
|
3232
|
+
writeFileSync(destPath, buf);
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
function download(url, dest) {
|
|
3238
|
+
return new Promise((resolve, reject) => {
|
|
3239
|
+
const file = createWriteStream(dest);
|
|
3240
|
+
const request = (u2) => get(u2, (res) => {
|
|
3241
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
3242
|
+
file.destroy();
|
|
3243
|
+
request(res.headers.location ?? "");
|
|
3244
|
+
return;
|
|
3245
|
+
}
|
|
3246
|
+
if (res.statusCode !== 200) {
|
|
3247
|
+
reject(new Error(`Failed to download: HTTP ${res.statusCode}`));
|
|
3248
|
+
return;
|
|
3249
|
+
}
|
|
3250
|
+
res.pipe(file);
|
|
3251
|
+
file.on("finish", () => file.close(() => resolve()));
|
|
3252
|
+
}).on("error", reject);
|
|
3253
|
+
request(url);
|
|
3254
|
+
});
|
|
3255
|
+
}
|
|
3256
|
+
function dirExists(p2) {
|
|
3257
|
+
try {
|
|
3258
|
+
statSync(p2);
|
|
3259
|
+
return true;
|
|
3260
|
+
} catch {
|
|
3261
|
+
return false;
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
async function main() {
|
|
3265
|
+
const input = process.argv[2];
|
|
3266
|
+
const DEFAULT_NAME = "my-blazestack-app";
|
|
3267
|
+
const rawName = input ?? DEFAULT_NAME;
|
|
3268
|
+
const baseName = sanitizeName(rawName);
|
|
3269
|
+
if (!baseName) {
|
|
3270
|
+
console.error(`Invalid project name: "${rawName}"`);
|
|
3271
|
+
process.exit(1);
|
|
3272
|
+
}
|
|
3273
|
+
let safeName = baseName;
|
|
3274
|
+
let counter = 1;
|
|
3275
|
+
while (dirExists(join(process.cwd(), safeName))) {
|
|
3276
|
+
safeName = `${baseName}-${counter}`;
|
|
3277
|
+
counter++;
|
|
3278
|
+
}
|
|
3279
|
+
if (safeName !== baseName) {
|
|
3280
|
+
console.log(`
|
|
3281
|
+
"${baseName}" already exists — using "${safeName}" instead.`);
|
|
3282
|
+
}
|
|
3283
|
+
const targetDir = join(process.cwd(), safeName);
|
|
3284
|
+
const tarUrl = `https://codeload.github.com/${REPO_OWNER}/${REPO_NAME}/tar.gz/refs/heads/${REPO_BRANCH}`;
|
|
3285
|
+
const tmpFile = join(tmpdir(), `create-blaze-${Date.now()}.tar.gz`);
|
|
3286
|
+
const tmpExtract = join(tmpdir(), `create-blaze-${Date.now()}`);
|
|
3287
|
+
console.log(`
|
|
3288
|
+
Creating ${safeName}...
|
|
3289
|
+
`);
|
|
3290
|
+
try {
|
|
3291
|
+
process.stdout.write(" Downloading template...");
|
|
3292
|
+
await download(tarUrl, tmpFile);
|
|
3293
|
+
console.log(" done");
|
|
3294
|
+
process.stdout.write(" Extracting...");
|
|
3295
|
+
mkdirSync(tmpExtract, { recursive: true });
|
|
3296
|
+
await co({ file: tmpFile, cwd: tmpExtract });
|
|
3297
|
+
console.log(" done");
|
|
3298
|
+
const extractedRoot = join(tmpExtract, `${REPO_NAME}-${REPO_BRANCH}`);
|
|
3299
|
+
process.stdout.write(" Scaffolding project...");
|
|
3300
|
+
mkdirSync(targetDir, { recursive: true });
|
|
3301
|
+
const entries = readdirSync(extractedRoot);
|
|
3302
|
+
for (const entry of entries) {
|
|
3303
|
+
if (shouldExclude(entry))
|
|
3304
|
+
continue;
|
|
3305
|
+
const srcPath = join(extractedRoot, entry);
|
|
3306
|
+
const destPath = join(targetDir, entry);
|
|
3307
|
+
const stat = statSync(srcPath);
|
|
3308
|
+
if (stat.isDirectory()) {
|
|
3309
|
+
if (entry === "packages") {
|
|
3310
|
+
mkdirSync(destPath, { recursive: true });
|
|
3311
|
+
for (const pkg of readdirSync(srcPath)) {
|
|
3312
|
+
if (pkg === "create-blaze")
|
|
3313
|
+
continue;
|
|
3314
|
+
copyDir(join(srcPath, pkg), join(destPath, pkg), safeName);
|
|
3315
|
+
}
|
|
3316
|
+
} else {
|
|
3317
|
+
copyDir(srcPath, destPath, safeName);
|
|
3318
|
+
}
|
|
3319
|
+
} else {
|
|
3320
|
+
if (isTextFile(srcPath)) {
|
|
3321
|
+
const content = readFileSync(srcPath, "utf8");
|
|
3322
|
+
writeFileSync(destPath, replaceTokens(content, safeName), "utf8");
|
|
3323
|
+
} else {
|
|
3324
|
+
writeFileSync(destPath, readFileSync(srcPath));
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
console.log(" done");
|
|
3329
|
+
} finally {
|
|
3330
|
+
try {
|
|
3331
|
+
rmSync(tmpFile, { force: true });
|
|
3332
|
+
} catch {}
|
|
3333
|
+
try {
|
|
3334
|
+
rmSync(tmpExtract, { recursive: true, force: true });
|
|
3335
|
+
} catch {}
|
|
3336
|
+
}
|
|
3337
|
+
console.log(`
|
|
3338
|
+
Done! Next steps:
|
|
3339
|
+
|
|
3340
|
+
cd ${safeName}
|
|
3341
|
+
bun install
|
|
3342
|
+
cp apps/api/.dev.vars.example apps/api/.dev.vars
|
|
3343
|
+
# Edit apps/api/.dev.vars with your DATABASE_URL and BETTER_AUTH_SECRET
|
|
3344
|
+
bun db:setup && bun db:generate && bun db:migrate
|
|
3345
|
+
bun dev:api # terminal 1 — API on http://localhost:8787
|
|
3346
|
+
bun dev:web # terminal 2 — web on http://localhost:5173
|
|
3347
|
+
`);
|
|
3348
|
+
}
|
|
3349
|
+
main().catch((err) => {
|
|
3350
|
+
console.error(`
|
|
3351
|
+
Error:`, err.message);
|
|
3352
|
+
process.exit(1);
|
|
3353
|
+
});
|