heading-case 1.1.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -8
- package/bin.js +2 -2
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +2659 -0
- package/dist/core.d.ts +6 -0
- package/dist/core.js +123 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +49 -2821
- package/dist/rslib-runtime.js +42 -0
- package/package.json +21 -15
package/dist/cli.js
ADDED
|
@@ -0,0 +1,2659 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_util from "node:util";
|
|
4
|
+
import * as __rspack_external_fs from "fs";
|
|
5
|
+
import { readdir, readdirSync, realpath, realpathSync, stat as external_fs_stat, statSync } from "fs";
|
|
6
|
+
import { basename, dirname, isAbsolute, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
import { createRequire } from "module";
|
|
9
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
10
|
+
import { formatLine } from "./core.js";
|
|
11
|
+
__webpack_require__.add({
|
|
12
|
+
"./node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) {
|
|
13
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
14
|
+
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
|
|
15
|
+
let formatter = (open, close, replace = open)=>(input)=>{
|
|
16
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
17
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
18
|
+
};
|
|
19
|
+
let replaceClose = (string, close, replace, index)=>{
|
|
20
|
+
let result = "", cursor = 0;
|
|
21
|
+
do {
|
|
22
|
+
result += string.substring(cursor, index) + replace;
|
|
23
|
+
cursor = index + close.length;
|
|
24
|
+
index = string.indexOf(close, cursor);
|
|
25
|
+
}while (~index);
|
|
26
|
+
return result + string.substring(cursor);
|
|
27
|
+
};
|
|
28
|
+
let createColors = (enabled = isColorSupported)=>{
|
|
29
|
+
let f = enabled ? formatter : ()=>String;
|
|
30
|
+
return {
|
|
31
|
+
isColorSupported: enabled,
|
|
32
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
33
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
34
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
35
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
36
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
37
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
38
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
39
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
40
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
41
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
42
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
43
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
44
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
45
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
46
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
47
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
48
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
49
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
50
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
51
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
52
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
53
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
54
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
55
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
56
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
57
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
58
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
59
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
60
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
61
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
62
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
63
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
64
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
65
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
66
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
67
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
68
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
69
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
70
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
71
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
72
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m")
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
module.exports = createColors();
|
|
76
|
+
module.exports.createColors = createColors;
|
|
77
|
+
},
|
|
78
|
+
"./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
79
|
+
const pico = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js");
|
|
80
|
+
const utils = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
81
|
+
function picomatch(glob, options, returnState = false) {
|
|
82
|
+
if (options && (null === options.windows || void 0 === options.windows)) options = {
|
|
83
|
+
...options,
|
|
84
|
+
windows: utils.isWindows()
|
|
85
|
+
};
|
|
86
|
+
return pico(glob, options, returnState);
|
|
87
|
+
}
|
|
88
|
+
Object.assign(picomatch, pico);
|
|
89
|
+
module.exports = picomatch;
|
|
90
|
+
},
|
|
91
|
+
"./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js" (module) {
|
|
92
|
+
const WIN_SLASH = '\\\\/';
|
|
93
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
94
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
95
|
+
const DOT_LITERAL = '\\.';
|
|
96
|
+
const PLUS_LITERAL = '\\+';
|
|
97
|
+
const QMARK_LITERAL = '\\?';
|
|
98
|
+
const SLASH_LITERAL = '\\/';
|
|
99
|
+
const ONE_CHAR = '(?=.)';
|
|
100
|
+
const QMARK = '[^/]';
|
|
101
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
102
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
103
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
104
|
+
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
105
|
+
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
106
|
+
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
107
|
+
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
108
|
+
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
109
|
+
const STAR = `${QMARK}*?`;
|
|
110
|
+
const SEP = '/';
|
|
111
|
+
const POSIX_CHARS = {
|
|
112
|
+
DOT_LITERAL,
|
|
113
|
+
PLUS_LITERAL,
|
|
114
|
+
QMARK_LITERAL,
|
|
115
|
+
SLASH_LITERAL,
|
|
116
|
+
ONE_CHAR,
|
|
117
|
+
QMARK,
|
|
118
|
+
END_ANCHOR,
|
|
119
|
+
DOTS_SLASH,
|
|
120
|
+
NO_DOT,
|
|
121
|
+
NO_DOTS,
|
|
122
|
+
NO_DOT_SLASH,
|
|
123
|
+
NO_DOTS_SLASH,
|
|
124
|
+
QMARK_NO_DOT,
|
|
125
|
+
STAR,
|
|
126
|
+
START_ANCHOR,
|
|
127
|
+
SEP
|
|
128
|
+
};
|
|
129
|
+
const WINDOWS_CHARS = {
|
|
130
|
+
...POSIX_CHARS,
|
|
131
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
132
|
+
QMARK: WIN_NO_SLASH,
|
|
133
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
134
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
135
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
136
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
137
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
138
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
139
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
140
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
141
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
142
|
+
SEP: '\\'
|
|
143
|
+
};
|
|
144
|
+
const POSIX_REGEX_SOURCE = {
|
|
145
|
+
__proto__: null,
|
|
146
|
+
alnum: 'a-zA-Z0-9',
|
|
147
|
+
alpha: 'a-zA-Z',
|
|
148
|
+
ascii: '\\x00-\\x7F',
|
|
149
|
+
blank: ' \\t',
|
|
150
|
+
cntrl: '\\x00-\\x1F\\x7F',
|
|
151
|
+
digit: '0-9',
|
|
152
|
+
graph: '\\x21-\\x7E',
|
|
153
|
+
lower: 'a-z',
|
|
154
|
+
print: '\\x20-\\x7E ',
|
|
155
|
+
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
156
|
+
space: ' \\t\\r\\n\\v\\f',
|
|
157
|
+
upper: 'A-Z',
|
|
158
|
+
word: 'A-Za-z0-9_',
|
|
159
|
+
xdigit: 'A-Fa-f0-9'
|
|
160
|
+
};
|
|
161
|
+
module.exports = {
|
|
162
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
163
|
+
MAX_LENGTH: 65536,
|
|
164
|
+
POSIX_REGEX_SOURCE,
|
|
165
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
166
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
167
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
168
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
169
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
170
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
171
|
+
REPLACEMENTS: {
|
|
172
|
+
__proto__: null,
|
|
173
|
+
'***': '*',
|
|
174
|
+
'**/**': '**',
|
|
175
|
+
'**/**/**': '**'
|
|
176
|
+
},
|
|
177
|
+
CHAR_0: 48,
|
|
178
|
+
CHAR_9: 57,
|
|
179
|
+
CHAR_UPPERCASE_A: 65,
|
|
180
|
+
CHAR_LOWERCASE_A: 97,
|
|
181
|
+
CHAR_UPPERCASE_Z: 90,
|
|
182
|
+
CHAR_LOWERCASE_Z: 122,
|
|
183
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
184
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
185
|
+
CHAR_ASTERISK: 42,
|
|
186
|
+
CHAR_AMPERSAND: 38,
|
|
187
|
+
CHAR_AT: 64,
|
|
188
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
189
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
190
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
191
|
+
CHAR_COLON: 58,
|
|
192
|
+
CHAR_COMMA: 44,
|
|
193
|
+
CHAR_DOT: 46,
|
|
194
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
195
|
+
CHAR_EQUAL: 61,
|
|
196
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
197
|
+
CHAR_FORM_FEED: 12,
|
|
198
|
+
CHAR_FORWARD_SLASH: 47,
|
|
199
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
200
|
+
CHAR_HASH: 35,
|
|
201
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
202
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
203
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
204
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
205
|
+
CHAR_LINE_FEED: 10,
|
|
206
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
207
|
+
CHAR_PERCENT: 37,
|
|
208
|
+
CHAR_PLUS: 43,
|
|
209
|
+
CHAR_QUESTION_MARK: 63,
|
|
210
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
211
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
212
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
213
|
+
CHAR_SEMICOLON: 59,
|
|
214
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
215
|
+
CHAR_SPACE: 32,
|
|
216
|
+
CHAR_TAB: 9,
|
|
217
|
+
CHAR_UNDERSCORE: 95,
|
|
218
|
+
CHAR_VERTICAL_LINE: 124,
|
|
219
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
220
|
+
extglobChars (chars) {
|
|
221
|
+
return {
|
|
222
|
+
'!': {
|
|
223
|
+
type: 'negate',
|
|
224
|
+
open: '(?:(?!(?:',
|
|
225
|
+
close: `))${chars.STAR})`
|
|
226
|
+
},
|
|
227
|
+
'?': {
|
|
228
|
+
type: 'qmark',
|
|
229
|
+
open: '(?:',
|
|
230
|
+
close: ')?'
|
|
231
|
+
},
|
|
232
|
+
'+': {
|
|
233
|
+
type: 'plus',
|
|
234
|
+
open: '(?:',
|
|
235
|
+
close: ')+'
|
|
236
|
+
},
|
|
237
|
+
'*': {
|
|
238
|
+
type: 'star',
|
|
239
|
+
open: '(?:',
|
|
240
|
+
close: ')*'
|
|
241
|
+
},
|
|
242
|
+
'@': {
|
|
243
|
+
type: 'at',
|
|
244
|
+
open: '(?:',
|
|
245
|
+
close: ')'
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
},
|
|
249
|
+
globChars (win32) {
|
|
250
|
+
return true === win32 ? WINDOWS_CHARS : POSIX_CHARS;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
},
|
|
254
|
+
"./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
255
|
+
const constants = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
256
|
+
const utils = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
257
|
+
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
258
|
+
const expandRange = (args, options)=>{
|
|
259
|
+
if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
|
|
260
|
+
args.sort();
|
|
261
|
+
const value = `[${args.join('-')}]`;
|
|
262
|
+
try {
|
|
263
|
+
new RegExp(value);
|
|
264
|
+
} catch (ex) {
|
|
265
|
+
return args.map((v)=>utils.escapeRegex(v)).join('..');
|
|
266
|
+
}
|
|
267
|
+
return value;
|
|
268
|
+
};
|
|
269
|
+
const syntaxError = (type, char)=>`Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
270
|
+
const splitTopLevel = (input)=>{
|
|
271
|
+
const parts = [];
|
|
272
|
+
let bracket = 0;
|
|
273
|
+
let paren = 0;
|
|
274
|
+
let quote = 0;
|
|
275
|
+
let value = '';
|
|
276
|
+
let escaped = false;
|
|
277
|
+
for (const ch of input){
|
|
278
|
+
if (true === escaped) {
|
|
279
|
+
value += ch;
|
|
280
|
+
escaped = false;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if ('\\' === ch) {
|
|
284
|
+
value += ch;
|
|
285
|
+
escaped = true;
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if ('"' === ch) {
|
|
289
|
+
quote = 1 === quote ? 0 : 1;
|
|
290
|
+
value += ch;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (0 === quote) {
|
|
294
|
+
if ('[' === ch) bracket++;
|
|
295
|
+
else if (']' === ch && bracket > 0) bracket--;
|
|
296
|
+
else if (0 === bracket) {
|
|
297
|
+
if ('(' === ch) paren++;
|
|
298
|
+
else if (')' === ch && paren > 0) paren--;
|
|
299
|
+
else if ('|' === ch && 0 === paren) {
|
|
300
|
+
parts.push(value);
|
|
301
|
+
value = '';
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
value += ch;
|
|
307
|
+
}
|
|
308
|
+
parts.push(value);
|
|
309
|
+
return parts;
|
|
310
|
+
};
|
|
311
|
+
const isPlainBranch = (branch)=>{
|
|
312
|
+
let escaped = false;
|
|
313
|
+
for (const ch of branch){
|
|
314
|
+
if (true === escaped) {
|
|
315
|
+
escaped = false;
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
if ('\\' === ch) {
|
|
319
|
+
escaped = true;
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (/[?*+@!()[\]{}]/.test(ch)) return false;
|
|
323
|
+
}
|
|
324
|
+
return true;
|
|
325
|
+
};
|
|
326
|
+
const normalizeSimpleBranch = (branch)=>{
|
|
327
|
+
let value = branch.trim();
|
|
328
|
+
let changed = true;
|
|
329
|
+
while(true === changed){
|
|
330
|
+
changed = false;
|
|
331
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
332
|
+
value = value.slice(2, -1);
|
|
333
|
+
changed = true;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (!isPlainBranch(value)) return;
|
|
337
|
+
return value.replace(/\\(.)/g, '$1');
|
|
338
|
+
};
|
|
339
|
+
const hasRepeatedCharPrefixOverlap = (branches)=>{
|
|
340
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
341
|
+
for(let i = 0; i < values.length; i++)for(let j = i + 1; j < values.length; j++){
|
|
342
|
+
const a = values[i];
|
|
343
|
+
const b = values[j];
|
|
344
|
+
const char = a[0];
|
|
345
|
+
if (char && a === char.repeat(a.length) && b === char.repeat(b.length)) {
|
|
346
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) return true;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return false;
|
|
350
|
+
};
|
|
351
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true)=>{
|
|
352
|
+
if ('+' !== pattern[0] && '*' !== pattern[0] || '(' !== pattern[1]) return;
|
|
353
|
+
let bracket = 0;
|
|
354
|
+
let paren = 0;
|
|
355
|
+
let quote = 0;
|
|
356
|
+
let escaped = false;
|
|
357
|
+
for(let i = 1; i < pattern.length; i++){
|
|
358
|
+
const ch = pattern[i];
|
|
359
|
+
if (true === escaped) {
|
|
360
|
+
escaped = false;
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
if ('\\' === ch) {
|
|
364
|
+
escaped = true;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if ('"' === ch) {
|
|
368
|
+
quote = 1 === quote ? 0 : 1;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (1 !== quote) {
|
|
372
|
+
if ('[' === ch) {
|
|
373
|
+
bracket++;
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (']' === ch && bracket > 0) {
|
|
377
|
+
bracket--;
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (!(bracket > 0)) {
|
|
381
|
+
if ('(' === ch) {
|
|
382
|
+
paren++;
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (')' === ch) {
|
|
386
|
+
paren--;
|
|
387
|
+
if (0 === paren) {
|
|
388
|
+
if (true === requireEnd && i !== pattern.length - 1) return;
|
|
389
|
+
return {
|
|
390
|
+
type: pattern[0],
|
|
391
|
+
body: pattern.slice(2, i),
|
|
392
|
+
end: i
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
const getStarExtglobSequenceOutput = (pattern)=>{
|
|
401
|
+
let index = 0;
|
|
402
|
+
const chars = [];
|
|
403
|
+
while(index < pattern.length){
|
|
404
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
405
|
+
if (!match || '*' !== match.type) return;
|
|
406
|
+
const branches = splitTopLevel(match.body).map((branch)=>branch.trim());
|
|
407
|
+
if (1 !== branches.length) return;
|
|
408
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
409
|
+
if (!branch || 1 !== branch.length) return;
|
|
410
|
+
chars.push(branch);
|
|
411
|
+
index += match.end + 1;
|
|
412
|
+
}
|
|
413
|
+
if (chars.length < 1) return;
|
|
414
|
+
const source = 1 === chars.length ? utils.escapeRegex(chars[0]) : `[${chars.map((ch)=>utils.escapeRegex(ch)).join('')}]`;
|
|
415
|
+
return `${source}*`;
|
|
416
|
+
};
|
|
417
|
+
const repeatedExtglobRecursion = (pattern)=>{
|
|
418
|
+
let depth = 0;
|
|
419
|
+
let value = pattern.trim();
|
|
420
|
+
let match = parseRepeatedExtglob(value);
|
|
421
|
+
while(match){
|
|
422
|
+
depth++;
|
|
423
|
+
value = match.body.trim();
|
|
424
|
+
match = parseRepeatedExtglob(value);
|
|
425
|
+
}
|
|
426
|
+
return depth;
|
|
427
|
+
};
|
|
428
|
+
const analyzeRepeatedExtglob = (body, options)=>{
|
|
429
|
+
if (false === options.maxExtglobRecursion) return {
|
|
430
|
+
risky: false
|
|
431
|
+
};
|
|
432
|
+
const max = 'number' == typeof options.maxExtglobRecursion ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
433
|
+
const branches = splitTopLevel(body).map((branch)=>branch.trim());
|
|
434
|
+
if (branches.length > 1) {
|
|
435
|
+
if (branches.some((branch)=>'' === branch) || branches.some((branch)=>/^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return {
|
|
436
|
+
risky: true
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
for (const branch of branches){
|
|
440
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
441
|
+
if (safeOutput) return {
|
|
442
|
+
risky: true,
|
|
443
|
+
safeOutput
|
|
444
|
+
};
|
|
445
|
+
if (repeatedExtglobRecursion(branch) > max) return {
|
|
446
|
+
risky: true
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
return {
|
|
450
|
+
risky: false
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
const parse = (input, options)=>{
|
|
454
|
+
if ('string' != typeof input) throw new TypeError('Expected a string');
|
|
455
|
+
input = REPLACEMENTS[input] || input;
|
|
456
|
+
const opts = {
|
|
457
|
+
...options
|
|
458
|
+
};
|
|
459
|
+
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
460
|
+
let len = input.length;
|
|
461
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
462
|
+
const bos = {
|
|
463
|
+
type: 'bos',
|
|
464
|
+
value: '',
|
|
465
|
+
output: opts.prepend || ''
|
|
466
|
+
};
|
|
467
|
+
const tokens = [
|
|
468
|
+
bos
|
|
469
|
+
];
|
|
470
|
+
const capture = opts.capture ? '' : '?:';
|
|
471
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
472
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
473
|
+
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
|
|
474
|
+
const globstar = (opts)=>`(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
475
|
+
const nodot = opts.dot ? '' : NO_DOT;
|
|
476
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
477
|
+
let star = true === opts.bash ? globstar(opts) : STAR;
|
|
478
|
+
if (opts.capture) star = `(${star})`;
|
|
479
|
+
if ('boolean' == typeof opts.noext) opts.noextglob = opts.noext;
|
|
480
|
+
const state = {
|
|
481
|
+
input,
|
|
482
|
+
index: -1,
|
|
483
|
+
start: 0,
|
|
484
|
+
dot: true === opts.dot,
|
|
485
|
+
consumed: '',
|
|
486
|
+
output: '',
|
|
487
|
+
prefix: '',
|
|
488
|
+
backtrack: false,
|
|
489
|
+
negated: false,
|
|
490
|
+
brackets: 0,
|
|
491
|
+
braces: 0,
|
|
492
|
+
parens: 0,
|
|
493
|
+
quotes: 0,
|
|
494
|
+
globstar: false,
|
|
495
|
+
tokens
|
|
496
|
+
};
|
|
497
|
+
input = utils.removePrefix(input, state);
|
|
498
|
+
len = input.length;
|
|
499
|
+
const extglobs = [];
|
|
500
|
+
const braces = [];
|
|
501
|
+
const stack = [];
|
|
502
|
+
let prev = bos;
|
|
503
|
+
let value;
|
|
504
|
+
const eos = ()=>state.index === len - 1;
|
|
505
|
+
const peek = state.peek = (n = 1)=>input[state.index + n];
|
|
506
|
+
const advance = state.advance = ()=>input[++state.index] || '';
|
|
507
|
+
const remaining = ()=>input.slice(state.index + 1);
|
|
508
|
+
const consume = (value = '', num = 0)=>{
|
|
509
|
+
state.consumed += value;
|
|
510
|
+
state.index += num;
|
|
511
|
+
};
|
|
512
|
+
const append = (token)=>{
|
|
513
|
+
state.output += null != token.output ? token.output : token.value;
|
|
514
|
+
consume(token.value);
|
|
515
|
+
};
|
|
516
|
+
const negate = ()=>{
|
|
517
|
+
let count = 1;
|
|
518
|
+
while('!' === peek() && ('(' !== peek(2) || '?' === peek(3))){
|
|
519
|
+
advance();
|
|
520
|
+
state.start++;
|
|
521
|
+
count++;
|
|
522
|
+
}
|
|
523
|
+
if (count % 2 === 0) return false;
|
|
524
|
+
state.negated = true;
|
|
525
|
+
state.start++;
|
|
526
|
+
return true;
|
|
527
|
+
};
|
|
528
|
+
const increment = (type)=>{
|
|
529
|
+
state[type]++;
|
|
530
|
+
stack.push(type);
|
|
531
|
+
};
|
|
532
|
+
const decrement = (type)=>{
|
|
533
|
+
state[type]--;
|
|
534
|
+
stack.pop();
|
|
535
|
+
};
|
|
536
|
+
const push = (tok)=>{
|
|
537
|
+
if ('globstar' === prev.type) {
|
|
538
|
+
const isBrace = state.braces > 0 && ('comma' === tok.type || 'brace' === tok.type);
|
|
539
|
+
const isExtglob = true === tok.extglob || extglobs.length && ('pipe' === tok.type || 'paren' === tok.type);
|
|
540
|
+
if ('slash' !== tok.type && 'paren' !== tok.type && !isBrace && !isExtglob) {
|
|
541
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
542
|
+
prev.type = 'star';
|
|
543
|
+
prev.value = '*';
|
|
544
|
+
prev.output = star;
|
|
545
|
+
state.output += prev.output;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (extglobs.length && 'paren' !== tok.type) extglobs[extglobs.length - 1].inner += tok.value;
|
|
549
|
+
if (tok.value || tok.output) append(tok);
|
|
550
|
+
if (prev && 'text' === prev.type && 'text' === tok.type) {
|
|
551
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
552
|
+
prev.value += tok.value;
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
tok.prev = prev;
|
|
556
|
+
tokens.push(tok);
|
|
557
|
+
prev = tok;
|
|
558
|
+
};
|
|
559
|
+
const extglobOpen = (type, value)=>{
|
|
560
|
+
const token = {
|
|
561
|
+
...EXTGLOB_CHARS[value],
|
|
562
|
+
conditions: 1,
|
|
563
|
+
inner: ''
|
|
564
|
+
};
|
|
565
|
+
token.prev = prev;
|
|
566
|
+
token.parens = state.parens;
|
|
567
|
+
token.output = state.output;
|
|
568
|
+
token.startIndex = state.index;
|
|
569
|
+
token.tokensIndex = tokens.length;
|
|
570
|
+
const output = (opts.capture ? '(' : '') + token.open;
|
|
571
|
+
increment('parens');
|
|
572
|
+
push({
|
|
573
|
+
type,
|
|
574
|
+
value,
|
|
575
|
+
output: state.output ? '' : ONE_CHAR
|
|
576
|
+
});
|
|
577
|
+
push({
|
|
578
|
+
type: 'paren',
|
|
579
|
+
extglob: true,
|
|
580
|
+
value: advance(),
|
|
581
|
+
output
|
|
582
|
+
});
|
|
583
|
+
extglobs.push(token);
|
|
584
|
+
};
|
|
585
|
+
const extglobClose = (token)=>{
|
|
586
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
587
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
588
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
589
|
+
if (('plus' === token.type || 'star' === token.type) && analysis.risky) {
|
|
590
|
+
const safeOutput = analysis.safeOutput ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
591
|
+
const open = tokens[token.tokensIndex];
|
|
592
|
+
open.type = 'text';
|
|
593
|
+
open.value = literal;
|
|
594
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
595
|
+
for(let i = token.tokensIndex + 1; i < tokens.length; i++){
|
|
596
|
+
tokens[i].value = '';
|
|
597
|
+
tokens[i].output = '';
|
|
598
|
+
delete tokens[i].suffix;
|
|
599
|
+
}
|
|
600
|
+
state.output = token.output + open.output;
|
|
601
|
+
state.backtrack = true;
|
|
602
|
+
push({
|
|
603
|
+
type: 'paren',
|
|
604
|
+
extglob: true,
|
|
605
|
+
value,
|
|
606
|
+
output: ''
|
|
607
|
+
});
|
|
608
|
+
decrement('parens');
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
let output = token.close + (opts.capture ? ')' : '');
|
|
612
|
+
let rest;
|
|
613
|
+
if ('negate' === token.type) {
|
|
614
|
+
let extglobStar = star;
|
|
615
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) extglobStar = globstar(opts);
|
|
616
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
617
|
+
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
618
|
+
const expression = parse(rest, {
|
|
619
|
+
...options,
|
|
620
|
+
fastpaths: false
|
|
621
|
+
}).output;
|
|
622
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
623
|
+
}
|
|
624
|
+
if ('bos' === token.prev.type) state.negatedExtglob = true;
|
|
625
|
+
}
|
|
626
|
+
push({
|
|
627
|
+
type: 'paren',
|
|
628
|
+
extglob: true,
|
|
629
|
+
value,
|
|
630
|
+
output
|
|
631
|
+
});
|
|
632
|
+
decrement('parens');
|
|
633
|
+
};
|
|
634
|
+
if (false !== opts.fastpaths && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
635
|
+
let backslashes = false;
|
|
636
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index)=>{
|
|
637
|
+
if ('\\' === first) {
|
|
638
|
+
backslashes = true;
|
|
639
|
+
return m;
|
|
640
|
+
}
|
|
641
|
+
if ('?' === first) {
|
|
642
|
+
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
643
|
+
if (0 === index) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
644
|
+
return QMARK.repeat(chars.length);
|
|
645
|
+
}
|
|
646
|
+
if ('.' === first) return DOT_LITERAL.repeat(chars.length);
|
|
647
|
+
if ('*' === first) {
|
|
648
|
+
if (esc) return esc + first + (rest ? star : '');
|
|
649
|
+
return star;
|
|
650
|
+
}
|
|
651
|
+
return esc ? m : `\\${m}`;
|
|
652
|
+
});
|
|
653
|
+
if (true === backslashes) output = true === opts.unescape ? output.replace(/\\/g, '') : output.replace(/\\+/g, (m)=>m.length % 2 === 0 ? '\\\\' : m ? '\\' : '');
|
|
654
|
+
if (output === input && true === opts.contains) {
|
|
655
|
+
state.output = input;
|
|
656
|
+
return state;
|
|
657
|
+
}
|
|
658
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
659
|
+
return state;
|
|
660
|
+
}
|
|
661
|
+
while(!eos()){
|
|
662
|
+
value = advance();
|
|
663
|
+
if ('\u0000' === value) continue;
|
|
664
|
+
if ('\\' === value) {
|
|
665
|
+
const next = peek();
|
|
666
|
+
if ('/' === next && true !== opts.bash) continue;
|
|
667
|
+
if ('.' === next || ';' === next) continue;
|
|
668
|
+
if (!next) {
|
|
669
|
+
value += '\\';
|
|
670
|
+
push({
|
|
671
|
+
type: 'text',
|
|
672
|
+
value
|
|
673
|
+
});
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
const match = /^\\+/.exec(remaining());
|
|
677
|
+
let slashes = 0;
|
|
678
|
+
if (match && match[0].length > 2) {
|
|
679
|
+
slashes = match[0].length;
|
|
680
|
+
state.index += slashes;
|
|
681
|
+
if (slashes % 2 !== 0) value += '\\';
|
|
682
|
+
}
|
|
683
|
+
if (true === opts.unescape) value = advance();
|
|
684
|
+
else value += advance();
|
|
685
|
+
if (0 === state.brackets) {
|
|
686
|
+
push({
|
|
687
|
+
type: 'text',
|
|
688
|
+
value
|
|
689
|
+
});
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (state.brackets > 0 && (']' !== value || '[' === prev.value || '[^' === prev.value)) {
|
|
694
|
+
if (false !== opts.posix && ':' === value) {
|
|
695
|
+
const inner = prev.value.slice(1);
|
|
696
|
+
if (inner.includes('[')) {
|
|
697
|
+
prev.posix = true;
|
|
698
|
+
if (inner.includes(':')) {
|
|
699
|
+
const idx = prev.value.lastIndexOf('[');
|
|
700
|
+
const pre = prev.value.slice(0, idx);
|
|
701
|
+
const rest = prev.value.slice(idx + 2);
|
|
702
|
+
const posix = POSIX_REGEX_SOURCE[rest];
|
|
703
|
+
if (posix) {
|
|
704
|
+
prev.value = pre + posix;
|
|
705
|
+
state.backtrack = true;
|
|
706
|
+
advance();
|
|
707
|
+
if (!bos.output && 1 === tokens.indexOf(prev)) bos.output = ONE_CHAR;
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if ('[' === value && ':' !== peek() || '-' === value && ']' === peek()) value = `\\${value}`;
|
|
714
|
+
if (']' === value && ('[' === prev.value || '[^' === prev.value)) value = `\\${value}`;
|
|
715
|
+
if (true === opts.posix && '!' === value && '[' === prev.value) value = '^';
|
|
716
|
+
prev.value += value;
|
|
717
|
+
append({
|
|
718
|
+
value
|
|
719
|
+
});
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
if (1 === state.quotes && '"' !== value) {
|
|
723
|
+
value = utils.escapeRegex(value);
|
|
724
|
+
prev.value += value;
|
|
725
|
+
append({
|
|
726
|
+
value
|
|
727
|
+
});
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
if ('"' === value) {
|
|
731
|
+
state.quotes = 1 === state.quotes ? 0 : 1;
|
|
732
|
+
if (true === opts.keepQuotes) push({
|
|
733
|
+
type: 'text',
|
|
734
|
+
value
|
|
735
|
+
});
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
if ('(' === value) {
|
|
739
|
+
increment('parens');
|
|
740
|
+
push({
|
|
741
|
+
type: 'paren',
|
|
742
|
+
value
|
|
743
|
+
});
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
if (')' === value) {
|
|
747
|
+
if (0 === state.parens && true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '('));
|
|
748
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
749
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
750
|
+
extglobClose(extglobs.pop());
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
push({
|
|
754
|
+
type: 'paren',
|
|
755
|
+
value,
|
|
756
|
+
output: state.parens ? ')' : '\\)'
|
|
757
|
+
});
|
|
758
|
+
decrement('parens');
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
if ('[' === value) {
|
|
762
|
+
if (true !== opts.nobracket && remaining().includes(']')) increment('brackets');
|
|
763
|
+
else {
|
|
764
|
+
if (true !== opts.nobracket && true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
|
|
765
|
+
value = `\\${value}`;
|
|
766
|
+
}
|
|
767
|
+
push({
|
|
768
|
+
type: 'bracket',
|
|
769
|
+
value
|
|
770
|
+
});
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
if (']' === value) {
|
|
774
|
+
if (true === opts.nobracket || prev && 'bracket' === prev.type && 1 === prev.value.length) {
|
|
775
|
+
push({
|
|
776
|
+
type: 'text',
|
|
777
|
+
value,
|
|
778
|
+
output: `\\${value}`
|
|
779
|
+
});
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (0 === state.brackets) {
|
|
783
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '['));
|
|
784
|
+
push({
|
|
785
|
+
type: 'text',
|
|
786
|
+
value,
|
|
787
|
+
output: `\\${value}`
|
|
788
|
+
});
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
decrement('brackets');
|
|
792
|
+
const prevValue = prev.value.slice(1);
|
|
793
|
+
if (true !== prev.posix && '^' === prevValue[0] && !prevValue.includes('/')) value = `/${value}`;
|
|
794
|
+
prev.value += value;
|
|
795
|
+
append({
|
|
796
|
+
value
|
|
797
|
+
});
|
|
798
|
+
if (false === opts.literalBrackets || utils.hasRegexChars(prevValue)) continue;
|
|
799
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
800
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
801
|
+
if (true === opts.literalBrackets) {
|
|
802
|
+
state.output += escaped;
|
|
803
|
+
prev.value = escaped;
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
807
|
+
state.output += prev.value;
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
if ('{' === value && true !== opts.nobrace) {
|
|
811
|
+
increment('braces');
|
|
812
|
+
const open = {
|
|
813
|
+
type: 'brace',
|
|
814
|
+
value,
|
|
815
|
+
output: '(',
|
|
816
|
+
outputIndex: state.output.length,
|
|
817
|
+
tokensIndex: state.tokens.length
|
|
818
|
+
};
|
|
819
|
+
braces.push(open);
|
|
820
|
+
push(open);
|
|
821
|
+
continue;
|
|
822
|
+
}
|
|
823
|
+
if ('}' === value) {
|
|
824
|
+
const brace = braces[braces.length - 1];
|
|
825
|
+
if (true === opts.nobrace || !brace) {
|
|
826
|
+
push({
|
|
827
|
+
type: 'text',
|
|
828
|
+
value,
|
|
829
|
+
output: value
|
|
830
|
+
});
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
let output = ')';
|
|
834
|
+
if (true === brace.dots) {
|
|
835
|
+
const arr = tokens.slice();
|
|
836
|
+
const range = [];
|
|
837
|
+
for(let i = arr.length - 1; i >= 0; i--){
|
|
838
|
+
tokens.pop();
|
|
839
|
+
if ('brace' === arr[i].type) break;
|
|
840
|
+
if ('dots' !== arr[i].type) range.unshift(arr[i].value);
|
|
841
|
+
}
|
|
842
|
+
output = expandRange(range, opts);
|
|
843
|
+
state.backtrack = true;
|
|
844
|
+
}
|
|
845
|
+
if (true !== brace.comma && true !== brace.dots) {
|
|
846
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
847
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
848
|
+
brace.value = brace.output = '\\{';
|
|
849
|
+
value = output = '\\}';
|
|
850
|
+
state.output = out;
|
|
851
|
+
for (const t of toks)state.output += t.output || t.value;
|
|
852
|
+
}
|
|
853
|
+
push({
|
|
854
|
+
type: 'brace',
|
|
855
|
+
value,
|
|
856
|
+
output
|
|
857
|
+
});
|
|
858
|
+
decrement('braces');
|
|
859
|
+
braces.pop();
|
|
860
|
+
continue;
|
|
861
|
+
}
|
|
862
|
+
if ('|' === value) {
|
|
863
|
+
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
864
|
+
push({
|
|
865
|
+
type: 'text',
|
|
866
|
+
value
|
|
867
|
+
});
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
if (',' === value) {
|
|
871
|
+
let output = value;
|
|
872
|
+
const brace = braces[braces.length - 1];
|
|
873
|
+
if (brace && 'braces' === stack[stack.length - 1]) {
|
|
874
|
+
brace.comma = true;
|
|
875
|
+
output = '|';
|
|
876
|
+
}
|
|
877
|
+
push({
|
|
878
|
+
type: 'comma',
|
|
879
|
+
value,
|
|
880
|
+
output
|
|
881
|
+
});
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
if ('/' === value) {
|
|
885
|
+
if ('dot' === prev.type && state.index === state.start + 1) {
|
|
886
|
+
state.start = state.index + 1;
|
|
887
|
+
state.consumed = '';
|
|
888
|
+
state.output = '';
|
|
889
|
+
tokens.pop();
|
|
890
|
+
prev = bos;
|
|
891
|
+
continue;
|
|
892
|
+
}
|
|
893
|
+
push({
|
|
894
|
+
type: 'slash',
|
|
895
|
+
value,
|
|
896
|
+
output: SLASH_LITERAL
|
|
897
|
+
});
|
|
898
|
+
continue;
|
|
899
|
+
}
|
|
900
|
+
if ('.' === value) {
|
|
901
|
+
if (state.braces > 0 && 'dot' === prev.type) {
|
|
902
|
+
if ('.' === prev.value) prev.output = DOT_LITERAL;
|
|
903
|
+
const brace = braces[braces.length - 1];
|
|
904
|
+
prev.type = 'dots';
|
|
905
|
+
prev.output += value;
|
|
906
|
+
prev.value += value;
|
|
907
|
+
brace.dots = true;
|
|
908
|
+
continue;
|
|
909
|
+
}
|
|
910
|
+
if (state.braces + state.parens === 0 && 'bos' !== prev.type && 'slash' !== prev.type) {
|
|
911
|
+
push({
|
|
912
|
+
type: 'text',
|
|
913
|
+
value,
|
|
914
|
+
output: DOT_LITERAL
|
|
915
|
+
});
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
918
|
+
push({
|
|
919
|
+
type: 'dot',
|
|
920
|
+
value,
|
|
921
|
+
output: DOT_LITERAL
|
|
922
|
+
});
|
|
923
|
+
continue;
|
|
924
|
+
}
|
|
925
|
+
if ('?' === value) {
|
|
926
|
+
const isGroup = prev && '(' === prev.value;
|
|
927
|
+
if (!isGroup && true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
928
|
+
extglobOpen('qmark', value);
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
if (prev && 'paren' === prev.type) {
|
|
932
|
+
const next = peek();
|
|
933
|
+
let output = value;
|
|
934
|
+
if ('(' === prev.value && !/[!=<:]/.test(next) || '<' === next && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
935
|
+
push({
|
|
936
|
+
type: 'text',
|
|
937
|
+
value,
|
|
938
|
+
output
|
|
939
|
+
});
|
|
940
|
+
continue;
|
|
941
|
+
}
|
|
942
|
+
if (true !== opts.dot && ('slash' === prev.type || 'bos' === prev.type)) {
|
|
943
|
+
push({
|
|
944
|
+
type: 'qmark',
|
|
945
|
+
value,
|
|
946
|
+
output: QMARK_NO_DOT
|
|
947
|
+
});
|
|
948
|
+
continue;
|
|
949
|
+
}
|
|
950
|
+
push({
|
|
951
|
+
type: 'qmark',
|
|
952
|
+
value,
|
|
953
|
+
output: QMARK
|
|
954
|
+
});
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
957
|
+
if ('!' === value) {
|
|
958
|
+
if (true !== opts.noextglob && '(' === peek()) {
|
|
959
|
+
if ('?' !== peek(2) || !/[!=<:]/.test(peek(3))) {
|
|
960
|
+
extglobOpen('negate', value);
|
|
961
|
+
continue;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
if (true !== opts.nonegate && 0 === state.index) {
|
|
965
|
+
negate();
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
if ('+' === value) {
|
|
970
|
+
if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
971
|
+
extglobOpen('plus', value);
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
if (prev && '(' === prev.value || false === opts.regex) {
|
|
975
|
+
push({
|
|
976
|
+
type: 'plus',
|
|
977
|
+
value,
|
|
978
|
+
output: PLUS_LITERAL
|
|
979
|
+
});
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
if (prev && ('bracket' === prev.type || 'paren' === prev.type || 'brace' === prev.type) || state.parens > 0) {
|
|
983
|
+
push({
|
|
984
|
+
type: 'plus',
|
|
985
|
+
value
|
|
986
|
+
});
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
989
|
+
push({
|
|
990
|
+
type: 'plus',
|
|
991
|
+
value: PLUS_LITERAL
|
|
992
|
+
});
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
if ('@' === value) {
|
|
996
|
+
if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
997
|
+
push({
|
|
998
|
+
type: 'at',
|
|
999
|
+
extglob: true,
|
|
1000
|
+
value,
|
|
1001
|
+
output: ''
|
|
1002
|
+
});
|
|
1003
|
+
continue;
|
|
1004
|
+
}
|
|
1005
|
+
push({
|
|
1006
|
+
type: 'text',
|
|
1007
|
+
value
|
|
1008
|
+
});
|
|
1009
|
+
continue;
|
|
1010
|
+
}
|
|
1011
|
+
if ('*' !== value) {
|
|
1012
|
+
if ('$' === value || '^' === value) value = `\\${value}`;
|
|
1013
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1014
|
+
if (match) {
|
|
1015
|
+
value += match[0];
|
|
1016
|
+
state.index += match[0].length;
|
|
1017
|
+
}
|
|
1018
|
+
push({
|
|
1019
|
+
type: 'text',
|
|
1020
|
+
value
|
|
1021
|
+
});
|
|
1022
|
+
continue;
|
|
1023
|
+
}
|
|
1024
|
+
if (prev && ('globstar' === prev.type || true === prev.star)) {
|
|
1025
|
+
prev.type = 'star';
|
|
1026
|
+
prev.star = true;
|
|
1027
|
+
prev.value += value;
|
|
1028
|
+
prev.output = star;
|
|
1029
|
+
state.backtrack = true;
|
|
1030
|
+
state.globstar = true;
|
|
1031
|
+
consume(value);
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1034
|
+
let rest = remaining();
|
|
1035
|
+
if (true !== opts.noextglob && /^\([^?]/.test(rest)) {
|
|
1036
|
+
extglobOpen('star', value);
|
|
1037
|
+
continue;
|
|
1038
|
+
}
|
|
1039
|
+
if ('star' === prev.type) {
|
|
1040
|
+
if (true === opts.noglobstar) {
|
|
1041
|
+
consume(value);
|
|
1042
|
+
continue;
|
|
1043
|
+
}
|
|
1044
|
+
const prior = prev.prev;
|
|
1045
|
+
const before = prior.prev;
|
|
1046
|
+
const isStart = 'slash' === prior.type || 'bos' === prior.type;
|
|
1047
|
+
const afterStar = before && ('star' === before.type || 'globstar' === before.type);
|
|
1048
|
+
if (true === opts.bash && (!isStart || rest[0] && '/' !== rest[0])) {
|
|
1049
|
+
push({
|
|
1050
|
+
type: 'star',
|
|
1051
|
+
value,
|
|
1052
|
+
output: ''
|
|
1053
|
+
});
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
const isBrace = state.braces > 0 && ('comma' === prior.type || 'brace' === prior.type);
|
|
1057
|
+
const isExtglob = extglobs.length && ('pipe' === prior.type || 'paren' === prior.type);
|
|
1058
|
+
if (!isStart && 'paren' !== prior.type && !isBrace && !isExtglob) {
|
|
1059
|
+
push({
|
|
1060
|
+
type: 'star',
|
|
1061
|
+
value,
|
|
1062
|
+
output: ''
|
|
1063
|
+
});
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1066
|
+
while('/**' === rest.slice(0, 3)){
|
|
1067
|
+
const after = input[state.index + 4];
|
|
1068
|
+
if (after && '/' !== after) break;
|
|
1069
|
+
rest = rest.slice(3);
|
|
1070
|
+
consume('/**', 3);
|
|
1071
|
+
}
|
|
1072
|
+
if ('bos' === prior.type && eos()) {
|
|
1073
|
+
prev.type = 'globstar';
|
|
1074
|
+
prev.value += value;
|
|
1075
|
+
prev.output = globstar(opts);
|
|
1076
|
+
state.output = prev.output;
|
|
1077
|
+
state.globstar = true;
|
|
1078
|
+
consume(value);
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && eos()) {
|
|
1082
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1083
|
+
prior.output = `(?:${prior.output}`;
|
|
1084
|
+
prev.type = 'globstar';
|
|
1085
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
1086
|
+
prev.value += value;
|
|
1087
|
+
state.globstar = true;
|
|
1088
|
+
state.output += prior.output + prev.output;
|
|
1089
|
+
consume(value);
|
|
1090
|
+
continue;
|
|
1091
|
+
}
|
|
1092
|
+
if ('slash' === prior.type && 'bos' !== prior.prev.type && '/' === rest[0]) {
|
|
1093
|
+
const end = void 0 !== rest[1] ? '|$' : '';
|
|
1094
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1095
|
+
prior.output = `(?:${prior.output}`;
|
|
1096
|
+
prev.type = 'globstar';
|
|
1097
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1098
|
+
prev.value += value;
|
|
1099
|
+
state.output += prior.output + prev.output;
|
|
1100
|
+
state.globstar = true;
|
|
1101
|
+
consume(value + advance());
|
|
1102
|
+
push({
|
|
1103
|
+
type: 'slash',
|
|
1104
|
+
value: '/',
|
|
1105
|
+
output: ''
|
|
1106
|
+
});
|
|
1107
|
+
continue;
|
|
1108
|
+
}
|
|
1109
|
+
if ('bos' === prior.type && '/' === rest[0]) {
|
|
1110
|
+
prev.type = 'globstar';
|
|
1111
|
+
prev.value += value;
|
|
1112
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1113
|
+
state.output = prev.output;
|
|
1114
|
+
state.globstar = true;
|
|
1115
|
+
consume(value + advance());
|
|
1116
|
+
push({
|
|
1117
|
+
type: 'slash',
|
|
1118
|
+
value: '/',
|
|
1119
|
+
output: ''
|
|
1120
|
+
});
|
|
1121
|
+
continue;
|
|
1122
|
+
}
|
|
1123
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1124
|
+
prev.type = 'globstar';
|
|
1125
|
+
prev.output = globstar(opts);
|
|
1126
|
+
prev.value += value;
|
|
1127
|
+
state.output += prev.output;
|
|
1128
|
+
state.globstar = true;
|
|
1129
|
+
consume(value);
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
const token = {
|
|
1133
|
+
type: 'star',
|
|
1134
|
+
value,
|
|
1135
|
+
output: star
|
|
1136
|
+
};
|
|
1137
|
+
if (true === opts.bash) {
|
|
1138
|
+
token.output = '.*?';
|
|
1139
|
+
if ('bos' === prev.type || 'slash' === prev.type) token.output = nodot + token.output;
|
|
1140
|
+
push(token);
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
if (prev && ('bracket' === prev.type || 'paren' === prev.type) && true === opts.regex) {
|
|
1144
|
+
token.output = value;
|
|
1145
|
+
push(token);
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
if (state.index === state.start || 'slash' === prev.type || 'dot' === prev.type) {
|
|
1149
|
+
if ('dot' === prev.type) {
|
|
1150
|
+
state.output += NO_DOT_SLASH;
|
|
1151
|
+
prev.output += NO_DOT_SLASH;
|
|
1152
|
+
} else if (true === opts.dot) {
|
|
1153
|
+
state.output += NO_DOTS_SLASH;
|
|
1154
|
+
prev.output += NO_DOTS_SLASH;
|
|
1155
|
+
} else {
|
|
1156
|
+
state.output += nodot;
|
|
1157
|
+
prev.output += nodot;
|
|
1158
|
+
}
|
|
1159
|
+
if ('*' !== peek()) {
|
|
1160
|
+
state.output += ONE_CHAR;
|
|
1161
|
+
prev.output += ONE_CHAR;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
push(token);
|
|
1165
|
+
}
|
|
1166
|
+
while(state.brackets > 0){
|
|
1167
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
|
|
1168
|
+
state.output = utils.escapeLast(state.output, '[');
|
|
1169
|
+
decrement('brackets');
|
|
1170
|
+
}
|
|
1171
|
+
while(state.parens > 0){
|
|
1172
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ')'));
|
|
1173
|
+
state.output = utils.escapeLast(state.output, '(');
|
|
1174
|
+
decrement('parens');
|
|
1175
|
+
}
|
|
1176
|
+
while(state.braces > 0){
|
|
1177
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', '}'));
|
|
1178
|
+
state.output = utils.escapeLast(state.output, '{');
|
|
1179
|
+
decrement('braces');
|
|
1180
|
+
}
|
|
1181
|
+
if (true !== opts.strictSlashes && ('star' === prev.type || 'bracket' === prev.type)) push({
|
|
1182
|
+
type: 'maybe_slash',
|
|
1183
|
+
value: '',
|
|
1184
|
+
output: `${SLASH_LITERAL}?`
|
|
1185
|
+
});
|
|
1186
|
+
if (true === state.backtrack) {
|
|
1187
|
+
state.output = '';
|
|
1188
|
+
for (const token of state.tokens){
|
|
1189
|
+
state.output += null != token.output ? token.output : token.value;
|
|
1190
|
+
if (token.suffix) state.output += token.suffix;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
return state;
|
|
1194
|
+
};
|
|
1195
|
+
parse.fastpaths = (input, options)=>{
|
|
1196
|
+
const opts = {
|
|
1197
|
+
...options
|
|
1198
|
+
};
|
|
1199
|
+
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1200
|
+
const len = input.length;
|
|
1201
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1202
|
+
input = REPLACEMENTS[input] || input;
|
|
1203
|
+
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
1204
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1205
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1206
|
+
const capture = opts.capture ? '' : '?:';
|
|
1207
|
+
const state = {
|
|
1208
|
+
negated: false,
|
|
1209
|
+
prefix: ''
|
|
1210
|
+
};
|
|
1211
|
+
let star = true === opts.bash ? '.*?' : STAR;
|
|
1212
|
+
if (opts.capture) star = `(${star})`;
|
|
1213
|
+
const globstar = (opts)=>{
|
|
1214
|
+
if (true === opts.noglobstar) return star;
|
|
1215
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1216
|
+
};
|
|
1217
|
+
const create = (str)=>{
|
|
1218
|
+
switch(str){
|
|
1219
|
+
case '*':
|
|
1220
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
1221
|
+
case '.*':
|
|
1222
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1223
|
+
case '*.*':
|
|
1224
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1225
|
+
case '*/*':
|
|
1226
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1227
|
+
case '**':
|
|
1228
|
+
return nodot + globstar(opts);
|
|
1229
|
+
case '**/*':
|
|
1230
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1231
|
+
case '**/*.*':
|
|
1232
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1233
|
+
case '**/.*':
|
|
1234
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1235
|
+
default:
|
|
1236
|
+
{
|
|
1237
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1238
|
+
if (!match) return;
|
|
1239
|
+
const source = create(match[1]);
|
|
1240
|
+
if (!source) return;
|
|
1241
|
+
return source + DOT_LITERAL + match[2];
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
const output = utils.removePrefix(input, state);
|
|
1246
|
+
let source = create(output);
|
|
1247
|
+
if (source && true !== opts.strictSlashes) source += `${SLASH_LITERAL}?`;
|
|
1248
|
+
return source;
|
|
1249
|
+
};
|
|
1250
|
+
module.exports = parse;
|
|
1251
|
+
},
|
|
1252
|
+
"./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1253
|
+
const scan = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js");
|
|
1254
|
+
const parse = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js");
|
|
1255
|
+
const utils = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
1256
|
+
const constants = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
1257
|
+
const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
|
|
1258
|
+
const picomatch = (glob, options, returnState = false)=>{
|
|
1259
|
+
if (Array.isArray(glob)) {
|
|
1260
|
+
const fns = glob.map((input)=>picomatch(input, options, returnState));
|
|
1261
|
+
const arrayMatcher = (str)=>{
|
|
1262
|
+
for (const isMatch of fns){
|
|
1263
|
+
const state = isMatch(str);
|
|
1264
|
+
if (state) return state;
|
|
1265
|
+
}
|
|
1266
|
+
return false;
|
|
1267
|
+
};
|
|
1268
|
+
return arrayMatcher;
|
|
1269
|
+
}
|
|
1270
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1271
|
+
if ('' === glob || 'string' != typeof glob && !isState) throw new TypeError('Expected pattern to be a non-empty string');
|
|
1272
|
+
const opts = options || {};
|
|
1273
|
+
const posix = opts.windows;
|
|
1274
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1275
|
+
const state = regex.state;
|
|
1276
|
+
delete regex.state;
|
|
1277
|
+
let isIgnored = ()=>false;
|
|
1278
|
+
if (opts.ignore) {
|
|
1279
|
+
const ignoreOpts = {
|
|
1280
|
+
...options,
|
|
1281
|
+
ignore: null,
|
|
1282
|
+
onMatch: null,
|
|
1283
|
+
onResult: null
|
|
1284
|
+
};
|
|
1285
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1286
|
+
}
|
|
1287
|
+
const matcher = (input, returnObject = false)=>{
|
|
1288
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
1289
|
+
glob,
|
|
1290
|
+
posix
|
|
1291
|
+
});
|
|
1292
|
+
const result = {
|
|
1293
|
+
glob,
|
|
1294
|
+
state,
|
|
1295
|
+
regex,
|
|
1296
|
+
posix,
|
|
1297
|
+
input,
|
|
1298
|
+
output,
|
|
1299
|
+
match,
|
|
1300
|
+
isMatch
|
|
1301
|
+
};
|
|
1302
|
+
if ('function' == typeof opts.onResult) opts.onResult(result);
|
|
1303
|
+
if (false === isMatch) {
|
|
1304
|
+
result.isMatch = false;
|
|
1305
|
+
return returnObject ? result : false;
|
|
1306
|
+
}
|
|
1307
|
+
if (isIgnored(input)) {
|
|
1308
|
+
if ('function' == typeof opts.onIgnore) opts.onIgnore(result);
|
|
1309
|
+
result.isMatch = false;
|
|
1310
|
+
return returnObject ? result : false;
|
|
1311
|
+
}
|
|
1312
|
+
if ('function' == typeof opts.onMatch) opts.onMatch(result);
|
|
1313
|
+
return returnObject ? result : true;
|
|
1314
|
+
};
|
|
1315
|
+
if (returnState) matcher.state = state;
|
|
1316
|
+
return matcher;
|
|
1317
|
+
};
|
|
1318
|
+
picomatch.test = (input, regex, options, { glob, posix } = {})=>{
|
|
1319
|
+
if ('string' != typeof input) throw new TypeError('Expected input to be a string');
|
|
1320
|
+
if ('' === input) return {
|
|
1321
|
+
isMatch: false,
|
|
1322
|
+
output: ''
|
|
1323
|
+
};
|
|
1324
|
+
const opts = options || {};
|
|
1325
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1326
|
+
let match = input === glob;
|
|
1327
|
+
let output = match && format ? format(input) : input;
|
|
1328
|
+
if (false === match) {
|
|
1329
|
+
output = format ? format(input) : input;
|
|
1330
|
+
match = output === glob;
|
|
1331
|
+
}
|
|
1332
|
+
if (false === match || true === opts.capture) match = true === opts.matchBase || true === opts.basename ? picomatch.matchBase(input, regex, options, posix) : regex.exec(output);
|
|
1333
|
+
return {
|
|
1334
|
+
isMatch: Boolean(match),
|
|
1335
|
+
match,
|
|
1336
|
+
output
|
|
1337
|
+
};
|
|
1338
|
+
};
|
|
1339
|
+
picomatch.matchBase = (input, glob, options)=>{
|
|
1340
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1341
|
+
return regex.test(utils.basename(input));
|
|
1342
|
+
};
|
|
1343
|
+
picomatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
|
|
1344
|
+
picomatch.parse = (pattern, options)=>{
|
|
1345
|
+
if (Array.isArray(pattern)) return pattern.map((p)=>picomatch.parse(p, options));
|
|
1346
|
+
return parse(pattern, {
|
|
1347
|
+
...options,
|
|
1348
|
+
fastpaths: false
|
|
1349
|
+
});
|
|
1350
|
+
};
|
|
1351
|
+
picomatch.scan = (input, options)=>scan(input, options);
|
|
1352
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false)=>{
|
|
1353
|
+
if (true === returnOutput) return state.output;
|
|
1354
|
+
const opts = options || {};
|
|
1355
|
+
const prepend = opts.contains ? '' : '^';
|
|
1356
|
+
const append = opts.contains ? '' : '$';
|
|
1357
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1358
|
+
if (state && true === state.negated) source = `^(?!${source}).*$`;
|
|
1359
|
+
const regex = picomatch.toRegex(source, options);
|
|
1360
|
+
if (true === returnState) regex.state = state;
|
|
1361
|
+
return regex;
|
|
1362
|
+
};
|
|
1363
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false)=>{
|
|
1364
|
+
if (!input || 'string' != typeof input) throw new TypeError('Expected a non-empty string');
|
|
1365
|
+
let parsed = {
|
|
1366
|
+
negated: false,
|
|
1367
|
+
fastpaths: true
|
|
1368
|
+
};
|
|
1369
|
+
if (false !== options.fastpaths && ('.' === input[0] || '*' === input[0])) parsed.output = parse.fastpaths(input, options);
|
|
1370
|
+
if (!parsed.output) parsed = parse(input, options);
|
|
1371
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1372
|
+
};
|
|
1373
|
+
picomatch.toRegex = (source, options)=>{
|
|
1374
|
+
try {
|
|
1375
|
+
const opts = options || {};
|
|
1376
|
+
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
1377
|
+
} catch (err) {
|
|
1378
|
+
if (options && true === options.debug) throw err;
|
|
1379
|
+
return /$^/;
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
picomatch.constants = constants;
|
|
1383
|
+
module.exports = picomatch;
|
|
1384
|
+
},
|
|
1385
|
+
"./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1386
|
+
const utils = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
1387
|
+
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
1388
|
+
const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1389
|
+
const depth = (token)=>{
|
|
1390
|
+
if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
|
|
1391
|
+
};
|
|
1392
|
+
const scan = (input, options)=>{
|
|
1393
|
+
const opts = options || {};
|
|
1394
|
+
const length = input.length - 1;
|
|
1395
|
+
const scanToEnd = true === opts.parts || true === opts.scanToEnd;
|
|
1396
|
+
const slashes = [];
|
|
1397
|
+
const tokens = [];
|
|
1398
|
+
const parts = [];
|
|
1399
|
+
let str = input;
|
|
1400
|
+
let index = -1;
|
|
1401
|
+
let start = 0;
|
|
1402
|
+
let lastIndex = 0;
|
|
1403
|
+
let isBrace = false;
|
|
1404
|
+
let isBracket = false;
|
|
1405
|
+
let isGlob = false;
|
|
1406
|
+
let isExtglob = false;
|
|
1407
|
+
let isGlobstar = false;
|
|
1408
|
+
let braceEscaped = false;
|
|
1409
|
+
let backslashes = false;
|
|
1410
|
+
let negated = false;
|
|
1411
|
+
let negatedExtglob = false;
|
|
1412
|
+
let finished = false;
|
|
1413
|
+
let braces = 0;
|
|
1414
|
+
let prev;
|
|
1415
|
+
let code;
|
|
1416
|
+
let token = {
|
|
1417
|
+
value: '',
|
|
1418
|
+
depth: 0,
|
|
1419
|
+
isGlob: false
|
|
1420
|
+
};
|
|
1421
|
+
const eos = ()=>index >= length;
|
|
1422
|
+
const peek = ()=>str.charCodeAt(index + 1);
|
|
1423
|
+
const advance = ()=>{
|
|
1424
|
+
prev = code;
|
|
1425
|
+
return str.charCodeAt(++index);
|
|
1426
|
+
};
|
|
1427
|
+
while(index < length){
|
|
1428
|
+
code = advance();
|
|
1429
|
+
let next;
|
|
1430
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1431
|
+
backslashes = token.backslashes = true;
|
|
1432
|
+
code = advance();
|
|
1433
|
+
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
1434
|
+
continue;
|
|
1435
|
+
}
|
|
1436
|
+
if (true === braceEscaped || code === CHAR_LEFT_CURLY_BRACE) {
|
|
1437
|
+
braces++;
|
|
1438
|
+
while(true !== eos() && (code = advance())){
|
|
1439
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1440
|
+
backslashes = token.backslashes = true;
|
|
1441
|
+
advance();
|
|
1442
|
+
continue;
|
|
1443
|
+
}
|
|
1444
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1445
|
+
braces++;
|
|
1446
|
+
continue;
|
|
1447
|
+
}
|
|
1448
|
+
if (true !== braceEscaped && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
1449
|
+
isBrace = token.isBrace = true;
|
|
1450
|
+
isGlob = token.isGlob = true;
|
|
1451
|
+
finished = true;
|
|
1452
|
+
if (true === scanToEnd) continue;
|
|
1453
|
+
break;
|
|
1454
|
+
}
|
|
1455
|
+
if (true !== braceEscaped && code === CHAR_COMMA) {
|
|
1456
|
+
isBrace = token.isBrace = true;
|
|
1457
|
+
isGlob = token.isGlob = true;
|
|
1458
|
+
finished = true;
|
|
1459
|
+
if (true === scanToEnd) continue;
|
|
1460
|
+
break;
|
|
1461
|
+
}
|
|
1462
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1463
|
+
braces--;
|
|
1464
|
+
if (0 === braces) {
|
|
1465
|
+
braceEscaped = false;
|
|
1466
|
+
isBrace = token.isBrace = true;
|
|
1467
|
+
finished = true;
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
if (true === scanToEnd) continue;
|
|
1473
|
+
break;
|
|
1474
|
+
}
|
|
1475
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
1476
|
+
slashes.push(index);
|
|
1477
|
+
tokens.push(token);
|
|
1478
|
+
token = {
|
|
1479
|
+
value: '',
|
|
1480
|
+
depth: 0,
|
|
1481
|
+
isGlob: false
|
|
1482
|
+
};
|
|
1483
|
+
if (true === finished) continue;
|
|
1484
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
1485
|
+
start += 2;
|
|
1486
|
+
continue;
|
|
1487
|
+
}
|
|
1488
|
+
lastIndex = index + 1;
|
|
1489
|
+
continue;
|
|
1490
|
+
}
|
|
1491
|
+
if (true !== opts.noext) {
|
|
1492
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
1493
|
+
if (true === isExtglobChar && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1494
|
+
isGlob = token.isGlob = true;
|
|
1495
|
+
isExtglob = token.isExtglob = true;
|
|
1496
|
+
finished = true;
|
|
1497
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
1498
|
+
if (true === scanToEnd) {
|
|
1499
|
+
while(true !== eos() && (code = advance())){
|
|
1500
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1501
|
+
backslashes = token.backslashes = true;
|
|
1502
|
+
code = advance();
|
|
1503
|
+
continue;
|
|
1504
|
+
}
|
|
1505
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1506
|
+
isGlob = token.isGlob = true;
|
|
1507
|
+
finished = true;
|
|
1508
|
+
break;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
continue;
|
|
1512
|
+
}
|
|
1513
|
+
break;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
if (code === CHAR_ASTERISK) {
|
|
1517
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1518
|
+
isGlob = token.isGlob = true;
|
|
1519
|
+
finished = true;
|
|
1520
|
+
if (true === scanToEnd) continue;
|
|
1521
|
+
break;
|
|
1522
|
+
}
|
|
1523
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
1524
|
+
isGlob = token.isGlob = true;
|
|
1525
|
+
finished = true;
|
|
1526
|
+
if (true === scanToEnd) continue;
|
|
1527
|
+
break;
|
|
1528
|
+
}
|
|
1529
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1530
|
+
while(true !== eos() && (next = advance())){
|
|
1531
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
1532
|
+
backslashes = token.backslashes = true;
|
|
1533
|
+
advance();
|
|
1534
|
+
continue;
|
|
1535
|
+
}
|
|
1536
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1537
|
+
isBracket = token.isBracket = true;
|
|
1538
|
+
isGlob = token.isGlob = true;
|
|
1539
|
+
finished = true;
|
|
1540
|
+
break;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
if (true === scanToEnd) continue;
|
|
1544
|
+
break;
|
|
1545
|
+
}
|
|
1546
|
+
if (true !== opts.nonegate && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1547
|
+
negated = token.negated = true;
|
|
1548
|
+
start++;
|
|
1549
|
+
continue;
|
|
1550
|
+
}
|
|
1551
|
+
if (true !== opts.noparen && code === CHAR_LEFT_PARENTHESES) {
|
|
1552
|
+
isGlob = token.isGlob = true;
|
|
1553
|
+
if (true === scanToEnd) {
|
|
1554
|
+
while(true !== eos() && (code = advance())){
|
|
1555
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1556
|
+
backslashes = token.backslashes = true;
|
|
1557
|
+
code = advance();
|
|
1558
|
+
continue;
|
|
1559
|
+
}
|
|
1560
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1561
|
+
finished = true;
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
continue;
|
|
1566
|
+
}
|
|
1567
|
+
break;
|
|
1568
|
+
}
|
|
1569
|
+
if (true === isGlob) {
|
|
1570
|
+
finished = true;
|
|
1571
|
+
if (true === scanToEnd) continue;
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
if (true === opts.noext) {
|
|
1576
|
+
isExtglob = false;
|
|
1577
|
+
isGlob = false;
|
|
1578
|
+
}
|
|
1579
|
+
let base = str;
|
|
1580
|
+
let prefix = '';
|
|
1581
|
+
let glob = '';
|
|
1582
|
+
if (start > 0) {
|
|
1583
|
+
prefix = str.slice(0, start);
|
|
1584
|
+
str = str.slice(start);
|
|
1585
|
+
lastIndex -= start;
|
|
1586
|
+
}
|
|
1587
|
+
if (base && true === isGlob && lastIndex > 0) {
|
|
1588
|
+
base = str.slice(0, lastIndex);
|
|
1589
|
+
glob = str.slice(lastIndex);
|
|
1590
|
+
} else if (true === isGlob) {
|
|
1591
|
+
base = '';
|
|
1592
|
+
glob = str;
|
|
1593
|
+
} else base = str;
|
|
1594
|
+
if (base && '' !== base && '/' !== base && base !== str) {
|
|
1595
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
1596
|
+
}
|
|
1597
|
+
if (true === opts.unescape) {
|
|
1598
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
1599
|
+
if (base && true === backslashes) base = utils.removeBackslashes(base);
|
|
1600
|
+
}
|
|
1601
|
+
const state = {
|
|
1602
|
+
prefix,
|
|
1603
|
+
input,
|
|
1604
|
+
start,
|
|
1605
|
+
base,
|
|
1606
|
+
glob,
|
|
1607
|
+
isBrace,
|
|
1608
|
+
isBracket,
|
|
1609
|
+
isGlob,
|
|
1610
|
+
isExtglob,
|
|
1611
|
+
isGlobstar,
|
|
1612
|
+
negated,
|
|
1613
|
+
negatedExtglob
|
|
1614
|
+
};
|
|
1615
|
+
if (true === opts.tokens) {
|
|
1616
|
+
state.maxDepth = 0;
|
|
1617
|
+
if (!isPathSeparator(code)) tokens.push(token);
|
|
1618
|
+
state.tokens = tokens;
|
|
1619
|
+
}
|
|
1620
|
+
if (true === opts.parts || true === opts.tokens) {
|
|
1621
|
+
let prevIndex;
|
|
1622
|
+
for(let idx = 0; idx < slashes.length; idx++){
|
|
1623
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
1624
|
+
const i = slashes[idx];
|
|
1625
|
+
const value = input.slice(n, i);
|
|
1626
|
+
if (opts.tokens) {
|
|
1627
|
+
if (0 === idx && 0 !== start) {
|
|
1628
|
+
tokens[idx].isPrefix = true;
|
|
1629
|
+
tokens[idx].value = prefix;
|
|
1630
|
+
} else tokens[idx].value = value;
|
|
1631
|
+
depth(tokens[idx]);
|
|
1632
|
+
state.maxDepth += tokens[idx].depth;
|
|
1633
|
+
}
|
|
1634
|
+
if (0 !== idx || '' !== value) parts.push(value);
|
|
1635
|
+
prevIndex = i;
|
|
1636
|
+
}
|
|
1637
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1638
|
+
const value = input.slice(prevIndex + 1);
|
|
1639
|
+
parts.push(value);
|
|
1640
|
+
if (opts.tokens) {
|
|
1641
|
+
tokens[tokens.length - 1].value = value;
|
|
1642
|
+
depth(tokens[tokens.length - 1]);
|
|
1643
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
state.slashes = slashes;
|
|
1647
|
+
state.parts = parts;
|
|
1648
|
+
}
|
|
1649
|
+
return state;
|
|
1650
|
+
};
|
|
1651
|
+
module.exports = scan;
|
|
1652
|
+
},
|
|
1653
|
+
"./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
1654
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
1655
|
+
exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
|
|
1656
|
+
exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
|
|
1657
|
+
exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
|
|
1658
|
+
exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
1659
|
+
exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/');
|
|
1660
|
+
exports.isWindows = ()=>{
|
|
1661
|
+
if ("u" > typeof navigator && navigator.platform) {
|
|
1662
|
+
const platform = navigator.platform.toLowerCase();
|
|
1663
|
+
return 'win32' === platform || 'windows' === platform;
|
|
1664
|
+
}
|
|
1665
|
+
if ("u" > typeof process && process.platform) return 'win32' === process.platform;
|
|
1666
|
+
return false;
|
|
1667
|
+
};
|
|
1668
|
+
exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match);
|
|
1669
|
+
exports.escapeLast = (input, char, lastIdx)=>{
|
|
1670
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
1671
|
+
if (-1 === idx) return input;
|
|
1672
|
+
if ('\\' === input[idx - 1]) return exports.escapeLast(input, char, idx - 1);
|
|
1673
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
1674
|
+
};
|
|
1675
|
+
exports.removePrefix = (input, state = {})=>{
|
|
1676
|
+
let output = input;
|
|
1677
|
+
if (output.startsWith('./')) {
|
|
1678
|
+
output = output.slice(2);
|
|
1679
|
+
state.prefix = './';
|
|
1680
|
+
}
|
|
1681
|
+
return output;
|
|
1682
|
+
};
|
|
1683
|
+
exports.wrapOutput = (input, state = {}, options = {})=>{
|
|
1684
|
+
const prepend = options.contains ? '' : '^';
|
|
1685
|
+
const append = options.contains ? '' : '$';
|
|
1686
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
1687
|
+
if (true === state.negated) output = `(?:^(?!${output}).*$)`;
|
|
1688
|
+
return output;
|
|
1689
|
+
};
|
|
1690
|
+
exports.basename = (path, { windows } = {})=>{
|
|
1691
|
+
const segs = path.split(windows ? /[\\/]/ : '/');
|
|
1692
|
+
const last = segs[segs.length - 1];
|
|
1693
|
+
if ('' === last) return segs[segs.length - 2];
|
|
1694
|
+
return last;
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
function checkNodeVersion() {
|
|
1699
|
+
const { versions } = process;
|
|
1700
|
+
if ("styleText" in node_util || !versions.node || versions.bun || versions.deno) return;
|
|
1701
|
+
throw new Error(`Unsupported Node.js version: "${process.versions.node || 'unknown'}". Expected Node.js >= 20.`);
|
|
1702
|
+
}
|
|
1703
|
+
checkNodeVersion();
|
|
1704
|
+
const createStyler = (style)=>(text)=>node_util.styleText(style, String(text));
|
|
1705
|
+
const color = {
|
|
1706
|
+
dim: createStyler('dim'),
|
|
1707
|
+
red: createStyler('red'),
|
|
1708
|
+
bold: createStyler('bold'),
|
|
1709
|
+
blue: createStyler('blue'),
|
|
1710
|
+
cyan: createStyler('cyan'),
|
|
1711
|
+
gray: createStyler('gray'),
|
|
1712
|
+
black: createStyler('black'),
|
|
1713
|
+
green: createStyler('green'),
|
|
1714
|
+
white: createStyler('white'),
|
|
1715
|
+
reset: createStyler('reset'),
|
|
1716
|
+
yellow: createStyler('yellow'),
|
|
1717
|
+
magenta: createStyler('magenta'),
|
|
1718
|
+
underline: createStyler('underline'),
|
|
1719
|
+
strikethrough: createStyler('strikethrough')
|
|
1720
|
+
};
|
|
1721
|
+
const supportsTrueColor = true === process.stdout.isTTY && process.stdout.hasColors(2 ** 24, process.env);
|
|
1722
|
+
const boldMint = (text)=>supportsTrueColor ? `\x1b[1;38;2;132;225;199m${text}\x1b[39;22m` : color.bold(color.cyan(text));
|
|
1723
|
+
const LOG_LEVEL = {
|
|
1724
|
+
silent: -1,
|
|
1725
|
+
error: 0,
|
|
1726
|
+
warn: 1,
|
|
1727
|
+
info: 2,
|
|
1728
|
+
log: 2,
|
|
1729
|
+
verbose: 3
|
|
1730
|
+
};
|
|
1731
|
+
const createLogType = (label, level, style)=>{
|
|
1732
|
+
let formattedLabel;
|
|
1733
|
+
return {
|
|
1734
|
+
get label () {
|
|
1735
|
+
return formattedLabel ??= color.bold(style(label.padEnd(7)));
|
|
1736
|
+
},
|
|
1737
|
+
level
|
|
1738
|
+
};
|
|
1739
|
+
};
|
|
1740
|
+
const LOG_TYPES = {
|
|
1741
|
+
error: createLogType('error', 'error', color.red),
|
|
1742
|
+
warn: createLogType('warn', 'warn', color.yellow),
|
|
1743
|
+
info: createLogType('info', 'info', color.cyan),
|
|
1744
|
+
start: createLogType('start', 'info', color.cyan),
|
|
1745
|
+
ready: createLogType('ready', 'info', color.green),
|
|
1746
|
+
success: createLogType('success', 'info', color.green),
|
|
1747
|
+
log: {
|
|
1748
|
+
level: 'info'
|
|
1749
|
+
},
|
|
1750
|
+
debug: createLogType('debug', 'verbose', color.magenta)
|
|
1751
|
+
};
|
|
1752
|
+
const ANSI_REGEXP = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, 'g');
|
|
1753
|
+
const stripAnsi = (text)=>text.replace(ANSI_REGEXP, '');
|
|
1754
|
+
const errorStackRegExp = /at [^\r\n]{0,200}(?::\d+:\d+[\s)]*|\(<anonymous>\)|\(index\s\d+\))$/;
|
|
1755
|
+
const isErrorStackMessage = (message)=>{
|
|
1756
|
+
const stripped = stripAnsi(message);
|
|
1757
|
+
return errorStackRegExp.test(stripped);
|
|
1758
|
+
};
|
|
1759
|
+
const normalizeErrorMessage = (err)=>{
|
|
1760
|
+
if (err.stack) {
|
|
1761
|
+
const [rawName, ...rest] = err.stack.split('\n');
|
|
1762
|
+
const name = rawName.startsWith('Error: ') ? rawName.slice(7) : rawName;
|
|
1763
|
+
return `${name}\n${color.gray(rest.join('\n'))}`;
|
|
1764
|
+
}
|
|
1765
|
+
return err.message;
|
|
1766
|
+
};
|
|
1767
|
+
const createLogger = (options = {})=>{
|
|
1768
|
+
const { level = 'info', prefix, console: console1 = globalThis.console, alignMultiline } = options;
|
|
1769
|
+
let maxLevel = level;
|
|
1770
|
+
const log = (type, message, ...args)=>{
|
|
1771
|
+
const logType = LOG_TYPES[type];
|
|
1772
|
+
const { level } = logType;
|
|
1773
|
+
if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
|
|
1774
|
+
if (null == message) return console1.log();
|
|
1775
|
+
const label = 'label' in logType ? logType.label : '';
|
|
1776
|
+
const header = label ? prefix ? `${label} ${prefix}` : label : prefix;
|
|
1777
|
+
let text = '';
|
|
1778
|
+
const isErrorObject = message instanceof Error;
|
|
1779
|
+
if (isErrorObject) {
|
|
1780
|
+
text += normalizeErrorMessage(message);
|
|
1781
|
+
const { cause } = message;
|
|
1782
|
+
if (cause) {
|
|
1783
|
+
text += color.yellow('\n [cause]: ');
|
|
1784
|
+
text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
|
|
1785
|
+
}
|
|
1786
|
+
} else if ('error' === level && 'string' == typeof message) {
|
|
1787
|
+
const lines = message.split('\n');
|
|
1788
|
+
text = lines.map((line)=>isErrorStackMessage(line) ? color.gray(line) : line).join('\n');
|
|
1789
|
+
} else text = `${message}`;
|
|
1790
|
+
if (alignMultiline && header && !isErrorObject && text.includes('\n')) {
|
|
1791
|
+
const indent = ' '.repeat(stripAnsi(header).length + 1);
|
|
1792
|
+
const skipStack = 'error' === level;
|
|
1793
|
+
text = text.split('\n').map((line, i)=>0 === i || '' === line || skipStack && isErrorStackMessage(line) ? line : indent + line).join('\n');
|
|
1794
|
+
}
|
|
1795
|
+
const method = 'error' === level || 'warn' === level ? level : 'log';
|
|
1796
|
+
console1[method](header ? `${header} ${text}` : text, ...args);
|
|
1797
|
+
};
|
|
1798
|
+
const logger = {
|
|
1799
|
+
greet: (message)=>log('log', boldMint(message))
|
|
1800
|
+
};
|
|
1801
|
+
Object.keys(LOG_TYPES).forEach((key)=>{
|
|
1802
|
+
logger[key] = (...args)=>log(key, ...args);
|
|
1803
|
+
});
|
|
1804
|
+
Object.defineProperty(logger, 'level', {
|
|
1805
|
+
get: ()=>maxLevel,
|
|
1806
|
+
set (val) {
|
|
1807
|
+
maxLevel = val;
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1810
|
+
Object.defineProperty(logger, 'options', {
|
|
1811
|
+
get: ()=>({
|
|
1812
|
+
...options
|
|
1813
|
+
})
|
|
1814
|
+
});
|
|
1815
|
+
logger.override = (customLogger)=>{
|
|
1816
|
+
Object.assign(logger, customLogger);
|
|
1817
|
+
};
|
|
1818
|
+
return logger;
|
|
1819
|
+
};
|
|
1820
|
+
const src_logger = createLogger();
|
|
1821
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
1822
|
+
function cleanPath(path) {
|
|
1823
|
+
let normalized = normalize(path);
|
|
1824
|
+
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
1825
|
+
return normalized;
|
|
1826
|
+
}
|
|
1827
|
+
const SLASHES_REGEX = /[\\/]/g;
|
|
1828
|
+
function convertSlashes(path, separator) {
|
|
1829
|
+
return path.replace(SLASHES_REGEX, separator);
|
|
1830
|
+
}
|
|
1831
|
+
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
1832
|
+
function isRootDirectory(path) {
|
|
1833
|
+
return "/" === path || WINDOWS_ROOT_DIR_REGEX.test(path);
|
|
1834
|
+
}
|
|
1835
|
+
function normalizePath(path, options) {
|
|
1836
|
+
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
1837
|
+
const pathNeedsCleaning = "win32" === process.platform && path.includes("/") || path.startsWith(".");
|
|
1838
|
+
if (resolvePaths) path = resolve(path);
|
|
1839
|
+
if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
|
|
1840
|
+
if ("." === path) return "";
|
|
1841
|
+
const needsSeperator = path[path.length - 1] !== pathSeparator;
|
|
1842
|
+
return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
|
|
1843
|
+
}
|
|
1844
|
+
function joinPathWithBasePath(filename, directoryPath) {
|
|
1845
|
+
return directoryPath + filename;
|
|
1846
|
+
}
|
|
1847
|
+
function joinPathWithRelativePath(root, options) {
|
|
1848
|
+
return function(filename, directoryPath) {
|
|
1849
|
+
const sameRoot = directoryPath.startsWith(root);
|
|
1850
|
+
if (sameRoot) return directoryPath.slice(root.length) + filename;
|
|
1851
|
+
return convertSlashes(external_path_relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
function joinPath(filename) {
|
|
1855
|
+
return filename;
|
|
1856
|
+
}
|
|
1857
|
+
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
1858
|
+
return directoryPath + filename + separator;
|
|
1859
|
+
}
|
|
1860
|
+
function build$7(root, options) {
|
|
1861
|
+
const { relativePaths, includeBasePath } = options;
|
|
1862
|
+
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
1863
|
+
}
|
|
1864
|
+
function pushDirectoryWithRelativePath(root) {
|
|
1865
|
+
return function(directoryPath, paths) {
|
|
1866
|
+
paths.push(directoryPath.substring(root.length) || ".");
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
function pushDirectoryFilterWithRelativePath(root) {
|
|
1870
|
+
return function(directoryPath, paths, filters) {
|
|
1871
|
+
const relativePath = directoryPath.substring(root.length) || ".";
|
|
1872
|
+
if (filters.every((filter)=>filter(relativePath, true))) paths.push(relativePath);
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
const pushDirectory = (directoryPath, paths)=>{
|
|
1876
|
+
paths.push(directoryPath || ".");
|
|
1877
|
+
};
|
|
1878
|
+
const pushDirectoryFilter = (directoryPath, paths, filters)=>{
|
|
1879
|
+
const path = directoryPath || ".";
|
|
1880
|
+
if (filters.every((filter)=>filter(path, true))) paths.push(path);
|
|
1881
|
+
};
|
|
1882
|
+
const empty$2 = ()=>{};
|
|
1883
|
+
function build$6(root, options) {
|
|
1884
|
+
const { includeDirs, filters, relativePaths } = options;
|
|
1885
|
+
if (!includeDirs) return empty$2;
|
|
1886
|
+
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
1887
|
+
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
1888
|
+
}
|
|
1889
|
+
const pushFileFilterAndCount = (filename, _paths, counts, filters)=>{
|
|
1890
|
+
if (filters.every((filter)=>filter(filename, false))) counts.files++;
|
|
1891
|
+
};
|
|
1892
|
+
const pushFileFilter = (filename, paths, _counts, filters)=>{
|
|
1893
|
+
if (filters.every((filter)=>filter(filename, false))) paths.push(filename);
|
|
1894
|
+
};
|
|
1895
|
+
const pushFileCount = (_filename, _paths, counts, _filters)=>{
|
|
1896
|
+
counts.files++;
|
|
1897
|
+
};
|
|
1898
|
+
const pushFile = (filename, paths)=>{
|
|
1899
|
+
paths.push(filename);
|
|
1900
|
+
};
|
|
1901
|
+
const empty$1 = ()=>{};
|
|
1902
|
+
function build$5(options) {
|
|
1903
|
+
const { excludeFiles, filters, onlyCounts } = options;
|
|
1904
|
+
if (excludeFiles) return empty$1;
|
|
1905
|
+
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
1906
|
+
if (onlyCounts) return pushFileCount;
|
|
1907
|
+
return pushFile;
|
|
1908
|
+
}
|
|
1909
|
+
const getArray = (paths)=>paths;
|
|
1910
|
+
const getArrayGroup = ()=>[
|
|
1911
|
+
""
|
|
1912
|
+
].slice(0, 0);
|
|
1913
|
+
function build$4(options) {
|
|
1914
|
+
return options.group ? getArrayGroup : getArray;
|
|
1915
|
+
}
|
|
1916
|
+
const groupFiles = (groups, directory, files)=>{
|
|
1917
|
+
groups.push({
|
|
1918
|
+
directory,
|
|
1919
|
+
files,
|
|
1920
|
+
dir: directory
|
|
1921
|
+
});
|
|
1922
|
+
};
|
|
1923
|
+
const empty = ()=>{};
|
|
1924
|
+
function build$3(options) {
|
|
1925
|
+
return options.group ? groupFiles : empty;
|
|
1926
|
+
}
|
|
1927
|
+
const resolveSymlinksAsync = function(path, state, callback$1) {
|
|
1928
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
1929
|
+
queue.enqueue();
|
|
1930
|
+
fs.realpath(path, (error, resolvedPath)=>{
|
|
1931
|
+
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
1932
|
+
fs.stat(resolvedPath, (error$1, stat)=>{
|
|
1933
|
+
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
1934
|
+
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
|
|
1935
|
+
callback$1(stat, resolvedPath);
|
|
1936
|
+
queue.dequeue(null, state);
|
|
1937
|
+
});
|
|
1938
|
+
});
|
|
1939
|
+
};
|
|
1940
|
+
const resolveSymlinks = function(path, state, callback$1) {
|
|
1941
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
1942
|
+
queue.enqueue();
|
|
1943
|
+
try {
|
|
1944
|
+
const resolvedPath = fs.realpathSync(path);
|
|
1945
|
+
const stat = fs.statSync(resolvedPath);
|
|
1946
|
+
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
|
|
1947
|
+
callback$1(stat, resolvedPath);
|
|
1948
|
+
} catch (e) {
|
|
1949
|
+
if (!suppressErrors) throw e;
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
function build$2(options, isSynchronous) {
|
|
1953
|
+
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
1954
|
+
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
1955
|
+
}
|
|
1956
|
+
function isRecursive(path, resolved, state) {
|
|
1957
|
+
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
1958
|
+
let parent = dirname(path);
|
|
1959
|
+
let depth = 1;
|
|
1960
|
+
while(parent !== state.root && depth < 2){
|
|
1961
|
+
const resolvedPath = state.symlinks.get(parent);
|
|
1962
|
+
const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
|
|
1963
|
+
if (isSameRoot) depth++;
|
|
1964
|
+
else parent = dirname(parent);
|
|
1965
|
+
}
|
|
1966
|
+
state.symlinks.set(path, resolved);
|
|
1967
|
+
return depth > 1;
|
|
1968
|
+
}
|
|
1969
|
+
function isRecursiveUsingRealPaths(resolved, state) {
|
|
1970
|
+
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
1971
|
+
}
|
|
1972
|
+
const onlyCountsSync = (state)=>state.counts;
|
|
1973
|
+
const groupsSync = (state)=>state.groups;
|
|
1974
|
+
const defaultSync = (state)=>state.paths;
|
|
1975
|
+
const limitFilesSync = (state)=>state.paths.slice(0, state.options.maxFiles);
|
|
1976
|
+
const onlyCountsAsync = (state, error, callback$1)=>{
|
|
1977
|
+
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
1978
|
+
return null;
|
|
1979
|
+
};
|
|
1980
|
+
const defaultAsync = (state, error, callback$1)=>{
|
|
1981
|
+
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
1982
|
+
return null;
|
|
1983
|
+
};
|
|
1984
|
+
const limitFilesAsync = (state, error, callback$1)=>{
|
|
1985
|
+
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
1986
|
+
return null;
|
|
1987
|
+
};
|
|
1988
|
+
const groupsAsync = (state, error, callback$1)=>{
|
|
1989
|
+
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
1990
|
+
return null;
|
|
1991
|
+
};
|
|
1992
|
+
function report(error, callback$1, output, suppressErrors) {
|
|
1993
|
+
callback$1(error && !suppressErrors ? error : null, output);
|
|
1994
|
+
}
|
|
1995
|
+
function build$1(options, isSynchronous) {
|
|
1996
|
+
const { onlyCounts, group, maxFiles } = options;
|
|
1997
|
+
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
1998
|
+
if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
1999
|
+
if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
2000
|
+
return isSynchronous ? defaultSync : defaultAsync;
|
|
2001
|
+
}
|
|
2002
|
+
const readdirOpts = {
|
|
2003
|
+
withFileTypes: true
|
|
2004
|
+
};
|
|
2005
|
+
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
|
|
2006
|
+
state.queue.enqueue();
|
|
2007
|
+
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
2008
|
+
const { fs } = state;
|
|
2009
|
+
state.visited.push(crawlPath);
|
|
2010
|
+
state.counts.directories++;
|
|
2011
|
+
fs.readdir(crawlPath || ".", readdirOpts, (error, entries = [])=>{
|
|
2012
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
2013
|
+
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
2014
|
+
});
|
|
2015
|
+
};
|
|
2016
|
+
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
|
|
2017
|
+
const { fs } = state;
|
|
2018
|
+
if (currentDepth < 0) return;
|
|
2019
|
+
state.visited.push(crawlPath);
|
|
2020
|
+
state.counts.directories++;
|
|
2021
|
+
let entries = [];
|
|
2022
|
+
try {
|
|
2023
|
+
entries = fs.readdirSync(crawlPath || ".", readdirOpts);
|
|
2024
|
+
} catch (e) {
|
|
2025
|
+
if (!state.options.suppressErrors) throw e;
|
|
2026
|
+
}
|
|
2027
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
2028
|
+
};
|
|
2029
|
+
function build(isSynchronous) {
|
|
2030
|
+
return isSynchronous ? walkSync : walkAsync;
|
|
2031
|
+
}
|
|
2032
|
+
var Queue = class {
|
|
2033
|
+
count = 0;
|
|
2034
|
+
constructor(onQueueEmpty){
|
|
2035
|
+
this.onQueueEmpty = onQueueEmpty;
|
|
2036
|
+
}
|
|
2037
|
+
enqueue() {
|
|
2038
|
+
this.count++;
|
|
2039
|
+
return this.count;
|
|
2040
|
+
}
|
|
2041
|
+
dequeue(error, output) {
|
|
2042
|
+
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
2043
|
+
this.onQueueEmpty(error, output);
|
|
2044
|
+
if (error) {
|
|
2045
|
+
output.controller.abort();
|
|
2046
|
+
this.onQueueEmpty = void 0;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
var Counter = class {
|
|
2052
|
+
_files = 0;
|
|
2053
|
+
_directories = 0;
|
|
2054
|
+
set files(num) {
|
|
2055
|
+
this._files = num;
|
|
2056
|
+
}
|
|
2057
|
+
get files() {
|
|
2058
|
+
return this._files;
|
|
2059
|
+
}
|
|
2060
|
+
set directories(num) {
|
|
2061
|
+
this._directories = num;
|
|
2062
|
+
}
|
|
2063
|
+
get directories() {
|
|
2064
|
+
return this._directories;
|
|
2065
|
+
}
|
|
2066
|
+
get dirs() {
|
|
2067
|
+
return this._directories;
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2070
|
+
var Aborter = class {
|
|
2071
|
+
aborted = false;
|
|
2072
|
+
abort() {
|
|
2073
|
+
this.aborted = true;
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
var Walker = class {
|
|
2077
|
+
root;
|
|
2078
|
+
isSynchronous;
|
|
2079
|
+
state;
|
|
2080
|
+
joinPath;
|
|
2081
|
+
pushDirectory;
|
|
2082
|
+
pushFile;
|
|
2083
|
+
getArray;
|
|
2084
|
+
groupFiles;
|
|
2085
|
+
resolveSymlink;
|
|
2086
|
+
walkDirectory;
|
|
2087
|
+
callbackInvoker;
|
|
2088
|
+
constructor(root, options, callback$1){
|
|
2089
|
+
this.isSynchronous = !callback$1;
|
|
2090
|
+
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
2091
|
+
this.root = normalizePath(root, options);
|
|
2092
|
+
this.state = {
|
|
2093
|
+
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
2094
|
+
paths: [
|
|
2095
|
+
""
|
|
2096
|
+
].slice(0, 0),
|
|
2097
|
+
groups: [],
|
|
2098
|
+
counts: new Counter(),
|
|
2099
|
+
options,
|
|
2100
|
+
queue: new Queue((error, state)=>this.callbackInvoker(state, error, callback$1)),
|
|
2101
|
+
symlinks: /* @__PURE__ */ new Map(),
|
|
2102
|
+
visited: [
|
|
2103
|
+
""
|
|
2104
|
+
].slice(0, 0),
|
|
2105
|
+
controller: new Aborter(),
|
|
2106
|
+
fs: options.fs || __rspack_external_fs
|
|
2107
|
+
};
|
|
2108
|
+
this.joinPath = build$7(this.root, options);
|
|
2109
|
+
this.pushDirectory = build$6(this.root, options);
|
|
2110
|
+
this.pushFile = build$5(options);
|
|
2111
|
+
this.getArray = build$4(options);
|
|
2112
|
+
this.groupFiles = build$3(options);
|
|
2113
|
+
this.resolveSymlink = build$2(options, this.isSynchronous);
|
|
2114
|
+
this.walkDirectory = build(this.isSynchronous);
|
|
2115
|
+
}
|
|
2116
|
+
start() {
|
|
2117
|
+
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
2118
|
+
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
2119
|
+
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
2120
|
+
}
|
|
2121
|
+
walk = (entries, directoryPath, depth)=>{
|
|
2122
|
+
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
2123
|
+
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
2124
|
+
const files = this.getArray(this.state.paths);
|
|
2125
|
+
for(let i = 0; i < entries.length; ++i){
|
|
2126
|
+
const entry = entries[i];
|
|
2127
|
+
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
2128
|
+
const filename = this.joinPath(entry.name, directoryPath);
|
|
2129
|
+
this.pushFile(filename, files, this.state.counts, filters);
|
|
2130
|
+
} else if (entry.isDirectory()) {
|
|
2131
|
+
let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
2132
|
+
if (exclude && exclude(entry.name, path)) continue;
|
|
2133
|
+
this.pushDirectory(path, paths, filters);
|
|
2134
|
+
this.walkDirectory(this.state, path, path, depth - 1, this.walk);
|
|
2135
|
+
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
2136
|
+
let path = joinPathWithBasePath(entry.name, directoryPath);
|
|
2137
|
+
this.resolveSymlink(path, this.state, (stat, resolvedPath)=>{
|
|
2138
|
+
if (stat.isDirectory()) {
|
|
2139
|
+
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
2140
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
|
|
2141
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
|
|
2142
|
+
} else {
|
|
2143
|
+
resolvedPath = useRealPaths ? resolvedPath : path;
|
|
2144
|
+
const filename = basename(resolvedPath);
|
|
2145
|
+
const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
|
|
2146
|
+
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
2147
|
+
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
2148
|
+
}
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
this.groupFiles(this.state.groups, directoryPath, files);
|
|
2153
|
+
};
|
|
2154
|
+
};
|
|
2155
|
+
function promise(root, options) {
|
|
2156
|
+
return new Promise((resolve$1, reject)=>{
|
|
2157
|
+
callback(root, options, (err, output)=>{
|
|
2158
|
+
if (err) return reject(err);
|
|
2159
|
+
resolve$1(output);
|
|
2160
|
+
});
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
function callback(root, options, callback$1) {
|
|
2164
|
+
let walker = new Walker(root, options, callback$1);
|
|
2165
|
+
walker.start();
|
|
2166
|
+
}
|
|
2167
|
+
function sync(root, options) {
|
|
2168
|
+
const walker = new Walker(root, options);
|
|
2169
|
+
return walker.start();
|
|
2170
|
+
}
|
|
2171
|
+
var APIBuilder = class {
|
|
2172
|
+
constructor(root, options){
|
|
2173
|
+
this.root = root;
|
|
2174
|
+
this.options = options;
|
|
2175
|
+
}
|
|
2176
|
+
withPromise() {
|
|
2177
|
+
return promise(this.root, this.options);
|
|
2178
|
+
}
|
|
2179
|
+
withCallback(cb) {
|
|
2180
|
+
callback(this.root, this.options, cb);
|
|
2181
|
+
}
|
|
2182
|
+
sync() {
|
|
2183
|
+
return sync(this.root, this.options);
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
2186
|
+
let pm = null;
|
|
2187
|
+
try {
|
|
2188
|
+
__require.resolve("picomatch");
|
|
2189
|
+
pm = __require("picomatch");
|
|
2190
|
+
} catch {}
|
|
2191
|
+
var Builder = class {
|
|
2192
|
+
globCache = {};
|
|
2193
|
+
options = {
|
|
2194
|
+
maxDepth: 1 / 0,
|
|
2195
|
+
suppressErrors: true,
|
|
2196
|
+
pathSeparator: sep,
|
|
2197
|
+
filters: []
|
|
2198
|
+
};
|
|
2199
|
+
globFunction;
|
|
2200
|
+
constructor(options){
|
|
2201
|
+
this.options = {
|
|
2202
|
+
...this.options,
|
|
2203
|
+
...options
|
|
2204
|
+
};
|
|
2205
|
+
this.globFunction = this.options.globFunction;
|
|
2206
|
+
}
|
|
2207
|
+
group() {
|
|
2208
|
+
this.options.group = true;
|
|
2209
|
+
return this;
|
|
2210
|
+
}
|
|
2211
|
+
withPathSeparator(separator) {
|
|
2212
|
+
this.options.pathSeparator = separator;
|
|
2213
|
+
return this;
|
|
2214
|
+
}
|
|
2215
|
+
withBasePath() {
|
|
2216
|
+
this.options.includeBasePath = true;
|
|
2217
|
+
return this;
|
|
2218
|
+
}
|
|
2219
|
+
withRelativePaths() {
|
|
2220
|
+
this.options.relativePaths = true;
|
|
2221
|
+
return this;
|
|
2222
|
+
}
|
|
2223
|
+
withDirs() {
|
|
2224
|
+
this.options.includeDirs = true;
|
|
2225
|
+
return this;
|
|
2226
|
+
}
|
|
2227
|
+
withMaxDepth(depth) {
|
|
2228
|
+
this.options.maxDepth = depth;
|
|
2229
|
+
return this;
|
|
2230
|
+
}
|
|
2231
|
+
withMaxFiles(limit) {
|
|
2232
|
+
this.options.maxFiles = limit;
|
|
2233
|
+
return this;
|
|
2234
|
+
}
|
|
2235
|
+
withFullPaths() {
|
|
2236
|
+
this.options.resolvePaths = true;
|
|
2237
|
+
this.options.includeBasePath = true;
|
|
2238
|
+
return this;
|
|
2239
|
+
}
|
|
2240
|
+
withErrors() {
|
|
2241
|
+
this.options.suppressErrors = false;
|
|
2242
|
+
return this;
|
|
2243
|
+
}
|
|
2244
|
+
withSymlinks({ resolvePaths = true } = {}) {
|
|
2245
|
+
this.options.resolveSymlinks = true;
|
|
2246
|
+
this.options.useRealPaths = resolvePaths;
|
|
2247
|
+
return this.withFullPaths();
|
|
2248
|
+
}
|
|
2249
|
+
withAbortSignal(signal) {
|
|
2250
|
+
this.options.signal = signal;
|
|
2251
|
+
return this;
|
|
2252
|
+
}
|
|
2253
|
+
normalize() {
|
|
2254
|
+
this.options.normalizePath = true;
|
|
2255
|
+
return this;
|
|
2256
|
+
}
|
|
2257
|
+
filter(predicate) {
|
|
2258
|
+
this.options.filters.push(predicate);
|
|
2259
|
+
return this;
|
|
2260
|
+
}
|
|
2261
|
+
onlyDirs() {
|
|
2262
|
+
this.options.excludeFiles = true;
|
|
2263
|
+
this.options.includeDirs = true;
|
|
2264
|
+
return this;
|
|
2265
|
+
}
|
|
2266
|
+
exclude(predicate) {
|
|
2267
|
+
this.options.exclude = predicate;
|
|
2268
|
+
return this;
|
|
2269
|
+
}
|
|
2270
|
+
onlyCounts() {
|
|
2271
|
+
this.options.onlyCounts = true;
|
|
2272
|
+
return this;
|
|
2273
|
+
}
|
|
2274
|
+
crawl(root) {
|
|
2275
|
+
return new APIBuilder(root || ".", this.options);
|
|
2276
|
+
}
|
|
2277
|
+
withGlobFunction(fn) {
|
|
2278
|
+
this.globFunction = fn;
|
|
2279
|
+
return this;
|
|
2280
|
+
}
|
|
2281
|
+
crawlWithOptions(root, options) {
|
|
2282
|
+
this.options = {
|
|
2283
|
+
...this.options,
|
|
2284
|
+
...options
|
|
2285
|
+
};
|
|
2286
|
+
return new APIBuilder(root || ".", this.options);
|
|
2287
|
+
}
|
|
2288
|
+
glob(...patterns) {
|
|
2289
|
+
if (this.globFunction) return this.globWithOptions(patterns);
|
|
2290
|
+
return this.globWithOptions(patterns, {
|
|
2291
|
+
dot: true
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
globWithOptions(patterns, ...options) {
|
|
2295
|
+
const globFn = this.globFunction || pm;
|
|
2296
|
+
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
2297
|
+
var isMatch = this.globCache[patterns.join("\0")];
|
|
2298
|
+
if (!isMatch) {
|
|
2299
|
+
isMatch = globFn(patterns, ...options);
|
|
2300
|
+
this.globCache[patterns.join("\0")] = isMatch;
|
|
2301
|
+
}
|
|
2302
|
+
this.options.filters.push((path)=>isMatch(path));
|
|
2303
|
+
return this;
|
|
2304
|
+
}
|
|
2305
|
+
};
|
|
2306
|
+
const picomatch = __webpack_require__("./node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
|
|
2307
|
+
const isReadonlyArray = Array.isArray;
|
|
2308
|
+
const BACKSLASHES = /\\/g;
|
|
2309
|
+
const DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
|
|
2310
|
+
const isWin = "win32" === process.platform;
|
|
2311
|
+
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
2312
|
+
function getPartialMatcher(patterns, options = {}) {
|
|
2313
|
+
const patternsCount = patterns.length;
|
|
2314
|
+
const patternsParts = Array(patternsCount);
|
|
2315
|
+
const matchers = Array(patternsCount);
|
|
2316
|
+
let i, j;
|
|
2317
|
+
for(i = 0; i < patternsCount; i++){
|
|
2318
|
+
const parts = splitPattern(patterns[i]);
|
|
2319
|
+
patternsParts[i] = parts;
|
|
2320
|
+
const partsCount = parts.length;
|
|
2321
|
+
const partMatchers = Array(partsCount);
|
|
2322
|
+
for(j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
|
|
2323
|
+
matchers[i] = partMatchers;
|
|
2324
|
+
}
|
|
2325
|
+
return (input)=>{
|
|
2326
|
+
const inputParts = input.split("/");
|
|
2327
|
+
if (".." === inputParts[0] && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
|
2328
|
+
for(i = 0; i < patternsCount; i++){
|
|
2329
|
+
const patternParts = patternsParts[i];
|
|
2330
|
+
const matcher = matchers[i];
|
|
2331
|
+
const inputPatternCount = inputParts.length;
|
|
2332
|
+
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
2333
|
+
j = 0;
|
|
2334
|
+
while(j < minParts){
|
|
2335
|
+
const part = patternParts[j];
|
|
2336
|
+
if (part.includes("/")) return true;
|
|
2337
|
+
if (!matcher[j](inputParts[j])) break;
|
|
2338
|
+
if (!options.noglobstar && "**" === part) return true;
|
|
2339
|
+
j++;
|
|
2340
|
+
}
|
|
2341
|
+
if (j === inputPatternCount) return true;
|
|
2342
|
+
}
|
|
2343
|
+
return false;
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2346
|
+
const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
|
|
2347
|
+
const isRoot = isWin ? (p)=>WIN32_ROOT_DIR.test(p) : (p)=>"/" === p;
|
|
2348
|
+
function buildFormat(cwd, root, absolute) {
|
|
2349
|
+
if (cwd === root || root.startsWith(`${cwd}/`)) {
|
|
2350
|
+
if (absolute) {
|
|
2351
|
+
const start = cwd.length + +!isRoot(cwd);
|
|
2352
|
+
return (p, isDir)=>p.slice(start, isDir ? -1 : void 0) || ".";
|
|
2353
|
+
}
|
|
2354
|
+
const prefix = root.slice(cwd.length + 1);
|
|
2355
|
+
if (prefix) return (p, isDir)=>{
|
|
2356
|
+
if ("." === p) return prefix;
|
|
2357
|
+
const result = `${prefix}/${p}`;
|
|
2358
|
+
return isDir ? result.slice(0, -1) : result;
|
|
2359
|
+
};
|
|
2360
|
+
return (p, isDir)=>isDir && "." !== p ? p.slice(0, -1) : p;
|
|
2361
|
+
}
|
|
2362
|
+
if (absolute) return (p)=>posix.relative(cwd, p) || ".";
|
|
2363
|
+
return (p)=>posix.relative(cwd, `${root}/${p}`) || ".";
|
|
2364
|
+
}
|
|
2365
|
+
function buildRelative(cwd, root) {
|
|
2366
|
+
if (root.startsWith(`${cwd}/`)) {
|
|
2367
|
+
const prefix = root.slice(cwd.length + 1);
|
|
2368
|
+
return (p)=>`${prefix}/${p}`;
|
|
2369
|
+
}
|
|
2370
|
+
return (p)=>{
|
|
2371
|
+
const result = posix.relative(cwd, `${root}/${p}`);
|
|
2372
|
+
return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2375
|
+
function ensureNonDriveRelativePath(path) {
|
|
2376
|
+
return path.replace(DRIVE_RELATIVE_PATH, (match)=>`${match}/`);
|
|
2377
|
+
}
|
|
2378
|
+
const splitPatternOptions = {
|
|
2379
|
+
parts: true
|
|
2380
|
+
};
|
|
2381
|
+
function splitPattern(path) {
|
|
2382
|
+
var _result$parts;
|
|
2383
|
+
const result = picomatch.scan(path, splitPatternOptions);
|
|
2384
|
+
return (null == (_result$parts = result.parts) ? void 0 : _result$parts.length) ? result.parts : [
|
|
2385
|
+
path
|
|
2386
|
+
];
|
|
2387
|
+
}
|
|
2388
|
+
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
2389
|
+
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
2390
|
+
const escapePosixPath = (path)=>path.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2391
|
+
const escapeWin32Path = (path)=>path.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2392
|
+
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
2393
|
+
function isDynamicPattern(pattern, options) {
|
|
2394
|
+
if ((null == options ? void 0 : options.caseSensitiveMatch) === false) return true;
|
|
2395
|
+
const scan = picomatch.scan(pattern);
|
|
2396
|
+
return scan.isGlob || scan.negated;
|
|
2397
|
+
}
|
|
2398
|
+
function dist_log(...tasks) {
|
|
2399
|
+
console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
|
|
2400
|
+
}
|
|
2401
|
+
function ensureStringArray(value) {
|
|
2402
|
+
return "string" == typeof value ? [
|
|
2403
|
+
value
|
|
2404
|
+
] : null != value ? value : [];
|
|
2405
|
+
}
|
|
2406
|
+
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
2407
|
+
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
2408
|
+
function normalizePattern(pattern, opts, props, isIgnore) {
|
|
2409
|
+
var _PARENT_DIRECTORY$exe;
|
|
2410
|
+
const cwd = opts.cwd;
|
|
2411
|
+
let result = pattern;
|
|
2412
|
+
if ("/" === pattern[pattern.length - 1]) result = pattern.slice(0, -1);
|
|
2413
|
+
if ("*" !== result[result.length - 1] && opts.expandDirectories) result += "/**";
|
|
2414
|
+
const escapedCwd = escapePath(cwd);
|
|
2415
|
+
result = isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
|
|
2416
|
+
const parentDir = null == (_PARENT_DIRECTORY$exe = PARENT_DIRECTORY.exec(result)) ? void 0 : _PARENT_DIRECTORY$exe[0];
|
|
2417
|
+
const parts = splitPattern(result);
|
|
2418
|
+
if (parentDir) {
|
|
2419
|
+
const n = (parentDir.length + 1) / 3;
|
|
2420
|
+
let i = 0;
|
|
2421
|
+
const cwdParts = escapedCwd.split("/");
|
|
2422
|
+
while(i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]){
|
|
2423
|
+
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
2424
|
+
i++;
|
|
2425
|
+
}
|
|
2426
|
+
const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
|
|
2427
|
+
if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
|
|
2428
|
+
props.root = ensureNonDriveRelativePath(potentialRoot);
|
|
2429
|
+
props.depthOffset = -n + i;
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
if (!isIgnore && props.depthOffset >= 0) {
|
|
2433
|
+
null != props.commonPath || (props.commonPath = parts);
|
|
2434
|
+
const newCommonPath = [];
|
|
2435
|
+
const length = Math.min(props.commonPath.length, parts.length);
|
|
2436
|
+
for(let i = 0; i < length; i++){
|
|
2437
|
+
const part = parts[i];
|
|
2438
|
+
if ("**" === part && !parts[i + 1]) {
|
|
2439
|
+
newCommonPath.pop();
|
|
2440
|
+
break;
|
|
2441
|
+
}
|
|
2442
|
+
if (i === parts.length - 1 || part !== props.commonPath[i] || isDynamicPattern(part)) break;
|
|
2443
|
+
newCommonPath.push(part);
|
|
2444
|
+
}
|
|
2445
|
+
props.depthOffset = newCommonPath.length;
|
|
2446
|
+
props.commonPath = newCommonPath;
|
|
2447
|
+
props.root = ensureNonDriveRelativePath(newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd);
|
|
2448
|
+
}
|
|
2449
|
+
return result;
|
|
2450
|
+
}
|
|
2451
|
+
function processPatterns(options, patterns, props) {
|
|
2452
|
+
const matchPatterns = [];
|
|
2453
|
+
const ignorePatterns = [];
|
|
2454
|
+
for (const pattern of options.ignore)if (pattern) {
|
|
2455
|
+
if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, options, props, true));
|
|
2456
|
+
}
|
|
2457
|
+
for (const pattern of patterns)if (pattern) {
|
|
2458
|
+
if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, options, props, false));
|
|
2459
|
+
else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), options, props, true));
|
|
2460
|
+
}
|
|
2461
|
+
return {
|
|
2462
|
+
match: matchPatterns,
|
|
2463
|
+
ignore: ignorePatterns
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2466
|
+
function buildCrawler(options, patterns) {
|
|
2467
|
+
const cwd = options.cwd;
|
|
2468
|
+
const props = {
|
|
2469
|
+
root: cwd,
|
|
2470
|
+
depthOffset: 0
|
|
2471
|
+
};
|
|
2472
|
+
const processed = processPatterns(options, patterns, props);
|
|
2473
|
+
if (options.debug) dist_log("internal processing patterns:", processed);
|
|
2474
|
+
const { absolute, caseSensitiveMatch, debug, dot, followSymbolicLinks, onlyDirectories } = options;
|
|
2475
|
+
const root = props.root.replace(BACKSLASHES, "");
|
|
2476
|
+
const matchOptions = {
|
|
2477
|
+
dot,
|
|
2478
|
+
nobrace: false === options.braceExpansion,
|
|
2479
|
+
nocase: !caseSensitiveMatch,
|
|
2480
|
+
noextglob: false === options.extglob,
|
|
2481
|
+
noglobstar: false === options.globstar,
|
|
2482
|
+
posix: true
|
|
2483
|
+
};
|
|
2484
|
+
const matcher = picomatch(processed.match, matchOptions);
|
|
2485
|
+
const ignore = picomatch(processed.ignore, matchOptions);
|
|
2486
|
+
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
|
2487
|
+
const format = buildFormat(cwd, root, absolute);
|
|
2488
|
+
const excludeFormatter = absolute ? format : buildFormat(cwd, root, true);
|
|
2489
|
+
const excludePredicate = (_, p)=>{
|
|
2490
|
+
const relativePath = excludeFormatter(p, true);
|
|
2491
|
+
return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2492
|
+
};
|
|
2493
|
+
let maxDepth;
|
|
2494
|
+
if (void 0 !== options.deep) maxDepth = Math.round(options.deep - props.depthOffset);
|
|
2495
|
+
const crawler = new Builder({
|
|
2496
|
+
filters: [
|
|
2497
|
+
debug ? (p, isDirectory)=>{
|
|
2498
|
+
const path = format(p, isDirectory);
|
|
2499
|
+
const matches = matcher(path) && !ignore(path);
|
|
2500
|
+
if (matches) dist_log(`matched ${path}`);
|
|
2501
|
+
return matches;
|
|
2502
|
+
} : (p, isDirectory)=>{
|
|
2503
|
+
const path = format(p, isDirectory);
|
|
2504
|
+
return matcher(path) && !ignore(path);
|
|
2505
|
+
}
|
|
2506
|
+
],
|
|
2507
|
+
exclude: debug ? (_, p)=>{
|
|
2508
|
+
const skipped = excludePredicate(_, p);
|
|
2509
|
+
dist_log(`${skipped ? "skipped" : "crawling"} ${p}`);
|
|
2510
|
+
return skipped;
|
|
2511
|
+
} : excludePredicate,
|
|
2512
|
+
fs: options.fs,
|
|
2513
|
+
pathSeparator: "/",
|
|
2514
|
+
relativePaths: !absolute,
|
|
2515
|
+
resolvePaths: absolute,
|
|
2516
|
+
includeBasePath: absolute,
|
|
2517
|
+
resolveSymlinks: followSymbolicLinks,
|
|
2518
|
+
excludeSymlinks: !followSymbolicLinks,
|
|
2519
|
+
excludeFiles: onlyDirectories,
|
|
2520
|
+
includeDirs: onlyDirectories || !options.onlyFiles,
|
|
2521
|
+
maxDepth,
|
|
2522
|
+
signal: options.signal
|
|
2523
|
+
}).crawl(root);
|
|
2524
|
+
if (options.debug) dist_log("internal properties:", {
|
|
2525
|
+
...props,
|
|
2526
|
+
root
|
|
2527
|
+
});
|
|
2528
|
+
return [
|
|
2529
|
+
crawler,
|
|
2530
|
+
cwd !== root && !absolute && buildRelative(cwd, root)
|
|
2531
|
+
];
|
|
2532
|
+
}
|
|
2533
|
+
function formatPaths(paths, mapper) {
|
|
2534
|
+
if (mapper) for(let i = paths.length - 1; i >= 0; i--)paths[i] = mapper(paths[i]);
|
|
2535
|
+
return paths;
|
|
2536
|
+
}
|
|
2537
|
+
const defaultOptions = {
|
|
2538
|
+
caseSensitiveMatch: true,
|
|
2539
|
+
debug: !!process.env.TINYGLOBBY_DEBUG,
|
|
2540
|
+
expandDirectories: true,
|
|
2541
|
+
followSymbolicLinks: true,
|
|
2542
|
+
onlyFiles: true
|
|
2543
|
+
};
|
|
2544
|
+
function getOptions(options) {
|
|
2545
|
+
const opts = Object.assign({}, options);
|
|
2546
|
+
for(const key in defaultOptions)if (void 0 === opts[key]) Object.assign(opts, {
|
|
2547
|
+
[key]: defaultOptions[key]
|
|
2548
|
+
});
|
|
2549
|
+
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd || process.cwd())).replace(BACKSLASHES, "/");
|
|
2550
|
+
opts.ignore = ensureStringArray(opts.ignore);
|
|
2551
|
+
opts.fs && (opts.fs = {
|
|
2552
|
+
readdir: opts.fs.readdir || readdir,
|
|
2553
|
+
readdirSync: opts.fs.readdirSync || readdirSync,
|
|
2554
|
+
realpath: opts.fs.realpath || realpath,
|
|
2555
|
+
realpathSync: opts.fs.realpathSync || realpathSync,
|
|
2556
|
+
stat: opts.fs.stat || external_fs_stat,
|
|
2557
|
+
statSync: opts.fs.statSync || statSync
|
|
2558
|
+
});
|
|
2559
|
+
if (opts.debug) dist_log("globbing with options:", opts);
|
|
2560
|
+
return opts;
|
|
2561
|
+
}
|
|
2562
|
+
function getCrawler(globInput, inputOptions = {}) {
|
|
2563
|
+
var _ref;
|
|
2564
|
+
if (globInput && (null == inputOptions ? void 0 : inputOptions.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2565
|
+
const isModern = isReadonlyArray(globInput) || "string" == typeof globInput;
|
|
2566
|
+
const patterns = ensureStringArray(null != (_ref = isModern ? globInput : globInput.patterns) ? _ref : "**/*");
|
|
2567
|
+
const options = getOptions(isModern ? inputOptions : globInput);
|
|
2568
|
+
return patterns.length > 0 ? buildCrawler(options, patterns) : [];
|
|
2569
|
+
}
|
|
2570
|
+
async function glob(globInput, options) {
|
|
2571
|
+
const [crawler, relative] = getCrawler(globInput, options);
|
|
2572
|
+
return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
|
|
2573
|
+
}
|
|
2574
|
+
const picocolors = __webpack_require__("./node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
2575
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
2576
|
+
const DEFAULT_IGNORE = [
|
|
2577
|
+
'**/node_modules',
|
|
2578
|
+
'**/dist',
|
|
2579
|
+
'**/.git',
|
|
2580
|
+
'**/.cache',
|
|
2581
|
+
'**/temp'
|
|
2582
|
+
];
|
|
2583
|
+
function getGitIgnorePatterns(cwd) {
|
|
2584
|
+
try {
|
|
2585
|
+
const stdout = execFileSync('git', [
|
|
2586
|
+
'ls-files',
|
|
2587
|
+
'--others',
|
|
2588
|
+
'--ignored',
|
|
2589
|
+
'--exclude-standard',
|
|
2590
|
+
'--directory',
|
|
2591
|
+
'-z'
|
|
2592
|
+
], {
|
|
2593
|
+
cwd,
|
|
2594
|
+
encoding: 'utf8',
|
|
2595
|
+
stdio: [
|
|
2596
|
+
'ignore',
|
|
2597
|
+
'pipe',
|
|
2598
|
+
'ignore'
|
|
2599
|
+
]
|
|
2600
|
+
});
|
|
2601
|
+
return stdout.split('\0').filter(Boolean).map((path)=>escapePath(path));
|
|
2602
|
+
} catch {
|
|
2603
|
+
return [];
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
async function globMarkdownFiles(cwd) {
|
|
2607
|
+
return glob([
|
|
2608
|
+
'**/*.md',
|
|
2609
|
+
'**/*.mdx'
|
|
2610
|
+
], {
|
|
2611
|
+
cwd,
|
|
2612
|
+
ignore: [
|
|
2613
|
+
...DEFAULT_IGNORE,
|
|
2614
|
+
...getGitIgnorePatterns(cwd)
|
|
2615
|
+
],
|
|
2616
|
+
absolute: true
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
const isTitleLine = (line)=>/^#{1,6}\s+\S/.test(line.trim());
|
|
2620
|
+
function formatContent(content, filePath, write) {
|
|
2621
|
+
const lines = content.split('\n');
|
|
2622
|
+
return lines.map((originalLine)=>{
|
|
2623
|
+
if (isTitleLine(originalLine)) {
|
|
2624
|
+
const formattedLine = formatLine(originalLine);
|
|
2625
|
+
if (!write && formattedLine !== originalLine) {
|
|
2626
|
+
src_logger.error(`Unexpected heading case in ${picocolors_default().dim(filePath)}`);
|
|
2627
|
+
src_logger.log(` Current: ${picocolors_default().cyan(originalLine)}`);
|
|
2628
|
+
src_logger.log(` Expected: ${picocolors_default().cyan(formattedLine)}\n`);
|
|
2629
|
+
}
|
|
2630
|
+
return formattedLine;
|
|
2631
|
+
}
|
|
2632
|
+
return originalLine;
|
|
2633
|
+
}).join('\n');
|
|
2634
|
+
}
|
|
2635
|
+
async function formatFile(filePath, write) {
|
|
2636
|
+
const content = await node_fs.promises.readFile(filePath, 'utf-8');
|
|
2637
|
+
const formatted = formatContent(content, filePath, write);
|
|
2638
|
+
const isChanged = formatted !== content;
|
|
2639
|
+
if (isChanged && write) {
|
|
2640
|
+
await node_fs.promises.writeFile(filePath, formatted);
|
|
2641
|
+
src_logger.success(`[heading-case] formatted: ${picocolors_default().dim(filePath)}`);
|
|
2642
|
+
}
|
|
2643
|
+
return isChanged;
|
|
2644
|
+
}
|
|
2645
|
+
async function headingCase({ root = process.cwd(), write = process.argv.includes('--write') } = {}) {
|
|
2646
|
+
const files = await globMarkdownFiles(root);
|
|
2647
|
+
let count = 0;
|
|
2648
|
+
for (const file of files){
|
|
2649
|
+
const isFormatted = await formatFile(file, write);
|
|
2650
|
+
if (isFormatted) count++;
|
|
2651
|
+
}
|
|
2652
|
+
if (count) if (write) src_logger.success(`[heading-case] formatted ${picocolors_default().yellow(count.toString())} files.`);
|
|
2653
|
+
else {
|
|
2654
|
+
src_logger.info(`[heading-case] found issues in ${picocolors_default().yellow(count.toString())} files.`);
|
|
2655
|
+
process.exit(1);
|
|
2656
|
+
}
|
|
2657
|
+
else src_logger.success(`[heading-case] ${picocolors_default().yellow(files.length)} files scanned, no issues found.`);
|
|
2658
|
+
}
|
|
2659
|
+
export { globMarkdownFiles, headingCase };
|