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