@catheadowl/pathscope 0.3.0 → 0.4.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/CHANGELOG.md +90 -0
- package/README.md +9 -3
- package/dist/cascade.d.ts +4 -0
- package/dist/cascade.js +7 -3
- package/dist/cascade.js.map +1 -1
- package/dist/cjs/cascade.d.ts +4 -0
- package/dist/cjs/exclusion-engine.d.ts +67 -10
- package/dist/cjs/index.js +2101 -83
- package/dist/cjs/types.d.ts +58 -8
- package/dist/cjs/walk-hidden.d.ts +41 -0
- package/dist/cjs/walk-links.d.ts +63 -0
- package/dist/cjs/win-attr.d.ts +27 -0
- package/dist/engine.js +69 -7
- package/dist/engine.js.map +1 -1
- package/dist/exclusion-engine.d.ts +67 -10
- package/dist/exclusion-engine.js +156 -71
- package/dist/exclusion-engine.js.map +1 -1
- package/dist/explain.js +18 -3
- package/dist/explain.js.map +1 -1
- package/dist/types.d.ts +58 -8
- package/dist/types.js.map +1 -1
- package/dist/walk-hidden.d.ts +41 -0
- package/dist/walk-hidden.js +96 -0
- package/dist/walk-hidden.js.map +1 -0
- package/dist/walk-links.d.ts +63 -0
- package/dist/walk-links.js +124 -0
- package/dist/walk-links.js.map +1 -0
- package/dist/win-attr.d.ts +27 -0
- package/dist/win-attr.js +81 -0
- package/dist/win-attr.js.map +1 -0
- package/docs/glossary.md +2 -0
- package/docs/semantics.md +16 -2
- package/package.json +4 -1
- package/prebuilds/win32-x64/pathscope_win_attr.node +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -34,9 +34,1785 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
));
|
|
35
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
36
|
|
|
37
|
-
// node_modules/.pnpm/
|
|
37
|
+
// node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js
|
|
38
|
+
var require_constants = __commonJS({
|
|
39
|
+
"node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js"(exports2, module2) {
|
|
40
|
+
"use strict";
|
|
41
|
+
var WIN_SLASH = "\\\\/";
|
|
42
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
43
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
44
|
+
var DOT_LITERAL = "\\.";
|
|
45
|
+
var PLUS_LITERAL = "\\+";
|
|
46
|
+
var QMARK_LITERAL = "\\?";
|
|
47
|
+
var SLASH_LITERAL = "\\/";
|
|
48
|
+
var ONE_CHAR = "(?=.)";
|
|
49
|
+
var QMARK = "[^/]";
|
|
50
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
51
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
52
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
53
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
54
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
55
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
56
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
57
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
58
|
+
var STAR = `${QMARK}*?`;
|
|
59
|
+
var SEP = "/";
|
|
60
|
+
var POSIX_CHARS = {
|
|
61
|
+
DOT_LITERAL,
|
|
62
|
+
PLUS_LITERAL,
|
|
63
|
+
QMARK_LITERAL,
|
|
64
|
+
SLASH_LITERAL,
|
|
65
|
+
ONE_CHAR,
|
|
66
|
+
QMARK,
|
|
67
|
+
END_ANCHOR,
|
|
68
|
+
DOTS_SLASH,
|
|
69
|
+
NO_DOT,
|
|
70
|
+
NO_DOTS,
|
|
71
|
+
NO_DOT_SLASH,
|
|
72
|
+
NO_DOTS_SLASH,
|
|
73
|
+
QMARK_NO_DOT,
|
|
74
|
+
STAR,
|
|
75
|
+
START_ANCHOR,
|
|
76
|
+
SEP
|
|
77
|
+
};
|
|
78
|
+
var WINDOWS_CHARS = {
|
|
79
|
+
...POSIX_CHARS,
|
|
80
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
81
|
+
QMARK: WIN_NO_SLASH,
|
|
82
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
83
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
84
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
85
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
86
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
87
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
88
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
89
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
90
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
91
|
+
SEP: "\\"
|
|
92
|
+
};
|
|
93
|
+
var POSIX_REGEX_SOURCE = {
|
|
94
|
+
__proto__: null,
|
|
95
|
+
alnum: "a-zA-Z0-9",
|
|
96
|
+
alpha: "a-zA-Z",
|
|
97
|
+
ascii: "\\x00-\\x7F",
|
|
98
|
+
blank: " \\t",
|
|
99
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
100
|
+
digit: "0-9",
|
|
101
|
+
graph: "\\x21-\\x7E",
|
|
102
|
+
lower: "a-z",
|
|
103
|
+
print: "\\x20-\\x7E ",
|
|
104
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
105
|
+
space: " \\t\\r\\n\\v\\f",
|
|
106
|
+
upper: "A-Z",
|
|
107
|
+
word: "A-Za-z0-9_",
|
|
108
|
+
xdigit: "A-Fa-f0-9"
|
|
109
|
+
};
|
|
110
|
+
module2.exports = {
|
|
111
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
112
|
+
MAX_LENGTH: 1024 * 64,
|
|
113
|
+
POSIX_REGEX_SOURCE,
|
|
114
|
+
// regular expressions
|
|
115
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
116
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
117
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
118
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
119
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
120
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
121
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
122
|
+
REPLACEMENTS: {
|
|
123
|
+
__proto__: null,
|
|
124
|
+
"***": "*",
|
|
125
|
+
"**/**": "**",
|
|
126
|
+
"**/**/**": "**"
|
|
127
|
+
},
|
|
128
|
+
// Digits
|
|
129
|
+
CHAR_0: 48,
|
|
130
|
+
/* 0 */
|
|
131
|
+
CHAR_9: 57,
|
|
132
|
+
/* 9 */
|
|
133
|
+
// Alphabet chars.
|
|
134
|
+
CHAR_UPPERCASE_A: 65,
|
|
135
|
+
/* A */
|
|
136
|
+
CHAR_LOWERCASE_A: 97,
|
|
137
|
+
/* a */
|
|
138
|
+
CHAR_UPPERCASE_Z: 90,
|
|
139
|
+
/* Z */
|
|
140
|
+
CHAR_LOWERCASE_Z: 122,
|
|
141
|
+
/* z */
|
|
142
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
143
|
+
/* ( */
|
|
144
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
145
|
+
/* ) */
|
|
146
|
+
CHAR_ASTERISK: 42,
|
|
147
|
+
/* * */
|
|
148
|
+
// Non-alphabetic chars.
|
|
149
|
+
CHAR_AMPERSAND: 38,
|
|
150
|
+
/* & */
|
|
151
|
+
CHAR_AT: 64,
|
|
152
|
+
/* @ */
|
|
153
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
154
|
+
/* \ */
|
|
155
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
156
|
+
/* \r */
|
|
157
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
158
|
+
/* ^ */
|
|
159
|
+
CHAR_COLON: 58,
|
|
160
|
+
/* : */
|
|
161
|
+
CHAR_COMMA: 44,
|
|
162
|
+
/* , */
|
|
163
|
+
CHAR_DOT: 46,
|
|
164
|
+
/* . */
|
|
165
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
166
|
+
/* " */
|
|
167
|
+
CHAR_EQUAL: 61,
|
|
168
|
+
/* = */
|
|
169
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
170
|
+
/* ! */
|
|
171
|
+
CHAR_FORM_FEED: 12,
|
|
172
|
+
/* \f */
|
|
173
|
+
CHAR_FORWARD_SLASH: 47,
|
|
174
|
+
/* / */
|
|
175
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
176
|
+
/* ` */
|
|
177
|
+
CHAR_HASH: 35,
|
|
178
|
+
/* # */
|
|
179
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
180
|
+
/* - */
|
|
181
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
182
|
+
/* < */
|
|
183
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
184
|
+
/* { */
|
|
185
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
186
|
+
/* [ */
|
|
187
|
+
CHAR_LINE_FEED: 10,
|
|
188
|
+
/* \n */
|
|
189
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
190
|
+
/* \u00A0 */
|
|
191
|
+
CHAR_PERCENT: 37,
|
|
192
|
+
/* % */
|
|
193
|
+
CHAR_PLUS: 43,
|
|
194
|
+
/* + */
|
|
195
|
+
CHAR_QUESTION_MARK: 63,
|
|
196
|
+
/* ? */
|
|
197
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
198
|
+
/* > */
|
|
199
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
200
|
+
/* } */
|
|
201
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
202
|
+
/* ] */
|
|
203
|
+
CHAR_SEMICOLON: 59,
|
|
204
|
+
/* ; */
|
|
205
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
206
|
+
/* ' */
|
|
207
|
+
CHAR_SPACE: 32,
|
|
208
|
+
/* */
|
|
209
|
+
CHAR_TAB: 9,
|
|
210
|
+
/* \t */
|
|
211
|
+
CHAR_UNDERSCORE: 95,
|
|
212
|
+
/* _ */
|
|
213
|
+
CHAR_VERTICAL_LINE: 124,
|
|
214
|
+
/* | */
|
|
215
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
216
|
+
/* \uFEFF */
|
|
217
|
+
/**
|
|
218
|
+
* Create EXTGLOB_CHARS
|
|
219
|
+
*/
|
|
220
|
+
extglobChars(chars) {
|
|
221
|
+
return {
|
|
222
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
223
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
224
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
225
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
226
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
/**
|
|
230
|
+
* Create GLOB_CHARS
|
|
231
|
+
*/
|
|
232
|
+
globChars(win32) {
|
|
233
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js
|
|
240
|
+
var require_utils = __commonJS({
|
|
241
|
+
"node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js"(exports2) {
|
|
242
|
+
"use strict";
|
|
243
|
+
var {
|
|
244
|
+
REGEX_BACKSLASH,
|
|
245
|
+
REGEX_REMOVE_BACKSLASH,
|
|
246
|
+
REGEX_SPECIAL_CHARS,
|
|
247
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
248
|
+
} = require_constants();
|
|
249
|
+
exports2.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
250
|
+
exports2.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
251
|
+
exports2.isRegexChar = (str) => str.length === 1 && exports2.hasRegexChars(str);
|
|
252
|
+
exports2.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
253
|
+
exports2.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
254
|
+
exports2.isWindows = () => {
|
|
255
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
256
|
+
const platform3 = navigator.platform.toLowerCase();
|
|
257
|
+
return platform3 === "win32" || platform3 === "windows";
|
|
258
|
+
}
|
|
259
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
260
|
+
return process.platform === "win32";
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
};
|
|
264
|
+
exports2.removeBackslashes = (str) => {
|
|
265
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
266
|
+
return match === "\\" ? "" : match;
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
exports2.escapeLast = (input, char, lastIdx) => {
|
|
270
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
271
|
+
if (idx === -1) return input;
|
|
272
|
+
if (input[idx - 1] === "\\") return exports2.escapeLast(input, char, idx - 1);
|
|
273
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
274
|
+
};
|
|
275
|
+
exports2.removePrefix = (input, state = {}) => {
|
|
276
|
+
let output = input;
|
|
277
|
+
if (output.startsWith("./")) {
|
|
278
|
+
output = output.slice(2);
|
|
279
|
+
state.prefix = "./";
|
|
280
|
+
}
|
|
281
|
+
return output;
|
|
282
|
+
};
|
|
283
|
+
exports2.wrapOutput = (input, state = {}, options = {}) => {
|
|
284
|
+
const prepend = options.contains ? "" : "^";
|
|
285
|
+
const append = options.contains ? "" : "$";
|
|
286
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
287
|
+
if (state.negated === true) {
|
|
288
|
+
output = `(?:^(?!${output}).*$)`;
|
|
289
|
+
}
|
|
290
|
+
return output;
|
|
291
|
+
};
|
|
292
|
+
exports2.basename = (path3, { windows } = {}) => {
|
|
293
|
+
const segs = path3.split(windows ? /[\\/]/ : "/");
|
|
294
|
+
const last = segs[segs.length - 1];
|
|
295
|
+
if (last === "") {
|
|
296
|
+
return segs[segs.length - 2];
|
|
297
|
+
}
|
|
298
|
+
return last;
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/scan.js
|
|
304
|
+
var require_scan = __commonJS({
|
|
305
|
+
"node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/scan.js"(exports2, module2) {
|
|
306
|
+
"use strict";
|
|
307
|
+
var utils = require_utils();
|
|
308
|
+
var {
|
|
309
|
+
CHAR_ASTERISK,
|
|
310
|
+
/* * */
|
|
311
|
+
CHAR_AT,
|
|
312
|
+
/* @ */
|
|
313
|
+
CHAR_BACKWARD_SLASH,
|
|
314
|
+
/* \ */
|
|
315
|
+
CHAR_COMMA,
|
|
316
|
+
/* , */
|
|
317
|
+
CHAR_DOT,
|
|
318
|
+
/* . */
|
|
319
|
+
CHAR_EXCLAMATION_MARK,
|
|
320
|
+
/* ! */
|
|
321
|
+
CHAR_FORWARD_SLASH,
|
|
322
|
+
/* / */
|
|
323
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
324
|
+
/* { */
|
|
325
|
+
CHAR_LEFT_PARENTHESES,
|
|
326
|
+
/* ( */
|
|
327
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
328
|
+
/* [ */
|
|
329
|
+
CHAR_PLUS,
|
|
330
|
+
/* + */
|
|
331
|
+
CHAR_QUESTION_MARK,
|
|
332
|
+
/* ? */
|
|
333
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
334
|
+
/* } */
|
|
335
|
+
CHAR_RIGHT_PARENTHESES,
|
|
336
|
+
/* ) */
|
|
337
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
338
|
+
/* ] */
|
|
339
|
+
} = require_constants();
|
|
340
|
+
var isPathSeparator = (code) => {
|
|
341
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
342
|
+
};
|
|
343
|
+
var depth = (token) => {
|
|
344
|
+
if (token.isPrefix !== true) {
|
|
345
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var scan = (input, options) => {
|
|
349
|
+
const opts = options || {};
|
|
350
|
+
const length = input.length - 1;
|
|
351
|
+
const scanToEnd = opts.parts === true || opts.tokens === true || opts.scanToEnd === true;
|
|
352
|
+
const slashes = [];
|
|
353
|
+
const tokens = [];
|
|
354
|
+
const parts = [];
|
|
355
|
+
let str = input;
|
|
356
|
+
let index = -1;
|
|
357
|
+
let start = 0;
|
|
358
|
+
let lastIndex = 0;
|
|
359
|
+
let isBrace = false;
|
|
360
|
+
let isBracket = false;
|
|
361
|
+
let isGlob = false;
|
|
362
|
+
let isExtglob = false;
|
|
363
|
+
let isGlobstar = false;
|
|
364
|
+
let braceEscaped = false;
|
|
365
|
+
let backslashes = false;
|
|
366
|
+
let negated = false;
|
|
367
|
+
let negatedExtglob = false;
|
|
368
|
+
let finished = false;
|
|
369
|
+
let braces = 0;
|
|
370
|
+
let prev;
|
|
371
|
+
let code;
|
|
372
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
373
|
+
const eos = () => index >= length;
|
|
374
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
375
|
+
const advance = () => {
|
|
376
|
+
prev = code;
|
|
377
|
+
return str.charCodeAt(++index);
|
|
378
|
+
};
|
|
379
|
+
while (index < length) {
|
|
380
|
+
code = advance();
|
|
381
|
+
let next;
|
|
382
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
383
|
+
backslashes = token.backslashes = true;
|
|
384
|
+
code = advance();
|
|
385
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
386
|
+
braceEscaped = true;
|
|
387
|
+
}
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
391
|
+
braces++;
|
|
392
|
+
while (eos() !== true && (code = advance())) {
|
|
393
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
394
|
+
backslashes = token.backslashes = true;
|
|
395
|
+
advance();
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
399
|
+
braces++;
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
403
|
+
isBrace = token.isBrace = true;
|
|
404
|
+
isGlob = token.isGlob = true;
|
|
405
|
+
finished = true;
|
|
406
|
+
if (scanToEnd === true) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
412
|
+
isBrace = token.isBrace = true;
|
|
413
|
+
isGlob = token.isGlob = true;
|
|
414
|
+
finished = true;
|
|
415
|
+
if (scanToEnd === true) {
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
421
|
+
braces--;
|
|
422
|
+
if (braces === 0) {
|
|
423
|
+
braceEscaped = false;
|
|
424
|
+
isBrace = token.isBrace = true;
|
|
425
|
+
finished = true;
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
if (scanToEnd === true) {
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
436
|
+
slashes.push(index);
|
|
437
|
+
tokens.push(token);
|
|
438
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
439
|
+
if (finished === true) continue;
|
|
440
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
441
|
+
start += 2;
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
lastIndex = index + 1;
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
if (opts.noext !== true) {
|
|
448
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
449
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
450
|
+
isGlob = token.isGlob = true;
|
|
451
|
+
isExtglob = token.isExtglob = true;
|
|
452
|
+
finished = true;
|
|
453
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
454
|
+
negatedExtglob = true;
|
|
455
|
+
}
|
|
456
|
+
if (scanToEnd === true) {
|
|
457
|
+
let parens = 0;
|
|
458
|
+
while (eos() !== true && (code = advance())) {
|
|
459
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
460
|
+
backslashes = token.backslashes = true;
|
|
461
|
+
advance();
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
465
|
+
parens++;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
469
|
+
finished = true;
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (code === CHAR_ASTERISK) {
|
|
479
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
480
|
+
isGlob = token.isGlob = true;
|
|
481
|
+
finished = true;
|
|
482
|
+
if (scanToEnd === true) {
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
488
|
+
isGlob = token.isGlob = true;
|
|
489
|
+
finished = true;
|
|
490
|
+
if (scanToEnd === true) {
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
496
|
+
while (eos() !== true && (next = advance())) {
|
|
497
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
498
|
+
backslashes = token.backslashes = true;
|
|
499
|
+
advance();
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
503
|
+
isBracket = token.isBracket = true;
|
|
504
|
+
isGlob = token.isGlob = true;
|
|
505
|
+
finished = true;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (scanToEnd === true) {
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
break;
|
|
513
|
+
}
|
|
514
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
515
|
+
negated = token.negated = true;
|
|
516
|
+
start++;
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
520
|
+
isGlob = token.isGlob = true;
|
|
521
|
+
if (scanToEnd === true) {
|
|
522
|
+
let parens = 1;
|
|
523
|
+
while (eos() !== true && (code = advance())) {
|
|
524
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
525
|
+
backslashes = token.backslashes = true;
|
|
526
|
+
advance();
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
530
|
+
parens++;
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
|
|
534
|
+
finished = true;
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
if (isGlob === true) {
|
|
543
|
+
finished = true;
|
|
544
|
+
if (scanToEnd === true) {
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (opts.noext === true) {
|
|
551
|
+
isExtglob = false;
|
|
552
|
+
isGlob = false;
|
|
553
|
+
}
|
|
554
|
+
let base = str;
|
|
555
|
+
let prefix = "";
|
|
556
|
+
let glob = "";
|
|
557
|
+
if (start > 0) {
|
|
558
|
+
prefix = str.slice(0, start);
|
|
559
|
+
str = str.slice(start);
|
|
560
|
+
lastIndex -= start;
|
|
561
|
+
}
|
|
562
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
563
|
+
base = str.slice(0, lastIndex);
|
|
564
|
+
glob = str.slice(lastIndex);
|
|
565
|
+
} else if (isGlob === true) {
|
|
566
|
+
base = "";
|
|
567
|
+
glob = str;
|
|
568
|
+
} else {
|
|
569
|
+
base = str;
|
|
570
|
+
}
|
|
571
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
572
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
573
|
+
base = base.slice(0, -1);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (opts.unescape === true) {
|
|
577
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
578
|
+
if (base && backslashes === true) {
|
|
579
|
+
base = utils.removeBackslashes(base);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
const state = {
|
|
583
|
+
prefix,
|
|
584
|
+
input,
|
|
585
|
+
start,
|
|
586
|
+
base,
|
|
587
|
+
glob,
|
|
588
|
+
isBrace,
|
|
589
|
+
isBracket,
|
|
590
|
+
isGlob,
|
|
591
|
+
isExtglob,
|
|
592
|
+
isGlobstar,
|
|
593
|
+
negated,
|
|
594
|
+
negatedExtglob
|
|
595
|
+
};
|
|
596
|
+
if (opts.tokens === true) {
|
|
597
|
+
state.maxDepth = 0;
|
|
598
|
+
if (!isPathSeparator(code)) {
|
|
599
|
+
tokens.push(token);
|
|
600
|
+
}
|
|
601
|
+
state.tokens = tokens;
|
|
602
|
+
}
|
|
603
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
604
|
+
let prevIndex;
|
|
605
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
606
|
+
const n2 = prevIndex !== void 0 ? prevIndex + 1 : start;
|
|
607
|
+
const i = slashes[idx];
|
|
608
|
+
const value2 = input.slice(n2, i);
|
|
609
|
+
if (opts.tokens) {
|
|
610
|
+
if (idx === 0 && start !== 0) {
|
|
611
|
+
tokens[idx].isPrefix = true;
|
|
612
|
+
tokens[idx].value = prefix;
|
|
613
|
+
} else {
|
|
614
|
+
tokens[idx].value = value2;
|
|
615
|
+
}
|
|
616
|
+
depth(tokens[idx]);
|
|
617
|
+
state.maxDepth += tokens[idx].depth;
|
|
618
|
+
}
|
|
619
|
+
if (i >= start) {
|
|
620
|
+
parts.push(value2);
|
|
621
|
+
prevIndex = i;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const n = prevIndex !== void 0 ? prevIndex + 1 : start;
|
|
625
|
+
const value = input.slice(n);
|
|
626
|
+
parts.push(value);
|
|
627
|
+
if (opts.tokens && prevIndex && prevIndex + 1 < input.length) {
|
|
628
|
+
tokens[tokens.length - 1].value = value;
|
|
629
|
+
depth(tokens[tokens.length - 1]);
|
|
630
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
631
|
+
}
|
|
632
|
+
state.slashes = slashes;
|
|
633
|
+
state.parts = parts;
|
|
634
|
+
}
|
|
635
|
+
return state;
|
|
636
|
+
};
|
|
637
|
+
module2.exports = scan;
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
// node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/parse.js
|
|
642
|
+
var require_parse = __commonJS({
|
|
643
|
+
"node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/parse.js"(exports2, module2) {
|
|
644
|
+
"use strict";
|
|
645
|
+
var constants = require_constants();
|
|
646
|
+
var utils = require_utils();
|
|
647
|
+
var {
|
|
648
|
+
MAX_LENGTH,
|
|
649
|
+
POSIX_REGEX_SOURCE,
|
|
650
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
651
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
652
|
+
REPLACEMENTS
|
|
653
|
+
} = constants;
|
|
654
|
+
var expandRange = (args, options) => {
|
|
655
|
+
if (typeof options.expandRange === "function") {
|
|
656
|
+
return options.expandRange(...args, options);
|
|
657
|
+
}
|
|
658
|
+
args.sort();
|
|
659
|
+
const value = `[${args.join("-")}]`;
|
|
660
|
+
try {
|
|
661
|
+
new RegExp(value);
|
|
662
|
+
} catch (ex) {
|
|
663
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
664
|
+
}
|
|
665
|
+
return value;
|
|
666
|
+
};
|
|
667
|
+
var syntaxError = (type, char) => {
|
|
668
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
669
|
+
};
|
|
670
|
+
var splitTopLevel = (input) => {
|
|
671
|
+
const parts = [];
|
|
672
|
+
let bracket = 0;
|
|
673
|
+
let paren = 0;
|
|
674
|
+
let quote = 0;
|
|
675
|
+
let value = "";
|
|
676
|
+
let escaped = false;
|
|
677
|
+
for (const ch of input) {
|
|
678
|
+
if (escaped === true) {
|
|
679
|
+
value += ch;
|
|
680
|
+
escaped = false;
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
if (ch === "\\") {
|
|
684
|
+
value += ch;
|
|
685
|
+
escaped = true;
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
688
|
+
if (ch === '"') {
|
|
689
|
+
quote = quote === 1 ? 0 : 1;
|
|
690
|
+
value += ch;
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (quote === 0) {
|
|
694
|
+
if (ch === "[") {
|
|
695
|
+
bracket++;
|
|
696
|
+
} else if (ch === "]" && bracket > 0) {
|
|
697
|
+
bracket--;
|
|
698
|
+
} else if (bracket === 0) {
|
|
699
|
+
if (ch === "(") {
|
|
700
|
+
paren++;
|
|
701
|
+
} else if (ch === ")" && paren > 0) {
|
|
702
|
+
paren--;
|
|
703
|
+
} else if (ch === "|" && paren === 0) {
|
|
704
|
+
parts.push(value);
|
|
705
|
+
value = "";
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
value += ch;
|
|
711
|
+
}
|
|
712
|
+
parts.push(value);
|
|
713
|
+
return parts;
|
|
714
|
+
};
|
|
715
|
+
var isPlainBranch = (branch) => {
|
|
716
|
+
let escaped = false;
|
|
717
|
+
for (const ch of branch) {
|
|
718
|
+
if (escaped === true) {
|
|
719
|
+
escaped = false;
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
if (ch === "\\") {
|
|
723
|
+
escaped = true;
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
727
|
+
return false;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return true;
|
|
731
|
+
};
|
|
732
|
+
var normalizeSimpleBranch = (branch) => {
|
|
733
|
+
let value = branch.trim();
|
|
734
|
+
let changed = true;
|
|
735
|
+
while (changed === true) {
|
|
736
|
+
changed = false;
|
|
737
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
738
|
+
value = value.slice(2, -1);
|
|
739
|
+
changed = true;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if (!isPlainBranch(value)) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
return value.replace(/\\(.)/g, "$1");
|
|
746
|
+
};
|
|
747
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
748
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
749
|
+
for (let i = 0; i < values.length; i++) {
|
|
750
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
751
|
+
const a = values[i];
|
|
752
|
+
const b = values[j];
|
|
753
|
+
const char = a[0];
|
|
754
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
755
|
+
continue;
|
|
756
|
+
}
|
|
757
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
758
|
+
return true;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
return false;
|
|
763
|
+
};
|
|
764
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
765
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
let bracket = 0;
|
|
769
|
+
let paren = 0;
|
|
770
|
+
let quote = 0;
|
|
771
|
+
let escaped = false;
|
|
772
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
773
|
+
const ch = pattern[i];
|
|
774
|
+
if (escaped === true) {
|
|
775
|
+
escaped = false;
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (ch === "\\") {
|
|
779
|
+
escaped = true;
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (ch === '"') {
|
|
783
|
+
quote = quote === 1 ? 0 : 1;
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
if (quote === 1) {
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
if (ch === "[") {
|
|
790
|
+
bracket++;
|
|
791
|
+
continue;
|
|
792
|
+
}
|
|
793
|
+
if (ch === "]" && bracket > 0) {
|
|
794
|
+
bracket--;
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
if (bracket > 0) {
|
|
798
|
+
continue;
|
|
799
|
+
}
|
|
800
|
+
if (ch === "(") {
|
|
801
|
+
paren++;
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
if (ch === ")") {
|
|
805
|
+
paren--;
|
|
806
|
+
if (paren === 0) {
|
|
807
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
return {
|
|
811
|
+
type: pattern[0],
|
|
812
|
+
body: pattern.slice(2, i),
|
|
813
|
+
end: i
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
var buildCharClassStar = (chars) => {
|
|
820
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
821
|
+
return `${source}*`;
|
|
822
|
+
};
|
|
823
|
+
var getStarExtglobSequenceChars = (pattern) => {
|
|
824
|
+
let index = 0;
|
|
825
|
+
const chars = [];
|
|
826
|
+
while (index < pattern.length) {
|
|
827
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
828
|
+
if (!match || match.type !== "*") {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
832
|
+
if (branches.length !== 1) {
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
836
|
+
if (!branch || branch.length !== 1) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
chars.push(branch);
|
|
840
|
+
index += match.end + 1;
|
|
841
|
+
}
|
|
842
|
+
if (chars.length < 1) {
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
return chars;
|
|
846
|
+
};
|
|
847
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
848
|
+
let depth = 0;
|
|
849
|
+
let value = pattern.trim();
|
|
850
|
+
let match = parseRepeatedExtglob(value);
|
|
851
|
+
while (match) {
|
|
852
|
+
depth++;
|
|
853
|
+
value = match.body.trim();
|
|
854
|
+
match = parseRepeatedExtglob(value);
|
|
855
|
+
}
|
|
856
|
+
return depth;
|
|
857
|
+
};
|
|
858
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
859
|
+
if (options.maxExtglobRecursion === false) {
|
|
860
|
+
return { risky: false };
|
|
861
|
+
}
|
|
862
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
863
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
864
|
+
if (branches.length > 1) {
|
|
865
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
866
|
+
return { risky: true };
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
const safeChars = [];
|
|
870
|
+
let sawStarSequence = false;
|
|
871
|
+
let combinable = true;
|
|
872
|
+
for (const branch of branches) {
|
|
873
|
+
const chars = getStarExtglobSequenceChars(branch);
|
|
874
|
+
if (chars) {
|
|
875
|
+
sawStarSequence = true;
|
|
876
|
+
safeChars.push(...chars);
|
|
877
|
+
continue;
|
|
878
|
+
}
|
|
879
|
+
const literal = normalizeSimpleBranch(branch);
|
|
880
|
+
if (literal && literal.length === 1) {
|
|
881
|
+
safeChars.push(literal);
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
combinable = false;
|
|
885
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
886
|
+
return { risky: true };
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
if (sawStarSequence) {
|
|
890
|
+
return combinable ? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) } : { risky: true };
|
|
891
|
+
}
|
|
892
|
+
return { risky: false };
|
|
893
|
+
};
|
|
894
|
+
var parse = (input, options) => {
|
|
895
|
+
if (typeof input !== "string") {
|
|
896
|
+
throw new TypeError("Expected a string");
|
|
897
|
+
}
|
|
898
|
+
input = REPLACEMENTS[input] || input;
|
|
899
|
+
const opts = { ...options };
|
|
900
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
901
|
+
let len = input.length;
|
|
902
|
+
if (len > max) {
|
|
903
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
904
|
+
}
|
|
905
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
906
|
+
const tokens = [bos];
|
|
907
|
+
const capture = opts.capture ? "" : "?:";
|
|
908
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
909
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
910
|
+
const {
|
|
911
|
+
DOT_LITERAL,
|
|
912
|
+
PLUS_LITERAL,
|
|
913
|
+
SLASH_LITERAL,
|
|
914
|
+
ONE_CHAR,
|
|
915
|
+
DOTS_SLASH,
|
|
916
|
+
NO_DOT,
|
|
917
|
+
NO_DOT_SLASH,
|
|
918
|
+
NO_DOTS_SLASH,
|
|
919
|
+
QMARK,
|
|
920
|
+
QMARK_NO_DOT,
|
|
921
|
+
STAR,
|
|
922
|
+
START_ANCHOR
|
|
923
|
+
} = PLATFORM_CHARS;
|
|
924
|
+
const globstar = (opts2) => {
|
|
925
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
926
|
+
};
|
|
927
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
928
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
929
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
930
|
+
if (opts.capture) {
|
|
931
|
+
star = `(${star})`;
|
|
932
|
+
}
|
|
933
|
+
if (typeof opts.noext === "boolean") {
|
|
934
|
+
opts.noextglob = opts.noext;
|
|
935
|
+
}
|
|
936
|
+
const state = {
|
|
937
|
+
input,
|
|
938
|
+
index: -1,
|
|
939
|
+
start: 0,
|
|
940
|
+
dot: opts.dot === true,
|
|
941
|
+
consumed: "",
|
|
942
|
+
output: "",
|
|
943
|
+
prefix: "",
|
|
944
|
+
backtrack: false,
|
|
945
|
+
negated: false,
|
|
946
|
+
brackets: 0,
|
|
947
|
+
braces: 0,
|
|
948
|
+
parens: 0,
|
|
949
|
+
quotes: 0,
|
|
950
|
+
globstar: false,
|
|
951
|
+
tokens
|
|
952
|
+
};
|
|
953
|
+
input = utils.removePrefix(input, state);
|
|
954
|
+
len = input.length;
|
|
955
|
+
const extglobs = [];
|
|
956
|
+
const braces = [];
|
|
957
|
+
const stack = [];
|
|
958
|
+
let prev = bos;
|
|
959
|
+
let value;
|
|
960
|
+
const eos = () => state.index === len - 1;
|
|
961
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
962
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
963
|
+
const remaining = () => input.slice(state.index + 1);
|
|
964
|
+
const consume = (value2 = "", num = 0) => {
|
|
965
|
+
state.consumed += value2;
|
|
966
|
+
state.index += num;
|
|
967
|
+
};
|
|
968
|
+
const append = (token) => {
|
|
969
|
+
state.output += token.output != null ? token.output : token.value;
|
|
970
|
+
consume(token.value);
|
|
971
|
+
};
|
|
972
|
+
const negate = () => {
|
|
973
|
+
let count = 1;
|
|
974
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
975
|
+
advance();
|
|
976
|
+
state.start++;
|
|
977
|
+
count++;
|
|
978
|
+
}
|
|
979
|
+
if (count % 2 === 0) {
|
|
980
|
+
return false;
|
|
981
|
+
}
|
|
982
|
+
state.negated = true;
|
|
983
|
+
state.start++;
|
|
984
|
+
return true;
|
|
985
|
+
};
|
|
986
|
+
const increment = (type) => {
|
|
987
|
+
state[type]++;
|
|
988
|
+
stack.push(type);
|
|
989
|
+
};
|
|
990
|
+
const decrement = (type) => {
|
|
991
|
+
state[type]--;
|
|
992
|
+
stack.pop();
|
|
993
|
+
};
|
|
994
|
+
const push = (tok) => {
|
|
995
|
+
if (prev.type === "globstar") {
|
|
996
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
997
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
998
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
999
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1000
|
+
prev.type = "star";
|
|
1001
|
+
prev.value = "*";
|
|
1002
|
+
prev.output = star;
|
|
1003
|
+
state.output += prev.output;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
1007
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
1008
|
+
}
|
|
1009
|
+
if (tok.value || tok.output) append(tok);
|
|
1010
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
1011
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
1012
|
+
prev.value += tok.value;
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
tok.prev = prev;
|
|
1016
|
+
tokens.push(tok);
|
|
1017
|
+
prev = tok;
|
|
1018
|
+
};
|
|
1019
|
+
const extglobOpen = (type, value2) => {
|
|
1020
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
1021
|
+
token.prev = prev;
|
|
1022
|
+
token.parens = state.parens;
|
|
1023
|
+
token.output = state.output;
|
|
1024
|
+
token.startIndex = state.index;
|
|
1025
|
+
token.tokensIndex = tokens.length;
|
|
1026
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
1027
|
+
increment("parens");
|
|
1028
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
1029
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
1030
|
+
extglobs.push(token);
|
|
1031
|
+
};
|
|
1032
|
+
const extglobClose = (token) => {
|
|
1033
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
1034
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
1035
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
1036
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
1037
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
1038
|
+
const open = tokens[token.tokensIndex];
|
|
1039
|
+
open.type = "text";
|
|
1040
|
+
open.value = literal;
|
|
1041
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
1042
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
1043
|
+
tokens[i].value = "";
|
|
1044
|
+
tokens[i].output = "";
|
|
1045
|
+
delete tokens[i].suffix;
|
|
1046
|
+
}
|
|
1047
|
+
state.output = token.output + open.output;
|
|
1048
|
+
state.backtrack = true;
|
|
1049
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
1050
|
+
decrement("parens");
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
1054
|
+
let rest;
|
|
1055
|
+
if (token.type === "negate") {
|
|
1056
|
+
let extglobStar = star;
|
|
1057
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
1058
|
+
extglobStar = globstar(opts);
|
|
1059
|
+
}
|
|
1060
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
1061
|
+
output = token.close = `)$))${extglobStar}`;
|
|
1062
|
+
}
|
|
1063
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
1064
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
1065
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
1066
|
+
}
|
|
1067
|
+
if (token.prev.type === "bos") {
|
|
1068
|
+
state.negatedExtglob = true;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
push({ type: "paren", extglob: true, value, output });
|
|
1072
|
+
decrement("parens");
|
|
1073
|
+
};
|
|
1074
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1075
|
+
let backslashes = false;
|
|
1076
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1077
|
+
if (first === "\\") {
|
|
1078
|
+
backslashes = true;
|
|
1079
|
+
return m;
|
|
1080
|
+
}
|
|
1081
|
+
if (first === "?") {
|
|
1082
|
+
if (esc) {
|
|
1083
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
1084
|
+
}
|
|
1085
|
+
if (index === 0) {
|
|
1086
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
1087
|
+
}
|
|
1088
|
+
return QMARK.repeat(chars.length);
|
|
1089
|
+
}
|
|
1090
|
+
if (first === ".") {
|
|
1091
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
1092
|
+
}
|
|
1093
|
+
if (first === "*") {
|
|
1094
|
+
if (esc) {
|
|
1095
|
+
return esc + first + (rest ? star : "");
|
|
1096
|
+
}
|
|
1097
|
+
return star;
|
|
1098
|
+
}
|
|
1099
|
+
return esc ? m : `\\${m}`;
|
|
1100
|
+
});
|
|
1101
|
+
if (backslashes === true) {
|
|
1102
|
+
if (opts.unescape === true) {
|
|
1103
|
+
output = output.replace(/\\/g, "");
|
|
1104
|
+
} else {
|
|
1105
|
+
output = output.replace(/\\+/g, (m) => {
|
|
1106
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
if (output === input && opts.contains === true) {
|
|
1111
|
+
state.output = input;
|
|
1112
|
+
return state;
|
|
1113
|
+
}
|
|
1114
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
1115
|
+
return state;
|
|
1116
|
+
}
|
|
1117
|
+
while (!eos()) {
|
|
1118
|
+
value = advance();
|
|
1119
|
+
if (value === "\0") {
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
if (value === "\\") {
|
|
1123
|
+
const next = peek();
|
|
1124
|
+
if (next === "/" && opts.bash !== true) {
|
|
1125
|
+
continue;
|
|
1126
|
+
}
|
|
1127
|
+
if (next === "." || next === ";") {
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
if (!next) {
|
|
1131
|
+
value += "\\";
|
|
1132
|
+
push({ type: "text", value });
|
|
1133
|
+
continue;
|
|
1134
|
+
}
|
|
1135
|
+
const match = /^\\+/.exec(remaining());
|
|
1136
|
+
let slashes = 0;
|
|
1137
|
+
if (match && match[0].length > 2) {
|
|
1138
|
+
slashes = match[0].length;
|
|
1139
|
+
state.index += slashes;
|
|
1140
|
+
if (slashes % 2 !== 0) {
|
|
1141
|
+
value += "\\";
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
if (opts.unescape === true) {
|
|
1145
|
+
value = advance();
|
|
1146
|
+
} else {
|
|
1147
|
+
value += advance();
|
|
1148
|
+
}
|
|
1149
|
+
if (state.brackets === 0) {
|
|
1150
|
+
push({ type: "text", value });
|
|
1151
|
+
continue;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1155
|
+
if (opts.posix !== false && value === ":") {
|
|
1156
|
+
const inner = prev.value.slice(1);
|
|
1157
|
+
if (inner.includes("[")) {
|
|
1158
|
+
prev.posix = true;
|
|
1159
|
+
if (inner.includes(":")) {
|
|
1160
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1161
|
+
const pre = prev.value.slice(0, idx);
|
|
1162
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
1163
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
1164
|
+
if (posix) {
|
|
1165
|
+
prev.value = pre + posix;
|
|
1166
|
+
state.backtrack = true;
|
|
1167
|
+
advance();
|
|
1168
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
1169
|
+
bos.output = ONE_CHAR;
|
|
1170
|
+
}
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
1177
|
+
value = `\\${value}`;
|
|
1178
|
+
}
|
|
1179
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
1180
|
+
value = `\\${value}`;
|
|
1181
|
+
}
|
|
1182
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
1183
|
+
value = "^";
|
|
1184
|
+
}
|
|
1185
|
+
prev.value += value;
|
|
1186
|
+
append({ value });
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
if (state.quotes === 1 && value !== '"') {
|
|
1190
|
+
value = utils.escapeRegex(value);
|
|
1191
|
+
prev.value += value;
|
|
1192
|
+
append({ value });
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1195
|
+
if (value === '"') {
|
|
1196
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1197
|
+
if (opts.keepQuotes === true) {
|
|
1198
|
+
push({ type: "text", value });
|
|
1199
|
+
}
|
|
1200
|
+
continue;
|
|
1201
|
+
}
|
|
1202
|
+
if (value === "(") {
|
|
1203
|
+
increment("parens");
|
|
1204
|
+
push({ type: "paren", value });
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
if (value === ")") {
|
|
1208
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
1209
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
1210
|
+
}
|
|
1211
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1212
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1213
|
+
extglobClose(extglobs.pop());
|
|
1214
|
+
continue;
|
|
1215
|
+
}
|
|
1216
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1217
|
+
decrement("parens");
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1220
|
+
if (value === "[") {
|
|
1221
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1222
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
1223
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1224
|
+
}
|
|
1225
|
+
value = `\\${value}`;
|
|
1226
|
+
} else {
|
|
1227
|
+
increment("brackets");
|
|
1228
|
+
}
|
|
1229
|
+
push({ type: "bracket", value });
|
|
1230
|
+
continue;
|
|
1231
|
+
}
|
|
1232
|
+
if (value === "]") {
|
|
1233
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1234
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1235
|
+
continue;
|
|
1236
|
+
}
|
|
1237
|
+
if (state.brackets === 0) {
|
|
1238
|
+
if (opts.strictBrackets === true) {
|
|
1239
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
1240
|
+
}
|
|
1241
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1242
|
+
continue;
|
|
1243
|
+
}
|
|
1244
|
+
decrement("brackets");
|
|
1245
|
+
const prevValue = prev.value.slice(1);
|
|
1246
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
1247
|
+
value = `/${value}`;
|
|
1248
|
+
}
|
|
1249
|
+
prev.value += value;
|
|
1250
|
+
append({ value });
|
|
1251
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1255
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1256
|
+
if (opts.literalBrackets === true) {
|
|
1257
|
+
state.output += escaped;
|
|
1258
|
+
prev.value = escaped;
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1262
|
+
state.output += prev.value;
|
|
1263
|
+
continue;
|
|
1264
|
+
}
|
|
1265
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1266
|
+
increment("braces");
|
|
1267
|
+
const open = {
|
|
1268
|
+
type: "brace",
|
|
1269
|
+
value,
|
|
1270
|
+
output: "(",
|
|
1271
|
+
outputIndex: state.output.length,
|
|
1272
|
+
tokensIndex: state.tokens.length
|
|
1273
|
+
};
|
|
1274
|
+
braces.push(open);
|
|
1275
|
+
push(open);
|
|
1276
|
+
continue;
|
|
1277
|
+
}
|
|
1278
|
+
if (value === "}") {
|
|
1279
|
+
const brace = braces[braces.length - 1];
|
|
1280
|
+
if (opts.nobrace === true || !brace) {
|
|
1281
|
+
push({ type: "text", value, output: value });
|
|
1282
|
+
continue;
|
|
1283
|
+
}
|
|
1284
|
+
let output = ")";
|
|
1285
|
+
if (brace.dots === true) {
|
|
1286
|
+
const arr = tokens.slice();
|
|
1287
|
+
const range = [];
|
|
1288
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1289
|
+
tokens.pop();
|
|
1290
|
+
if (arr[i].type === "brace") {
|
|
1291
|
+
break;
|
|
1292
|
+
}
|
|
1293
|
+
if (arr[i].type !== "dots") {
|
|
1294
|
+
range.unshift(arr[i].value);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
output = expandRange(range, opts);
|
|
1298
|
+
state.backtrack = true;
|
|
1299
|
+
}
|
|
1300
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1301
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1302
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1303
|
+
brace.value = brace.output = "\\{";
|
|
1304
|
+
value = output = "\\}";
|
|
1305
|
+
state.output = out;
|
|
1306
|
+
for (const t of toks) {
|
|
1307
|
+
state.output += t.output || t.value;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
push({ type: "brace", value, output });
|
|
1311
|
+
decrement("braces");
|
|
1312
|
+
braces.pop();
|
|
1313
|
+
continue;
|
|
1314
|
+
}
|
|
1315
|
+
if (value === "|") {
|
|
1316
|
+
if (extglobs.length > 0) {
|
|
1317
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1318
|
+
}
|
|
1319
|
+
push({ type: "text", value });
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
if (value === ",") {
|
|
1323
|
+
let output = value;
|
|
1324
|
+
const brace = braces[braces.length - 1];
|
|
1325
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1326
|
+
brace.comma = true;
|
|
1327
|
+
output = "|";
|
|
1328
|
+
}
|
|
1329
|
+
push({ type: "comma", value, output });
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (value === "/") {
|
|
1333
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1334
|
+
state.start = state.index + 1;
|
|
1335
|
+
state.consumed = "";
|
|
1336
|
+
state.output = "";
|
|
1337
|
+
tokens.pop();
|
|
1338
|
+
prev = bos;
|
|
1339
|
+
continue;
|
|
1340
|
+
}
|
|
1341
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1342
|
+
continue;
|
|
1343
|
+
}
|
|
1344
|
+
if (value === ".") {
|
|
1345
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1346
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1347
|
+
const brace = braces[braces.length - 1];
|
|
1348
|
+
prev.type = "dots";
|
|
1349
|
+
prev.output += value;
|
|
1350
|
+
prev.value += value;
|
|
1351
|
+
brace.dots = true;
|
|
1352
|
+
continue;
|
|
1353
|
+
}
|
|
1354
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1355
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1359
|
+
continue;
|
|
1360
|
+
}
|
|
1361
|
+
if (value === "?") {
|
|
1362
|
+
const isGroup = prev && prev.value === "(";
|
|
1363
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1364
|
+
extglobOpen("qmark", value);
|
|
1365
|
+
continue;
|
|
1366
|
+
}
|
|
1367
|
+
if (prev && prev.type === "paren") {
|
|
1368
|
+
const next = peek();
|
|
1369
|
+
let output = value;
|
|
1370
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1371
|
+
output = `\\${value}`;
|
|
1372
|
+
}
|
|
1373
|
+
push({ type: "text", value, output });
|
|
1374
|
+
continue;
|
|
1375
|
+
}
|
|
1376
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1377
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1378
|
+
continue;
|
|
1379
|
+
}
|
|
1380
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1381
|
+
continue;
|
|
1382
|
+
}
|
|
1383
|
+
if (value === "!") {
|
|
1384
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1385
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1386
|
+
extglobOpen("negate", value);
|
|
1387
|
+
continue;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1391
|
+
negate();
|
|
1392
|
+
continue;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
if (value === "+") {
|
|
1396
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1397
|
+
extglobOpen("plus", value);
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1401
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1402
|
+
continue;
|
|
1403
|
+
}
|
|
1404
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1405
|
+
push({ type: "plus", value });
|
|
1406
|
+
continue;
|
|
1407
|
+
}
|
|
1408
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1411
|
+
if (value === "@") {
|
|
1412
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1413
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1414
|
+
continue;
|
|
1415
|
+
}
|
|
1416
|
+
push({ type: "text", value });
|
|
1417
|
+
continue;
|
|
1418
|
+
}
|
|
1419
|
+
if (value !== "*") {
|
|
1420
|
+
if (value === "$" || value === "^") {
|
|
1421
|
+
value = `\\${value}`;
|
|
1422
|
+
}
|
|
1423
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1424
|
+
if (match) {
|
|
1425
|
+
value += match[0];
|
|
1426
|
+
state.index += match[0].length;
|
|
1427
|
+
}
|
|
1428
|
+
push({ type: "text", value });
|
|
1429
|
+
continue;
|
|
1430
|
+
}
|
|
1431
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1432
|
+
prev.type = "star";
|
|
1433
|
+
prev.star = true;
|
|
1434
|
+
prev.value += value;
|
|
1435
|
+
prev.output = star;
|
|
1436
|
+
state.backtrack = true;
|
|
1437
|
+
state.globstar = true;
|
|
1438
|
+
consume(value);
|
|
1439
|
+
continue;
|
|
1440
|
+
}
|
|
1441
|
+
let rest = remaining();
|
|
1442
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1443
|
+
extglobOpen("star", value);
|
|
1444
|
+
continue;
|
|
1445
|
+
}
|
|
1446
|
+
if (prev.type === "star") {
|
|
1447
|
+
if (opts.noglobstar === true) {
|
|
1448
|
+
consume(value);
|
|
1449
|
+
continue;
|
|
1450
|
+
}
|
|
1451
|
+
const prior = prev.prev;
|
|
1452
|
+
const before = prior.prev;
|
|
1453
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1454
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1455
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1456
|
+
push({ type: "star", value, output: "" });
|
|
1457
|
+
continue;
|
|
1458
|
+
}
|
|
1459
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1460
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1461
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1462
|
+
push({ type: "star", value, output: "" });
|
|
1463
|
+
continue;
|
|
1464
|
+
}
|
|
1465
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1466
|
+
const after = input[state.index + 4];
|
|
1467
|
+
if (after && after !== "/") {
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
rest = rest.slice(3);
|
|
1471
|
+
consume("/**", 3);
|
|
1472
|
+
}
|
|
1473
|
+
const isEnd = eos() || state.parens > 0 && rest === ")".repeat(state.parens) && !extglobs.some((extglob) => extglob.type === "negate");
|
|
1474
|
+
if (prior.type === "bos" && eos()) {
|
|
1475
|
+
prev.type = "globstar";
|
|
1476
|
+
prev.value += value;
|
|
1477
|
+
prev.output = globstar(opts);
|
|
1478
|
+
state.output = prev.output;
|
|
1479
|
+
state.globstar = true;
|
|
1480
|
+
consume(value);
|
|
1481
|
+
continue;
|
|
1482
|
+
}
|
|
1483
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && isEnd) {
|
|
1484
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1485
|
+
prior.output = `(?:${prior.output}`;
|
|
1486
|
+
prev.type = "globstar";
|
|
1487
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1488
|
+
prev.value += value;
|
|
1489
|
+
state.globstar = true;
|
|
1490
|
+
state.output += prior.output + prev.output;
|
|
1491
|
+
consume(value);
|
|
1492
|
+
continue;
|
|
1493
|
+
}
|
|
1494
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1495
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1496
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1497
|
+
prior.output = `(?:${prior.output}`;
|
|
1498
|
+
prev.type = "globstar";
|
|
1499
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1500
|
+
prev.value += value;
|
|
1501
|
+
state.output += prior.output + prev.output;
|
|
1502
|
+
state.globstar = true;
|
|
1503
|
+
consume(value + advance());
|
|
1504
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1505
|
+
continue;
|
|
1506
|
+
}
|
|
1507
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1508
|
+
prev.type = "globstar";
|
|
1509
|
+
prev.value += value;
|
|
1510
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1511
|
+
state.output = prev.output;
|
|
1512
|
+
state.globstar = true;
|
|
1513
|
+
consume(value + advance());
|
|
1514
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1515
|
+
continue;
|
|
1516
|
+
}
|
|
1517
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1518
|
+
prev.type = "globstar";
|
|
1519
|
+
prev.output = globstar(opts);
|
|
1520
|
+
prev.value += value;
|
|
1521
|
+
state.output += prev.output;
|
|
1522
|
+
state.globstar = true;
|
|
1523
|
+
consume(value);
|
|
1524
|
+
continue;
|
|
1525
|
+
}
|
|
1526
|
+
const token = { type: "star", value, output: star };
|
|
1527
|
+
if (opts.bash === true) {
|
|
1528
|
+
token.output = ".*?";
|
|
1529
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
1530
|
+
token.output = nodot + token.output;
|
|
1531
|
+
}
|
|
1532
|
+
push(token);
|
|
1533
|
+
continue;
|
|
1534
|
+
}
|
|
1535
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1536
|
+
token.output = value;
|
|
1537
|
+
push(token);
|
|
1538
|
+
continue;
|
|
1539
|
+
}
|
|
1540
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1541
|
+
if (prev.type === "dot") {
|
|
1542
|
+
state.output += NO_DOT_SLASH;
|
|
1543
|
+
prev.output += NO_DOT_SLASH;
|
|
1544
|
+
} else if (opts.dot === true) {
|
|
1545
|
+
state.output += NO_DOTS_SLASH;
|
|
1546
|
+
prev.output += NO_DOTS_SLASH;
|
|
1547
|
+
} else {
|
|
1548
|
+
state.output += nodot;
|
|
1549
|
+
prev.output += nodot;
|
|
1550
|
+
}
|
|
1551
|
+
if (peek() !== "*") {
|
|
1552
|
+
state.output += ONE_CHAR;
|
|
1553
|
+
prev.output += ONE_CHAR;
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
push(token);
|
|
1557
|
+
}
|
|
1558
|
+
while (state.brackets > 0) {
|
|
1559
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1560
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1561
|
+
decrement("brackets");
|
|
1562
|
+
}
|
|
1563
|
+
while (state.parens > 0) {
|
|
1564
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1565
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1566
|
+
decrement("parens");
|
|
1567
|
+
}
|
|
1568
|
+
while (state.braces > 0) {
|
|
1569
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1570
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1571
|
+
decrement("braces");
|
|
1572
|
+
}
|
|
1573
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1574
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1575
|
+
}
|
|
1576
|
+
if (state.backtrack === true) {
|
|
1577
|
+
state.output = "";
|
|
1578
|
+
for (const token of state.tokens) {
|
|
1579
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1580
|
+
if (token.suffix) {
|
|
1581
|
+
state.output += token.suffix;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
return state;
|
|
1586
|
+
};
|
|
1587
|
+
parse.fastpaths = (input, options) => {
|
|
1588
|
+
const opts = { ...options };
|
|
1589
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1590
|
+
const len = input.length;
|
|
1591
|
+
if (len > max) {
|
|
1592
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1593
|
+
}
|
|
1594
|
+
input = REPLACEMENTS[input] || input;
|
|
1595
|
+
const {
|
|
1596
|
+
DOT_LITERAL,
|
|
1597
|
+
SLASH_LITERAL,
|
|
1598
|
+
ONE_CHAR,
|
|
1599
|
+
DOTS_SLASH,
|
|
1600
|
+
NO_DOT,
|
|
1601
|
+
NO_DOTS,
|
|
1602
|
+
NO_DOTS_SLASH,
|
|
1603
|
+
STAR,
|
|
1604
|
+
START_ANCHOR
|
|
1605
|
+
} = constants.globChars(opts.windows);
|
|
1606
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1607
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1608
|
+
const capture = opts.capture ? "" : "?:";
|
|
1609
|
+
const state = { negated: false, prefix: "" };
|
|
1610
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
1611
|
+
if (opts.capture) {
|
|
1612
|
+
star = `(${star})`;
|
|
1613
|
+
}
|
|
1614
|
+
const globstar = (opts2) => {
|
|
1615
|
+
if (opts2.noglobstar === true) return star;
|
|
1616
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1617
|
+
};
|
|
1618
|
+
const create = (str) => {
|
|
1619
|
+
switch (str) {
|
|
1620
|
+
case "*":
|
|
1621
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
1622
|
+
case ".*":
|
|
1623
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1624
|
+
case "*.*":
|
|
1625
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1626
|
+
case "*/*":
|
|
1627
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1628
|
+
case "**":
|
|
1629
|
+
return nodot + globstar(opts);
|
|
1630
|
+
case "**/*":
|
|
1631
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1632
|
+
case "**/*.*":
|
|
1633
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1634
|
+
case "**/.*":
|
|
1635
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1636
|
+
default: {
|
|
1637
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1638
|
+
if (!match) return;
|
|
1639
|
+
const source2 = create(match[1]);
|
|
1640
|
+
if (!source2) return;
|
|
1641
|
+
return source2 + DOT_LITERAL + match[2];
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
const output = utils.removePrefix(input, state);
|
|
1646
|
+
let source = create(output);
|
|
1647
|
+
if (source && opts.strictSlashes !== true) {
|
|
1648
|
+
source += `${SLASH_LITERAL}?`;
|
|
1649
|
+
}
|
|
1650
|
+
return source;
|
|
1651
|
+
};
|
|
1652
|
+
module2.exports = parse;
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
|
|
1656
|
+
// node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/picomatch.js
|
|
1657
|
+
var require_picomatch = __commonJS({
|
|
1658
|
+
"node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/picomatch.js"(exports2, module2) {
|
|
1659
|
+
"use strict";
|
|
1660
|
+
var scan = require_scan();
|
|
1661
|
+
var parse = require_parse();
|
|
1662
|
+
var utils = require_utils();
|
|
1663
|
+
var constants = require_constants();
|
|
1664
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1665
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
1666
|
+
if (Array.isArray(glob)) {
|
|
1667
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1668
|
+
const arrayMatcher = (str) => {
|
|
1669
|
+
for (const isMatch of fns) {
|
|
1670
|
+
const state2 = isMatch(str);
|
|
1671
|
+
if (state2) return state2;
|
|
1672
|
+
}
|
|
1673
|
+
return false;
|
|
1674
|
+
};
|
|
1675
|
+
return arrayMatcher;
|
|
1676
|
+
}
|
|
1677
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1678
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1679
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1680
|
+
}
|
|
1681
|
+
const opts = options || {};
|
|
1682
|
+
const posix = opts.windows;
|
|
1683
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1684
|
+
const state = regex.state;
|
|
1685
|
+
delete regex.state;
|
|
1686
|
+
let isIgnored = () => false;
|
|
1687
|
+
if (opts.ignore) {
|
|
1688
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1689
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1690
|
+
}
|
|
1691
|
+
const matcher = (input, returnObject = false) => {
|
|
1692
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
1693
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1694
|
+
if (typeof opts.onResult === "function") {
|
|
1695
|
+
opts.onResult(result);
|
|
1696
|
+
}
|
|
1697
|
+
if (isMatch === false) {
|
|
1698
|
+
result.isMatch = false;
|
|
1699
|
+
return returnObject ? result : false;
|
|
1700
|
+
}
|
|
1701
|
+
if (isIgnored(input)) {
|
|
1702
|
+
if (typeof opts.onIgnore === "function") {
|
|
1703
|
+
opts.onIgnore(result);
|
|
1704
|
+
}
|
|
1705
|
+
result.isMatch = false;
|
|
1706
|
+
return returnObject ? result : false;
|
|
1707
|
+
}
|
|
1708
|
+
if (typeof opts.onMatch === "function") {
|
|
1709
|
+
opts.onMatch(result);
|
|
1710
|
+
}
|
|
1711
|
+
return returnObject ? result : true;
|
|
1712
|
+
};
|
|
1713
|
+
if (returnState) {
|
|
1714
|
+
matcher.state = state;
|
|
1715
|
+
}
|
|
1716
|
+
return matcher;
|
|
1717
|
+
};
|
|
1718
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1719
|
+
if (typeof input !== "string") {
|
|
1720
|
+
throw new TypeError("Expected input to be a string");
|
|
1721
|
+
}
|
|
1722
|
+
if (input === "") {
|
|
1723
|
+
return { isMatch: false, output: "" };
|
|
1724
|
+
}
|
|
1725
|
+
const opts = options || {};
|
|
1726
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1727
|
+
let match = input === glob;
|
|
1728
|
+
let output = match && format ? format(input) : input;
|
|
1729
|
+
if (match === false) {
|
|
1730
|
+
output = format ? format(input) : input;
|
|
1731
|
+
match = output === glob;
|
|
1732
|
+
}
|
|
1733
|
+
if (match === false || opts.capture === true) {
|
|
1734
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
1735
|
+
match = picomatch.matchBase(input, regex, options, posix);
|
|
1736
|
+
} else {
|
|
1737
|
+
match = regex.exec(output);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
return { isMatch: Boolean(match), match, output };
|
|
1741
|
+
};
|
|
1742
|
+
picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
|
|
1743
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1744
|
+
return regex.test(utils.basename(input, { windows: posix }));
|
|
1745
|
+
};
|
|
1746
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
1747
|
+
picomatch.parse = (pattern, options) => {
|
|
1748
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
1749
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
1750
|
+
};
|
|
1751
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
1752
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1753
|
+
if (returnOutput === true) {
|
|
1754
|
+
return state.output;
|
|
1755
|
+
}
|
|
1756
|
+
const opts = options || {};
|
|
1757
|
+
const prepend = opts.contains ? "" : "^";
|
|
1758
|
+
const append = opts.contains ? "" : "$";
|
|
1759
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1760
|
+
if (state && state.negated === true) {
|
|
1761
|
+
source = `^(?!${source}).*$`;
|
|
1762
|
+
}
|
|
1763
|
+
const regex = picomatch.toRegex(source, options);
|
|
1764
|
+
if (returnState === true) {
|
|
1765
|
+
regex.state = state;
|
|
1766
|
+
}
|
|
1767
|
+
return regex;
|
|
1768
|
+
};
|
|
1769
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1770
|
+
if (!input || typeof input !== "string") {
|
|
1771
|
+
throw new TypeError("Expected a non-empty string");
|
|
1772
|
+
}
|
|
1773
|
+
let parsed = { negated: false, fastpaths: true };
|
|
1774
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
1775
|
+
parsed.output = parse.fastpaths(input, options);
|
|
1776
|
+
}
|
|
1777
|
+
if (!parsed.output) {
|
|
1778
|
+
parsed = parse(input, options);
|
|
1779
|
+
}
|
|
1780
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1781
|
+
};
|
|
1782
|
+
picomatch.toRegex = (source, options) => {
|
|
1783
|
+
try {
|
|
1784
|
+
const opts = options || {};
|
|
1785
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1786
|
+
} catch (err) {
|
|
1787
|
+
if (options && options.debug === true) throw err;
|
|
1788
|
+
return /$^/;
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
picomatch.constants = constants;
|
|
1792
|
+
module2.exports = picomatch;
|
|
1793
|
+
}
|
|
1794
|
+
});
|
|
1795
|
+
|
|
1796
|
+
// node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/index.js
|
|
1797
|
+
var require_picomatch2 = __commonJS({
|
|
1798
|
+
"node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/index.js"(exports2, module2) {
|
|
1799
|
+
"use strict";
|
|
1800
|
+
var pico = require_picomatch();
|
|
1801
|
+
var utils = require_utils();
|
|
1802
|
+
function picomatch(glob, options, returnState = false) {
|
|
1803
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
1804
|
+
options = { ...options, windows: utils.isWindows() };
|
|
1805
|
+
}
|
|
1806
|
+
return pico(glob, options, returnState);
|
|
1807
|
+
}
|
|
1808
|
+
Object.assign(picomatch, pico);
|
|
1809
|
+
module2.exports = picomatch;
|
|
1810
|
+
}
|
|
1811
|
+
});
|
|
1812
|
+
|
|
1813
|
+
// node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.7/node_modules/fdir/dist/index.cjs
|
|
38
1814
|
var require_dist = __commonJS({
|
|
39
|
-
"node_modules/.pnpm/fdir@6.5.0/node_modules/fdir/dist/index.cjs"(exports2) {
|
|
1815
|
+
"node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.7/node_modules/fdir/dist/index.cjs"(exports2) {
|
|
40
1816
|
var __create2 = Object.create;
|
|
41
1817
|
var __defProp2 = Object.defineProperty;
|
|
42
1818
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -174,10 +1950,10 @@ var require_dist = __commonJS({
|
|
|
174
1950
|
queue.enqueue();
|
|
175
1951
|
fs$1.realpath(path$1, (error, resolvedPath) => {
|
|
176
1952
|
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
177
|
-
fs$1.stat(resolvedPath, (error$1,
|
|
1953
|
+
fs$1.stat(resolvedPath, (error$1, stat2) => {
|
|
178
1954
|
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
179
|
-
if (
|
|
180
|
-
callback$1(
|
|
1955
|
+
if (stat2.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
|
|
1956
|
+
callback$1(stat2, resolvedPath);
|
|
181
1957
|
queue.dequeue(null, state);
|
|
182
1958
|
});
|
|
183
1959
|
});
|
|
@@ -187,9 +1963,9 @@ var require_dist = __commonJS({
|
|
|
187
1963
|
queue.enqueue();
|
|
188
1964
|
try {
|
|
189
1965
|
const resolvedPath = fs$1.realpathSync(path$1);
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
192
|
-
callback$1(
|
|
1966
|
+
const stat2 = fs$1.statSync(resolvedPath);
|
|
1967
|
+
if (stat2.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
|
|
1968
|
+
callback$1(stat2, resolvedPath);
|
|
193
1969
|
} catch (e) {
|
|
194
1970
|
if (!suppressErrors) throw e;
|
|
195
1971
|
}
|
|
@@ -386,8 +2162,8 @@ var require_dist = __commonJS({
|
|
|
386
2162
|
this.walkDirectory(this.state, path$1, path$1, depth - 1, this.walk);
|
|
387
2163
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
388
2164
|
let path$1 = joinPathWithBasePath(entry.name, directoryPath);
|
|
389
|
-
this.resolveSymlink(path$1, this.state, (
|
|
390
|
-
if (
|
|
2165
|
+
this.resolveSymlink(path$1, this.state, (stat2, resolvedPath) => {
|
|
2166
|
+
if (stat2.isDirectory()) {
|
|
391
2167
|
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
392
2168
|
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;
|
|
393
2169
|
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth - 1, this.walk);
|
|
@@ -438,7 +2214,7 @@ var require_dist = __commonJS({
|
|
|
438
2214
|
var pm = null;
|
|
439
2215
|
try {
|
|
440
2216
|
require.resolve("picomatch");
|
|
441
|
-
pm =
|
|
2217
|
+
pm = require_picomatch2();
|
|
442
2218
|
} catch {
|
|
443
2219
|
}
|
|
444
2220
|
var Builder = class {
|
|
@@ -1422,19 +3198,23 @@ __export(index_exports, {
|
|
|
1422
3198
|
module.exports = __toCommonJS(index_exports);
|
|
1423
3199
|
|
|
1424
3200
|
// src/engine.ts
|
|
1425
|
-
var
|
|
3201
|
+
var import_node_fs4 = require("node:fs");
|
|
1426
3202
|
var import_node_path2 = require("node:path");
|
|
3203
|
+
var import_node_process2 = require("node:process");
|
|
1427
3204
|
var import_fdir = __toESM(require_dist(), 1);
|
|
1428
3205
|
|
|
1429
3206
|
// src/cascade.ts
|
|
1430
3207
|
var import_node_fs = require("node:fs");
|
|
1431
|
-
function
|
|
3208
|
+
function readIgnoreFileText(dirPath, filename) {
|
|
1432
3209
|
try {
|
|
1433
|
-
return (0, import_node_fs.readFileSync)(`${dirPath.replace(/\/+$/, "")}
|
|
3210
|
+
return (0, import_node_fs.readFileSync)(`${dirPath.replace(/\/+$/, "")}/${filename}`, "utf8");
|
|
1434
3211
|
} catch {
|
|
1435
3212
|
return null;
|
|
1436
3213
|
}
|
|
1437
3214
|
}
|
|
3215
|
+
function readGitignoreText(dirPath) {
|
|
3216
|
+
return readIgnoreFileText(dirPath, ".gitignore");
|
|
3217
|
+
}
|
|
1438
3218
|
function splitLines(text) {
|
|
1439
3219
|
return text.split(/\r?\n/);
|
|
1440
3220
|
}
|
|
@@ -1558,10 +3338,58 @@ var PathscopeGitError = class extends Error {
|
|
|
1558
3338
|
}
|
|
1559
3339
|
};
|
|
1560
3340
|
|
|
3341
|
+
// src/win-attr.ts
|
|
3342
|
+
var import_node_module = require("node:module");
|
|
3343
|
+
var import_node_process = require("node:process");
|
|
3344
|
+
var import_meta = {};
|
|
3345
|
+
var cached;
|
|
3346
|
+
function requireForThisFile() {
|
|
3347
|
+
if (typeof __filename !== "undefined") return (0, import_node_module.createRequire)(__filename);
|
|
3348
|
+
return (0, import_node_module.createRequire)(import_meta.url);
|
|
3349
|
+
}
|
|
3350
|
+
var PREBUILD_CANDIDATES = [
|
|
3351
|
+
"../prebuilds/win32-x64/pathscope_win_attr.node",
|
|
3352
|
+
"../../prebuilds/win32-x64/pathscope_win_attr.node"
|
|
3353
|
+
];
|
|
3354
|
+
function loadWinAttr() {
|
|
3355
|
+
if (cached !== void 0) return cached;
|
|
3356
|
+
cached = null;
|
|
3357
|
+
if (import_node_process.platform === "win32") {
|
|
3358
|
+
const require2 = requireForThisFile();
|
|
3359
|
+
for (const candidate of PREBUILD_CANDIDATES) {
|
|
3360
|
+
try {
|
|
3361
|
+
const mod = require2(candidate);
|
|
3362
|
+
if (typeof mod.getHidden === "function" && typeof mod.readdirWithAttrs === "function" && typeof mod.readdirWithAttrsSync === "function") {
|
|
3363
|
+
cached = mod;
|
|
3364
|
+
break;
|
|
3365
|
+
}
|
|
3366
|
+
} catch {
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
return cached;
|
|
3371
|
+
}
|
|
3372
|
+
function hiddenFaceDiagnostic(excludeDotEntriesOn, addonAvailable, isWin) {
|
|
3373
|
+
if (!isWin || !excludeDotEntriesOn || addonAvailable) return null;
|
|
3374
|
+
return {
|
|
3375
|
+
code: "windows-hidden-attributes-unavailable",
|
|
3376
|
+
message: "the Windows hidden-attribute face of the dot category is inert this run (native prebuild not loaded): attribute-hidden, dot-less entries are NOT pruned \u2014 never a silent cut; install integrity or the package tarball is the first suspect"
|
|
3377
|
+
};
|
|
3378
|
+
}
|
|
3379
|
+
|
|
1561
3380
|
// src/exclusion-engine.ts
|
|
1562
3381
|
var nodeExclusionIO = {
|
|
1563
3382
|
exists: (dirKey, name) => Promise.resolve((0, import_node_fs2.existsSync)((0, import_node_path.join)(dirKey, ...name.split("/")))),
|
|
1564
|
-
readGitignore: (dirKey) => Promise.resolve(readGitignoreText(dirKey))
|
|
3383
|
+
readGitignore: (dirKey) => Promise.resolve(readGitignoreText(dirKey)),
|
|
3384
|
+
readIgnoreFamily: (dirKey) => Promise.resolve({
|
|
3385
|
+
ignore: readIgnoreFileText(dirKey, ".ignore"),
|
|
3386
|
+
rgignore: readIgnoreFileText(dirKey, ".rgignore")
|
|
3387
|
+
}),
|
|
3388
|
+
hidden: (dirKey, name) => {
|
|
3389
|
+
const winAttr = loadWinAttr();
|
|
3390
|
+
if (winAttr === null) return Promise.resolve(null);
|
|
3391
|
+
return Promise.resolve(winAttr.getHidden((0, import_node_path.join)(dirKey, ...name.split("/"))) === 1);
|
|
3392
|
+
}
|
|
1565
3393
|
};
|
|
1566
3394
|
function validateOptions(options) {
|
|
1567
3395
|
if (options.mountPresets !== void 0) {
|
|
@@ -1634,18 +3462,20 @@ function parentDirKey(key) {
|
|
|
1634
3462
|
async function createExclusionEngine(rootKey, options = {}, io = nodeExclusionIO) {
|
|
1635
3463
|
validateOptions(options);
|
|
1636
3464
|
const respectGitignore = options.respectGitignore !== false;
|
|
3465
|
+
const respectIgnoreFamily = options.respectIgnoreFamily !== false;
|
|
1637
3466
|
const asRule = (raw) => raw === "" || raw.startsWith("#") || raw === "!" ? null : raw;
|
|
1638
3467
|
const ruleIg = (mounted) => {
|
|
1639
3468
|
const ig = (0, import_ignore.default)();
|
|
1640
3469
|
ig.add([mounted]);
|
|
1641
3470
|
return ig;
|
|
1642
3471
|
};
|
|
1643
|
-
const gitignoreRules = (lines, anchor, prefix) =>
|
|
3472
|
+
const gitignoreRules = (lines, anchor, prefix) => ignoreFileRules(lines, anchor, prefix, "gitignore");
|
|
3473
|
+
const ignoreFileRules = (lines, anchor, prefix, source, ignoreFile) => {
|
|
1644
3474
|
const out = [];
|
|
1645
3475
|
for (const raw of lines) {
|
|
1646
3476
|
const mounted = prefix === "" ? asRule(raw) : reanchorLine(raw, prefix);
|
|
1647
3477
|
if (mounted === null) continue;
|
|
1648
|
-
out.push({ mounted, original: raw, source
|
|
3478
|
+
out.push({ mounted, original: raw, source, gitignoreAnchor: anchor, ...ignoreFile !== void 0 ? { ignoreFile } : {}, ig: ruleIg(mounted) });
|
|
1649
3479
|
}
|
|
1650
3480
|
return out;
|
|
1651
3481
|
};
|
|
@@ -1657,6 +3487,7 @@ async function createExclusionEngine(rootKey, options = {}, io = nodeExclusionIO
|
|
|
1657
3487
|
const hit = { source: r.source, ruleText: r.original };
|
|
1658
3488
|
if (r.presetName !== void 0) hit.presetName = r.presetName;
|
|
1659
3489
|
if (r.gitignoreAnchor !== void 0) hit.gitignoreAnchor = r.gitignoreAnchor;
|
|
3490
|
+
if (r.ignoreFile !== void 0) hit.ignoreFile = r.ignoreFile;
|
|
1660
3491
|
hits.push(hit);
|
|
1661
3492
|
}
|
|
1662
3493
|
return hits;
|
|
@@ -1727,6 +3558,15 @@ async function createExclusionEngine(rootKey, options = {}, io = nodeExclusionIO
|
|
|
1727
3558
|
if (rootIgnoreText !== null) {
|
|
1728
3559
|
coreRules.push(...gitignoreRules(splitLines(rootIgnoreText), "", offRel));
|
|
1729
3560
|
}
|
|
3561
|
+
if (respectIgnoreFamily && io.readIgnoreFamily !== void 0) {
|
|
3562
|
+
const family = await io.readIgnoreFamily(rootKey);
|
|
3563
|
+
if (family.ignore !== null) {
|
|
3564
|
+
coreRules.push(...ignoreFileRules(splitLines(family.ignore), "", offRel, "ignore", ".ignore"));
|
|
3565
|
+
}
|
|
3566
|
+
if (family.rgignore !== null) {
|
|
3567
|
+
coreRules.push(...ignoreFileRules(splitLines(family.rgignore), "", offRel, "ignore", ".rgignore"));
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
1730
3570
|
if (coreRules.length > 0) core.add(coreRules.map((r) => r.mounted));
|
|
1731
3571
|
const policy = (0, import_ignore.default)();
|
|
1732
3572
|
const policyRules = [];
|
|
@@ -1799,82 +3639,109 @@ async function createExclusionEngine(rootKey, options = {}, io = nodeExclusionIO
|
|
|
1799
3639
|
if (policyResult.unignored) return false;
|
|
1800
3640
|
return core.test(canonical).ignored;
|
|
1801
3641
|
};
|
|
1802
|
-
const
|
|
3642
|
+
const runDirectoryVerdict = (name, dirPath, stoneHit, meta, hits) => {
|
|
1803
3643
|
const key = dirPath.replace(/\/+$/, "");
|
|
1804
3644
|
const relDir = key === rootKey ? "" : key.slice(rootKey.length + 1);
|
|
1805
|
-
const hits = [];
|
|
1806
3645
|
if (key !== rootKey) {
|
|
1807
|
-
const stones =
|
|
1808
|
-
hits.push(...stones);
|
|
1809
|
-
if (stones.some((h) => h.enforced)) return
|
|
3646
|
+
const stones = stoneDetail(stoneHit, relDir);
|
|
3647
|
+
if (hits !== void 0) hits.push(...stoneHitEntries(stones));
|
|
3648
|
+
if (stones.some((h) => h.enforced)) return true;
|
|
1810
3649
|
}
|
|
1811
3650
|
const canonicalDir = toCanonical(`${relDir}/`);
|
|
1812
|
-
hits.push(...channelHits(strictRules, canonicalDir));
|
|
1813
|
-
if (strictIg.test(canonicalDir).ignored) return
|
|
3651
|
+
if (hits !== void 0) hits.push(...channelHits(strictRules, canonicalDir));
|
|
3652
|
+
if (strictIg.test(canonicalDir).ignored) return true;
|
|
1814
3653
|
if (overrideIg.test(canonicalDir).ignored) {
|
|
1815
|
-
hits.push(...channelHits(overrideRules, canonicalDir));
|
|
1816
|
-
return
|
|
3654
|
+
if (hits !== void 0) hits.push(...channelHits(overrideRules, canonicalDir));
|
|
3655
|
+
return false;
|
|
3656
|
+
}
|
|
3657
|
+
if (hits !== void 0) {
|
|
3658
|
+
hits.push(...channelHits(coreRules, canonicalDir));
|
|
3659
|
+
hits.push(...channelHits(policyRules, canonicalDir));
|
|
1817
3660
|
}
|
|
1818
|
-
hits.push(...channelHits(coreRules, canonicalDir));
|
|
1819
|
-
hits.push(...channelHits(policyRules, canonicalDir));
|
|
1820
3661
|
const policyResult = policy.test(canonicalDir);
|
|
1821
|
-
if (policyResult.ignored) return
|
|
3662
|
+
if (policyResult.ignored) return true;
|
|
1822
3663
|
if (policyResult.unignored) {
|
|
1823
3664
|
if (core.test(canonicalDir).ignored) {
|
|
1824
3665
|
core.add(`!/${canonicalDir}`);
|
|
1825
3666
|
}
|
|
1826
3667
|
} else if (core.test(canonicalDir).ignored) {
|
|
1827
|
-
return
|
|
3668
|
+
return true;
|
|
1828
3669
|
}
|
|
1829
|
-
if (excludeDotEntries
|
|
1830
|
-
|
|
1831
|
-
|
|
3670
|
+
if (excludeDotEntries) {
|
|
3671
|
+
const byName = name.startsWith(".");
|
|
3672
|
+
const byAttribute = !byName && meta?.hidden === true;
|
|
3673
|
+
if (byName || byAttribute) {
|
|
3674
|
+
if (hits !== void 0) hits.push({ source: "dot", via: byName ? "name" : "attribute" });
|
|
3675
|
+
return true;
|
|
3676
|
+
}
|
|
1832
3677
|
}
|
|
1833
|
-
return
|
|
3678
|
+
return false;
|
|
1834
3679
|
};
|
|
1835
|
-
const
|
|
3680
|
+
const runFileVerdict = (relPath, meta, hits) => {
|
|
1836
3681
|
const canonical = toCanonical(relPath);
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
if (strictIg.test(canonical).ignored) return { admitted: false, hits };
|
|
3682
|
+
if (hits !== void 0) hits.push(...channelHits(strictRules, canonical));
|
|
3683
|
+
if (strictIg.test(canonical).ignored) return false;
|
|
1840
3684
|
if (overrideIg.test(canonical).ignored) {
|
|
1841
|
-
hits.push(...channelHits(overrideRules, canonical));
|
|
1842
|
-
return
|
|
3685
|
+
if (hits !== void 0) hits.push(...channelHits(overrideRules, canonical));
|
|
3686
|
+
return true;
|
|
3687
|
+
}
|
|
3688
|
+
if (hits !== void 0) {
|
|
3689
|
+
hits.push(...channelHits(coreRules, canonical));
|
|
3690
|
+
hits.push(...channelHits(policyRules, canonical));
|
|
1843
3691
|
}
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
3692
|
+
if (combinedExcludes(canonical)) return false;
|
|
3693
|
+
if (excludeDotEntries) {
|
|
3694
|
+
const byName = baseNamePosix(relPath).startsWith(".");
|
|
3695
|
+
const byAttribute = !byName && meta?.hidden === true;
|
|
3696
|
+
if (byName || byAttribute) {
|
|
3697
|
+
if (hits !== void 0) hits.push({ source: "dot", via: byName ? "name" : "attribute" });
|
|
3698
|
+
return false;
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
return true;
|
|
3702
|
+
};
|
|
3703
|
+
const adjudicateDirectoryImpl = (name, dirPath, stoneHit, meta) => {
|
|
3704
|
+
const hits = [];
|
|
3705
|
+
const excluded = runDirectoryVerdict(name, dirPath, stoneHit, meta, hits);
|
|
3706
|
+
return { excluded, hits };
|
|
3707
|
+
};
|
|
3708
|
+
const adjudicateFileImpl = (relPath, meta) => {
|
|
3709
|
+
const hits = [];
|
|
3710
|
+
const admitted = runFileVerdict(relPath, meta, hits);
|
|
3711
|
+
return { admitted, hits };
|
|
3712
|
+
};
|
|
3713
|
+
const foldLayer = (dirPath, text, source, ignoreFile) => {
|
|
3714
|
+
if (text == null || (source === "gitignore" ? !respectGitignore : !respectIgnoreFamily)) return;
|
|
3715
|
+
const key = dirPath.replace(/\/+$/, "");
|
|
3716
|
+
if (key === rootKey) return;
|
|
3717
|
+
const relDir = key.slice(rootKey.length + 1);
|
|
3718
|
+
const rules = ignoreFileRules(splitLines(text), relDir, joinPosix(offRel, relDir), source, ignoreFile);
|
|
3719
|
+
if (rules.length > 0) {
|
|
3720
|
+
core.add(rules.map((r) => r.mounted));
|
|
3721
|
+
coreRules.push(...rules);
|
|
1850
3722
|
}
|
|
1851
|
-
return { admitted: true, hits };
|
|
1852
3723
|
};
|
|
1853
3724
|
return {
|
|
1854
3725
|
rootKey,
|
|
1855
3726
|
stoneNames,
|
|
1856
|
-
excludeDirectory(name, dirPath, stoneHit) {
|
|
1857
|
-
return
|
|
3727
|
+
excludeDirectory(name, dirPath, stoneHit, meta) {
|
|
3728
|
+
return runDirectoryVerdict(name, dirPath, stoneHit, meta, void 0);
|
|
1858
3729
|
},
|
|
1859
3730
|
foldGitignore(dirPath, text) {
|
|
1860
|
-
|
|
1861
|
-
const key = dirPath.replace(/\/+$/, "");
|
|
1862
|
-
if (key === rootKey) return;
|
|
1863
|
-
const relDir = key.slice(rootKey.length + 1);
|
|
1864
|
-
const rules = gitignoreRules(splitLines(text), relDir, joinPosix(offRel, relDir));
|
|
1865
|
-
if (rules.length > 0) {
|
|
1866
|
-
core.add(rules.map((r) => r.mounted));
|
|
1867
|
-
coreRules.push(...rules);
|
|
1868
|
-
}
|
|
3731
|
+
foldLayer(dirPath, text, "gitignore");
|
|
1869
3732
|
},
|
|
1870
|
-
|
|
1871
|
-
|
|
3733
|
+
foldIgnoreFamily(dirPath, texts) {
|
|
3734
|
+
foldLayer(dirPath, texts.ignore ?? null, "ignore", ".ignore");
|
|
3735
|
+
foldLayer(dirPath, texts.rgignore ?? null, "ignore", ".rgignore");
|
|
1872
3736
|
},
|
|
1873
|
-
|
|
1874
|
-
return
|
|
3737
|
+
admitFile(relPath, meta) {
|
|
3738
|
+
return runFileVerdict(relPath, meta, void 0);
|
|
1875
3739
|
},
|
|
1876
|
-
|
|
1877
|
-
return
|
|
3740
|
+
adjudicateDirectory(name, dirPath, stoneHit, meta) {
|
|
3741
|
+
return adjudicateDirectoryImpl(name, dirPath, stoneHit, meta);
|
|
3742
|
+
},
|
|
3743
|
+
adjudicateFile(relPath, meta) {
|
|
3744
|
+
return adjudicateFileImpl(relPath, meta);
|
|
1878
3745
|
},
|
|
1879
3746
|
attributeStones(relDir, stoneHit) {
|
|
1880
3747
|
if (relDir === "") return [];
|
|
@@ -1888,12 +3755,134 @@ async function createExclusionEngine(rootKey, options = {}, io = nodeExclusionIO
|
|
|
1888
3755
|
};
|
|
1889
3756
|
}
|
|
1890
3757
|
|
|
3758
|
+
// src/walk-links.ts
|
|
3759
|
+
var import_node_fs3 = require("node:fs");
|
|
3760
|
+
var nativeFs = __toESM(require("node:fs"), 1);
|
|
3761
|
+
function createLinkRecorder(base = nativeFs) {
|
|
3762
|
+
const recorded = /* @__PURE__ */ new Set();
|
|
3763
|
+
let rootForm = null;
|
|
3764
|
+
const observe = (crawlPath, entries) => {
|
|
3765
|
+
if (rootForm === null) rootForm = crawlPath;
|
|
3766
|
+
const out = [];
|
|
3767
|
+
for (const entry of entries) {
|
|
3768
|
+
let observed = entry;
|
|
3769
|
+
if (entry.isSymbolicLink()) {
|
|
3770
|
+
recorded.add(crawlPath.slice(rootForm.length) + entry.name);
|
|
3771
|
+
} else if (!entry.isFile() && !entry.isDirectory()) {
|
|
3772
|
+
observed = rescueUnknownType(crawlPath + entry.name, entry);
|
|
3773
|
+
if (observed !== entry && observed.isSymbolicLink()) {
|
|
3774
|
+
recorded.add(crawlPath.slice(rootForm.length) + entry.name);
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
out.push(observed);
|
|
3778
|
+
}
|
|
3779
|
+
return out;
|
|
3780
|
+
};
|
|
3781
|
+
const readdir = ((crawlPath, opts, cb) => {
|
|
3782
|
+
base.readdir(crawlPath, opts, (err, entries) => {
|
|
3783
|
+
if (err) return cb(err);
|
|
3784
|
+
cb(null, observe(crawlPath, entries));
|
|
3785
|
+
});
|
|
3786
|
+
});
|
|
3787
|
+
const readdirSync = ((crawlPath, opts) => observe(crawlPath, base.readdirSync(crawlPath, opts)));
|
|
3788
|
+
return {
|
|
3789
|
+
fs: {
|
|
3790
|
+
readdir,
|
|
3791
|
+
readdirSync,
|
|
3792
|
+
realpath: base.realpath,
|
|
3793
|
+
realpathSync: base.realpathSync,
|
|
3794
|
+
stat: base.stat,
|
|
3795
|
+
statSync: base.statSync
|
|
3796
|
+
},
|
|
3797
|
+
links: recorded,
|
|
3798
|
+
observeDirents: observe
|
|
3799
|
+
};
|
|
3800
|
+
}
|
|
3801
|
+
function rescueUnknownType(walkPath, entry) {
|
|
3802
|
+
let stats;
|
|
3803
|
+
try {
|
|
3804
|
+
stats = (0, import_node_fs3.lstatSync)(walkPath);
|
|
3805
|
+
} catch {
|
|
3806
|
+
return entry;
|
|
3807
|
+
}
|
|
3808
|
+
if (stats.isSymbolicLink()) return direntFacade(entry.name, false, false, true);
|
|
3809
|
+
if (stats.isFile()) return direntFacade(entry.name, true, false, false);
|
|
3810
|
+
if (stats.isDirectory()) return direntFacade(entry.name, false, true, false);
|
|
3811
|
+
return entry;
|
|
3812
|
+
}
|
|
3813
|
+
function direntFacade(name, file, dir, link) {
|
|
3814
|
+
return { name, isFile: () => file, isDirectory: () => dir, isSymbolicLink: () => link };
|
|
3815
|
+
}
|
|
3816
|
+
function selectLinks(files, recorded) {
|
|
3817
|
+
return files.filter((rel) => recorded.has(rel));
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
// src/walk-hidden.ts
|
|
3821
|
+
var nativeFs2 = __toESM(require("node:fs"), 1);
|
|
3822
|
+
var ATTR_HIDDEN = 2;
|
|
3823
|
+
var ATTR_DIRECTORY = 16;
|
|
3824
|
+
var ATTR_REPARSE_POINT = 1024;
|
|
3825
|
+
function createHiddenStashFs(winAttr) {
|
|
3826
|
+
const hiddenByDir = /* @__PURE__ */ new Map();
|
|
3827
|
+
const dirKeyOf = (crawlPath) => crawlPath.replace(/\/+$/, "");
|
|
3828
|
+
const facade = (name, attrs) => {
|
|
3829
|
+
const isLink = (attrs & ATTR_REPARSE_POINT) !== 0;
|
|
3830
|
+
const isDir = !isLink && (attrs & ATTR_DIRECTORY) !== 0;
|
|
3831
|
+
return {
|
|
3832
|
+
name,
|
|
3833
|
+
isFile: () => !isDir && !isLink,
|
|
3834
|
+
isDirectory: () => isDir,
|
|
3835
|
+
isSymbolicLink: () => isLink
|
|
3836
|
+
};
|
|
3837
|
+
};
|
|
3838
|
+
const observe = (crawlPath, names, attrs) => {
|
|
3839
|
+
const key = dirKeyOf(crawlPath);
|
|
3840
|
+
const out = [];
|
|
3841
|
+
for (let i = 0; i < names.length; i++) {
|
|
3842
|
+
if ((attrs[i] & ATTR_HIDDEN) !== 0) {
|
|
3843
|
+
let set = hiddenByDir.get(key);
|
|
3844
|
+
if (set === void 0) {
|
|
3845
|
+
set = /* @__PURE__ */ new Set();
|
|
3846
|
+
hiddenByDir.set(key, set);
|
|
3847
|
+
}
|
|
3848
|
+
set.add(names[i]);
|
|
3849
|
+
}
|
|
3850
|
+
out.push(facade(names[i], attrs[i]));
|
|
3851
|
+
}
|
|
3852
|
+
return out;
|
|
3853
|
+
};
|
|
3854
|
+
const readdir = ((crawlPath, opts, cb) => {
|
|
3855
|
+
winAttr.readdirWithAttrs(crawlPath, (err, names, attrs) => {
|
|
3856
|
+
if (err !== null) {
|
|
3857
|
+
cb(err);
|
|
3858
|
+
return;
|
|
3859
|
+
}
|
|
3860
|
+
cb(null, observe(crawlPath, names ?? [], attrs ?? []));
|
|
3861
|
+
});
|
|
3862
|
+
});
|
|
3863
|
+
const readdirSync = ((crawlPath, opts) => {
|
|
3864
|
+
const { names, attrs } = winAttr.readdirWithAttrsSync(crawlPath);
|
|
3865
|
+
return observe(crawlPath, names, attrs);
|
|
3866
|
+
});
|
|
3867
|
+
return {
|
|
3868
|
+
fs: {
|
|
3869
|
+
readdir,
|
|
3870
|
+
readdirSync,
|
|
3871
|
+
realpath: nativeFs2.realpath,
|
|
3872
|
+
realpathSync: nativeFs2.realpathSync,
|
|
3873
|
+
stat: nativeFs2.stat,
|
|
3874
|
+
statSync: nativeFs2.statSync
|
|
3875
|
+
},
|
|
3876
|
+
hiddenFor: (dirKey, name) => hiddenByDir.get(dirKey)?.has(name) === true ? true : void 0
|
|
3877
|
+
};
|
|
3878
|
+
}
|
|
3879
|
+
|
|
1891
3880
|
// src/engine.ts
|
|
1892
3881
|
var DEFAULT_MAX_FILES = 2e3;
|
|
1893
3882
|
async function walkScope(root, options = {}) {
|
|
1894
3883
|
validateOptions(options);
|
|
1895
3884
|
const rootNative = (0, import_node_path2.resolve)(root);
|
|
1896
|
-
if (!(0,
|
|
3885
|
+
if (!(0, import_node_fs4.existsSync)(rootNative)) {
|
|
1897
3886
|
throw new PathscopeConfigError(`scan root does not exist: ${rootNative}`);
|
|
1898
3887
|
}
|
|
1899
3888
|
const scanKey = rootNative.replace(/\\/g, "/");
|
|
@@ -1901,11 +3890,16 @@ async function walkScope(root, options = {}) {
|
|
|
1901
3890
|
const stoneHits = (key) => {
|
|
1902
3891
|
const hits = [];
|
|
1903
3892
|
for (const name of engine.stoneNames) {
|
|
1904
|
-
if ((0,
|
|
3893
|
+
if ((0, import_node_fs4.existsSync)((0, import_node_path2.join)(key, ...name.split("/")))) hits.push(name);
|
|
1905
3894
|
}
|
|
1906
3895
|
return hits;
|
|
1907
3896
|
};
|
|
1908
3897
|
const diagnostics = [];
|
|
3898
|
+
const winAttr = options.excludeDotEntries === false ? null : loadWinAttr();
|
|
3899
|
+
const respectIgnoreFamily = options.respectIgnoreFamily !== false;
|
|
3900
|
+
const attrStash = winAttr === null ? null : createHiddenStashFs(winAttr);
|
|
3901
|
+
const degraded = hiddenFaceDiagnostic(options.excludeDotEntries !== false, attrStash !== null, import_node_process2.platform === "win32");
|
|
3902
|
+
if (degraded !== null) diagnostics.push(degraded);
|
|
1909
3903
|
const stoneReport = [];
|
|
1910
3904
|
const controller = new AbortController();
|
|
1911
3905
|
const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
|
|
@@ -1922,13 +3916,23 @@ async function walkScope(root, options = {}) {
|
|
|
1922
3916
|
}
|
|
1923
3917
|
}
|
|
1924
3918
|
}
|
|
1925
|
-
|
|
3919
|
+
const meta = attrStash !== null && !dirName.startsWith(".") && attrStash.hiddenFor(key.slice(0, key.lastIndexOf("/")), dirName) === true ? { hidden: true } : void 0;
|
|
3920
|
+
if (engine.excludeDirectory(dirName, key, hits, meta)) return true;
|
|
1926
3921
|
engine.foldGitignore(key, readGitignoreText(key));
|
|
3922
|
+
if (respectIgnoreFamily) {
|
|
3923
|
+
engine.foldIgnoreFamily(key, {
|
|
3924
|
+
ignore: readIgnoreFileText(key, ".ignore"),
|
|
3925
|
+
rgignore: readIgnoreFileText(key, ".rgignore")
|
|
3926
|
+
});
|
|
3927
|
+
}
|
|
1927
3928
|
return false;
|
|
1928
3929
|
};
|
|
1929
3930
|
const keepFile = (rel) => {
|
|
1930
3931
|
if (budgetCut) return false;
|
|
1931
|
-
|
|
3932
|
+
const slash = rel.lastIndexOf("/");
|
|
3933
|
+
const name = slash === -1 ? rel : rel.slice(slash + 1);
|
|
3934
|
+
const fileMeta = attrStash !== null && !name.startsWith(".") && attrStash.hiddenFor(slash === -1 ? scanKey : `${scanKey}/${rel.slice(0, slash)}`, name) === true ? { hidden: true } : void 0;
|
|
3935
|
+
if (!engine.admitFile(rel, fileMeta)) return false;
|
|
1932
3936
|
if (included >= maxFiles) {
|
|
1933
3937
|
budgetCut = true;
|
|
1934
3938
|
controller.abort();
|
|
@@ -1942,26 +3946,35 @@ async function walkScope(root, options = {}) {
|
|
|
1942
3946
|
included += 1;
|
|
1943
3947
|
return true;
|
|
1944
3948
|
};
|
|
3949
|
+
const follow = options.followSymlinks === true;
|
|
3950
|
+
const recorder = follow ? null : createLinkRecorder(attrStash?.fs);
|
|
1945
3951
|
const files = await new import_fdir.fdir({
|
|
1946
3952
|
pathSeparator: "/",
|
|
1947
3953
|
exclude: excludeDirectory,
|
|
1948
3954
|
signal: controller.signal,
|
|
1949
|
-
resolveSymlinks:
|
|
3955
|
+
resolveSymlinks: follow,
|
|
1950
3956
|
// Keep descended-through-symlink paths in the scan-root universe instead
|
|
1951
3957
|
// of emitting real (possibly outside-root) paths.
|
|
1952
3958
|
useRealPaths: false,
|
|
1953
3959
|
// Unreadable directories are skipped, ripgrep-style; the loud channel is
|
|
1954
3960
|
// the budget, not per-directory I/O errors.
|
|
1955
|
-
suppressErrors: true
|
|
3961
|
+
suppressErrors: true,
|
|
3962
|
+
fs: recorder?.fs ?? attrStash?.fs
|
|
1956
3963
|
}).withRelativePaths().filter((path3) => keepFile(path3)).crawl(rootNative).withPromise();
|
|
1957
3964
|
stoneReport.sort(
|
|
1958
3965
|
(a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.stoneName < b.stoneName ? -1 : a.stoneName > b.stoneName ? 1 : 0
|
|
1959
3966
|
);
|
|
1960
|
-
|
|
3967
|
+
const sortedFiles = [...files].sort();
|
|
3968
|
+
return {
|
|
3969
|
+
files: sortedFiles,
|
|
3970
|
+
links: recorder ? selectLinks(sortedFiles, recorder.links) : [],
|
|
3971
|
+
diagnostics,
|
|
3972
|
+
stoneHits: stoneReport
|
|
3973
|
+
};
|
|
1961
3974
|
}
|
|
1962
3975
|
|
|
1963
3976
|
// src/explain.ts
|
|
1964
|
-
var
|
|
3977
|
+
var import_node_fs5 = require("node:fs");
|
|
1965
3978
|
var import_node_path3 = require("node:path");
|
|
1966
3979
|
function parseRelPath(relPath) {
|
|
1967
3980
|
if (typeof relPath !== "string") {
|
|
@@ -1991,7 +4004,7 @@ function parseRelPath(relPath) {
|
|
|
1991
4004
|
async function explainScopePath(root, relPath, options = {}) {
|
|
1992
4005
|
const { segments, isDir, isRoot } = parseRelPath(relPath);
|
|
1993
4006
|
const rootNative = (0, import_node_path3.resolve)(root);
|
|
1994
|
-
if (!(0,
|
|
4007
|
+
if (!(0, import_node_fs5.existsSync)(rootNative)) {
|
|
1995
4008
|
throw new PathscopeConfigError(`scan root does not exist: ${rootNative}`);
|
|
1996
4009
|
}
|
|
1997
4010
|
const baseKey = rootNative.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
@@ -2024,9 +4037,11 @@ async function explainScopePath(root, relPath, options = {}) {
|
|
|
2024
4037
|
const relHere = segments.slice(0, i + 1).join("/");
|
|
2025
4038
|
const isLeaf = i === segments.length - 1;
|
|
2026
4039
|
const adjudicateAsDir = isLeaf ? isDir : true;
|
|
4040
|
+
const parentKey = i === 0 ? baseKey : keys[i - 1];
|
|
4041
|
+
const hiddenMeta = io.hidden !== void 0 && !name.startsWith(".") ? { hidden: await io.hidden(parentKey, name) === true } : void 0;
|
|
2027
4042
|
if (adjudicateAsDir) {
|
|
2028
4043
|
const stoneHit = await probeStones(keys[i]);
|
|
2029
|
-
const adj = engine.adjudicateDirectory(name, keys[i], stoneHit);
|
|
4044
|
+
const adj = engine.adjudicateDirectory(name, keys[i], stoneHit, hiddenMeta);
|
|
2030
4045
|
hitChain.push(...withPath(adj.hits, relHere));
|
|
2031
4046
|
if (adj.excluded) {
|
|
2032
4047
|
excluded = true;
|
|
@@ -2035,9 +4050,12 @@ async function explainScopePath(root, relPath, options = {}) {
|
|
|
2035
4050
|
break;
|
|
2036
4051
|
}
|
|
2037
4052
|
engine.foldGitignore(keys[i], await io.readGitignore(keys[i]));
|
|
4053
|
+
if (io.readIgnoreFamily !== void 0 && options.respectIgnoreFamily !== false) {
|
|
4054
|
+
engine.foldIgnoreFamily(keys[i], await io.readIgnoreFamily(keys[i]));
|
|
4055
|
+
}
|
|
2038
4056
|
if (isLeaf) excluded = false;
|
|
2039
4057
|
} else {
|
|
2040
|
-
const adj = engine.adjudicateFile(relHere);
|
|
4058
|
+
const adj = engine.adjudicateFile(relHere, hiddenMeta);
|
|
2041
4059
|
hitChain.push(...withPath(adj.hits, relHere));
|
|
2042
4060
|
excluded = !adj.admitted;
|
|
2043
4061
|
}
|
|
@@ -2210,9 +4228,9 @@ var import_node_path7 = require("node:path");
|
|
|
2210
4228
|
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
2211
4229
|
|
|
2212
4230
|
// node_modules/.pnpm/locate-path@8.0.0/node_modules/locate-path/index.js
|
|
2213
|
-
var
|
|
4231
|
+
var import_node_process3 = __toESM(require("node:process"), 1);
|
|
2214
4232
|
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
2215
|
-
var
|
|
4233
|
+
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
2216
4234
|
var import_node_url = require("node:url");
|
|
2217
4235
|
var typeMappings = {
|
|
2218
4236
|
directory: "isDirectory",
|
|
@@ -2224,25 +4242,25 @@ function checkType(type) {
|
|
|
2224
4242
|
}
|
|
2225
4243
|
throw new Error(`Invalid type specified: ${type}`);
|
|
2226
4244
|
}
|
|
2227
|
-
var matchType = (type,
|
|
4245
|
+
var matchType = (type, stat2) => type === "both" ? stat2.isFile() || stat2.isDirectory() : stat2[typeMappings[type]]();
|
|
2228
4246
|
var toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
|
|
2229
4247
|
function locatePathSync(paths, {
|
|
2230
|
-
cwd =
|
|
4248
|
+
cwd = import_node_process3.default.cwd(),
|
|
2231
4249
|
type = "file",
|
|
2232
4250
|
allowSymlinks = true
|
|
2233
4251
|
} = {}) {
|
|
2234
4252
|
checkType(type);
|
|
2235
4253
|
cwd = toPath(cwd);
|
|
2236
|
-
const statFunction = allowSymlinks ?
|
|
4254
|
+
const statFunction = allowSymlinks ? import_node_fs6.default.statSync : import_node_fs6.default.lstatSync;
|
|
2237
4255
|
for (const path_ of paths) {
|
|
2238
4256
|
try {
|
|
2239
|
-
const
|
|
4257
|
+
const stat2 = statFunction(import_node_path5.default.resolve(cwd, path_), {
|
|
2240
4258
|
throwIfNoEntry: false
|
|
2241
4259
|
});
|
|
2242
|
-
if (!
|
|
4260
|
+
if (!stat2) {
|
|
2243
4261
|
continue;
|
|
2244
4262
|
}
|
|
2245
|
-
if (matchType(type,
|
|
4263
|
+
if (matchType(type, stat2)) {
|
|
2246
4264
|
return path_;
|
|
2247
4265
|
}
|
|
2248
4266
|
} catch {
|