weapp-tailwindcss 3.5.2 → 3.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/bundlers/gulp/index.d.ts +1 -1
  2. package/dist/cache/index.d.ts +1 -1
  3. package/dist/cli.js +3360 -5
  4. package/dist/cli.mjs +3357 -9
  5. package/dist/core.js +2 -2
  6. package/dist/core.mjs +2 -2
  7. package/dist/{defaults-CWrYZAlE.mjs → defaults-5A8JI2hW.mjs} +1 -1
  8. package/dist/{defaults-Bo5n6a1r.js → defaults-CdqzSWsR.js} +1 -1
  9. package/dist/defaults.js +1 -1
  10. package/dist/defaults.mjs +1 -1
  11. package/dist/gulp.js +3 -3
  12. package/dist/gulp.mjs +3 -3
  13. package/dist/{index-CMRC3rPR.mjs → index-BOz3IEuV.mjs} +1 -1
  14. package/dist/{index-DnKMgPUl.mjs → index-BfmTmdHm.mjs} +2 -2
  15. package/dist/{index-D_Im3H17.js → index-DIZlWN56.js} +2 -2
  16. package/dist/{index-DzdjmBcg.js → index-Dbbfs_Dv.js} +1 -1
  17. package/dist/index.js +5 -5
  18. package/dist/index.mjs +5 -5
  19. package/dist/init.d.ts +34 -0
  20. package/dist/logger.d.ts +1 -0
  21. package/dist/npm.d.ts +22 -0
  22. package/dist/{options-B9PPOdJv.mjs → options-BDij5-AP.mjs} +1 -1
  23. package/dist/{options-DgkOONy_.js → options-DslwksAa.js} +1 -1
  24. package/dist/postcss/index.d.ts +1 -1
  25. package/dist/postcss/mp.d.ts +1 -1
  26. package/dist/postcss/selectorParser.d.ts +1 -1
  27. package/dist/tailwindcss/patcher.d.ts +1 -1
  28. package/dist/{v5-c6m3PupX.mjs → v5-D7B3M2-H.mjs} +2 -2
  29. package/dist/{v5-CqteGjOW.js → v5-axtiXCio.js} +2 -2
  30. package/dist/vite.js +3 -3
  31. package/dist/vite.mjs +3 -3
  32. package/dist/webpack.js +3 -3
  33. package/dist/webpack.mjs +3 -3
  34. package/dist/webpack4.js +2 -2
  35. package/dist/webpack4.mjs +2 -2
  36. package/dist/wxml/utils.d.ts +1 -1
  37. package/package.json +5 -3
package/dist/cli.js CHANGED
@@ -1,9 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var process = require('node:process');
3
+ var process$1 = require('node:process');
4
4
  var semver = require('semver');
5
5
  var index = require('./index-B2LUAr--.js');
6
- var options = require('./options-DgkOONy_.js');
6
+ var options = require('./options-DslwksAa.js');
7
+ var require$$0$2 = require('fs');
8
+ var require$$0 = require('constants');
9
+ var require$$0$1 = require('stream');
10
+ var require$$4 = require('util');
11
+ var require$$5 = require('assert');
12
+ var require$$1 = require('path');
13
+ var consola = require('consola');
14
+ var fetch = require('npm-registry-fetch');
15
+ var defu = require('./defu-Cdz2PomB.js');
7
16
  require('@csstools/postcss-is-pseudo-class');
8
17
  require('postcss-rem-to-responsive-pixel');
9
18
  require('postcss');
@@ -13,8 +22,7 @@ require('@ast-core/escape');
13
22
  require('@weapp-core/escape');
14
23
  require('lru-cache');
15
24
  require('md5');
16
- require('./defaults-Bo5n6a1r.js');
17
- require('./defu-Cdz2PomB.js');
25
+ require('./defaults-CdqzSWsR.js');
18
26
  require('magic-string');
19
27
  require('@babel/generator');
20
28
  require('@babel/traverse');
@@ -29,8 +37,3352 @@ require('htmlparser2');
29
37
 
30
38
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
31
39
 
32
- var process__default = /*#__PURE__*/_interopDefaultCompat(process);
40
+ var process__default = /*#__PURE__*/_interopDefaultCompat(process$1);
33
41
  var semver__default = /*#__PURE__*/_interopDefaultCompat(semver);
