weapp-tailwindcss 3.5.2 → 3.5.3

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