@quilted/create 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/cjs/app.cjs +303 -0
  3. package/build/cjs/index.cjs +5220 -5198
  4. package/build/cjs/index2.cjs +374 -0
  5. package/build/cjs/index3.cjs +50060 -0
  6. package/build/cjs/index4.cjs +7854 -0
  7. package/build/cjs/minimatch.cjs +1202 -0
  8. package/build/cjs/package-manager.cjs +300 -0
  9. package/build/cjs/package.cjs +410 -0
  10. package/build/esm/app.mjs +280 -0
  11. package/build/esm/index.mjs +5206 -5195
  12. package/build/esm/index2.mjs +365 -0
  13. package/build/esm/index3.mjs +50047 -0
  14. package/build/esm/index4.mjs +7852 -0
  15. package/build/esm/minimatch.mjs +1200 -0
  16. package/build/esm/package-manager.mjs +270 -0
  17. package/build/esm/package.mjs +387 -0
  18. package/build/tsconfig.tsbuildinfo +1 -1
  19. package/build/typescript/app.d.ts +2 -0
  20. package/build/typescript/app.d.ts.map +1 -0
  21. package/build/typescript/help.d.ts +6 -0
  22. package/build/typescript/help.d.ts.map +1 -0
  23. package/build/typescript/package.d.ts +2 -0
  24. package/build/typescript/package.d.ts.map +1 -0
  25. package/build/typescript/shared/package-manager.d.ts +3 -0
  26. package/build/typescript/shared/package-manager.d.ts.map +1 -0
  27. package/build/typescript/shared/prompts.d.ts +22 -0
  28. package/build/typescript/shared/prompts.d.ts.map +1 -0
  29. package/build/typescript/shared/tsconfig.d.ts +3 -0
  30. package/build/typescript/shared/tsconfig.d.ts.map +1 -0
  31. package/build/typescript/shared.d.ts +21 -0
  32. package/build/typescript/shared.d.ts.map +1 -0
  33. package/package.json +13 -3
  34. package/source/app.ts +387 -0
  35. package/source/create.ts +43 -383
  36. package/source/help.ts +132 -0
  37. package/source/package.ts +510 -0
  38. package/source/shared/package-manager.ts +74 -0
  39. package/source/shared/prompts.ts +133 -0
  40. package/source/shared/tsconfig.ts +90 -0
  41. package/source/shared.ts +165 -0
  42. package/templates/{app → app-basic}/App.tsx +4 -7
  43. package/templates/{app → app-basic}/features/Start/Start.module.css +0 -0
  44. package/templates/{app → app-basic}/features/Start/Start.tsx +1 -1
  45. package/templates/{app → app-basic}/features/Start/index.ts +0 -0
  46. package/templates/{app → app-basic}/foundation/Head.tsx +8 -8
  47. package/templates/{app → app-basic}/foundation/Http.tsx +10 -6
  48. package/templates/{app → app-basic}/package.json +10 -1
  49. package/templates/{app → app-basic}/quilt.project.ts +0 -0
  50. package/templates/{app → app-basic}/server.tsx +0 -0
  51. package/templates/{app → app-basic}/shared/types.ts +0 -0
  52. package/templates/{app → app-basic}/tsconfig.json +0 -0
  53. package/templates/app-single-file/App.tsx +168 -0
  54. package/templates/app-single-file/package.json +30 -0
  55. package/templates/app-single-file/quilt.project.ts +6 -0
  56. package/templates/app-single-file/tsconfig.json +9 -0
  57. package/templates/{workspace → github}/_github/workflows/actions/prepare/action.yml +0 -0
  58. package/templates/{workspace → github}/_github/workflows/ci.yml +0 -0
  59. package/templates/package/package.json +24 -9
  60. package/templates/package/quilt.project.ts +1 -1
  61. package/templates/vscode/_vscode/extensions.json +7 -0
  62. package/templates/vscode/_vscode/settings.json +17 -0
  63. package/templates/workspace/_gitignore +1 -1
  64. package/templates/workspace/_prettierignore +1 -0
  65. package/templates/workspace/package.json +1 -7
  66. package/templates/workspace/tsconfig.json +6 -1
  67. package/templates/workspace/pnpm-workspace.yaml +0 -3
