jiek 2.0.2-alpha.1 → 2.0.2-alpha.2

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