jiek 2.0.2-alpha.1 → 2.0.2-alpha.10

Sign up to get free protection for your applications and to get access to all the features.
package/cli.cjs ADDED
@@ -0,0 +1,4742 @@
1
+ 'use strict';
2
+
3
+ var childProcess = require('node:child_process');
4
+ var fs = require('node:fs');
5
+ var path = require('node:path');
6
+ var bumper = require('@jiek/utils/bumper');
7
+ var commander = require('commander');
8
+ var detectIndent = require('detect-indent');
9
+ var jsoncParser = require('jsonc-parser');
10
+ var node_module = require('node:module');
11
+ var filterWorkspacePackages = require('@pnpm/filter-workspace-packages');
12
+ var jsYaml = require('js-yaml');
13
+ var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
14
+ var entrypoints = require('@jiek/pkger/entrypoints');
15
+ var require$$0 = require('util');
16
+ var require$$0$1 = require('path');
17
+ require('jiek/cli-only-build');
18
+
19
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
20
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
+
22
+ function _interopNamespace(e) {
23
+ if (e && e.__esModule) return e;
24
+ var n = Object.create(null);
25
+ if (e) {
26
+ Object.keys(e).forEach(function (k) {
27
+ if (k !== 'default') {
28
+ var d = Object.getOwnPropertyDescriptor(e, k);
29
+ Object.defineProperty(n, k, d.get ? d : {
30
+ enumerable: true,
31
+ get: function () { return e[k]; }
32
+ });
33
+ }
34
+ });
35
+ }
36
+ n.default = e;
37
+ return Object.freeze(n);
38
+ }
39
+
40
+ var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
41
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
42
+ var path__default = /*#__PURE__*/_interopDefault(path);
43
+ var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
44
+ var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
45
+ var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
46
+
47
+ let root;
48
+ function getRoot() {
49
+ if (root)
50
+ return root;
51
+ const rootOption = commander.program.getOptionValue("root");
52
+ root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
53
+ return root;
54
+ }
55
+
56
+ let wd;
57
+ let notWorkspace = false;
58
+ function getWD() {
59
+ if (wd)
60
+ return { wd, notWorkspace };
61
+ const root = getRoot();
62
+ if (root !== void 0) {
63
+ const isWorkspace = getWorkspaceDir.isWorkspaceDir(root, type);
64
+ notWorkspace = !isWorkspace;
65
+ wd = root;
66
+ return { wd, notWorkspace };
67
+ }
68
+ try {
69
+ wd = getWorkspaceDir.getWorkspaceDir(type);
70
+ } catch (e) {
71
+ if ("message" in e && e.message === "workspace root not found") {
72
+ wd = root;
73
+ notWorkspace = true;
74
+ } else {
75
+ throw e;
76
+ }
77
+ }
78
+ return { wd, notWorkspace };
79
+ }
80
+
81
+ let type = "";
82
+ try {
83
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
84
+ require$1.resolve("@pnpm/filter-workspace-packages");
85
+ type = "pnpm";
86
+ } catch {
87
+ }
88
+ async function getSelectedProjectsGraph(filter = commander.program.getOptionValue("filter")) {
89
+ let root = getRoot();
90
+ const { wd, notWorkspace } = getWD();
91
+ if (notWorkspace) {
92
+ return {
93
+ wd,
94
+ root,
95
+ value: {
96
+ [wd]: JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(wd, "package.json"), "utf-8"))
97
+ }
98
+ };
99
+ }
100
+ if (type === "pnpm") {
101
+ const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
102
+ const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
103
+ const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
104
+ if (root === wd && !filter) {
105
+ throw new Error("root path is workspace root, please provide a filter");
106
+ }
107
+ if (root === void 0) {
108
+ root = process.cwd();
109
+ }
110
+ if (root !== wd && !filter) {
111
+ const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
112
+ if (!packageJSONIsExist) {
113
+ throw new Error("root path is not workspace root, please provide a filter");
114
+ }
115
+ const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
116
+ if (!packageJSON.name) {
117
+ throw new Error("root path is not workspace root, please provide a filter");
118
+ }
119
+ filter = packageJSON.name;
120
+ }
121
+ const { selectedProjectsGraph } = await filterWorkspacePackages.filterPackagesFromDir(wd, [{
122
+ filter: filter ?? "",
123
+ followProdDepsOnly: true
124
+ }], {
125
+ prefix: root,
126
+ workspaceDir: wd,
127
+ patterns: pnpmWorkspace.packages
128
+ });
129
+ return {
130
+ wd,
131
+ root,
132
+ value: Object.entries(selectedProjectsGraph).reduce((acc, [key, value]) => {
133
+ acc[key] = value.package.manifest;
134
+ return acc;
135
+ }, {})
136
+ };
137
+ }
138
+ throw new Error(`not supported package manager ${type}`);
139
+ }
140
+
141
+ var utils$1 = {};
142
+
143
+ var hasRequiredUtils$1;
144
+
145
+ function requireUtils$1 () {
146
+ if (hasRequiredUtils$1) return utils$1;
147
+ hasRequiredUtils$1 = 1;
148
+ (function (exports) {
149
+
150
+ exports.isInteger = num => {
151
+ if (typeof num === 'number') {
152
+ return Number.isInteger(num);
153
+ }
154
+ if (typeof num === 'string' && num.trim() !== '') {
155
+ return Number.isInteger(Number(num));
156
+ }
157
+ return false;
158
+ };
159
+
160
+ /**
161
+ * Find a node of the given type
162
+ */
163
+
164
+ exports.find = (node, type) => node.nodes.find(node => node.type === type);
165
+
166
+ /**
167
+ * Find a node of the given type
168
+ */
169
+
170
+ exports.exceedsLimit = (min, max, step = 1, limit) => {
171
+ if (limit === false) return false;
172
+ if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
173
+ return ((Number(max) - Number(min)) / Number(step)) >= limit;
174
+ };
175
+
176
+ /**
177
+ * Escape the given node with '\\' before node.value
178
+ */
179
+
180
+ exports.escapeNode = (block, n = 0, type) => {
181
+ let node = block.nodes[n];
182
+ if (!node) return;
183
+
184
+ if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
185
+ if (node.escaped !== true) {
186
+ node.value = '\\' + node.value;
187
+ node.escaped = true;
188
+ }
189
+ }
190
+ };
191
+
192
+ /**
193
+ * Returns true if the given brace node should be enclosed in literal braces
194
+ */
195
+
196
+ exports.encloseBrace = node => {
197
+ if (node.type !== 'brace') return false;
198
+ if ((node.commas >> 0 + node.ranges >> 0) === 0) {
199
+ node.invalid = true;
200
+ return true;
201
+ }
202
+ return false;
203
+ };
204
+
205
+ /**
206
+ * Returns true if a brace node is invalid.
207
+ */
208
+
209
+ exports.isInvalidBrace = block => {
210
+ if (block.type !== 'brace') return false;
211
+ if (block.invalid === true || block.dollar) return true;
212
+ if ((block.commas >> 0 + block.ranges >> 0) === 0) {
213
+ block.invalid = true;
214
+ return true;
215
+ }
216
+ if (block.open !== true || block.close !== true) {
217
+ block.invalid = true;
218
+ return true;
219
+ }
220
+ return false;
221
+ };
222
+
223
+ /**
224
+ * Returns true if a node is an open or close node
225
+ */
226
+
227
+ exports.isOpenOrClose = node => {
228
+ if (node.type === 'open' || node.type === 'close') {
229
+ return true;
230
+ }
231
+ return node.open === true || node.close === true;
232
+ };
233
+
234
+ /**
235
+ * Reduce an array of text nodes.
236
+ */
237
+
238
+ exports.reduce = nodes => nodes.reduce((acc, node) => {
239
+ if (node.type === 'text') acc.push(node.value);
240
+ if (node.type === 'range') node.type = 'text';
241
+ return acc;
242
+ }, []);
243
+
244
+ /**
245
+ * Flatten an array
246
+ */
247
+
248
+ exports.flatten = (...args) => {
249
+ const result = [];
250
+ const flat = arr => {
251
+ for (let i = 0; i < arr.length; i++) {
252
+ let ele = arr[i];
253
+ Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
254
+ }
255
+ return result;
256
+ };
257
+ flat(args);
258
+ return result;
259
+ };
260
+ } (utils$1));
261
+ return utils$1;
262
+ }
263
+
264
+ var stringify;
265
+ var hasRequiredStringify;
266
+
267
+ function requireStringify () {
268
+ if (hasRequiredStringify) return stringify;
269
+ hasRequiredStringify = 1;
270
+
271
+ const utils = requireUtils$1();
272
+
273
+ stringify = (ast, options = {}) => {
274
+ let stringify = (node, parent = {}) => {
275
+ let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
276
+ let invalidNode = node.invalid === true && options.escapeInvalid === true;
277
+ let output = '';
278
+
279
+ if (node.value) {
280
+ if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
281
+ return '\\' + node.value;
282
+ }
283
+ return node.value;
284
+ }
285
+
286
+ if (node.value) {
287
+ return node.value;
288
+ }
289
+
290
+ if (node.nodes) {
291
+ for (let child of node.nodes) {
292
+ output += stringify(child);
293
+ }
294
+ }
295
+ return output;
296
+ };
297
+
298
+ return stringify(ast);
299
+ };
300
+ return stringify;
301
+ }
302
+
303
+ /*!
304
+ * is-number <https://github.com/jonschlinkert/is-number>
305
+ *
306
+ * Copyright (c) 2014-present, Jon Schlinkert.
307
+ * Released under the MIT License.
308
+ */
309
+
310
+ var isNumber;
311
+ var hasRequiredIsNumber;
312
+
313
+ function requireIsNumber () {
314
+ if (hasRequiredIsNumber) return isNumber;
315
+ hasRequiredIsNumber = 1;
316
+
317
+ isNumber = function(num) {
318
+ if (typeof num === 'number') {
319
+ return num - num === 0;
320
+ }
321
+ if (typeof num === 'string' && num.trim() !== '') {
322
+ return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
323
+ }
324
+ return false;
325
+ };
326
+ return isNumber;
327
+ }
328
+
329
+ /*!
330
+ * to-regex-range <https://github.com/micromatch/to-regex-range>
331
+ *
332
+ * Copyright (c) 2015-present, Jon Schlinkert.
333
+ * Released under the MIT License.
334
+ */
335
+
336
+ var toRegexRange_1;
337
+ var hasRequiredToRegexRange;
338
+
339
+ function requireToRegexRange () {
340
+ if (hasRequiredToRegexRange) return toRegexRange_1;
341
+ hasRequiredToRegexRange = 1;
342
+
343
+ const isNumber = requireIsNumber();
344
+
345
+ const toRegexRange = (min, max, options) => {
346
+ if (isNumber(min) === false) {
347
+ throw new TypeError('toRegexRange: expected the first argument to be a number');
348
+ }
349
+
350
+ if (max === void 0 || min === max) {
351
+ return String(min);
352
+ }
353
+
354
+ if (isNumber(max) === false) {
355
+ throw new TypeError('toRegexRange: expected the second argument to be a number.');
356
+ }
357
+
358
+ let opts = { relaxZeros: true, ...options };
359
+ if (typeof opts.strictZeros === 'boolean') {
360
+ opts.relaxZeros = opts.strictZeros === false;
361
+ }
362
+
363
+ let relax = String(opts.relaxZeros);
364
+ let shorthand = String(opts.shorthand);
365
+ let capture = String(opts.capture);
366
+ let wrap = String(opts.wrap);
367
+ let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
368
+
369
+ if (toRegexRange.cache.hasOwnProperty(cacheKey)) {
370
+ return toRegexRange.cache[cacheKey].result;
371
+ }
372
+
373
+ let a = Math.min(min, max);
374
+ let b = Math.max(min, max);
375
+
376
+ if (Math.abs(a - b) === 1) {
377
+ let result = min + '|' + max;
378
+ if (opts.capture) {
379
+ return `(${result})`;
380
+ }
381
+ if (opts.wrap === false) {
382
+ return result;
383
+ }
384
+ return `(?:${result})`;
385
+ }
386
+
387
+ let isPadded = hasPadding(min) || hasPadding(max);
388
+ let state = { min, max, a, b };
389
+ let positives = [];
390
+ let negatives = [];
391
+
392
+ if (isPadded) {
393
+ state.isPadded = isPadded;
394
+ state.maxLen = String(state.max).length;
395
+ }
396
+
397
+ if (a < 0) {
398
+ let newMin = b < 0 ? Math.abs(b) : 1;
399
+ negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
400
+ a = state.a = 0;
401
+ }
402
+
403
+ if (b >= 0) {
404
+ positives = splitToPatterns(a, b, state, opts);
405
+ }
406
+
407
+ state.negatives = negatives;
408
+ state.positives = positives;
409
+ state.result = collatePatterns(negatives, positives);
410
+
411
+ if (opts.capture === true) {
412
+ state.result = `(${state.result})`;
413
+ } else if (opts.wrap !== false && (positives.length + negatives.length) > 1) {
414
+ state.result = `(?:${state.result})`;
415
+ }
416
+
417
+ toRegexRange.cache[cacheKey] = state;
418
+ return state.result;
419
+ };
420
+
421
+ function collatePatterns(neg, pos, options) {
422
+ let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
423
+ let onlyPositive = filterPatterns(pos, neg, '', false) || [];
424
+ let intersected = filterPatterns(neg, pos, '-?', true) || [];
425
+ let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
426
+ return subpatterns.join('|');
427
+ }
428
+
429
+ function splitToRanges(min, max) {
430
+ let nines = 1;
431
+ let zeros = 1;
432
+
433
+ let stop = countNines(min, nines);
434
+ let stops = new Set([max]);
435
+
436
+ while (min <= stop && stop <= max) {
437
+ stops.add(stop);
438
+ nines += 1;
439
+ stop = countNines(min, nines);
440
+ }
441
+
442
+ stop = countZeros(max + 1, zeros) - 1;
443
+
444
+ while (min < stop && stop <= max) {
445
+ stops.add(stop);
446
+ zeros += 1;
447
+ stop = countZeros(max + 1, zeros) - 1;
448
+ }
449
+
450
+ stops = [...stops];
451
+ stops.sort(compare);
452
+ return stops;
453
+ }
454
+
455
+ /**
456
+ * Convert a range to a regex pattern
457
+ * @param {Number} `start`
458
+ * @param {Number} `stop`
459
+ * @return {String}
460
+ */
461
+
462
+ function rangeToPattern(start, stop, options) {
463
+ if (start === stop) {
464
+ return { pattern: start, count: [], digits: 0 };
465
+ }
466
+
467
+ let zipped = zip(start, stop);
468
+ let digits = zipped.length;
469
+ let pattern = '';
470
+ let count = 0;
471
+
472
+ for (let i = 0; i < digits; i++) {
473
+ let [startDigit, stopDigit] = zipped[i];
474
+
475
+ if (startDigit === stopDigit) {
476
+ pattern += startDigit;
477
+
478
+ } else if (startDigit !== '0' || stopDigit !== '9') {
479
+ pattern += toCharacterClass(startDigit, stopDigit);
480
+
481
+ } else {
482
+ count++;
483
+ }
484
+ }
485
+
486
+ if (count) {
487
+ pattern += options.shorthand === true ? '\\d' : '[0-9]';
488
+ }
489
+
490
+ return { pattern, count: [count], digits };
491
+ }
492
+
493
+ function splitToPatterns(min, max, tok, options) {
494
+ let ranges = splitToRanges(min, max);
495
+ let tokens = [];
496
+ let start = min;
497
+ let prev;
498
+
499
+ for (let i = 0; i < ranges.length; i++) {
500
+ let max = ranges[i];
501
+ let obj = rangeToPattern(String(start), String(max), options);
502
+ let zeros = '';
503
+
504
+ if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
505
+ if (prev.count.length > 1) {
506
+ prev.count.pop();
507
+ }
508
+
509
+ prev.count.push(obj.count[0]);
510
+ prev.string = prev.pattern + toQuantifier(prev.count);
511
+ start = max + 1;
512
+ continue;
513
+ }
514
+
515
+ if (tok.isPadded) {
516
+ zeros = padZeros(max, tok, options);
517
+ }
518
+
519
+ obj.string = zeros + obj.pattern + toQuantifier(obj.count);
520
+ tokens.push(obj);
521
+ start = max + 1;
522
+ prev = obj;
523
+ }
524
+
525
+ return tokens;
526
+ }
527
+
528
+ function filterPatterns(arr, comparison, prefix, intersection, options) {
529
+ let result = [];
530
+
531
+ for (let ele of arr) {
532
+ let { string } = ele;
533
+
534
+ // only push if _both_ are negative...
535
+ if (!intersection && !contains(comparison, 'string', string)) {
536
+ result.push(prefix + string);
537
+ }
538
+
539
+ // or _both_ are positive
540
+ if (intersection && contains(comparison, 'string', string)) {
541
+ result.push(prefix + string);
542
+ }
543
+ }
544
+ return result;
545
+ }
546
+
547
+ /**
548
+ * Zip strings
549
+ */
550
+
551
+ function zip(a, b) {
552
+ let arr = [];
553
+ for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
554
+ return arr;
555
+ }
556
+
557
+ function compare(a, b) {
558
+ return a > b ? 1 : b > a ? -1 : 0;
559
+ }
560
+
561
+ function contains(arr, key, val) {
562
+ return arr.some(ele => ele[key] === val);
563
+ }
564
+
565
+ function countNines(min, len) {
566
+ return Number(String(min).slice(0, -len) + '9'.repeat(len));
567
+ }
568
+
569
+ function countZeros(integer, zeros) {
570
+ return integer - (integer % Math.pow(10, zeros));
571
+ }
572
+
573
+ function toQuantifier(digits) {
574
+ let [start = 0, stop = ''] = digits;
575
+ if (stop || start > 1) {
576
+ return `{${start + (stop ? ',' + stop : '')}}`;
577
+ }
578
+ return '';
579
+ }
580
+
581
+ function toCharacterClass(a, b, options) {
582
+ return `[${a}${(b - a === 1) ? '' : '-'}${b}]`;
583
+ }
584
+
585
+ function hasPadding(str) {
586
+ return /^-?(0+)\d/.test(str);
587
+ }
588
+
589
+ function padZeros(value, tok, options) {
590
+ if (!tok.isPadded) {
591
+ return value;
592
+ }
593
+
594
+ let diff = Math.abs(tok.maxLen - String(value).length);
595
+ let relax = options.relaxZeros !== false;
596
+
597
+ switch (diff) {
598
+ case 0:
599
+ return '';
600
+ case 1:
601
+ return relax ? '0?' : '0';
602
+ case 2:
603
+ return relax ? '0{0,2}' : '00';
604
+ default: {
605
+ return relax ? `0{0,${diff}}` : `0{${diff}}`;
606
+ }
607
+ }
608
+ }
609
+
610
+ /**
611
+ * Cache
612
+ */
613
+
614
+ toRegexRange.cache = {};
615
+ toRegexRange.clearCache = () => (toRegexRange.cache = {});
616
+
617
+ /**
618
+ * Expose `toRegexRange`
619
+ */
620
+
621
+ toRegexRange_1 = toRegexRange;
622
+ return toRegexRange_1;
623
+ }
624
+
625
+ /*!
626
+ * fill-range <https://github.com/jonschlinkert/fill-range>
627
+ *
628
+ * Copyright (c) 2014-present, Jon Schlinkert.
629
+ * Licensed under the MIT License.
630
+ */
631
+
632
+ var fillRange;
633
+ var hasRequiredFillRange;
634
+
635
+ function requireFillRange () {
636
+ if (hasRequiredFillRange) return fillRange;
637
+ hasRequiredFillRange = 1;
638
+
639
+ const util = require$$0__default.default;
640
+ const toRegexRange = requireToRegexRange();
641
+
642
+ const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
643
+
644
+ const transform = toNumber => {
645
+ return value => toNumber === true ? Number(value) : String(value);
646
+ };
647
+
648
+ const isValidValue = value => {
649
+ return typeof value === 'number' || (typeof value === 'string' && value !== '');
650
+ };
651
+
652
+ const isNumber = num => Number.isInteger(+num);
653
+
654
+ const zeros = input => {
655
+ let value = `${input}`;
656
+ let index = -1;
657
+ if (value[0] === '-') value = value.slice(1);
658
+ if (value === '0') return false;
659
+ while (value[++index] === '0');
660
+ return index > 0;
661
+ };
662
+
663
+ const stringify = (start, end, options) => {
664
+ if (typeof start === 'string' || typeof end === 'string') {
665
+ return true;
666
+ }
667
+ return options.stringify === true;
668
+ };
669
+
670
+ const pad = (input, maxLength, toNumber) => {
671
+ if (maxLength > 0) {
672
+ let dash = input[0] === '-' ? '-' : '';
673
+ if (dash) input = input.slice(1);
674
+ input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0'));
675
+ }
676
+ if (toNumber === false) {
677
+ return String(input);
678
+ }
679
+ return input;
680
+ };
681
+
682
+ const toMaxLen = (input, maxLength) => {
683
+ let negative = input[0] === '-' ? '-' : '';
684
+ if (negative) {
685
+ input = input.slice(1);
686
+ maxLength--;
687
+ }
688
+ while (input.length < maxLength) input = '0' + input;
689
+ return negative ? ('-' + input) : input;
690
+ };
691
+
692
+ const toSequence = (parts, options) => {
693
+ parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
694
+ parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
695
+
696
+ let prefix = options.capture ? '' : '?:';
697
+ let positives = '';
698
+ let negatives = '';
699
+ let result;
700
+
701
+ if (parts.positives.length) {
702
+ positives = parts.positives.join('|');
703
+ }
704
+
705
+ if (parts.negatives.length) {
706
+ negatives = `-(${prefix}${parts.negatives.join('|')})`;
707
+ }
708
+
709
+ if (positives && negatives) {
710
+ result = `${positives}|${negatives}`;
711
+ } else {
712
+ result = positives || negatives;
713
+ }
714
+
715
+ if (options.wrap) {
716
+ return `(${prefix}${result})`;
717
+ }
718
+
719
+ return result;
720
+ };
721
+
722
+ const toRange = (a, b, isNumbers, options) => {
723
+ if (isNumbers) {
724
+ return toRegexRange(a, b, { wrap: false, ...options });
725
+ }
726
+
727
+ let start = String.fromCharCode(a);
728
+ if (a === b) return start;
729
+
730
+ let stop = String.fromCharCode(b);
731
+ return `[${start}-${stop}]`;
732
+ };
733
+
734
+ const toRegex = (start, end, options) => {
735
+ if (Array.isArray(start)) {
736
+ let wrap = options.wrap === true;
737
+ let prefix = options.capture ? '' : '?:';
738
+ return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
739
+ }
740
+ return toRegexRange(start, end, options);
741
+ };
742
+
743
+ const rangeError = (...args) => {
744
+ return new RangeError('Invalid range arguments: ' + util.inspect(...args));
745
+ };
746
+
747
+ const invalidRange = (start, end, options) => {
748
+ if (options.strictRanges === true) throw rangeError([start, end]);
749
+ return [];
750
+ };
751
+
752
+ const invalidStep = (step, options) => {
753
+ if (options.strictRanges === true) {
754
+ throw new TypeError(`Expected step "${step}" to be a number`);
755
+ }
756
+ return [];
757
+ };
758
+
759
+ const fillNumbers = (start, end, step = 1, options = {}) => {
760
+ let a = Number(start);
761
+ let b = Number(end);
762
+
763
+ if (!Number.isInteger(a) || !Number.isInteger(b)) {
764
+ if (options.strictRanges === true) throw rangeError([start, end]);
765
+ return [];
766
+ }
767
+
768
+ // fix negative zero
769
+ if (a === 0) a = 0;
770
+ if (b === 0) b = 0;
771
+
772
+ let descending = a > b;
773
+ let startString = String(start);
774
+ let endString = String(end);
775
+ let stepString = String(step);
776
+ step = Math.max(Math.abs(step), 1);
777
+
778
+ let padded = zeros(startString) || zeros(endString) || zeros(stepString);
779
+ let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
780
+ let toNumber = padded === false && stringify(start, end, options) === false;
781
+ let format = options.transform || transform(toNumber);
782
+
783
+ if (options.toRegex && step === 1) {
784
+ return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
785
+ }
786
+
787
+ let parts = { negatives: [], positives: [] };
788
+ let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
789
+ let range = [];
790
+ let index = 0;
791
+
792
+ while (descending ? a >= b : a <= b) {
793
+ if (options.toRegex === true && step > 1) {
794
+ push(a);
795
+ } else {
796
+ range.push(pad(format(a, index), maxLen, toNumber));
797
+ }
798
+ a = descending ? a - step : a + step;
799
+ index++;
800
+ }
801
+
802
+ if (options.toRegex === true) {
803
+ return step > 1
804
+ ? toSequence(parts, options)
805
+ : toRegex(range, null, { wrap: false, ...options });
806
+ }
807
+
808
+ return range;
809
+ };
810
+
811
+ const fillLetters = (start, end, step = 1, options = {}) => {
812
+ if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) {
813
+ return invalidRange(start, end, options);
814
+ }
815
+
816
+
817
+ let format = options.transform || (val => String.fromCharCode(val));
818
+ let a = `${start}`.charCodeAt(0);
819
+ let b = `${end}`.charCodeAt(0);
820
+
821
+ let descending = a > b;
822
+ let min = Math.min(a, b);
823
+ let max = Math.max(a, b);
824
+
825
+ if (options.toRegex && step === 1) {
826
+ return toRange(min, max, false, options);
827
+ }
828
+
829
+ let range = [];
830
+ let index = 0;
831
+
832
+ while (descending ? a >= b : a <= b) {
833
+ range.push(format(a, index));
834
+ a = descending ? a - step : a + step;
835
+ index++;
836
+ }
837
+
838
+ if (options.toRegex === true) {
839
+ return toRegex(range, null, { wrap: false, options });
840
+ }
841
+
842
+ return range;
843
+ };
844
+
845
+ const fill = (start, end, step, options = {}) => {
846
+ if (end == null && isValidValue(start)) {
847
+ return [start];
848
+ }
849
+
850
+ if (!isValidValue(start) || !isValidValue(end)) {
851
+ return invalidRange(start, end, options);
852
+ }
853
+
854
+ if (typeof step === 'function') {
855
+ return fill(start, end, 1, { transform: step });
856
+ }
857
+
858
+ if (isObject(step)) {
859
+ return fill(start, end, 0, step);
860
+ }
861
+
862
+ let opts = { ...options };
863
+ if (opts.capture === true) opts.wrap = true;
864
+ step = step || opts.step || 1;
865
+
866
+ if (!isNumber(step)) {
867
+ if (step != null && !isObject(step)) return invalidStep(step, opts);
868
+ return fill(start, end, 1, step);
869
+ }
870
+
871
+ if (isNumber(start) && isNumber(end)) {
872
+ return fillNumbers(start, end, step, opts);
873
+ }
874
+
875
+ return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
876
+ };
877
+
878
+ fillRange = fill;
879
+ return fillRange;
880
+ }
881
+
882
+ var compile_1;
883
+ var hasRequiredCompile;
884
+
885
+ function requireCompile () {
886
+ if (hasRequiredCompile) return compile_1;
887
+ hasRequiredCompile = 1;
888
+
889
+ const fill = requireFillRange();
890
+ const utils = requireUtils$1();
891
+
892
+ const compile = (ast, options = {}) => {
893
+ let walk = (node, parent = {}) => {
894
+ let invalidBlock = utils.isInvalidBrace(parent);
895
+ let invalidNode = node.invalid === true && options.escapeInvalid === true;
896
+ let invalid = invalidBlock === true || invalidNode === true;
897
+ let prefix = options.escapeInvalid === true ? '\\' : '';
898
+ let output = '';
899
+
900
+ if (node.isOpen === true) {
901
+ return prefix + node.value;
902
+ }
903
+ if (node.isClose === true) {
904
+ return prefix + node.value;
905
+ }
906
+
907
+ if (node.type === 'open') {
908
+ return invalid ? (prefix + node.value) : '(';
909
+ }
910
+
911
+ if (node.type === 'close') {
912
+ return invalid ? (prefix + node.value) : ')';
913
+ }
914
+
915
+ if (node.type === 'comma') {
916
+ return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
917
+ }
918
+
919
+ if (node.value) {
920
+ return node.value;
921
+ }
922
+
923
+ if (node.nodes && node.ranges > 0) {
924
+ let args = utils.reduce(node.nodes);
925
+ let range = fill(...args, { ...options, wrap: false, toRegex: true });
926
+
927
+ if (range.length !== 0) {
928
+ return args.length > 1 && range.length > 1 ? `(${range})` : range;
929
+ }
930
+ }
931
+
932
+ if (node.nodes) {
933
+ for (let child of node.nodes) {
934
+ output += walk(child, node);
935
+ }
936
+ }
937
+ return output;
938
+ };
939
+
940
+ return walk(ast);
941
+ };
942
+
943
+ compile_1 = compile;
944
+ return compile_1;
945
+ }
946
+
947
+ var expand_1;
948
+ var hasRequiredExpand;
949
+
950
+ function requireExpand () {
951
+ if (hasRequiredExpand) return expand_1;
952
+ hasRequiredExpand = 1;
953
+
954
+ const fill = requireFillRange();
955
+ const stringify = requireStringify();
956
+ const utils = requireUtils$1();
957
+
958
+ const append = (queue = '', stash = '', enclose = false) => {
959
+ let result = [];
960
+
961
+ queue = [].concat(queue);
962
+ stash = [].concat(stash);
963
+
964
+ if (!stash.length) return queue;
965
+ if (!queue.length) {
966
+ return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
967
+ }
968
+
969
+ for (let item of queue) {
970
+ if (Array.isArray(item)) {
971
+ for (let value of item) {
972
+ result.push(append(value, stash, enclose));
973
+ }
974
+ } else {
975
+ for (let ele of stash) {
976
+ if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
977
+ result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
978
+ }
979
+ }
980
+ }
981
+ return utils.flatten(result);
982
+ };
983
+
984
+ const expand = (ast, options = {}) => {
985
+ let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
986
+
987
+ let walk = (node, parent = {}) => {
988
+ node.queue = [];
989
+
990
+ let p = parent;
991
+ let q = parent.queue;
992
+
993
+ while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
994
+ p = p.parent;
995
+ q = p.queue;
996
+ }
997
+
998
+ if (node.invalid || node.dollar) {
999
+ q.push(append(q.pop(), stringify(node, options)));
1000
+ return;
1001
+ }
1002
+
1003
+ if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
1004
+ q.push(append(q.pop(), ['{}']));
1005
+ return;
1006
+ }
1007
+
1008
+ if (node.nodes && node.ranges > 0) {
1009
+ let args = utils.reduce(node.nodes);
1010
+
1011
+ if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
1012
+ throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
1013
+ }
1014
+
1015
+ let range = fill(...args, options);
1016
+ if (range.length === 0) {
1017
+ range = stringify(node, options);
1018
+ }
1019
+
1020
+ q.push(append(q.pop(), range));
1021
+ node.nodes = [];
1022
+ return;
1023
+ }
1024
+
1025
+ let enclose = utils.encloseBrace(node);
1026
+ let queue = node.queue;
1027
+ let block = node;
1028
+
1029
+ while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
1030
+ block = block.parent;
1031
+ queue = block.queue;
1032
+ }
1033
+
1034
+ for (let i = 0; i < node.nodes.length; i++) {
1035
+ let child = node.nodes[i];
1036
+
1037
+ if (child.type === 'comma' && node.type === 'brace') {
1038
+ if (i === 1) queue.push('');
1039
+ queue.push('');
1040
+ continue;
1041
+ }
1042
+
1043
+ if (child.type === 'close') {
1044
+ q.push(append(q.pop(), queue, enclose));
1045
+ continue;
1046
+ }
1047
+
1048
+ if (child.value && child.type !== 'open') {
1049
+ queue.push(append(queue.pop(), child.value));
1050
+ continue;
1051
+ }
1052
+
1053
+ if (child.nodes) {
1054
+ walk(child, node);
1055
+ }
1056
+ }
1057
+
1058
+ return queue;
1059
+ };
1060
+
1061
+ return utils.flatten(walk(ast));
1062
+ };
1063
+
1064
+ expand_1 = expand;
1065
+ return expand_1;
1066
+ }
1067
+
1068
+ var constants$1;
1069
+ var hasRequiredConstants$1;
1070
+
1071
+ function requireConstants$1 () {
1072
+ if (hasRequiredConstants$1) return constants$1;
1073
+ hasRequiredConstants$1 = 1;
1074
+
1075
+ constants$1 = {
1076
+ MAX_LENGTH: 1024 * 64,
1077
+
1078
+ // Digits
1079
+ CHAR_0: '0', /* 0 */
1080
+ CHAR_9: '9', /* 9 */
1081
+
1082
+ // Alphabet chars.
1083
+ CHAR_UPPERCASE_A: 'A', /* A */
1084
+ CHAR_LOWERCASE_A: 'a', /* a */
1085
+ CHAR_UPPERCASE_Z: 'Z', /* Z */
1086
+ CHAR_LOWERCASE_Z: 'z', /* z */
1087
+
1088
+ CHAR_LEFT_PARENTHESES: '(', /* ( */
1089
+ CHAR_RIGHT_PARENTHESES: ')', /* ) */
1090
+
1091
+ CHAR_ASTERISK: '*', /* * */
1092
+
1093
+ // Non-alphabetic chars.
1094
+ CHAR_AMPERSAND: '&', /* & */
1095
+ CHAR_AT: '@', /* @ */
1096
+ CHAR_BACKSLASH: '\\', /* \ */
1097
+ CHAR_BACKTICK: '`', /* ` */
1098
+ CHAR_CARRIAGE_RETURN: '\r', /* \r */
1099
+ CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
1100
+ CHAR_COLON: ':', /* : */
1101
+ CHAR_COMMA: ',', /* , */
1102
+ CHAR_DOLLAR: '$', /* . */
1103
+ CHAR_DOT: '.', /* . */
1104
+ CHAR_DOUBLE_QUOTE: '"', /* " */
1105
+ CHAR_EQUAL: '=', /* = */
1106
+ CHAR_EXCLAMATION_MARK: '!', /* ! */
1107
+ CHAR_FORM_FEED: '\f', /* \f */
1108
+ CHAR_FORWARD_SLASH: '/', /* / */
1109
+ CHAR_HASH: '#', /* # */
1110
+ CHAR_HYPHEN_MINUS: '-', /* - */
1111
+ CHAR_LEFT_ANGLE_BRACKET: '<', /* < */
1112
+ CHAR_LEFT_CURLY_BRACE: '{', /* { */
1113
+ CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */
1114
+ CHAR_LINE_FEED: '\n', /* \n */
1115
+ CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */
1116
+ CHAR_PERCENT: '%', /* % */
1117
+ CHAR_PLUS: '+', /* + */
1118
+ CHAR_QUESTION_MARK: '?', /* ? */
1119
+ CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */
1120
+ CHAR_RIGHT_CURLY_BRACE: '}', /* } */
1121
+ CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */
1122
+ CHAR_SEMICOLON: ';', /* ; */
1123
+ CHAR_SINGLE_QUOTE: '\'', /* ' */
1124
+ CHAR_SPACE: ' ', /* */
1125
+ CHAR_TAB: '\t', /* \t */
1126
+ CHAR_UNDERSCORE: '_', /* _ */
1127
+ CHAR_VERTICAL_LINE: '|', /* | */
1128
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */
1129
+ };
1130
+ return constants$1;
1131
+ }
1132
+
1133
+ var parse_1$1;
1134
+ var hasRequiredParse$1;
1135
+
1136
+ function requireParse$1 () {
1137
+ if (hasRequiredParse$1) return parse_1$1;
1138
+ hasRequiredParse$1 = 1;
1139
+
1140
+ const stringify = requireStringify();
1141
+
1142
+ /**
1143
+ * Constants
1144
+ */
1145
+
1146
+ const {
1147
+ MAX_LENGTH,
1148
+ CHAR_BACKSLASH, /* \ */
1149
+ CHAR_BACKTICK, /* ` */
1150
+ CHAR_COMMA, /* , */
1151
+ CHAR_DOT, /* . */
1152
+ CHAR_LEFT_PARENTHESES, /* ( */
1153
+ CHAR_RIGHT_PARENTHESES, /* ) */
1154
+ CHAR_LEFT_CURLY_BRACE, /* { */
1155
+ CHAR_RIGHT_CURLY_BRACE, /* } */
1156
+ CHAR_LEFT_SQUARE_BRACKET, /* [ */
1157
+ CHAR_RIGHT_SQUARE_BRACKET, /* ] */
1158
+ CHAR_DOUBLE_QUOTE, /* " */
1159
+ CHAR_SINGLE_QUOTE, /* ' */
1160
+ CHAR_NO_BREAK_SPACE,
1161
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE
1162
+ } = requireConstants$1();
1163
+
1164
+ /**
1165
+ * parse
1166
+ */
1167
+
1168
+ const parse = (input, options = {}) => {
1169
+ if (typeof input !== 'string') {
1170
+ throw new TypeError('Expected a string');
1171
+ }
1172
+
1173
+ let opts = options || {};
1174
+ let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1175
+ if (input.length > max) {
1176
+ throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
1177
+ }
1178
+
1179
+ let ast = { type: 'root', input, nodes: [] };
1180
+ let stack = [ast];
1181
+ let block = ast;
1182
+ let prev = ast;
1183
+ let brackets = 0;
1184
+ let length = input.length;
1185
+ let index = 0;
1186
+ let depth = 0;
1187
+ let value;
1188
+
1189
+ /**
1190
+ * Helpers
1191
+ */
1192
+
1193
+ const advance = () => input[index++];
1194
+ const push = node => {
1195
+ if (node.type === 'text' && prev.type === 'dot') {
1196
+ prev.type = 'text';
1197
+ }
1198
+
1199
+ if (prev && prev.type === 'text' && node.type === 'text') {
1200
+ prev.value += node.value;
1201
+ return;
1202
+ }
1203
+
1204
+ block.nodes.push(node);
1205
+ node.parent = block;
1206
+ node.prev = prev;
1207
+ prev = node;
1208
+ return node;
1209
+ };
1210
+
1211
+ push({ type: 'bos' });
1212
+
1213
+ while (index < length) {
1214
+ block = stack[stack.length - 1];
1215
+ value = advance();
1216
+
1217
+ /**
1218
+ * Invalid chars
1219
+ */
1220
+
1221
+ if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
1222
+ continue;
1223
+ }
1224
+
1225
+ /**
1226
+ * Escaped chars
1227
+ */
1228
+
1229
+ if (value === CHAR_BACKSLASH) {
1230
+ push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() });
1231
+ continue;
1232
+ }
1233
+
1234
+ /**
1235
+ * Right square bracket (literal): ']'
1236
+ */
1237
+
1238
+ if (value === CHAR_RIGHT_SQUARE_BRACKET) {
1239
+ push({ type: 'text', value: '\\' + value });
1240
+ continue;
1241
+ }
1242
+
1243
+ /**
1244
+ * Left square bracket: '['
1245
+ */
1246
+
1247
+ if (value === CHAR_LEFT_SQUARE_BRACKET) {
1248
+ brackets++;
1249
+ let next;
1250
+
1251
+ while (index < length && (next = advance())) {
1252
+ value += next;
1253
+
1254
+ if (next === CHAR_LEFT_SQUARE_BRACKET) {
1255
+ brackets++;
1256
+ continue;
1257
+ }
1258
+
1259
+ if (next === CHAR_BACKSLASH) {
1260
+ value += advance();
1261
+ continue;
1262
+ }
1263
+
1264
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1265
+ brackets--;
1266
+
1267
+ if (brackets === 0) {
1268
+ break;
1269
+ }
1270
+ }
1271
+ }
1272
+
1273
+ push({ type: 'text', value });
1274
+ continue;
1275
+ }
1276
+
1277
+ /**
1278
+ * Parentheses
1279
+ */
1280
+
1281
+ if (value === CHAR_LEFT_PARENTHESES) {
1282
+ block = push({ type: 'paren', nodes: [] });
1283
+ stack.push(block);
1284
+ push({ type: 'text', value });
1285
+ continue;
1286
+ }
1287
+
1288
+ if (value === CHAR_RIGHT_PARENTHESES) {
1289
+ if (block.type !== 'paren') {
1290
+ push({ type: 'text', value });
1291
+ continue;
1292
+ }
1293
+ block = stack.pop();
1294
+ push({ type: 'text', value });
1295
+ block = stack[stack.length - 1];
1296
+ continue;
1297
+ }
1298
+
1299
+ /**
1300
+ * Quotes: '|"|`
1301
+ */
1302
+
1303
+ if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
1304
+ let open = value;
1305
+ let next;
1306
+
1307
+ if (options.keepQuotes !== true) {
1308
+ value = '';
1309
+ }
1310
+
1311
+ while (index < length && (next = advance())) {
1312
+ if (next === CHAR_BACKSLASH) {
1313
+ value += next + advance();
1314
+ continue;
1315
+ }
1316
+
1317
+ if (next === open) {
1318
+ if (options.keepQuotes === true) value += next;
1319
+ break;
1320
+ }
1321
+
1322
+ value += next;
1323
+ }
1324
+
1325
+ push({ type: 'text', value });
1326
+ continue;
1327
+ }
1328
+
1329
+ /**
1330
+ * Left curly brace: '{'
1331
+ */
1332
+
1333
+ if (value === CHAR_LEFT_CURLY_BRACE) {
1334
+ depth++;
1335
+
1336
+ let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
1337
+ let brace = {
1338
+ type: 'brace',
1339
+ open: true,
1340
+ close: false,
1341
+ dollar,
1342
+ depth,
1343
+ commas: 0,
1344
+ ranges: 0,
1345
+ nodes: []
1346
+ };
1347
+
1348
+ block = push(brace);
1349
+ stack.push(block);
1350
+ push({ type: 'open', value });
1351
+ continue;
1352
+ }
1353
+
1354
+ /**
1355
+ * Right curly brace: '}'
1356
+ */
1357
+
1358
+ if (value === CHAR_RIGHT_CURLY_BRACE) {
1359
+ if (block.type !== 'brace') {
1360
+ push({ type: 'text', value });
1361
+ continue;
1362
+ }
1363
+
1364
+ let type = 'close';
1365
+ block = stack.pop();
1366
+ block.close = true;
1367
+
1368
+ push({ type, value });
1369
+ depth--;
1370
+
1371
+ block = stack[stack.length - 1];
1372
+ continue;
1373
+ }
1374
+
1375
+ /**
1376
+ * Comma: ','
1377
+ */
1378
+
1379
+ if (value === CHAR_COMMA && depth > 0) {
1380
+ if (block.ranges > 0) {
1381
+ block.ranges = 0;
1382
+ let open = block.nodes.shift();
1383
+ block.nodes = [open, { type: 'text', value: stringify(block) }];
1384
+ }
1385
+
1386
+ push({ type: 'comma', value });
1387
+ block.commas++;
1388
+ continue;
1389
+ }
1390
+
1391
+ /**
1392
+ * Dot: '.'
1393
+ */
1394
+
1395
+ if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
1396
+ let siblings = block.nodes;
1397
+
1398
+ if (depth === 0 || siblings.length === 0) {
1399
+ push({ type: 'text', value });
1400
+ continue;
1401
+ }
1402
+
1403
+ if (prev.type === 'dot') {
1404
+ block.range = [];
1405
+ prev.value += value;
1406
+ prev.type = 'range';
1407
+
1408
+ if (block.nodes.length !== 3 && block.nodes.length !== 5) {
1409
+ block.invalid = true;
1410
+ block.ranges = 0;
1411
+ prev.type = 'text';
1412
+ continue;
1413
+ }
1414
+
1415
+ block.ranges++;
1416
+ block.args = [];
1417
+ continue;
1418
+ }
1419
+
1420
+ if (prev.type === 'range') {
1421
+ siblings.pop();
1422
+
1423
+ let before = siblings[siblings.length - 1];
1424
+ before.value += prev.value + value;
1425
+ prev = before;
1426
+ block.ranges--;
1427
+ continue;
1428
+ }
1429
+
1430
+ push({ type: 'dot', value });
1431
+ continue;
1432
+ }
1433
+
1434
+ /**
1435
+ * Text
1436
+ */
1437
+
1438
+ push({ type: 'text', value });
1439
+ }
1440
+
1441
+ // Mark imbalanced braces and brackets as invalid
1442
+ do {
1443
+ block = stack.pop();
1444
+
1445
+ if (block.type !== 'root') {
1446
+ block.nodes.forEach(node => {
1447
+ if (!node.nodes) {
1448
+ if (node.type === 'open') node.isOpen = true;
1449
+ if (node.type === 'close') node.isClose = true;
1450
+ if (!node.nodes) node.type = 'text';
1451
+ node.invalid = true;
1452
+ }
1453
+ });
1454
+
1455
+ // get the location of the block on parent.nodes (block's siblings)
1456
+ let parent = stack[stack.length - 1];
1457
+ let index = parent.nodes.indexOf(block);
1458
+ // replace the (invalid) block with it's nodes
1459
+ parent.nodes.splice(index, 1, ...block.nodes);
1460
+ }
1461
+ } while (stack.length > 0);
1462
+
1463
+ push({ type: 'eos' });
1464
+ return ast;
1465
+ };
1466
+
1467
+ parse_1$1 = parse;
1468
+ return parse_1$1;
1469
+ }
1470
+
1471
+ var braces_1;
1472
+ var hasRequiredBraces;
1473
+
1474
+ function requireBraces () {
1475
+ if (hasRequiredBraces) return braces_1;
1476
+ hasRequiredBraces = 1;
1477
+
1478
+ const stringify = requireStringify();
1479
+ const compile = requireCompile();
1480
+ const expand = requireExpand();
1481
+ const parse = requireParse$1();
1482
+
1483
+ /**
1484
+ * Expand the given pattern or create a regex-compatible string.
1485
+ *
1486
+ * ```js
1487
+ * const braces = require('braces');
1488
+ * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
1489
+ * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
1490
+ * ```
1491
+ * @param {String} `str`
1492
+ * @param {Object} `options`
1493
+ * @return {String}
1494
+ * @api public
1495
+ */
1496
+
1497
+ const braces = (input, options = {}) => {
1498
+ let output = [];
1499
+
1500
+ if (Array.isArray(input)) {
1501
+ for (let pattern of input) {
1502
+ let result = braces.create(pattern, options);
1503
+ if (Array.isArray(result)) {
1504
+ output.push(...result);
1505
+ } else {
1506
+ output.push(result);
1507
+ }
1508
+ }
1509
+ } else {
1510
+ output = [].concat(braces.create(input, options));
1511
+ }
1512
+
1513
+ if (options && options.expand === true && options.nodupes === true) {
1514
+ output = [...new Set(output)];
1515
+ }
1516
+ return output;
1517
+ };
1518
+
1519
+ /**
1520
+ * Parse the given `str` with the given `options`.
1521
+ *
1522
+ * ```js
1523
+ * // braces.parse(pattern, [, options]);
1524
+ * const ast = braces.parse('a/{b,c}/d');
1525
+ * console.log(ast);
1526
+ * ```
1527
+ * @param {String} pattern Brace pattern to parse
1528
+ * @param {Object} options
1529
+ * @return {Object} Returns an AST
1530
+ * @api public
1531
+ */
1532
+
1533
+ braces.parse = (input, options = {}) => parse(input, options);
1534
+
1535
+ /**
1536
+ * Creates a braces string from an AST, or an AST node.
1537
+ *
1538
+ * ```js
1539
+ * const braces = require('braces');
1540
+ * let ast = braces.parse('foo/{a,b}/bar');
1541
+ * console.log(stringify(ast.nodes[2])); //=> '{a,b}'
1542
+ * ```
1543
+ * @param {String} `input` Brace pattern or AST.
1544
+ * @param {Object} `options`
1545
+ * @return {Array} Returns an array of expanded values.
1546
+ * @api public
1547
+ */
1548
+
1549
+ braces.stringify = (input, options = {}) => {
1550
+ if (typeof input === 'string') {
1551
+ return stringify(braces.parse(input, options), options);
1552
+ }
1553
+ return stringify(input, options);
1554
+ };
1555
+
1556
+ /**
1557
+ * Compiles a brace pattern into a regex-compatible, optimized string.
1558
+ * This method is called by the main [braces](#braces) function by default.
1559
+ *
1560
+ * ```js
1561
+ * const braces = require('braces');
1562
+ * console.log(braces.compile('a/{b,c}/d'));
1563
+ * //=> ['a/(b|c)/d']
1564
+ * ```
1565
+ * @param {String} `input` Brace pattern or AST.
1566
+ * @param {Object} `options`
1567
+ * @return {Array} Returns an array of expanded values.
1568
+ * @api public
1569
+ */
1570
+
1571
+ braces.compile = (input, options = {}) => {
1572
+ if (typeof input === 'string') {
1573
+ input = braces.parse(input, options);
1574
+ }
1575
+ return compile(input, options);
1576
+ };
1577
+
1578
+ /**
1579
+ * Expands a brace pattern into an array. This method is called by the
1580
+ * main [braces](#braces) function when `options.expand` is true. Before
1581
+ * using this method it's recommended that you read the [performance notes](#performance))
1582
+ * and advantages of using [.compile](#compile) instead.
1583
+ *
1584
+ * ```js
1585
+ * const braces = require('braces');
1586
+ * console.log(braces.expand('a/{b,c}/d'));
1587
+ * //=> ['a/b/d', 'a/c/d'];
1588
+ * ```
1589
+ * @param {String} `pattern` Brace pattern
1590
+ * @param {Object} `options`
1591
+ * @return {Array} Returns an array of expanded values.
1592
+ * @api public
1593
+ */
1594
+
1595
+ braces.expand = (input, options = {}) => {
1596
+ if (typeof input === 'string') {
1597
+ input = braces.parse(input, options);
1598
+ }
1599
+
1600
+ let result = expand(input, options);
1601
+
1602
+ // filter out empty strings if specified
1603
+ if (options.noempty === true) {
1604
+ result = result.filter(Boolean);
1605
+ }
1606
+
1607
+ // filter out duplicates if specified
1608
+ if (options.nodupes === true) {
1609
+ result = [...new Set(result)];
1610
+ }
1611
+
1612
+ return result;
1613
+ };
1614
+
1615
+ /**
1616
+ * Processes a brace pattern and returns either an expanded array
1617
+ * (if `options.expand` is true), a highly optimized regex-compatible string.
1618
+ * This method is called by the main [braces](#braces) function.
1619
+ *
1620
+ * ```js
1621
+ * const braces = require('braces');
1622
+ * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
1623
+ * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
1624
+ * ```
1625
+ * @param {String} `pattern` Brace pattern
1626
+ * @param {Object} `options`
1627
+ * @return {Array} Returns an array of expanded values.
1628
+ * @api public
1629
+ */
1630
+
1631
+ braces.create = (input, options = {}) => {
1632
+ if (input === '' || input.length < 3) {
1633
+ return [input];
1634
+ }
1635
+
1636
+ return options.expand !== true
1637
+ ? braces.compile(input, options)
1638
+ : braces.expand(input, options);
1639
+ };
1640
+
1641
+ /**
1642
+ * Expose "braces"
1643
+ */
1644
+
1645
+ braces_1 = braces;
1646
+ return braces_1;
1647
+ }
1648
+
1649
+ var utils = {};
1650
+
1651
+ var constants;
1652
+ var hasRequiredConstants;
1653
+
1654
+ function requireConstants () {
1655
+ if (hasRequiredConstants) return constants;
1656
+ hasRequiredConstants = 1;
1657
+
1658
+ const path = require$$0__default$1.default;
1659
+ const WIN_SLASH = '\\\\/';
1660
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1661
+
1662
+ /**
1663
+ * Posix glob regex
1664
+ */
1665
+
1666
+ const DOT_LITERAL = '\\.';
1667
+ const PLUS_LITERAL = '\\+';
1668
+ const QMARK_LITERAL = '\\?';
1669
+ const SLASH_LITERAL = '\\/';
1670
+ const ONE_CHAR = '(?=.)';
1671
+ const QMARK = '[^/]';
1672
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
1673
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
1674
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
1675
+ const NO_DOT = `(?!${DOT_LITERAL})`;
1676
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
1677
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
1678
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
1679
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
1680
+ const STAR = `${QMARK}*?`;
1681
+
1682
+ const POSIX_CHARS = {
1683
+ DOT_LITERAL,
1684
+ PLUS_LITERAL,
1685
+ QMARK_LITERAL,
1686
+ SLASH_LITERAL,
1687
+ ONE_CHAR,
1688
+ QMARK,
1689
+ END_ANCHOR,
1690
+ DOTS_SLASH,
1691
+ NO_DOT,
1692
+ NO_DOTS,
1693
+ NO_DOT_SLASH,
1694
+ NO_DOTS_SLASH,
1695
+ QMARK_NO_DOT,
1696
+ STAR,
1697
+ START_ANCHOR
1698
+ };
1699
+
1700
+ /**
1701
+ * Windows glob regex
1702
+ */
1703
+
1704
+ const WINDOWS_CHARS = {
1705
+ ...POSIX_CHARS,
1706
+
1707
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
1708
+ QMARK: WIN_NO_SLASH,
1709
+ STAR: `${WIN_NO_SLASH}*?`,
1710
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
1711
+ NO_DOT: `(?!${DOT_LITERAL})`,
1712
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1713
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
1714
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1715
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
1716
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
1717
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
1718
+ };
1719
+
1720
+ /**
1721
+ * POSIX Bracket Regex
1722
+ */
1723
+
1724
+ const POSIX_REGEX_SOURCE = {
1725
+ alnum: 'a-zA-Z0-9',
1726
+ alpha: 'a-zA-Z',
1727
+ ascii: '\\x00-\\x7F',
1728
+ blank: ' \\t',
1729
+ cntrl: '\\x00-\\x1F\\x7F',
1730
+ digit: '0-9',
1731
+ graph: '\\x21-\\x7E',
1732
+ lower: 'a-z',
1733
+ print: '\\x20-\\x7E ',
1734
+ punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
1735
+ space: ' \\t\\r\\n\\v\\f',
1736
+ upper: 'A-Z',
1737
+ word: 'A-Za-z0-9_',
1738
+ xdigit: 'A-Fa-f0-9'
1739
+ };
1740
+
1741
+ constants = {
1742
+ MAX_LENGTH: 1024 * 64,
1743
+ POSIX_REGEX_SOURCE,
1744
+
1745
+ // regular expressions
1746
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
1747
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
1748
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
1749
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
1750
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
1751
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
1752
+
1753
+ // Replace globs with equivalent patterns to reduce parsing time.
1754
+ REPLACEMENTS: {
1755
+ '***': '*',
1756
+ '**/**': '**',
1757
+ '**/**/**': '**'
1758
+ },
1759
+
1760
+ // Digits
1761
+ CHAR_0: 48, /* 0 */
1762
+ CHAR_9: 57, /* 9 */
1763
+
1764
+ // Alphabet chars.
1765
+ CHAR_UPPERCASE_A: 65, /* A */
1766
+ CHAR_LOWERCASE_A: 97, /* a */
1767
+ CHAR_UPPERCASE_Z: 90, /* Z */
1768
+ CHAR_LOWERCASE_Z: 122, /* z */
1769
+
1770
+ CHAR_LEFT_PARENTHESES: 40, /* ( */
1771
+ CHAR_RIGHT_PARENTHESES: 41, /* ) */
1772
+
1773
+ CHAR_ASTERISK: 42, /* * */
1774
+
1775
+ // Non-alphabetic chars.
1776
+ CHAR_AMPERSAND: 38, /* & */
1777
+ CHAR_AT: 64, /* @ */
1778
+ CHAR_BACKWARD_SLASH: 92, /* \ */
1779
+ CHAR_CARRIAGE_RETURN: 13, /* \r */
1780
+ CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
1781
+ CHAR_COLON: 58, /* : */
1782
+ CHAR_COMMA: 44, /* , */
1783
+ CHAR_DOT: 46, /* . */
1784
+ CHAR_DOUBLE_QUOTE: 34, /* " */
1785
+ CHAR_EQUAL: 61, /* = */
1786
+ CHAR_EXCLAMATION_MARK: 33, /* ! */
1787
+ CHAR_FORM_FEED: 12, /* \f */
1788
+ CHAR_FORWARD_SLASH: 47, /* / */
1789
+ CHAR_GRAVE_ACCENT: 96, /* ` */
1790
+ CHAR_HASH: 35, /* # */
1791
+ CHAR_HYPHEN_MINUS: 45, /* - */
1792
+ CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
1793
+ CHAR_LEFT_CURLY_BRACE: 123, /* { */
1794
+ CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
1795
+ CHAR_LINE_FEED: 10, /* \n */
1796
+ CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
1797
+ CHAR_PERCENT: 37, /* % */
1798
+ CHAR_PLUS: 43, /* + */
1799
+ CHAR_QUESTION_MARK: 63, /* ? */
1800
+ CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
1801
+ CHAR_RIGHT_CURLY_BRACE: 125, /* } */
1802
+ CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
1803
+ CHAR_SEMICOLON: 59, /* ; */
1804
+ CHAR_SINGLE_QUOTE: 39, /* ' */
1805
+ CHAR_SPACE: 32, /* */
1806
+ CHAR_TAB: 9, /* \t */
1807
+ CHAR_UNDERSCORE: 95, /* _ */
1808
+ CHAR_VERTICAL_LINE: 124, /* | */
1809
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
1810
+
1811
+ SEP: path.sep,
1812
+
1813
+ /**
1814
+ * Create EXTGLOB_CHARS
1815
+ */
1816
+
1817
+ extglobChars(chars) {
1818
+ return {
1819
+ '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
1820
+ '?': { type: 'qmark', open: '(?:', close: ')?' },
1821
+ '+': { type: 'plus', open: '(?:', close: ')+' },
1822
+ '*': { type: 'star', open: '(?:', close: ')*' },
1823
+ '@': { type: 'at', open: '(?:', close: ')' }
1824
+ };
1825
+ },
1826
+
1827
+ /**
1828
+ * Create GLOB_CHARS
1829
+ */
1830
+
1831
+ globChars(win32) {
1832
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
1833
+ }
1834
+ };
1835
+ return constants;
1836
+ }
1837
+
1838
+ var hasRequiredUtils;
1839
+
1840
+ function requireUtils () {
1841
+ if (hasRequiredUtils) return utils;
1842
+ hasRequiredUtils = 1;
1843
+ (function (exports) {
1844
+
1845
+ const path = require$$0__default$1.default;
1846
+ const win32 = process.platform === 'win32';
1847
+ const {
1848
+ REGEX_BACKSLASH,
1849
+ REGEX_REMOVE_BACKSLASH,
1850
+ REGEX_SPECIAL_CHARS,
1851
+ REGEX_SPECIAL_CHARS_GLOBAL
1852
+ } = requireConstants();
1853
+
1854
+ exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1855
+ exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
1856
+ exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
1857
+ exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
1858
+ exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
1859
+
1860
+ exports.removeBackslashes = str => {
1861
+ return str.replace(REGEX_REMOVE_BACKSLASH, match => {
1862
+ return match === '\\' ? '' : match;
1863
+ });
1864
+ };
1865
+
1866
+ exports.supportsLookbehinds = () => {
1867
+ const segs = process.version.slice(1).split('.').map(Number);
1868
+ if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
1869
+ return true;
1870
+ }
1871
+ return false;
1872
+ };
1873
+
1874
+ exports.isWindows = options => {
1875
+ if (options && typeof options.windows === 'boolean') {
1876
+ return options.windows;
1877
+ }
1878
+ return win32 === true || path.sep === '\\';
1879
+ };
1880
+
1881
+ exports.escapeLast = (input, char, lastIdx) => {
1882
+ const idx = input.lastIndexOf(char, lastIdx);
1883
+ if (idx === -1) return input;
1884
+ if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
1885
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
1886
+ };
1887
+
1888
+ exports.removePrefix = (input, state = {}) => {
1889
+ let output = input;
1890
+ if (output.startsWith('./')) {
1891
+ output = output.slice(2);
1892
+ state.prefix = './';
1893
+ }
1894
+ return output;
1895
+ };
1896
+
1897
+ exports.wrapOutput = (input, state = {}, options = {}) => {
1898
+ const prepend = options.contains ? '' : '^';
1899
+ const append = options.contains ? '' : '$';
1900
+
1901
+ let output = `${prepend}(?:${input})${append}`;
1902
+ if (state.negated === true) {
1903
+ output = `(?:^(?!${output}).*$)`;
1904
+ }
1905
+ return output;
1906
+ };
1907
+ } (utils));
1908
+ return utils;
1909
+ }
1910
+
1911
+ var scan_1;
1912
+ var hasRequiredScan;
1913
+
1914
+ function requireScan () {
1915
+ if (hasRequiredScan) return scan_1;
1916
+ hasRequiredScan = 1;
1917
+
1918
+ const utils = requireUtils();
1919
+ const {
1920
+ CHAR_ASTERISK, /* * */
1921
+ CHAR_AT, /* @ */
1922
+ CHAR_BACKWARD_SLASH, /* \ */
1923
+ CHAR_COMMA, /* , */
1924
+ CHAR_DOT, /* . */
1925
+ CHAR_EXCLAMATION_MARK, /* ! */
1926
+ CHAR_FORWARD_SLASH, /* / */
1927
+ CHAR_LEFT_CURLY_BRACE, /* { */
1928
+ CHAR_LEFT_PARENTHESES, /* ( */
1929
+ CHAR_LEFT_SQUARE_BRACKET, /* [ */
1930
+ CHAR_PLUS, /* + */
1931
+ CHAR_QUESTION_MARK, /* ? */
1932
+ CHAR_RIGHT_CURLY_BRACE, /* } */
1933
+ CHAR_RIGHT_PARENTHESES, /* ) */
1934
+ CHAR_RIGHT_SQUARE_BRACKET /* ] */
1935
+ } = requireConstants();
1936
+
1937
+ const isPathSeparator = code => {
1938
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
1939
+ };
1940
+
1941
+ const depth = token => {
1942
+ if (token.isPrefix !== true) {
1943
+ token.depth = token.isGlobstar ? Infinity : 1;
1944
+ }
1945
+ };
1946
+
1947
+ /**
1948
+ * Quickly scans a glob pattern and returns an object with a handful of
1949
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
1950
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
1951
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
1952
+ *
1953
+ * ```js
1954
+ * const pm = require('picomatch');
1955
+ * console.log(pm.scan('foo/bar/*.js'));
1956
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
1957
+ * ```
1958
+ * @param {String} `str`
1959
+ * @param {Object} `options`
1960
+ * @return {Object} Returns an object with tokens and regex source string.
1961
+ * @api public
1962
+ */
1963
+
1964
+ const scan = (input, options) => {
1965
+ const opts = options || {};
1966
+
1967
+ const length = input.length - 1;
1968
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
1969
+ const slashes = [];
1970
+ const tokens = [];
1971
+ const parts = [];
1972
+
1973
+ let str = input;
1974
+ let index = -1;
1975
+ let start = 0;
1976
+ let lastIndex = 0;
1977
+ let isBrace = false;
1978
+ let isBracket = false;
1979
+ let isGlob = false;
1980
+ let isExtglob = false;
1981
+ let isGlobstar = false;
1982
+ let braceEscaped = false;
1983
+ let backslashes = false;
1984
+ let negated = false;
1985
+ let negatedExtglob = false;
1986
+ let finished = false;
1987
+ let braces = 0;
1988
+ let prev;
1989
+ let code;
1990
+ let token = { value: '', depth: 0, isGlob: false };
1991
+
1992
+ const eos = () => index >= length;
1993
+ const peek = () => str.charCodeAt(index + 1);
1994
+ const advance = () => {
1995
+ prev = code;
1996
+ return str.charCodeAt(++index);
1997
+ };
1998
+
1999
+ while (index < length) {
2000
+ code = advance();
2001
+ let next;
2002
+
2003
+ if (code === CHAR_BACKWARD_SLASH) {
2004
+ backslashes = token.backslashes = true;
2005
+ code = advance();
2006
+
2007
+ if (code === CHAR_LEFT_CURLY_BRACE) {
2008
+ braceEscaped = true;
2009
+ }
2010
+ continue;
2011
+ }
2012
+
2013
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
2014
+ braces++;
2015
+
2016
+ while (eos() !== true && (code = advance())) {
2017
+ if (code === CHAR_BACKWARD_SLASH) {
2018
+ backslashes = token.backslashes = true;
2019
+ advance();
2020
+ continue;
2021
+ }
2022
+
2023
+ if (code === CHAR_LEFT_CURLY_BRACE) {
2024
+ braces++;
2025
+ continue;
2026
+ }
2027
+
2028
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
2029
+ isBrace = token.isBrace = true;
2030
+ isGlob = token.isGlob = true;
2031
+ finished = true;
2032
+
2033
+ if (scanToEnd === true) {
2034
+ continue;
2035
+ }
2036
+
2037
+ break;
2038
+ }
2039
+
2040
+ if (braceEscaped !== true && code === CHAR_COMMA) {
2041
+ isBrace = token.isBrace = true;
2042
+ isGlob = token.isGlob = true;
2043
+ finished = true;
2044
+
2045
+ if (scanToEnd === true) {
2046
+ continue;
2047
+ }
2048
+
2049
+ break;
2050
+ }
2051
+
2052
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
2053
+ braces--;
2054
+
2055
+ if (braces === 0) {
2056
+ braceEscaped = false;
2057
+ isBrace = token.isBrace = true;
2058
+ finished = true;
2059
+ break;
2060
+ }
2061
+ }
2062
+ }
2063
+
2064
+ if (scanToEnd === true) {
2065
+ continue;
2066
+ }
2067
+
2068
+ break;
2069
+ }
2070
+
2071
+ if (code === CHAR_FORWARD_SLASH) {
2072
+ slashes.push(index);
2073
+ tokens.push(token);
2074
+ token = { value: '', depth: 0, isGlob: false };
2075
+
2076
+ if (finished === true) continue;
2077
+ if (prev === CHAR_DOT && index === (start + 1)) {
2078
+ start += 2;
2079
+ continue;
2080
+ }
2081
+
2082
+ lastIndex = index + 1;
2083
+ continue;
2084
+ }
2085
+
2086
+ if (opts.noext !== true) {
2087
+ const isExtglobChar = code === CHAR_PLUS
2088
+ || code === CHAR_AT
2089
+ || code === CHAR_ASTERISK
2090
+ || code === CHAR_QUESTION_MARK
2091
+ || code === CHAR_EXCLAMATION_MARK;
2092
+
2093
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
2094
+ isGlob = token.isGlob = true;
2095
+ isExtglob = token.isExtglob = true;
2096
+ finished = true;
2097
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
2098
+ negatedExtglob = true;
2099
+ }
2100
+
2101
+ if (scanToEnd === true) {
2102
+ while (eos() !== true && (code = advance())) {
2103
+ if (code === CHAR_BACKWARD_SLASH) {
2104
+ backslashes = token.backslashes = true;
2105
+ code = advance();
2106
+ continue;
2107
+ }
2108
+
2109
+ if (code === CHAR_RIGHT_PARENTHESES) {
2110
+ isGlob = token.isGlob = true;
2111
+ finished = true;
2112
+ break;
2113
+ }
2114
+ }
2115
+ continue;
2116
+ }
2117
+ break;
2118
+ }
2119
+ }
2120
+
2121
+ if (code === CHAR_ASTERISK) {
2122
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
2123
+ isGlob = token.isGlob = true;
2124
+ finished = true;
2125
+
2126
+ if (scanToEnd === true) {
2127
+ continue;
2128
+ }
2129
+ break;
2130
+ }
2131
+
2132
+ if (code === CHAR_QUESTION_MARK) {
2133
+ isGlob = token.isGlob = true;
2134
+ finished = true;
2135
+
2136
+ if (scanToEnd === true) {
2137
+ continue;
2138
+ }
2139
+ break;
2140
+ }
2141
+
2142
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
2143
+ while (eos() !== true && (next = advance())) {
2144
+ if (next === CHAR_BACKWARD_SLASH) {
2145
+ backslashes = token.backslashes = true;
2146
+ advance();
2147
+ continue;
2148
+ }
2149
+
2150
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
2151
+ isBracket = token.isBracket = true;
2152
+ isGlob = token.isGlob = true;
2153
+ finished = true;
2154
+ break;
2155
+ }
2156
+ }
2157
+
2158
+ if (scanToEnd === true) {
2159
+ continue;
2160
+ }
2161
+
2162
+ break;
2163
+ }
2164
+
2165
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
2166
+ negated = token.negated = true;
2167
+ start++;
2168
+ continue;
2169
+ }
2170
+
2171
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
2172
+ isGlob = token.isGlob = true;
2173
+
2174
+ if (scanToEnd === true) {
2175
+ while (eos() !== true && (code = advance())) {
2176
+ if (code === CHAR_LEFT_PARENTHESES) {
2177
+ backslashes = token.backslashes = true;
2178
+ code = advance();
2179
+ continue;
2180
+ }
2181
+
2182
+ if (code === CHAR_RIGHT_PARENTHESES) {
2183
+ finished = true;
2184
+ break;
2185
+ }
2186
+ }
2187
+ continue;
2188
+ }
2189
+ break;
2190
+ }
2191
+
2192
+ if (isGlob === true) {
2193
+ finished = true;
2194
+
2195
+ if (scanToEnd === true) {
2196
+ continue;
2197
+ }
2198
+
2199
+ break;
2200
+ }
2201
+ }
2202
+
2203
+ if (opts.noext === true) {
2204
+ isExtglob = false;
2205
+ isGlob = false;
2206
+ }
2207
+
2208
+ let base = str;
2209
+ let prefix = '';
2210
+ let glob = '';
2211
+
2212
+ if (start > 0) {
2213
+ prefix = str.slice(0, start);
2214
+ str = str.slice(start);
2215
+ lastIndex -= start;
2216
+ }
2217
+
2218
+ if (base && isGlob === true && lastIndex > 0) {
2219
+ base = str.slice(0, lastIndex);
2220
+ glob = str.slice(lastIndex);
2221
+ } else if (isGlob === true) {
2222
+ base = '';
2223
+ glob = str;
2224
+ } else {
2225
+ base = str;
2226
+ }
2227
+
2228
+ if (base && base !== '' && base !== '/' && base !== str) {
2229
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
2230
+ base = base.slice(0, -1);
2231
+ }
2232
+ }
2233
+
2234
+ if (opts.unescape === true) {
2235
+ if (glob) glob = utils.removeBackslashes(glob);
2236
+
2237
+ if (base && backslashes === true) {
2238
+ base = utils.removeBackslashes(base);
2239
+ }
2240
+ }
2241
+
2242
+ const state = {
2243
+ prefix,
2244
+ input,
2245
+ start,
2246
+ base,
2247
+ glob,
2248
+ isBrace,
2249
+ isBracket,
2250
+ isGlob,
2251
+ isExtglob,
2252
+ isGlobstar,
2253
+ negated,
2254
+ negatedExtglob
2255
+ };
2256
+
2257
+ if (opts.tokens === true) {
2258
+ state.maxDepth = 0;
2259
+ if (!isPathSeparator(code)) {
2260
+ tokens.push(token);
2261
+ }
2262
+ state.tokens = tokens;
2263
+ }
2264
+
2265
+ if (opts.parts === true || opts.tokens === true) {
2266
+ let prevIndex;
2267
+
2268
+ for (let idx = 0; idx < slashes.length; idx++) {
2269
+ const n = prevIndex ? prevIndex + 1 : start;
2270
+ const i = slashes[idx];
2271
+ const value = input.slice(n, i);
2272
+ if (opts.tokens) {
2273
+ if (idx === 0 && start !== 0) {
2274
+ tokens[idx].isPrefix = true;
2275
+ tokens[idx].value = prefix;
2276
+ } else {
2277
+ tokens[idx].value = value;
2278
+ }
2279
+ depth(tokens[idx]);
2280
+ state.maxDepth += tokens[idx].depth;
2281
+ }
2282
+ if (idx !== 0 || value !== '') {
2283
+ parts.push(value);
2284
+ }
2285
+ prevIndex = i;
2286
+ }
2287
+
2288
+ if (prevIndex && prevIndex + 1 < input.length) {
2289
+ const value = input.slice(prevIndex + 1);
2290
+ parts.push(value);
2291
+
2292
+ if (opts.tokens) {
2293
+ tokens[tokens.length - 1].value = value;
2294
+ depth(tokens[tokens.length - 1]);
2295
+ state.maxDepth += tokens[tokens.length - 1].depth;
2296
+ }
2297
+ }
2298
+
2299
+ state.slashes = slashes;
2300
+ state.parts = parts;
2301
+ }
2302
+
2303
+ return state;
2304
+ };
2305
+
2306
+ scan_1 = scan;
2307
+ return scan_1;
2308
+ }
2309
+
2310
+ var parse_1;
2311
+ var hasRequiredParse;
2312
+
2313
+ function requireParse () {
2314
+ if (hasRequiredParse) return parse_1;
2315
+ hasRequiredParse = 1;
2316
+
2317
+ const constants = requireConstants();
2318
+ const utils = requireUtils();
2319
+
2320
+ /**
2321
+ * Constants
2322
+ */
2323
+
2324
+ const {
2325
+ MAX_LENGTH,
2326
+ POSIX_REGEX_SOURCE,
2327
+ REGEX_NON_SPECIAL_CHARS,
2328
+ REGEX_SPECIAL_CHARS_BACKREF,
2329
+ REPLACEMENTS
2330
+ } = constants;
2331
+
2332
+ /**
2333
+ * Helpers
2334
+ */
2335
+
2336
+ const expandRange = (args, options) => {
2337
+ if (typeof options.expandRange === 'function') {
2338
+ return options.expandRange(...args, options);
2339
+ }
2340
+
2341
+ args.sort();
2342
+ const value = `[${args.join('-')}]`;
2343
+
2344
+ try {
2345
+ /* eslint-disable-next-line no-new */
2346
+ new RegExp(value);
2347
+ } catch (ex) {
2348
+ return args.map(v => utils.escapeRegex(v)).join('..');
2349
+ }
2350
+
2351
+ return value;
2352
+ };
2353
+
2354
+ /**
2355
+ * Create the message for a syntax error
2356
+ */
2357
+
2358
+ const syntaxError = (type, char) => {
2359
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
2360
+ };
2361
+
2362
+ /**
2363
+ * Parse the given input string.
2364
+ * @param {String} input
2365
+ * @param {Object} options
2366
+ * @return {Object}
2367
+ */
2368
+
2369
+ const parse = (input, options) => {
2370
+ if (typeof input !== 'string') {
2371
+ throw new TypeError('Expected a string');
2372
+ }
2373
+
2374
+ input = REPLACEMENTS[input] || input;
2375
+
2376
+ const opts = { ...options };
2377
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2378
+
2379
+ let len = input.length;
2380
+ if (len > max) {
2381
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2382
+ }
2383
+
2384
+ const bos = { type: 'bos', value: '', output: opts.prepend || '' };
2385
+ const tokens = [bos];
2386
+
2387
+ const capture = opts.capture ? '' : '?:';
2388
+ const win32 = utils.isWindows(options);
2389
+
2390
+ // create constants based on platform, for windows or posix
2391
+ const PLATFORM_CHARS = constants.globChars(win32);
2392
+ const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
2393
+
2394
+ const {
2395
+ DOT_LITERAL,
2396
+ PLUS_LITERAL,
2397
+ SLASH_LITERAL,
2398
+ ONE_CHAR,
2399
+ DOTS_SLASH,
2400
+ NO_DOT,
2401
+ NO_DOT_SLASH,
2402
+ NO_DOTS_SLASH,
2403
+ QMARK,
2404
+ QMARK_NO_DOT,
2405
+ STAR,
2406
+ START_ANCHOR
2407
+ } = PLATFORM_CHARS;
2408
+
2409
+ const globstar = opts => {
2410
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2411
+ };
2412
+
2413
+ const nodot = opts.dot ? '' : NO_DOT;
2414
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
2415
+ let star = opts.bash === true ? globstar(opts) : STAR;
2416
+
2417
+ if (opts.capture) {
2418
+ star = `(${star})`;
2419
+ }
2420
+
2421
+ // minimatch options support
2422
+ if (typeof opts.noext === 'boolean') {
2423
+ opts.noextglob = opts.noext;
2424
+ }
2425
+
2426
+ const state = {
2427
+ input,
2428
+ index: -1,
2429
+ start: 0,
2430
+ dot: opts.dot === true,
2431
+ consumed: '',
2432
+ output: '',
2433
+ prefix: '',
2434
+ backtrack: false,
2435
+ negated: false,
2436
+ brackets: 0,
2437
+ braces: 0,
2438
+ parens: 0,
2439
+ quotes: 0,
2440
+ globstar: false,
2441
+ tokens
2442
+ };
2443
+
2444
+ input = utils.removePrefix(input, state);
2445
+ len = input.length;
2446
+
2447
+ const extglobs = [];
2448
+ const braces = [];
2449
+ const stack = [];
2450
+ let prev = bos;
2451
+ let value;
2452
+
2453
+ /**
2454
+ * Tokenizing helpers
2455
+ */
2456
+
2457
+ const eos = () => state.index === len - 1;
2458
+ const peek = state.peek = (n = 1) => input[state.index + n];
2459
+ const advance = state.advance = () => input[++state.index] || '';
2460
+ const remaining = () => input.slice(state.index + 1);
2461
+ const consume = (value = '', num = 0) => {
2462
+ state.consumed += value;
2463
+ state.index += num;
2464
+ };
2465
+
2466
+ const append = token => {
2467
+ state.output += token.output != null ? token.output : token.value;
2468
+ consume(token.value);
2469
+ };
2470
+
2471
+ const negate = () => {
2472
+ let count = 1;
2473
+
2474
+ while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
2475
+ advance();
2476
+ state.start++;
2477
+ count++;
2478
+ }
2479
+
2480
+ if (count % 2 === 0) {
2481
+ return false;
2482
+ }
2483
+
2484
+ state.negated = true;
2485
+ state.start++;
2486
+ return true;
2487
+ };
2488
+
2489
+ const increment = type => {
2490
+ state[type]++;
2491
+ stack.push(type);
2492
+ };
2493
+
2494
+ const decrement = type => {
2495
+ state[type]--;
2496
+ stack.pop();
2497
+ };
2498
+
2499
+ /**
2500
+ * Push tokens onto the tokens array. This helper speeds up
2501
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
2502
+ * and 2) helping us avoid creating extra tokens when consecutive
2503
+ * characters are plain text. This improves performance and simplifies
2504
+ * lookbehinds.
2505
+ */
2506
+
2507
+ const push = tok => {
2508
+ if (prev.type === 'globstar') {
2509
+ const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
2510
+ const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
2511
+
2512
+ if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
2513
+ state.output = state.output.slice(0, -prev.output.length);
2514
+ prev.type = 'star';
2515
+ prev.value = '*';
2516
+ prev.output = star;
2517
+ state.output += prev.output;
2518
+ }
2519
+ }
2520
+
2521
+ if (extglobs.length && tok.type !== 'paren') {
2522
+ extglobs[extglobs.length - 1].inner += tok.value;
2523
+ }
2524
+
2525
+ if (tok.value || tok.output) append(tok);
2526
+ if (prev && prev.type === 'text' && tok.type === 'text') {
2527
+ prev.value += tok.value;
2528
+ prev.output = (prev.output || '') + tok.value;
2529
+ return;
2530
+ }
2531
+
2532
+ tok.prev = prev;
2533
+ tokens.push(tok);
2534
+ prev = tok;
2535
+ };
2536
+
2537
+ const extglobOpen = (type, value) => {
2538
+ const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
2539
+
2540
+ token.prev = prev;
2541
+ token.parens = state.parens;
2542
+ token.output = state.output;
2543
+ const output = (opts.capture ? '(' : '') + token.open;
2544
+
2545
+ increment('parens');
2546
+ push({ type, value, output: state.output ? '' : ONE_CHAR });
2547
+ push({ type: 'paren', extglob: true, value: advance(), output });
2548
+ extglobs.push(token);
2549
+ };
2550
+
2551
+ const extglobClose = token => {
2552
+ let output = token.close + (opts.capture ? ')' : '');
2553
+ let rest;
2554
+
2555
+ if (token.type === 'negate') {
2556
+ let extglobStar = star;
2557
+
2558
+ if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
2559
+ extglobStar = globstar(opts);
2560
+ }
2561
+
2562
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
2563
+ output = token.close = `)$))${extglobStar}`;
2564
+ }
2565
+
2566
+ if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
2567
+ // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
2568
+ // In this case, we need to parse the string and use it in the output of the original pattern.
2569
+ // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
2570
+ //
2571
+ // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
2572
+ const expression = parse(rest, { ...options, fastpaths: false }).output;
2573
+
2574
+ output = token.close = `)${expression})${extglobStar})`;
2575
+ }
2576
+
2577
+ if (token.prev.type === 'bos') {
2578
+ state.negatedExtglob = true;
2579
+ }
2580
+ }
2581
+
2582
+ push({ type: 'paren', extglob: true, value, output });
2583
+ decrement('parens');
2584
+ };
2585
+
2586
+ /**
2587
+ * Fast paths
2588
+ */
2589
+
2590
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
2591
+ let backslashes = false;
2592
+
2593
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
2594
+ if (first === '\\') {
2595
+ backslashes = true;
2596
+ return m;
2597
+ }
2598
+
2599
+ if (first === '?') {
2600
+ if (esc) {
2601
+ return esc + first + (rest ? QMARK.repeat(rest.length) : '');
2602
+ }
2603
+ if (index === 0) {
2604
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
2605
+ }
2606
+ return QMARK.repeat(chars.length);
2607
+ }
2608
+
2609
+ if (first === '.') {
2610
+ return DOT_LITERAL.repeat(chars.length);
2611
+ }
2612
+
2613
+ if (first === '*') {
2614
+ if (esc) {
2615
+ return esc + first + (rest ? star : '');
2616
+ }
2617
+ return star;
2618
+ }
2619
+ return esc ? m : `\\${m}`;
2620
+ });
2621
+
2622
+ if (backslashes === true) {
2623
+ if (opts.unescape === true) {
2624
+ output = output.replace(/\\/g, '');
2625
+ } else {
2626
+ output = output.replace(/\\+/g, m => {
2627
+ return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
2628
+ });
2629
+ }
2630
+ }
2631
+
2632
+ if (output === input && opts.contains === true) {
2633
+ state.output = input;
2634
+ return state;
2635
+ }
2636
+
2637
+ state.output = utils.wrapOutput(output, state, options);
2638
+ return state;
2639
+ }
2640
+
2641
+ /**
2642
+ * Tokenize input until we reach end-of-string
2643
+ */
2644
+
2645
+ while (!eos()) {
2646
+ value = advance();
2647
+
2648
+ if (value === '\u0000') {
2649
+ continue;
2650
+ }
2651
+
2652
+ /**
2653
+ * Escaped characters
2654
+ */
2655
+
2656
+ if (value === '\\') {
2657
+ const next = peek();
2658
+
2659
+ if (next === '/' && opts.bash !== true) {
2660
+ continue;
2661
+ }
2662
+
2663
+ if (next === '.' || next === ';') {
2664
+ continue;
2665
+ }
2666
+
2667
+ if (!next) {
2668
+ value += '\\';
2669
+ push({ type: 'text', value });
2670
+ continue;
2671
+ }
2672
+
2673
+ // collapse slashes to reduce potential for exploits
2674
+ const match = /^\\+/.exec(remaining());
2675
+ let slashes = 0;
2676
+
2677
+ if (match && match[0].length > 2) {
2678
+ slashes = match[0].length;
2679
+ state.index += slashes;
2680
+ if (slashes % 2 !== 0) {
2681
+ value += '\\';
2682
+ }
2683
+ }
2684
+
2685
+ if (opts.unescape === true) {
2686
+ value = advance();
2687
+ } else {
2688
+ value += advance();
2689
+ }
2690
+
2691
+ if (state.brackets === 0) {
2692
+ push({ type: 'text', value });
2693
+ continue;
2694
+ }
2695
+ }
2696
+
2697
+ /**
2698
+ * If we're inside a regex character class, continue
2699
+ * until we reach the closing bracket.
2700
+ */
2701
+
2702
+ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
2703
+ if (opts.posix !== false && value === ':') {
2704
+ const inner = prev.value.slice(1);
2705
+ if (inner.includes('[')) {
2706
+ prev.posix = true;
2707
+
2708
+ if (inner.includes(':')) {
2709
+ const idx = prev.value.lastIndexOf('[');
2710
+ const pre = prev.value.slice(0, idx);
2711
+ const rest = prev.value.slice(idx + 2);
2712
+ const posix = POSIX_REGEX_SOURCE[rest];
2713
+ if (posix) {
2714
+ prev.value = pre + posix;
2715
+ state.backtrack = true;
2716
+ advance();
2717
+
2718
+ if (!bos.output && tokens.indexOf(prev) === 1) {
2719
+ bos.output = ONE_CHAR;
2720
+ }
2721
+ continue;
2722
+ }
2723
+ }
2724
+ }
2725
+ }
2726
+
2727
+ if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
2728
+ value = `\\${value}`;
2729
+ }
2730
+
2731
+ if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
2732
+ value = `\\${value}`;
2733
+ }
2734
+
2735
+ if (opts.posix === true && value === '!' && prev.value === '[') {
2736
+ value = '^';
2737
+ }
2738
+
2739
+ prev.value += value;
2740
+ append({ value });
2741
+ continue;
2742
+ }
2743
+
2744
+ /**
2745
+ * If we're inside a quoted string, continue
2746
+ * until we reach the closing double quote.
2747
+ */
2748
+
2749
+ if (state.quotes === 1 && value !== '"') {
2750
+ value = utils.escapeRegex(value);
2751
+ prev.value += value;
2752
+ append({ value });
2753
+ continue;
2754
+ }
2755
+
2756
+ /**
2757
+ * Double quotes
2758
+ */
2759
+
2760
+ if (value === '"') {
2761
+ state.quotes = state.quotes === 1 ? 0 : 1;
2762
+ if (opts.keepQuotes === true) {
2763
+ push({ type: 'text', value });
2764
+ }
2765
+ continue;
2766
+ }
2767
+
2768
+ /**
2769
+ * Parentheses
2770
+ */
2771
+
2772
+ if (value === '(') {
2773
+ increment('parens');
2774
+ push({ type: 'paren', value });
2775
+ continue;
2776
+ }
2777
+
2778
+ if (value === ')') {
2779
+ if (state.parens === 0 && opts.strictBrackets === true) {
2780
+ throw new SyntaxError(syntaxError('opening', '('));
2781
+ }
2782
+
2783
+ const extglob = extglobs[extglobs.length - 1];
2784
+ if (extglob && state.parens === extglob.parens + 1) {
2785
+ extglobClose(extglobs.pop());
2786
+ continue;
2787
+ }
2788
+
2789
+ push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
2790
+ decrement('parens');
2791
+ continue;
2792
+ }
2793
+
2794
+ /**
2795
+ * Square brackets
2796
+ */
2797
+
2798
+ if (value === '[') {
2799
+ if (opts.nobracket === true || !remaining().includes(']')) {
2800
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
2801
+ throw new SyntaxError(syntaxError('closing', ']'));
2802
+ }
2803
+
2804
+ value = `\\${value}`;
2805
+ } else {
2806
+ increment('brackets');
2807
+ }
2808
+
2809
+ push({ type: 'bracket', value });
2810
+ continue;
2811
+ }
2812
+
2813
+ if (value === ']') {
2814
+ if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
2815
+ push({ type: 'text', value, output: `\\${value}` });
2816
+ continue;
2817
+ }
2818
+
2819
+ if (state.brackets === 0) {
2820
+ if (opts.strictBrackets === true) {
2821
+ throw new SyntaxError(syntaxError('opening', '['));
2822
+ }
2823
+
2824
+ push({ type: 'text', value, output: `\\${value}` });
2825
+ continue;
2826
+ }
2827
+
2828
+ decrement('brackets');
2829
+
2830
+ const prevValue = prev.value.slice(1);
2831
+ if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
2832
+ value = `/${value}`;
2833
+ }
2834
+
2835
+ prev.value += value;
2836
+ append({ value });
2837
+
2838
+ // when literal brackets are explicitly disabled
2839
+ // assume we should match with a regex character class
2840
+ if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
2841
+ continue;
2842
+ }
2843
+
2844
+ const escaped = utils.escapeRegex(prev.value);
2845
+ state.output = state.output.slice(0, -prev.value.length);
2846
+
2847
+ // when literal brackets are explicitly enabled
2848
+ // assume we should escape the brackets to match literal characters
2849
+ if (opts.literalBrackets === true) {
2850
+ state.output += escaped;
2851
+ prev.value = escaped;
2852
+ continue;
2853
+ }
2854
+
2855
+ // when the user specifies nothing, try to match both
2856
+ prev.value = `(${capture}${escaped}|${prev.value})`;
2857
+ state.output += prev.value;
2858
+ continue;
2859
+ }
2860
+
2861
+ /**
2862
+ * Braces
2863
+ */
2864
+
2865
+ if (value === '{' && opts.nobrace !== true) {
2866
+ increment('braces');
2867
+
2868
+ const open = {
2869
+ type: 'brace',
2870
+ value,
2871
+ output: '(',
2872
+ outputIndex: state.output.length,
2873
+ tokensIndex: state.tokens.length
2874
+ };
2875
+
2876
+ braces.push(open);
2877
+ push(open);
2878
+ continue;
2879
+ }
2880
+
2881
+ if (value === '}') {
2882
+ const brace = braces[braces.length - 1];
2883
+
2884
+ if (opts.nobrace === true || !brace) {
2885
+ push({ type: 'text', value, output: value });
2886
+ continue;
2887
+ }
2888
+
2889
+ let output = ')';
2890
+
2891
+ if (brace.dots === true) {
2892
+ const arr = tokens.slice();
2893
+ const range = [];
2894
+
2895
+ for (let i = arr.length - 1; i >= 0; i--) {
2896
+ tokens.pop();
2897
+ if (arr[i].type === 'brace') {
2898
+ break;
2899
+ }
2900
+ if (arr[i].type !== 'dots') {
2901
+ range.unshift(arr[i].value);
2902
+ }
2903
+ }
2904
+
2905
+ output = expandRange(range, opts);
2906
+ state.backtrack = true;
2907
+ }
2908
+
2909
+ if (brace.comma !== true && brace.dots !== true) {
2910
+ const out = state.output.slice(0, brace.outputIndex);
2911
+ const toks = state.tokens.slice(brace.tokensIndex);
2912
+ brace.value = brace.output = '\\{';
2913
+ value = output = '\\}';
2914
+ state.output = out;
2915
+ for (const t of toks) {
2916
+ state.output += (t.output || t.value);
2917
+ }
2918
+ }
2919
+
2920
+ push({ type: 'brace', value, output });
2921
+ decrement('braces');
2922
+ braces.pop();
2923
+ continue;
2924
+ }
2925
+
2926
+ /**
2927
+ * Pipes
2928
+ */
2929
+
2930
+ if (value === '|') {
2931
+ if (extglobs.length > 0) {
2932
+ extglobs[extglobs.length - 1].conditions++;
2933
+ }
2934
+ push({ type: 'text', value });
2935
+ continue;
2936
+ }
2937
+
2938
+ /**
2939
+ * Commas
2940
+ */
2941
+
2942
+ if (value === ',') {
2943
+ let output = value;
2944
+
2945
+ const brace = braces[braces.length - 1];
2946
+ if (brace && stack[stack.length - 1] === 'braces') {
2947
+ brace.comma = true;
2948
+ output = '|';
2949
+ }
2950
+
2951
+ push({ type: 'comma', value, output });
2952
+ continue;
2953
+ }
2954
+
2955
+ /**
2956
+ * Slashes
2957
+ */
2958
+
2959
+ if (value === '/') {
2960
+ // if the beginning of the glob is "./", advance the start
2961
+ // to the current index, and don't add the "./" characters
2962
+ // to the state. This greatly simplifies lookbehinds when
2963
+ // checking for BOS characters like "!" and "." (not "./")
2964
+ if (prev.type === 'dot' && state.index === state.start + 1) {
2965
+ state.start = state.index + 1;
2966
+ state.consumed = '';
2967
+ state.output = '';
2968
+ tokens.pop();
2969
+ prev = bos; // reset "prev" to the first token
2970
+ continue;
2971
+ }
2972
+
2973
+ push({ type: 'slash', value, output: SLASH_LITERAL });
2974
+ continue;
2975
+ }
2976
+
2977
+ /**
2978
+ * Dots
2979
+ */
2980
+
2981
+ if (value === '.') {
2982
+ if (state.braces > 0 && prev.type === 'dot') {
2983
+ if (prev.value === '.') prev.output = DOT_LITERAL;
2984
+ const brace = braces[braces.length - 1];
2985
+ prev.type = 'dots';
2986
+ prev.output += value;
2987
+ prev.value += value;
2988
+ brace.dots = true;
2989
+ continue;
2990
+ }
2991
+
2992
+ if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
2993
+ push({ type: 'text', value, output: DOT_LITERAL });
2994
+ continue;
2995
+ }
2996
+
2997
+ push({ type: 'dot', value, output: DOT_LITERAL });
2998
+ continue;
2999
+ }
3000
+
3001
+ /**
3002
+ * Question marks
3003
+ */
3004
+
3005
+ if (value === '?') {
3006
+ const isGroup = prev && prev.value === '(';
3007
+ if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
3008
+ extglobOpen('qmark', value);
3009
+ continue;
3010
+ }
3011
+
3012
+ if (prev && prev.type === 'paren') {
3013
+ const next = peek();
3014
+ let output = value;
3015
+
3016
+ if (next === '<' && !utils.supportsLookbehinds()) {
3017
+ throw new Error('Node.js v10 or higher is required for regex lookbehinds');
3018
+ }
3019
+
3020
+ if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
3021
+ output = `\\${value}`;
3022
+ }
3023
+
3024
+ push({ type: 'text', value, output });
3025
+ continue;
3026
+ }
3027
+
3028
+ if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
3029
+ push({ type: 'qmark', value, output: QMARK_NO_DOT });
3030
+ continue;
3031
+ }
3032
+
3033
+ push({ type: 'qmark', value, output: QMARK });
3034
+ continue;
3035
+ }
3036
+
3037
+ /**
3038
+ * Exclamation
3039
+ */
3040
+
3041
+ if (value === '!') {
3042
+ if (opts.noextglob !== true && peek() === '(') {
3043
+ if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
3044
+ extglobOpen('negate', value);
3045
+ continue;
3046
+ }
3047
+ }
3048
+
3049
+ if (opts.nonegate !== true && state.index === 0) {
3050
+ negate();
3051
+ continue;
3052
+ }
3053
+ }
3054
+
3055
+ /**
3056
+ * Plus
3057
+ */
3058
+
3059
+ if (value === '+') {
3060
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
3061
+ extglobOpen('plus', value);
3062
+ continue;
3063
+ }
3064
+
3065
+ if ((prev && prev.value === '(') || opts.regex === false) {
3066
+ push({ type: 'plus', value, output: PLUS_LITERAL });
3067
+ continue;
3068
+ }
3069
+
3070
+ if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
3071
+ push({ type: 'plus', value });
3072
+ continue;
3073
+ }
3074
+
3075
+ push({ type: 'plus', value: PLUS_LITERAL });
3076
+ continue;
3077
+ }
3078
+
3079
+ /**
3080
+ * Plain text
3081
+ */
3082
+
3083
+ if (value === '@') {
3084
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
3085
+ push({ type: 'at', extglob: true, value, output: '' });
3086
+ continue;
3087
+ }
3088
+
3089
+ push({ type: 'text', value });
3090
+ continue;
3091
+ }
3092
+
3093
+ /**
3094
+ * Plain text
3095
+ */
3096
+
3097
+ if (value !== '*') {
3098
+ if (value === '$' || value === '^') {
3099
+ value = `\\${value}`;
3100
+ }
3101
+
3102
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
3103
+ if (match) {
3104
+ value += match[0];
3105
+ state.index += match[0].length;
3106
+ }
3107
+
3108
+ push({ type: 'text', value });
3109
+ continue;
3110
+ }
3111
+
3112
+ /**
3113
+ * Stars
3114
+ */
3115
+
3116
+ if (prev && (prev.type === 'globstar' || prev.star === true)) {
3117
+ prev.type = 'star';
3118
+ prev.star = true;
3119
+ prev.value += value;
3120
+ prev.output = star;
3121
+ state.backtrack = true;
3122
+ state.globstar = true;
3123
+ consume(value);
3124
+ continue;
3125
+ }
3126
+
3127
+ let rest = remaining();
3128
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
3129
+ extglobOpen('star', value);
3130
+ continue;
3131
+ }
3132
+
3133
+ if (prev.type === 'star') {
3134
+ if (opts.noglobstar === true) {
3135
+ consume(value);
3136
+ continue;
3137
+ }
3138
+
3139
+ const prior = prev.prev;
3140
+ const before = prior.prev;
3141
+ const isStart = prior.type === 'slash' || prior.type === 'bos';
3142
+ const afterStar = before && (before.type === 'star' || before.type === 'globstar');
3143
+
3144
+ if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
3145
+ push({ type: 'star', value, output: '' });
3146
+ continue;
3147
+ }
3148
+
3149
+ const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
3150
+ const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
3151
+ if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
3152
+ push({ type: 'star', value, output: '' });
3153
+ continue;
3154
+ }
3155
+
3156
+ // strip consecutive `/**/`
3157
+ while (rest.slice(0, 3) === '/**') {
3158
+ const after = input[state.index + 4];
3159
+ if (after && after !== '/') {
3160
+ break;
3161
+ }
3162
+ rest = rest.slice(3);
3163
+ consume('/**', 3);
3164
+ }
3165
+
3166
+ if (prior.type === 'bos' && eos()) {
3167
+ prev.type = 'globstar';
3168
+ prev.value += value;
3169
+ prev.output = globstar(opts);
3170
+ state.output = prev.output;
3171
+ state.globstar = true;
3172
+ consume(value);
3173
+ continue;
3174
+ }
3175
+
3176
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
3177
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
3178
+ prior.output = `(?:${prior.output}`;
3179
+
3180
+ prev.type = 'globstar';
3181
+ prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
3182
+ prev.value += value;
3183
+ state.globstar = true;
3184
+ state.output += prior.output + prev.output;
3185
+ consume(value);
3186
+ continue;
3187
+ }
3188
+
3189
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
3190
+ const end = rest[1] !== void 0 ? '|$' : '';
3191
+
3192
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
3193
+ prior.output = `(?:${prior.output}`;
3194
+
3195
+ prev.type = 'globstar';
3196
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
3197
+ prev.value += value;
3198
+
3199
+ state.output += prior.output + prev.output;
3200
+ state.globstar = true;
3201
+
3202
+ consume(value + advance());
3203
+
3204
+ push({ type: 'slash', value: '/', output: '' });
3205
+ continue;
3206
+ }
3207
+
3208
+ if (prior.type === 'bos' && rest[0] === '/') {
3209
+ prev.type = 'globstar';
3210
+ prev.value += value;
3211
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
3212
+ state.output = prev.output;
3213
+ state.globstar = true;
3214
+ consume(value + advance());
3215
+ push({ type: 'slash', value: '/', output: '' });
3216
+ continue;
3217
+ }
3218
+
3219
+ // remove single star from output
3220
+ state.output = state.output.slice(0, -prev.output.length);
3221
+
3222
+ // reset previous token to globstar
3223
+ prev.type = 'globstar';
3224
+ prev.output = globstar(opts);
3225
+ prev.value += value;
3226
+
3227
+ // reset output with globstar
3228
+ state.output += prev.output;
3229
+ state.globstar = true;
3230
+ consume(value);
3231
+ continue;
3232
+ }
3233
+
3234
+ const token = { type: 'star', value, output: star };
3235
+
3236
+ if (opts.bash === true) {
3237
+ token.output = '.*?';
3238
+ if (prev.type === 'bos' || prev.type === 'slash') {
3239
+ token.output = nodot + token.output;
3240
+ }
3241
+ push(token);
3242
+ continue;
3243
+ }
3244
+
3245
+ if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
3246
+ token.output = value;
3247
+ push(token);
3248
+ continue;
3249
+ }
3250
+
3251
+ if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
3252
+ if (prev.type === 'dot') {
3253
+ state.output += NO_DOT_SLASH;
3254
+ prev.output += NO_DOT_SLASH;
3255
+
3256
+ } else if (opts.dot === true) {
3257
+ state.output += NO_DOTS_SLASH;
3258
+ prev.output += NO_DOTS_SLASH;
3259
+
3260
+ } else {
3261
+ state.output += nodot;
3262
+ prev.output += nodot;
3263
+ }
3264
+
3265
+ if (peek() !== '*') {
3266
+ state.output += ONE_CHAR;
3267
+ prev.output += ONE_CHAR;
3268
+ }
3269
+ }
3270
+
3271
+ push(token);
3272
+ }
3273
+
3274
+ while (state.brackets > 0) {
3275
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
3276
+ state.output = utils.escapeLast(state.output, '[');
3277
+ decrement('brackets');
3278
+ }
3279
+
3280
+ while (state.parens > 0) {
3281
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
3282
+ state.output = utils.escapeLast(state.output, '(');
3283
+ decrement('parens');
3284
+ }
3285
+
3286
+ while (state.braces > 0) {
3287
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
3288
+ state.output = utils.escapeLast(state.output, '{');
3289
+ decrement('braces');
3290
+ }
3291
+
3292
+ if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
3293
+ push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
3294
+ }
3295
+
3296
+ // rebuild the output if we had to backtrack at any point
3297
+ if (state.backtrack === true) {
3298
+ state.output = '';
3299
+
3300
+ for (const token of state.tokens) {
3301
+ state.output += token.output != null ? token.output : token.value;
3302
+
3303
+ if (token.suffix) {
3304
+ state.output += token.suffix;
3305
+ }
3306
+ }
3307
+ }
3308
+
3309
+ return state;
3310
+ };
3311
+
3312
+ /**
3313
+ * Fast paths for creating regular expressions for common glob patterns.
3314
+ * This can significantly speed up processing and has very little downside
3315
+ * impact when none of the fast paths match.
3316
+ */
3317
+
3318
+ parse.fastpaths = (input, options) => {
3319
+ const opts = { ...options };
3320
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
3321
+ const len = input.length;
3322
+ if (len > max) {
3323
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
3324
+ }
3325
+
3326
+ input = REPLACEMENTS[input] || input;
3327
+ const win32 = utils.isWindows(options);
3328
+
3329
+ // create constants based on platform, for windows or posix
3330
+ const {
3331
+ DOT_LITERAL,
3332
+ SLASH_LITERAL,
3333
+ ONE_CHAR,
3334
+ DOTS_SLASH,
3335
+ NO_DOT,
3336
+ NO_DOTS,
3337
+ NO_DOTS_SLASH,
3338
+ STAR,
3339
+ START_ANCHOR
3340
+ } = constants.globChars(win32);
3341
+
3342
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
3343
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
3344
+ const capture = opts.capture ? '' : '?:';
3345
+ const state = { negated: false, prefix: '' };
3346
+ let star = opts.bash === true ? '.*?' : STAR;
3347
+
3348
+ if (opts.capture) {
3349
+ star = `(${star})`;
3350
+ }
3351
+
3352
+ const globstar = opts => {
3353
+ if (opts.noglobstar === true) return star;
3354
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
3355
+ };
3356
+
3357
+ const create = str => {
3358
+ switch (str) {
3359
+ case '*':
3360
+ return `${nodot}${ONE_CHAR}${star}`;
3361
+
3362
+ case '.*':
3363
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
3364
+
3365
+ case '*.*':
3366
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
3367
+
3368
+ case '*/*':
3369
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
3370
+
3371
+ case '**':
3372
+ return nodot + globstar(opts);
3373
+
3374
+ case '**/*':
3375
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
3376
+
3377
+ case '**/*.*':
3378
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
3379
+
3380
+ case '**/.*':
3381
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
3382
+
3383
+ default: {
3384
+ const match = /^(.*?)\.(\w+)$/.exec(str);
3385
+ if (!match) return;
3386
+
3387
+ const source = create(match[1]);
3388
+ if (!source) return;
3389
+
3390
+ return source + DOT_LITERAL + match[2];
3391
+ }
3392
+ }
3393
+ };
3394
+
3395
+ const output = utils.removePrefix(input, state);
3396
+ let source = create(output);
3397
+
3398
+ if (source && opts.strictSlashes !== true) {
3399
+ source += `${SLASH_LITERAL}?`;
3400
+ }
3401
+
3402
+ return source;
3403
+ };
3404
+
3405
+ parse_1 = parse;
3406
+ return parse_1;
3407
+ }
3408
+
3409
+ var picomatch_1;
3410
+ var hasRequiredPicomatch$1;
3411
+
3412
+ function requirePicomatch$1 () {
3413
+ if (hasRequiredPicomatch$1) return picomatch_1;
3414
+ hasRequiredPicomatch$1 = 1;
3415
+
3416
+ const path = require$$0__default$1.default;
3417
+ const scan = requireScan();
3418
+ const parse = requireParse();
3419
+ const utils = requireUtils();
3420
+ const constants = requireConstants();
3421
+ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
3422
+
3423
+ /**
3424
+ * Creates a matcher function from one or more glob patterns. The
3425
+ * returned function takes a string to match as its first argument,
3426
+ * and returns true if the string is a match. The returned matcher
3427
+ * function also takes a boolean as the second argument that, when true,
3428
+ * returns an object with additional information.
3429
+ *
3430
+ * ```js
3431
+ * const picomatch = require('picomatch');
3432
+ * // picomatch(glob[, options]);
3433
+ *
3434
+ * const isMatch = picomatch('*.!(*a)');
3435
+ * console.log(isMatch('a.a')); //=> false
3436
+ * console.log(isMatch('a.b')); //=> true
3437
+ * ```
3438
+ * @name picomatch
3439
+ * @param {String|Array} `globs` One or more glob patterns.
3440
+ * @param {Object=} `options`
3441
+ * @return {Function=} Returns a matcher function.
3442
+ * @api public
3443
+ */
3444
+
3445
+ const picomatch = (glob, options, returnState = false) => {
3446
+ if (Array.isArray(glob)) {
3447
+ const fns = glob.map(input => picomatch(input, options, returnState));
3448
+ const arrayMatcher = str => {
3449
+ for (const isMatch of fns) {
3450
+ const state = isMatch(str);
3451
+ if (state) return state;
3452
+ }
3453
+ return false;
3454
+ };
3455
+ return arrayMatcher;
3456
+ }
3457
+
3458
+ const isState = isObject(glob) && glob.tokens && glob.input;
3459
+
3460
+ if (glob === '' || (typeof glob !== 'string' && !isState)) {
3461
+ throw new TypeError('Expected pattern to be a non-empty string');
3462
+ }
3463
+
3464
+ const opts = options || {};
3465
+ const posix = utils.isWindows(options);
3466
+ const regex = isState
3467
+ ? picomatch.compileRe(glob, options)
3468
+ : picomatch.makeRe(glob, options, false, true);
3469
+
3470
+ const state = regex.state;
3471
+ delete regex.state;
3472
+
3473
+ let isIgnored = () => false;
3474
+ if (opts.ignore) {
3475
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
3476
+ isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
3477
+ }
3478
+
3479
+ const matcher = (input, returnObject = false) => {
3480
+ const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
3481
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
3482
+
3483
+ if (typeof opts.onResult === 'function') {
3484
+ opts.onResult(result);
3485
+ }
3486
+
3487
+ if (isMatch === false) {
3488
+ result.isMatch = false;
3489
+ return returnObject ? result : false;
3490
+ }
3491
+
3492
+ if (isIgnored(input)) {
3493
+ if (typeof opts.onIgnore === 'function') {
3494
+ opts.onIgnore(result);
3495
+ }
3496
+ result.isMatch = false;
3497
+ return returnObject ? result : false;
3498
+ }
3499
+
3500
+ if (typeof opts.onMatch === 'function') {
3501
+ opts.onMatch(result);
3502
+ }
3503
+ return returnObject ? result : true;
3504
+ };
3505
+
3506
+ if (returnState) {
3507
+ matcher.state = state;
3508
+ }
3509
+
3510
+ return matcher;
3511
+ };
3512
+
3513
+ /**
3514
+ * Test `input` with the given `regex`. This is used by the main
3515
+ * `picomatch()` function to test the input string.
3516
+ *
3517
+ * ```js
3518
+ * const picomatch = require('picomatch');
3519
+ * // picomatch.test(input, regex[, options]);
3520
+ *
3521
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
3522
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
3523
+ * ```
3524
+ * @param {String} `input` String to test.
3525
+ * @param {RegExp} `regex`
3526
+ * @return {Object} Returns an object with matching info.
3527
+ * @api public
3528
+ */
3529
+
3530
+ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
3531
+ if (typeof input !== 'string') {
3532
+ throw new TypeError('Expected input to be a string');
3533
+ }
3534
+
3535
+ if (input === '') {
3536
+ return { isMatch: false, output: '' };
3537
+ }
3538
+
3539
+ const opts = options || {};
3540
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
3541
+ let match = input === glob;
3542
+ let output = (match && format) ? format(input) : input;
3543
+
3544
+ if (match === false) {
3545
+ output = format ? format(input) : input;
3546
+ match = output === glob;
3547
+ }
3548
+
3549
+ if (match === false || opts.capture === true) {
3550
+ if (opts.matchBase === true || opts.basename === true) {
3551
+ match = picomatch.matchBase(input, regex, options, posix);
3552
+ } else {
3553
+ match = regex.exec(output);
3554
+ }
3555
+ }
3556
+
3557
+ return { isMatch: Boolean(match), match, output };
3558
+ };
3559
+
3560
+ /**
3561
+ * Match the basename of a filepath.
3562
+ *
3563
+ * ```js
3564
+ * const picomatch = require('picomatch');
3565
+ * // picomatch.matchBase(input, glob[, options]);
3566
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
3567
+ * ```
3568
+ * @param {String} `input` String to test.
3569
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
3570
+ * @return {Boolean}
3571
+ * @api public
3572
+ */
3573
+
3574
+ picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3575
+ const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
3576
+ return regex.test(path.basename(input));
3577
+ };
3578
+
3579
+ /**
3580
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
3581
+ *
3582
+ * ```js
3583
+ * const picomatch = require('picomatch');
3584
+ * // picomatch.isMatch(string, patterns[, options]);
3585
+ *
3586
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
3587
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
3588
+ * ```
3589
+ * @param {String|Array} str The string to test.
3590
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
3591
+ * @param {Object} [options] See available [options](#options).
3592
+ * @return {Boolean} Returns true if any patterns match `str`
3593
+ * @api public
3594
+ */
3595
+
3596
+ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
3597
+
3598
+ /**
3599
+ * Parse a glob pattern to create the source string for a regular
3600
+ * expression.
3601
+ *
3602
+ * ```js
3603
+ * const picomatch = require('picomatch');
3604
+ * const result = picomatch.parse(pattern[, options]);
3605
+ * ```
3606
+ * @param {String} `pattern`
3607
+ * @param {Object} `options`
3608
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
3609
+ * @api public
3610
+ */
3611
+
3612
+ picomatch.parse = (pattern, options) => {
3613
+ if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
3614
+ return parse(pattern, { ...options, fastpaths: false });
3615
+ };
3616
+
3617
+ /**
3618
+ * Scan a glob pattern to separate the pattern into segments.
3619
+ *
3620
+ * ```js
3621
+ * const picomatch = require('picomatch');
3622
+ * // picomatch.scan(input[, options]);
3623
+ *
3624
+ * const result = picomatch.scan('!./foo/*.js');
3625
+ * console.log(result);
3626
+ * { prefix: '!./',
3627
+ * input: '!./foo/*.js',
3628
+ * start: 3,
3629
+ * base: 'foo',
3630
+ * glob: '*.js',
3631
+ * isBrace: false,
3632
+ * isBracket: false,
3633
+ * isGlob: true,
3634
+ * isExtglob: false,
3635
+ * isGlobstar: false,
3636
+ * negated: true }
3637
+ * ```
3638
+ * @param {String} `input` Glob pattern to scan.
3639
+ * @param {Object} `options`
3640
+ * @return {Object} Returns an object with
3641
+ * @api public
3642
+ */
3643
+
3644
+ picomatch.scan = (input, options) => scan(input, options);
3645
+
3646
+ /**
3647
+ * Compile a regular expression from the `state` object returned by the
3648
+ * [parse()](#parse) method.
3649
+ *
3650
+ * @param {Object} `state`
3651
+ * @param {Object} `options`
3652
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
3653
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
3654
+ * @return {RegExp}
3655
+ * @api public
3656
+ */
3657
+
3658
+ picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
3659
+ if (returnOutput === true) {
3660
+ return state.output;
3661
+ }
3662
+
3663
+ const opts = options || {};
3664
+ const prepend = opts.contains ? '' : '^';
3665
+ const append = opts.contains ? '' : '$';
3666
+
3667
+ let source = `${prepend}(?:${state.output})${append}`;
3668
+ if (state && state.negated === true) {
3669
+ source = `^(?!${source}).*$`;
3670
+ }
3671
+
3672
+ const regex = picomatch.toRegex(source, options);
3673
+ if (returnState === true) {
3674
+ regex.state = state;
3675
+ }
3676
+
3677
+ return regex;
3678
+ };
3679
+
3680
+ /**
3681
+ * Create a regular expression from a parsed glob pattern.
3682
+ *
3683
+ * ```js
3684
+ * const picomatch = require('picomatch');
3685
+ * const state = picomatch.parse('*.js');
3686
+ * // picomatch.compileRe(state[, options]);
3687
+ *
3688
+ * console.log(picomatch.compileRe(state));
3689
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3690
+ * ```
3691
+ * @param {String} `state` The object returned from the `.parse` method.
3692
+ * @param {Object} `options`
3693
+ * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
3694
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
3695
+ * @return {RegExp} Returns a regex created from the given pattern.
3696
+ * @api public
3697
+ */
3698
+
3699
+ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3700
+ if (!input || typeof input !== 'string') {
3701
+ throw new TypeError('Expected a non-empty string');
3702
+ }
3703
+
3704
+ let parsed = { negated: false, fastpaths: true };
3705
+
3706
+ if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
3707
+ parsed.output = parse.fastpaths(input, options);
3708
+ }
3709
+
3710
+ if (!parsed.output) {
3711
+ parsed = parse(input, options);
3712
+ }
3713
+
3714
+ return picomatch.compileRe(parsed, options, returnOutput, returnState);
3715
+ };
3716
+
3717
+ /**
3718
+ * Create a regular expression from the given regex source string.
3719
+ *
3720
+ * ```js
3721
+ * const picomatch = require('picomatch');
3722
+ * // picomatch.toRegex(source[, options]);
3723
+ *
3724
+ * const { output } = picomatch.parse('*.js');
3725
+ * console.log(picomatch.toRegex(output));
3726
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3727
+ * ```
3728
+ * @param {String} `source` Regular expression source string.
3729
+ * @param {Object} `options`
3730
+ * @return {RegExp}
3731
+ * @api public
3732
+ */
3733
+
3734
+ picomatch.toRegex = (source, options) => {
3735
+ try {
3736
+ const opts = options || {};
3737
+ return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
3738
+ } catch (err) {
3739
+ if (options && options.debug === true) throw err;
3740
+ return /$^/;
3741
+ }
3742
+ };
3743
+
3744
+ /**
3745
+ * Picomatch constants.
3746
+ * @return {Object}
3747
+ */
3748
+
3749
+ picomatch.constants = constants;
3750
+
3751
+ /**
3752
+ * Expose "picomatch"
3753
+ */
3754
+
3755
+ picomatch_1 = picomatch;
3756
+ return picomatch_1;
3757
+ }
3758
+
3759
+ var picomatch;
3760
+ var hasRequiredPicomatch;
3761
+
3762
+ function requirePicomatch () {
3763
+ if (hasRequiredPicomatch) return picomatch;
3764
+ hasRequiredPicomatch = 1;
3765
+
3766
+ picomatch = requirePicomatch$1();
3767
+ return picomatch;
3768
+ }
3769
+
3770
+ var micromatch_1;
3771
+ var hasRequiredMicromatch;
3772
+
3773
+ function requireMicromatch () {
3774
+ if (hasRequiredMicromatch) return micromatch_1;
3775
+ hasRequiredMicromatch = 1;
3776
+
3777
+ const util = require$$0__default.default;
3778
+ const braces = requireBraces();
3779
+ const picomatch = requirePicomatch();
3780
+ const utils = requireUtils();
3781
+ const isEmptyString = val => val === '' || val === './';
3782
+
3783
+ /**
3784
+ * Returns an array of strings that match one or more glob patterns.
3785
+ *
3786
+ * ```js
3787
+ * const mm = require('micromatch');
3788
+ * // mm(list, patterns[, options]);
3789
+ *
3790
+ * console.log(mm(['a.js', 'a.txt'], ['*.js']));
3791
+ * //=> [ 'a.js' ]
3792
+ * ```
3793
+ * @param {String|Array<string>} `list` List of strings to match.
3794
+ * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
3795
+ * @param {Object} `options` See available [options](#options)
3796
+ * @return {Array} Returns an array of matches
3797
+ * @summary false
3798
+ * @api public
3799
+ */
3800
+
3801
+ const micromatch = (list, patterns, options) => {
3802
+ patterns = [].concat(patterns);
3803
+ list = [].concat(list);
3804
+
3805
+ let omit = new Set();
3806
+ let keep = new Set();
3807
+ let items = new Set();
3808
+ let negatives = 0;
3809
+
3810
+ let onResult = state => {
3811
+ items.add(state.output);
3812
+ if (options && options.onResult) {
3813
+ options.onResult(state);
3814
+ }
3815
+ };
3816
+
3817
+ for (let i = 0; i < patterns.length; i++) {
3818
+ let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
3819
+ let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
3820
+ if (negated) negatives++;
3821
+
3822
+ for (let item of list) {
3823
+ let matched = isMatch(item, true);
3824
+
3825
+ let match = negated ? !matched.isMatch : matched.isMatch;
3826
+ if (!match) continue;
3827
+
3828
+ if (negated) {
3829
+ omit.add(matched.output);
3830
+ } else {
3831
+ omit.delete(matched.output);
3832
+ keep.add(matched.output);
3833
+ }
3834
+ }
3835
+ }
3836
+
3837
+ let result = negatives === patterns.length ? [...items] : [...keep];
3838
+ let matches = result.filter(item => !omit.has(item));
3839
+
3840
+ if (options && matches.length === 0) {
3841
+ if (options.failglob === true) {
3842
+ throw new Error(`No matches found for "${patterns.join(', ')}"`);
3843
+ }
3844
+
3845
+ if (options.nonull === true || options.nullglob === true) {
3846
+ return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
3847
+ }
3848
+ }
3849
+
3850
+ return matches;
3851
+ };
3852
+
3853
+ /**
3854
+ * Backwards compatibility
3855
+ */
3856
+
3857
+ micromatch.match = micromatch;
3858
+
3859
+ /**
3860
+ * Returns a matcher function from the given glob `pattern` and `options`.
3861
+ * The returned function takes a string to match as its only argument and returns
3862
+ * true if the string is a match.
3863
+ *
3864
+ * ```js
3865
+ * const mm = require('micromatch');
3866
+ * // mm.matcher(pattern[, options]);
3867
+ *
3868
+ * const isMatch = mm.matcher('*.!(*a)');
3869
+ * console.log(isMatch('a.a')); //=> false
3870
+ * console.log(isMatch('a.b')); //=> true
3871
+ * ```
3872
+ * @param {String} `pattern` Glob pattern
3873
+ * @param {Object} `options`
3874
+ * @return {Function} Returns a matcher function.
3875
+ * @api public
3876
+ */
3877
+
3878
+ micromatch.matcher = (pattern, options) => picomatch(pattern, options);
3879
+
3880
+ /**
3881
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
3882
+ *
3883
+ * ```js
3884
+ * const mm = require('micromatch');
3885
+ * // mm.isMatch(string, patterns[, options]);
3886
+ *
3887
+ * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
3888
+ * console.log(mm.isMatch('a.a', 'b.*')); //=> false
3889
+ * ```
3890
+ * @param {String} `str` The string to test.
3891
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3892
+ * @param {Object} `[options]` See available [options](#options).
3893
+ * @return {Boolean} Returns true if any patterns match `str`
3894
+ * @api public
3895
+ */
3896
+
3897
+ micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
3898
+
3899
+ /**
3900
+ * Backwards compatibility
3901
+ */
3902
+
3903
+ micromatch.any = micromatch.isMatch;
3904
+
3905
+ /**
3906
+ * Returns a list of strings that _**do not match any**_ of the given `patterns`.
3907
+ *
3908
+ * ```js
3909
+ * const mm = require('micromatch');
3910
+ * // mm.not(list, patterns[, options]);
3911
+ *
3912
+ * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
3913
+ * //=> ['b.b', 'c.c']
3914
+ * ```
3915
+ * @param {Array} `list` Array of strings to match.
3916
+ * @param {String|Array} `patterns` One or more glob pattern to use for matching.
3917
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
3918
+ * @return {Array} Returns an array of strings that **do not match** the given patterns.
3919
+ * @api public
3920
+ */
3921
+
3922
+ micromatch.not = (list, patterns, options = {}) => {
3923
+ patterns = [].concat(patterns).map(String);
3924
+ let result = new Set();
3925
+ let items = [];
3926
+
3927
+ let onResult = state => {
3928
+ if (options.onResult) options.onResult(state);
3929
+ items.push(state.output);
3930
+ };
3931
+
3932
+ let matches = new Set(micromatch(list, patterns, { ...options, onResult }));
3933
+
3934
+ for (let item of items) {
3935
+ if (!matches.has(item)) {
3936
+ result.add(item);
3937
+ }
3938
+ }
3939
+ return [...result];
3940
+ };
3941
+
3942
+ /**
3943
+ * Returns true if the given `string` contains the given pattern. Similar
3944
+ * to [.isMatch](#isMatch) but the pattern can match any part of the string.
3945
+ *
3946
+ * ```js
3947
+ * var mm = require('micromatch');
3948
+ * // mm.contains(string, pattern[, options]);
3949
+ *
3950
+ * console.log(mm.contains('aa/bb/cc', '*b'));
3951
+ * //=> true
3952
+ * console.log(mm.contains('aa/bb/cc', '*d'));
3953
+ * //=> false
3954
+ * ```
3955
+ * @param {String} `str` The string to match.
3956
+ * @param {String|Array} `patterns` Glob pattern to use for matching.
3957
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
3958
+ * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
3959
+ * @api public
3960
+ */
3961
+
3962
+ micromatch.contains = (str, pattern, options) => {
3963
+ if (typeof str !== 'string') {
3964
+ throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
3965
+ }
3966
+
3967
+ if (Array.isArray(pattern)) {
3968
+ return pattern.some(p => micromatch.contains(str, p, options));
3969
+ }
3970
+
3971
+ if (typeof pattern === 'string') {
3972
+ if (isEmptyString(str) || isEmptyString(pattern)) {
3973
+ return false;
3974
+ }
3975
+
3976
+ if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) {
3977
+ return true;
3978
+ }
3979
+ }
3980
+
3981
+ return micromatch.isMatch(str, pattern, { ...options, contains: true });
3982
+ };
3983
+
3984
+ /**
3985
+ * Filter the keys of the given object with the given `glob` pattern
3986
+ * and `options`. Does not attempt to match nested keys. If you need this feature,
3987
+ * use [glob-object][] instead.
3988
+ *
3989
+ * ```js
3990
+ * const mm = require('micromatch');
3991
+ * // mm.matchKeys(object, patterns[, options]);
3992
+ *
3993
+ * const obj = { aa: 'a', ab: 'b', ac: 'c' };
3994
+ * console.log(mm.matchKeys(obj, '*b'));
3995
+ * //=> { ab: 'b' }
3996
+ * ```
3997
+ * @param {Object} `object` The object with keys to filter.
3998
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3999
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
4000
+ * @return {Object} Returns an object with only keys that match the given patterns.
4001
+ * @api public
4002
+ */
4003
+
4004
+ micromatch.matchKeys = (obj, patterns, options) => {
4005
+ if (!utils.isObject(obj)) {
4006
+ throw new TypeError('Expected the first argument to be an object');
4007
+ }
4008
+ let keys = micromatch(Object.keys(obj), patterns, options);
4009
+ let res = {};
4010
+ for (let key of keys) res[key] = obj[key];
4011
+ return res;
4012
+ };
4013
+
4014
+ /**
4015
+ * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
4016
+ *
4017
+ * ```js
4018
+ * const mm = require('micromatch');
4019
+ * // mm.some(list, patterns[, options]);
4020
+ *
4021
+ * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
4022
+ * // true
4023
+ * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
4024
+ * // false
4025
+ * ```
4026
+ * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
4027
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
4028
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
4029
+ * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
4030
+ * @api public
4031
+ */
4032
+
4033
+ micromatch.some = (list, patterns, options) => {
4034
+ let items = [].concat(list);
4035
+
4036
+ for (let pattern of [].concat(patterns)) {
4037
+ let isMatch = picomatch(String(pattern), options);
4038
+ if (items.some(item => isMatch(item))) {
4039
+ return true;
4040
+ }
4041
+ }
4042
+ return false;
4043
+ };
4044
+
4045
+ /**
4046
+ * Returns true if every string in the given `list` matches
4047
+ * any of the given glob `patterns`.
4048
+ *
4049
+ * ```js
4050
+ * const mm = require('micromatch');
4051
+ * // mm.every(list, patterns[, options]);
4052
+ *
4053
+ * console.log(mm.every('foo.js', ['foo.js']));
4054
+ * // true
4055
+ * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
4056
+ * // true
4057
+ * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
4058
+ * // false
4059
+ * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
4060
+ * // false
4061
+ * ```
4062
+ * @param {String|Array} `list` The string or array of strings to test.
4063
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
4064
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
4065
+ * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
4066
+ * @api public
4067
+ */
4068
+
4069
+ micromatch.every = (list, patterns, options) => {
4070
+ let items = [].concat(list);
4071
+
4072
+ for (let pattern of [].concat(patterns)) {
4073
+ let isMatch = picomatch(String(pattern), options);
4074
+ if (!items.every(item => isMatch(item))) {
4075
+ return false;
4076
+ }
4077
+ }
4078
+ return true;
4079
+ };
4080
+
4081
+ /**
4082
+ * Returns true if **all** of the given `patterns` match
4083
+ * the specified string.
4084
+ *
4085
+ * ```js
4086
+ * const mm = require('micromatch');
4087
+ * // mm.all(string, patterns[, options]);
4088
+ *
4089
+ * console.log(mm.all('foo.js', ['foo.js']));
4090
+ * // true
4091
+ *
4092
+ * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
4093
+ * // false
4094
+ *
4095
+ * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
4096
+ * // true
4097
+ *
4098
+ * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
4099
+ * // true
4100
+ * ```
4101
+ * @param {String|Array} `str` The string to test.
4102
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
4103
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
4104
+ * @return {Boolean} Returns true if any patterns match `str`
4105
+ * @api public
4106
+ */
4107
+
4108
+ micromatch.all = (str, patterns, options) => {
4109
+ if (typeof str !== 'string') {
4110
+ throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
4111
+ }
4112
+
4113
+ return [].concat(patterns).every(p => picomatch(p, options)(str));
4114
+ };
4115
+
4116
+ /**
4117
+ * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
4118
+ *
4119
+ * ```js
4120
+ * const mm = require('micromatch');
4121
+ * // mm.capture(pattern, string[, options]);
4122
+ *
4123
+ * console.log(mm.capture('test/*.js', 'test/foo.js'));
4124
+ * //=> ['foo']
4125
+ * console.log(mm.capture('test/*.js', 'foo/bar.css'));
4126
+ * //=> null
4127
+ * ```
4128
+ * @param {String} `glob` Glob pattern to use for matching.
4129
+ * @param {String} `input` String to match
4130
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
4131
+ * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
4132
+ * @api public
4133
+ */
4134
+
4135
+ micromatch.capture = (glob, input, options) => {
4136
+ let posix = utils.isWindows(options);
4137
+ let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
4138
+ let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
4139
+
4140
+ if (match) {
4141
+ return match.slice(1).map(v => v === void 0 ? '' : v);
4142
+ }
4143
+ };
4144
+
4145
+ /**
4146
+ * Create a regular expression from the given glob `pattern`.
4147
+ *
4148
+ * ```js
4149
+ * const mm = require('micromatch');
4150
+ * // mm.makeRe(pattern[, options]);
4151
+ *
4152
+ * console.log(mm.makeRe('*.js'));
4153
+ * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
4154
+ * ```
4155
+ * @param {String} `pattern` A glob pattern to convert to regex.
4156
+ * @param {Object} `options`
4157
+ * @return {RegExp} Returns a regex created from the given pattern.
4158
+ * @api public
4159
+ */
4160
+
4161
+ micromatch.makeRe = (...args) => picomatch.makeRe(...args);
4162
+
4163
+ /**
4164
+ * Scan a glob pattern to separate the pattern into segments. Used
4165
+ * by the [split](#split) method.
4166
+ *
4167
+ * ```js
4168
+ * const mm = require('micromatch');
4169
+ * const state = mm.scan(pattern[, options]);
4170
+ * ```
4171
+ * @param {String} `pattern`
4172
+ * @param {Object} `options`
4173
+ * @return {Object} Returns an object with
4174
+ * @api public
4175
+ */
4176
+
4177
+ micromatch.scan = (...args) => picomatch.scan(...args);
4178
+
4179
+ /**
4180
+ * Parse a glob pattern to create the source string for a regular
4181
+ * expression.
4182
+ *
4183
+ * ```js
4184
+ * const mm = require('micromatch');
4185
+ * const state = mm.parse(pattern[, options]);
4186
+ * ```
4187
+ * @param {String} `glob`
4188
+ * @param {Object} `options`
4189
+ * @return {Object} Returns an object with useful properties and output to be used as regex source string.
4190
+ * @api public
4191
+ */
4192
+
4193
+ micromatch.parse = (patterns, options) => {
4194
+ let res = [];
4195
+ for (let pattern of [].concat(patterns || [])) {
4196
+ for (let str of braces(String(pattern), options)) {
4197
+ res.push(picomatch.parse(str, options));
4198
+ }
4199
+ }
4200
+ return res;
4201
+ };
4202
+
4203
+ /**
4204
+ * Process the given brace `pattern`.
4205
+ *
4206
+ * ```js
4207
+ * const { braces } = require('micromatch');
4208
+ * console.log(braces('foo/{a,b,c}/bar'));
4209
+ * //=> [ 'foo/(a|b|c)/bar' ]
4210
+ *
4211
+ * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
4212
+ * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
4213
+ * ```
4214
+ * @param {String} `pattern` String with brace pattern to process.
4215
+ * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
4216
+ * @return {Array}
4217
+ * @api public
4218
+ */
4219
+
4220
+ micromatch.braces = (pattern, options) => {
4221
+ if (typeof pattern !== 'string') throw new TypeError('Expected a string');
4222
+ if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
4223
+ return [pattern];
4224
+ }
4225
+ return braces(pattern, options);
4226
+ };
4227
+
4228
+ /**
4229
+ * Expand braces
4230
+ */
4231
+
4232
+ micromatch.braceExpand = (pattern, options) => {
4233
+ if (typeof pattern !== 'string') throw new TypeError('Expected a string');
4234
+ return micromatch.braces(pattern, { ...options, expand: true });
4235
+ };
4236
+
4237
+ /**
4238
+ * Expose micromatch
4239
+ */
4240
+
4241
+ micromatch_1 = micromatch;
4242
+ return micromatch_1;
4243
+ }
4244
+
4245
+ var micromatchExports = requireMicromatch();
4246
+
4247
+ const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
4248
+ const {
4249
+ JIEK_OUT_DIR
4250
+ } = process.env;
4251
+ const OUTDIR = JIEK_OUT_DIR ?? "dist";
4252
+ function getOutDirs({
4253
+ cwd = process.cwd(),
4254
+ defaultOutdir = OUTDIR,
4255
+ config,
4256
+ pkgName
4257
+ }) {
4258
+ const { build = {} } = config ?? {};
4259
+ const outdir = build?.output?.dir;
4260
+ function resolveOutdir(type) {
4261
+ const dir = (typeof outdir === "object" ? outdir[type] ?? outdir[{
4262
+ js: "dts",
4263
+ dts: "js"
4264
+ }[type]] : outdir) ?? defaultOutdir;
4265
+ return (path.isAbsolute(dir) ? dir : `./${path.relative(cwd, path.resolve(cwd, dir))}`).replace("{{PKG_NAME}}", pkgName);
4266
+ }
4267
+ return {
4268
+ js: resolveOutdir("js"),
4269
+ dts: resolveOutdir("dts")
4270
+ };
4271
+ }
4272
+ function getExports({
4273
+ entrypoints: entrypoints$1,
4274
+ pkgName,
4275
+ pkgIsModule,
4276
+ entries,
4277
+ config,
4278
+ dir,
4279
+ defaultOutdir = OUTDIR,
4280
+ // FIXME dts support
4281
+ outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
4282
+ noFilter,
4283
+ isPublish
4284
+ }) {
4285
+ const {
4286
+ build = {},
4287
+ publish: {
4288
+ withSuffix = false,
4289
+ withSource = true
4290
+ } = {}
4291
+ } = config ?? {};
4292
+ const {
4293
+ crossModuleConvertor = true
4294
+ } = build;
4295
+ const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
4296
+ if (entries) {
4297
+ Object.entries(resolvedEntrypoints).forEach(([key]) => {
4298
+ if (!entries.some((e) => micromatchExports.isMatch(key, e, { matchBase: true }))) {
4299
+ delete resolvedEntrypoints[key];
4300
+ }
4301
+ });
4302
+ }
4303
+ const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : entrypoints.filterLeafs(
4304
+ resolvedEntrypoints,
4305
+ {
4306
+ skipValue: [
4307
+ // ignore values that filename starts with `.jk-noentry`
4308
+ /(^|\/)\.jk-noentry/,
4309
+ ...entrypoints.DEFAULT_SKIP_VALUES
4310
+ ]
4311
+ }
4312
+ );
4313
+ const crossModuleWithConditional = crossModuleConvertor ? {
4314
+ import: (opts) => !pkgIsModule && intersection(
4315
+ new Set(opts.conditionals),
4316
+ /* @__PURE__ */ new Set(["import", "module"])
4317
+ ).size === 0 ? opts.dist.replace(/\.js$/, ".mjs") : false,
4318
+ require: (opts) => pkgIsModule && intersection(
4319
+ new Set(opts.conditionals),
4320
+ /* @__PURE__ */ new Set(["require", "node"])
4321
+ ).size === 0 ? opts.dist.replace(/\.js$/, ".cjs") : false
4322
+ } : {};
4323
+ return [
4324
+ filteredResolvedEntrypoints,
4325
+ entrypoints.entrypoints2Exports(filteredResolvedEntrypoints, {
4326
+ outdir,
4327
+ withSuffix: isPublish ? withSuffix : void 0,
4328
+ withSource: isPublish ? withSource : void 0,
4329
+ withConditional: {
4330
+ ...crossModuleWithConditional
4331
+ }
4332
+ }),
4333
+ outdir
4334
+ ];
4335
+ }
4336
+
4337
+ const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
4338
+ function packageIsExist(name) {
4339
+ try {
4340
+ require$2.resolve(name);
4341
+ return true;
4342
+ } catch (e) {
4343
+ return false;
4344
+ }
4345
+ }
4346
+ let tsRegisterName;
4347
+ const registers = [
4348
+ process.env.JIEK_TS_REGISTER,
4349
+ "esbuild-register",
4350
+ "@swc-node/register",
4351
+ "ts-node/register"
4352
+ ].filter(Boolean);
4353
+ for (const register of registers) {
4354
+ if (packageIsExist(register)) {
4355
+ tsRegisterName = register;
4356
+ break;
4357
+ }
4358
+ }
4359
+
4360
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
4361
+ let configName = "jiek.config";
4362
+ function getConfigPath(root, dir) {
4363
+ const isSupportTsLoader = !!tsRegisterName;
4364
+ function configWithExtIsExist(ext) {
4365
+ const filenames = [
4366
+ path__default.default.resolve(process.cwd(), `${configName}.${ext}`),
4367
+ path__default.default.resolve(process.cwd(), `.${configName}.${ext}`),
4368
+ path__default.default.resolve(root, `${configName}.${ext}`),
4369
+ path__default.default.resolve(root, `.${configName}.${ext}`)
4370
+ ];
4371
+ if (dir) {
4372
+ filenames.unshift(...[
4373
+ path__default.default.resolve(dir, `${configName}.${ext}`),
4374
+ path__default.default.resolve(dir, `.${configName}.${ext}`)
4375
+ ]);
4376
+ }
4377
+ for (const filename of filenames) {
4378
+ if (fs__default.default.existsSync(filename) && fs__default.default.lstatSync(filename).isFile()) {
4379
+ return filename;
4380
+ }
4381
+ }
4382
+ return;
4383
+ }
4384
+ configName = configWithExtIsExist("js") ?? configName;
4385
+ configName = configWithExtIsExist("json") ?? configName;
4386
+ configName = configWithExtIsExist("yaml") ?? configName;
4387
+ if (isSupportTsLoader) {
4388
+ configName = configWithExtIsExist("ts") ?? configName;
4389
+ }
4390
+ return path__default.default.resolve(root, configName);
4391
+ }
4392
+ function loadConfig(dirOrOptions) {
4393
+ let dir;
4394
+ let root;
4395
+ if (typeof dirOrOptions === "object") {
4396
+ dir = dirOrOptions.dir;
4397
+ root = dirOrOptions.root ?? getWD().wd;
4398
+ } else {
4399
+ dir = dirOrOptions;
4400
+ root = getWD().wd;
4401
+ }
4402
+ let configPath = commander.program.getOptionValue("configPath");
4403
+ if (!configPath) {
4404
+ configPath = getConfigPath(root, dir);
4405
+ } else {
4406
+ if (!fs__default.default.existsSync(configPath)) {
4407
+ throw new Error(`config file not found: ${configPath}`);
4408
+ }
4409
+ if (!path__default.default.isAbsolute(configPath)) {
4410
+ configPath = path__default.default.resolve(root, configPath);
4411
+ }
4412
+ }
4413
+ const ext = path__default.default.extname(configPath);
4414
+ let module;
4415
+ switch (ext) {
4416
+ case ".js":
4417
+ module = require$1(configPath);
4418
+ break;
4419
+ case ".json":
4420
+ return require$1(configPath);
4421
+ case ".yaml":
4422
+ return jsYaml.load(fs__default.default.readFileSync(configPath, "utf-8"));
4423
+ case ".ts":
4424
+ if (tsRegisterName) {
4425
+ require$1(tsRegisterName);
4426
+ module = require$1(configPath);
4427
+ break;
4428
+ }
4429
+ throw new Error(
4430
+ "ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register"
4431
+ );
4432
+ case ".config":
4433
+ module = {};
4434
+ break;
4435
+ default:
4436
+ throw new Error(`unsupported config file type: ${ext}`);
4437
+ }
4438
+ if (!module)
4439
+ throw new Error("config file is empty");
4440
+ return module.default ?? module;
4441
+ }
4442
+
4443
+ const outdirDescription = `
4444
+ The output directory of the build, which relative to the target subpackage root directory.
4445
+ Support with variables: 'PKG_NAME',
4446
+ .e.g. 'dist/{{PKG_NAME}}'.
4447
+ `.trim();
4448
+
4449
+ const description = `
4450
+ Publish package to npm registry, and auto generate exports field and other fields in published package.json.
4451
+ If you want to through the options to the \`pnpm publish\` command, you can pass the options after '--'.
4452
+ `.trim();
4453
+ async function forEachSelectedProjectsGraphEntries(callback) {
4454
+ const { value = {} } = await getSelectedProjectsGraph() ?? {};
4455
+ const selectedProjectsGraphEntries = Object.entries(value);
4456
+ if (selectedProjectsGraphEntries.length === 0) {
4457
+ throw new Error("no packages selected");
4458
+ }
4459
+ for (const [dir, manifest] of selectedProjectsGraphEntries) {
4460
+ callback(dir, manifest);
4461
+ }
4462
+ }
4463
+ commander.program.command("publish").description(description).aliases(["pub", "p"]).option("-b, --bumper <bumper>", "bump version", "patch").option("-no-b, --no-bumper", "no bump version").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").action(async ({ outdir, bumper: bumper$1 }) => {
4464
+ let shouldPassThrough = false;
4465
+ const passThroughOptions = process.argv.reduce(
4466
+ (acc, value) => {
4467
+ if (shouldPassThrough) {
4468
+ acc.push(value);
4469
+ }
4470
+ if (value === "--") {
4471
+ shouldPassThrough = true;
4472
+ }
4473
+ return acc;
4474
+ },
4475
+ []
4476
+ );
4477
+ await forEachSelectedProjectsGraphEntries((dir) => {
4478
+ const args = ["pnpm", "publish", "--access", "public", "--no-git-checks"];
4479
+ if (bumper$1 && bumper.TAGS.includes(bumper$1)) {
4480
+ args.push("--tag", bumper$1);
4481
+ }
4482
+ args.push(...passThroughOptions);
4483
+ childProcess__namespace.execSync(args.join(" "), {
4484
+ cwd: dir,
4485
+ stdio: "inherit",
4486
+ env: {
4487
+ ...process.env,
4488
+ JIEK_PUBLISH_OUTDIR: JSON.stringify(outdir),
4489
+ JIEK_PUBLISH_BUMPER: JSON.stringify(bumper$1)
4490
+ }
4491
+ });
4492
+ });
4493
+ });
4494
+ async function prepublish() {
4495
+ const {
4496
+ JIEK_PUBLISH_OUTDIR: outdirEnv,
4497
+ JIEK_PUBLISH_BUMPER: bumperEnv
4498
+ } = process.env;
4499
+ const outdir = outdirEnv ? JSON.parse(outdirEnv) : "dist";
4500
+ const bumper$1 = bumperEnv ? JSON.parse(bumperEnv) : false;
4501
+ const generateNewManifest = (dir, manifest) => {
4502
+ const { name, type, exports: entrypoints = {} } = manifest;
4503
+ if (!name) {
4504
+ throw new Error(`package.json in ${dir} must have a name field`);
4505
+ }
4506
+ const pkgIsModule = type === "module";
4507
+ const newManifest = { ...manifest };
4508
+ const [resolvedEntrypoints, exports, resolvedOutdir] = getExports({
4509
+ entrypoints,
4510
+ pkgIsModule,
4511
+ pkgName: name,
4512
+ config: loadConfig(dir),
4513
+ dir,
4514
+ defaultOutdir: outdir,
4515
+ noFilter: true,
4516
+ isPublish: true
4517
+ });
4518
+ newManifest.exports = {
4519
+ ...resolvedEntrypoints,
4520
+ ...exports
4521
+ };
4522
+ return [newManifest, resolvedOutdir];
4523
+ };
4524
+ const generateNewPackageJSONString = ({
4525
+ oldJSONString,
4526
+ oldJSON,
4527
+ manifest,
4528
+ formattingOptions
4529
+ }) => {
4530
+ let newJSONString = oldJSONString;
4531
+ newJSONString = jsoncParser.applyEdits(
4532
+ newJSONString,
4533
+ jsoncParser.modify(
4534
+ newJSONString,
4535
+ ["publishConfig", "typesVersions"],
4536
+ {
4537
+ "<5.0": {
4538
+ "*": [
4539
+ "*",
4540
+ `./*`,
4541
+ `./*/index.d.ts`,
4542
+ `./*/index.d.mts`,
4543
+ `./*/index.d.cts`
4544
+ ]
4545
+ }
4546
+ },
4547
+ { formattingOptions }
4548
+ )
4549
+ );
4550
+ for (const [key, value] of Object.entries(manifest)) {
4551
+ if (key === "version")
4552
+ continue;
4553
+ if (JSON.stringify(value) === JSON.stringify(oldJSON[key]))
4554
+ continue;
4555
+ if (key !== "exports") {
4556
+ newJSONString = jsoncParser.applyEdits(
4557
+ newJSONString,
4558
+ jsoncParser.modify(
4559
+ newJSONString,
4560
+ ["publishConfig", key],
4561
+ value,
4562
+ { formattingOptions }
4563
+ )
4564
+ );
4565
+ } else {
4566
+ const exports = value;
4567
+ for (const [k, v] of Object.entries(exports)) {
4568
+ newJSONString = jsoncParser.applyEdits(
4569
+ newJSONString,
4570
+ jsoncParser.modify(
4571
+ newJSONString,
4572
+ ["publishConfig", "exports", k],
4573
+ v,
4574
+ { formattingOptions }
4575
+ )
4576
+ );
4577
+ }
4578
+ const index = exports?.["."];
4579
+ const indexPublishConfig = {};
4580
+ if (index) {
4581
+ switch (typeof index) {
4582
+ case "string":
4583
+ indexPublishConfig[manifest?.type === "module" ? "module" : "main"] = index;
4584
+ break;
4585
+ case "object": {
4586
+ const indexExports = index;
4587
+ indexPublishConfig.main = indexExports["require"] ?? indexExports["default"];
4588
+ indexPublishConfig.module = indexExports["import"] ?? indexExports["module"] ?? indexExports["default"];
4589
+ break;
4590
+ }
4591
+ }
4592
+ for (const [k, v] of Object.entries(indexPublishConfig)) {
4593
+ if (v === void 0)
4594
+ continue;
4595
+ newJSONString = jsoncParser.applyEdits(
4596
+ newJSONString,
4597
+ jsoncParser.modify(
4598
+ newJSONString,
4599
+ ["publishConfig", k],
4600
+ v,
4601
+ { formattingOptions }
4602
+ )
4603
+ );
4604
+ }
4605
+ }
4606
+ }
4607
+ }
4608
+ if (oldJSON["peerDependencies"]) {
4609
+ const peerDependenciesMeta = Object.keys(oldJSON["peerDependencies"]).reduce(
4610
+ (acc, key) => {
4611
+ acc[key] = { optional: true };
4612
+ return acc;
4613
+ },
4614
+ {}
4615
+ );
4616
+ newJSONString = jsoncParser.applyEdits(
4617
+ newJSONString,
4618
+ jsoncParser.modify(
4619
+ newJSONString,
4620
+ ["peerDependenciesMeta"],
4621
+ peerDependenciesMeta,
4622
+ { formattingOptions }
4623
+ )
4624
+ );
4625
+ }
4626
+ if (oldJSON["files"]) {
4627
+ newJSONString = jsoncParser.applyEdits(
4628
+ newJSONString,
4629
+ jsoncParser.modify(
4630
+ newJSONString,
4631
+ ["files"],
4632
+ void 0,
4633
+ { formattingOptions }
4634
+ )
4635
+ );
4636
+ }
4637
+ return newJSONString;
4638
+ };
4639
+ await forEachSelectedProjectsGraphEntries((dir, originalManifest) => {
4640
+ const [manifest, resolvedOutdir] = generateNewManifest(dir, originalManifest);
4641
+ const resolveByDir = (...paths) => path__default.default.resolve(dir, ...paths);
4642
+ const oldJSONString = fs__default.default.readFileSync(resolveByDir("package.json"), "utf-8");
4643
+ const oldJSON = JSON.parse(oldJSONString) ?? "0.0.0";
4644
+ if (typeof oldJSON.version !== "string") {
4645
+ throw new Error(`${dir}/package.json must have a version field with a string value`);
4646
+ }
4647
+ const { indent = " " } = detectIndent__default.default(oldJSONString);
4648
+ const formattingOptions = {
4649
+ tabSize: indent.length,
4650
+ insertSpaces: true
4651
+ };
4652
+ const newVersion = bumper$1 ? bumper.bump(oldJSON.version, bumper$1) : oldJSON.version;
4653
+ const modifyVersionPackageJSON = jsoncParser.applyEdits(
4654
+ oldJSONString,
4655
+ jsoncParser.modify(oldJSONString, ["version"], newVersion, { formattingOptions })
4656
+ );
4657
+ const newJSONString = generateNewPackageJSONString({
4658
+ oldJSONString: modifyVersionPackageJSON,
4659
+ oldJSON: {
4660
+ ...oldJSON,
4661
+ version: newVersion
4662
+ },
4663
+ manifest,
4664
+ formattingOptions
4665
+ });
4666
+ const withPublishConfigDirectoryOldJSONString = jsoncParser.applyEdits(
4667
+ modifyVersionPackageJSON,
4668
+ jsoncParser.modify(modifyVersionPackageJSON, ["publishConfig", "directory"], resolvedOutdir, { formattingOptions })
4669
+ );
4670
+ if (oldJSON.files) {
4671
+ if (!Array.isArray(oldJSON.files)) {
4672
+ throw new Error(`${dir}/package.json files field must be an array`);
4673
+ }
4674
+ if (Array.isArray(oldJSON.files) && oldJSON.files.every((file) => typeof file !== "string")) {
4675
+ throw new Error(`${dir}/package.json files field must be an array of string`);
4676
+ }
4677
+ }
4678
+ const resolvedOutdirAbs = resolveByDir(resolvedOutdir);
4679
+ const files = oldJSON.files ?? fs__default.default.readdirSync(resolveByDir(".")).filter((file) => file !== "node_modules" && resolveByDir(file) !== resolvedOutdirAbs);
4680
+ for (const file of files) {
4681
+ const path2 = resolveByDir(file);
4682
+ try {
4683
+ const stat = fs__default.default.statSync(path2);
4684
+ if (stat.isDirectory()) {
4685
+ fs__default.default.symlinkSync(path2, resolveByDir(resolvedOutdir, file), "dir");
4686
+ continue;
4687
+ }
4688
+ if (stat.isFile()) {
4689
+ fs__default.default.symlinkSync(path2, resolveByDir(resolvedOutdir, file), "file");
4690
+ continue;
4691
+ }
4692
+ } catch (e) {
4693
+ console.warn(String(e));
4694
+ continue;
4695
+ }
4696
+ throw new Error(`file type of ${path2} is not supported`);
4697
+ }
4698
+ if (!fs__default.default.existsSync(resolveByDir(resolvedOutdir))) {
4699
+ fs__default.default.mkdirSync(resolveByDir(resolvedOutdir));
4700
+ }
4701
+ const jiekTempDir = resolveByDir("node_modules/.jiek/.tmp");
4702
+ if (!fs__default.default.existsSync(resolveByDir(jiekTempDir))) {
4703
+ fs__default.default.mkdirSync(resolveByDir(jiekTempDir), { recursive: true });
4704
+ }
4705
+ fs__default.default.writeFileSync(resolveByDir(resolvedOutdir, "package.json"), newJSONString);
4706
+ fs__default.default.writeFileSync(resolveByDir(jiekTempDir, "package.json"), modifyVersionPackageJSON);
4707
+ fs__default.default.writeFileSync(resolveByDir("package.json"), withPublishConfigDirectoryOldJSONString);
4708
+ });
4709
+ }
4710
+ async function postpublish() {
4711
+ await forEachSelectedProjectsGraphEntries((dir) => {
4712
+ const jiekTempDir = path__default.default.resolve(dir, "node_modules/.jiek/.tmp");
4713
+ const packageJSON = path__default.default.resolve(dir, "package.json");
4714
+ const jiekTempPackageJSON = path__default.default.resolve(jiekTempDir, "package.json");
4715
+ if (fs__default.default.existsSync(jiekTempPackageJSON)) {
4716
+ fs__default.default.copyFileSync(jiekTempPackageJSON, packageJSON);
4717
+ fs__default.default.rmSync(jiekTempPackageJSON);
4718
+ console.log(`${dir}/package.json has been restored`);
4719
+ } else {
4720
+ throw new Error(
4721
+ `jiek temp \`${dir}/package.json\` not found, please confirm the jiek pre-publish command has been executed`
4722
+ );
4723
+ }
4724
+ });
4725
+ }
4726
+ commander.program.action(async () => {
4727
+ const {
4728
+ npm_lifecycle_event: NPM_LIFECYCLE_EVENT
4729
+ } = process.env;
4730
+ switch (NPM_LIFECYCLE_EVENT) {
4731
+ case "prepublish":
4732
+ await prepublish();
4733
+ break;
4734
+ case "postpublish":
4735
+ await postpublish();
4736
+ break;
4737
+ default:
4738
+ commander.program.help();
4739
+ }
4740
+ });
4741
+ commander.program.command("prepublish").action(prepublish);
4742
+ commander.program.command("postpublish").action(postpublish);