@prisma-lossless/fetch-engine 7.8.0-lossless.11

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.
@@ -0,0 +1,2340 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_XRHAN4W7_exports = {};
30
+ __export(chunk_XRHAN4W7_exports, {
31
+ getCacheDir: () => getCacheDir,
32
+ getDownloadUrl: () => getDownloadUrl,
33
+ getRootCacheDir: () => getRootCacheDir,
34
+ overwriteFile: () => overwriteFile,
35
+ require_lib: () => require_lib
36
+ });
37
+ module.exports = __toCommonJS(chunk_XRHAN4W7_exports);
38
+ var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
39
+ var import_node_fs = __toESM(require("node:fs"));
40
+ var import_node_os = __toESM(require("node:os"));
41
+ var import_node_path = __toESM(require("node:path"));
42
+ var import_debug = __toESM(require("@prisma-lossless/debug"));
43
+ var import_node_process = __toESM(require("node:process"));
44
+ var import_node_path2 = __toESM(require("node:path"));
45
+ var import_node_fs2 = __toESM(require("node:fs"));
46
+ var import_node_path3 = __toESM(require("node:path"));
47
+ var import_node_path4 = __toESM(require("node:path"));
48
+ var import_node_url = require("node:url");
49
+ var import_node_process2 = __toESM(require("node:process"));
50
+ var import_node_path5 = __toESM(require("node:path"));
51
+ var import_node_fs3 = __toESM(require("node:fs"));
52
+ var import_node_url2 = require("node:url");
53
+ var require_common_path_prefix = (0, import_chunk_2ESYSVXG.__commonJS)({
54
+ "../../node_modules/.pnpm/common-path-prefix@3.0.0/node_modules/common-path-prefix/index.js"(exports, module2) {
55
+ "use strict";
56
+ var { sep: DEFAULT_SEPARATOR } = (0, import_chunk_2ESYSVXG.__require)("path");
57
+ var determineSeparator = (paths) => {
58
+ for (const path6 of paths) {
59
+ const match = /(\/|\\)/.exec(path6);
60
+ if (match !== null) return match[0];
61
+ }
62
+ return DEFAULT_SEPARATOR;
63
+ };
64
+ module2.exports = function commonPathPrefix2(paths, sep = determineSeparator(paths)) {
65
+ const [first = "", ...remaining] = paths;
66
+ if (first === "" || remaining.length === 0) return "";
67
+ const parts = first.split(sep);
68
+ let endOfPrefix = parts.length;
69
+ for (const path6 of remaining) {
70
+ const compare = path6.split(sep);
71
+ for (let i = 0; i < endOfPrefix; i++) {
72
+ if (compare[i] !== parts[i]) {
73
+ endOfPrefix = i;
74
+ }
75
+ }
76
+ if (endOfPrefix === 0) return "";
77
+ }
78
+ const prefix = parts.slice(0, endOfPrefix).join(sep);
79
+ return prefix.endsWith(sep) ? prefix : prefix + sep;
80
+ };
81
+ }
82
+ });
83
+ var require_universalify = (0, import_chunk_2ESYSVXG.__commonJS)({
84
+ "../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js"(exports) {
85
+ "use strict";
86
+ exports.fromCallback = function(fn) {
87
+ return Object.defineProperty(function(...args) {
88
+ if (typeof args[args.length - 1] === "function") fn.apply(this, args);
89
+ else {
90
+ return new Promise((resolve, reject) => {
91
+ args.push((err, res) => err != null ? reject(err) : resolve(res));
92
+ fn.apply(this, args);
93
+ });
94
+ }
95
+ }, "name", { value: fn.name });
96
+ };
97
+ exports.fromPromise = function(fn) {
98
+ return Object.defineProperty(function(...args) {
99
+ const cb = args[args.length - 1];
100
+ if (typeof cb !== "function") return fn.apply(this, args);
101
+ else {
102
+ args.pop();
103
+ fn.apply(this, args).then((r) => cb(null, r), cb);
104
+ }
105
+ }, "name", { value: fn.name });
106
+ };
107
+ }
108
+ });
109
+ var require_polyfills = (0, import_chunk_2ESYSVXG.__commonJS)({
110
+ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js"(exports, module2) {
111
+ "use strict";
112
+ var constants = (0, import_chunk_2ESYSVXG.__require)("constants");
113
+ var origCwd = process.cwd;
114
+ var cwd2 = null;
115
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
116
+ process.cwd = function() {
117
+ if (!cwd2)
118
+ cwd2 = origCwd.call(process);
119
+ return cwd2;
120
+ };
121
+ try {
122
+ process.cwd();
123
+ } catch (er) {
124
+ }
125
+ if (typeof process.chdir === "function") {
126
+ chdir = process.chdir;
127
+ process.chdir = function(d) {
128
+ cwd2 = null;
129
+ chdir.call(process, d);
130
+ };
131
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
132
+ }
133
+ var chdir;
134
+ module2.exports = patch;
135
+ function patch(fs4) {
136
+ if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
137
+ patchLchmod(fs4);
138
+ }
139
+ if (!fs4.lutimes) {
140
+ patchLutimes(fs4);
141
+ }
142
+ fs4.chown = chownFix(fs4.chown);
143
+ fs4.fchown = chownFix(fs4.fchown);
144
+ fs4.lchown = chownFix(fs4.lchown);
145
+ fs4.chmod = chmodFix(fs4.chmod);
146
+ fs4.fchmod = chmodFix(fs4.fchmod);
147
+ fs4.lchmod = chmodFix(fs4.lchmod);
148
+ fs4.chownSync = chownFixSync(fs4.chownSync);
149
+ fs4.fchownSync = chownFixSync(fs4.fchownSync);
150
+ fs4.lchownSync = chownFixSync(fs4.lchownSync);
151
+ fs4.chmodSync = chmodFixSync(fs4.chmodSync);
152
+ fs4.fchmodSync = chmodFixSync(fs4.fchmodSync);
153
+ fs4.lchmodSync = chmodFixSync(fs4.lchmodSync);
154
+ fs4.stat = statFix(fs4.stat);
155
+ fs4.fstat = statFix(fs4.fstat);
156
+ fs4.lstat = statFix(fs4.lstat);
157
+ fs4.statSync = statFixSync(fs4.statSync);
158
+ fs4.fstatSync = statFixSync(fs4.fstatSync);
159
+ fs4.lstatSync = statFixSync(fs4.lstatSync);
160
+ if (fs4.chmod && !fs4.lchmod) {
161
+ fs4.lchmod = function(path6, mode, cb) {
162
+ if (cb) process.nextTick(cb);
163
+ };
164
+ fs4.lchmodSync = function() {
165
+ };
166
+ }
167
+ if (fs4.chown && !fs4.lchown) {
168
+ fs4.lchown = function(path6, uid, gid, cb) {
169
+ if (cb) process.nextTick(cb);
170
+ };
171
+ fs4.lchownSync = function() {
172
+ };
173
+ }
174
+ if (platform === "win32") {
175
+ fs4.rename = typeof fs4.rename !== "function" ? fs4.rename : function(fs$rename) {
176
+ function rename(from, to, cb) {
177
+ var start = Date.now();
178
+ var backoff = 0;
179
+ fs$rename(from, to, function CB(er) {
180
+ if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
181
+ setTimeout(function() {
182
+ fs4.stat(to, function(stater, st) {
183
+ if (stater && stater.code === "ENOENT")
184
+ fs$rename(from, to, CB);
185
+ else
186
+ cb(er);
187
+ });
188
+ }, backoff);
189
+ if (backoff < 100)
190
+ backoff += 10;
191
+ return;
192
+ }
193
+ if (cb) cb(er);
194
+ });
195
+ }
196
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
197
+ return rename;
198
+ }(fs4.rename);
199
+ }
200
+ fs4.read = typeof fs4.read !== "function" ? fs4.read : function(fs$read) {
201
+ function read(fd, buffer, offset, length, position, callback_) {
202
+ var callback;
203
+ if (callback_ && typeof callback_ === "function") {
204
+ var eagCounter = 0;
205
+ callback = function(er, _, __) {
206
+ if (er && er.code === "EAGAIN" && eagCounter < 10) {
207
+ eagCounter++;
208
+ return fs$read.call(fs4, fd, buffer, offset, length, position, callback);
209
+ }
210
+ callback_.apply(this, arguments);
211
+ };
212
+ }
213
+ return fs$read.call(fs4, fd, buffer, offset, length, position, callback);
214
+ }
215
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
216
+ return read;
217
+ }(fs4.read);
218
+ fs4.readSync = typeof fs4.readSync !== "function" ? fs4.readSync : /* @__PURE__ */ function(fs$readSync) {
219
+ return function(fd, buffer, offset, length, position) {
220
+ var eagCounter = 0;
221
+ while (true) {
222
+ try {
223
+ return fs$readSync.call(fs4, fd, buffer, offset, length, position);
224
+ } catch (er) {
225
+ if (er.code === "EAGAIN" && eagCounter < 10) {
226
+ eagCounter++;
227
+ continue;
228
+ }
229
+ throw er;
230
+ }
231
+ }
232
+ };
233
+ }(fs4.readSync);
234
+ function patchLchmod(fs5) {
235
+ fs5.lchmod = function(path6, mode, callback) {
236
+ fs5.open(
237
+ path6,
238
+ constants.O_WRONLY | constants.O_SYMLINK,
239
+ mode,
240
+ function(err, fd) {
241
+ if (err) {
242
+ if (callback) callback(err);
243
+ return;
244
+ }
245
+ fs5.fchmod(fd, mode, function(err2) {
246
+ fs5.close(fd, function(err22) {
247
+ if (callback) callback(err2 || err22);
248
+ });
249
+ });
250
+ }
251
+ );
252
+ };
253
+ fs5.lchmodSync = function(path6, mode) {
254
+ var fd = fs5.openSync(path6, constants.O_WRONLY | constants.O_SYMLINK, mode);
255
+ var threw = true;
256
+ var ret;
257
+ try {
258
+ ret = fs5.fchmodSync(fd, mode);
259
+ threw = false;
260
+ } finally {
261
+ if (threw) {
262
+ try {
263
+ fs5.closeSync(fd);
264
+ } catch (er) {
265
+ }
266
+ } else {
267
+ fs5.closeSync(fd);
268
+ }
269
+ }
270
+ return ret;
271
+ };
272
+ }
273
+ function patchLutimes(fs5) {
274
+ if (constants.hasOwnProperty("O_SYMLINK") && fs5.futimes) {
275
+ fs5.lutimes = function(path6, at, mt, cb) {
276
+ fs5.open(path6, constants.O_SYMLINK, function(er, fd) {
277
+ if (er) {
278
+ if (cb) cb(er);
279
+ return;
280
+ }
281
+ fs5.futimes(fd, at, mt, function(er2) {
282
+ fs5.close(fd, function(er22) {
283
+ if (cb) cb(er2 || er22);
284
+ });
285
+ });
286
+ });
287
+ };
288
+ fs5.lutimesSync = function(path6, at, mt) {
289
+ var fd = fs5.openSync(path6, constants.O_SYMLINK);
290
+ var ret;
291
+ var threw = true;
292
+ try {
293
+ ret = fs5.futimesSync(fd, at, mt);
294
+ threw = false;
295
+ } finally {
296
+ if (threw) {
297
+ try {
298
+ fs5.closeSync(fd);
299
+ } catch (er) {
300
+ }
301
+ } else {
302
+ fs5.closeSync(fd);
303
+ }
304
+ }
305
+ return ret;
306
+ };
307
+ } else if (fs5.futimes) {
308
+ fs5.lutimes = function(_a, _b, _c, cb) {
309
+ if (cb) process.nextTick(cb);
310
+ };
311
+ fs5.lutimesSync = function() {
312
+ };
313
+ }
314
+ }
315
+ function chmodFix(orig) {
316
+ if (!orig) return orig;
317
+ return function(target, mode, cb) {
318
+ return orig.call(fs4, target, mode, function(er) {
319
+ if (chownErOk(er)) er = null;
320
+ if (cb) cb.apply(this, arguments);
321
+ });
322
+ };
323
+ }
324
+ function chmodFixSync(orig) {
325
+ if (!orig) return orig;
326
+ return function(target, mode) {
327
+ try {
328
+ return orig.call(fs4, target, mode);
329
+ } catch (er) {
330
+ if (!chownErOk(er)) throw er;
331
+ }
332
+ };
333
+ }
334
+ function chownFix(orig) {
335
+ if (!orig) return orig;
336
+ return function(target, uid, gid, cb) {
337
+ return orig.call(fs4, target, uid, gid, function(er) {
338
+ if (chownErOk(er)) er = null;
339
+ if (cb) cb.apply(this, arguments);
340
+ });
341
+ };
342
+ }
343
+ function chownFixSync(orig) {
344
+ if (!orig) return orig;
345
+ return function(target, uid, gid) {
346
+ try {
347
+ return orig.call(fs4, target, uid, gid);
348
+ } catch (er) {
349
+ if (!chownErOk(er)) throw er;
350
+ }
351
+ };
352
+ }
353
+ function statFix(orig) {
354
+ if (!orig) return orig;
355
+ return function(target, options, cb) {
356
+ if (typeof options === "function") {
357
+ cb = options;
358
+ options = null;
359
+ }
360
+ function callback(er, stats) {
361
+ if (stats) {
362
+ if (stats.uid < 0) stats.uid += 4294967296;
363
+ if (stats.gid < 0) stats.gid += 4294967296;
364
+ }
365
+ if (cb) cb.apply(this, arguments);
366
+ }
367
+ return options ? orig.call(fs4, target, options, callback) : orig.call(fs4, target, callback);
368
+ };
369
+ }
370
+ function statFixSync(orig) {
371
+ if (!orig) return orig;
372
+ return function(target, options) {
373
+ var stats = options ? orig.call(fs4, target, options) : orig.call(fs4, target);
374
+ if (stats) {
375
+ if (stats.uid < 0) stats.uid += 4294967296;
376
+ if (stats.gid < 0) stats.gid += 4294967296;
377
+ }
378
+ return stats;
379
+ };
380
+ }
381
+ function chownErOk(er) {
382
+ if (!er)
383
+ return true;
384
+ if (er.code === "ENOSYS")
385
+ return true;
386
+ var nonroot = !process.getuid || process.getuid() !== 0;
387
+ if (nonroot) {
388
+ if (er.code === "EINVAL" || er.code === "EPERM")
389
+ return true;
390
+ }
391
+ return false;
392
+ }
393
+ }
394
+ }
395
+ });
396
+ var require_legacy_streams = (0, import_chunk_2ESYSVXG.__commonJS)({
397
+ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
398
+ "use strict";
399
+ var Stream = (0, import_chunk_2ESYSVXG.__require)("stream").Stream;
400
+ module2.exports = legacy;
401
+ function legacy(fs4) {
402
+ return {
403
+ ReadStream,
404
+ WriteStream
405
+ };
406
+ function ReadStream(path6, options) {
407
+ if (!(this instanceof ReadStream)) return new ReadStream(path6, options);
408
+ Stream.call(this);
409
+ var self = this;
410
+ this.path = path6;
411
+ this.fd = null;
412
+ this.readable = true;
413
+ this.paused = false;
414
+ this.flags = "r";
415
+ this.mode = 438;
416
+ this.bufferSize = 64 * 1024;
417
+ options = options || {};
418
+ var keys = Object.keys(options);
419
+ for (var index = 0, length = keys.length; index < length; index++) {
420
+ var key = keys[index];
421
+ this[key] = options[key];
422
+ }
423
+ if (this.encoding) this.setEncoding(this.encoding);
424
+ if (this.start !== void 0) {
425
+ if ("number" !== typeof this.start) {
426
+ throw TypeError("start must be a Number");
427
+ }
428
+ if (this.end === void 0) {
429
+ this.end = Infinity;
430
+ } else if ("number" !== typeof this.end) {
431
+ throw TypeError("end must be a Number");
432
+ }
433
+ if (this.start > this.end) {
434
+ throw new Error("start must be <= end");
435
+ }
436
+ this.pos = this.start;
437
+ }
438
+ if (this.fd !== null) {
439
+ process.nextTick(function() {
440
+ self._read();
441
+ });
442
+ return;
443
+ }
444
+ fs4.open(this.path, this.flags, this.mode, function(err, fd) {
445
+ if (err) {
446
+ self.emit("error", err);
447
+ self.readable = false;
448
+ return;
449
+ }
450
+ self.fd = fd;
451
+ self.emit("open", fd);
452
+ self._read();
453
+ });
454
+ }
455
+ function WriteStream(path6, options) {
456
+ if (!(this instanceof WriteStream)) return new WriteStream(path6, options);
457
+ Stream.call(this);
458
+ this.path = path6;
459
+ this.fd = null;
460
+ this.writable = true;
461
+ this.flags = "w";
462
+ this.encoding = "binary";
463
+ this.mode = 438;
464
+ this.bytesWritten = 0;
465
+ options = options || {};
466
+ var keys = Object.keys(options);
467
+ for (var index = 0, length = keys.length; index < length; index++) {
468
+ var key = keys[index];
469
+ this[key] = options[key];
470
+ }
471
+ if (this.start !== void 0) {
472
+ if ("number" !== typeof this.start) {
473
+ throw TypeError("start must be a Number");
474
+ }
475
+ if (this.start < 0) {
476
+ throw new Error("start must be >= zero");
477
+ }
478
+ this.pos = this.start;
479
+ }
480
+ this.busy = false;
481
+ this._queue = [];
482
+ if (this.fd === null) {
483
+ this._open = fs4.open;
484
+ this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
485
+ this.flush();
486
+ }
487
+ }
488
+ }
489
+ }
490
+ });
491
+ var require_clone = (0, import_chunk_2ESYSVXG.__commonJS)({
492
+ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js"(exports, module2) {
493
+ "use strict";
494
+ module2.exports = clone;
495
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
496
+ return obj.__proto__;
497
+ };
498
+ function clone(obj) {
499
+ if (obj === null || typeof obj !== "object")
500
+ return obj;
501
+ if (obj instanceof Object)
502
+ var copy = { __proto__: getPrototypeOf(obj) };
503
+ else
504
+ var copy = /* @__PURE__ */ Object.create(null);
505
+ Object.getOwnPropertyNames(obj).forEach(function(key) {
506
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
507
+ });
508
+ return copy;
509
+ }
510
+ }
511
+ });
512
+ var require_graceful_fs = (0, import_chunk_2ESYSVXG.__commonJS)({
513
+ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
514
+ "use strict";
515
+ var fs4 = (0, import_chunk_2ESYSVXG.__require)("fs");
516
+ var polyfills = require_polyfills();
517
+ var legacy = require_legacy_streams();
518
+ var clone = require_clone();
519
+ var util = (0, import_chunk_2ESYSVXG.__require)("util");
520
+ var gracefulQueue;
521
+ var previousSymbol;
522
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
523
+ gracefulQueue = Symbol.for("graceful-fs.queue");
524
+ previousSymbol = Symbol.for("graceful-fs.previous");
525
+ } else {
526
+ gracefulQueue = "___graceful-fs.queue";
527
+ previousSymbol = "___graceful-fs.previous";
528
+ }
529
+ function noop() {
530
+ }
531
+ function publishQueue(context, queue2) {
532
+ Object.defineProperty(context, gracefulQueue, {
533
+ get: function() {
534
+ return queue2;
535
+ }
536
+ });
537
+ }
538
+ var debug2 = noop;
539
+ if (util.debuglog)
540
+ debug2 = util.debuglog("gfs4");
541
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
542
+ debug2 = function() {
543
+ var m = util.format.apply(util, arguments);
544
+ m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
545
+ console.error(m);
546
+ };
547
+ if (!fs4[gracefulQueue]) {
548
+ queue = global[gracefulQueue] || [];
549
+ publishQueue(fs4, queue);
550
+ fs4.close = function(fs$close) {
551
+ function close(fd, cb) {
552
+ return fs$close.call(fs4, fd, function(err) {
553
+ if (!err) {
554
+ resetQueue();
555
+ }
556
+ if (typeof cb === "function")
557
+ cb.apply(this, arguments);
558
+ });
559
+ }
560
+ Object.defineProperty(close, previousSymbol, {
561
+ value: fs$close
562
+ });
563
+ return close;
564
+ }(fs4.close);
565
+ fs4.closeSync = function(fs$closeSync) {
566
+ function closeSync(fd) {
567
+ fs$closeSync.apply(fs4, arguments);
568
+ resetQueue();
569
+ }
570
+ Object.defineProperty(closeSync, previousSymbol, {
571
+ value: fs$closeSync
572
+ });
573
+ return closeSync;
574
+ }(fs4.closeSync);
575
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
576
+ process.on("exit", function() {
577
+ debug2(fs4[gracefulQueue]);
578
+ (0, import_chunk_2ESYSVXG.__require)("assert").equal(fs4[gracefulQueue].length, 0);
579
+ });
580
+ }
581
+ }
582
+ var queue;
583
+ if (!global[gracefulQueue]) {
584
+ publishQueue(global, fs4[gracefulQueue]);
585
+ }
586
+ module2.exports = patch(clone(fs4));
587
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs4.__patched) {
588
+ module2.exports = patch(fs4);
589
+ fs4.__patched = true;
590
+ }
591
+ function patch(fs5) {
592
+ polyfills(fs5);
593
+ fs5.gracefulify = patch;
594
+ fs5.createReadStream = createReadStream;
595
+ fs5.createWriteStream = createWriteStream;
596
+ var fs$readFile = fs5.readFile;
597
+ fs5.readFile = readFile;
598
+ function readFile(path6, options, cb) {
599
+ if (typeof options === "function")
600
+ cb = options, options = null;
601
+ return go$readFile(path6, options, cb);
602
+ function go$readFile(path7, options2, cb2, startTime) {
603
+ return fs$readFile(path7, options2, function(err) {
604
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
605
+ enqueue([go$readFile, [path7, options2, cb2], err, startTime || Date.now(), Date.now()]);
606
+ else {
607
+ if (typeof cb2 === "function")
608
+ cb2.apply(this, arguments);
609
+ }
610
+ });
611
+ }
612
+ }
613
+ var fs$writeFile = fs5.writeFile;
614
+ fs5.writeFile = writeFile;
615
+ function writeFile(path6, data, options, cb) {
616
+ if (typeof options === "function")
617
+ cb = options, options = null;
618
+ return go$writeFile(path6, data, options, cb);
619
+ function go$writeFile(path7, data2, options2, cb2, startTime) {
620
+ return fs$writeFile(path7, data2, options2, function(err) {
621
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
622
+ enqueue([go$writeFile, [path7, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
623
+ else {
624
+ if (typeof cb2 === "function")
625
+ cb2.apply(this, arguments);
626
+ }
627
+ });
628
+ }
629
+ }
630
+ var fs$appendFile = fs5.appendFile;
631
+ if (fs$appendFile)
632
+ fs5.appendFile = appendFile;
633
+ function appendFile(path6, data, options, cb) {
634
+ if (typeof options === "function")
635
+ cb = options, options = null;
636
+ return go$appendFile(path6, data, options, cb);
637
+ function go$appendFile(path7, data2, options2, cb2, startTime) {
638
+ return fs$appendFile(path7, data2, options2, function(err) {
639
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
640
+ enqueue([go$appendFile, [path7, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
641
+ else {
642
+ if (typeof cb2 === "function")
643
+ cb2.apply(this, arguments);
644
+ }
645
+ });
646
+ }
647
+ }
648
+ var fs$copyFile = fs5.copyFile;
649
+ if (fs$copyFile)
650
+ fs5.copyFile = copyFile;
651
+ function copyFile(src, dest, flags, cb) {
652
+ if (typeof flags === "function") {
653
+ cb = flags;
654
+ flags = 0;
655
+ }
656
+ return go$copyFile(src, dest, flags, cb);
657
+ function go$copyFile(src2, dest2, flags2, cb2, startTime) {
658
+ return fs$copyFile(src2, dest2, flags2, function(err) {
659
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
660
+ enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
661
+ else {
662
+ if (typeof cb2 === "function")
663
+ cb2.apply(this, arguments);
664
+ }
665
+ });
666
+ }
667
+ }
668
+ var fs$readdir = fs5.readdir;
669
+ fs5.readdir = readdir;
670
+ var noReaddirOptionVersions = /^v[0-5]\./;
671
+ function readdir(path6, options, cb) {
672
+ if (typeof options === "function")
673
+ cb = options, options = null;
674
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path7, options2, cb2, startTime) {
675
+ return fs$readdir(path7, fs$readdirCallback(
676
+ path7,
677
+ options2,
678
+ cb2,
679
+ startTime
680
+ ));
681
+ } : function go$readdir2(path7, options2, cb2, startTime) {
682
+ return fs$readdir(path7, options2, fs$readdirCallback(
683
+ path7,
684
+ options2,
685
+ cb2,
686
+ startTime
687
+ ));
688
+ };
689
+ return go$readdir(path6, options, cb);
690
+ function fs$readdirCallback(path7, options2, cb2, startTime) {
691
+ return function(err, files) {
692
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
693
+ enqueue([
694
+ go$readdir,
695
+ [path7, options2, cb2],
696
+ err,
697
+ startTime || Date.now(),
698
+ Date.now()
699
+ ]);
700
+ else {
701
+ if (files && files.sort)
702
+ files.sort();
703
+ if (typeof cb2 === "function")
704
+ cb2.call(this, err, files);
705
+ }
706
+ };
707
+ }
708
+ }
709
+ if (process.version.substr(0, 4) === "v0.8") {
710
+ var legStreams = legacy(fs5);
711
+ ReadStream = legStreams.ReadStream;
712
+ WriteStream = legStreams.WriteStream;
713
+ }
714
+ var fs$ReadStream = fs5.ReadStream;
715
+ if (fs$ReadStream) {
716
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
717
+ ReadStream.prototype.open = ReadStream$open;
718
+ }
719
+ var fs$WriteStream = fs5.WriteStream;
720
+ if (fs$WriteStream) {
721
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
722
+ WriteStream.prototype.open = WriteStream$open;
723
+ }
724
+ Object.defineProperty(fs5, "ReadStream", {
725
+ get: function() {
726
+ return ReadStream;
727
+ },
728
+ set: function(val) {
729
+ ReadStream = val;
730
+ },
731
+ enumerable: true,
732
+ configurable: true
733
+ });
734
+ Object.defineProperty(fs5, "WriteStream", {
735
+ get: function() {
736
+ return WriteStream;
737
+ },
738
+ set: function(val) {
739
+ WriteStream = val;
740
+ },
741
+ enumerable: true,
742
+ configurable: true
743
+ });
744
+ var FileReadStream = ReadStream;
745
+ Object.defineProperty(fs5, "FileReadStream", {
746
+ get: function() {
747
+ return FileReadStream;
748
+ },
749
+ set: function(val) {
750
+ FileReadStream = val;
751
+ },
752
+ enumerable: true,
753
+ configurable: true
754
+ });
755
+ var FileWriteStream = WriteStream;
756
+ Object.defineProperty(fs5, "FileWriteStream", {
757
+ get: function() {
758
+ return FileWriteStream;
759
+ },
760
+ set: function(val) {
761
+ FileWriteStream = val;
762
+ },
763
+ enumerable: true,
764
+ configurable: true
765
+ });
766
+ function ReadStream(path6, options) {
767
+ if (this instanceof ReadStream)
768
+ return fs$ReadStream.apply(this, arguments), this;
769
+ else
770
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
771
+ }
772
+ function ReadStream$open() {
773
+ var that = this;
774
+ open(that.path, that.flags, that.mode, function(err, fd) {
775
+ if (err) {
776
+ if (that.autoClose)
777
+ that.destroy();
778
+ that.emit("error", err);
779
+ } else {
780
+ that.fd = fd;
781
+ that.emit("open", fd);
782
+ that.read();
783
+ }
784
+ });
785
+ }
786
+ function WriteStream(path6, options) {
787
+ if (this instanceof WriteStream)
788
+ return fs$WriteStream.apply(this, arguments), this;
789
+ else
790
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
791
+ }
792
+ function WriteStream$open() {
793
+ var that = this;
794
+ open(that.path, that.flags, that.mode, function(err, fd) {
795
+ if (err) {
796
+ that.destroy();
797
+ that.emit("error", err);
798
+ } else {
799
+ that.fd = fd;
800
+ that.emit("open", fd);
801
+ }
802
+ });
803
+ }
804
+ function createReadStream(path6, options) {
805
+ return new fs5.ReadStream(path6, options);
806
+ }
807
+ function createWriteStream(path6, options) {
808
+ return new fs5.WriteStream(path6, options);
809
+ }
810
+ var fs$open = fs5.open;
811
+ fs5.open = open;
812
+ function open(path6, flags, mode, cb) {
813
+ if (typeof mode === "function")
814
+ cb = mode, mode = null;
815
+ return go$open(path6, flags, mode, cb);
816
+ function go$open(path7, flags2, mode2, cb2, startTime) {
817
+ return fs$open(path7, flags2, mode2, function(err, fd) {
818
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
819
+ enqueue([go$open, [path7, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
820
+ else {
821
+ if (typeof cb2 === "function")
822
+ cb2.apply(this, arguments);
823
+ }
824
+ });
825
+ }
826
+ }
827
+ return fs5;
828
+ }
829
+ function enqueue(elem) {
830
+ debug2("ENQUEUE", elem[0].name, elem[1]);
831
+ fs4[gracefulQueue].push(elem);
832
+ retry();
833
+ }
834
+ var retryTimer;
835
+ function resetQueue() {
836
+ var now = Date.now();
837
+ for (var i = 0; i < fs4[gracefulQueue].length; ++i) {
838
+ if (fs4[gracefulQueue][i].length > 2) {
839
+ fs4[gracefulQueue][i][3] = now;
840
+ fs4[gracefulQueue][i][4] = now;
841
+ }
842
+ }
843
+ retry();
844
+ }
845
+ function retry() {
846
+ clearTimeout(retryTimer);
847
+ retryTimer = void 0;
848
+ if (fs4[gracefulQueue].length === 0)
849
+ return;
850
+ var elem = fs4[gracefulQueue].shift();
851
+ var fn = elem[0];
852
+ var args = elem[1];
853
+ var err = elem[2];
854
+ var startTime = elem[3];
855
+ var lastTime = elem[4];
856
+ if (startTime === void 0) {
857
+ debug2("RETRY", fn.name, args);
858
+ fn.apply(null, args);
859
+ } else if (Date.now() - startTime >= 6e4) {
860
+ debug2("TIMEOUT", fn.name, args);
861
+ var cb = args.pop();
862
+ if (typeof cb === "function")
863
+ cb.call(null, err);
864
+ } else {
865
+ var sinceAttempt = Date.now() - lastTime;
866
+ var sinceStart = Math.max(lastTime - startTime, 1);
867
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
868
+ if (sinceAttempt >= desiredDelay) {
869
+ debug2("RETRY", fn.name, args);
870
+ fn.apply(null, args.concat([startTime]));
871
+ } else {
872
+ fs4[gracefulQueue].push(elem);
873
+ }
874
+ }
875
+ if (retryTimer === void 0) {
876
+ retryTimer = setTimeout(retry, 0);
877
+ }
878
+ }
879
+ }
880
+ });
881
+ var require_fs = (0, import_chunk_2ESYSVXG.__commonJS)({
882
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/fs/index.js"(exports) {
883
+ "use strict";
884
+ var u = require_universalify().fromCallback;
885
+ var fs4 = require_graceful_fs();
886
+ var api = [
887
+ "access",
888
+ "appendFile",
889
+ "chmod",
890
+ "chown",
891
+ "close",
892
+ "copyFile",
893
+ "cp",
894
+ "fchmod",
895
+ "fchown",
896
+ "fdatasync",
897
+ "fstat",
898
+ "fsync",
899
+ "ftruncate",
900
+ "futimes",
901
+ "glob",
902
+ "lchmod",
903
+ "lchown",
904
+ "lutimes",
905
+ "link",
906
+ "lstat",
907
+ "mkdir",
908
+ "mkdtemp",
909
+ "open",
910
+ "opendir",
911
+ "readdir",
912
+ "readFile",
913
+ "readlink",
914
+ "realpath",
915
+ "rename",
916
+ "rm",
917
+ "rmdir",
918
+ "stat",
919
+ "statfs",
920
+ "symlink",
921
+ "truncate",
922
+ "unlink",
923
+ "utimes",
924
+ "writeFile"
925
+ ].filter((key) => {
926
+ return typeof fs4[key] === "function";
927
+ });
928
+ Object.assign(exports, fs4);
929
+ api.forEach((method) => {
930
+ exports[method] = u(fs4[method]);
931
+ });
932
+ exports.exists = function(filename, callback) {
933
+ if (typeof callback === "function") {
934
+ return fs4.exists(filename, callback);
935
+ }
936
+ return new Promise((resolve) => {
937
+ return fs4.exists(filename, resolve);
938
+ });
939
+ };
940
+ exports.read = function(fd, buffer, offset, length, position, callback) {
941
+ if (typeof callback === "function") {
942
+ return fs4.read(fd, buffer, offset, length, position, callback);
943
+ }
944
+ return new Promise((resolve, reject) => {
945
+ fs4.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
946
+ if (err) return reject(err);
947
+ resolve({ bytesRead, buffer: buffer2 });
948
+ });
949
+ });
950
+ };
951
+ exports.write = function(fd, buffer, ...args) {
952
+ if (typeof args[args.length - 1] === "function") {
953
+ return fs4.write(fd, buffer, ...args);
954
+ }
955
+ return new Promise((resolve, reject) => {
956
+ fs4.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
957
+ if (err) return reject(err);
958
+ resolve({ bytesWritten, buffer: buffer2 });
959
+ });
960
+ });
961
+ };
962
+ exports.readv = function(fd, buffers, ...args) {
963
+ if (typeof args[args.length - 1] === "function") {
964
+ return fs4.readv(fd, buffers, ...args);
965
+ }
966
+ return new Promise((resolve, reject) => {
967
+ fs4.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
968
+ if (err) return reject(err);
969
+ resolve({ bytesRead, buffers: buffers2 });
970
+ });
971
+ });
972
+ };
973
+ exports.writev = function(fd, buffers, ...args) {
974
+ if (typeof args[args.length - 1] === "function") {
975
+ return fs4.writev(fd, buffers, ...args);
976
+ }
977
+ return new Promise((resolve, reject) => {
978
+ fs4.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
979
+ if (err) return reject(err);
980
+ resolve({ bytesWritten, buffers: buffers2 });
981
+ });
982
+ });
983
+ };
984
+ if (typeof fs4.realpath.native === "function") {
985
+ exports.realpath.native = u(fs4.realpath.native);
986
+ } else {
987
+ process.emitWarning(
988
+ "fs.realpath.native is not a function. Is fs being monkey-patched?",
989
+ "Warning",
990
+ "fs-extra-WARN0003"
991
+ );
992
+ }
993
+ }
994
+ });
995
+ var require_utils = (0, import_chunk_2ESYSVXG.__commonJS)({
996
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/utils.js"(exports, module2) {
997
+ "use strict";
998
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
999
+ module2.exports.checkPath = function checkPath(pth) {
1000
+ if (process.platform === "win32") {
1001
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path6.parse(pth).root, ""));
1002
+ if (pathHasInvalidWinCharacters) {
1003
+ const error = new Error(`Path contains invalid characters: ${pth}`);
1004
+ error.code = "EINVAL";
1005
+ throw error;
1006
+ }
1007
+ }
1008
+ };
1009
+ }
1010
+ });
1011
+ var require_make_dir = (0, import_chunk_2ESYSVXG.__commonJS)({
1012
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports, module2) {
1013
+ "use strict";
1014
+ var fs4 = require_fs();
1015
+ var { checkPath } = require_utils();
1016
+ var getMode = (options) => {
1017
+ const defaults = { mode: 511 };
1018
+ if (typeof options === "number") return options;
1019
+ return { ...defaults, ...options }.mode;
1020
+ };
1021
+ module2.exports.makeDir = async (dir, options) => {
1022
+ checkPath(dir);
1023
+ return fs4.mkdir(dir, {
1024
+ mode: getMode(options),
1025
+ recursive: true
1026
+ });
1027
+ };
1028
+ module2.exports.makeDirSync = (dir, options) => {
1029
+ checkPath(dir);
1030
+ return fs4.mkdirSync(dir, {
1031
+ mode: getMode(options),
1032
+ recursive: true
1033
+ });
1034
+ };
1035
+ }
1036
+ });
1037
+ var require_mkdirs = (0, import_chunk_2ESYSVXG.__commonJS)({
1038
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/index.js"(exports, module2) {
1039
+ "use strict";
1040
+ var u = require_universalify().fromPromise;
1041
+ var { makeDir: _makeDir, makeDirSync } = require_make_dir();
1042
+ var makeDir = u(_makeDir);
1043
+ module2.exports = {
1044
+ mkdirs: makeDir,
1045
+ mkdirsSync: makeDirSync,
1046
+ // alias
1047
+ mkdirp: makeDir,
1048
+ mkdirpSync: makeDirSync,
1049
+ ensureDir: makeDir,
1050
+ ensureDirSync: makeDirSync
1051
+ };
1052
+ }
1053
+ });
1054
+ var require_path_exists = (0, import_chunk_2ESYSVXG.__commonJS)({
1055
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/path-exists/index.js"(exports, module2) {
1056
+ "use strict";
1057
+ var u = require_universalify().fromPromise;
1058
+ var fs4 = require_fs();
1059
+ function pathExists2(path6) {
1060
+ return fs4.access(path6).then(() => true).catch(() => false);
1061
+ }
1062
+ module2.exports = {
1063
+ pathExists: u(pathExists2),
1064
+ pathExistsSync: fs4.existsSync
1065
+ };
1066
+ }
1067
+ });
1068
+ var require_utimes = (0, import_chunk_2ESYSVXG.__commonJS)({
1069
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/util/utimes.js"(exports, module2) {
1070
+ "use strict";
1071
+ var fs4 = require_fs();
1072
+ var u = require_universalify().fromPromise;
1073
+ async function utimesMillis(path6, atime, mtime) {
1074
+ const fd = await fs4.open(path6, "r+");
1075
+ let closeErr = null;
1076
+ try {
1077
+ await fs4.futimes(fd, atime, mtime);
1078
+ } finally {
1079
+ try {
1080
+ await fs4.close(fd);
1081
+ } catch (e) {
1082
+ closeErr = e;
1083
+ }
1084
+ }
1085
+ if (closeErr) {
1086
+ throw closeErr;
1087
+ }
1088
+ }
1089
+ function utimesMillisSync(path6, atime, mtime) {
1090
+ const fd = fs4.openSync(path6, "r+");
1091
+ fs4.futimesSync(fd, atime, mtime);
1092
+ return fs4.closeSync(fd);
1093
+ }
1094
+ module2.exports = {
1095
+ utimesMillis: u(utimesMillis),
1096
+ utimesMillisSync
1097
+ };
1098
+ }
1099
+ });
1100
+ var require_stat = (0, import_chunk_2ESYSVXG.__commonJS)({
1101
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/util/stat.js"(exports, module2) {
1102
+ "use strict";
1103
+ var fs4 = require_fs();
1104
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1105
+ var u = require_universalify().fromPromise;
1106
+ function getStats(src, dest, opts) {
1107
+ const statFunc = opts.dereference ? (file) => fs4.stat(file, { bigint: true }) : (file) => fs4.lstat(file, { bigint: true });
1108
+ return Promise.all([
1109
+ statFunc(src),
1110
+ statFunc(dest).catch((err) => {
1111
+ if (err.code === "ENOENT") return null;
1112
+ throw err;
1113
+ })
1114
+ ]).then(([srcStat, destStat]) => ({ srcStat, destStat }));
1115
+ }
1116
+ function getStatsSync(src, dest, opts) {
1117
+ let destStat;
1118
+ const statFunc = opts.dereference ? (file) => fs4.statSync(file, { bigint: true }) : (file) => fs4.lstatSync(file, { bigint: true });
1119
+ const srcStat = statFunc(src);
1120
+ try {
1121
+ destStat = statFunc(dest);
1122
+ } catch (err) {
1123
+ if (err.code === "ENOENT") return { srcStat, destStat: null };
1124
+ throw err;
1125
+ }
1126
+ return { srcStat, destStat };
1127
+ }
1128
+ async function checkPaths(src, dest, funcName, opts) {
1129
+ const { srcStat, destStat } = await getStats(src, dest, opts);
1130
+ if (destStat) {
1131
+ if (areIdentical(srcStat, destStat)) {
1132
+ const srcBaseName = path6.basename(src);
1133
+ const destBaseName = path6.basename(dest);
1134
+ if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1135
+ return { srcStat, destStat, isChangingCase: true };
1136
+ }
1137
+ throw new Error("Source and destination must not be the same.");
1138
+ }
1139
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
1140
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
1141
+ }
1142
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
1143
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
1144
+ }
1145
+ }
1146
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1147
+ throw new Error(errMsg(src, dest, funcName));
1148
+ }
1149
+ return { srcStat, destStat };
1150
+ }
1151
+ function checkPathsSync(src, dest, funcName, opts) {
1152
+ const { srcStat, destStat } = getStatsSync(src, dest, opts);
1153
+ if (destStat) {
1154
+ if (areIdentical(srcStat, destStat)) {
1155
+ const srcBaseName = path6.basename(src);
1156
+ const destBaseName = path6.basename(dest);
1157
+ if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1158
+ return { srcStat, destStat, isChangingCase: true };
1159
+ }
1160
+ throw new Error("Source and destination must not be the same.");
1161
+ }
1162
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
1163
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
1164
+ }
1165
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
1166
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
1167
+ }
1168
+ }
1169
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1170
+ throw new Error(errMsg(src, dest, funcName));
1171
+ }
1172
+ return { srcStat, destStat };
1173
+ }
1174
+ async function checkParentPaths(src, srcStat, dest, funcName) {
1175
+ const srcParent = path6.resolve(path6.dirname(src));
1176
+ const destParent = path6.resolve(path6.dirname(dest));
1177
+ if (destParent === srcParent || destParent === path6.parse(destParent).root) return;
1178
+ let destStat;
1179
+ try {
1180
+ destStat = await fs4.stat(destParent, { bigint: true });
1181
+ } catch (err) {
1182
+ if (err.code === "ENOENT") return;
1183
+ throw err;
1184
+ }
1185
+ if (areIdentical(srcStat, destStat)) {
1186
+ throw new Error(errMsg(src, dest, funcName));
1187
+ }
1188
+ return checkParentPaths(src, srcStat, destParent, funcName);
1189
+ }
1190
+ function checkParentPathsSync(src, srcStat, dest, funcName) {
1191
+ const srcParent = path6.resolve(path6.dirname(src));
1192
+ const destParent = path6.resolve(path6.dirname(dest));
1193
+ if (destParent === srcParent || destParent === path6.parse(destParent).root) return;
1194
+ let destStat;
1195
+ try {
1196
+ destStat = fs4.statSync(destParent, { bigint: true });
1197
+ } catch (err) {
1198
+ if (err.code === "ENOENT") return;
1199
+ throw err;
1200
+ }
1201
+ if (areIdentical(srcStat, destStat)) {
1202
+ throw new Error(errMsg(src, dest, funcName));
1203
+ }
1204
+ return checkParentPathsSync(src, srcStat, destParent, funcName);
1205
+ }
1206
+ function areIdentical(srcStat, destStat) {
1207
+ return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
1208
+ }
1209
+ function isSrcSubdir(src, dest) {
1210
+ const srcArr = path6.resolve(src).split(path6.sep).filter((i) => i);
1211
+ const destArr = path6.resolve(dest).split(path6.sep).filter((i) => i);
1212
+ return srcArr.every((cur, i) => destArr[i] === cur);
1213
+ }
1214
+ function errMsg(src, dest, funcName) {
1215
+ return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
1216
+ }
1217
+ module2.exports = {
1218
+ // checkPaths
1219
+ checkPaths: u(checkPaths),
1220
+ checkPathsSync,
1221
+ // checkParent
1222
+ checkParentPaths: u(checkParentPaths),
1223
+ checkParentPathsSync,
1224
+ // Misc
1225
+ isSrcSubdir,
1226
+ areIdentical
1227
+ };
1228
+ }
1229
+ });
1230
+ var require_copy = (0, import_chunk_2ESYSVXG.__commonJS)({
1231
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/copy.js"(exports, module2) {
1232
+ "use strict";
1233
+ var fs4 = require_fs();
1234
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1235
+ var { mkdirs } = require_mkdirs();
1236
+ var { pathExists: pathExists2 } = require_path_exists();
1237
+ var { utimesMillis } = require_utimes();
1238
+ var stat = require_stat();
1239
+ async function copy(src, dest, opts = {}) {
1240
+ if (typeof opts === "function") {
1241
+ opts = { filter: opts };
1242
+ }
1243
+ opts.clobber = "clobber" in opts ? !!opts.clobber : true;
1244
+ opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
1245
+ if (opts.preserveTimestamps && process.arch === "ia32") {
1246
+ process.emitWarning(
1247
+ "Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
1248
+ "Warning",
1249
+ "fs-extra-WARN0001"
1250
+ );
1251
+ }
1252
+ const { srcStat, destStat } = await stat.checkPaths(src, dest, "copy", opts);
1253
+ await stat.checkParentPaths(src, srcStat, dest, "copy");
1254
+ const include = await runFilter(src, dest, opts);
1255
+ if (!include) return;
1256
+ const destParent = path6.dirname(dest);
1257
+ const dirExists = await pathExists2(destParent);
1258
+ if (!dirExists) {
1259
+ await mkdirs(destParent);
1260
+ }
1261
+ await getStatsAndPerformCopy(destStat, src, dest, opts);
1262
+ }
1263
+ async function runFilter(src, dest, opts) {
1264
+ if (!opts.filter) return true;
1265
+ return opts.filter(src, dest);
1266
+ }
1267
+ async function getStatsAndPerformCopy(destStat, src, dest, opts) {
1268
+ const statFn = opts.dereference ? fs4.stat : fs4.lstat;
1269
+ const srcStat = await statFn(src);
1270
+ if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
1271
+ if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
1272
+ if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
1273
+ if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
1274
+ if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
1275
+ throw new Error(`Unknown file: ${src}`);
1276
+ }
1277
+ async function onFile(srcStat, destStat, src, dest, opts) {
1278
+ if (!destStat) return copyFile(srcStat, src, dest, opts);
1279
+ if (opts.overwrite) {
1280
+ await fs4.unlink(dest);
1281
+ return copyFile(srcStat, src, dest, opts);
1282
+ }
1283
+ if (opts.errorOnExist) {
1284
+ throw new Error(`'${dest}' already exists`);
1285
+ }
1286
+ }
1287
+ async function copyFile(srcStat, src, dest, opts) {
1288
+ await fs4.copyFile(src, dest);
1289
+ if (opts.preserveTimestamps) {
1290
+ if (fileIsNotWritable(srcStat.mode)) {
1291
+ await makeFileWritable(dest, srcStat.mode);
1292
+ }
1293
+ const updatedSrcStat = await fs4.stat(src);
1294
+ await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1295
+ }
1296
+ return fs4.chmod(dest, srcStat.mode);
1297
+ }
1298
+ function fileIsNotWritable(srcMode) {
1299
+ return (srcMode & 128) === 0;
1300
+ }
1301
+ function makeFileWritable(dest, srcMode) {
1302
+ return fs4.chmod(dest, srcMode | 128);
1303
+ }
1304
+ async function onDir(srcStat, destStat, src, dest, opts) {
1305
+ if (!destStat) {
1306
+ await fs4.mkdir(dest);
1307
+ }
1308
+ const promises = [];
1309
+ for await (const item of await fs4.opendir(src)) {
1310
+ const srcItem = path6.join(src, item.name);
1311
+ const destItem = path6.join(dest, item.name);
1312
+ promises.push(
1313
+ runFilter(srcItem, destItem, opts).then((include) => {
1314
+ if (include) {
1315
+ return stat.checkPaths(srcItem, destItem, "copy", opts).then(({ destStat: destStat2 }) => {
1316
+ return getStatsAndPerformCopy(destStat2, srcItem, destItem, opts);
1317
+ });
1318
+ }
1319
+ })
1320
+ );
1321
+ }
1322
+ await Promise.all(promises);
1323
+ if (!destStat) {
1324
+ await fs4.chmod(dest, srcStat.mode);
1325
+ }
1326
+ }
1327
+ async function onLink(destStat, src, dest, opts) {
1328
+ let resolvedSrc = await fs4.readlink(src);
1329
+ if (opts.dereference) {
1330
+ resolvedSrc = path6.resolve(process.cwd(), resolvedSrc);
1331
+ }
1332
+ if (!destStat) {
1333
+ return fs4.symlink(resolvedSrc, dest);
1334
+ }
1335
+ let resolvedDest = null;
1336
+ try {
1337
+ resolvedDest = await fs4.readlink(dest);
1338
+ } catch (e) {
1339
+ if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs4.symlink(resolvedSrc, dest);
1340
+ throw e;
1341
+ }
1342
+ if (opts.dereference) {
1343
+ resolvedDest = path6.resolve(process.cwd(), resolvedDest);
1344
+ }
1345
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1346
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
1347
+ }
1348
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1349
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
1350
+ }
1351
+ await fs4.unlink(dest);
1352
+ return fs4.symlink(resolvedSrc, dest);
1353
+ }
1354
+ module2.exports = copy;
1355
+ }
1356
+ });
1357
+ var require_copy_sync = (0, import_chunk_2ESYSVXG.__commonJS)({
1358
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/copy-sync.js"(exports, module2) {
1359
+ "use strict";
1360
+ var fs4 = require_graceful_fs();
1361
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1362
+ var mkdirsSync = require_mkdirs().mkdirsSync;
1363
+ var utimesMillisSync = require_utimes().utimesMillisSync;
1364
+ var stat = require_stat();
1365
+ function copySync(src, dest, opts) {
1366
+ if (typeof opts === "function") {
1367
+ opts = { filter: opts };
1368
+ }
1369
+ opts = opts || {};
1370
+ opts.clobber = "clobber" in opts ? !!opts.clobber : true;
1371
+ opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
1372
+ if (opts.preserveTimestamps && process.arch === "ia32") {
1373
+ process.emitWarning(
1374
+ "Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
1375
+ "Warning",
1376
+ "fs-extra-WARN0002"
1377
+ );
1378
+ }
1379
+ const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
1380
+ stat.checkParentPathsSync(src, srcStat, dest, "copy");
1381
+ if (opts.filter && !opts.filter(src, dest)) return;
1382
+ const destParent = path6.dirname(dest);
1383
+ if (!fs4.existsSync(destParent)) mkdirsSync(destParent);
1384
+ return getStats(destStat, src, dest, opts);
1385
+ }
1386
+ function getStats(destStat, src, dest, opts) {
1387
+ const statSync = opts.dereference ? fs4.statSync : fs4.lstatSync;
1388
+ const srcStat = statSync(src);
1389
+ if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
1390
+ else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
1391
+ else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
1392
+ else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
1393
+ else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
1394
+ throw new Error(`Unknown file: ${src}`);
1395
+ }
1396
+ function onFile(srcStat, destStat, src, dest, opts) {
1397
+ if (!destStat) return copyFile(srcStat, src, dest, opts);
1398
+ return mayCopyFile(srcStat, src, dest, opts);
1399
+ }
1400
+ function mayCopyFile(srcStat, src, dest, opts) {
1401
+ if (opts.overwrite) {
1402
+ fs4.unlinkSync(dest);
1403
+ return copyFile(srcStat, src, dest, opts);
1404
+ } else if (opts.errorOnExist) {
1405
+ throw new Error(`'${dest}' already exists`);
1406
+ }
1407
+ }
1408
+ function copyFile(srcStat, src, dest, opts) {
1409
+ fs4.copyFileSync(src, dest);
1410
+ if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
1411
+ return setDestMode(dest, srcStat.mode);
1412
+ }
1413
+ function handleTimestamps(srcMode, src, dest) {
1414
+ if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
1415
+ return setDestTimestamps(src, dest);
1416
+ }
1417
+ function fileIsNotWritable(srcMode) {
1418
+ return (srcMode & 128) === 0;
1419
+ }
1420
+ function makeFileWritable(dest, srcMode) {
1421
+ return setDestMode(dest, srcMode | 128);
1422
+ }
1423
+ function setDestMode(dest, srcMode) {
1424
+ return fs4.chmodSync(dest, srcMode);
1425
+ }
1426
+ function setDestTimestamps(src, dest) {
1427
+ const updatedSrcStat = fs4.statSync(src);
1428
+ return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1429
+ }
1430
+ function onDir(srcStat, destStat, src, dest, opts) {
1431
+ if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts);
1432
+ return copyDir(src, dest, opts);
1433
+ }
1434
+ function mkDirAndCopy(srcMode, src, dest, opts) {
1435
+ fs4.mkdirSync(dest);
1436
+ copyDir(src, dest, opts);
1437
+ return setDestMode(dest, srcMode);
1438
+ }
1439
+ function copyDir(src, dest, opts) {
1440
+ const dir = fs4.opendirSync(src);
1441
+ try {
1442
+ let dirent;
1443
+ while ((dirent = dir.readSync()) !== null) {
1444
+ copyDirItem(dirent.name, src, dest, opts);
1445
+ }
1446
+ } finally {
1447
+ dir.closeSync();
1448
+ }
1449
+ }
1450
+ function copyDirItem(item, src, dest, opts) {
1451
+ const srcItem = path6.join(src, item);
1452
+ const destItem = path6.join(dest, item);
1453
+ if (opts.filter && !opts.filter(srcItem, destItem)) return;
1454
+ const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
1455
+ return getStats(destStat, srcItem, destItem, opts);
1456
+ }
1457
+ function onLink(destStat, src, dest, opts) {
1458
+ let resolvedSrc = fs4.readlinkSync(src);
1459
+ if (opts.dereference) {
1460
+ resolvedSrc = path6.resolve(process.cwd(), resolvedSrc);
1461
+ }
1462
+ if (!destStat) {
1463
+ return fs4.symlinkSync(resolvedSrc, dest);
1464
+ } else {
1465
+ let resolvedDest;
1466
+ try {
1467
+ resolvedDest = fs4.readlinkSync(dest);
1468
+ } catch (err) {
1469
+ if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs4.symlinkSync(resolvedSrc, dest);
1470
+ throw err;
1471
+ }
1472
+ if (opts.dereference) {
1473
+ resolvedDest = path6.resolve(process.cwd(), resolvedDest);
1474
+ }
1475
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1476
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
1477
+ }
1478
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1479
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
1480
+ }
1481
+ return copyLink(resolvedSrc, dest);
1482
+ }
1483
+ }
1484
+ function copyLink(resolvedSrc, dest) {
1485
+ fs4.unlinkSync(dest);
1486
+ return fs4.symlinkSync(resolvedSrc, dest);
1487
+ }
1488
+ module2.exports = copySync;
1489
+ }
1490
+ });
1491
+ var require_copy2 = (0, import_chunk_2ESYSVXG.__commonJS)({
1492
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/index.js"(exports, module2) {
1493
+ "use strict";
1494
+ var u = require_universalify().fromPromise;
1495
+ module2.exports = {
1496
+ copy: u(require_copy()),
1497
+ copySync: require_copy_sync()
1498
+ };
1499
+ }
1500
+ });
1501
+ var require_remove = (0, import_chunk_2ESYSVXG.__commonJS)({
1502
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/remove/index.js"(exports, module2) {
1503
+ "use strict";
1504
+ var fs4 = require_graceful_fs();
1505
+ var u = require_universalify().fromCallback;
1506
+ function remove(path6, callback) {
1507
+ fs4.rm(path6, { recursive: true, force: true }, callback);
1508
+ }
1509
+ function removeSync(path6) {
1510
+ fs4.rmSync(path6, { recursive: true, force: true });
1511
+ }
1512
+ module2.exports = {
1513
+ remove: u(remove),
1514
+ removeSync
1515
+ };
1516
+ }
1517
+ });
1518
+ var require_empty = (0, import_chunk_2ESYSVXG.__commonJS)({
1519
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/empty/index.js"(exports, module2) {
1520
+ "use strict";
1521
+ var u = require_universalify().fromPromise;
1522
+ var fs4 = require_fs();
1523
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1524
+ var mkdir = require_mkdirs();
1525
+ var remove = require_remove();
1526
+ var emptyDir = u(async function emptyDir2(dir) {
1527
+ let items;
1528
+ try {
1529
+ items = await fs4.readdir(dir);
1530
+ } catch {
1531
+ return mkdir.mkdirs(dir);
1532
+ }
1533
+ return Promise.all(items.map((item) => remove.remove(path6.join(dir, item))));
1534
+ });
1535
+ function emptyDirSync(dir) {
1536
+ let items;
1537
+ try {
1538
+ items = fs4.readdirSync(dir);
1539
+ } catch {
1540
+ return mkdir.mkdirsSync(dir);
1541
+ }
1542
+ items.forEach((item) => {
1543
+ item = path6.join(dir, item);
1544
+ remove.removeSync(item);
1545
+ });
1546
+ }
1547
+ module2.exports = {
1548
+ emptyDirSync,
1549
+ emptydirSync: emptyDirSync,
1550
+ emptyDir,
1551
+ emptydir: emptyDir
1552
+ };
1553
+ }
1554
+ });
1555
+ var require_file = (0, import_chunk_2ESYSVXG.__commonJS)({
1556
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/file.js"(exports, module2) {
1557
+ "use strict";
1558
+ var u = require_universalify().fromPromise;
1559
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1560
+ var fs4 = require_fs();
1561
+ var mkdir = require_mkdirs();
1562
+ async function createFile(file) {
1563
+ let stats;
1564
+ try {
1565
+ stats = await fs4.stat(file);
1566
+ } catch {
1567
+ }
1568
+ if (stats && stats.isFile()) return;
1569
+ const dir = path6.dirname(file);
1570
+ let dirStats = null;
1571
+ try {
1572
+ dirStats = await fs4.stat(dir);
1573
+ } catch (err) {
1574
+ if (err.code === "ENOENT") {
1575
+ await mkdir.mkdirs(dir);
1576
+ await fs4.writeFile(file, "");
1577
+ return;
1578
+ } else {
1579
+ throw err;
1580
+ }
1581
+ }
1582
+ if (dirStats.isDirectory()) {
1583
+ await fs4.writeFile(file, "");
1584
+ } else {
1585
+ await fs4.readdir(dir);
1586
+ }
1587
+ }
1588
+ function createFileSync(file) {
1589
+ let stats;
1590
+ try {
1591
+ stats = fs4.statSync(file);
1592
+ } catch {
1593
+ }
1594
+ if (stats && stats.isFile()) return;
1595
+ const dir = path6.dirname(file);
1596
+ try {
1597
+ if (!fs4.statSync(dir).isDirectory()) {
1598
+ fs4.readdirSync(dir);
1599
+ }
1600
+ } catch (err) {
1601
+ if (err && err.code === "ENOENT") mkdir.mkdirsSync(dir);
1602
+ else throw err;
1603
+ }
1604
+ fs4.writeFileSync(file, "");
1605
+ }
1606
+ module2.exports = {
1607
+ createFile: u(createFile),
1608
+ createFileSync
1609
+ };
1610
+ }
1611
+ });
1612
+ var require_link = (0, import_chunk_2ESYSVXG.__commonJS)({
1613
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/link.js"(exports, module2) {
1614
+ "use strict";
1615
+ var u = require_universalify().fromPromise;
1616
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1617
+ var fs4 = require_fs();
1618
+ var mkdir = require_mkdirs();
1619
+ var { pathExists: pathExists2 } = require_path_exists();
1620
+ var { areIdentical } = require_stat();
1621
+ async function createLink(srcpath, dstpath) {
1622
+ let dstStat;
1623
+ try {
1624
+ dstStat = await fs4.lstat(dstpath);
1625
+ } catch {
1626
+ }
1627
+ let srcStat;
1628
+ try {
1629
+ srcStat = await fs4.lstat(srcpath);
1630
+ } catch (err) {
1631
+ err.message = err.message.replace("lstat", "ensureLink");
1632
+ throw err;
1633
+ }
1634
+ if (dstStat && areIdentical(srcStat, dstStat)) return;
1635
+ const dir = path6.dirname(dstpath);
1636
+ const dirExists = await pathExists2(dir);
1637
+ if (!dirExists) {
1638
+ await mkdir.mkdirs(dir);
1639
+ }
1640
+ await fs4.link(srcpath, dstpath);
1641
+ }
1642
+ function createLinkSync(srcpath, dstpath) {
1643
+ let dstStat;
1644
+ try {
1645
+ dstStat = fs4.lstatSync(dstpath);
1646
+ } catch {
1647
+ }
1648
+ try {
1649
+ const srcStat = fs4.lstatSync(srcpath);
1650
+ if (dstStat && areIdentical(srcStat, dstStat)) return;
1651
+ } catch (err) {
1652
+ err.message = err.message.replace("lstat", "ensureLink");
1653
+ throw err;
1654
+ }
1655
+ const dir = path6.dirname(dstpath);
1656
+ const dirExists = fs4.existsSync(dir);
1657
+ if (dirExists) return fs4.linkSync(srcpath, dstpath);
1658
+ mkdir.mkdirsSync(dir);
1659
+ return fs4.linkSync(srcpath, dstpath);
1660
+ }
1661
+ module2.exports = {
1662
+ createLink: u(createLink),
1663
+ createLinkSync
1664
+ };
1665
+ }
1666
+ });
1667
+ var require_symlink_paths = (0, import_chunk_2ESYSVXG.__commonJS)({
1668
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports, module2) {
1669
+ "use strict";
1670
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1671
+ var fs4 = require_fs();
1672
+ var { pathExists: pathExists2 } = require_path_exists();
1673
+ var u = require_universalify().fromPromise;
1674
+ async function symlinkPaths(srcpath, dstpath) {
1675
+ if (path6.isAbsolute(srcpath)) {
1676
+ try {
1677
+ await fs4.lstat(srcpath);
1678
+ } catch (err) {
1679
+ err.message = err.message.replace("lstat", "ensureSymlink");
1680
+ throw err;
1681
+ }
1682
+ return {
1683
+ toCwd: srcpath,
1684
+ toDst: srcpath
1685
+ };
1686
+ }
1687
+ const dstdir = path6.dirname(dstpath);
1688
+ const relativeToDst = path6.join(dstdir, srcpath);
1689
+ const exists = await pathExists2(relativeToDst);
1690
+ if (exists) {
1691
+ return {
1692
+ toCwd: relativeToDst,
1693
+ toDst: srcpath
1694
+ };
1695
+ }
1696
+ try {
1697
+ await fs4.lstat(srcpath);
1698
+ } catch (err) {
1699
+ err.message = err.message.replace("lstat", "ensureSymlink");
1700
+ throw err;
1701
+ }
1702
+ return {
1703
+ toCwd: srcpath,
1704
+ toDst: path6.relative(dstdir, srcpath)
1705
+ };
1706
+ }
1707
+ function symlinkPathsSync(srcpath, dstpath) {
1708
+ if (path6.isAbsolute(srcpath)) {
1709
+ const exists2 = fs4.existsSync(srcpath);
1710
+ if (!exists2) throw new Error("absolute srcpath does not exist");
1711
+ return {
1712
+ toCwd: srcpath,
1713
+ toDst: srcpath
1714
+ };
1715
+ }
1716
+ const dstdir = path6.dirname(dstpath);
1717
+ const relativeToDst = path6.join(dstdir, srcpath);
1718
+ const exists = fs4.existsSync(relativeToDst);
1719
+ if (exists) {
1720
+ return {
1721
+ toCwd: relativeToDst,
1722
+ toDst: srcpath
1723
+ };
1724
+ }
1725
+ const srcExists = fs4.existsSync(srcpath);
1726
+ if (!srcExists) throw new Error("relative srcpath does not exist");
1727
+ return {
1728
+ toCwd: srcpath,
1729
+ toDst: path6.relative(dstdir, srcpath)
1730
+ };
1731
+ }
1732
+ module2.exports = {
1733
+ symlinkPaths: u(symlinkPaths),
1734
+ symlinkPathsSync
1735
+ };
1736
+ }
1737
+ });
1738
+ var require_symlink_type = (0, import_chunk_2ESYSVXG.__commonJS)({
1739
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink-type.js"(exports, module2) {
1740
+ "use strict";
1741
+ var fs4 = require_fs();
1742
+ var u = require_universalify().fromPromise;
1743
+ async function symlinkType(srcpath, type) {
1744
+ if (type) return type;
1745
+ let stats;
1746
+ try {
1747
+ stats = await fs4.lstat(srcpath);
1748
+ } catch {
1749
+ return "file";
1750
+ }
1751
+ return stats && stats.isDirectory() ? "dir" : "file";
1752
+ }
1753
+ function symlinkTypeSync(srcpath, type) {
1754
+ if (type) return type;
1755
+ let stats;
1756
+ try {
1757
+ stats = fs4.lstatSync(srcpath);
1758
+ } catch {
1759
+ return "file";
1760
+ }
1761
+ return stats && stats.isDirectory() ? "dir" : "file";
1762
+ }
1763
+ module2.exports = {
1764
+ symlinkType: u(symlinkType),
1765
+ symlinkTypeSync
1766
+ };
1767
+ }
1768
+ });
1769
+ var require_symlink = (0, import_chunk_2ESYSVXG.__commonJS)({
1770
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink.js"(exports, module2) {
1771
+ "use strict";
1772
+ var u = require_universalify().fromPromise;
1773
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1774
+ var fs4 = require_fs();
1775
+ var { mkdirs, mkdirsSync } = require_mkdirs();
1776
+ var { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
1777
+ var { symlinkType, symlinkTypeSync } = require_symlink_type();
1778
+ var { pathExists: pathExists2 } = require_path_exists();
1779
+ var { areIdentical } = require_stat();
1780
+ async function createSymlink(srcpath, dstpath, type) {
1781
+ let stats;
1782
+ try {
1783
+ stats = await fs4.lstat(dstpath);
1784
+ } catch {
1785
+ }
1786
+ if (stats && stats.isSymbolicLink()) {
1787
+ const [srcStat, dstStat] = await Promise.all([
1788
+ fs4.stat(srcpath),
1789
+ fs4.stat(dstpath)
1790
+ ]);
1791
+ if (areIdentical(srcStat, dstStat)) return;
1792
+ }
1793
+ const relative = await symlinkPaths(srcpath, dstpath);
1794
+ srcpath = relative.toDst;
1795
+ const toType = await symlinkType(relative.toCwd, type);
1796
+ const dir = path6.dirname(dstpath);
1797
+ if (!await pathExists2(dir)) {
1798
+ await mkdirs(dir);
1799
+ }
1800
+ return fs4.symlink(srcpath, dstpath, toType);
1801
+ }
1802
+ function createSymlinkSync(srcpath, dstpath, type) {
1803
+ let stats;
1804
+ try {
1805
+ stats = fs4.lstatSync(dstpath);
1806
+ } catch {
1807
+ }
1808
+ if (stats && stats.isSymbolicLink()) {
1809
+ const srcStat = fs4.statSync(srcpath);
1810
+ const dstStat = fs4.statSync(dstpath);
1811
+ if (areIdentical(srcStat, dstStat)) return;
1812
+ }
1813
+ const relative = symlinkPathsSync(srcpath, dstpath);
1814
+ srcpath = relative.toDst;
1815
+ type = symlinkTypeSync(relative.toCwd, type);
1816
+ const dir = path6.dirname(dstpath);
1817
+ const exists = fs4.existsSync(dir);
1818
+ if (exists) return fs4.symlinkSync(srcpath, dstpath, type);
1819
+ mkdirsSync(dir);
1820
+ return fs4.symlinkSync(srcpath, dstpath, type);
1821
+ }
1822
+ module2.exports = {
1823
+ createSymlink: u(createSymlink),
1824
+ createSymlinkSync
1825
+ };
1826
+ }
1827
+ });
1828
+ var require_ensure = (0, import_chunk_2ESYSVXG.__commonJS)({
1829
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/index.js"(exports, module2) {
1830
+ "use strict";
1831
+ var { createFile, createFileSync } = require_file();
1832
+ var { createLink, createLinkSync } = require_link();
1833
+ var { createSymlink, createSymlinkSync } = require_symlink();
1834
+ module2.exports = {
1835
+ // file
1836
+ createFile,
1837
+ createFileSync,
1838
+ ensureFile: createFile,
1839
+ ensureFileSync: createFileSync,
1840
+ // link
1841
+ createLink,
1842
+ createLinkSync,
1843
+ ensureLink: createLink,
1844
+ ensureLinkSync: createLinkSync,
1845
+ // symlink
1846
+ createSymlink,
1847
+ createSymlinkSync,
1848
+ ensureSymlink: createSymlink,
1849
+ ensureSymlinkSync: createSymlinkSync
1850
+ };
1851
+ }
1852
+ });
1853
+ var require_utils2 = (0, import_chunk_2ESYSVXG.__commonJS)({
1854
+ "../../node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/utils.js"(exports, module2) {
1855
+ "use strict";
1856
+ function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
1857
+ const EOF = finalEOL ? EOL : "";
1858
+ const str = JSON.stringify(obj, replacer, spaces);
1859
+ return str.replace(/\n/g, EOL) + EOF;
1860
+ }
1861
+ function stripBom(content) {
1862
+ if (Buffer.isBuffer(content)) content = content.toString("utf8");
1863
+ return content.replace(/^\uFEFF/, "");
1864
+ }
1865
+ module2.exports = { stringify, stripBom };
1866
+ }
1867
+ });
1868
+ var require_jsonfile = (0, import_chunk_2ESYSVXG.__commonJS)({
1869
+ "../../node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/index.js"(exports, module2) {
1870
+ "use strict";
1871
+ var _fs;
1872
+ try {
1873
+ _fs = require_graceful_fs();
1874
+ } catch (_) {
1875
+ _fs = (0, import_chunk_2ESYSVXG.__require)("fs");
1876
+ }
1877
+ var universalify = require_universalify();
1878
+ var { stringify, stripBom } = require_utils2();
1879
+ async function _readFile(file, options = {}) {
1880
+ if (typeof options === "string") {
1881
+ options = { encoding: options };
1882
+ }
1883
+ const fs4 = options.fs || _fs;
1884
+ const shouldThrow = "throws" in options ? options.throws : true;
1885
+ let data = await universalify.fromCallback(fs4.readFile)(file, options);
1886
+ data = stripBom(data);
1887
+ let obj;
1888
+ try {
1889
+ obj = JSON.parse(data, options ? options.reviver : null);
1890
+ } catch (err) {
1891
+ if (shouldThrow) {
1892
+ err.message = `${file}: ${err.message}`;
1893
+ throw err;
1894
+ } else {
1895
+ return null;
1896
+ }
1897
+ }
1898
+ return obj;
1899
+ }
1900
+ var readFile = universalify.fromPromise(_readFile);
1901
+ function readFileSync(file, options = {}) {
1902
+ if (typeof options === "string") {
1903
+ options = { encoding: options };
1904
+ }
1905
+ const fs4 = options.fs || _fs;
1906
+ const shouldThrow = "throws" in options ? options.throws : true;
1907
+ try {
1908
+ let content = fs4.readFileSync(file, options);
1909
+ content = stripBom(content);
1910
+ return JSON.parse(content, options.reviver);
1911
+ } catch (err) {
1912
+ if (shouldThrow) {
1913
+ err.message = `${file}: ${err.message}`;
1914
+ throw err;
1915
+ } else {
1916
+ return null;
1917
+ }
1918
+ }
1919
+ }
1920
+ async function _writeFile(file, obj, options = {}) {
1921
+ const fs4 = options.fs || _fs;
1922
+ const str = stringify(obj, options);
1923
+ await universalify.fromCallback(fs4.writeFile)(file, str, options);
1924
+ }
1925
+ var writeFile = universalify.fromPromise(_writeFile);
1926
+ function writeFileSync(file, obj, options = {}) {
1927
+ const fs4 = options.fs || _fs;
1928
+ const str = stringify(obj, options);
1929
+ return fs4.writeFileSync(file, str, options);
1930
+ }
1931
+ module2.exports = {
1932
+ readFile,
1933
+ readFileSync,
1934
+ writeFile,
1935
+ writeFileSync
1936
+ };
1937
+ }
1938
+ });
1939
+ var require_jsonfile2 = (0, import_chunk_2ESYSVXG.__commonJS)({
1940
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/jsonfile.js"(exports, module2) {
1941
+ "use strict";
1942
+ var jsonFile = require_jsonfile();
1943
+ module2.exports = {
1944
+ // jsonfile exports
1945
+ readJson: jsonFile.readFile,
1946
+ readJsonSync: jsonFile.readFileSync,
1947
+ writeJson: jsonFile.writeFile,
1948
+ writeJsonSync: jsonFile.writeFileSync
1949
+ };
1950
+ }
1951
+ });
1952
+ var require_output_file = (0, import_chunk_2ESYSVXG.__commonJS)({
1953
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/output-file/index.js"(exports, module2) {
1954
+ "use strict";
1955
+ var u = require_universalify().fromPromise;
1956
+ var fs4 = require_fs();
1957
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
1958
+ var mkdir = require_mkdirs();
1959
+ var pathExists2 = require_path_exists().pathExists;
1960
+ async function outputFile(file, data, encoding = "utf-8") {
1961
+ const dir = path6.dirname(file);
1962
+ if (!await pathExists2(dir)) {
1963
+ await mkdir.mkdirs(dir);
1964
+ }
1965
+ return fs4.writeFile(file, data, encoding);
1966
+ }
1967
+ function outputFileSync(file, ...args) {
1968
+ const dir = path6.dirname(file);
1969
+ if (!fs4.existsSync(dir)) {
1970
+ mkdir.mkdirsSync(dir);
1971
+ }
1972
+ fs4.writeFileSync(file, ...args);
1973
+ }
1974
+ module2.exports = {
1975
+ outputFile: u(outputFile),
1976
+ outputFileSync
1977
+ };
1978
+ }
1979
+ });
1980
+ var require_output_json = (0, import_chunk_2ESYSVXG.__commonJS)({
1981
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/output-json.js"(exports, module2) {
1982
+ "use strict";
1983
+ var { stringify } = require_utils2();
1984
+ var { outputFile } = require_output_file();
1985
+ async function outputJson(file, data, options = {}) {
1986
+ const str = stringify(data, options);
1987
+ await outputFile(file, str, options);
1988
+ }
1989
+ module2.exports = outputJson;
1990
+ }
1991
+ });
1992
+ var require_output_json_sync = (0, import_chunk_2ESYSVXG.__commonJS)({
1993
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/output-json-sync.js"(exports, module2) {
1994
+ "use strict";
1995
+ var { stringify } = require_utils2();
1996
+ var { outputFileSync } = require_output_file();
1997
+ function outputJsonSync(file, data, options) {
1998
+ const str = stringify(data, options);
1999
+ outputFileSync(file, str, options);
2000
+ }
2001
+ module2.exports = outputJsonSync;
2002
+ }
2003
+ });
2004
+ var require_json = (0, import_chunk_2ESYSVXG.__commonJS)({
2005
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/index.js"(exports, module2) {
2006
+ "use strict";
2007
+ var u = require_universalify().fromPromise;
2008
+ var jsonFile = require_jsonfile2();
2009
+ jsonFile.outputJson = u(require_output_json());
2010
+ jsonFile.outputJsonSync = require_output_json_sync();
2011
+ jsonFile.outputJSON = jsonFile.outputJson;
2012
+ jsonFile.outputJSONSync = jsonFile.outputJsonSync;
2013
+ jsonFile.writeJSON = jsonFile.writeJson;
2014
+ jsonFile.writeJSONSync = jsonFile.writeJsonSync;
2015
+ jsonFile.readJSON = jsonFile.readJson;
2016
+ jsonFile.readJSONSync = jsonFile.readJsonSync;
2017
+ module2.exports = jsonFile;
2018
+ }
2019
+ });
2020
+ var require_move = (0, import_chunk_2ESYSVXG.__commonJS)({
2021
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/move.js"(exports, module2) {
2022
+ "use strict";
2023
+ var fs4 = require_fs();
2024
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
2025
+ var { copy } = require_copy2();
2026
+ var { remove } = require_remove();
2027
+ var { mkdirp } = require_mkdirs();
2028
+ var { pathExists: pathExists2 } = require_path_exists();
2029
+ var stat = require_stat();
2030
+ async function move(src, dest, opts = {}) {
2031
+ const overwrite = opts.overwrite || opts.clobber || false;
2032
+ const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, "move", opts);
2033
+ await stat.checkParentPaths(src, srcStat, dest, "move");
2034
+ const destParent = path6.dirname(dest);
2035
+ const parsedParentPath = path6.parse(destParent);
2036
+ if (parsedParentPath.root !== destParent) {
2037
+ await mkdirp(destParent);
2038
+ }
2039
+ return doRename(src, dest, overwrite, isChangingCase);
2040
+ }
2041
+ async function doRename(src, dest, overwrite, isChangingCase) {
2042
+ if (!isChangingCase) {
2043
+ if (overwrite) {
2044
+ await remove(dest);
2045
+ } else if (await pathExists2(dest)) {
2046
+ throw new Error("dest already exists.");
2047
+ }
2048
+ }
2049
+ try {
2050
+ await fs4.rename(src, dest);
2051
+ } catch (err) {
2052
+ if (err.code !== "EXDEV") {
2053
+ throw err;
2054
+ }
2055
+ await moveAcrossDevice(src, dest, overwrite);
2056
+ }
2057
+ }
2058
+ async function moveAcrossDevice(src, dest, overwrite) {
2059
+ const opts = {
2060
+ overwrite,
2061
+ errorOnExist: true,
2062
+ preserveTimestamps: true
2063
+ };
2064
+ await copy(src, dest, opts);
2065
+ return remove(src);
2066
+ }
2067
+ module2.exports = move;
2068
+ }
2069
+ });
2070
+ var require_move_sync = (0, import_chunk_2ESYSVXG.__commonJS)({
2071
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/move-sync.js"(exports, module2) {
2072
+ "use strict";
2073
+ var fs4 = require_graceful_fs();
2074
+ var path6 = (0, import_chunk_2ESYSVXG.__require)("path");
2075
+ var copySync = require_copy2().copySync;
2076
+ var removeSync = require_remove().removeSync;
2077
+ var mkdirpSync = require_mkdirs().mkdirpSync;
2078
+ var stat = require_stat();
2079
+ function moveSync(src, dest, opts) {
2080
+ opts = opts || {};
2081
+ const overwrite = opts.overwrite || opts.clobber || false;
2082
+ const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
2083
+ stat.checkParentPathsSync(src, srcStat, dest, "move");
2084
+ if (!isParentRoot(dest)) mkdirpSync(path6.dirname(dest));
2085
+ return doRename(src, dest, overwrite, isChangingCase);
2086
+ }
2087
+ function isParentRoot(dest) {
2088
+ const parent = path6.dirname(dest);
2089
+ const parsedPath = path6.parse(parent);
2090
+ return parsedPath.root === parent;
2091
+ }
2092
+ function doRename(src, dest, overwrite, isChangingCase) {
2093
+ if (isChangingCase) return rename(src, dest, overwrite);
2094
+ if (overwrite) {
2095
+ removeSync(dest);
2096
+ return rename(src, dest, overwrite);
2097
+ }
2098
+ if (fs4.existsSync(dest)) throw new Error("dest already exists.");
2099
+ return rename(src, dest, overwrite);
2100
+ }
2101
+ function rename(src, dest, overwrite) {
2102
+ try {
2103
+ fs4.renameSync(src, dest);
2104
+ } catch (err) {
2105
+ if (err.code !== "EXDEV") throw err;
2106
+ return moveAcrossDevice(src, dest, overwrite);
2107
+ }
2108
+ }
2109
+ function moveAcrossDevice(src, dest, overwrite) {
2110
+ const opts = {
2111
+ overwrite,
2112
+ errorOnExist: true,
2113
+ preserveTimestamps: true
2114
+ };
2115
+ copySync(src, dest, opts);
2116
+ return removeSync(src);
2117
+ }
2118
+ module2.exports = moveSync;
2119
+ }
2120
+ });
2121
+ var require_move2 = (0, import_chunk_2ESYSVXG.__commonJS)({
2122
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/index.js"(exports, module2) {
2123
+ "use strict";
2124
+ var u = require_universalify().fromPromise;
2125
+ module2.exports = {
2126
+ move: u(require_move()),
2127
+ moveSync: require_move_sync()
2128
+ };
2129
+ }
2130
+ });
2131
+ var require_lib = (0, import_chunk_2ESYSVXG.__commonJS)({
2132
+ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/index.js"(exports, module2) {
2133
+ "use strict";
2134
+ module2.exports = {
2135
+ // Export promiseified graceful-fs:
2136
+ ...require_fs(),
2137
+ // Export extra methods:
2138
+ ...require_copy2(),
2139
+ ...require_empty(),
2140
+ ...require_ensure(),
2141
+ ...require_json(),
2142
+ ...require_mkdirs(),
2143
+ ...require_move2(),
2144
+ ...require_output_file(),
2145
+ ...require_path_exists(),
2146
+ ...require_remove()
2147
+ };
2148
+ }
2149
+ });
2150
+ var import_common_path_prefix = (0, import_chunk_2ESYSVXG.__toESM)(require_common_path_prefix(), 1);
2151
+ var typeMappings = {
2152
+ directory: "isDirectory",
2153
+ file: "isFile"
2154
+ };
2155
+ function checkType(type) {
2156
+ if (Object.hasOwnProperty.call(typeMappings, type)) {
2157
+ return;
2158
+ }
2159
+ throw new Error(`Invalid type specified: ${type}`);
2160
+ }
2161
+ var matchType = (type, stat) => stat[typeMappings[type]]();
2162
+ var toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url2.fileURLToPath)(urlOrPath) : urlOrPath;
2163
+ function locatePathSync(paths, {
2164
+ cwd: cwd2 = import_node_process2.default.cwd(),
2165
+ type = "file",
2166
+ allowSymlinks = true
2167
+ } = {}) {
2168
+ checkType(type);
2169
+ cwd2 = toPath(cwd2);
2170
+ const statFunction = allowSymlinks ? import_node_fs3.default.statSync : import_node_fs3.default.lstatSync;
2171
+ for (const path_ of paths) {
2172
+ try {
2173
+ const stat = statFunction(import_node_path5.default.resolve(cwd2, path_), {
2174
+ throwIfNoEntry: false
2175
+ });
2176
+ if (!stat) {
2177
+ continue;
2178
+ }
2179
+ if (matchType(type, stat)) {
2180
+ return path_;
2181
+ }
2182
+ } catch {
2183
+ }
2184
+ }
2185
+ }
2186
+ var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
2187
+ var findUpStop = Symbol("findUpStop");
2188
+ function findUpMultipleSync(name, options = {}) {
2189
+ let directory = import_node_path4.default.resolve(toPath2(options.cwd) || "");
2190
+ const { root } = import_node_path4.default.parse(directory);
2191
+ const stopAt = options.stopAt || root;
2192
+ const limit = options.limit || Number.POSITIVE_INFINITY;
2193
+ const paths = [name].flat();
2194
+ const runMatcher = (locateOptions) => {
2195
+ if (typeof name !== "function") {
2196
+ return locatePathSync(paths, locateOptions);
2197
+ }
2198
+ const foundPath = name(locateOptions.cwd);
2199
+ if (typeof foundPath === "string") {
2200
+ return locatePathSync([foundPath], locateOptions);
2201
+ }
2202
+ return foundPath;
2203
+ };
2204
+ const matches = [];
2205
+ while (true) {
2206
+ const foundPath = runMatcher({ ...options, cwd: directory });
2207
+ if (foundPath === findUpStop) {
2208
+ break;
2209
+ }
2210
+ if (foundPath) {
2211
+ matches.push(import_node_path4.default.resolve(directory, foundPath));
2212
+ }
2213
+ if (directory === stopAt || matches.length >= limit) {
2214
+ break;
2215
+ }
2216
+ directory = import_node_path4.default.dirname(directory);
2217
+ }
2218
+ return matches;
2219
+ }
2220
+ function findUpSync(name, options = {}) {
2221
+ const matches = findUpMultipleSync(name, { ...options, limit: 1 });
2222
+ return matches[0];
2223
+ }
2224
+ function packageDirectorySync({ cwd: cwd2 } = {}) {
2225
+ const filePath = findUpSync("package.json", { cwd: cwd2 });
2226
+ return filePath && import_node_path3.default.dirname(filePath);
2227
+ }
2228
+ var { env, cwd } = import_node_process.default;
2229
+ var isWritable = (path6) => {
2230
+ try {
2231
+ import_node_fs2.default.accessSync(path6, import_node_fs2.default.constants.W_OK);
2232
+ return true;
2233
+ } catch {
2234
+ return false;
2235
+ }
2236
+ };
2237
+ function useDirectory(directory, options) {
2238
+ if (options.create) {
2239
+ import_node_fs2.default.mkdirSync(directory, { recursive: true });
2240
+ }
2241
+ return directory;
2242
+ }
2243
+ function getNodeModuleDirectory(directory) {
2244
+ const nodeModules = import_node_path2.default.join(directory, "node_modules");
2245
+ if (!isWritable(nodeModules) && (import_node_fs2.default.existsSync(nodeModules) || !isWritable(import_node_path2.default.join(directory)))) {
2246
+ return;
2247
+ }
2248
+ return nodeModules;
2249
+ }
2250
+ function findCacheDirectory(options = {}) {
2251
+ if (env.CACHE_DIR && !["true", "false", "1", "0"].includes(env.CACHE_DIR)) {
2252
+ return useDirectory(import_node_path2.default.join(env.CACHE_DIR, options.name), options);
2253
+ }
2254
+ let { cwd: directory = cwd(), files } = options;
2255
+ if (files) {
2256
+ if (!Array.isArray(files)) {
2257
+ throw new TypeError(`Expected \`files\` option to be an array, got \`${typeof files}\`.`);
2258
+ }
2259
+ directory = (0, import_common_path_prefix.default)(files.map((file) => import_node_path2.default.resolve(directory, file)));
2260
+ }
2261
+ directory = packageDirectorySync({ cwd: directory });
2262
+ if (!directory) {
2263
+ return;
2264
+ }
2265
+ const nodeModules = getNodeModuleDirectory(directory);
2266
+ if (!nodeModules) {
2267
+ return;
2268
+ }
2269
+ return useDirectory(import_node_path2.default.join(directory, "node_modules", ".cache", options.name), options);
2270
+ }
2271
+ var import_fs_extra = (0, import_chunk_2ESYSVXG.__toESM)(require_lib());
2272
+ var debug = (0, import_debug.default)("prisma:fetch-engine:cache-dir");
2273
+ async function getRootCacheDir() {
2274
+ if (import_node_os.default.platform() === "win32") {
2275
+ const cacheDir = findCacheDirectory({ name: "prisma", create: true });
2276
+ if (cacheDir) {
2277
+ return cacheDir;
2278
+ }
2279
+ if (process.env.APPDATA) {
2280
+ return import_node_path.default.join(process.env.APPDATA, "Prisma");
2281
+ }
2282
+ }
2283
+ if (process.env.AWS_LAMBDA_FUNCTION_VERSION) {
2284
+ try {
2285
+ await (0, import_fs_extra.ensureDir)(`/tmp/prisma-download`);
2286
+ return `/tmp/prisma-download`;
2287
+ } catch (e) {
2288
+ return null;
2289
+ }
2290
+ }
2291
+ return process.env.XDG_CACHE_HOME ? import_node_path.default.join(process.env.XDG_CACHE_HOME, "prisma") : import_node_path.default.join(import_node_os.default.homedir(), ".cache/prisma");
2292
+ }
2293
+ async function getCacheDir(channel, version, binaryTarget) {
2294
+ const rootCacheDir = await getRootCacheDir();
2295
+ if (!rootCacheDir) {
2296
+ return null;
2297
+ }
2298
+ const cacheDir = import_node_path.default.join(rootCacheDir, channel, version, binaryTarget);
2299
+ try {
2300
+ if (!import_node_fs.default.existsSync(cacheDir)) {
2301
+ await (0, import_fs_extra.ensureDir)(cacheDir);
2302
+ }
2303
+ } catch (e) {
2304
+ debug("The following error is being caught and just there for debugging:");
2305
+ debug(e);
2306
+ return null;
2307
+ }
2308
+ return cacheDir;
2309
+ }
2310
+ function getDownloadUrl({
2311
+ channel,
2312
+ version,
2313
+ binaryTarget,
2314
+ binaryName,
2315
+ extension = ".gz"
2316
+ }) {
2317
+ const baseUrl = process.env.PRISMA_BINARIES_MIRROR || // TODO: remove this
2318
+ process.env.PRISMA_ENGINES_MIRROR || "https://binaries.prisma.sh";
2319
+ const finalExtension = binaryTarget === "windows" ? `.exe${extension}` : extension;
2320
+ return `${baseUrl}/${channel}/${version}/${binaryTarget}/${binaryName}${finalExtension}`;
2321
+ }
2322
+ async function overwriteFile(sourcePath, targetPath) {
2323
+ if (import_node_os.default.platform() === "darwin") {
2324
+ await removeFileIfExists(targetPath);
2325
+ await import_node_fs.default.promises.copyFile(sourcePath, targetPath);
2326
+ } else {
2327
+ const tempPath = `${targetPath}.tmp${process.pid}`;
2328
+ await import_node_fs.default.promises.copyFile(sourcePath, tempPath);
2329
+ await import_node_fs.default.promises.rename(tempPath, targetPath);
2330
+ }
2331
+ }
2332
+ async function removeFileIfExists(filePath) {
2333
+ try {
2334
+ await import_node_fs.default.promises.unlink(filePath);
2335
+ } catch (e) {
2336
+ if (e.code !== "ENOENT") {
2337
+ throw e;
2338
+ }
2339
+ }
2340
+ }