@quilted/create 0.1.13 → 0.1.16

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