weapp-tailwindcss 3.5.2 → 3.6.0

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