@@ -0,0 +1,1202 @@
1
+ 'use strict';
2
+
3
+ function _mergeNamespaces(n, m) {
4
+ m.forEach(function (e) {
5
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
6
+ if (k !== 'default' && !(k in n)) {
7
+ var d = Object.getOwnPropertyDescriptor(e, k);
8
+ Object.defineProperty(n, k, d.get ? d : {
9
+ enumerable: true,
10
+ get: function () { return e[k]; }
11
+ });
12
+ }
13
+ });
14
+ });
15
+ return Object.freeze(n);
16
+ }
17
+
18
+ const isWindows = typeof process === 'object' &&
19
+ process &&
20
+ process.platform === 'win32';
21
+ var path$1 = isWindows ? { sep: '\\' } : { sep: '/' };
22
+
23
+ var balancedMatch = balanced$1;
24
+ function balanced$1(a, b, str) {
25
+ if (a instanceof RegExp) a = maybeMatch(a, str);
26
+ if (b instanceof RegExp) b = maybeMatch(b, str);
27
+
28
+ var r = range(a, b, str);
29
+
30
+ return r && {
31
+ start: r[0],
32
+ end: r[1],
33
+ pre: str.slice(0, r[0]),
34
+ body: str.slice(r[0] + a.length, r[1]),
35
+ post: str.slice(r[1] + b.length)
36
+ };
37
+ }
38
+
39
+ function maybeMatch(reg, str) {
40
+ var m = str.match(reg);
41
+ return m ? m[0] : null;
42
+ }
43
+
44
+ balanced$1.range = range;
45
+ function range(a, b, str) {
46
+ var begs, beg, left, right, result;
47
+ var ai = str.indexOf(a);
48
+ var bi = str.indexOf(b, ai + 1);
49
+ var i = ai;
50
+
51
+ if (ai >= 0 && bi > 0) {
52
+ if(a===b) {
53
+ return [ai, bi];
54
+ }
55
+ begs = [];
56
+ left = str.length;
57
+
58
+ while (i >= 0 && !result) {
59
+ if (i == ai) {
60
+ begs.push(i);
61
+ ai = str.indexOf(a, i + 1);
62
+ } else if (begs.length == 1) {
63
+ result = [ begs.pop(), bi ];
64
+ } else {
65
+ beg = begs.pop();
66
+ if (beg < left) {
67
+ left = beg;
68
+ right = bi;
69
+ }
70
+
71
+ bi = str.indexOf(b, i + 1);
72
+ }
73
+
74
+ i = ai < bi && ai >= 0 ? ai : bi;
75
+ }
76
+
77
+ if (begs.length) {
78
+ result = [ left, right ];
79
+ }
80
+ }
81
+
82
+ return result;
83
+ }
84
+
85
+ var balanced = balancedMatch;
86
+
87
+ var braceExpansion = expandTop;
88
+
89
+ var escSlash = '\0SLASH'+Math.random()+'\0';
90
+ var escOpen = '\0OPEN'+Math.random()+'\0';
91
+ var escClose = '\0CLOSE'+Math.random()+'\0';
92
+ var escComma = '\0COMMA'+Math.random()+'\0';
93
+ var escPeriod = '\0PERIOD'+Math.random()+'\0';
94
+
95
+ function numeric(str) {
96
+ return parseInt(str, 10) == str
97
+ ? parseInt(str, 10)
98
+ : str.charCodeAt(0);
99
+ }
100
+
101
+ function escapeBraces(str) {
102
+ return str.split('\\\\').join(escSlash)
103
+ .split('\\{').join(escOpen)
104
+ .split('\\}').join(escClose)
105
+ .split('\\,').join(escComma)
106
+ .split('\\.').join(escPeriod);
107
+ }
108
+
109
+ function unescapeBraces(str) {
110
+ return str.split(escSlash).join('\\')
111
+ .split(escOpen).join('{')
112
+ .split(escClose).join('}')
113
+ .split(escComma).join(',')
114
+ .split(escPeriod).join('.');
115
+ }
116
+
117
+
118
+ // Basically just str.split(","), but handling cases
119
+ // where we have nested braced sections, which should be
120
+ // treated as individual members, like {a,{b,c},d}
121
+ function parseCommaParts(str) {
122
+ if (!str)
123
+ return [''];
124
+
125
+ var parts = [];
126
+ var m = balanced('{', '}', str);
127
+
128
+ if (!m)
129
+ return str.split(',');
130
+
131
+ var pre = m.pre;
132
+ var body = m.body;
133
+ var post = m.post;
134
+ var p = pre.split(',');
135
+
136
+ p[p.length-1] += '{' + body + '}';
137
+ var postParts = parseCommaParts(post);
138
+ if (post.length) {
139
+ p[p.length-1] += postParts.shift();
140
+ p.push.apply(p, postParts);
141
+ }
142
+
143
+ parts.push.apply(parts, p);
144
+
145
+ return parts;
146
+ }
147
+
148
+ function expandTop(str) {
149
+ if (!str)
150
+ return [];
151
+
152
+ // I don't know why Bash 4.3 does this, but it does.
153
+ // Anything starting with {} will have the first two bytes preserved
154
+ // but *only* at the top level, so {},a}b will not expand to anything,
155
+ // but a{},b}c will be expanded to [a}c,abc].
156
+ // One could argue that this is a bug in Bash, but since the goal of
157
+ // this module is to match Bash's rules, we escape a leading {}
158
+ if (str.substr(0, 2) === '{}') {
159
+ str = '\\{\\}' + str.substr(2);
160
+ }
161
+
162
+ return expand$1(escapeBraces(str), true).map(unescapeBraces);
163
+ }
164
+
165
+ function embrace(str) {
166
+ return '{' + str + '}';
167
+ }
168
+ function isPadded(el) {
169
+ return /^-?0\d/.test(el);
170
+ }
171
+
172
+ function lte(i, y) {
173
+ return i <= y;
174
+ }
175
+ function gte(i, y) {
176
+ return i >= y;
177
+ }
178
+
179
+ function expand$1(str, isTop) {
180
+ var expansions = [];
181
+
182
+ var m = balanced('{', '}', str);
183
+ if (!m) return [str];
184
+
185
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
186
+ var pre = m.pre;
187
+ var post = m.post.length
188
+ ? expand$1(m.post, false)
189
+ : [''];
190
+
191
+ if (/\$$/.test(m.pre)) {
192
+ for (var k = 0; k < post.length; k++) {
193
+ var expansion = pre+ '{' + m.body + '}' + post[k];
194
+ expansions.push(expansion);
195
+ }
196
+ } else {
197
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
198
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
199
+ var isSequence = isNumericSequence || isAlphaSequence;
200
+ var isOptions = m.body.indexOf(',') >= 0;
201
+ if (!isSequence && !isOptions) {
202
+ // {a},b}
203
+ if (m.post.match(/,.*\}/)) {
204
+ str = m.pre + '{' + m.body + escClose + m.post;
205
+ return expand$1(str);
206
+ }
207
+ return [str];
208
+ }
209
+
210
+ var n;
211
+ if (isSequence) {
212
+ n = m.body.split(/\.\./);
213
+ } else {
214
+ n = parseCommaParts(m.body);
215
+ if (n.length === 1) {
216
+ // x{{a,b}}y ==> x{a}y x{b}y
217
+ n = expand$1(n[0], false).map(embrace);
218
+ if (n.length === 1) {
219
+ return post.map(function(p) {
220
+ return m.pre + n[0] + p;
221
+ });
222
+ }
223
+ }
224
+ }
225
+
226
+ // at this point, n is the parts, and we know it's not a comma set
227
+ // with a single entry.
228
+ var N;
229
+
230
+ if (isSequence) {
231
+ var x = numeric(n[0]);
232
+ var y = numeric(n[1]);
233
+ var width = Math.max(n[0].length, n[1].length);
234
+ var incr = n.length == 3
235
+ ? Math.abs(numeric(n[2]))
236
+ : 1;
237
+ var test = lte;
238
+ var reverse = y < x;
239
+ if (reverse) {
240
+ incr *= -1;
241
+ test = gte;
242
+ }
243
+ var pad = n.some(isPadded);
244
+
245
+ N = [];
246
+
247
+ for (var i = x; test(i, y); i += incr) {
248
+ var c;
249
+ if (isAlphaSequence) {
250
+ c = String.fromCharCode(i);
251
+ if (c === '\\')
252
+ c = '';
253
+ } else {
254
+ c = String(i);
255
+ if (pad) {
256
+ var need = width - c.length;
257
+ if (need > 0) {
258
+ var z = new Array(need + 1).join('0');
259
+ if (i < 0)
260
+ c = '-' + z + c.slice(1);
261
+ else
262
+ c = z + c;
263
+ }
264
+ }
265
+ }
266
+ N.push(c);
267
+ }
268
+ } else {
269
+ N = [];
270
+
271
+ for (var j = 0; j < n.length; j++) {
272
+ N.push.apply(N, expand$1(n[j], false));
273
+ }
274
+ }
275
+
276
+ for (var j = 0; j < N.length; j++) {
277
+ for (var k = 0; k < post.length; k++) {
278
+ var expansion = pre + N[j] + post[k];
279
+ if (!isTop || isSequence || expansion)
280
+ expansions.push(expansion);
281
+ }
282
+ }
283
+ }
284
+
285
+ return expansions;
286
+ }
287
+
288
+ const minimatch = minimatch_1 = (p, pattern, options = {}) => {
289
+ assertValidPattern(pattern);
290
+
291
+ // shortcut: comments match nothing.
292
+ if (!options.nocomment && pattern.charAt(0) === '#') {
293
+ return false
294
+ }
295
+
296
+ return new Minimatch(pattern, options).match(p)
297
+ };
298
+
299
+ var minimatch_1 = minimatch;
300
+
301
+ const path = path$1;
302
+ minimatch.sep = path.sep;
303
+
304
+ const GLOBSTAR = Symbol('globstar **');
305
+ minimatch.GLOBSTAR = GLOBSTAR;
306
+ const expand = braceExpansion;
307
+
308
+ const plTypes = {
309
+ '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
310
+ '?': { open: '(?:', close: ')?' },
311
+ '+': { open: '(?:', close: ')+' },
312
+ '*': { open: '(?:', close: ')*' },
313
+ '@': { open: '(?:', close: ')' }
314
+ };
315
+
316
+ // any single thing other than /
317
+ // don't need to escape / when using new RegExp()
318
+ const qmark = '[^/]';
319
+
320
+ // * => any number of characters
321
+ const star = qmark + '*?';
322
+
323
+ // ** when dots are allowed. Anything goes, except .. and .
324
+ // not (^ or / followed by one or two dots followed by $ or /),
325
+ // followed by anything, any number of times.
326
+ const twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?';
327
+
328
+ // not a ^ or / followed by a dot,
329
+ // followed by anything, any number of times.
330
+ const twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?';
331
+
332
+ // "abc" -> { a:true, b:true, c:true }
333
+ const charSet = s => s.split('').reduce((set, c) => {
334
+ set[c] = true;
335
+ return set
336
+ }, {});
337
+
338
+ // characters that need to be escaped in RegExp.
339
+ const reSpecials = charSet('().*{}+?[]^$\\!');
340
+
341
+ // characters that indicate we have to add the pattern start
342
+ const addPatternStartSet = charSet('[.(');
343
+
344
+ // normalizes slashes.
345
+ const slashSplit = /\/+/;
346
+
347
+ minimatch.filter = (pattern, options = {}) =>
348
+ (p, i, list) => minimatch(p, pattern, options);
349
+
350
+ const ext = (a, b = {}) => {
351
+ const t = {};
352
+ Object.keys(a).forEach(k => t[k] = a[k]);
353
+ Object.keys(b).forEach(k => t[k] = b[k]);
354
+ return t
355
+ };
356
+
357
+ minimatch.defaults = def => {
358
+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
359
+ return minimatch
360
+ }
361
+
362
+ const orig = minimatch;
363
+
364
+ const m = (p, pattern, options) => orig(p, pattern, ext(def, options));
365
+ m.Minimatch = class Minimatch extends orig.Minimatch {
366
+ constructor (pattern, options) {
367
+ super(pattern, ext(def, options));
368
+ }
369
+ };
370
+ m.Minimatch.defaults = options => orig.defaults(ext(def, options)).Minimatch;
371
+ m.filter = (pattern, options) => orig.filter(pattern, ext(def, options));
372
+ m.defaults = options => orig.defaults(ext(def, options));
373
+ m.makeRe = (pattern, options) => orig.makeRe(pattern, ext(def, options));
374
+ m.braceExpand = (pattern, options) => orig.braceExpand(pattern, ext(def, options));
375
+ m.match = (list, pattern, options) => orig.match(list, pattern, ext(def, options));
376
+
377
+ return m
378
+ };
379
+
380
+
381
+
382
+
383
+
384
+ // Brace expansion:
385
+ // a{b,c}d -> abd acd
386
+ // a{b,}c -> abc ac
387
+ // a{0..3}d -> a0d a1d a2d a3d
388
+ // a{b,c{d,e}f}g -> abg acdfg acefg
389
+ // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
390
+ //
391
+ // Invalid sets are not expanded.
392
+ // a{2..}b -> a{2..}b
393
+ // a{b}c -> a{b}c
394
+ minimatch.braceExpand = (pattern, options) => braceExpand(pattern, options);
395
+
396
+ const braceExpand = (pattern, options = {}) => {
397
+ assertValidPattern(pattern);
398
+
399
+ // Thanks to Yeting Li <https://github.com/yetingli> for
400
+ // improving this regexp to avoid a ReDOS vulnerability.
401
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
402
+ // shortcut. no need to expand.
403
+ return [pattern]
404
+ }
405
+
406
+ return expand(pattern)
407
+ };
408
+
409
+ const MAX_PATTERN_LENGTH = 1024 * 64;
410
+ const assertValidPattern = pattern => {
411
+ if (typeof pattern !== 'string') {
412
+ throw new TypeError('invalid pattern')
413
+ }
414
+
415
+ if (pattern.length > MAX_PATTERN_LENGTH) {
416
+ throw new TypeError('pattern is too long')
417
+ }
418
+ };
419
+
420
+ // parse a component of the expanded set.
421
+ // At this point, no pattern may contain "/" in it
422
+ // so we're going to return a 2d array, where each entry is the full
423
+ // pattern, split on '/', and then turned into a regular expression.
424
+ // A regexp is made at the end which joins each array with an
425
+ // escaped /, and another full one which joins each regexp with |.
426
+ //
427
+ // Following the lead of Bash 4.1, note that "**" only has special meaning
428
+ // when it is the *only* thing in a path portion. Otherwise, any series
429
+ // of * is equivalent to a single *. Globstar behavior is enabled by
430
+ // default, and can be disabled by setting options.noglobstar.
431
+ const SUBPARSE = Symbol('subparse');
432
+
433
+ minimatch.makeRe = (pattern, options) =>
434
+ new Minimatch(pattern, options || {}).makeRe();
435
+
436
+ minimatch.match = (list, pattern, options = {}) => {
437
+ const mm = new Minimatch(pattern, options);
438
+ list = list.filter(f => mm.match(f));
439
+ if (mm.options.nonull && !list.length) {
440
+ list.push(pattern);
441
+ }
442
+ return list
443
+ };
444
+
445
+ // replace stuff like \* with *
446
+ const globUnescape = s => s.replace(/\\(.)/g, '$1');
447
+ const regExpEscape = s => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
448
+
449
+ class Minimatch {
450
+ constructor (pattern, options) {
451
+ assertValidPattern(pattern);
452
+
453
+ if (!options) options = {};
454
+
455
+ this.options = options;
456
+ this.set = [];
457
+ this.pattern = pattern;
458
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape ||
459
+ options.allowWindowsEscape === false;
460
+ if (this.windowsPathsNoEscape) {
461
+ this.pattern = this.pattern.replace(/\\/g, '/');
462
+ }
463
+ this.regexp = null;
464
+ this.negate = false;
465
+ this.comment = false;
466
+ this.empty = false;
467
+ this.partial = !!options.partial;
468
+
469
+ // make the set of regexps etc.
470
+ this.make();
471
+ }
472
+
473
+ debug () {}
474
+
475
+ make () {
476
+ const pattern = this.pattern;
477
+ const options = this.options;
478
+
479
+ // empty patterns and comments match nothing.
480
+ if (!options.nocomment && pattern.charAt(0) === '#') {
481
+ this.comment = true;
482
+ return
483
+ }
484
+ if (!pattern) {
485
+ this.empty = true;
486
+ return
487
+ }
488
+
489
+ // step 1: figure out negation, etc.
490
+ this.parseNegate();
491
+
492
+ // step 2: expand braces
493
+ let set = this.globSet = this.braceExpand();
494
+
495
+ if (options.debug) this.debug = (...args) => console.error(...args);
496
+
497
+ this.debug(this.pattern, set);
498
+
499
+ // step 3: now we have a set, so turn each one into a series of path-portion
500
+ // matching patterns.
501
+ // These will be regexps, except in the case of "**", which is
502
+ // set to the GLOBSTAR object for globstar behavior,
503
+ // and will not contain any / characters
504
+ set = this.globParts = set.map(s => s.split(slashSplit));
505
+
506
+ this.debug(this.pattern, set);
507
+
508
+ // glob --> regexps
509
+ set = set.map((s, si, set) => s.map(this.parse, this));
510
+
511
+ this.debug(this.pattern, set);
512
+
513
+ // filter out everything that didn't compile properly.
514
+ set = set.filter(s => s.indexOf(false) === -1);
515
+
516
+ this.debug(this.pattern, set);
517
+
518
+ this.set = set;
519
+ }
520
+
521
+ parseNegate () {
522
+ if (this.options.nonegate) return
523
+
524
+ const pattern = this.pattern;
525
+ let negate = false;
526
+ let negateOffset = 0;
527
+
528
+ for (let i = 0; i < pattern.length && pattern.charAt(i) === '!'; i++) {
529
+ negate = !negate;
530
+ negateOffset++;
531
+ }
532
+
533
+ if (negateOffset) this.pattern = pattern.substr(negateOffset);
534
+ this.negate = negate;
535
+ }
536
+
537
+ // set partial to true to test if, for example,
538
+ // "/a/b" matches the start of "/*/b/*/d"
539
+ // Partial means, if you run out of file before you run
540
+ // out of pattern, then that's fine, as long as all
541
+ // the parts match.
542
+ matchOne (file, pattern, partial) {
543
+ var options = this.options;
544
+
545
+ this.debug('matchOne',
546
+ { 'this': this, file: file, pattern: pattern });
547
+
548
+ this.debug('matchOne', file.length, pattern.length);
549
+
550
+ for (var fi = 0,
551
+ pi = 0,
552
+ fl = file.length,
553
+ pl = pattern.length
554
+ ; (fi < fl) && (pi < pl)
555
+ ; fi++, pi++) {
556
+ this.debug('matchOne loop');
557
+ var p = pattern[pi];
558
+ var f = file[fi];
559
+
560
+ this.debug(pattern, p, f);
561
+
562
+ // should be impossible.
563
+ // some invalid regexp stuff in the set.
564
+ /* istanbul ignore if */
565
+ if (p === false) return false
566
+
567
+ if (p === GLOBSTAR) {
568
+ this.debug('GLOBSTAR', [pattern, p, f]);
569
+
570
+ // "**"
571
+ // a/**/b/**/c would match the following:
572
+ // a/b/x/y/z/c
573
+ // a/x/y/z/b/c
574
+ // a/b/x/b/x/c
575
+ // a/b/c
576
+ // To do this, take the rest of the pattern after
577
+ // the **, and see if it would match the file remainder.
578
+ // If so, return success.
579
+ // If not, the ** "swallows" a segment, and try again.
580
+ // This is recursively awful.
581
+ //
582
+ // a/**/b/**/c matching a/b/x/y/z/c
583
+ // - a matches a
584
+ // - doublestar
585
+ // - matchOne(b/x/y/z/c, b/**/c)
586
+ // - b matches b
587
+ // - doublestar
588
+ // - matchOne(x/y/z/c, c) -> no
589
+ // - matchOne(y/z/c, c) -> no
590
+ // - matchOne(z/c, c) -> no
591
+ // - matchOne(c, c) yes, hit
592
+ var fr = fi;
593
+ var pr = pi + 1;
594
+ if (pr === pl) {
595
+ this.debug('** at the end');
596
+ // a ** at the end will just swallow the rest.
597
+ // We have found a match.
598
+ // however, it will not swallow /.x, unless
599
+ // options.dot is set.
600
+ // . and .. are *never* matched by **, for explosively
601
+ // exponential reasons.
602
+ for (; fi < fl; fi++) {
603
+ if (file[fi] === '.' || file[fi] === '..' ||
604
+ (!options.dot && file[fi].charAt(0) === '.')) return false
605
+ }
606
+ return true
607
+ }
608
+
609
+ // ok, let's see if we can swallow whatever we can.
610
+ while (fr < fl) {
611
+ var swallowee = file[fr];
612
+
613
+ this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
614
+
615
+ // XXX remove this slice. Just pass the start index.
616
+ if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
617
+ this.debug('globstar found match!', fr, fl, swallowee);
618
+ // found a match.
619
+ return true
620
+ } else {
621
+ // can't swallow "." or ".." ever.
622
+ // can only swallow ".foo" when explicitly asked.
623
+ if (swallowee === '.' || swallowee === '..' ||
624
+ (!options.dot && swallowee.charAt(0) === '.')) {
625
+ this.debug('dot detected!', file, fr, pattern, pr);
626
+ break
627
+ }
628
+
629
+ // ** swallows a segment, and continue.
630
+ this.debug('globstar swallow a segment, and continue');
631
+ fr++;
632
+ }
633
+ }
634
+
635
+ // no match was found.
636
+ // However, in partial mode, we can't say this is necessarily over.
637
+ // If there's more *pattern* left, then
638
+ /* istanbul ignore if */
639
+ if (partial) {
640
+ // ran out of file
641
+ this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
642
+ if (fr === fl) return true
643
+ }
644
+ return false
645
+ }
646
+
647
+ // something other than **
648
+ // non-magic patterns just have to match exactly
649
+ // patterns with magic have been turned into regexps.
650
+ var hit;
651
+ if (typeof p === 'string') {
652
+ hit = f === p;
653
+ this.debug('string match', p, f, hit);
654
+ } else {
655
+ hit = f.match(p);
656
+ this.debug('pattern match', p, f, hit);
657
+ }
658
+
659
+ if (!hit) return false
660
+ }
661
+
662
+ // Note: ending in / means that we'll get a final ""
663
+ // at the end of the pattern. This can only match a
664
+ // corresponding "" at the end of the file.
665
+ // If the file ends in /, then it can only match a
666
+ // a pattern that ends in /, unless the pattern just
667
+ // doesn't have any more for it. But, a/b/ should *not*
668
+ // match "a/b/*", even though "" matches against the
669
+ // [^/]*? pattern, except in partial mode, where it might
670
+ // simply not be reached yet.
671
+ // However, a/b/ should still satisfy a/*
672
+
673
+ // now either we fell off the end of the pattern, or we're done.
674
+ if (fi === fl && pi === pl) {
675
+ // ran out of pattern and filename at the same time.
676
+ // an exact hit!
677
+ return true
678
+ } else if (fi === fl) {
679
+ // ran out of file, but still had pattern left.
680
+ // this is ok if we're doing the match as part of
681
+ // a glob fs traversal.
682
+ return partial
683
+ } else /* istanbul ignore else */ if (pi === pl) {
684
+ // ran out of pattern, still have file left.
685
+ // this is only acceptable if we're on the very last
686
+ // empty segment of a file with a trailing slash.
687
+ // a/* should match a/b/
688
+ return (fi === fl - 1) && (file[fi] === '')
689
+ }
690
+
691
+ // should be unreachable.
692
+ /* istanbul ignore next */
693
+ throw new Error('wtf?')
694
+ }
695
+
696
+ braceExpand () {
697
+ return braceExpand(this.pattern, this.options)
698
+ }
699
+
700
+ parse (pattern, isSub) {
701
+ assertValidPattern(pattern);
702
+
703
+ const options = this.options;
704
+
705
+ // shortcuts
706
+ if (pattern === '**') {
707
+ if (!options.noglobstar)
708
+ return GLOBSTAR
709
+ else
710
+ pattern = '*';
711
+ }
712
+ if (pattern === '') return ''
713
+
714
+ let re = '';
715
+ let hasMagic = !!options.nocase;
716
+ let escaping = false;
717
+ // ? => one single character
718
+ const patternListStack = [];
719
+ const negativeLists = [];
720
+ let stateChar;
721
+ let inClass = false;
722
+ let reClassStart = -1;
723
+ let classStart = -1;
724
+ let cs;
725
+ let pl;
726
+ let sp;
727
+ // . and .. never match anything that doesn't start with .,
728
+ // even when options.dot is set.
729
+ const patternStart = pattern.charAt(0) === '.' ? '' // anything
730
+ // not (start or / followed by . or .. followed by / or end)
731
+ : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
732
+ : '(?!\\.)';
733
+
734
+ const clearStateChar = () => {
735
+ if (stateChar) {
736
+ // we had some state-tracking character
737
+ // that wasn't consumed by this pass.
738
+ switch (stateChar) {
739
+ case '*':
740
+ re += star;
741
+ hasMagic = true;
742
+ break
743
+ case '?':
744
+ re += qmark;
745
+ hasMagic = true;
746
+ break
747
+ default:
748
+ re += '\\' + stateChar;
749
+ break
750
+ }
751
+ this.debug('clearStateChar %j %j', stateChar, re);
752
+ stateChar = false;
753
+ }
754
+ };
755
+
756
+ for (let i = 0, c; (i < pattern.length) && (c = pattern.charAt(i)); i++) {
757
+ this.debug('%s\t%s %s %j', pattern, i, re, c);
758
+
759
+ // skip over any that are escaped.
760
+ if (escaping) {
761
+ /* istanbul ignore next - completely not allowed, even escaped. */
762
+ if (c === '/') {
763
+ return false
764
+ }
765
+
766
+ if (reSpecials[c]) {
767
+ re += '\\';
768
+ }
769
+ re += c;
770
+ escaping = false;
771
+ continue
772
+ }
773
+
774
+ switch (c) {
775
+ /* istanbul ignore next */
776
+ case '/': {
777
+ // Should already be path-split by now.
778
+ return false
779
+ }
780
+
781
+ case '\\':
782
+ clearStateChar();
783
+ escaping = true;
784
+ continue
785
+
786
+ // the various stateChar values
787
+ // for the "extglob" stuff.
788
+ case '?':
789
+ case '*':
790
+ case '+':
791
+ case '@':
792
+ case '!':
793
+ this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
794
+
795
+ // all of those are literals inside a class, except that
796
+ // the glob [!a] means [^a] in regexp
797
+ if (inClass) {
798
+ this.debug(' in class');
799
+ if (c === '!' && i === classStart + 1) c = '^';
800
+ re += c;
801
+ continue
802
+ }
803
+
804
+ // if we already have a stateChar, then it means
805
+ // that there was something like ** or +? in there.
806
+ // Handle the stateChar, then proceed with this one.
807
+ this.debug('call clearStateChar %j', stateChar);
808
+ clearStateChar();
809
+ stateChar = c;
810
+ // if extglob is disabled, then +(asdf|foo) isn't a thing.
811
+ // just clear the statechar *now*, rather than even diving into
812
+ // the patternList stuff.
813
+ if (options.noext) clearStateChar();
814
+ continue
815
+
816
+ case '(':
817
+ if (inClass) {
818
+ re += '(';
819
+ continue
820
+ }
821
+
822
+ if (!stateChar) {
823
+ re += '\\(';
824
+ continue
825
+ }
826
+
827
+ patternListStack.push({
828
+ type: stateChar,
829
+ start: i - 1,
830
+ reStart: re.length,
831
+ open: plTypes[stateChar].open,
832
+ close: plTypes[stateChar].close
833
+ });
834
+ // negation is (?:(?!js)[^/]*)
835
+ re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
836
+ this.debug('plType %j %j', stateChar, re);
837
+ stateChar = false;
838
+ continue
839
+
840
+ case ')':
841
+ if (inClass || !patternListStack.length) {
842
+ re += '\\)';
843
+ continue
844
+ }
845
+
846
+ clearStateChar();
847
+ hasMagic = true;
848
+ pl = patternListStack.pop();
849
+ // negation is (?:(?!js)[^/]*)
850
+ // The others are (?:<pattern>)<type>
851
+ re += pl.close;
852
+ if (pl.type === '!') {
853
+ negativeLists.push(pl);
854
+ }
855
+ pl.reEnd = re.length;
856
+ continue
857
+
858
+ case '|':
859
+ if (inClass || !patternListStack.length) {
860
+ re += '\\|';
861
+ continue
862
+ }
863
+
864
+ clearStateChar();
865
+ re += '|';
866
+ continue
867
+
868
+ // these are mostly the same in regexp and glob
869
+ case '[':
870
+ // swallow any state-tracking char before the [
871
+ clearStateChar();
872
+
873
+ if (inClass) {
874
+ re += '\\' + c;
875
+ continue
876
+ }
877
+
878
+ inClass = true;
879
+ classStart = i;
880
+ reClassStart = re.length;
881
+ re += c;
882
+ continue
883
+
884
+ case ']':
885
+ // a right bracket shall lose its special
886
+ // meaning and represent itself in
887
+ // a bracket expression if it occurs
888
+ // first in the list. -- POSIX.2 2.8.3.2
889
+ if (i === classStart + 1 || !inClass) {
890
+ re += '\\' + c;
891
+ continue
892
+ }
893
+
894
+ // handle the case where we left a class open.
895
+ // "[z-a]" is valid, equivalent to "\[z-a\]"
896
+ // split where the last [ was, make sure we don't have
897
+ // an invalid re. if so, re-walk the contents of the
898
+ // would-be class to re-translate any characters that
899
+ // were passed through as-is
900
+ // TODO: It would probably be faster to determine this
901
+ // without a try/catch and a new RegExp, but it's tricky
902
+ // to do safely. For now, this is safe and works.
903
+ cs = pattern.substring(classStart + 1, i);
904
+ try {
905
+ RegExp('[' + cs + ']');
906
+ } catch (er) {
907
+ // not a valid class!
908
+ sp = this.parse(cs, SUBPARSE);
909
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
910
+ hasMagic = hasMagic || sp[1];
911
+ inClass = false;
912
+ continue
913
+ }
914
+
915
+ // finish up the class.
916
+ hasMagic = true;
917
+ inClass = false;
918
+ re += c;
919
+ continue
920
+
921
+ default:
922
+ // swallow any state char that wasn't consumed
923
+ clearStateChar();
924
+
925
+ if (reSpecials[c] && !(c === '^' && inClass)) {
926
+ re += '\\';
927
+ }
928
+
929
+ re += c;
930
+ break
931
+
932
+ } // switch
933
+ } // for
934
+
935
+ // handle the case where we left a class open.
936
+ // "[abc" is valid, equivalent to "\[abc"
937
+ if (inClass) {
938
+ // split where the last [ was, and escape it
939
+ // this is a huge pita. We now have to re-walk
940
+ // the contents of the would-be class to re-translate
941
+ // any characters that were passed through as-is
942
+ cs = pattern.substr(classStart + 1);
943
+ sp = this.parse(cs, SUBPARSE);
944
+ re = re.substr(0, reClassStart) + '\\[' + sp[0];
945
+ hasMagic = hasMagic || sp[1];
946
+ }
947
+
948
+ // handle the case where we had a +( thing at the *end*
949
+ // of the pattern.
950
+ // each pattern list stack adds 3 chars, and we need to go through
951
+ // and escape any | chars that were passed through as-is for the regexp.
952
+ // Go through and escape them, taking care not to double-escape any
953
+ // | chars that were already escaped.
954
+ for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
955
+ let tail;
956
+ tail = re.slice(pl.reStart + pl.open.length);
957
+ this.debug('setting tail', re, pl);
958
+ // maybe some even number of \, then maybe 1 \, followed by a |
959
+ tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => {
960
+ /* istanbul ignore else - should already be done */
961
+ if (!$2) {
962
+ // the | isn't already escaped, so escape it.
963
+ $2 = '\\';
964
+ }
965
+
966
+ // need to escape all those slashes *again*, without escaping the
967
+ // one that we need for escaping the | character. As it works out,
968
+ // escaping an even number of slashes can be done by simply repeating
969
+ // it exactly after itself. That's why this trick works.
970
+ //
971
+ // I am sorry that you have to see this.
972
+ return $1 + $1 + $2 + '|'
973
+ });
974
+
975
+ this.debug('tail=%j\n %s', tail, tail, pl, re);
976
+ const t = pl.type === '*' ? star
977
+ : pl.type === '?' ? qmark
978
+ : '\\' + pl.type;
979
+
980
+ hasMagic = true;
981
+ re = re.slice(0, pl.reStart) + t + '\\(' + tail;
982
+ }
983
+
984
+ // handle trailing things that only matter at the very end.
985
+ clearStateChar();
986
+ if (escaping) {
987
+ // trailing \\
988
+ re += '\\\\';
989
+ }
990
+
991
+ // only need to apply the nodot start if the re starts with
992
+ // something that could conceivably capture a dot
993
+ const addPatternStart = addPatternStartSet[re.charAt(0)];
994
+
995
+ // Hack to work around lack of negative lookbehind in JS
996
+ // A pattern like: *.!(x).!(y|z) needs to ensure that a name
997
+ // like 'a.xyz.yz' doesn't match. So, the first negative
998
+ // lookahead, has to look ALL the way ahead, to the end of
999
+ // the pattern.
1000
+ for (let n = negativeLists.length - 1; n > -1; n--) {
1001
+ const nl = negativeLists[n];
1002
+
1003
+ const nlBefore = re.slice(0, nl.reStart);
1004
+ const nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
1005
+ let nlAfter = re.slice(nl.reEnd);
1006
+ const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter;
1007
+
1008
+ // Handle nested stuff like *(*.js|!(*.json)), where open parens
1009
+ // mean that we should *not* include the ) in the bit that is considered
1010
+ // "after" the negated section.
1011
+ const openParensBefore = nlBefore.split('(').length - 1;
1012
+ let cleanAfter = nlAfter;
1013
+ for (let i = 0; i < openParensBefore; i++) {
1014
+ cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
1015
+ }
1016
+ nlAfter = cleanAfter;
1017
+
1018
+ const dollar = nlAfter === '' && isSub !== SUBPARSE ? '$' : '';
1019
+ re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
1020
+ }
1021
+
1022
+ // if the re is not "" at this point, then we need to make sure
1023
+ // it doesn't match against an empty path part.
1024
+ // Otherwise a/* will match a/, which it should not.
1025
+ if (re !== '' && hasMagic) {
1026
+ re = '(?=.)' + re;
1027
+ }
1028
+
1029
+ if (addPatternStart) {
1030
+ re = patternStart + re;
1031
+ }
1032
+
1033
+ // parsing just a piece of a larger pattern.
1034
+ if (isSub === SUBPARSE) {
1035
+ return [re, hasMagic]
1036
+ }
1037
+
1038
+ // skip the regexp for non-magical patterns
1039
+ // unescape anything in it, though, so that it'll be
1040
+ // an exact match against a file etc.
1041
+ if (!hasMagic) {
1042
+ return globUnescape(pattern)
1043
+ }
1044
+
1045
+ const flags = options.nocase ? 'i' : '';
1046
+ try {
1047
+ return Object.assign(new RegExp('^' + re + '$', flags), {
1048
+ _glob: pattern,
1049
+ _src: re,
1050
+ })
1051
+ } catch (er) /* istanbul ignore next - should be impossible */ {
1052
+ // If it was an invalid regular expression, then it can't match
1053
+ // anything. This trick looks for a character after the end of
1054
+ // the string, which is of course impossible, except in multi-line
1055
+ // mode, but it's not a /m regex.
1056
+ return new RegExp('$.')
1057
+ }
1058
+ }
1059
+
1060
+ makeRe () {
1061
+ if (this.regexp || this.regexp === false) return this.regexp
1062
+
1063
+ // at this point, this.set is a 2d array of partial
1064
+ // pattern strings, or "**".
1065
+ //
1066
+ // It's better to use .match(). This function shouldn't
1067
+ // be used, really, but it's pretty convenient sometimes,
1068
+ // when you just want to work with a regex.
1069
+ const set = this.set;
1070
+
1071
+ if (!set.length) {
1072
+ this.regexp = false;
1073
+ return this.regexp
1074
+ }
1075
+ const options = this.options;
1076
+
1077
+ const twoStar = options.noglobstar ? star
1078
+ : options.dot ? twoStarDot
1079
+ : twoStarNoDot;
1080
+ const flags = options.nocase ? 'i' : '';
1081
+
1082
+ // coalesce globstars and regexpify non-globstar patterns
1083
+ // if it's the only item, then we just do one twoStar
1084
+ // if it's the first, and there are more, prepend (\/|twoStar\/)? to next
1085
+ // if it's the last, append (\/twoStar|) to previous
1086
+ // if it's in the middle, append (\/|\/twoStar\/) to previous
1087
+ // then filter out GLOBSTAR symbols
1088
+ let re = set.map(pattern => {
1089
+ pattern = pattern.map(p =>
1090
+ typeof p === 'string' ? regExpEscape(p)
1091
+ : p === GLOBSTAR ? GLOBSTAR
1092
+ : p._src
1093
+ ).reduce((set, p) => {
1094
+ if (!(set[set.length - 1] === GLOBSTAR && p === GLOBSTAR)) {
1095
+ set.push(p);
1096
+ }
1097
+ return set
1098
+ }, []);
1099
+ pattern.forEach((p, i) => {
1100
+ if (p !== GLOBSTAR || pattern[i-1] === GLOBSTAR) {
1101
+ return
1102
+ }
1103
+ if (i === 0) {
1104
+ if (pattern.length > 1) {
1105
+ pattern[i+1] = '(?:\\\/|' + twoStar + '\\\/)?' + pattern[i+1];
1106
+ } else {
1107
+ pattern[i] = twoStar;
1108
+ }
1109
+ } else if (i === pattern.length - 1) {
1110
+ pattern[i-1] += '(?:\\\/|' + twoStar + ')?';
1111
+ } else {
1112
+ pattern[i-1] += '(?:\\\/|\\\/' + twoStar + '\\\/)' + pattern[i+1];
1113
+ pattern[i+1] = GLOBSTAR;
1114
+ }
1115
+ });
1116
+ return pattern.filter(p => p !== GLOBSTAR).join('/')
1117
+ }).join('|');
1118
+
1119
+ // must match entire pattern
1120
+ // ending in a * or ** will make it less strict.
1121
+ re = '^(?:' + re + ')$';
1122
+
1123
+ // can match anything, as long as it's not this.
1124
+ if (this.negate) re = '^(?!' + re + ').*$';
1125
+
1126
+ try {
1127
+ this.regexp = new RegExp(re, flags);
1128
+ } catch (ex) /* istanbul ignore next - should be impossible */ {
1129
+ this.regexp = false;
1130
+ }
1131
+ return this.regexp
1132
+ }
1133
+
1134
+ match (f, partial = this.partial) {
1135
+ this.debug('match', f, this.pattern);
1136
+ // short-circuit in the case of busted things.
1137
+ // comments, etc.
1138
+ if (this.comment) return false
1139
+ if (this.empty) return f === ''
1140
+
1141
+ if (f === '/' && partial) return true
1142
+
1143
+ const options = this.options;
1144
+
1145
+ // windows: need to use /, not \
1146
+ if (path.sep !== '/') {
1147
+ f = f.split(path.sep).join('/');
1148
+ }
1149
+
1150
+ // treat the test path as a set of pathparts.
1151
+ f = f.split(slashSplit);
1152
+ this.debug(this.pattern, 'split', f);
1153
+
1154
+ // just ONE of the pattern sets in this.set needs to match
1155
+ // in order for it to be valid. If negating, then just one
1156
+ // match means that we have failed.
1157
+ // Either way, return on the first hit.
1158
+
1159
+ const set = this.set;
1160
+ this.debug(this.pattern, 'set', set);
1161
+
1162
+ // Find the basename of the path by looking for the last non-empty segment
1163
+ let filename;
1164
+ for (let i = f.length - 1; i >= 0; i--) {
1165
+ filename = f[i];
1166
+ if (filename) break
1167
+ }
1168
+
1169
+ for (let i = 0; i < set.length; i++) {
1170
+ const pattern = set[i];
1171
+ let file = f;
1172
+ if (options.matchBase && pattern.length === 1) {
1173
+ file = [filename];
1174
+ }
1175
+ const hit = this.matchOne(file, pattern, partial);
1176
+ if (hit) {
1177
+ if (options.flipNegate) return true
1178
+ return !this.negate
1179
+ }
1180
+ }
1181
+
1182
+ // didn't get any hits. this is success if it's a negative
1183
+ // pattern, failure otherwise.
1184
+ if (options.flipNegate) return false
1185
+ return this.negate
1186
+ }
1187
+
1188
+ static defaults (def) {
1189
+ return minimatch.defaults(def).Minimatch
1190
+ }
1191
+ }
1192
+
1193
+ minimatch.Minimatch = Minimatch;
1194
+
1195
+ var minimatch_1$1 = minimatch_1;
1196
+
1197
+ var minimatch$1 = /*#__PURE__*/_mergeNamespaces({
1198
+ __proto__: null,
1199
+ 'default': minimatch_1$1
1200
+ }, [minimatch_1]);
1201
+
1202
+ exports.minimatch = minimatch$1;