jiek 1.0.0 → 1.0.1

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