42
+ var require$$0__default$2 = /*#__PURE__*/_interopDefaultCompat(require$$0$2);
43
+ var require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
44
+ var require$$0__default$1 = /*#__PURE__*/_interopDefaultCompat(require$$0$1);
45
+ var require$$4__default = /*#__PURE__*/_interopDefaultCompat(require$$4);
46
+ var require$$5__default = /*#__PURE__*/_interopDefaultCompat(require$$5);
47
+ var require$$1__default = /*#__PURE__*/_interopDefaultCompat(require$$1);
48
+ var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
49
+
50
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
51
+
52
+ function getDefaultExportFromCjs (x) {
53
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
54
+ }
55
+
56
+ var fs$1 = {};
57
+
58
+ var universalify = {};
59
+
60
+ var hasRequiredUniversalify;
61
+
62
+ function requireUniversalify () {
63
+ if (hasRequiredUniversalify) return universalify;
64
+ hasRequiredUniversalify = 1;
65
+
66
+ universalify.fromCallback = function (fn) {
67
+ return Object.defineProperty(function (...args) {
68
+ if (typeof args[args.length - 1] === 'function') fn.apply(this, args);
69
+ else {
70
+ return new Promise((resolve, reject) => {
71
+ args.push((err, res) => (err != null) ? reject(err) : resolve(res));
72
+ fn.apply(this, args);
73
+ })
74
+ }
75
+ }, 'name', { value: fn.name })
76
+ };
77
+
78
+ universalify.fromPromise = function (fn) {
79
+ return Object.defineProperty(function (...args) {
80
+ const cb = args[args.length - 1];
81
+ if (typeof cb !== 'function') return fn.apply(this, args)
82
+ else {
83
+ args.pop();
84
+ fn.apply(this, args).then(r => cb(null, r), cb);
85
+ }
86
+ }, 'name', { value: fn.name })
87
+ };
88
+ return universalify;
89
+ }
90
+
91
+ var polyfills;
92
+ var hasRequiredPolyfills;
93
+
94
+ function requirePolyfills () {
95
+ if (hasRequiredPolyfills) return polyfills;
96
+ hasRequiredPolyfills = 1;
97
+ var constants = require$$0__default["default"];
98
+
99
+ var origCwd = process.cwd;
100
+ var cwd = null;
101
+
102
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
103
+
104
+ process.cwd = function() {
105
+ if (!cwd)
106
+ cwd = origCwd.call(process);
107
+ return cwd
108
+ };
109
+ try {
110
+ process.cwd();
111
+ } catch (er) {}
112
+
113
+ // This check is needed until node.js 12 is required
114
+ if (typeof process.chdir === 'function') {
115
+ var chdir = process.chdir;
116
+ process.chdir = function (d) {
117
+ cwd = null;
118
+ chdir.call(process, d);
119
+ };
120
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
121
+ }
122
+
123
+ polyfills = patch;
124
+
125
+ function patch (fs) {
126
+ // (re-)implement some things that are known busted or missing.
127
+
128
+ // lchmod, broken prior to 0.6.2
129
+ // back-port the fix here.
130
+ if (constants.hasOwnProperty('O_SYMLINK') &&
131
+ process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
132
+ patchLchmod(fs);
133
+ }
134
+
135
+ // lutimes implementation, or no-op
136
+ if (!fs.lutimes) {
137
+ patchLutimes(fs);
138
+ }
139
+
140
+ // https://github.com/isaacs/node-graceful-fs/issues/4
141
+ // Chown should not fail on einval or eperm if non-root.
142
+ // It should not fail on enosys ever, as this just indicates
143
+ // that a fs doesn't support the intended operation.
144
+
145
+ fs.chown = chownFix(fs.chown);
146
+ fs.fchown = chownFix(fs.fchown);
147
+ fs.lchown = chownFix(fs.lchown);
148
+
149
+ fs.chmod = chmodFix(fs.chmod);
150
+ fs.fchmod = chmodFix(fs.fchmod);
151
+ fs.lchmod = chmodFix(fs.lchmod);
152
+
153
+ fs.chownSync = chownFixSync(fs.chownSync);
154
+ fs.fchownSync = chownFixSync(fs.fchownSync);
155
+ fs.lchownSync = chownFixSync(fs.lchownSync);
156
+
157
+ fs.chmodSync = chmodFixSync(fs.chmodSync);
158
+ fs.fchmodSync = chmodFixSync(fs.fchmodSync);
159
+ fs.lchmodSync = chmodFixSync(fs.lchmodSync);
160
+
161
+ fs.stat = statFix(fs.stat);
162
+ fs.fstat = statFix(fs.fstat);
163
+ fs.lstat = statFix(fs.lstat);
164
+
165
+ fs.statSync = statFixSync(fs.statSync);
166
+ fs.fstatSync = statFixSync(fs.fstatSync);
167
+ fs.lstatSync = statFixSync(fs.lstatSync);
168
+
169
+ // if lchmod/lchown do not exist, then make them no-ops
170
+ if (fs.chmod && !fs.lchmod) {
171
+ fs.lchmod = function (path, mode, cb) {
172
+ if (cb) process.nextTick(cb);
173
+ };
174
+ fs.lchmodSync = function () {};
175
+ }
176
+ if (fs.chown && !fs.lchown) {
177
+ fs.lchown = function (path, uid, gid, cb) {
178
+ if (cb) process.nextTick(cb);
179
+ };
180
+ fs.lchownSync = function () {};
181
+ }
182
+
183
+ // on Windows, A/V software can lock the directory, causing this
184
+ // to fail with an EACCES or EPERM if the directory contains newly
185
+ // created files. Try again on failure, for up to 60 seconds.
186
+
187
+ // Set the timeout this long because some Windows Anti-Virus, such as Parity
188
+ // bit9, may lock files for up to a minute, causing npm package install
189
+ // failures. Also, take care to yield the scheduler. Windows scheduling gives
190
+ // CPU to a busy looping process, which can cause the program causing the lock
191
+ // contention to be starved of CPU by node, so the contention doesn't resolve.
192
+ if (platform === "win32") {
193
+ fs.rename = typeof fs.rename !== 'function' ? fs.rename
194
+ : (function (fs$rename) {
195
+ function rename (from, to, cb) {
196
+ var start = Date.now();
197
+ var backoff = 0;
198
+ fs$rename(from, to, function CB (er) {
199
+ if (er
200
+ && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY")
201
+ && Date.now() - start < 60000) {
202
+ setTimeout(function() {
203
+ fs.stat(to, function (stater, st) {
204
+ if (stater && stater.code === "ENOENT")
205
+ fs$rename(from, to, CB);
206
+ else
207
+ cb(er);
208
+ });
209
+ }, backoff);
210
+ if (backoff < 100)
211
+ backoff += 10;
212
+ return;
213
+ }
214
+ if (cb) cb(er);
215
+ });
216
+ }
217
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
218
+ return rename
219
+ })(fs.rename);
220
+ }
221
+
222
+ // if read() returns EAGAIN, then just try it again.
223
+ fs.read = typeof fs.read !== 'function' ? fs.read
224
+ : (function (fs$read) {
225
+ function read (fd, buffer, offset, length, position, callback_) {
226
+ var callback;
227
+ if (callback_ && typeof callback_ === 'function') {
228
+ var eagCounter = 0;
229
+ callback = function (er, _, __) {
230
+ if (er && er.code === 'EAGAIN' && eagCounter < 10) {
231
+ eagCounter ++;
232
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
233
+ }
234
+ callback_.apply(this, arguments);
235
+ };
236
+ }
237
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
238
+ }
239
+
240
+ // This ensures `util.promisify` works as it does for native `fs.read`.
241
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
242
+ return read
243
+ })(fs.read);
244
+
245
+ fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync
246
+ : (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
247
+ var eagCounter = 0;
248
+ while (true) {
249
+ try {
250
+ return fs$readSync.call(fs, fd, buffer, offset, length, position)
251
+ } catch (er) {
252
+ if (er.code === 'EAGAIN' && eagCounter < 10) {
253
+ eagCounter ++;
254
+ continue
255
+ }
256
+ throw er
257
+ }
258
+ }
259
+ }})(fs.readSync);
260
+
261
+ function patchLchmod (fs) {
262
+ fs.lchmod = function (path, mode, callback) {
263
+ fs.open( path
264
+ , constants.O_WRONLY | constants.O_SYMLINK
265
+ , mode
266
+ , function (err, fd) {
267
+ if (err) {
268
+ if (callback) callback(err);
269
+ return
270
+ }
271
+ // prefer to return the chmod error, if one occurs,
272
+ // but still try to close, and report closing errors if they occur.
273
+ fs.fchmod(fd, mode, function (err) {
274
+ fs.close(fd, function(err2) {
275
+ if (callback) callback(err || err2);
276
+ });
277
+ });
278
+ });
279
+ };
280
+
281
+ fs.lchmodSync = function (path, mode) {
282
+ var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
283
+
284
+ // prefer to return the chmod error, if one occurs,
285
+ // but still try to close, and report closing errors if they occur.
286
+ var threw = true;
287
+ var ret;
288
+ try {
289
+ ret = fs.fchmodSync(fd, mode);
290
+ threw = false;
291
+ } finally {
292
+ if (threw) {
293
+ try {
294
+ fs.closeSync(fd);
295
+ } catch (er) {}
296
+ } else {
297
+ fs.closeSync(fd);
298
+ }
299
+ }
300
+ return ret
301
+ };
302
+ }
303
+
304
+ function patchLutimes (fs) {
305
+ if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
306
+ fs.lutimes = function (path, at, mt, cb) {
307
+ fs.open(path, constants.O_SYMLINK, function (er, fd) {
308
+ if (er) {
309
+ if (cb) cb(er);
310
+ return
311
+ }
312
+ fs.futimes(fd, at, mt, function (er) {
313
+ fs.close(fd, function (er2) {
314
+ if (cb) cb(er || er2);
315
+ });
316
+ });
317
+ });
318
+ };
319
+
320
+ fs.lutimesSync = function (path, at, mt) {
321
+ var fd = fs.openSync(path, constants.O_SYMLINK);
322
+ var ret;
323
+ var threw = true;
324
+ try {
325
+ ret = fs.futimesSync(fd, at, mt);
326
+ threw = false;
327
+ } finally {
328
+ if (threw) {
329
+ try {
330
+ fs.closeSync(fd);
331
+ } catch (er) {}
332
+ } else {
333
+ fs.closeSync(fd);
334
+ }
335
+ }
336
+ return ret
337
+ };
338
+
339
+ } else if (fs.futimes) {
340
+ fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb); };
341
+ fs.lutimesSync = function () {};
342
+ }
343
+ }
344
+
345
+ function chmodFix (orig) {
346
+ if (!orig) return orig
347
+ return function (target, mode, cb) {
348
+ return orig.call(fs, target, mode, function (er) {
349
+ if (chownErOk(er)) er = null;
350
+ if (cb) cb.apply(this, arguments);
351
+ })
352
+ }
353
+ }
354
+
355
+ function chmodFixSync (orig) {
356
+ if (!orig) return orig
357
+ return function (target, mode) {
358
+ try {
359
+ return orig.call(fs, target, mode)
360
+ } catch (er) {
361
+ if (!chownErOk(er)) throw er
362
+ }
363
+ }
364
+ }
365
+
366
+
367
+ function chownFix (orig) {
368
+ if (!orig) return orig
369
+ return function (target, uid, gid, cb) {
370
+ return orig.call(fs, target, uid, gid, function (er) {
371
+ if (chownErOk(er)) er = null;
372
+ if (cb) cb.apply(this, arguments);
373
+ })
374
+ }
375
+ }
376
+
377
+ function chownFixSync (orig) {
378
+ if (!orig) return orig
379
+ return function (target, uid, gid) {
380
+ try {
381
+ return orig.call(fs, target, uid, gid)
382
+ } catch (er) {
383
+ if (!chownErOk(er)) throw er
384
+ }
385
+ }
386
+ }
387
+
388
+ function statFix (orig) {
389
+ if (!orig) return orig
390
+ // Older versions of Node erroneously returned signed integers for
391
+ // uid + gid.
392
+ return function (target, options, cb) {
393
+ if (typeof options === 'function') {
394
+ cb = options;
395
+ options = null;
396
+ }
397
+ function callback (er, stats) {
398
+ if (stats) {
399
+ if (stats.uid < 0) stats.uid += 0x100000000;
400
+ if (stats.gid < 0) stats.gid += 0x100000000;
401
+ }
402
+ if (cb) cb.apply(this, arguments);
403
+ }
404
+ return options ? orig.call(fs, target, options, callback)
405
+ : orig.call(fs, target, callback)
406
+ }
407
+ }
408
+
409
+ function statFixSync (orig) {
410
+ if (!orig) return orig
411
+ // Older versions of Node erroneously returned signed integers for
412
+ // uid + gid.
413
+ return function (target, options) {
414
+ var stats = options ? orig.call(fs, target, options)
415
+ : orig.call(fs, target);
416
+ if (stats) {
417
+ if (stats.uid < 0) stats.uid += 0x100000000;
418
+ if (stats.gid < 0) stats.gid += 0x100000000;
419
+ }
420
+ return stats;
421
+ }
422
+ }
423
+
424
+ // ENOSYS means that the fs doesn't support the op. Just ignore
425
+ // that, because it doesn't matter.
426
+ //
427
+ // if there's no getuid, or if getuid() is something other
428
+ // than 0, and the error is EINVAL or EPERM, then just ignore
429
+ // it.
430
+ //
431
+ // This specific case is a silent failure in cp, install, tar,
432
+ // and most other unix tools that manage permissions.
433
+ //
434
+ // When running as root, or if other types of errors are
435
+ // encountered, then it's strict.
436
+ function chownErOk (er) {
437
+ if (!er)
438
+ return true
439
+
440
+ if (er.code === "ENOSYS")
441
+ return true
442
+
443
+ var nonroot = !process.getuid || process.getuid() !== 0;
444
+ if (nonroot) {
445
+ if (er.code === "EINVAL" || er.code === "EPERM")
446
+ return true
447
+ }
448
+
449
+ return false
450
+ }
451
+ }
452
+ return polyfills;
453
+ }
454
+
455
+ var legacyStreams;
456
+ var hasRequiredLegacyStreams;
457
+
458
+ function requireLegacyStreams () {
459
+ if (hasRequiredLegacyStreams) return legacyStreams;
460
+ hasRequiredLegacyStreams = 1;
461
+ var Stream = require$$0__default$1["default"].Stream;
462
+
463
+ legacyStreams = legacy;
464
+
465
+ function legacy (fs) {
466
+ return {
467
+ ReadStream: ReadStream,
468
+ WriteStream: WriteStream
469
+ }
470
+
471
+ function ReadStream (path, options) {
472
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
473
+
474
+ Stream.call(this);
475
+
476
+ var self = this;
477
+
478
+ this.path = path;
479
+ this.fd = null;
480
+ this.readable = true;
481
+ this.paused = false;
482
+
483
+ this.flags = 'r';
484
+ this.mode = 438; /*=0666*/
485
+ this.bufferSize = 64 * 1024;
486
+
487
+ options = options || {};
488
+
489
+ // Mixin options into this
490
+ var keys = Object.keys(options);
491
+ for (var index = 0, length = keys.length; index < length; index++) {
492
+ var key = keys[index];
493
+ this[key] = options[key];
494
+ }
495
+
496
+ if (this.encoding) this.setEncoding(this.encoding);
497
+
498
+ if (this.start !== undefined) {
499
+ if ('number' !== typeof this.start) {
500
+ throw TypeError('start must be a Number');
501
+ }
502
+ if (this.end === undefined) {
503
+ this.end = Infinity;
504
+ } else if ('number' !== typeof this.end) {
505
+ throw TypeError('end must be a Number');
506
+ }
507
+
508
+ if (this.start > this.end) {
509
+ throw new Error('start must be <= end');
510
+ }
511
+
512
+ this.pos = this.start;
513
+ }
514
+
515
+ if (this.fd !== null) {
516
+ process.nextTick(function() {
517
+ self._read();
518
+ });
519
+ return;
520
+ }
521
+
522
+ fs.open(this.path, this.flags, this.mode, function (err, fd) {
523
+ if (err) {
524
+ self.emit('error', err);
525
+ self.readable = false;
526
+ return;
527
+ }
528
+
529
+ self.fd = fd;
530
+ self.emit('open', fd);
531
+ self._read();
532
+ });
533
+ }
534
+
535
+ function WriteStream (path, options) {
536
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
537
+
538
+ Stream.call(this);
539
+
540
+ this.path = path;
541
+ this.fd = null;
542
+ this.writable = true;
543
+
544
+ this.flags = 'w';
545
+ this.encoding = 'binary';
546
+ this.mode = 438; /*=0666*/
547
+ this.bytesWritten = 0;
548
+
549
+ options = options || {};
550
+
551
+ // Mixin options into this
552
+ var keys = Object.keys(options);
553
+ for (var index = 0, length = keys.length; index < length; index++) {
554
+ var key = keys[index];
555
+ this[key] = options[key];
556
+ }
557
+
558
+ if (this.start !== undefined) {
559
+ if ('number' !== typeof this.start) {
560
+ throw TypeError('start must be a Number');
561
+ }
562
+ if (this.start < 0) {
563
+ throw new Error('start must be >= zero');
564
+ }
565
+
566
+ this.pos = this.start;
567
+ }
568
+
569
+ this.busy = false;
570
+ this._queue = [];
571
+
572
+ if (this.fd === null) {
573
+ this._open = fs.open;
574
+ this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
575
+ this.flush();
576
+ }
577
+ }
578
+ }
579
+ return legacyStreams;
580
+ }
581
+
582
+ var clone_1;
583
+ var hasRequiredClone;
584
+
585
+ function requireClone () {
586
+ if (hasRequiredClone) return clone_1;
587
+ hasRequiredClone = 1;
588
+
589
+ clone_1 = clone;
590
+
591
+ var getPrototypeOf = Object.getPrototypeOf || function (obj) {
592
+ return obj.__proto__
593
+ };
594
+
595
+ function clone (obj) {
596
+ if (obj === null || typeof obj !== 'object')
597
+ return obj
598
+
599
+ if (obj instanceof Object)
600
+ var copy = { __proto__: getPrototypeOf(obj) };
601
+ else
602
+ var copy = Object.create(null);
603
+
604
+ Object.getOwnPropertyNames(obj).forEach(function (key) {
605
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
606
+ });
607
+
608
+ return copy
609
+ }
610
+ return clone_1;
611
+ }
612
+
613
+ var gracefulFs;
614
+ var hasRequiredGracefulFs;
615
+
616
+ function requireGracefulFs () {
617
+ if (hasRequiredGracefulFs) return gracefulFs;
618
+ hasRequiredGracefulFs = 1;
619
+ var fs = require$$0__default$2["default"];
620
+ var polyfills = requirePolyfills();
621
+ var legacy = requireLegacyStreams();
622
+ var clone = requireClone();
623
+
624
+ var util = require$$4__default["default"];
625
+
626
+ /* istanbul ignore next - node 0.x polyfill */
627
+ var gracefulQueue;
628
+ var previousSymbol;
629
+
630
+ /* istanbul ignore else - node 0.x polyfill */
631
+ if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
632
+ gracefulQueue = Symbol.for('graceful-fs.queue');
633
+ // This is used in testing by future versions
634
+ previousSymbol = Symbol.for('graceful-fs.previous');
635
+ } else {
636
+ gracefulQueue = '___graceful-fs.queue';
637
+ previousSymbol = '___graceful-fs.previous';
638
+ }
639
+
640
+ function noop () {}
641
+
642
+ function publishQueue(context, queue) {
643
+ Object.defineProperty(context, gracefulQueue, {
644
+ get: function() {
645
+ return queue
646
+ }
647
+ });
648
+ }
649
+
650
+ var debug = noop;
651
+ if (util.debuglog)
652
+ debug = util.debuglog('gfs4');
653
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
654
+ debug = function() {
655
+ var m = util.format.apply(util, arguments);
656
+ m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ');
657
+ console.error(m);
658
+ };
659
+
660
+ // Once time initialization
661
+ if (!fs[gracefulQueue]) {
662
+ // This queue can be shared by multiple loaded instances
663
+ var queue = commonjsGlobal[gracefulQueue] || [];
664
+ publishQueue(fs, queue);
665
+
666
+ // Patch fs.close/closeSync to shared queue version, because we need
667
+ // to retry() whenever a close happens *anywhere* in the program.
668
+ // This is essential when multiple graceful-fs instances are
669
+ // in play at the same time.
670
+ fs.close = (function (fs$close) {
671
+ function close (fd, cb) {
672
+ return fs$close.call(fs, fd, function (err) {
673
+ // This function uses the graceful-fs shared queue
674
+ if (!err) {
675
+ resetQueue();
676
+ }
677
+
678
+ if (typeof cb === 'function')
679
+ cb.apply(this, arguments);
680
+ })
681
+ }
682
+
683
+ Object.defineProperty(close, previousSymbol, {
684
+ value: fs$close
685
+ });
686
+ return close
687
+ })(fs.close);
688
+
689
+ fs.closeSync = (function (fs$closeSync) {
690
+ function closeSync (fd) {
691
+ // This function uses the graceful-fs shared queue
692
+ fs$closeSync.apply(fs, arguments);
693
+ resetQueue();
694
+ }
695
+
696
+ Object.defineProperty(closeSync, previousSymbol, {
697
+ value: fs$closeSync
698
+ });
699
+ return closeSync
700
+ })(fs.closeSync);
701
+
702
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
703
+ process.on('exit', function() {
704
+ debug(fs[gracefulQueue]);
705
+ require$$5__default["default"].equal(fs[gracefulQueue].length, 0);
706
+ });
707
+ }
708
+ }
709
+
710
+ if (!commonjsGlobal[gracefulQueue]) {
711
+ publishQueue(commonjsGlobal, fs[gracefulQueue]);
712
+ }
713
+
714
+ gracefulFs = patch(clone(fs));
715
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
716
+ gracefulFs = patch(fs);
717
+ fs.__patched = true;
718
+ }
719
+
720
+ function patch (fs) {
721
+ // Everything that references the open() function needs to be in here
722
+ polyfills(fs);
723
+ fs.gracefulify = patch;
724
+
725
+ fs.createReadStream = createReadStream;
726
+ fs.createWriteStream = createWriteStream;
727
+ var fs$readFile = fs.readFile;
728
+ fs.readFile = readFile;
729
+ function readFile (path, options, cb) {
730
+ if (typeof options === 'function')
731
+ cb = options, options = null;
732
+
733
+ return go$readFile(path, options, cb)
734
+
735
+ function go$readFile (path, options, cb, startTime) {
736
+ return fs$readFile(path, options, function (err) {
737
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
738
+ enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()]);
739
+ else {
740
+ if (typeof cb === 'function')
741
+ cb.apply(this, arguments);
742
+ }
743
+ })
744
+ }
745
+ }
746
+
747
+ var fs$writeFile = fs.writeFile;
748
+ fs.writeFile = writeFile;
749
+ function writeFile (path, data, options, cb) {
750
+ if (typeof options === 'function')
751
+ cb = options, options = null;
752
+
753
+ return go$writeFile(path, data, options, cb)
754
+
755
+ function go$writeFile (path, data, options, cb, startTime) {
756
+ return fs$writeFile(path, data, options, function (err) {
757
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
758
+ enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
759
+ else {
760
+ if (typeof cb === 'function')
761
+ cb.apply(this, arguments);
762
+ }
763
+ })
764
+ }
765
+ }
766
+
767
+ var fs$appendFile = fs.appendFile;
768
+ if (fs$appendFile)
769
+ fs.appendFile = appendFile;
770
+ function appendFile (path, data, options, cb) {
771
+ if (typeof options === 'function')
772
+ cb = options, options = null;
773
+
774
+ return go$appendFile(path, data, options, cb)
775
+
776
+ function go$appendFile (path, data, options, cb, startTime) {
777
+ return fs$appendFile(path, data, options, function (err) {
778
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
779
+ enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
780
+ else {
781
+ if (typeof cb === 'function')
782
+ cb.apply(this, arguments);
783
+ }
784
+ })
785
+ }
786
+ }
787
+
788
+ var fs$copyFile = fs.copyFile;
789
+ if (fs$copyFile)
790
+ fs.copyFile = copyFile;
791
+ function copyFile (src, dest, flags, cb) {
792
+ if (typeof flags === 'function') {
793
+ cb = flags;
794
+ flags = 0;
795
+ }
796
+ return go$copyFile(src, dest, flags, cb)
797
+
798
+ function go$copyFile (src, dest, flags, cb, startTime) {
799
+ return fs$copyFile(src, dest, flags, function (err) {
800
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
801
+ enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()]);
802
+ else {
803
+ if (typeof cb === 'function')
804
+ cb.apply(this, arguments);
805
+ }
806
+ })
807
+ }
808
+ }
809
+
810
+ var fs$readdir = fs.readdir;
811
+ fs.readdir = readdir;
812
+ var noReaddirOptionVersions = /^v[0-5]\./;
813
+ function readdir (path, options, cb) {
814
+ if (typeof options === 'function')
815
+ cb = options, options = null;
816
+
817
+ var go$readdir = noReaddirOptionVersions.test(process.version)
818
+ ? function go$readdir (path, options, cb, startTime) {
819
+ return fs$readdir(path, fs$readdirCallback(
820
+ path, options, cb, startTime
821
+ ))
822
+ }
823
+ : function go$readdir (path, options, cb, startTime) {
824
+ return fs$readdir(path, options, fs$readdirCallback(
825
+ path, options, cb, startTime
826
+ ))
827
+ };
828
+
829
+ return go$readdir(path, options, cb)
830
+
831
+ function fs$readdirCallback (path, options, cb, startTime) {
832
+ return function (err, files) {
833
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
834
+ enqueue([
835
+ go$readdir,
836
+ [path, options, cb],
837
+ err,
838
+ startTime || Date.now(),
839
+ Date.now()
840
+ ]);
841
+ else {
842
+ if (files && files.sort)
843
+ files.sort();
844
+
845
+ if (typeof cb === 'function')
846
+ cb.call(this, err, files);
847
+ }
848
+ }
849
+ }
850
+ }
851
+
852
+ if (process.version.substr(0, 4) === 'v0.8') {
853
+ var legStreams = legacy(fs);
854
+ ReadStream = legStreams.ReadStream;
855
+ WriteStream = legStreams.WriteStream;
856
+ }
857
+
858
+ var fs$ReadStream = fs.ReadStream;
859
+ if (fs$ReadStream) {
860
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
861
+ ReadStream.prototype.open = ReadStream$open;
862
+ }
863
+
864
+ var fs$WriteStream = fs.WriteStream;
865
+ if (fs$WriteStream) {
866
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
867
+ WriteStream.prototype.open = WriteStream$open;
868
+ }
869
+
870
+ Object.defineProperty(fs, 'ReadStream', {
871
+ get: function () {
872
+ return ReadStream
873
+ },
874
+ set: function (val) {
875
+ ReadStream = val;
876
+ },
877
+ enumerable: true,
878
+ configurable: true
879
+ });
880
+ Object.defineProperty(fs, 'WriteStream', {
881
+ get: function () {
882
+ return WriteStream
883
+ },
884
+ set: function (val) {
885
+ WriteStream = val;
886
+ },
887
+ enumerable: true,
888
+ configurable: true
889
+ });
890
+
891
+ // legacy names
892
+ var FileReadStream = ReadStream;
893
+ Object.defineProperty(fs, 'FileReadStream', {
894
+ get: function () {
895
+ return FileReadStream
896
+ },
897
+ set: function (val) {
898
+ FileReadStream = val;
899
+ },
900
+ enumerable: true,
901
+ configurable: true
902
+ });
903
+ var FileWriteStream = WriteStream;
904
+ Object.defineProperty(fs, 'FileWriteStream', {
905
+ get: function () {
906
+ return FileWriteStream
907
+ },
908
+ set: function (val) {
909
+ FileWriteStream = val;
910
+ },
911
+ enumerable: true,
912
+ configurable: true
913
+ });
914
+
915
+ function ReadStream (path, options) {
916
+ if (this instanceof ReadStream)
917
+ return fs$ReadStream.apply(this, arguments), this
918
+ else
919
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
920
+ }
921
+
922
+ function ReadStream$open () {
923
+ var that = this;
924
+ open(that.path, that.flags, that.mode, function (err, fd) {
925
+ if (err) {
926
+ if (that.autoClose)
927
+ that.destroy();
928
+
929
+ that.emit('error', err);
930
+ } else {
931
+ that.fd = fd;
932
+ that.emit('open', fd);
933
+ that.read();
934
+ }
935
+ });
936
+ }
937
+
938
+ function WriteStream (path, options) {
939
+ if (this instanceof WriteStream)
940
+ return fs$WriteStream.apply(this, arguments), this
941
+ else
942
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
943
+ }
944
+
945
+ function WriteStream$open () {
946
+ var that = this;
947
+ open(that.path, that.flags, that.mode, function (err, fd) {
948
+ if (err) {
949
+ that.destroy();
950
+ that.emit('error', err);
951
+ } else {
952
+ that.fd = fd;
953
+ that.emit('open', fd);
954
+ }
955
+ });
956
+ }
957
+
958
+ function createReadStream (path, options) {
959
+ return new fs.ReadStream(path, options)
960
+ }
961
+
962
+ function createWriteStream (path, options) {
963
+ return new fs.WriteStream(path, options)
964
+ }
965
+
966
+ var fs$open = fs.open;
967
+ fs.open = open;
968
+ function open (path, flags, mode, cb) {
969
+ if (typeof mode === 'function')
970
+ cb = mode, mode = null;
971
+
972
+ return go$open(path, flags, mode, cb)
973
+
974
+ function go$open (path, flags, mode, cb, startTime) {
975
+ return fs$open(path, flags, mode, function (err, fd) {
976
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
977
+ enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()]);
978
+ else {
979
+ if (typeof cb === 'function')
980
+ cb.apply(this, arguments);
981
+ }
982
+ })
983
+ }
984
+ }
985
+
986
+ return fs
987
+ }
988
+
989
+ function enqueue (elem) {
990
+ debug('ENQUEUE', elem[0].name, elem[1]);
991
+ fs[gracefulQueue].push(elem);
992
+ retry();
993
+ }
994
+
995
+ // keep track of the timeout between retry() calls
996
+ var retryTimer;
997
+
998
+ // reset the startTime and lastTime to now
999
+ // this resets the start of the 60 second overall timeout as well as the
1000
+ // delay between attempts so that we'll retry these jobs sooner
1001
+ function resetQueue () {
1002
+ var now = Date.now();
1003
+ for (var i = 0; i < fs[gracefulQueue].length; ++i) {
1004
+ // entries that are only a length of 2 are from an older version, don't
1005
+ // bother modifying those since they'll be retried anyway.
1006
+ if (fs[gracefulQueue][i].length > 2) {
1007
+ fs[gracefulQueue][i][3] = now; // startTime
1008
+ fs[gracefulQueue][i][4] = now; // lastTime
1009
+ }
1010
+ }
1011
+ // call retry to make sure we're actively processing the queue
1012
+ retry();
1013
+ }
1014
+
1015
+ function retry () {
1016
+ // clear the timer and remove it to help prevent unintended concurrency
1017
+ clearTimeout(retryTimer);
1018
+ retryTimer = undefined;
1019
+
1020
+ if (fs[gracefulQueue].length === 0)
1021
+ return
1022
+
1023
+ var elem = fs[gracefulQueue].shift();
1024
+ var fn = elem[0];
1025
+ var args = elem[1];
1026
+ // these items may be unset if they were added by an older graceful-fs
1027
+ var err = elem[2];
1028
+ var startTime = elem[3];
1029
+ var lastTime = elem[4];
1030
+
1031
+ // if we don't have a startTime we have no way of knowing if we've waited
1032
+ // long enough, so go ahead and retry this item now
1033
+ if (startTime === undefined) {
1034
+ debug('RETRY', fn.name, args);
1035
+ fn.apply(null, args);
1036
+ } else if (Date.now() - startTime >= 60000) {
1037
+ // it's been more than 60 seconds total, bail now
1038
+ debug('TIMEOUT', fn.name, args);
1039
+ var cb = args.pop();
1040
+ if (typeof cb === 'function')
1041
+ cb.call(null, err);
1042
+ } else {
1043
+ // the amount of time between the last attempt and right now
1044
+ var sinceAttempt = Date.now() - lastTime;
1045
+ // the amount of time between when we first tried, and when we last tried
1046
+ // rounded up to at least 1
1047
+ var sinceStart = Math.max(lastTime - startTime, 1);
1048
+ // backoff. wait longer than the total time we've been retrying, but only
1049
+ // up to a maximum of 100ms
1050
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
1051
+ // it's been long enough since the last retry, do it again
1052
+ if (sinceAttempt >= desiredDelay) {
1053
+ debug('RETRY', fn.name, args);
1054
+ fn.apply(null, args.concat([startTime]));
1055
+ } else {
1056
+ // if we can't do this job yet, push it to the end of the queue
1057
+ // and let the next iteration check again
1058
+ fs[gracefulQueue].push(elem);
1059
+ }
1060
+ }
1061
+
1062
+ // schedule our next run if one isn't already scheduled
1063
+ if (retryTimer === undefined) {
1064
+ retryTimer = setTimeout(retry, 0);
1065
+ }
1066
+ }
1067
+ return gracefulFs;
1068
+ }
1069
+
1070
+ var hasRequiredFs;
1071
+
1072
+ function requireFs () {
1073
+ if (hasRequiredFs) return fs$1;
1074
+ hasRequiredFs = 1;
1075
+ (function (exports) {
1076
+ // This is adapted from https://github.com/normalize/mz
1077
+ // Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
1078
+ const u = requireUniversalify().fromCallback;
1079
+ const fs = requireGracefulFs();
1080
+
1081
+ const api = [
1082
+ 'access',
1083
+ 'appendFile',
1084
+ 'chmod',
1085
+ 'chown',
1086
+ 'close',
1087
+ 'copyFile',
1088
+ 'fchmod',
1089
+ 'fchown',
1090
+ 'fdatasync',
1091
+ 'fstat',
1092
+ 'fsync',
1093
+ 'ftruncate',
1094
+ 'futimes',
1095
+ 'lchmod',
1096
+ 'lchown',
1097
+ 'link',
1098
+ 'lstat',
1099
+ 'mkdir',
1100
+ 'mkdtemp',
1101
+ 'open',
1102
+ 'opendir',
1103
+ 'readdir',
1104
+ 'readFile',
1105
+ 'readlink',
1106
+ 'realpath',
1107
+ 'rename',
1108
+ 'rm',
1109
+ 'rmdir',
1110
+ 'stat',
1111
+ 'symlink',
1112
+ 'truncate',
1113
+ 'unlink',
1114
+ 'utimes',
1115
+ 'writeFile'
1116
+ ].filter(key => {
1117
+ // Some commands are not available on some systems. Ex:
1118
+ // fs.cp was added in Node.js v16.7.0
1119
+ // fs.lchown is not available on at least some Linux
1120
+ return typeof fs[key] === 'function'
1121
+ });
1122
+
1123
+ // Export cloned fs:
1124
+ Object.assign(exports, fs);
1125
+
1126
+ // Universalify async methods:
1127
+ api.forEach(method => {
1128
+ exports[method] = u(fs[method]);
1129
+ });
1130
+
1131
+ // We differ from mz/fs in that we still ship the old, broken, fs.exists()
1132
+ // since we are a drop-in replacement for the native module
1133
+ exports.exists = function (filename, callback) {
1134
+ if (typeof callback === 'function') {
1135
+ return fs.exists(filename, callback)
1136
+ }
1137
+ return new Promise(resolve => {
1138
+ return fs.exists(filename, resolve)
1139
+ })
1140
+ };
1141
+
1142
+ // fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
1143
+
1144
+ exports.read = function (fd, buffer, offset, length, position, callback) {
1145
+ if (typeof callback === 'function') {
1146
+ return fs.read(fd, buffer, offset, length, position, callback)
1147
+ }
1148
+ return new Promise((resolve, reject) => {
1149
+ fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
1150
+ if (err) return reject(err)
1151
+ resolve({ bytesRead, buffer });
1152
+ });
1153
+ })
1154
+ };
1155
+
1156
+ // Function signature can be
1157
+ // fs.write(fd, buffer[, offset[, length[, position]]], callback)
1158
+ // OR
1159
+ // fs.write(fd, string[, position[, encoding]], callback)
1160
+ // We need to handle both cases, so we use ...args
1161
+ exports.write = function (fd, buffer, ...args) {
1162
+ if (typeof args[args.length - 1] === 'function') {
1163
+ return fs.write(fd, buffer, ...args)
1164
+ }
1165
+
1166
+ return new Promise((resolve, reject) => {
1167
+ fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
1168
+ if (err) return reject(err)
1169
+ resolve({ bytesWritten, buffer });
1170
+ });
1171
+ })
1172
+ };
1173
+
1174
+ // Function signature is
1175
+ // s.readv(fd, buffers[, position], callback)
1176
+ // We need to handle the optional arg, so we use ...args
1177
+ exports.readv = function (fd, buffers, ...args) {
1178
+ if (typeof args[args.length - 1] === 'function') {
1179
+ return fs.readv(fd, buffers, ...args)
1180
+ }
1181
+
1182
+ return new Promise((resolve, reject) => {
1183
+ fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
1184
+ if (err) return reject(err)
1185
+ resolve({ bytesRead, buffers });
1186
+ });
1187
+ })
1188
+ };
1189
+
1190
+ // Function signature is
1191
+ // s.writev(fd, buffers[, position], callback)
1192
+ // We need to handle the optional arg, so we use ...args
1193
+ exports.writev = function (fd, buffers, ...args) {
1194
+ if (typeof args[args.length - 1] === 'function') {
1195
+ return fs.writev(fd, buffers, ...args)
1196
+ }
1197
+
1198
+ return new Promise((resolve, reject) => {
1199
+ fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
1200
+ if (err) return reject(err)
1201
+ resolve({ bytesWritten, buffers });
1202
+ });
1203
+ })
1204
+ };
1205
+
1206
+ // fs.realpath.native sometimes not available if fs is monkey-patched
1207
+ if (typeof fs.realpath.native === 'function') {
1208
+ exports.realpath.native = u(fs.realpath.native);
1209
+ } else {
1210
+ process.emitWarning(
1211
+ 'fs.realpath.native is not a function. Is fs being monkey-patched?',
1212
+ 'Warning', 'fs-extra-WARN0003'
1213
+ );
1214
+ }
1215
+ } (fs$1));
1216
+ return fs$1;
1217
+ }
1218
+
1219
+ var makeDir = {};
1220
+
1221
+ var utils$1 = {};
1222
+
1223
+ var hasRequiredUtils$1;
1224
+
1225
+ function requireUtils$1 () {
1226
+ if (hasRequiredUtils$1) return utils$1;
1227
+ hasRequiredUtils$1 = 1;
1228
+ const path = require$$1__default["default"];
1229
+
1230
+ // https://github.com/nodejs/node/issues/8987
1231
+ // https://github.com/libuv/libuv/pull/1088
1232
+ utils$1.checkPath = function checkPath (pth) {
1233
+ if (process.platform === 'win32') {
1234
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
1235
+
1236
+ if (pathHasInvalidWinCharacters) {
1237
+ const error = new Error(`Path contains invalid characters: ${pth}`);
1238
+ error.code = 'EINVAL';
1239
+ throw error
1240
+ }
1241
+ }
1242
+ };
1243
+ return utils$1;
1244
+ }
1245
+
1246
+ var hasRequiredMakeDir;
1247
+
1248
+ function requireMakeDir () {
1249
+ if (hasRequiredMakeDir) return makeDir;
1250
+ hasRequiredMakeDir = 1;
1251
+ const fs = /*@__PURE__*/ requireFs();
1252
+ const { checkPath } = /*@__PURE__*/ requireUtils$1();
1253
+
1254
+ const getMode = options => {
1255
+ const defaults = { mode: 0o777 };
1256
+ if (typeof options === 'number') return options
1257
+ return ({ ...defaults, ...options }).mode
1258
+ };
1259
+
1260
+ makeDir.makeDir = async (dir, options) => {
1261
+ checkPath(dir);
1262
+
1263
+ return fs.mkdir(dir, {
1264
+ mode: getMode(options),
1265
+ recursive: true
1266
+ })
1267
+ };
1268
+
1269
+ makeDir.makeDirSync = (dir, options) => {
1270
+ checkPath(dir);
1271
+
1272
+ return fs.mkdirSync(dir, {
1273
+ mode: getMode(options),
1274
+ recursive: true
1275
+ })
1276
+ };
1277
+ return makeDir;
1278
+ }
1279
+
1280
+ var mkdirs;
1281
+ var hasRequiredMkdirs;
1282
+
1283
+ function requireMkdirs () {
1284
+ if (hasRequiredMkdirs) return mkdirs;
1285
+ hasRequiredMkdirs = 1;
1286
+ const u = requireUniversalify().fromPromise;
1287
+ const { makeDir: _makeDir, makeDirSync } = /*@__PURE__*/ requireMakeDir();
1288
+ const makeDir = u(_makeDir);
1289
+
1290
+ mkdirs = {
1291
+ mkdirs: makeDir,
1292
+ mkdirsSync: makeDirSync,
1293
+ // alias
1294
+ mkdirp: makeDir,
1295
+ mkdirpSync: makeDirSync,
1296
+ ensureDir: makeDir,
1297
+ ensureDirSync: makeDirSync
1298
+ };
1299
+ return mkdirs;
1300
+ }
1301
+
1302
+ var pathExists_1;
1303
+ var hasRequiredPathExists;
1304
+
1305
+ function requirePathExists () {
1306
+ if (hasRequiredPathExists) return pathExists_1;
1307
+ hasRequiredPathExists = 1;
1308
+ const u = requireUniversalify().fromPromise;
1309
+ const fs = /*@__PURE__*/ requireFs();
1310
+
1311
+ function pathExists (path) {
1312
+ return fs.access(path).then(() => true).catch(() => false)
1313
+ }
1314
+
1315
+ pathExists_1 = {
1316
+ pathExists: u(pathExists),
1317
+ pathExistsSync: fs.existsSync
1318
+ };
1319
+ return pathExists_1;
1320
+ }
1321
+
1322
+ var utimes;
1323
+ var hasRequiredUtimes;
1324
+
1325
+ function requireUtimes () {
1326
+ if (hasRequiredUtimes) return utimes;
1327
+ hasRequiredUtimes = 1;
1328
+
1329
+ const fs = /*@__PURE__*/ requireFs();
1330
+ const u = requireUniversalify().fromPromise;
1331
+
1332
+ async function utimesMillis (path, atime, mtime) {
1333
+ // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
1334
+ const fd = await fs.open(path, 'r+');
1335
+
1336
+ let closeErr = null;
1337
+
1338
+ try {
1339
+ await fs.futimes(fd, atime, mtime);
1340
+ } finally {
1341
+ try {
1342
+ await fs.close(fd);
1343
+ } catch (e) {
1344
+ closeErr = e;
1345
+ }
1346
+ }
1347
+
1348
+ if (closeErr) {
1349
+ throw closeErr
1350
+ }
1351
+ }
1352
+
1353
+ function utimesMillisSync (path, atime, mtime) {
1354
+ const fd = fs.openSync(path, 'r+');
1355
+ fs.futimesSync(fd, atime, mtime);
1356
+ return fs.closeSync(fd)
1357
+ }
1358
+
1359
+ utimes = {
1360
+ utimesMillis: u(utimesMillis),
1361
+ utimesMillisSync
1362
+ };
1363
+ return utimes;
1364
+ }
1365
+
1366
+ var stat;
1367
+ var hasRequiredStat;
1368
+
1369
+ function requireStat () {
1370
+ if (hasRequiredStat) return stat;
1371
+ hasRequiredStat = 1;
1372
+
1373
+ const fs = /*@__PURE__*/ requireFs();
1374
+ const path = require$$1__default["default"];
1375
+ const u = requireUniversalify().fromPromise;
1376
+
1377
+ function getStats (src, dest, opts) {
1378
+ const statFunc = opts.dereference
1379
+ ? (file) => fs.stat(file, { bigint: true })
1380
+ : (file) => fs.lstat(file, { bigint: true });
1381
+ return Promise.all([
1382
+ statFunc(src),
1383
+ statFunc(dest).catch(err => {
1384
+ if (err.code === 'ENOENT') return null
1385
+ throw err
1386
+ })
1387
+ ]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
1388
+ }
1389
+
1390
+ function getStatsSync (src, dest, opts) {
1391
+ let destStat;
1392
+ const statFunc = opts.dereference
1393
+ ? (file) => fs.statSync(file, { bigint: true })
1394
+ : (file) => fs.lstatSync(file, { bigint: true });
1395
+ const srcStat = statFunc(src);
1396
+ try {
1397
+ destStat = statFunc(dest);
1398
+ } catch (err) {
1399
+ if (err.code === 'ENOENT') return { srcStat, destStat: null }
1400
+ throw err
1401
+ }
1402
+ return { srcStat, destStat }
1403
+ }
1404
+
1405
+ async function checkPaths (src, dest, funcName, opts) {
1406
+ const { srcStat, destStat } = await getStats(src, dest, opts);
1407
+ if (destStat) {
1408
+ if (areIdentical(srcStat, destStat)) {
1409
+ const srcBaseName = path.basename(src);
1410
+ const destBaseName = path.basename(dest);
1411
+ if (funcName === 'move' &&
1412
+ srcBaseName !== destBaseName &&
1413
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1414
+ return { srcStat, destStat, isChangingCase: true }
1415
+ }
1416
+ throw new Error('Source and destination must not be the same.')
1417
+ }
1418
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
1419
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
1420
+ }
1421
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
1422
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
1423
+ }
1424
+ }
1425
+
1426
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1427
+ throw new Error(errMsg(src, dest, funcName))
1428
+ }
1429
+
1430
+ return { srcStat, destStat }
1431
+ }
1432
+
1433
+ function checkPathsSync (src, dest, funcName, opts) {
1434
+ const { srcStat, destStat } = getStatsSync(src, dest, opts);
1435
+
1436
+ if (destStat) {
1437
+ if (areIdentical(srcStat, destStat)) {
1438
+ const srcBaseName = path.basename(src);
1439
+ const destBaseName = path.basename(dest);
1440
+ if (funcName === 'move' &&
1441
+ srcBaseName !== destBaseName &&
1442
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1443
+ return { srcStat, destStat, isChangingCase: true }
1444
+ }
1445
+ throw new Error('Source and destination must not be the same.')
1446
+ }
1447
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
1448
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
1449
+ }
1450
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
1451
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
1452
+ }
1453
+ }
1454
+
1455
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1456
+ throw new Error(errMsg(src, dest, funcName))
1457
+ }
1458
+ return { srcStat, destStat }
1459
+ }
1460
+
1461
+ // recursively check if dest parent is a subdirectory of src.
1462
+ // It works for all file types including symlinks since it
1463
+ // checks the src and dest inodes. It starts from the deepest
1464
+ // parent and stops once it reaches the src parent or the root path.
1465
+ async function checkParentPaths (src, srcStat, dest, funcName) {
1466
+ const srcParent = path.resolve(path.dirname(src));
1467
+ const destParent = path.resolve(path.dirname(dest));
1468
+ if (destParent === srcParent || destParent === path.parse(destParent).root) return
1469
+
1470
+ let destStat;
1471
+ try {
1472
+ destStat = await fs.stat(destParent, { bigint: true });
1473
+ } catch (err) {
1474
+ if (err.code === 'ENOENT') return
1475
+ throw err
1476
+ }
1477
+
1478
+ if (areIdentical(srcStat, destStat)) {
1479
+ throw new Error(errMsg(src, dest, funcName))
1480
+ }
1481
+
1482
+ return checkParentPaths(src, srcStat, destParent, funcName)
1483
+ }
1484
+
1485
+ function checkParentPathsSync (src, srcStat, dest, funcName) {
1486
+ const srcParent = path.resolve(path.dirname(src));
1487
+ const destParent = path.resolve(path.dirname(dest));
1488
+ if (destParent === srcParent || destParent === path.parse(destParent).root) return
1489
+ let destStat;
1490
+ try {
1491
+ destStat = fs.statSync(destParent, { bigint: true });
1492
+ } catch (err) {
1493
+ if (err.code === 'ENOENT') return
1494
+ throw err
1495
+ }
1496
+ if (areIdentical(srcStat, destStat)) {
1497
+ throw new Error(errMsg(src, dest, funcName))
1498
+ }
1499
+ return checkParentPathsSync(src, srcStat, destParent, funcName)
1500
+ }
1501
+
1502
+ function areIdentical (srcStat, destStat) {
1503
+ return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
1504
+ }
1505
+
1506
+ // return true if dest is a subdir of src, otherwise false.
1507
+ // It only checks the path strings.
1508
+ function isSrcSubdir (src, dest) {
1509
+ const srcArr = path.resolve(src).split(path.sep).filter(i => i);
1510
+ const destArr = path.resolve(dest).split(path.sep).filter(i => i);
1511
+ return srcArr.every((cur, i) => destArr[i] === cur)
1512
+ }
1513
+
1514
+ function errMsg (src, dest, funcName) {
1515
+ return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
1516
+ }
1517
+
1518
+ stat = {
1519
+ // checkPaths
1520
+ checkPaths: u(checkPaths),
1521
+ checkPathsSync,
1522
+ // checkParent
1523
+ checkParentPaths: u(checkParentPaths),
1524
+ checkParentPathsSync,
1525
+ // Misc
1526
+ isSrcSubdir,
1527
+ areIdentical
1528
+ };
1529
+ return stat;
1530
+ }
1531
+
1532
+ var copy_1;
1533
+ var hasRequiredCopy$1;
1534
+
1535
+ function requireCopy$1 () {
1536
+ if (hasRequiredCopy$1) return copy_1;
1537
+ hasRequiredCopy$1 = 1;
1538
+
1539
+ const fs = /*@__PURE__*/ requireFs();
1540
+ const path = require$$1__default["default"];
1541
+ const { mkdirs } = /*@__PURE__*/ requireMkdirs();
1542
+ const { pathExists } = /*@__PURE__*/ requirePathExists();
1543
+ const { utimesMillis } = /*@__PURE__*/ requireUtimes();
1544
+ const stat = /*@__PURE__*/ requireStat();
1545
+
1546
+ async function copy (src, dest, opts = {}) {
1547
+ if (typeof opts === 'function') {
1548
+ opts = { filter: opts };
1549
+ }
1550
+
1551
+ opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now
1552
+ opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
1553
+
1554
+ // Warn about using preserveTimestamps on 32-bit node
1555
+ if (opts.preserveTimestamps && process.arch === 'ia32') {
1556
+ process.emitWarning(
1557
+ 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
1558
+ '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
1559
+ 'Warning', 'fs-extra-WARN0001'
1560
+ );
1561
+ }
1562
+
1563
+ const { srcStat, destStat } = await stat.checkPaths(src, dest, 'copy', opts);
1564
+
1565
+ await stat.checkParentPaths(src, srcStat, dest, 'copy');
1566
+
1567
+ const include = await runFilter(src, dest, opts);
1568
+
1569
+ if (!include) return
1570
+
1571
+ // check if the parent of dest exists, and create it if it doesn't exist
1572
+ const destParent = path.dirname(dest);
1573
+ const dirExists = await pathExists(destParent);
1574
+ if (!dirExists) {
1575
+ await mkdirs(destParent);
1576
+ }
1577
+
1578
+ await getStatsAndPerformCopy(destStat, src, dest, opts);
1579
+ }
1580
+
1581
+ async function runFilter (src, dest, opts) {
1582
+ if (!opts.filter) return true
1583
+ return opts.filter(src, dest)
1584
+ }
1585
+
1586
+ async function getStatsAndPerformCopy (destStat, src, dest, opts) {
1587
+ const statFn = opts.dereference ? fs.stat : fs.lstat;
1588
+ const srcStat = await statFn(src);
1589
+
1590
+ if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
1591
+
1592
+ if (
1593
+ srcStat.isFile() ||
1594
+ srcStat.isCharacterDevice() ||
1595
+ srcStat.isBlockDevice()
1596
+ ) return onFile(srcStat, destStat, src, dest, opts)
1597
+
1598
+ if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
1599
+ if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
1600
+ if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
1601
+ throw new Error(`Unknown file: ${src}`)
1602
+ }
1603
+
1604
+ async function onFile (srcStat, destStat, src, dest, opts) {
1605
+ if (!destStat) return copyFile(srcStat, src, dest, opts)
1606
+
1607
+ if (opts.overwrite) {
1608
+ await fs.unlink(dest);
1609
+ return copyFile(srcStat, src, dest, opts)
1610
+ }
1611
+ if (opts.errorOnExist) {
1612
+ throw new Error(`'${dest}' already exists`)
1613
+ }
1614
+ }
1615
+
1616
+ async function copyFile (srcStat, src, dest, opts) {
1617
+ await fs.copyFile(src, dest);
1618
+ if (opts.preserveTimestamps) {
1619
+ // Make sure the file is writable before setting the timestamp
1620
+ // otherwise open fails with EPERM when invoked with 'r+'
1621
+ // (through utimes call)
1622
+ if (fileIsNotWritable(srcStat.mode)) {
1623
+ await makeFileWritable(dest, srcStat.mode);
1624
+ }
1625
+
1626
+ // Set timestamps and mode correspondingly
1627
+
1628
+ // Note that The initial srcStat.atime cannot be trusted
1629
+ // because it is modified by the read(2) system call
1630
+ // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
1631
+ const updatedSrcStat = await fs.stat(src);
1632
+ await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1633
+ }
1634
+
1635
+ return fs.chmod(dest, srcStat.mode)
1636
+ }
1637
+
1638
+ function fileIsNotWritable (srcMode) {
1639
+ return (srcMode & 0o200) === 0
1640
+ }
1641
+
1642
+ function makeFileWritable (dest, srcMode) {
1643
+ return fs.chmod(dest, srcMode | 0o200)
1644
+ }
1645
+
1646
+ async function onDir (srcStat, destStat, src, dest, opts) {
1647
+ // the dest directory might not exist, create it
1648
+ if (!destStat) {
1649
+ await fs.mkdir(dest);
1650
+ }
1651
+
1652
+ const items = await fs.readdir(src);
1653
+
1654
+ // loop through the files in the current directory to copy everything
1655
+ await Promise.all(items.map(async item => {
1656
+ const srcItem = path.join(src, item);
1657
+ const destItem = path.join(dest, item);
1658
+
1659
+ // skip the item if it is matches by the filter function
1660
+ const include = await runFilter(srcItem, destItem, opts);
1661
+ if (!include) return
1662
+
1663
+ const { destStat } = await stat.checkPaths(srcItem, destItem, 'copy', opts);
1664
+
1665
+ // If the item is a copyable file, `getStatsAndPerformCopy` will copy it
1666
+ // If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
1667
+ return getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
1668
+ }));
1669
+
1670
+ if (!destStat) {
1671
+ await fs.chmod(dest, srcStat.mode);
1672
+ }
1673
+ }
1674
+
1675
+ async function onLink (destStat, src, dest, opts) {
1676
+ let resolvedSrc = await fs.readlink(src);
1677
+ if (opts.dereference) {
1678
+ resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
1679
+ }
1680
+ if (!destStat) {
1681
+ return fs.symlink(resolvedSrc, dest)
1682
+ }
1683
+
1684
+ let resolvedDest = null;
1685
+ try {
1686
+ resolvedDest = await fs.readlink(dest);
1687
+ } catch (e) {
1688
+ // dest exists and is a regular file or directory,
1689
+ // Windows may throw UNKNOWN error. If dest already exists,
1690
+ // fs throws error anyway, so no need to guard against it here.
1691
+ if (e.code === 'EINVAL' || e.code === 'UNKNOWN') return fs.symlink(resolvedSrc, dest)
1692
+ throw e
1693
+ }
1694
+ if (opts.dereference) {
1695
+ resolvedDest = path.resolve(process.cwd(), resolvedDest);
1696
+ }
1697
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1698
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
1699
+ }
1700
+
1701
+ // do not copy if src is a subdir of dest since unlinking
1702
+ // dest in this case would result in removing src contents
1703
+ // and therefore a broken symlink would be created.
1704
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1705
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
1706
+ }
1707
+
1708
+ // copy the link
1709
+ await fs.unlink(dest);
1710
+ return fs.symlink(resolvedSrc, dest)
1711
+ }
1712
+
1713
+ copy_1 = copy;
1714
+ return copy_1;
1715
+ }
1716
+
1717
+ var copySync_1;
1718
+ var hasRequiredCopySync;
1719
+
1720
+ function requireCopySync () {
1721
+ if (hasRequiredCopySync) return copySync_1;
1722
+ hasRequiredCopySync = 1;
1723
+
1724
+ const fs = requireGracefulFs();
1725
+ const path = require$$1__default["default"];
1726
+ const mkdirsSync = /*@__PURE__*/ requireMkdirs().mkdirsSync;
1727
+ const utimesMillisSync = /*@__PURE__*/ requireUtimes().utimesMillisSync;
1728
+ const stat = /*@__PURE__*/ requireStat();
1729
+
1730
+ function copySync (src, dest, opts) {
1731
+ if (typeof opts === 'function') {
1732
+ opts = { filter: opts };
1733
+ }
1734
+
1735
+ opts = opts || {};
1736
+ opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now
1737
+ opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
1738
+
1739
+ // Warn about using preserveTimestamps on 32-bit node
1740
+ if (opts.preserveTimestamps && process.arch === 'ia32') {
1741
+ process.emitWarning(
1742
+ 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
1743
+ '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
1744
+ 'Warning', 'fs-extra-WARN0002'
1745
+ );
1746
+ }
1747
+
1748
+ const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy', opts);
1749
+ stat.checkParentPathsSync(src, srcStat, dest, 'copy');
1750
+ if (opts.filter && !opts.filter(src, dest)) return
1751
+ const destParent = path.dirname(dest);
1752
+ if (!fs.existsSync(destParent)) mkdirsSync(destParent);
1753
+ return getStats(destStat, src, dest, opts)
1754
+ }
1755
+
1756
+ function getStats (destStat, src, dest, opts) {
1757
+ const statSync = opts.dereference ? fs.statSync : fs.lstatSync;
1758
+ const srcStat = statSync(src);
1759
+
1760
+ if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
1761
+ else if (srcStat.isFile() ||
1762
+ srcStat.isCharacterDevice() ||
1763
+ srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
1764
+ else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
1765
+ else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
1766
+ else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
1767
+ throw new Error(`Unknown file: ${src}`)
1768
+ }
1769
+
1770
+ function onFile (srcStat, destStat, src, dest, opts) {
1771
+ if (!destStat) return copyFile(srcStat, src, dest, opts)
1772
+ return mayCopyFile(srcStat, src, dest, opts)
1773
+ }
1774
+
1775
+ function mayCopyFile (srcStat, src, dest, opts) {
1776
+ if (opts.overwrite) {
1777
+ fs.unlinkSync(dest);
1778
+ return copyFile(srcStat, src, dest, opts)
1779
+ } else if (opts.errorOnExist) {
1780
+ throw new Error(`'${dest}' already exists`)
1781
+ }
1782
+ }
1783
+
1784
+ function copyFile (srcStat, src, dest, opts) {
1785
+ fs.copyFileSync(src, dest);
1786
+ if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
1787
+ return setDestMode(dest, srcStat.mode)
1788
+ }
1789
+
1790
+ function handleTimestamps (srcMode, src, dest) {
1791
+ // Make sure the file is writable before setting the timestamp
1792
+ // otherwise open fails with EPERM when invoked with 'r+'
1793
+ // (through utimes call)
1794
+ if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
1795
+ return setDestTimestamps(src, dest)
1796
+ }
1797
+
1798
+ function fileIsNotWritable (srcMode) {
1799
+ return (srcMode & 0o200) === 0
1800
+ }
1801
+
1802
+ function makeFileWritable (dest, srcMode) {
1803
+ return setDestMode(dest, srcMode | 0o200)
1804
+ }
1805
+
1806
+ function setDestMode (dest, srcMode) {
1807
+ return fs.chmodSync(dest, srcMode)
1808
+ }
1809
+
1810
+ function setDestTimestamps (src, dest) {
1811
+ // The initial srcStat.atime cannot be trusted
1812
+ // because it is modified by the read(2) system call
1813
+ // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
1814
+ const updatedSrcStat = fs.statSync(src);
1815
+ return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
1816
+ }
1817
+
1818
+ function onDir (srcStat, destStat, src, dest, opts) {
1819
+ if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
1820
+ return copyDir(src, dest, opts)
1821
+ }
1822
+
1823
+ function mkDirAndCopy (srcMode, src, dest, opts) {
1824
+ fs.mkdirSync(dest);
1825
+ copyDir(src, dest, opts);
1826
+ return setDestMode(dest, srcMode)
1827
+ }
1828
+
1829
+ function copyDir (src, dest, opts) {
1830
+ fs.readdirSync(src).forEach(item => copyDirItem(item, src, dest, opts));
1831
+ }
1832
+
1833
+ function copyDirItem (item, src, dest, opts) {
1834
+ const srcItem = path.join(src, item);
1835
+ const destItem = path.join(dest, item);
1836
+ if (opts.filter && !opts.filter(srcItem, destItem)) return
1837
+ const { destStat } = stat.checkPathsSync(srcItem, destItem, 'copy', opts);
1838
+ return getStats(destStat, srcItem, destItem, opts)
1839
+ }
1840
+
1841
+ function onLink (destStat, src, dest, opts) {
1842
+ let resolvedSrc = fs.readlinkSync(src);
1843
+ if (opts.dereference) {
1844
+ resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
1845
+ }
1846
+
1847
+ if (!destStat) {
1848
+ return fs.symlinkSync(resolvedSrc, dest)
1849
+ } else {
1850
+ let resolvedDest;
1851
+ try {
1852
+ resolvedDest = fs.readlinkSync(dest);
1853
+ } catch (err) {
1854
+ // dest exists and is a regular file or directory,
1855
+ // Windows may throw UNKNOWN error. If dest already exists,
1856
+ // fs throws error anyway, so no need to guard against it here.
1857
+ if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlinkSync(resolvedSrc, dest)
1858
+ throw err
1859
+ }
1860
+ if (opts.dereference) {
1861
+ resolvedDest = path.resolve(process.cwd(), resolvedDest);
1862
+ }
1863
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1864
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
1865
+ }
1866
+
1867
+ // prevent copy if src is a subdir of dest since unlinking
1868
+ // dest in this case would result in removing src contents
1869
+ // and therefore a broken symlink would be created.
1870
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1871
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
1872
+ }
1873
+ return copyLink(resolvedSrc, dest)
1874
+ }
1875
+ }
1876
+
1877
+ function copyLink (resolvedSrc, dest) {
1878
+ fs.unlinkSync(dest);
1879
+ return fs.symlinkSync(resolvedSrc, dest)
1880
+ }
1881
+
1882
+ copySync_1 = copySync;
1883
+ return copySync_1;
1884
+ }
1885
+
1886
+ var copy;
1887
+ var hasRequiredCopy;
1888
+
1889
+ function requireCopy () {
1890
+ if (hasRequiredCopy) return copy;
1891
+ hasRequiredCopy = 1;
1892
+
1893
+ const u = requireUniversalify().fromPromise;
1894
+ copy = {
1895
+ copy: u(/*@__PURE__*/ requireCopy$1()),
1896
+ copySync: /*@__PURE__*/ requireCopySync()
1897
+ };
1898
+ return copy;
1899
+ }
1900
+
1901
+ var remove_1;
1902
+ var hasRequiredRemove;
1903
+
1904
+ function requireRemove () {
1905
+ if (hasRequiredRemove) return remove_1;
1906
+ hasRequiredRemove = 1;
1907
+
1908
+ const fs = requireGracefulFs();
1909
+ const u = requireUniversalify().fromCallback;
1910
+
1911
+ function remove (path, callback) {
1912
+ fs.rm(path, { recursive: true, force: true }, callback);
1913
+ }
1914
+
1915
+ function removeSync (path) {
1916
+ fs.rmSync(path, { recursive: true, force: true });
1917
+ }
1918
+
1919
+ remove_1 = {
1920
+ remove: u(remove),
1921
+ removeSync
1922
+ };
1923
+ return remove_1;
1924
+ }
1925
+
1926
+ var empty;
1927
+ var hasRequiredEmpty;
1928
+
1929
+ function requireEmpty () {
1930
+ if (hasRequiredEmpty) return empty;
1931
+ hasRequiredEmpty = 1;
1932
+
1933
+ const u = requireUniversalify().fromPromise;
1934
+ const fs = /*@__PURE__*/ requireFs();
1935
+ const path = require$$1__default["default"];
1936
+ const mkdir = /*@__PURE__*/ requireMkdirs();
1937
+ const remove = /*@__PURE__*/ requireRemove();
1938
+
1939
+ const emptyDir = u(async function emptyDir (dir) {
1940
+ let items;
1941
+ try {
1942
+ items = await fs.readdir(dir);
1943
+ } catch {
1944
+ return mkdir.mkdirs(dir)
1945
+ }
1946
+
1947
+ return Promise.all(items.map(item => remove.remove(path.join(dir, item))))
1948
+ });
1949
+
1950
+ function emptyDirSync (dir) {
1951
+ let items;
1952
+ try {
1953
+ items = fs.readdirSync(dir);
1954
+ } catch {
1955
+ return mkdir.mkdirsSync(dir)
1956
+ }
1957
+
1958
+ items.forEach(item => {
1959
+ item = path.join(dir, item);
1960
+ remove.removeSync(item);
1961
+ });
1962
+ }
1963
+
1964
+ empty = {
1965
+ emptyDirSync,
1966
+ emptydirSync: emptyDirSync,
1967
+ emptyDir,
1968
+ emptydir: emptyDir
1969
+ };
1970
+ return empty;
1971
+ }
1972
+
1973
+ var file;
1974
+ var hasRequiredFile;
1975
+
1976
+ function requireFile () {
1977
+ if (hasRequiredFile) return file;
1978
+ hasRequiredFile = 1;
1979
+
1980
+ const u = requireUniversalify().fromPromise;
1981
+ const path = require$$1__default["default"];
1982
+ const fs = /*@__PURE__*/ requireFs();
1983
+ const mkdir = /*@__PURE__*/ requireMkdirs();
1984
+
1985
+ async function createFile (file) {
1986
+ let stats;
1987
+ try {
1988
+ stats = await fs.stat(file);
1989
+ } catch { }
1990
+ if (stats && stats.isFile()) return
1991
+
1992
+ const dir = path.dirname(file);
1993
+
1994
+ let dirStats = null;
1995
+ try {
1996
+ dirStats = await fs.stat(dir);
1997
+ } catch (err) {
1998
+ // if the directory doesn't exist, make it
1999
+ if (err.code === 'ENOENT') {
2000
+ await mkdir.mkdirs(dir);
2001
+ await fs.writeFile(file, '');
2002
+ return
2003
+ } else {
2004
+ throw err
2005
+ }
2006
+ }
2007
+
2008
+ if (dirStats.isDirectory()) {
2009
+ await fs.writeFile(file, '');
2010
+ } else {
2011
+ // parent is not a directory
2012
+ // This is just to cause an internal ENOTDIR error to be thrown
2013
+ await fs.readdir(dir);
2014
+ }
2015
+ }
2016
+
2017
+ function createFileSync (file) {
2018
+ let stats;
2019
+ try {
2020
+ stats = fs.statSync(file);
2021
+ } catch { }
2022
+ if (stats && stats.isFile()) return
2023
+
2024
+ const dir = path.dirname(file);
2025
+ try {
2026
+ if (!fs.statSync(dir).isDirectory()) {
2027
+ // parent is not a directory
2028
+ // This is just to cause an internal ENOTDIR error to be thrown
2029
+ fs.readdirSync(dir);
2030
+ }
2031
+ } catch (err) {
2032
+ // If the stat call above failed because the directory doesn't exist, create it
2033
+ if (err && err.code === 'ENOENT') mkdir.mkdirsSync(dir);
2034
+ else throw err
2035
+ }
2036
+
2037
+ fs.writeFileSync(file, '');
2038
+ }
2039
+
2040
+ file = {
2041
+ createFile: u(createFile),
2042
+ createFileSync
2043
+ };
2044
+ return file;
2045
+ }
2046
+
2047
+ var link;
2048
+ var hasRequiredLink;
2049
+
2050
+ function requireLink () {
2051
+ if (hasRequiredLink) return link;
2052
+ hasRequiredLink = 1;
2053
+
2054
+ const u = requireUniversalify().fromPromise;
2055
+ const path = require$$1__default["default"];
2056
+ const fs = /*@__PURE__*/ requireFs();
2057
+ const mkdir = /*@__PURE__*/ requireMkdirs();
2058
+ const { pathExists } = /*@__PURE__*/ requirePathExists();
2059
+ const { areIdentical } = /*@__PURE__*/ requireStat();
2060
+
2061
+ async function createLink (srcpath, dstpath) {
2062
+ let dstStat;
2063
+ try {
2064
+ dstStat = await fs.lstat(dstpath);
2065
+ } catch {
2066
+ // ignore error
2067
+ }
2068
+
2069
+ let srcStat;
2070
+ try {
2071
+ srcStat = await fs.lstat(srcpath);
2072
+ } catch (err) {
2073
+ err.message = err.message.replace('lstat', 'ensureLink');
2074
+ throw err
2075
+ }
2076
+
2077
+ if (dstStat && areIdentical(srcStat, dstStat)) return
2078
+
2079
+ const dir = path.dirname(dstpath);
2080
+
2081
+ const dirExists = await pathExists(dir);
2082
+
2083
+ if (!dirExists) {
2084
+ await mkdir.mkdirs(dir);
2085
+ }
2086
+
2087
+ await fs.link(srcpath, dstpath);
2088
+ }
2089
+
2090
+ function createLinkSync (srcpath, dstpath) {
2091
+ let dstStat;
2092
+ try {
2093
+ dstStat = fs.lstatSync(dstpath);
2094
+ } catch {}
2095
+
2096
+ try {
2097
+ const srcStat = fs.lstatSync(srcpath);
2098
+ if (dstStat && areIdentical(srcStat, dstStat)) return
2099
+ } catch (err) {
2100
+ err.message = err.message.replace('lstat', 'ensureLink');
2101
+ throw err
2102
+ }
2103
+
2104
+ const dir = path.dirname(dstpath);
2105
+ const dirExists = fs.existsSync(dir);
2106
+ if (dirExists) return fs.linkSync(srcpath, dstpath)
2107
+ mkdir.mkdirsSync(dir);
2108
+
2109
+ return fs.linkSync(srcpath, dstpath)
2110
+ }
2111
+
2112
+ link = {
2113
+ createLink: u(createLink),
2114
+ createLinkSync
2115
+ };
2116
+ return link;
2117
+ }
2118
+
2119
+ var symlinkPaths_1;
2120
+ var hasRequiredSymlinkPaths;
2121
+
2122
+ function requireSymlinkPaths () {
2123
+ if (hasRequiredSymlinkPaths) return symlinkPaths_1;
2124
+ hasRequiredSymlinkPaths = 1;
2125
+
2126
+ const path = require$$1__default["default"];
2127
+ const fs = /*@__PURE__*/ requireFs();
2128
+ const { pathExists } = /*@__PURE__*/ requirePathExists();
2129
+
2130
+ const u = requireUniversalify().fromPromise;
2131
+
2132
+ /**
2133
+ * Function that returns two types of paths, one relative to symlink, and one
2134
+ * relative to the current working directory. Checks if path is absolute or
2135
+ * relative. If the path is relative, this function checks if the path is
2136
+ * relative to symlink or relative to current working directory. This is an
2137
+ * initiative to find a smarter `srcpath` to supply when building symlinks.
2138
+ * This allows you to determine which path to use out of one of three possible
2139
+ * types of source paths. The first is an absolute path. This is detected by
2140
+ * `path.isAbsolute()`. When an absolute path is provided, it is checked to
2141
+ * see if it exists. If it does it's used, if not an error is returned
2142
+ * (callback)/ thrown (sync). The other two options for `srcpath` are a
2143
+ * relative url. By default Node's `fs.symlink` works by creating a symlink
2144
+ * using `dstpath` and expects the `srcpath` to be relative to the newly
2145
+ * created symlink. If you provide a `srcpath` that does not exist on the file
2146
+ * system it results in a broken symlink. To minimize this, the function
2147
+ * checks to see if the 'relative to symlink' source file exists, and if it
2148
+ * does it will use it. If it does not, it checks if there's a file that
2149
+ * exists that is relative to the current working directory, if does its used.
2150
+ * This preserves the expectations of the original fs.symlink spec and adds
2151
+ * the ability to pass in `relative to current working direcotry` paths.
2152
+ */
2153
+
2154
+ async function symlinkPaths (srcpath, dstpath) {
2155
+ if (path.isAbsolute(srcpath)) {
2156
+ try {
2157
+ await fs.lstat(srcpath);
2158
+ } catch (err) {
2159
+ err.message = err.message.replace('lstat', 'ensureSymlink');
2160
+ throw err
2161
+ }
2162
+
2163
+ return {
2164
+ toCwd: srcpath,
2165
+ toDst: srcpath
2166
+ }
2167
+ }
2168
+
2169
+ const dstdir = path.dirname(dstpath);
2170
+ const relativeToDst = path.join(dstdir, srcpath);
2171
+
2172
+ const exists = await pathExists(relativeToDst);
2173
+ if (exists) {
2174
+ return {
2175
+ toCwd: relativeToDst,
2176
+ toDst: srcpath
2177
+ }
2178
+ }
2179
+
2180
+ try {
2181
+ await fs.lstat(srcpath);
2182
+ } catch (err) {
2183
+ err.message = err.message.replace('lstat', 'ensureSymlink');
2184
+ throw err
2185
+ }
2186
+
2187
+ return {
2188
+ toCwd: srcpath,
2189
+ toDst: path.relative(dstdir, srcpath)
2190
+ }
2191
+ }
2192
+
2193
+ function symlinkPathsSync (srcpath, dstpath) {
2194
+ if (path.isAbsolute(srcpath)) {
2195
+ const exists = fs.existsSync(srcpath);
2196
+ if (!exists) throw new Error('absolute srcpath does not exist')
2197
+ return {
2198
+ toCwd: srcpath,
2199
+ toDst: srcpath
2200
+ }
2201
+ }
2202
+
2203
+ const dstdir = path.dirname(dstpath);
2204
+ const relativeToDst = path.join(dstdir, srcpath);
2205
+ const exists = fs.existsSync(relativeToDst);
2206
+ if (exists) {
2207
+ return {
2208
+ toCwd: relativeToDst,
2209
+ toDst: srcpath
2210
+ }
2211
+ }
2212
+
2213
+ const srcExists = fs.existsSync(srcpath);
2214
+ if (!srcExists) throw new Error('relative srcpath does not exist')
2215
+ return {
2216
+ toCwd: srcpath,
2217
+ toDst: path.relative(dstdir, srcpath)
2218
+ }
2219
+ }
2220
+
2221
+ symlinkPaths_1 = {
2222
+ symlinkPaths: u(symlinkPaths),
2223
+ symlinkPathsSync
2224
+ };
2225
+ return symlinkPaths_1;
2226
+ }
2227
+
2228
+ var symlinkType_1;
2229
+ var hasRequiredSymlinkType;
2230
+
2231
+ function requireSymlinkType () {
2232
+ if (hasRequiredSymlinkType) return symlinkType_1;
2233
+ hasRequiredSymlinkType = 1;
2234
+
2235
+ const fs = /*@__PURE__*/ requireFs();
2236
+ const u = requireUniversalify().fromPromise;
2237
+
2238
+ async function symlinkType (srcpath, type) {
2239
+ if (type) return type
2240
+
2241
+ let stats;
2242
+ try {
2243
+ stats = await fs.lstat(srcpath);
2244
+ } catch {
2245
+ return 'file'
2246
+ }
2247
+
2248
+ return (stats && stats.isDirectory()) ? 'dir' : 'file'
2249
+ }
2250
+
2251
+ function symlinkTypeSync (srcpath, type) {
2252
+ if (type) return type
2253
+
2254
+ let stats;
2255
+ try {
2256
+ stats = fs.lstatSync(srcpath);
2257
+ } catch {
2258
+ return 'file'
2259
+ }
2260
+ return (stats && stats.isDirectory()) ? 'dir' : 'file'
2261
+ }
2262
+
2263
+ symlinkType_1 = {
2264
+ symlinkType: u(symlinkType),
2265
+ symlinkTypeSync
2266
+ };
2267
+ return symlinkType_1;
2268
+ }
2269
+
2270
+ var symlink;
2271
+ var hasRequiredSymlink;
2272
+
2273
+ function requireSymlink () {
2274
+ if (hasRequiredSymlink) return symlink;
2275
+ hasRequiredSymlink = 1;
2276
+
2277
+ const u = requireUniversalify().fromPromise;
2278
+ const path = require$$1__default["default"];
2279
+ const fs = /*@__PURE__*/ requireFs();
2280
+
2281
+ const { mkdirs, mkdirsSync } = /*@__PURE__*/ requireMkdirs();
2282
+
2283
+ const { symlinkPaths, symlinkPathsSync } = /*@__PURE__*/ requireSymlinkPaths();
2284
+ const { symlinkType, symlinkTypeSync } = /*@__PURE__*/ requireSymlinkType();
2285
+
2286
+ const { pathExists } = /*@__PURE__*/ requirePathExists();
2287
+
2288
+ const { areIdentical } = /*@__PURE__*/ requireStat();
2289
+
2290
+ async function createSymlink (srcpath, dstpath, type) {
2291
+ let stats;
2292
+ try {
2293
+ stats = await fs.lstat(dstpath);
2294
+ } catch { }
2295
+
2296
+ if (stats && stats.isSymbolicLink()) {
2297
+ const [srcStat, dstStat] = await Promise.all([
2298
+ fs.stat(srcpath),
2299
+ fs.stat(dstpath)
2300
+ ]);
2301
+
2302
+ if (areIdentical(srcStat, dstStat)) return
2303
+ }
2304
+
2305
+ const relative = await symlinkPaths(srcpath, dstpath);
2306
+ srcpath = relative.toDst;
2307
+ const toType = await symlinkType(relative.toCwd, type);
2308
+ const dir = path.dirname(dstpath);
2309
+
2310
+ if (!(await pathExists(dir))) {
2311
+ await mkdirs(dir);
2312
+ }
2313
+
2314
+ return fs.symlink(srcpath, dstpath, toType)
2315
+ }
2316
+
2317
+ function createSymlinkSync (srcpath, dstpath, type) {
2318
+ let stats;
2319
+ try {
2320
+ stats = fs.lstatSync(dstpath);
2321
+ } catch { }
2322
+ if (stats && stats.isSymbolicLink()) {
2323
+ const srcStat = fs.statSync(srcpath);
2324
+ const dstStat = fs.statSync(dstpath);
2325
+ if (areIdentical(srcStat, dstStat)) return
2326
+ }
2327
+
2328
+ const relative = symlinkPathsSync(srcpath, dstpath);
2329
+ srcpath = relative.toDst;
2330
+ type = symlinkTypeSync(relative.toCwd, type);
2331
+ const dir = path.dirname(dstpath);
2332
+ const exists = fs.existsSync(dir);
2333
+ if (exists) return fs.symlinkSync(srcpath, dstpath, type)
2334
+ mkdirsSync(dir);
2335
+ return fs.symlinkSync(srcpath, dstpath, type)
2336
+ }
2337
+
2338
+ symlink = {
2339
+ createSymlink: u(createSymlink),
2340
+ createSymlinkSync
2341
+ };
2342
+ return symlink;
2343
+ }
2344
+
2345
+ var ensure;
2346
+ var hasRequiredEnsure;
2347
+
2348
+ function requireEnsure () {
2349
+ if (hasRequiredEnsure) return ensure;
2350
+ hasRequiredEnsure = 1;
2351
+
2352
+ const { createFile, createFileSync } = /*@__PURE__*/ requireFile();
2353
+ const { createLink, createLinkSync } = /*@__PURE__*/ requireLink();
2354
+ const { createSymlink, createSymlinkSync } = /*@__PURE__*/ requireSymlink();
2355
+
2356
+ ensure = {
2357
+ // file
2358
+ createFile,
2359
+ createFileSync,
2360
+ ensureFile: createFile,
2361
+ ensureFileSync: createFileSync,
2362
+ // link
2363
+ createLink,
2364
+ createLinkSync,
2365
+ ensureLink: createLink,
2366
+ ensureLinkSync: createLinkSync,
2367
+ // symlink
2368
+ createSymlink,
2369
+ createSymlinkSync,
2370
+ ensureSymlink: createSymlink,
2371
+ ensureSymlinkSync: createSymlinkSync
2372
+ };
2373
+ return ensure;
2374
+ }
2375
+
2376
+ var utils;
2377
+ var hasRequiredUtils;
2378
+
2379
+ function requireUtils () {
2380
+ if (hasRequiredUtils) return utils;
2381
+ hasRequiredUtils = 1;
2382
+ function stringify (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
2383
+ const EOF = finalEOL ? EOL : '';
2384
+ const str = JSON.stringify(obj, replacer, spaces);
2385
+
2386
+ return str.replace(/\n/g, EOL) + EOF
2387
+ }
2388
+
2389
+ function stripBom (content) {
2390
+ // we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
2391
+ if (Buffer.isBuffer(content)) content = content.toString('utf8');
2392
+ return content.replace(/^\uFEFF/, '')
2393
+ }
2394
+
2395
+ utils = { stringify, stripBom };
2396
+ return utils;
2397
+ }
2398
+
2399
+ var jsonfile_1;
2400
+ var hasRequiredJsonfile$1;
2401
+
2402
+ function requireJsonfile$1 () {
2403
+ if (hasRequiredJsonfile$1) return jsonfile_1;
2404
+ hasRequiredJsonfile$1 = 1;
2405
+ let _fs;
2406
+ try {
2407
+ _fs = requireGracefulFs();
2408
+ } catch (_) {
2409
+ _fs = require$$0__default$2["default"];
2410
+ }
2411
+ const universalify = requireUniversalify();
2412
+ const { stringify, stripBom } = requireUtils();
2413
+
2414
+ async function _readFile (file, options = {}) {
2415
+ if (typeof options === 'string') {
2416
+ options = { encoding: options };
2417
+ }
2418
+
2419
+ const fs = options.fs || _fs;
2420
+
2421
+ const shouldThrow = 'throws' in options ? options.throws : true;
2422
+
2423
+ let data = await universalify.fromCallback(fs.readFile)(file, options);
2424
+
2425
+ data = stripBom(data);
2426
+
2427
+ let obj;
2428
+ try {
2429
+ obj = JSON.parse(data, options ? options.reviver : null);
2430
+ } catch (err) {
2431
+ if (shouldThrow) {
2432
+ err.message = `${file}: ${err.message}`;
2433
+ throw err
2434
+ } else {
2435
+ return null
2436
+ }
2437
+ }
2438
+
2439
+ return obj
2440
+ }
2441
+
2442
+ const readFile = universalify.fromPromise(_readFile);
2443
+
2444
+ function readFileSync (file, options = {}) {
2445
+ if (typeof options === 'string') {
2446
+ options = { encoding: options };
2447
+ }
2448
+
2449
+ const fs = options.fs || _fs;
2450
+
2451
+ const shouldThrow = 'throws' in options ? options.throws : true;
2452
+
2453
+ try {
2454
+ let content = fs.readFileSync(file, options);
2455
+ content = stripBom(content);
2456
+ return JSON.parse(content, options.reviver)
2457
+ } catch (err) {
2458
+ if (shouldThrow) {
2459
+ err.message = `${file}: ${err.message}`;
2460
+ throw err
2461
+ } else {
2462
+ return null
2463
+ }
2464
+ }
2465
+ }
2466
+
2467
+ async function _writeFile (file, obj, options = {}) {
2468
+ const fs = options.fs || _fs;
2469
+
2470
+ const str = stringify(obj, options);
2471
+
2472
+ await universalify.fromCallback(fs.writeFile)(file, str, options);
2473
+ }
2474
+
2475
+ const writeFile = universalify.fromPromise(_writeFile);
2476
+
2477
+ function writeFileSync (file, obj, options = {}) {
2478
+ const fs = options.fs || _fs;
2479
+
2480
+ const str = stringify(obj, options);
2481
+ // not sure if fs.writeFileSync returns anything, but just in case
2482
+ return fs.writeFileSync(file, str, options)
2483
+ }
2484
+
2485
+ const jsonfile = {
2486
+ readFile,
2487
+ readFileSync,
2488
+ writeFile,
2489
+ writeFileSync
2490
+ };
2491
+
2492
+ jsonfile_1 = jsonfile;
2493
+ return jsonfile_1;
2494
+ }
2495
+
2496
+ var jsonfile;
2497
+ var hasRequiredJsonfile;
2498
+
2499
+ function requireJsonfile () {
2500
+ if (hasRequiredJsonfile) return jsonfile;
2501
+ hasRequiredJsonfile = 1;
2502
+
2503
+ const jsonFile = requireJsonfile$1();
2504
+
2505
+ jsonfile = {
2506
+ // jsonfile exports
2507
+ readJson: jsonFile.readFile,
2508
+ readJsonSync: jsonFile.readFileSync,
2509
+ writeJson: jsonFile.writeFile,
2510
+ writeJsonSync: jsonFile.writeFileSync
2511
+ };
2512
+ return jsonfile;
2513
+ }
2514
+
2515
+ var outputFile_1;
2516
+ var hasRequiredOutputFile;
2517
+
2518
+ function requireOutputFile () {
2519
+ if (hasRequiredOutputFile) return outputFile_1;
2520
+ hasRequiredOutputFile = 1;
2521
+
2522
+ const u = requireUniversalify().fromPromise;
2523
+ const fs = /*@__PURE__*/ requireFs();
2524
+ const path = require$$1__default["default"];
2525
+ const mkdir = /*@__PURE__*/ requireMkdirs();
2526
+ const pathExists = /*@__PURE__*/ requirePathExists().pathExists;
2527
+
2528
+ async function outputFile (file, data, encoding = 'utf-8') {
2529
+ const dir = path.dirname(file);
2530
+
2531
+ if (!(await pathExists(dir))) {
2532
+ await mkdir.mkdirs(dir);
2533
+ }
2534
+
2535
+ return fs.writeFile(file, data, encoding)
2536
+ }
2537
+
2538
+ function outputFileSync (file, ...args) {
2539
+ const dir = path.dirname(file);
2540
+ if (!fs.existsSync(dir)) {
2541
+ mkdir.mkdirsSync(dir);
2542
+ }
2543
+
2544
+ fs.writeFileSync(file, ...args);
2545
+ }
2546
+
2547
+ outputFile_1 = {
2548
+ outputFile: u(outputFile),
2549
+ outputFileSync
2550
+ };
2551
+ return outputFile_1;
2552
+ }
2553
+
2554
+ var outputJson_1;
2555
+ var hasRequiredOutputJson;
2556
+
2557
+ function requireOutputJson () {
2558
+ if (hasRequiredOutputJson) return outputJson_1;
2559
+ hasRequiredOutputJson = 1;
2560
+
2561
+ const { stringify } = requireUtils();
2562
+ const { outputFile } = /*@__PURE__*/ requireOutputFile();
2563
+
2564
+ async function outputJson (file, data, options = {}) {
2565
+ const str = stringify(data, options);
2566
+
2567
+ await outputFile(file, str, options);
2568
+ }
2569
+
2570
+ outputJson_1 = outputJson;
2571
+ return outputJson_1;
2572
+ }
2573
+
2574
+ var outputJsonSync_1;
2575
+ var hasRequiredOutputJsonSync;
2576
+
2577
+ function requireOutputJsonSync () {
2578
+ if (hasRequiredOutputJsonSync) return outputJsonSync_1;
2579
+ hasRequiredOutputJsonSync = 1;
2580
+
2581
+ const { stringify } = requireUtils();
2582
+ const { outputFileSync } = /*@__PURE__*/ requireOutputFile();
2583
+
2584
+ function outputJsonSync (file, data, options) {
2585
+ const str = stringify(data, options);
2586
+
2587
+ outputFileSync(file, str, options);
2588
+ }
2589
+
2590
+ outputJsonSync_1 = outputJsonSync;
2591
+ return outputJsonSync_1;
2592
+ }
2593
+
2594
+ var json;
2595
+ var hasRequiredJson;
2596
+
2597
+ function requireJson () {
2598
+ if (hasRequiredJson) return json;
2599
+ hasRequiredJson = 1;
2600
+
2601
+ const u = requireUniversalify().fromPromise;
2602
+ const jsonFile = /*@__PURE__*/ requireJsonfile();
2603
+
2604
+ jsonFile.outputJson = u(/*@__PURE__*/ requireOutputJson());
2605
+ jsonFile.outputJsonSync = /*@__PURE__*/ requireOutputJsonSync();
2606
+ // aliases
2607
+ jsonFile.outputJSON = jsonFile.outputJson;
2608
+ jsonFile.outputJSONSync = jsonFile.outputJsonSync;
2609
+ jsonFile.writeJSON = jsonFile.writeJson;
2610
+ jsonFile.writeJSONSync = jsonFile.writeJsonSync;
2611
+ jsonFile.readJSON = jsonFile.readJson;
2612
+ jsonFile.readJSONSync = jsonFile.readJsonSync;
2613
+
2614
+ json = jsonFile;
2615
+ return json;
2616
+ }
2617
+
2618
+ var move_1;
2619
+ var hasRequiredMove$1;
2620
+
2621
+ function requireMove$1 () {
2622
+ if (hasRequiredMove$1) return move_1;
2623
+ hasRequiredMove$1 = 1;
2624
+
2625
+ const fs = /*@__PURE__*/ requireFs();
2626
+ const path = require$$1__default["default"];
2627
+ const { copy } = /*@__PURE__*/ requireCopy();
2628
+ const { remove } = /*@__PURE__*/ requireRemove();
2629
+ const { mkdirp } = /*@__PURE__*/ requireMkdirs();
2630
+ const { pathExists } = /*@__PURE__*/ requirePathExists();
2631
+ const stat = /*@__PURE__*/ requireStat();
2632
+
2633
+ async function move (src, dest, opts = {}) {
2634
+ const overwrite = opts.overwrite || opts.clobber || false;
2635
+
2636
+ const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, 'move', opts);
2637
+
2638
+ await stat.checkParentPaths(src, srcStat, dest, 'move');
2639
+
2640
+ // If the parent of dest is not root, make sure it exists before proceeding
2641
+ const destParent = path.dirname(dest);
2642
+ const parsedParentPath = path.parse(destParent);
2643
+ if (parsedParentPath.root !== destParent) {
2644
+ await mkdirp(destParent);
2645
+ }
2646
+
2647
+ return doRename(src, dest, overwrite, isChangingCase)
2648
+ }
2649
+
2650
+ async function doRename (src, dest, overwrite, isChangingCase) {
2651
+ if (!isChangingCase) {
2652
+ if (overwrite) {
2653
+ await remove(dest);
2654
+ } else if (await pathExists(dest)) {
2655
+ throw new Error('dest already exists.')
2656
+ }
2657
+ }
2658
+
2659
+ try {
2660
+ // Try w/ rename first, and try copy + remove if EXDEV
2661
+ await fs.rename(src, dest);
2662
+ } catch (err) {
2663
+ if (err.code !== 'EXDEV') {
2664
+ throw err
2665
+ }
2666
+ await moveAcrossDevice(src, dest, overwrite);
2667
+ }
2668
+ }
2669
+
2670
+ async function moveAcrossDevice (src, dest, overwrite) {
2671
+ const opts = {
2672
+ overwrite,
2673
+ errorOnExist: true,
2674
+ preserveTimestamps: true
2675
+ };
2676
+
2677
+ await copy(src, dest, opts);
2678
+ return remove(src)
2679
+ }
2680
+
2681
+ move_1 = move;
2682
+ return move_1;
2683
+ }
2684
+
2685
+ var moveSync_1;
2686
+ var hasRequiredMoveSync;
2687
+
2688
+ function requireMoveSync () {
2689
+ if (hasRequiredMoveSync) return moveSync_1;
2690
+ hasRequiredMoveSync = 1;
2691
+
2692
+ const fs = requireGracefulFs();
2693
+ const path = require$$1__default["default"];
2694
+ const copySync = /*@__PURE__*/ requireCopy().copySync;
2695
+ const removeSync = /*@__PURE__*/ requireRemove().removeSync;
2696
+ const mkdirpSync = /*@__PURE__*/ requireMkdirs().mkdirpSync;
2697
+ const stat = /*@__PURE__*/ requireStat();
2698
+
2699
+ function moveSync (src, dest, opts) {
2700
+ opts = opts || {};
2701
+ const overwrite = opts.overwrite || opts.clobber || false;
2702
+
2703
+ const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts);
2704
+ stat.checkParentPathsSync(src, srcStat, dest, 'move');
2705
+ if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest));
2706
+ return doRename(src, dest, overwrite, isChangingCase)
2707
+ }
2708
+
2709
+ function isParentRoot (dest) {
2710
+ const parent = path.dirname(dest);
2711
+ const parsedPath = path.parse(parent);
2712
+ return parsedPath.root === parent
2713
+ }
2714
+
2715
+ function doRename (src, dest, overwrite, isChangingCase) {
2716
+ if (isChangingCase) return rename(src, dest, overwrite)
2717
+ if (overwrite) {
2718
+ removeSync(dest);
2719
+ return rename(src, dest, overwrite)
2720
+ }
2721
+ if (fs.existsSync(dest)) throw new Error('dest already exists.')
2722
+ return rename(src, dest, overwrite)
2723
+ }
2724
+
2725
+ function rename (src, dest, overwrite) {
2726
+ try {
2727
+ fs.renameSync(src, dest);
2728
+ } catch (err) {
2729
+ if (err.code !== 'EXDEV') throw err
2730
+ return moveAcrossDevice(src, dest, overwrite)
2731
+ }
2732
+ }
2733
+
2734
+ function moveAcrossDevice (src, dest, overwrite) {
2735
+ const opts = {
2736
+ overwrite,
2737
+ errorOnExist: true,
2738
+ preserveTimestamps: true
2739
+ };
2740
+ copySync(src, dest, opts);
2741
+ return removeSync(src)
2742
+ }
2743
+
2744
+ moveSync_1 = moveSync;
2745
+ return moveSync_1;
2746
+ }
2747
+
2748
+ var move;
2749
+ var hasRequiredMove;
2750
+
2751
+ function requireMove () {
2752
+ if (hasRequiredMove) return move;
2753
+ hasRequiredMove = 1;
2754
+
2755
+ const u = requireUniversalify().fromPromise;
2756
+ move = {
2757
+ move: u(/*@__PURE__*/ requireMove$1()),
2758
+ moveSync: /*@__PURE__*/ requireMoveSync()
2759
+ };
2760
+ return move;
2761
+ }
2762
+
2763
+ var lib;
2764
+ var hasRequiredLib;
2765
+
2766
+ function requireLib () {
2767
+ if (hasRequiredLib) return lib;
2768
+ hasRequiredLib = 1;
2769
+
2770
+ lib = {
2771
+ // Export promiseified graceful-fs:
2772
+ .../*@__PURE__*/ requireFs(),
2773
+ // Export extra methods:
2774
+ .../*@__PURE__*/ requireCopy(),
2775
+ .../*@__PURE__*/ requireEmpty(),
2776
+ .../*@__PURE__*/ requireEnsure(),
2777
+ .../*@__PURE__*/ requireJson(),
2778
+ .../*@__PURE__*/ requireMkdirs(),
2779
+ .../*@__PURE__*/ requireMove(),
2780
+ .../*@__PURE__*/ requireOutputFile(),
2781
+ .../*@__PURE__*/ requirePathExists(),
2782
+ .../*@__PURE__*/ requireRemove()
2783
+ };
2784
+ return lib;
2785
+ }
2786
+
2787
+ var libExports = /*@__PURE__*/ requireLib();
2788
+ var fs = /*@__PURE__*/getDefaultExportFromCjs(libExports);
2789
+
2790
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2791
+ function normalizeWindowsPath(input = "") {
2792
+ if (!input) {
2793
+ return input;
2794
+ }
2795
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
2796
+ }
2797
+
2798
+ const _UNC_REGEX = /^[/\\]{2}/;
2799
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
2800
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
2801
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
2802
+ const sep = "/";
2803
+ const delimiter = ":";
2804
+ const normalize = function(path) {
2805
+ if (path.length === 0) {
2806
+ return ".";
2807
+ }
2808
+ path = normalizeWindowsPath(path);
2809
+ const isUNCPath = path.match(_UNC_REGEX);
2810
+ const isPathAbsolute = isAbsolute(path);
2811
+ const trailingSeparator = path[path.length - 1] === "/";
2812
+ path = normalizeString(path, !isPathAbsolute);
2813
+ if (path.length === 0) {
2814
+ if (isPathAbsolute) {
2815
+ return "/";
2816
+ }
2817
+ return trailingSeparator ? "./" : ".";
2818
+ }
2819
+ if (trailingSeparator) {
2820
+ path += "/";
2821
+ }
2822
+ if (_DRIVE_LETTER_RE.test(path)) {
2823
+ path += "/";
2824
+ }
2825
+ if (isUNCPath) {
2826
+ if (!isPathAbsolute) {
2827
+ return `//./${path}`;
2828
+ }
2829
+ return `//${path}`;
2830
+ }
2831
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
2832
+ };
2833
+ const join = function(...arguments_) {
2834
+ if (arguments_.length === 0) {
2835
+ return ".";
2836
+ }
2837
+ let joined;
2838
+ for (const argument of arguments_) {
2839
+ if (argument && argument.length > 0) {
2840
+ if (joined === void 0) {
2841
+ joined = argument;
2842
+ } else {
2843
+ joined += `/${argument}`;
2844
+ }
2845
+ }
2846
+ }
2847
+ if (joined === void 0) {
2848
+ return ".";
2849
+ }
2850
+ return normalize(joined.replace(/\/\/+/g, "/"));
2851
+ };
2852
+ function cwd() {
2853
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
2854
+ return process.cwd().replace(/\\/g, "/");
2855
+ }
2856
+ return "/";
2857
+ }
2858
+ const resolve = function(...arguments_) {
2859
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
2860
+ let resolvedPath = "";
2861
+ let resolvedAbsolute = false;
2862
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
2863
+ const path = index >= 0 ? arguments_[index] : cwd();
2864
+ if (!path || path.length === 0) {
2865
+ continue;
2866
+ }
2867
+ resolvedPath = `${path}/${resolvedPath}`;
2868
+ resolvedAbsolute = isAbsolute(path);
2869
+ }
2870
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
2871
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
2872
+ return `/${resolvedPath}`;
2873
+ }
2874
+ return resolvedPath.length > 0 ? resolvedPath : ".";
2875
+ };
2876
+ function normalizeString(path, allowAboveRoot) {
2877
+ let res = "";
2878
+ let lastSegmentLength = 0;
2879
+ let lastSlash = -1;
2880
+ let dots = 0;
2881
+ let char = null;
2882
+ for (let index = 0; index <= path.length; ++index) {
2883
+ if (index < path.length) {
2884
+ char = path[index];
2885
+ } else if (char === "/") {
2886
+ break;
2887
+ } else {
2888
+ char = "/";
2889
+ }
2890
+ if (char === "/") {
2891
+ if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
2892
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
2893
+ if (res.length > 2) {
2894
+ const lastSlashIndex = res.lastIndexOf("/");
2895
+ if (lastSlashIndex === -1) {
2896
+ res = "";
2897
+ lastSegmentLength = 0;
2898
+ } else {
2899
+ res = res.slice(0, lastSlashIndex);
2900
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
2901
+ }
2902
+ lastSlash = index;
2903
+ dots = 0;
2904
+ continue;
2905
+ } else if (res.length > 0) {
2906
+ res = "";
2907
+ lastSegmentLength = 0;
2908
+ lastSlash = index;
2909
+ dots = 0;
2910
+ continue;
2911
+ }
2912
+ }
2913
+ if (allowAboveRoot) {
2914
+ res += res.length > 0 ? "/.." : "..";
2915
+ lastSegmentLength = 2;
2916
+ }
2917
+ } else {
2918
+ if (res.length > 0) {
2919
+ res += `/${path.slice(lastSlash + 1, index)}`;
2920
+ } else {
2921
+ res = path.slice(lastSlash + 1, index);
2922
+ }
2923
+ lastSegmentLength = index - lastSlash - 1;
2924
+ }
2925
+ lastSlash = index;
2926
+ dots = 0;
2927
+ } else if (char === "." && dots !== -1) {
2928
+ ++dots;
2929
+ } else {
2930
+ dots = -1;
2931
+ }
2932
+ }
2933
+ return res;
2934
+ }
2935
+ const isAbsolute = function(p) {
2936
+ return _IS_ABSOLUTE_RE.test(p);
2937
+ };
2938
+ const toNamespacedPath = function(p) {
2939
+ return normalizeWindowsPath(p);
2940
+ };
2941
+ const _EXTNAME_RE = /.(\.[^./]+)$/;
2942
+ const extname = function(p) {
2943
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
2944
+ return match && match[1] || "";
2945
+ };
2946
+ const relative = function(from, to) {
2947
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
2948
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
2949
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
2950
+ return _to.join("/");
2951
+ }
2952
+ const _fromCopy = [..._from];
2953
+ for (const segment of _fromCopy) {
2954
+ if (_to[0] !== segment) {
2955
+ break;
2956
+ }
2957
+ _from.shift();
2958
+ _to.shift();
2959
+ }
2960
+ return [..._from.map(() => ".."), ..._to].join("/");
2961
+ };
2962
+ const dirname = function(p) {
2963
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
2964
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
2965
+ segments[0] += "/";
2966
+ }
2967
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
2968
+ };
2969
+ const format = function(p) {
2970
+ const segments = [p.root, p.dir, p.base ?? p.name + p.ext].filter(Boolean);
2971
+ return normalizeWindowsPath(
2972
+ p.root ? resolve(...segments) : segments.join("/")
2973
+ );
2974
+ };
2975
+ const basename = function(p, extension) {
2976
+ const lastSegment = normalizeWindowsPath(p).split("/").pop();
2977
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
2978
+ };
2979
+ const parse = function(p) {
2980
+ const root = normalizeWindowsPath(p).split("/").shift() || "/";
2981
+ const base = basename(p);
2982
+ const extension = extname(base);
2983
+ return {
2984
+ root,
2985
+ dir: dirname(p),
2986
+ base,
2987
+ ext: extension,
2988
+ name: base.slice(0, base.length - extension.length)
2989
+ };
2990
+ };
2991
+
2992
+ const path = {
2993
+ __proto__: null,
2994
+ basename: basename,
2995
+ delimiter: delimiter,
2996
+ dirname: dirname,
2997
+ extname: extname,
2998
+ format: format,
2999
+ isAbsolute: isAbsolute,
3000
+ join: join,
3001
+ normalize: normalize,
3002
+ normalizeString: normalizeString,
3003
+ parse: parse,
3004
+ relative: relative,
3005
+ resolve: resolve,
3006
+ sep: sep,
3007
+ toNamespacedPath: toNamespacedPath
3008
+ };
3009
+
3010
+ /*!
3011
+ * is-primitive <https://github.com/jonschlinkert/is-primitive>
3012
+ *
3013
+ * Copyright (c) 2014-present, Jon Schlinkert.
3014
+ * Released under the MIT License.
3015
+ */
3016
+
3017
+ var isPrimitive;
3018
+ var hasRequiredIsPrimitive;
3019
+
3020
+ function requireIsPrimitive () {
3021
+ if (hasRequiredIsPrimitive) return isPrimitive;
3022
+ hasRequiredIsPrimitive = 1;
3023
+
3024
+ isPrimitive = function isPrimitive(val) {
3025
+ if (typeof val === 'object') {
3026
+ return val === null;
3027
+ }
3028
+ return typeof val !== 'function';
3029
+ };
3030
+ return isPrimitive;
3031
+ }
3032
+
3033
+ /*!
3034
+ * isobject <https://github.com/jonschlinkert/isobject>
3035
+ *
3036
+ * Copyright (c) 2014-2017, Jon Schlinkert.
3037
+ * Released under the MIT License.
3038
+ */
3039
+
3040
+ var isobject;
3041
+ var hasRequiredIsobject;
3042
+
3043
+ function requireIsobject () {
3044
+ if (hasRequiredIsobject) return isobject;
3045
+ hasRequiredIsobject = 1;
3046
+
3047
+ isobject = function isObject(val) {
3048
+ return val != null && typeof val === 'object' && Array.isArray(val) === false;
3049
+ };
3050
+ return isobject;
3051
+ }
3052
+
3053
+ /*!
3054
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
3055
+ *
3056
+ * Copyright (c) 2014-2017, Jon Schlinkert.
3057
+ * Released under the MIT License.
3058
+ */
3059
+
3060
+ var isPlainObject;
3061
+ var hasRequiredIsPlainObject;
3062
+
3063
+ function requireIsPlainObject () {
3064
+ if (hasRequiredIsPlainObject) return isPlainObject;
3065
+ hasRequiredIsPlainObject = 1;
3066
+
3067
+ var isObject = requireIsobject();
3068
+
3069
+ function isObjectObject(o) {
3070
+ return isObject(o) === true
3071
+ && Object.prototype.toString.call(o) === '[object Object]';
3072
+ }
3073
+
3074
+ isPlainObject = function isPlainObject(o) {
3075
+ var ctor,prot;
3076
+
3077
+ if (isObjectObject(o) === false) return false;
3078
+
3079
+ // If has modified constructor
3080
+ ctor = o.constructor;
3081
+ if (typeof ctor !== 'function') return false;
3082
+
3083
+ // If has modified prototype
3084
+ prot = ctor.prototype;
3085
+ if (isObjectObject(prot) === false) return false;
3086
+
3087
+ // If constructor does not have an Object-specific method
3088
+ if (prot.hasOwnProperty('isPrototypeOf') === false) {
3089
+ return false;
3090
+ }
3091
+
3092
+ // Most likely a plain Object
3093
+ return true;
3094
+ };
3095
+ return isPlainObject;
3096
+ }
3097
+
3098
+ /*!
3099
+ * set-value <https://github.com/jonschlinkert/set-value>
3100
+ *
3101
+ * Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
3102
+ * Released under the MIT License.
3103
+ */
3104
+
3105
+ var setValue_1;
3106
+ var hasRequiredSetValue;
3107
+
3108
+ function requireSetValue () {
3109
+ if (hasRequiredSetValue) return setValue_1;
3110
+ hasRequiredSetValue = 1;
3111
+
3112
+ const { deleteProperty } = Reflect;
3113
+ const isPrimitive = requireIsPrimitive();
3114
+ const isPlainObject = requireIsPlainObject();
3115
+
3116
+ const isObject = value => {
3117
+ return (typeof value === 'object' && value !== null) || typeof value === 'function';
3118
+ };
3119
+
3120
+ const isUnsafeKey = key => {
3121
+ return key === '__proto__' || key === 'constructor' || key === 'prototype';
3122
+ };
3123
+
3124
+ const validateKey = key => {
3125
+ if (!isPrimitive(key)) {
3126
+ throw new TypeError('Object keys must be strings or symbols');
3127
+ }
3128
+
3129
+ if (isUnsafeKey(key)) {
3130
+ throw new Error(`Cannot set unsafe key: "${key}"`);
3131
+ }
3132
+ };
3133
+
3134
+ const toStringKey = input => {
3135
+ return Array.isArray(input) ? input.flat().map(String).join(',') : input;
3136
+ };
3137
+
3138
+ const createMemoKey = (input, options) => {
3139
+ if (typeof input !== 'string' || !options) return input;
3140
+ let key = input + ';';
3141
+ if (options.arrays !== undefined) key += `arrays=${options.arrays};`;
3142
+ if (options.separator !== undefined) key += `separator=${options.separator};`;
3143
+ if (options.split !== undefined) key += `split=${options.split};`;
3144
+ if (options.merge !== undefined) key += `merge=${options.merge};`;
3145
+ if (options.preservePaths !== undefined) key += `preservePaths=${options.preservePaths};`;
3146
+ return key;
3147
+ };
3148
+
3149
+ const memoize = (input, options, fn) => {
3150
+ const key = toStringKey(options ? createMemoKey(input, options) : input);
3151
+ validateKey(key);
3152
+
3153
+ const value = setValue.cache.get(key) || fn();
3154
+ setValue.cache.set(key, value);
3155
+ return value;
3156
+ };
3157
+
3158
+ const splitString = (input, options = {}) => {
3159
+ const sep = options.separator || '.';
3160
+ const preserve = sep === '/' ? false : options.preservePaths;
3161
+
3162
+ if (typeof input === 'string' && preserve !== false && /\//.test(input)) {
3163
+ return [input];
3164
+ }
3165
+
3166
+ const parts = [];
3167
+ let part = '';
3168
+
3169
+ const push = part => {
3170
+ let number;
3171
+ if (part.trim() !== '' && Number.isInteger((number = Number(part)))) {
3172
+ parts.push(number);
3173
+ } else {
3174
+ parts.push(part);
3175
+ }
3176
+ };
3177
+
3178
+ for (let i = 0; i < input.length; i++) {
3179
+ const value = input[i];
3180
+
3181
+ if (value === '\\') {
3182
+ part += input[++i];
3183
+ continue;
3184
+ }
3185
+
3186
+ if (value === sep) {
3187
+ push(part);
3188
+ part = '';
3189
+ continue;
3190
+ }
3191
+
3192
+ part += value;
3193
+ }
3194
+
3195
+ if (part) {
3196
+ push(part);
3197
+ }
3198
+
3199
+ return parts;
3200
+ };
3201
+
3202
+ const split = (input, options) => {
3203
+ if (options && typeof options.split === 'function') return options.split(input);
3204
+ if (typeof input === 'symbol') return [input];
3205
+ if (Array.isArray(input)) return input;
3206
+ return memoize(input, options, () => splitString(input, options));
3207
+ };
3208
+
3209
+ const assignProp = (obj, prop, value, options) => {
3210
+ validateKey(prop);
3211
+
3212
+ // Delete property when "value" is undefined
3213
+ if (value === undefined) {
3214
+ deleteProperty(obj, prop);
3215
+
3216
+ } else if (options && options.merge) {
3217
+ const merge = options.merge === 'function' ? options.merge : Object.assign;
3218
+
3219
+ // Only merge plain objects
3220
+ if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) {
3221
+ obj[prop] = merge(obj[prop], value);
3222
+ } else {
3223
+ obj[prop] = value;
3224
+ }
3225
+
3226
+ } else {
3227
+ obj[prop] = value;
3228
+ }
3229
+
3230
+ return obj;
3231
+ };
3232
+
3233
+ const setValue = (target, path, value, options) => {
3234
+ if (!path || !isObject(target)) return target;
3235
+
3236
+ const keys = split(path, options);
3237
+ let obj = target;
3238
+
3239
+ for (let i = 0; i < keys.length; i++) {
3240
+ const key = keys[i];
3241
+ const next = keys[i + 1];
3242
+
3243
+ validateKey(key);
3244
+
3245
+ if (next === undefined) {
3246
+ assignProp(obj, key, value, options);
3247
+ break;
3248
+ }
3249
+
3250
+ if (typeof next === 'number' && !Array.isArray(obj[key])) {
3251
+ obj = obj[key] = [];
3252
+ continue;
3253
+ }
3254
+
3255
+ if (!isObject(obj[key])) {
3256
+ obj[key] = {};
3257
+ }
3258
+
3259
+ obj = obj[key];
3260
+ }
3261
+
3262
+ return target;
3263
+ };
3264
+
3265
+ setValue.split = split;
3266
+ setValue.cache = new Map();
3267
+ setValue.clear = () => {
3268
+ setValue.cache = new Map();
3269
+ };
3270
+
3271
+ setValue_1 = setValue;
3272
+ return setValue_1;
3273
+ }
3274
+
3275
+ var setValueExports = requireSetValue();
3276
+ var set = /*@__PURE__*/getDefaultExportFromCjs(setValueExports);
3277
+
3278
+ const logger = consola.createConsola();
3279
+
3280
+ function fetchPackage(packageName, options) {
3281
+ return fetch__default["default"].json(`/${packageName}`, options);
3282
+ }
3283
+ function getLatestVersionInRange(packageName, versionRange, options$1) {
3284
+ return options.__awaiter(this, void 0, void 0, function* () {
3285
+ const response = yield fetchPackage(packageName, options$1);
3286
+ const versions = Object.keys(response.versions);
3287
+ const filteredVersions = versions.filter(version => version.startsWith(versionRange));
3288
+ return filteredVersions[filteredVersions.length - 1];
3289
+ });
3290
+ }
3291
+ const defaultDevDeps = {
3292
+ 'tailwindcss': '3',
3293
+ 'postcss': '8',
3294
+ 'autoprefixer': '10',
3295
+ 'weapp-tailwindcss': '3',
3296
+ };
3297
+ function getDevDepsVersions(options$1) {
3298
+ return options.__awaiter(this, void 0, void 0, function* () {
3299
+ return Object.fromEntries(yield Promise.all(Object.entries(defaultDevDeps).map((x) => options.__awaiter(this, void 0, void 0, function* () {
3300
+ return [x[0], `^${yield getLatestVersionInRange(...x, options$1)}`];
3301
+ }))));
3302
+ });
3303
+ }
3304
+
3305
+ function createContext(options$1) {
3306
+ return options.__awaiter(this, void 0, void 0, function* () {
3307
+ const { cwd, pkgJsonBasename, postcssConfigBasename, tailwindConfigBasename, fetchOptions } = options$1;
3308
+ const pkgJsonPath = path.resolve(cwd, pkgJsonBasename);
3309
+ if (yield fs.exists(pkgJsonPath)) {
3310
+ const pkgJson = yield fs.readJson(pkgJsonPath);
3311
+ const versions = yield getDevDepsVersions(fetchOptions);
3312
+ return {
3313
+ pkgJson,
3314
+ pkgJsonPath,
3315
+ cwd,
3316
+ versions,
3317
+ postcssConfigBasename,
3318
+ tailwindConfigBasename,
3319
+ get type() {
3320
+ return pkgJson.type;
3321
+ },
3322
+ };
3323
+ }
3324
+ else {
3325
+ logger.warn('当前目录下不存在 `package.json` 文件,初始化脚本将被跳过,请执行 `npm init` 或手动创建 `package.json` 后重试 ');
3326
+ }
3327
+ });
3328
+ }
3329
+ function updatePackageJson(ctx) {
3330
+ return options.__awaiter(this, void 0, void 0, function* () {
3331
+ set(ctx.pkgJson, 'scripts.postinstall', 'weapp-tw patch');
3332
+ for (const [key, value] of Object.entries(ctx.versions)) {
3333
+ set(ctx.pkgJson, `devDependencies.${key}`, value);
3334
+ }
3335
+ yield fs.writeJSON(ctx.pkgJsonPath, ctx.pkgJson, { spaces: 2 });
3336
+ });
3337
+ }
3338
+ function touchPostcssConfig(ctx) {
3339
+ return options.__awaiter(this, void 0, void 0, function* () {
3340
+ const data = `${ctx.type === 'module' ? 'export default ' : 'module.exports = '}{
3341
+ plugins: {
3342
+ tailwindcss: {},
3343
+ // 假如框架已经内置了 \`autoprefixer\`,可以去除下一行
3344
+ autoprefixer: {},
3345
+ }
3346
+ }`;
3347
+ yield fs.writeFile(path.resolve(ctx.cwd, ctx.postcssConfigBasename), data);
3348
+ });
3349
+ }
3350
+ function touchTailwindConfig(ctx) {
3351
+ return options.__awaiter(this, void 0, void 0, function* () {
3352
+ const data = `/** @type {import('tailwindcss').Config} */
3353
+ ${ctx.type === 'module' ? 'export default ' : 'module.exports = '}{
3354
+ // 这里给出了一份 uni-app /taro 通用示例,具体要根据你自己项目的目录结构进行配置
3355
+ // 不在 content 包括的文件内,你编写的 class,是不会生成对应的css工具类的
3356
+ content: ['./public/index.html', './src/**/*.{html,js,ts,jsx,tsx,vue}'],
3357
+ // 其他配置项
3358
+ // ...
3359
+ corePlugins: {
3360
+ // 小程序不需要 preflight,因为这主要是给 h5 的,如果你要同时开发小程序和 h5 端,你应该使用环境变量来控制它
3361
+ preflight: false,
3362
+ },
3363
+ }`;
3364
+ yield fs.writeFile(path.resolve(ctx.cwd, ctx.tailwindConfigBasename), data);
3365
+ });
3366
+ }
3367
+ function getInitDefaults() {
3368
+ return {
3369
+ cwd: process__default["default"].cwd(),
3370
+ postcssConfigBasename: 'postcss.config.js',
3371
+ tailwindConfigBasename: 'tailwind.config.js',
3372
+ pkgJsonBasename: 'package.json',
3373
+ };
3374
+ }
3375
+ function init(options$1) {
3376
+ return options.__awaiter(this, void 0, void 0, function* () {
3377
+ const opts = defu.defu(options$1, getInitDefaults());
3378
+ const ctx = yield createContext(opts);
3379
+ if (ctx) {
3380
+ yield updatePackageJson(ctx);
3381
+ yield touchPostcssConfig(ctx);
3382
+ yield touchTailwindConfig(ctx);
3383
+ }
3384
+ });
3385
+ }
34
3386
 
35
3387
  process__default["default"].title = 'node (weapp-tailwindcss)';
36
3388
  const args = process__default["default"].argv.slice(2);
@@ -43,6 +3395,9 @@ if (command === 'patch') {
43
3395
  const options$1 = options.getOptions();
44
3396
  options$1.patch();
45
3397
  }
3398
+ else if (command === 'init') {
3399
+ init();
3400
+ }
46
3401
  else {
47
3402
  try {
48
3403
  import('@weapp-tailwindcss/cli').then(({ createCli }) => {