@stacksjs/buddy 0.59.11 → 0.61.1

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