archal 0.9.13 → 0.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -73
- package/bin/archal.cjs +1 -1
- package/clone-assets/apify/tools.json +668 -0
- package/{twin-assets → clone-assets}/discord/fidelity.json +1 -1
- package/{twin-assets → clone-assets}/discord/tools.json +510 -510
- package/clone-assets/github/fidelity.json +31 -0
- package/{twin-assets → clone-assets}/github/tools.json +113 -3
- package/{twin-assets → clone-assets}/google-workspace/fidelity.json +2 -2
- package/{twin-assets → clone-assets}/google-workspace/tools.json +10 -10
- package/{twin-assets → clone-assets}/jira/fidelity.json +44 -4
- package/{twin-assets → clone-assets}/jira/tools.json +1 -1
- package/clone-assets/linear/fidelity.json +36 -0
- package/{twin-assets → clone-assets}/linear/tools.json +1 -1
- package/{twin-assets → clone-assets}/ramp/fidelity.json +1 -1
- package/{twin-assets → clone-assets}/ramp/tools.json +1 -1
- package/clone-assets/slack/fidelity.json +38 -0
- package/{twin-assets → clone-assets}/slack/tools.json +1 -1
- package/clone-assets/stripe/fidelity.json +67 -0
- package/{twin-assets → clone-assets}/stripe/tools.json +42 -11
- package/clone-assets/supabase/fidelity.json +31 -0
- package/{twin-assets → clone-assets}/supabase/tools.json +1 -1
- package/clone-assets/tavily/tools.json +115 -0
- package/dist/cli.cjs +97917 -0
- package/dist/cli.d.cts +1 -0
- package/dist/harness.cjs +62 -0
- package/dist/harness.d.cts +20 -0
- package/dist/index.cjs +5 -87878
- package/dist/index.d.cts +3 -1
- package/dist/seed/dynamic-generator.cjs +8796 -9201
- package/dist/seed/dynamic-generator.d.cts +39 -0
- package/dist/vitest/chunk-2GY4SFKE.js +29279 -0
- package/dist/vitest/{chunk-KTMNDJFB.js → chunk-WVRVNHAX.js} +45255 -44440
- package/dist/vitest/index.cjs +56408 -31519
- package/dist/vitest/index.d.ts +61 -27
- package/dist/vitest/index.js +145 -1807
- package/dist/vitest/runtime/hosted-session-reaper.cjs +34766 -28922
- package/dist/vitest/runtime/hosted-session-reaper.js +1 -2
- package/dist/vitest/runtime/setup-files.js +2 -3
- package/package.json +19 -10
- package/skills/eval/SKILL.md +113 -0
- package/skills/onboard/SKILL.md +67 -36
- package/skills/scenario/SKILL.md +22 -20
- package/skills/vitest/SKILL.md +25 -24
- package/dist/vitest/chunk-L6HSMJ3F.js +0 -2216
- package/dist/vitest/chunk-YJICENME.js +0 -1230
- package/dist/vitest/src-JGHX6UKK.js +0 -94
- package/skills/audit/SKILL.md +0 -55
- package/skills/test/SKILL.md +0 -109
- package/twin-assets/github/fidelity.json +0 -13
- package/twin-assets/linear/fidelity.json +0 -18
- package/twin-assets/slack/fidelity.json +0 -20
- package/twin-assets/stripe/fidelity.json +0 -22
- package/twin-assets/supabase/fidelity.json +0 -13
package/dist/vitest/index.js
CHANGED
|
@@ -2,1777 +2,23 @@ import {
|
|
|
2
2
|
ARCHAL_VITEST_CONFIG_ENV,
|
|
3
3
|
assertSupportedArchalVitestServices,
|
|
4
4
|
bootstrapArchalVitestRouting,
|
|
5
|
-
|
|
5
|
+
fetchArchalClone,
|
|
6
6
|
getInstalledArchalVitestRuntime,
|
|
7
7
|
getInstalledArchalVitestSession,
|
|
8
8
|
readArchalVitestConfig,
|
|
9
|
-
|
|
9
|
+
resetArchalClones,
|
|
10
10
|
resolveRuntimeModule
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2GY4SFKE.js";
|
|
12
12
|
import {
|
|
13
13
|
encodeConfig,
|
|
14
|
+
getCredentials,
|
|
14
15
|
getSessionIdFilePath
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
__commonJS,
|
|
18
|
-
__toESM
|
|
19
|
-
} from "./chunk-YJICENME.js";
|
|
20
|
-
|
|
21
|
-
// ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js
|
|
22
|
-
var require_constants = __commonJS({
|
|
23
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
24
|
-
"use strict";
|
|
25
|
-
var WIN_SLASH = "\\\\/";
|
|
26
|
-
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
27
|
-
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
28
|
-
var DOT_LITERAL = "\\.";
|
|
29
|
-
var PLUS_LITERAL = "\\+";
|
|
30
|
-
var QMARK_LITERAL = "\\?";
|
|
31
|
-
var SLASH_LITERAL = "\\/";
|
|
32
|
-
var ONE_CHAR = "(?=.)";
|
|
33
|
-
var QMARK = "[^/]";
|
|
34
|
-
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
35
|
-
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
36
|
-
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
37
|
-
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
38
|
-
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
39
|
-
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
40
|
-
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
41
|
-
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
42
|
-
var STAR = `${QMARK}*?`;
|
|
43
|
-
var SEP = "/";
|
|
44
|
-
var POSIX_CHARS = {
|
|
45
|
-
DOT_LITERAL,
|
|
46
|
-
PLUS_LITERAL,
|
|
47
|
-
QMARK_LITERAL,
|
|
48
|
-
SLASH_LITERAL,
|
|
49
|
-
ONE_CHAR,
|
|
50
|
-
QMARK,
|
|
51
|
-
END_ANCHOR,
|
|
52
|
-
DOTS_SLASH,
|
|
53
|
-
NO_DOT,
|
|
54
|
-
NO_DOTS,
|
|
55
|
-
NO_DOT_SLASH,
|
|
56
|
-
NO_DOTS_SLASH,
|
|
57
|
-
QMARK_NO_DOT,
|
|
58
|
-
STAR,
|
|
59
|
-
START_ANCHOR,
|
|
60
|
-
SEP
|
|
61
|
-
};
|
|
62
|
-
var WINDOWS_CHARS = {
|
|
63
|
-
...POSIX_CHARS,
|
|
64
|
-
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
65
|
-
QMARK: WIN_NO_SLASH,
|
|
66
|
-
STAR: `${WIN_NO_SLASH}*?`,
|
|
67
|
-
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
68
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
69
|
-
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
70
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
71
|
-
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
72
|
-
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
73
|
-
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
74
|
-
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
75
|
-
SEP: "\\"
|
|
76
|
-
};
|
|
77
|
-
var POSIX_REGEX_SOURCE = {
|
|
78
|
-
__proto__: null,
|
|
79
|
-
alnum: "a-zA-Z0-9",
|
|
80
|
-
alpha: "a-zA-Z",
|
|
81
|
-
ascii: "\\x00-\\x7F",
|
|
82
|
-
blank: " \\t",
|
|
83
|
-
cntrl: "\\x00-\\x1F\\x7F",
|
|
84
|
-
digit: "0-9",
|
|
85
|
-
graph: "\\x21-\\x7E",
|
|
86
|
-
lower: "a-z",
|
|
87
|
-
print: "\\x20-\\x7E ",
|
|
88
|
-
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
89
|
-
space: " \\t\\r\\n\\v\\f",
|
|
90
|
-
upper: "A-Z",
|
|
91
|
-
word: "A-Za-z0-9_",
|
|
92
|
-
xdigit: "A-Fa-f0-9"
|
|
93
|
-
};
|
|
94
|
-
module.exports = {
|
|
95
|
-
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
96
|
-
MAX_LENGTH: 1024 * 64,
|
|
97
|
-
POSIX_REGEX_SOURCE,
|
|
98
|
-
// regular expressions
|
|
99
|
-
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
100
|
-
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
101
|
-
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
102
|
-
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
103
|
-
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
104
|
-
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
105
|
-
// Replace globs with equivalent patterns to reduce parsing time.
|
|
106
|
-
REPLACEMENTS: {
|
|
107
|
-
__proto__: null,
|
|
108
|
-
"***": "*",
|
|
109
|
-
"**/**": "**",
|
|
110
|
-
"**/**/**": "**"
|
|
111
|
-
},
|
|
112
|
-
// Digits
|
|
113
|
-
CHAR_0: 48,
|
|
114
|
-
/* 0 */
|
|
115
|
-
CHAR_9: 57,
|
|
116
|
-
/* 9 */
|
|
117
|
-
// Alphabet chars.
|
|
118
|
-
CHAR_UPPERCASE_A: 65,
|
|
119
|
-
/* A */
|
|
120
|
-
CHAR_LOWERCASE_A: 97,
|
|
121
|
-
/* a */
|
|
122
|
-
CHAR_UPPERCASE_Z: 90,
|
|
123
|
-
/* Z */
|
|
124
|
-
CHAR_LOWERCASE_Z: 122,
|
|
125
|
-
/* z */
|
|
126
|
-
CHAR_LEFT_PARENTHESES: 40,
|
|
127
|
-
/* ( */
|
|
128
|
-
CHAR_RIGHT_PARENTHESES: 41,
|
|
129
|
-
/* ) */
|
|
130
|
-
CHAR_ASTERISK: 42,
|
|
131
|
-
/* * */
|
|
132
|
-
// Non-alphabetic chars.
|
|
133
|
-
CHAR_AMPERSAND: 38,
|
|
134
|
-
/* & */
|
|
135
|
-
CHAR_AT: 64,
|
|
136
|
-
/* @ */
|
|
137
|
-
CHAR_BACKWARD_SLASH: 92,
|
|
138
|
-
/* \ */
|
|
139
|
-
CHAR_CARRIAGE_RETURN: 13,
|
|
140
|
-
/* \r */
|
|
141
|
-
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
142
|
-
/* ^ */
|
|
143
|
-
CHAR_COLON: 58,
|
|
144
|
-
/* : */
|
|
145
|
-
CHAR_COMMA: 44,
|
|
146
|
-
/* , */
|
|
147
|
-
CHAR_DOT: 46,
|
|
148
|
-
/* . */
|
|
149
|
-
CHAR_DOUBLE_QUOTE: 34,
|
|
150
|
-
/* " */
|
|
151
|
-
CHAR_EQUAL: 61,
|
|
152
|
-
/* = */
|
|
153
|
-
CHAR_EXCLAMATION_MARK: 33,
|
|
154
|
-
/* ! */
|
|
155
|
-
CHAR_FORM_FEED: 12,
|
|
156
|
-
/* \f */
|
|
157
|
-
CHAR_FORWARD_SLASH: 47,
|
|
158
|
-
/* / */
|
|
159
|
-
CHAR_GRAVE_ACCENT: 96,
|
|
160
|
-
/* ` */
|
|
161
|
-
CHAR_HASH: 35,
|
|
162
|
-
/* # */
|
|
163
|
-
CHAR_HYPHEN_MINUS: 45,
|
|
164
|
-
/* - */
|
|
165
|
-
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
166
|
-
/* < */
|
|
167
|
-
CHAR_LEFT_CURLY_BRACE: 123,
|
|
168
|
-
/* { */
|
|
169
|
-
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
170
|
-
/* [ */
|
|
171
|
-
CHAR_LINE_FEED: 10,
|
|
172
|
-
/* \n */
|
|
173
|
-
CHAR_NO_BREAK_SPACE: 160,
|
|
174
|
-
/* \u00A0 */
|
|
175
|
-
CHAR_PERCENT: 37,
|
|
176
|
-
/* % */
|
|
177
|
-
CHAR_PLUS: 43,
|
|
178
|
-
/* + */
|
|
179
|
-
CHAR_QUESTION_MARK: 63,
|
|
180
|
-
/* ? */
|
|
181
|
-
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
182
|
-
/* > */
|
|
183
|
-
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
184
|
-
/* } */
|
|
185
|
-
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
186
|
-
/* ] */
|
|
187
|
-
CHAR_SEMICOLON: 59,
|
|
188
|
-
/* ; */
|
|
189
|
-
CHAR_SINGLE_QUOTE: 39,
|
|
190
|
-
/* ' */
|
|
191
|
-
CHAR_SPACE: 32,
|
|
192
|
-
/* */
|
|
193
|
-
CHAR_TAB: 9,
|
|
194
|
-
/* \t */
|
|
195
|
-
CHAR_UNDERSCORE: 95,
|
|
196
|
-
/* _ */
|
|
197
|
-
CHAR_VERTICAL_LINE: 124,
|
|
198
|
-
/* | */
|
|
199
|
-
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
200
|
-
/* \uFEFF */
|
|
201
|
-
/**
|
|
202
|
-
* Create EXTGLOB_CHARS
|
|
203
|
-
*/
|
|
204
|
-
extglobChars(chars) {
|
|
205
|
-
return {
|
|
206
|
-
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
207
|
-
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
208
|
-
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
209
|
-
"*": { type: "star", open: "(?:", close: ")*" },
|
|
210
|
-
"@": { type: "at", open: "(?:", close: ")" }
|
|
211
|
-
};
|
|
212
|
-
},
|
|
213
|
-
/**
|
|
214
|
-
* Create GLOB_CHARS
|
|
215
|
-
*/
|
|
216
|
-
globChars(win32) {
|
|
217
|
-
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
// ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js
|
|
224
|
-
var require_utils = __commonJS({
|
|
225
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js"(exports) {
|
|
226
|
-
"use strict";
|
|
227
|
-
var {
|
|
228
|
-
REGEX_BACKSLASH,
|
|
229
|
-
REGEX_REMOVE_BACKSLASH,
|
|
230
|
-
REGEX_SPECIAL_CHARS,
|
|
231
|
-
REGEX_SPECIAL_CHARS_GLOBAL
|
|
232
|
-
} = require_constants();
|
|
233
|
-
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
234
|
-
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
235
|
-
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
236
|
-
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
237
|
-
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
238
|
-
exports.isWindows = () => {
|
|
239
|
-
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
240
|
-
const platform = navigator.platform.toLowerCase();
|
|
241
|
-
return platform === "win32" || platform === "windows";
|
|
242
|
-
}
|
|
243
|
-
if (typeof process !== "undefined" && process.platform) {
|
|
244
|
-
return process.platform === "win32";
|
|
245
|
-
}
|
|
246
|
-
return false;
|
|
247
|
-
};
|
|
248
|
-
exports.removeBackslashes = (str) => {
|
|
249
|
-
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
250
|
-
return match === "\\" ? "" : match;
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
exports.escapeLast = (input, char, lastIdx) => {
|
|
254
|
-
const idx = input.lastIndexOf(char, lastIdx);
|
|
255
|
-
if (idx === -1) return input;
|
|
256
|
-
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
257
|
-
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
258
|
-
};
|
|
259
|
-
exports.removePrefix = (input, state = {}) => {
|
|
260
|
-
let output = input;
|
|
261
|
-
if (output.startsWith("./")) {
|
|
262
|
-
output = output.slice(2);
|
|
263
|
-
state.prefix = "./";
|
|
264
|
-
}
|
|
265
|
-
return output;
|
|
266
|
-
};
|
|
267
|
-
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
268
|
-
const prepend = options.contains ? "" : "^";
|
|
269
|
-
const append = options.contains ? "" : "$";
|
|
270
|
-
let output = `${prepend}(?:${input})${append}`;
|
|
271
|
-
if (state.negated === true) {
|
|
272
|
-
output = `(?:^(?!${output}).*$)`;
|
|
273
|
-
}
|
|
274
|
-
return output;
|
|
275
|
-
};
|
|
276
|
-
exports.basename = (path, { windows } = {}) => {
|
|
277
|
-
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
278
|
-
const last = segs[segs.length - 1];
|
|
279
|
-
if (last === "") {
|
|
280
|
-
return segs[segs.length - 2];
|
|
281
|
-
}
|
|
282
|
-
return last;
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
// ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js
|
|
288
|
-
var require_scan = __commonJS({
|
|
289
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
290
|
-
"use strict";
|
|
291
|
-
var utils = require_utils();
|
|
292
|
-
var {
|
|
293
|
-
CHAR_ASTERISK,
|
|
294
|
-
/* * */
|
|
295
|
-
CHAR_AT,
|
|
296
|
-
/* @ */
|
|
297
|
-
CHAR_BACKWARD_SLASH,
|
|
298
|
-
/* \ */
|
|
299
|
-
CHAR_COMMA,
|
|
300
|
-
/* , */
|
|
301
|
-
CHAR_DOT,
|
|
302
|
-
/* . */
|
|
303
|
-
CHAR_EXCLAMATION_MARK,
|
|
304
|
-
/* ! */
|
|
305
|
-
CHAR_FORWARD_SLASH,
|
|
306
|
-
/* / */
|
|
307
|
-
CHAR_LEFT_CURLY_BRACE,
|
|
308
|
-
/* { */
|
|
309
|
-
CHAR_LEFT_PARENTHESES,
|
|
310
|
-
/* ( */
|
|
311
|
-
CHAR_LEFT_SQUARE_BRACKET,
|
|
312
|
-
/* [ */
|
|
313
|
-
CHAR_PLUS,
|
|
314
|
-
/* + */
|
|
315
|
-
CHAR_QUESTION_MARK,
|
|
316
|
-
/* ? */
|
|
317
|
-
CHAR_RIGHT_CURLY_BRACE,
|
|
318
|
-
/* } */
|
|
319
|
-
CHAR_RIGHT_PARENTHESES,
|
|
320
|
-
/* ) */
|
|
321
|
-
CHAR_RIGHT_SQUARE_BRACKET
|
|
322
|
-
/* ] */
|
|
323
|
-
} = require_constants();
|
|
324
|
-
var isPathSeparator = (code) => {
|
|
325
|
-
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
326
|
-
};
|
|
327
|
-
var depth = (token) => {
|
|
328
|
-
if (token.isPrefix !== true) {
|
|
329
|
-
token.depth = token.isGlobstar ? Infinity : 1;
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
var scan = (input, options) => {
|
|
333
|
-
const opts = options || {};
|
|
334
|
-
const length = input.length - 1;
|
|
335
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
336
|
-
const slashes = [];
|
|
337
|
-
const tokens = [];
|
|
338
|
-
const parts = [];
|
|
339
|
-
let str = input;
|
|
340
|
-
let index = -1;
|
|
341
|
-
let start = 0;
|
|
342
|
-
let lastIndex = 0;
|
|
343
|
-
let isBrace = false;
|
|
344
|
-
let isBracket = false;
|
|
345
|
-
let isGlob = false;
|
|
346
|
-
let isExtglob = false;
|
|
347
|
-
let isGlobstar = false;
|
|
348
|
-
let braceEscaped = false;
|
|
349
|
-
let backslashes = false;
|
|
350
|
-
let negated = false;
|
|
351
|
-
let negatedExtglob = false;
|
|
352
|
-
let finished = false;
|
|
353
|
-
let braces = 0;
|
|
354
|
-
let prev;
|
|
355
|
-
let code;
|
|
356
|
-
let token = { value: "", depth: 0, isGlob: false };
|
|
357
|
-
const eos = () => index >= length;
|
|
358
|
-
const peek = () => str.charCodeAt(index + 1);
|
|
359
|
-
const advance = () => {
|
|
360
|
-
prev = code;
|
|
361
|
-
return str.charCodeAt(++index);
|
|
362
|
-
};
|
|
363
|
-
while (index < length) {
|
|
364
|
-
code = advance();
|
|
365
|
-
let next;
|
|
366
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
367
|
-
backslashes = token.backslashes = true;
|
|
368
|
-
code = advance();
|
|
369
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
370
|
-
braceEscaped = true;
|
|
371
|
-
}
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
375
|
-
braces++;
|
|
376
|
-
while (eos() !== true && (code = advance())) {
|
|
377
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
378
|
-
backslashes = token.backslashes = true;
|
|
379
|
-
advance();
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
383
|
-
braces++;
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
387
|
-
isBrace = token.isBrace = true;
|
|
388
|
-
isGlob = token.isGlob = true;
|
|
389
|
-
finished = true;
|
|
390
|
-
if (scanToEnd === true) {
|
|
391
|
-
continue;
|
|
392
|
-
}
|
|
393
|
-
break;
|
|
394
|
-
}
|
|
395
|
-
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
396
|
-
isBrace = token.isBrace = true;
|
|
397
|
-
isGlob = token.isGlob = true;
|
|
398
|
-
finished = true;
|
|
399
|
-
if (scanToEnd === true) {
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
405
|
-
braces--;
|
|
406
|
-
if (braces === 0) {
|
|
407
|
-
braceEscaped = false;
|
|
408
|
-
isBrace = token.isBrace = true;
|
|
409
|
-
finished = true;
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
if (scanToEnd === true) {
|
|
415
|
-
continue;
|
|
416
|
-
}
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
if (code === CHAR_FORWARD_SLASH) {
|
|
420
|
-
slashes.push(index);
|
|
421
|
-
tokens.push(token);
|
|
422
|
-
token = { value: "", depth: 0, isGlob: false };
|
|
423
|
-
if (finished === true) continue;
|
|
424
|
-
if (prev === CHAR_DOT && index === start + 1) {
|
|
425
|
-
start += 2;
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
428
|
-
lastIndex = index + 1;
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
if (opts.noext !== true) {
|
|
432
|
-
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
433
|
-
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
434
|
-
isGlob = token.isGlob = true;
|
|
435
|
-
isExtglob = token.isExtglob = true;
|
|
436
|
-
finished = true;
|
|
437
|
-
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
438
|
-
negatedExtglob = true;
|
|
439
|
-
}
|
|
440
|
-
if (scanToEnd === true) {
|
|
441
|
-
while (eos() !== true && (code = advance())) {
|
|
442
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
443
|
-
backslashes = token.backslashes = true;
|
|
444
|
-
code = advance();
|
|
445
|
-
continue;
|
|
446
|
-
}
|
|
447
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
448
|
-
isGlob = token.isGlob = true;
|
|
449
|
-
finished = true;
|
|
450
|
-
break;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
455
|
-
break;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
if (code === CHAR_ASTERISK) {
|
|
459
|
-
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
460
|
-
isGlob = token.isGlob = true;
|
|
461
|
-
finished = true;
|
|
462
|
-
if (scanToEnd === true) {
|
|
463
|
-
continue;
|
|
464
|
-
}
|
|
465
|
-
break;
|
|
466
|
-
}
|
|
467
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
468
|
-
isGlob = token.isGlob = true;
|
|
469
|
-
finished = true;
|
|
470
|
-
if (scanToEnd === true) {
|
|
471
|
-
continue;
|
|
472
|
-
}
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
476
|
-
while (eos() !== true && (next = advance())) {
|
|
477
|
-
if (next === CHAR_BACKWARD_SLASH) {
|
|
478
|
-
backslashes = token.backslashes = true;
|
|
479
|
-
advance();
|
|
480
|
-
continue;
|
|
481
|
-
}
|
|
482
|
-
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
483
|
-
isBracket = token.isBracket = true;
|
|
484
|
-
isGlob = token.isGlob = true;
|
|
485
|
-
finished = true;
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
if (scanToEnd === true) {
|
|
490
|
-
continue;
|
|
491
|
-
}
|
|
492
|
-
break;
|
|
493
|
-
}
|
|
494
|
-
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
495
|
-
negated = token.negated = true;
|
|
496
|
-
start++;
|
|
497
|
-
continue;
|
|
498
|
-
}
|
|
499
|
-
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
500
|
-
isGlob = token.isGlob = true;
|
|
501
|
-
if (scanToEnd === true) {
|
|
502
|
-
while (eos() !== true && (code = advance())) {
|
|
503
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
504
|
-
backslashes = token.backslashes = true;
|
|
505
|
-
code = advance();
|
|
506
|
-
continue;
|
|
507
|
-
}
|
|
508
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
509
|
-
finished = true;
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
break;
|
|
516
|
-
}
|
|
517
|
-
if (isGlob === true) {
|
|
518
|
-
finished = true;
|
|
519
|
-
if (scanToEnd === true) {
|
|
520
|
-
continue;
|
|
521
|
-
}
|
|
522
|
-
break;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
if (opts.noext === true) {
|
|
526
|
-
isExtglob = false;
|
|
527
|
-
isGlob = false;
|
|
528
|
-
}
|
|
529
|
-
let base = str;
|
|
530
|
-
let prefix = "";
|
|
531
|
-
let glob = "";
|
|
532
|
-
if (start > 0) {
|
|
533
|
-
prefix = str.slice(0, start);
|
|
534
|
-
str = str.slice(start);
|
|
535
|
-
lastIndex -= start;
|
|
536
|
-
}
|
|
537
|
-
if (base && isGlob === true && lastIndex > 0) {
|
|
538
|
-
base = str.slice(0, lastIndex);
|
|
539
|
-
glob = str.slice(lastIndex);
|
|
540
|
-
} else if (isGlob === true) {
|
|
541
|
-
base = "";
|
|
542
|
-
glob = str;
|
|
543
|
-
} else {
|
|
544
|
-
base = str;
|
|
545
|
-
}
|
|
546
|
-
if (base && base !== "" && base !== "/" && base !== str) {
|
|
547
|
-
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
548
|
-
base = base.slice(0, -1);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
if (opts.unescape === true) {
|
|
552
|
-
if (glob) glob = utils.removeBackslashes(glob);
|
|
553
|
-
if (base && backslashes === true) {
|
|
554
|
-
base = utils.removeBackslashes(base);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
const state = {
|
|
558
|
-
prefix,
|
|
559
|
-
input,
|
|
560
|
-
start,
|
|
561
|
-
base,
|
|
562
|
-
glob,
|
|
563
|
-
isBrace,
|
|
564
|
-
isBracket,
|
|
565
|
-
isGlob,
|
|
566
|
-
isExtglob,
|
|
567
|
-
isGlobstar,
|
|
568
|
-
negated,
|
|
569
|
-
negatedExtglob
|
|
570
|
-
};
|
|
571
|
-
if (opts.tokens === true) {
|
|
572
|
-
state.maxDepth = 0;
|
|
573
|
-
if (!isPathSeparator(code)) {
|
|
574
|
-
tokens.push(token);
|
|
575
|
-
}
|
|
576
|
-
state.tokens = tokens;
|
|
577
|
-
}
|
|
578
|
-
if (opts.parts === true || opts.tokens === true) {
|
|
579
|
-
let prevIndex;
|
|
580
|
-
for (let idx = 0; idx < slashes.length; idx++) {
|
|
581
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
582
|
-
const i = slashes[idx];
|
|
583
|
-
const value = input.slice(n, i);
|
|
584
|
-
if (opts.tokens) {
|
|
585
|
-
if (idx === 0 && start !== 0) {
|
|
586
|
-
tokens[idx].isPrefix = true;
|
|
587
|
-
tokens[idx].value = prefix;
|
|
588
|
-
} else {
|
|
589
|
-
tokens[idx].value = value;
|
|
590
|
-
}
|
|
591
|
-
depth(tokens[idx]);
|
|
592
|
-
state.maxDepth += tokens[idx].depth;
|
|
593
|
-
}
|
|
594
|
-
if (idx !== 0 || value !== "") {
|
|
595
|
-
parts.push(value);
|
|
596
|
-
}
|
|
597
|
-
prevIndex = i;
|
|
598
|
-
}
|
|
599
|
-
if (prevIndex && prevIndex + 1 < input.length) {
|
|
600
|
-
const value = input.slice(prevIndex + 1);
|
|
601
|
-
parts.push(value);
|
|
602
|
-
if (opts.tokens) {
|
|
603
|
-
tokens[tokens.length - 1].value = value;
|
|
604
|
-
depth(tokens[tokens.length - 1]);
|
|
605
|
-
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
state.slashes = slashes;
|
|
609
|
-
state.parts = parts;
|
|
610
|
-
}
|
|
611
|
-
return state;
|
|
612
|
-
};
|
|
613
|
-
module.exports = scan;
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
// ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js
|
|
618
|
-
var require_parse = __commonJS({
|
|
619
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
620
|
-
"use strict";
|
|
621
|
-
var constants = require_constants();
|
|
622
|
-
var utils = require_utils();
|
|
623
|
-
var {
|
|
624
|
-
MAX_LENGTH,
|
|
625
|
-
POSIX_REGEX_SOURCE,
|
|
626
|
-
REGEX_NON_SPECIAL_CHARS,
|
|
627
|
-
REGEX_SPECIAL_CHARS_BACKREF,
|
|
628
|
-
REPLACEMENTS
|
|
629
|
-
} = constants;
|
|
630
|
-
var expandRange = (args, options) => {
|
|
631
|
-
if (typeof options.expandRange === "function") {
|
|
632
|
-
return options.expandRange(...args, options);
|
|
633
|
-
}
|
|
634
|
-
args.sort();
|
|
635
|
-
const value = `[${args.join("-")}]`;
|
|
636
|
-
try {
|
|
637
|
-
new RegExp(value);
|
|
638
|
-
} catch (ex) {
|
|
639
|
-
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
640
|
-
}
|
|
641
|
-
return value;
|
|
642
|
-
};
|
|
643
|
-
var syntaxError = (type, char) => {
|
|
644
|
-
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
645
|
-
};
|
|
646
|
-
var splitTopLevel = (input) => {
|
|
647
|
-
const parts = [];
|
|
648
|
-
let bracket = 0;
|
|
649
|
-
let paren = 0;
|
|
650
|
-
let quote = 0;
|
|
651
|
-
let value = "";
|
|
652
|
-
let escaped = false;
|
|
653
|
-
for (const ch of input) {
|
|
654
|
-
if (escaped === true) {
|
|
655
|
-
value += ch;
|
|
656
|
-
escaped = false;
|
|
657
|
-
continue;
|
|
658
|
-
}
|
|
659
|
-
if (ch === "\\") {
|
|
660
|
-
value += ch;
|
|
661
|
-
escaped = true;
|
|
662
|
-
continue;
|
|
663
|
-
}
|
|
664
|
-
if (ch === '"') {
|
|
665
|
-
quote = quote === 1 ? 0 : 1;
|
|
666
|
-
value += ch;
|
|
667
|
-
continue;
|
|
668
|
-
}
|
|
669
|
-
if (quote === 0) {
|
|
670
|
-
if (ch === "[") {
|
|
671
|
-
bracket++;
|
|
672
|
-
} else if (ch === "]" && bracket > 0) {
|
|
673
|
-
bracket--;
|
|
674
|
-
} else if (bracket === 0) {
|
|
675
|
-
if (ch === "(") {
|
|
676
|
-
paren++;
|
|
677
|
-
} else if (ch === ")" && paren > 0) {
|
|
678
|
-
paren--;
|
|
679
|
-
} else if (ch === "|" && paren === 0) {
|
|
680
|
-
parts.push(value);
|
|
681
|
-
value = "";
|
|
682
|
-
continue;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
value += ch;
|
|
687
|
-
}
|
|
688
|
-
parts.push(value);
|
|
689
|
-
return parts;
|
|
690
|
-
};
|
|
691
|
-
var isPlainBranch = (branch) => {
|
|
692
|
-
let escaped = false;
|
|
693
|
-
for (const ch of branch) {
|
|
694
|
-
if (escaped === true) {
|
|
695
|
-
escaped = false;
|
|
696
|
-
continue;
|
|
697
|
-
}
|
|
698
|
-
if (ch === "\\") {
|
|
699
|
-
escaped = true;
|
|
700
|
-
continue;
|
|
701
|
-
}
|
|
702
|
-
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
703
|
-
return false;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
return true;
|
|
707
|
-
};
|
|
708
|
-
var normalizeSimpleBranch = (branch) => {
|
|
709
|
-
let value = branch.trim();
|
|
710
|
-
let changed = true;
|
|
711
|
-
while (changed === true) {
|
|
712
|
-
changed = false;
|
|
713
|
-
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
714
|
-
value = value.slice(2, -1);
|
|
715
|
-
changed = true;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
if (!isPlainBranch(value)) {
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
return value.replace(/\\(.)/g, "$1");
|
|
722
|
-
};
|
|
723
|
-
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
724
|
-
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
725
|
-
for (let i = 0; i < values.length; i++) {
|
|
726
|
-
for (let j = i + 1; j < values.length; j++) {
|
|
727
|
-
const a = values[i];
|
|
728
|
-
const b = values[j];
|
|
729
|
-
const char = a[0];
|
|
730
|
-
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
731
|
-
continue;
|
|
732
|
-
}
|
|
733
|
-
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
734
|
-
return true;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
return false;
|
|
739
|
-
};
|
|
740
|
-
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
741
|
-
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
let bracket = 0;
|
|
745
|
-
let paren = 0;
|
|
746
|
-
let quote = 0;
|
|
747
|
-
let escaped = false;
|
|
748
|
-
for (let i = 1; i < pattern.length; i++) {
|
|
749
|
-
const ch = pattern[i];
|
|
750
|
-
if (escaped === true) {
|
|
751
|
-
escaped = false;
|
|
752
|
-
continue;
|
|
753
|
-
}
|
|
754
|
-
if (ch === "\\") {
|
|
755
|
-
escaped = true;
|
|
756
|
-
continue;
|
|
757
|
-
}
|
|
758
|
-
if (ch === '"') {
|
|
759
|
-
quote = quote === 1 ? 0 : 1;
|
|
760
|
-
continue;
|
|
761
|
-
}
|
|
762
|
-
if (quote === 1) {
|
|
763
|
-
continue;
|
|
764
|
-
}
|
|
765
|
-
if (ch === "[") {
|
|
766
|
-
bracket++;
|
|
767
|
-
continue;
|
|
768
|
-
}
|
|
769
|
-
if (ch === "]" && bracket > 0) {
|
|
770
|
-
bracket--;
|
|
771
|
-
continue;
|
|
772
|
-
}
|
|
773
|
-
if (bracket > 0) {
|
|
774
|
-
continue;
|
|
775
|
-
}
|
|
776
|
-
if (ch === "(") {
|
|
777
|
-
paren++;
|
|
778
|
-
continue;
|
|
779
|
-
}
|
|
780
|
-
if (ch === ")") {
|
|
781
|
-
paren--;
|
|
782
|
-
if (paren === 0) {
|
|
783
|
-
if (requireEnd === true && i !== pattern.length - 1) {
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
return {
|
|
787
|
-
type: pattern[0],
|
|
788
|
-
body: pattern.slice(2, i),
|
|
789
|
-
end: i
|
|
790
|
-
};
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
};
|
|
795
|
-
var getStarExtglobSequenceOutput = (pattern) => {
|
|
796
|
-
let index = 0;
|
|
797
|
-
const chars = [];
|
|
798
|
-
while (index < pattern.length) {
|
|
799
|
-
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
800
|
-
if (!match || match.type !== "*") {
|
|
801
|
-
return;
|
|
802
|
-
}
|
|
803
|
-
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
804
|
-
if (branches.length !== 1) {
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
const branch = normalizeSimpleBranch(branches[0]);
|
|
808
|
-
if (!branch || branch.length !== 1) {
|
|
809
|
-
return;
|
|
810
|
-
}
|
|
811
|
-
chars.push(branch);
|
|
812
|
-
index += match.end + 1;
|
|
813
|
-
}
|
|
814
|
-
if (chars.length < 1) {
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
818
|
-
return `${source}*`;
|
|
819
|
-
};
|
|
820
|
-
var repeatedExtglobRecursion = (pattern) => {
|
|
821
|
-
let depth = 0;
|
|
822
|
-
let value = pattern.trim();
|
|
823
|
-
let match = parseRepeatedExtglob(value);
|
|
824
|
-
while (match) {
|
|
825
|
-
depth++;
|
|
826
|
-
value = match.body.trim();
|
|
827
|
-
match = parseRepeatedExtglob(value);
|
|
828
|
-
}
|
|
829
|
-
return depth;
|
|
830
|
-
};
|
|
831
|
-
var analyzeRepeatedExtglob = (body, options) => {
|
|
832
|
-
if (options.maxExtglobRecursion === false) {
|
|
833
|
-
return { risky: false };
|
|
834
|
-
}
|
|
835
|
-
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
836
|
-
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
837
|
-
if (branches.length > 1) {
|
|
838
|
-
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
839
|
-
return { risky: true };
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
for (const branch of branches) {
|
|
843
|
-
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
844
|
-
if (safeOutput) {
|
|
845
|
-
return { risky: true, safeOutput };
|
|
846
|
-
}
|
|
847
|
-
if (repeatedExtglobRecursion(branch) > max) {
|
|
848
|
-
return { risky: true };
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
return { risky: false };
|
|
852
|
-
};
|
|
853
|
-
var parse = (input, options) => {
|
|
854
|
-
if (typeof input !== "string") {
|
|
855
|
-
throw new TypeError("Expected a string");
|
|
856
|
-
}
|
|
857
|
-
input = REPLACEMENTS[input] || input;
|
|
858
|
-
const opts = { ...options };
|
|
859
|
-
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
860
|
-
let len = input.length;
|
|
861
|
-
if (len > max) {
|
|
862
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
863
|
-
}
|
|
864
|
-
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
865
|
-
const tokens = [bos];
|
|
866
|
-
const capture = opts.capture ? "" : "?:";
|
|
867
|
-
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
868
|
-
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
869
|
-
const {
|
|
870
|
-
DOT_LITERAL,
|
|
871
|
-
PLUS_LITERAL,
|
|
872
|
-
SLASH_LITERAL,
|
|
873
|
-
ONE_CHAR,
|
|
874
|
-
DOTS_SLASH,
|
|
875
|
-
NO_DOT,
|
|
876
|
-
NO_DOT_SLASH,
|
|
877
|
-
NO_DOTS_SLASH,
|
|
878
|
-
QMARK,
|
|
879
|
-
QMARK_NO_DOT,
|
|
880
|
-
STAR,
|
|
881
|
-
START_ANCHOR
|
|
882
|
-
} = PLATFORM_CHARS;
|
|
883
|
-
const globstar = (opts2) => {
|
|
884
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
885
|
-
};
|
|
886
|
-
const nodot = opts.dot ? "" : NO_DOT;
|
|
887
|
-
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
888
|
-
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
889
|
-
if (opts.capture) {
|
|
890
|
-
star = `(${star})`;
|
|
891
|
-
}
|
|
892
|
-
if (typeof opts.noext === "boolean") {
|
|
893
|
-
opts.noextglob = opts.noext;
|
|
894
|
-
}
|
|
895
|
-
const state = {
|
|
896
|
-
input,
|
|
897
|
-
index: -1,
|
|
898
|
-
start: 0,
|
|
899
|
-
dot: opts.dot === true,
|
|
900
|
-
consumed: "",
|
|
901
|
-
output: "",
|
|
902
|
-
prefix: "",
|
|
903
|
-
backtrack: false,
|
|
904
|
-
negated: false,
|
|
905
|
-
brackets: 0,
|
|
906
|
-
braces: 0,
|
|
907
|
-
parens: 0,
|
|
908
|
-
quotes: 0,
|
|
909
|
-
globstar: false,
|
|
910
|
-
tokens
|
|
911
|
-
};
|
|
912
|
-
input = utils.removePrefix(input, state);
|
|
913
|
-
len = input.length;
|
|
914
|
-
const extglobs = [];
|
|
915
|
-
const braces = [];
|
|
916
|
-
const stack = [];
|
|
917
|
-
let prev = bos;
|
|
918
|
-
let value;
|
|
919
|
-
const eos = () => state.index === len - 1;
|
|
920
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
921
|
-
const advance = state.advance = () => input[++state.index] || "";
|
|
922
|
-
const remaining = () => input.slice(state.index + 1);
|
|
923
|
-
const consume = (value2 = "", num = 0) => {
|
|
924
|
-
state.consumed += value2;
|
|
925
|
-
state.index += num;
|
|
926
|
-
};
|
|
927
|
-
const append = (token) => {
|
|
928
|
-
state.output += token.output != null ? token.output : token.value;
|
|
929
|
-
consume(token.value);
|
|
930
|
-
};
|
|
931
|
-
const negate = () => {
|
|
932
|
-
let count = 1;
|
|
933
|
-
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
934
|
-
advance();
|
|
935
|
-
state.start++;
|
|
936
|
-
count++;
|
|
937
|
-
}
|
|
938
|
-
if (count % 2 === 0) {
|
|
939
|
-
return false;
|
|
940
|
-
}
|
|
941
|
-
state.negated = true;
|
|
942
|
-
state.start++;
|
|
943
|
-
return true;
|
|
944
|
-
};
|
|
945
|
-
const increment = (type) => {
|
|
946
|
-
state[type]++;
|
|
947
|
-
stack.push(type);
|
|
948
|
-
};
|
|
949
|
-
const decrement = (type) => {
|
|
950
|
-
state[type]--;
|
|
951
|
-
stack.pop();
|
|
952
|
-
};
|
|
953
|
-
const push = (tok) => {
|
|
954
|
-
if (prev.type === "globstar") {
|
|
955
|
-
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
956
|
-
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
957
|
-
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
958
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
959
|
-
prev.type = "star";
|
|
960
|
-
prev.value = "*";
|
|
961
|
-
prev.output = star;
|
|
962
|
-
state.output += prev.output;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
if (extglobs.length && tok.type !== "paren") {
|
|
966
|
-
extglobs[extglobs.length - 1].inner += tok.value;
|
|
967
|
-
}
|
|
968
|
-
if (tok.value || tok.output) append(tok);
|
|
969
|
-
if (prev && prev.type === "text" && tok.type === "text") {
|
|
970
|
-
prev.output = (prev.output || prev.value) + tok.value;
|
|
971
|
-
prev.value += tok.value;
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
tok.prev = prev;
|
|
975
|
-
tokens.push(tok);
|
|
976
|
-
prev = tok;
|
|
977
|
-
};
|
|
978
|
-
const extglobOpen = (type, value2) => {
|
|
979
|
-
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
980
|
-
token.prev = prev;
|
|
981
|
-
token.parens = state.parens;
|
|
982
|
-
token.output = state.output;
|
|
983
|
-
token.startIndex = state.index;
|
|
984
|
-
token.tokensIndex = tokens.length;
|
|
985
|
-
const output = (opts.capture ? "(" : "") + token.open;
|
|
986
|
-
increment("parens");
|
|
987
|
-
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
988
|
-
push({ type: "paren", extglob: true, value: advance(), output });
|
|
989
|
-
extglobs.push(token);
|
|
990
|
-
};
|
|
991
|
-
const extglobClose = (token) => {
|
|
992
|
-
const literal = input.slice(token.startIndex, state.index + 1);
|
|
993
|
-
const body = input.slice(token.startIndex + 2, state.index);
|
|
994
|
-
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
995
|
-
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
996
|
-
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
997
|
-
const open = tokens[token.tokensIndex];
|
|
998
|
-
open.type = "text";
|
|
999
|
-
open.value = literal;
|
|
1000
|
-
open.output = safeOutput || utils.escapeRegex(literal);
|
|
1001
|
-
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
1002
|
-
tokens[i].value = "";
|
|
1003
|
-
tokens[i].output = "";
|
|
1004
|
-
delete tokens[i].suffix;
|
|
1005
|
-
}
|
|
1006
|
-
state.output = token.output + open.output;
|
|
1007
|
-
state.backtrack = true;
|
|
1008
|
-
push({ type: "paren", extglob: true, value, output: "" });
|
|
1009
|
-
decrement("parens");
|
|
1010
|
-
return;
|
|
1011
|
-
}
|
|
1012
|
-
let output = token.close + (opts.capture ? ")" : "");
|
|
1013
|
-
let rest;
|
|
1014
|
-
if (token.type === "negate") {
|
|
1015
|
-
let extglobStar = star;
|
|
1016
|
-
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
1017
|
-
extglobStar = globstar(opts);
|
|
1018
|
-
}
|
|
1019
|
-
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
1020
|
-
output = token.close = `)$))${extglobStar}`;
|
|
1021
|
-
}
|
|
1022
|
-
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
1023
|
-
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
1024
|
-
output = token.close = `)${expression})${extglobStar})`;
|
|
1025
|
-
}
|
|
1026
|
-
if (token.prev.type === "bos") {
|
|
1027
|
-
state.negatedExtglob = true;
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
push({ type: "paren", extglob: true, value, output });
|
|
1031
|
-
decrement("parens");
|
|
1032
|
-
};
|
|
1033
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1034
|
-
let backslashes = false;
|
|
1035
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1036
|
-
if (first === "\\") {
|
|
1037
|
-
backslashes = true;
|
|
1038
|
-
return m;
|
|
1039
|
-
}
|
|
1040
|
-
if (first === "?") {
|
|
1041
|
-
if (esc) {
|
|
1042
|
-
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
1043
|
-
}
|
|
1044
|
-
if (index === 0) {
|
|
1045
|
-
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
1046
|
-
}
|
|
1047
|
-
return QMARK.repeat(chars.length);
|
|
1048
|
-
}
|
|
1049
|
-
if (first === ".") {
|
|
1050
|
-
return DOT_LITERAL.repeat(chars.length);
|
|
1051
|
-
}
|
|
1052
|
-
if (first === "*") {
|
|
1053
|
-
if (esc) {
|
|
1054
|
-
return esc + first + (rest ? star : "");
|
|
1055
|
-
}
|
|
1056
|
-
return star;
|
|
1057
|
-
}
|
|
1058
|
-
return esc ? m : `\\${m}`;
|
|
1059
|
-
});
|
|
1060
|
-
if (backslashes === true) {
|
|
1061
|
-
if (opts.unescape === true) {
|
|
1062
|
-
output = output.replace(/\\/g, "");
|
|
1063
|
-
} else {
|
|
1064
|
-
output = output.replace(/\\+/g, (m) => {
|
|
1065
|
-
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
if (output === input && opts.contains === true) {
|
|
1070
|
-
state.output = input;
|
|
1071
|
-
return state;
|
|
1072
|
-
}
|
|
1073
|
-
state.output = utils.wrapOutput(output, state, options);
|
|
1074
|
-
return state;
|
|
1075
|
-
}
|
|
1076
|
-
while (!eos()) {
|
|
1077
|
-
value = advance();
|
|
1078
|
-
if (value === "\0") {
|
|
1079
|
-
continue;
|
|
1080
|
-
}
|
|
1081
|
-
if (value === "\\") {
|
|
1082
|
-
const next = peek();
|
|
1083
|
-
if (next === "/" && opts.bash !== true) {
|
|
1084
|
-
continue;
|
|
1085
|
-
}
|
|
1086
|
-
if (next === "." || next === ";") {
|
|
1087
|
-
continue;
|
|
1088
|
-
}
|
|
1089
|
-
if (!next) {
|
|
1090
|
-
value += "\\";
|
|
1091
|
-
push({ type: "text", value });
|
|
1092
|
-
continue;
|
|
1093
|
-
}
|
|
1094
|
-
const match = /^\\+/.exec(remaining());
|
|
1095
|
-
let slashes = 0;
|
|
1096
|
-
if (match && match[0].length > 2) {
|
|
1097
|
-
slashes = match[0].length;
|
|
1098
|
-
state.index += slashes;
|
|
1099
|
-
if (slashes % 2 !== 0) {
|
|
1100
|
-
value += "\\";
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
if (opts.unescape === true) {
|
|
1104
|
-
value = advance();
|
|
1105
|
-
} else {
|
|
1106
|
-
value += advance();
|
|
1107
|
-
}
|
|
1108
|
-
if (state.brackets === 0) {
|
|
1109
|
-
push({ type: "text", value });
|
|
1110
|
-
continue;
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1114
|
-
if (opts.posix !== false && value === ":") {
|
|
1115
|
-
const inner = prev.value.slice(1);
|
|
1116
|
-
if (inner.includes("[")) {
|
|
1117
|
-
prev.posix = true;
|
|
1118
|
-
if (inner.includes(":")) {
|
|
1119
|
-
const idx = prev.value.lastIndexOf("[");
|
|
1120
|
-
const pre = prev.value.slice(0, idx);
|
|
1121
|
-
const rest2 = prev.value.slice(idx + 2);
|
|
1122
|
-
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
1123
|
-
if (posix) {
|
|
1124
|
-
prev.value = pre + posix;
|
|
1125
|
-
state.backtrack = true;
|
|
1126
|
-
advance();
|
|
1127
|
-
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
1128
|
-
bos.output = ONE_CHAR;
|
|
1129
|
-
}
|
|
1130
|
-
continue;
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
1136
|
-
value = `\\${value}`;
|
|
1137
|
-
}
|
|
1138
|
-
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
1139
|
-
value = `\\${value}`;
|
|
1140
|
-
}
|
|
1141
|
-
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
1142
|
-
value = "^";
|
|
1143
|
-
}
|
|
1144
|
-
prev.value += value;
|
|
1145
|
-
append({ value });
|
|
1146
|
-
continue;
|
|
1147
|
-
}
|
|
1148
|
-
if (state.quotes === 1 && value !== '"') {
|
|
1149
|
-
value = utils.escapeRegex(value);
|
|
1150
|
-
prev.value += value;
|
|
1151
|
-
append({ value });
|
|
1152
|
-
continue;
|
|
1153
|
-
}
|
|
1154
|
-
if (value === '"') {
|
|
1155
|
-
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1156
|
-
if (opts.keepQuotes === true) {
|
|
1157
|
-
push({ type: "text", value });
|
|
1158
|
-
}
|
|
1159
|
-
continue;
|
|
1160
|
-
}
|
|
1161
|
-
if (value === "(") {
|
|
1162
|
-
increment("parens");
|
|
1163
|
-
push({ type: "paren", value });
|
|
1164
|
-
continue;
|
|
1165
|
-
}
|
|
1166
|
-
if (value === ")") {
|
|
1167
|
-
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
1168
|
-
throw new SyntaxError(syntaxError("opening", "("));
|
|
1169
|
-
}
|
|
1170
|
-
const extglob = extglobs[extglobs.length - 1];
|
|
1171
|
-
if (extglob && state.parens === extglob.parens + 1) {
|
|
1172
|
-
extglobClose(extglobs.pop());
|
|
1173
|
-
continue;
|
|
1174
|
-
}
|
|
1175
|
-
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1176
|
-
decrement("parens");
|
|
1177
|
-
continue;
|
|
1178
|
-
}
|
|
1179
|
-
if (value === "[") {
|
|
1180
|
-
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1181
|
-
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
1182
|
-
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1183
|
-
}
|
|
1184
|
-
value = `\\${value}`;
|
|
1185
|
-
} else {
|
|
1186
|
-
increment("brackets");
|
|
1187
|
-
}
|
|
1188
|
-
push({ type: "bracket", value });
|
|
1189
|
-
continue;
|
|
1190
|
-
}
|
|
1191
|
-
if (value === "]") {
|
|
1192
|
-
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1193
|
-
push({ type: "text", value, output: `\\${value}` });
|
|
1194
|
-
continue;
|
|
1195
|
-
}
|
|
1196
|
-
if (state.brackets === 0) {
|
|
1197
|
-
if (opts.strictBrackets === true) {
|
|
1198
|
-
throw new SyntaxError(syntaxError("opening", "["));
|
|
1199
|
-
}
|
|
1200
|
-
push({ type: "text", value, output: `\\${value}` });
|
|
1201
|
-
continue;
|
|
1202
|
-
}
|
|
1203
|
-
decrement("brackets");
|
|
1204
|
-
const prevValue = prev.value.slice(1);
|
|
1205
|
-
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
1206
|
-
value = `/${value}`;
|
|
1207
|
-
}
|
|
1208
|
-
prev.value += value;
|
|
1209
|
-
append({ value });
|
|
1210
|
-
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
1211
|
-
continue;
|
|
1212
|
-
}
|
|
1213
|
-
const escaped = utils.escapeRegex(prev.value);
|
|
1214
|
-
state.output = state.output.slice(0, -prev.value.length);
|
|
1215
|
-
if (opts.literalBrackets === true) {
|
|
1216
|
-
state.output += escaped;
|
|
1217
|
-
prev.value = escaped;
|
|
1218
|
-
continue;
|
|
1219
|
-
}
|
|
1220
|
-
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1221
|
-
state.output += prev.value;
|
|
1222
|
-
continue;
|
|
1223
|
-
}
|
|
1224
|
-
if (value === "{" && opts.nobrace !== true) {
|
|
1225
|
-
increment("braces");
|
|
1226
|
-
const open = {
|
|
1227
|
-
type: "brace",
|
|
1228
|
-
value,
|
|
1229
|
-
output: "(",
|
|
1230
|
-
outputIndex: state.output.length,
|
|
1231
|
-
tokensIndex: state.tokens.length
|
|
1232
|
-
};
|
|
1233
|
-
braces.push(open);
|
|
1234
|
-
push(open);
|
|
1235
|
-
continue;
|
|
1236
|
-
}
|
|
1237
|
-
if (value === "}") {
|
|
1238
|
-
const brace = braces[braces.length - 1];
|
|
1239
|
-
if (opts.nobrace === true || !brace) {
|
|
1240
|
-
push({ type: "text", value, output: value });
|
|
1241
|
-
continue;
|
|
1242
|
-
}
|
|
1243
|
-
let output = ")";
|
|
1244
|
-
if (brace.dots === true) {
|
|
1245
|
-
const arr = tokens.slice();
|
|
1246
|
-
const range = [];
|
|
1247
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1248
|
-
tokens.pop();
|
|
1249
|
-
if (arr[i].type === "brace") {
|
|
1250
|
-
break;
|
|
1251
|
-
}
|
|
1252
|
-
if (arr[i].type !== "dots") {
|
|
1253
|
-
range.unshift(arr[i].value);
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
output = expandRange(range, opts);
|
|
1257
|
-
state.backtrack = true;
|
|
1258
|
-
}
|
|
1259
|
-
if (brace.comma !== true && brace.dots !== true) {
|
|
1260
|
-
const out = state.output.slice(0, brace.outputIndex);
|
|
1261
|
-
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1262
|
-
brace.value = brace.output = "\\{";
|
|
1263
|
-
value = output = "\\}";
|
|
1264
|
-
state.output = out;
|
|
1265
|
-
for (const t of toks) {
|
|
1266
|
-
state.output += t.output || t.value;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
push({ type: "brace", value, output });
|
|
1270
|
-
decrement("braces");
|
|
1271
|
-
braces.pop();
|
|
1272
|
-
continue;
|
|
1273
|
-
}
|
|
1274
|
-
if (value === "|") {
|
|
1275
|
-
if (extglobs.length > 0) {
|
|
1276
|
-
extglobs[extglobs.length - 1].conditions++;
|
|
1277
|
-
}
|
|
1278
|
-
push({ type: "text", value });
|
|
1279
|
-
continue;
|
|
1280
|
-
}
|
|
1281
|
-
if (value === ",") {
|
|
1282
|
-
let output = value;
|
|
1283
|
-
const brace = braces[braces.length - 1];
|
|
1284
|
-
if (brace && stack[stack.length - 1] === "braces") {
|
|
1285
|
-
brace.comma = true;
|
|
1286
|
-
output = "|";
|
|
1287
|
-
}
|
|
1288
|
-
push({ type: "comma", value, output });
|
|
1289
|
-
continue;
|
|
1290
|
-
}
|
|
1291
|
-
if (value === "/") {
|
|
1292
|
-
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1293
|
-
state.start = state.index + 1;
|
|
1294
|
-
state.consumed = "";
|
|
1295
|
-
state.output = "";
|
|
1296
|
-
tokens.pop();
|
|
1297
|
-
prev = bos;
|
|
1298
|
-
continue;
|
|
1299
|
-
}
|
|
1300
|
-
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1301
|
-
continue;
|
|
1302
|
-
}
|
|
1303
|
-
if (value === ".") {
|
|
1304
|
-
if (state.braces > 0 && prev.type === "dot") {
|
|
1305
|
-
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1306
|
-
const brace = braces[braces.length - 1];
|
|
1307
|
-
prev.type = "dots";
|
|
1308
|
-
prev.output += value;
|
|
1309
|
-
prev.value += value;
|
|
1310
|
-
brace.dots = true;
|
|
1311
|
-
continue;
|
|
1312
|
-
}
|
|
1313
|
-
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1314
|
-
push({ type: "text", value, output: DOT_LITERAL });
|
|
1315
|
-
continue;
|
|
1316
|
-
}
|
|
1317
|
-
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1318
|
-
continue;
|
|
1319
|
-
}
|
|
1320
|
-
if (value === "?") {
|
|
1321
|
-
const isGroup = prev && prev.value === "(";
|
|
1322
|
-
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1323
|
-
extglobOpen("qmark", value);
|
|
1324
|
-
continue;
|
|
1325
|
-
}
|
|
1326
|
-
if (prev && prev.type === "paren") {
|
|
1327
|
-
const next = peek();
|
|
1328
|
-
let output = value;
|
|
1329
|
-
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1330
|
-
output = `\\${value}`;
|
|
1331
|
-
}
|
|
1332
|
-
push({ type: "text", value, output });
|
|
1333
|
-
continue;
|
|
1334
|
-
}
|
|
1335
|
-
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1336
|
-
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1337
|
-
continue;
|
|
1338
|
-
}
|
|
1339
|
-
push({ type: "qmark", value, output: QMARK });
|
|
1340
|
-
continue;
|
|
1341
|
-
}
|
|
1342
|
-
if (value === "!") {
|
|
1343
|
-
if (opts.noextglob !== true && peek() === "(") {
|
|
1344
|
-
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1345
|
-
extglobOpen("negate", value);
|
|
1346
|
-
continue;
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
if (opts.nonegate !== true && state.index === 0) {
|
|
1350
|
-
negate();
|
|
1351
|
-
continue;
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
if (value === "+") {
|
|
1355
|
-
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1356
|
-
extglobOpen("plus", value);
|
|
1357
|
-
continue;
|
|
1358
|
-
}
|
|
1359
|
-
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1360
|
-
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1361
|
-
continue;
|
|
1362
|
-
}
|
|
1363
|
-
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1364
|
-
push({ type: "plus", value });
|
|
1365
|
-
continue;
|
|
1366
|
-
}
|
|
1367
|
-
push({ type: "plus", value: PLUS_LITERAL });
|
|
1368
|
-
continue;
|
|
1369
|
-
}
|
|
1370
|
-
if (value === "@") {
|
|
1371
|
-
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1372
|
-
push({ type: "at", extglob: true, value, output: "" });
|
|
1373
|
-
continue;
|
|
1374
|
-
}
|
|
1375
|
-
push({ type: "text", value });
|
|
1376
|
-
continue;
|
|
1377
|
-
}
|
|
1378
|
-
if (value !== "*") {
|
|
1379
|
-
if (value === "$" || value === "^") {
|
|
1380
|
-
value = `\\${value}`;
|
|
1381
|
-
}
|
|
1382
|
-
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1383
|
-
if (match) {
|
|
1384
|
-
value += match[0];
|
|
1385
|
-
state.index += match[0].length;
|
|
1386
|
-
}
|
|
1387
|
-
push({ type: "text", value });
|
|
1388
|
-
continue;
|
|
1389
|
-
}
|
|
1390
|
-
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1391
|
-
prev.type = "star";
|
|
1392
|
-
prev.star = true;
|
|
1393
|
-
prev.value += value;
|
|
1394
|
-
prev.output = star;
|
|
1395
|
-
state.backtrack = true;
|
|
1396
|
-
state.globstar = true;
|
|
1397
|
-
consume(value);
|
|
1398
|
-
continue;
|
|
1399
|
-
}
|
|
1400
|
-
let rest = remaining();
|
|
1401
|
-
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1402
|
-
extglobOpen("star", value);
|
|
1403
|
-
continue;
|
|
1404
|
-
}
|
|
1405
|
-
if (prev.type === "star") {
|
|
1406
|
-
if (opts.noglobstar === true) {
|
|
1407
|
-
consume(value);
|
|
1408
|
-
continue;
|
|
1409
|
-
}
|
|
1410
|
-
const prior = prev.prev;
|
|
1411
|
-
const before = prior.prev;
|
|
1412
|
-
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1413
|
-
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1414
|
-
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1415
|
-
push({ type: "star", value, output: "" });
|
|
1416
|
-
continue;
|
|
1417
|
-
}
|
|
1418
|
-
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1419
|
-
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1420
|
-
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1421
|
-
push({ type: "star", value, output: "" });
|
|
1422
|
-
continue;
|
|
1423
|
-
}
|
|
1424
|
-
while (rest.slice(0, 3) === "/**") {
|
|
1425
|
-
const after = input[state.index + 4];
|
|
1426
|
-
if (after && after !== "/") {
|
|
1427
|
-
break;
|
|
1428
|
-
}
|
|
1429
|
-
rest = rest.slice(3);
|
|
1430
|
-
consume("/**", 3);
|
|
1431
|
-
}
|
|
1432
|
-
if (prior.type === "bos" && eos()) {
|
|
1433
|
-
prev.type = "globstar";
|
|
1434
|
-
prev.value += value;
|
|
1435
|
-
prev.output = globstar(opts);
|
|
1436
|
-
state.output = prev.output;
|
|
1437
|
-
state.globstar = true;
|
|
1438
|
-
consume(value);
|
|
1439
|
-
continue;
|
|
1440
|
-
}
|
|
1441
|
-
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1442
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1443
|
-
prior.output = `(?:${prior.output}`;
|
|
1444
|
-
prev.type = "globstar";
|
|
1445
|
-
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1446
|
-
prev.value += value;
|
|
1447
|
-
state.globstar = true;
|
|
1448
|
-
state.output += prior.output + prev.output;
|
|
1449
|
-
consume(value);
|
|
1450
|
-
continue;
|
|
1451
|
-
}
|
|
1452
|
-
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1453
|
-
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1454
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1455
|
-
prior.output = `(?:${prior.output}`;
|
|
1456
|
-
prev.type = "globstar";
|
|
1457
|
-
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1458
|
-
prev.value += value;
|
|
1459
|
-
state.output += prior.output + prev.output;
|
|
1460
|
-
state.globstar = true;
|
|
1461
|
-
consume(value + advance());
|
|
1462
|
-
push({ type: "slash", value: "/", output: "" });
|
|
1463
|
-
continue;
|
|
1464
|
-
}
|
|
1465
|
-
if (prior.type === "bos" && rest[0] === "/") {
|
|
1466
|
-
prev.type = "globstar";
|
|
1467
|
-
prev.value += value;
|
|
1468
|
-
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1469
|
-
state.output = prev.output;
|
|
1470
|
-
state.globstar = true;
|
|
1471
|
-
consume(value + advance());
|
|
1472
|
-
push({ type: "slash", value: "/", output: "" });
|
|
1473
|
-
continue;
|
|
1474
|
-
}
|
|
1475
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
1476
|
-
prev.type = "globstar";
|
|
1477
|
-
prev.output = globstar(opts);
|
|
1478
|
-
prev.value += value;
|
|
1479
|
-
state.output += prev.output;
|
|
1480
|
-
state.globstar = true;
|
|
1481
|
-
consume(value);
|
|
1482
|
-
continue;
|
|
1483
|
-
}
|
|
1484
|
-
const token = { type: "star", value, output: star };
|
|
1485
|
-
if (opts.bash === true) {
|
|
1486
|
-
token.output = ".*?";
|
|
1487
|
-
if (prev.type === "bos" || prev.type === "slash") {
|
|
1488
|
-
token.output = nodot + token.output;
|
|
1489
|
-
}
|
|
1490
|
-
push(token);
|
|
1491
|
-
continue;
|
|
1492
|
-
}
|
|
1493
|
-
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1494
|
-
token.output = value;
|
|
1495
|
-
push(token);
|
|
1496
|
-
continue;
|
|
1497
|
-
}
|
|
1498
|
-
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1499
|
-
if (prev.type === "dot") {
|
|
1500
|
-
state.output += NO_DOT_SLASH;
|
|
1501
|
-
prev.output += NO_DOT_SLASH;
|
|
1502
|
-
} else if (opts.dot === true) {
|
|
1503
|
-
state.output += NO_DOTS_SLASH;
|
|
1504
|
-
prev.output += NO_DOTS_SLASH;
|
|
1505
|
-
} else {
|
|
1506
|
-
state.output += nodot;
|
|
1507
|
-
prev.output += nodot;
|
|
1508
|
-
}
|
|
1509
|
-
if (peek() !== "*") {
|
|
1510
|
-
state.output += ONE_CHAR;
|
|
1511
|
-
prev.output += ONE_CHAR;
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
push(token);
|
|
1515
|
-
}
|
|
1516
|
-
while (state.brackets > 0) {
|
|
1517
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1518
|
-
state.output = utils.escapeLast(state.output, "[");
|
|
1519
|
-
decrement("brackets");
|
|
1520
|
-
}
|
|
1521
|
-
while (state.parens > 0) {
|
|
1522
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1523
|
-
state.output = utils.escapeLast(state.output, "(");
|
|
1524
|
-
decrement("parens");
|
|
1525
|
-
}
|
|
1526
|
-
while (state.braces > 0) {
|
|
1527
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1528
|
-
state.output = utils.escapeLast(state.output, "{");
|
|
1529
|
-
decrement("braces");
|
|
1530
|
-
}
|
|
1531
|
-
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1532
|
-
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1533
|
-
}
|
|
1534
|
-
if (state.backtrack === true) {
|
|
1535
|
-
state.output = "";
|
|
1536
|
-
for (const token of state.tokens) {
|
|
1537
|
-
state.output += token.output != null ? token.output : token.value;
|
|
1538
|
-
if (token.suffix) {
|
|
1539
|
-
state.output += token.suffix;
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
return state;
|
|
1544
|
-
};
|
|
1545
|
-
parse.fastpaths = (input, options) => {
|
|
1546
|
-
const opts = { ...options };
|
|
1547
|
-
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1548
|
-
const len = input.length;
|
|
1549
|
-
if (len > max) {
|
|
1550
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1551
|
-
}
|
|
1552
|
-
input = REPLACEMENTS[input] || input;
|
|
1553
|
-
const {
|
|
1554
|
-
DOT_LITERAL,
|
|
1555
|
-
SLASH_LITERAL,
|
|
1556
|
-
ONE_CHAR,
|
|
1557
|
-
DOTS_SLASH,
|
|
1558
|
-
NO_DOT,
|
|
1559
|
-
NO_DOTS,
|
|
1560
|
-
NO_DOTS_SLASH,
|
|
1561
|
-
STAR,
|
|
1562
|
-
START_ANCHOR
|
|
1563
|
-
} = constants.globChars(opts.windows);
|
|
1564
|
-
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1565
|
-
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1566
|
-
const capture = opts.capture ? "" : "?:";
|
|
1567
|
-
const state = { negated: false, prefix: "" };
|
|
1568
|
-
let star = opts.bash === true ? ".*?" : STAR;
|
|
1569
|
-
if (opts.capture) {
|
|
1570
|
-
star = `(${star})`;
|
|
1571
|
-
}
|
|
1572
|
-
const globstar = (opts2) => {
|
|
1573
|
-
if (opts2.noglobstar === true) return star;
|
|
1574
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1575
|
-
};
|
|
1576
|
-
const create = (str) => {
|
|
1577
|
-
switch (str) {
|
|
1578
|
-
case "*":
|
|
1579
|
-
return `${nodot}${ONE_CHAR}${star}`;
|
|
1580
|
-
case ".*":
|
|
1581
|
-
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1582
|
-
case "*.*":
|
|
1583
|
-
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1584
|
-
case "*/*":
|
|
1585
|
-
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1586
|
-
case "**":
|
|
1587
|
-
return nodot + globstar(opts);
|
|
1588
|
-
case "**/*":
|
|
1589
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1590
|
-
case "**/*.*":
|
|
1591
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1592
|
-
case "**/.*":
|
|
1593
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1594
|
-
default: {
|
|
1595
|
-
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1596
|
-
if (!match) return;
|
|
1597
|
-
const source2 = create(match[1]);
|
|
1598
|
-
if (!source2) return;
|
|
1599
|
-
return source2 + DOT_LITERAL + match[2];
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
};
|
|
1603
|
-
const output = utils.removePrefix(input, state);
|
|
1604
|
-
let source = create(output);
|
|
1605
|
-
if (source && opts.strictSlashes !== true) {
|
|
1606
|
-
source += `${SLASH_LITERAL}?`;
|
|
1607
|
-
}
|
|
1608
|
-
return source;
|
|
1609
|
-
};
|
|
1610
|
-
module.exports = parse;
|
|
1611
|
-
}
|
|
1612
|
-
});
|
|
1613
|
-
|
|
1614
|
-
// ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js
|
|
1615
|
-
var require_picomatch = __commonJS({
|
|
1616
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
1617
|
-
"use strict";
|
|
1618
|
-
var scan = require_scan();
|
|
1619
|
-
var parse = require_parse();
|
|
1620
|
-
var utils = require_utils();
|
|
1621
|
-
var constants = require_constants();
|
|
1622
|
-
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1623
|
-
var picomatch2 = (glob, options, returnState = false) => {
|
|
1624
|
-
if (Array.isArray(glob)) {
|
|
1625
|
-
const fns = glob.map((input) => picomatch2(input, options, returnState));
|
|
1626
|
-
const arrayMatcher = (str) => {
|
|
1627
|
-
for (const isMatch of fns) {
|
|
1628
|
-
const state2 = isMatch(str);
|
|
1629
|
-
if (state2) return state2;
|
|
1630
|
-
}
|
|
1631
|
-
return false;
|
|
1632
|
-
};
|
|
1633
|
-
return arrayMatcher;
|
|
1634
|
-
}
|
|
1635
|
-
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1636
|
-
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1637
|
-
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1638
|
-
}
|
|
1639
|
-
const opts = options || {};
|
|
1640
|
-
const posix = opts.windows;
|
|
1641
|
-
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
1642
|
-
const state = regex.state;
|
|
1643
|
-
delete regex.state;
|
|
1644
|
-
let isIgnored = () => false;
|
|
1645
|
-
if (opts.ignore) {
|
|
1646
|
-
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1647
|
-
isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
|
|
1648
|
-
}
|
|
1649
|
-
const matcher = (input, returnObject = false) => {
|
|
1650
|
-
const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
|
|
1651
|
-
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1652
|
-
if (typeof opts.onResult === "function") {
|
|
1653
|
-
opts.onResult(result);
|
|
1654
|
-
}
|
|
1655
|
-
if (isMatch === false) {
|
|
1656
|
-
result.isMatch = false;
|
|
1657
|
-
return returnObject ? result : false;
|
|
1658
|
-
}
|
|
1659
|
-
if (isIgnored(input)) {
|
|
1660
|
-
if (typeof opts.onIgnore === "function") {
|
|
1661
|
-
opts.onIgnore(result);
|
|
1662
|
-
}
|
|
1663
|
-
result.isMatch = false;
|
|
1664
|
-
return returnObject ? result : false;
|
|
1665
|
-
}
|
|
1666
|
-
if (typeof opts.onMatch === "function") {
|
|
1667
|
-
opts.onMatch(result);
|
|
1668
|
-
}
|
|
1669
|
-
return returnObject ? result : true;
|
|
1670
|
-
};
|
|
1671
|
-
if (returnState) {
|
|
1672
|
-
matcher.state = state;
|
|
1673
|
-
}
|
|
1674
|
-
return matcher;
|
|
1675
|
-
};
|
|
1676
|
-
picomatch2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1677
|
-
if (typeof input !== "string") {
|
|
1678
|
-
throw new TypeError("Expected input to be a string");
|
|
1679
|
-
}
|
|
1680
|
-
if (input === "") {
|
|
1681
|
-
return { isMatch: false, output: "" };
|
|
1682
|
-
}
|
|
1683
|
-
const opts = options || {};
|
|
1684
|
-
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1685
|
-
let match = input === glob;
|
|
1686
|
-
let output = match && format ? format(input) : input;
|
|
1687
|
-
if (match === false) {
|
|
1688
|
-
output = format ? format(input) : input;
|
|
1689
|
-
match = output === glob;
|
|
1690
|
-
}
|
|
1691
|
-
if (match === false || opts.capture === true) {
|
|
1692
|
-
if (opts.matchBase === true || opts.basename === true) {
|
|
1693
|
-
match = picomatch2.matchBase(input, regex, options, posix);
|
|
1694
|
-
} else {
|
|
1695
|
-
match = regex.exec(output);
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
return { isMatch: Boolean(match), match, output };
|
|
1699
|
-
};
|
|
1700
|
-
picomatch2.matchBase = (input, glob, options) => {
|
|
1701
|
-
const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
|
|
1702
|
-
return regex.test(utils.basename(input));
|
|
1703
|
-
};
|
|
1704
|
-
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
1705
|
-
picomatch2.parse = (pattern, options) => {
|
|
1706
|
-
if (Array.isArray(pattern)) return pattern.map((p) => picomatch2.parse(p, options));
|
|
1707
|
-
return parse(pattern, { ...options, fastpaths: false });
|
|
1708
|
-
};
|
|
1709
|
-
picomatch2.scan = (input, options) => scan(input, options);
|
|
1710
|
-
picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1711
|
-
if (returnOutput === true) {
|
|
1712
|
-
return state.output;
|
|
1713
|
-
}
|
|
1714
|
-
const opts = options || {};
|
|
1715
|
-
const prepend = opts.contains ? "" : "^";
|
|
1716
|
-
const append = opts.contains ? "" : "$";
|
|
1717
|
-
let source = `${prepend}(?:${state.output})${append}`;
|
|
1718
|
-
if (state && state.negated === true) {
|
|
1719
|
-
source = `^(?!${source}).*$`;
|
|
1720
|
-
}
|
|
1721
|
-
const regex = picomatch2.toRegex(source, options);
|
|
1722
|
-
if (returnState === true) {
|
|
1723
|
-
regex.state = state;
|
|
1724
|
-
}
|
|
1725
|
-
return regex;
|
|
1726
|
-
};
|
|
1727
|
-
picomatch2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1728
|
-
if (!input || typeof input !== "string") {
|
|
1729
|
-
throw new TypeError("Expected a non-empty string");
|
|
1730
|
-
}
|
|
1731
|
-
let parsed = { negated: false, fastpaths: true };
|
|
1732
|
-
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
1733
|
-
parsed.output = parse.fastpaths(input, options);
|
|
1734
|
-
}
|
|
1735
|
-
if (!parsed.output) {
|
|
1736
|
-
parsed = parse(input, options);
|
|
1737
|
-
}
|
|
1738
|
-
return picomatch2.compileRe(parsed, options, returnOutput, returnState);
|
|
1739
|
-
};
|
|
1740
|
-
picomatch2.toRegex = (source, options) => {
|
|
1741
|
-
try {
|
|
1742
|
-
const opts = options || {};
|
|
1743
|
-
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1744
|
-
} catch (err) {
|
|
1745
|
-
if (options && options.debug === true) throw err;
|
|
1746
|
-
return /$^/;
|
|
1747
|
-
}
|
|
1748
|
-
};
|
|
1749
|
-
picomatch2.constants = constants;
|
|
1750
|
-
module.exports = picomatch2;
|
|
1751
|
-
}
|
|
1752
|
-
});
|
|
1753
|
-
|
|
1754
|
-
// ../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js
|
|
1755
|
-
var require_picomatch2 = __commonJS({
|
|
1756
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js"(exports, module) {
|
|
1757
|
-
"use strict";
|
|
1758
|
-
var pico = require_picomatch();
|
|
1759
|
-
var utils = require_utils();
|
|
1760
|
-
function picomatch2(glob, options, returnState = false) {
|
|
1761
|
-
if (options && (options.windows === null || options.windows === void 0)) {
|
|
1762
|
-
options = { ...options, windows: utils.isWindows() };
|
|
1763
|
-
}
|
|
1764
|
-
return pico(glob, options, returnState);
|
|
1765
|
-
}
|
|
1766
|
-
Object.assign(picomatch2, pico);
|
|
1767
|
-
module.exports = picomatch2;
|
|
1768
|
-
}
|
|
1769
|
-
});
|
|
16
|
+
} from "./chunk-WVRVNHAX.js";
|
|
1770
17
|
|
|
1771
18
|
// src/index.ts
|
|
1772
|
-
import { createHash as createHash2 } from "crypto";
|
|
1773
19
|
import { dirname, resolve as resolve2 } from "path";
|
|
1774
20
|
import { fileURLToPath } from "url";
|
|
1775
|
-
import { defineProject
|
|
21
|
+
import { defineProject } from "vitest/config";
|
|
1776
22
|
|
|
1777
23
|
// src/misuse-detector.ts
|
|
1778
24
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
|
|
@@ -1826,6 +72,7 @@ var reporterCheckInstalled = false;
|
|
|
1826
72
|
var WORKSPACE_REPORTER_MARKER_DIR = join(tmpdir(), "archal-vitest-workspace-reporter");
|
|
1827
73
|
var workspaceReporterMarkers = /* @__PURE__ */ new Set();
|
|
1828
74
|
var workspaceReporterCheckInstalled = false;
|
|
75
|
+
var ARCHAL_VITEST_CONFIG_ENV2 = "ARCHAL_VITEST_CONFIG";
|
|
1829
76
|
var reporterMarkerSeq = 0;
|
|
1830
77
|
var workspaceReporterMarkerSeq = 0;
|
|
1831
78
|
function installMisuseDetector(projectName) {
|
|
@@ -1838,10 +85,7 @@ function installMisuseDetector(projectName) {
|
|
|
1838
85
|
} catch {
|
|
1839
86
|
}
|
|
1840
87
|
}
|
|
1841
|
-
const markerPath = join(
|
|
1842
|
-
WIRING_MARKER_DIR,
|
|
1843
|
-
`${process.pid}-${projectName}-${Date.now()}.marker`
|
|
1844
|
-
);
|
|
88
|
+
const markerPath = join(WIRING_MARKER_DIR, `${process.pid}-${projectName}-${Date.now()}.marker`);
|
|
1845
89
|
try {
|
|
1846
90
|
writeFileSync(markerPath, projectName, { mode: 384 });
|
|
1847
91
|
} catch {
|
|
@@ -1855,7 +99,7 @@ function installMisuseDetector(projectName) {
|
|
|
1855
99
|
return;
|
|
1856
100
|
}
|
|
1857
101
|
process.stderr.write(
|
|
1858
|
-
"\n\x1B[33m\x1B[
|
|
102
|
+
"\n\x1B[33m\x1B[1mArchal Vitest is not routing test requests\n\x1B[0m\x1B[33mYour Vitest config uses archalVitestProject(), but Archal setup did\nnot run. Tests may have sent requests to live services.\n\nFix: either use withArchal() for a single vitest.config.ts:\n\n import { defineConfig } from 'vitest/config';\n import { withArchal } from 'archal/vitest';\n export default defineConfig({\n test: withArchal({}, { services: { ... } }),\n });\n\nOr move archalVitestProject() into vitest.workspace.ts:\n\n import { archalVitestProject } from 'archal/vitest';\n export default [archalVitestProject({ services: { ... } })];\n\x1B[0m\n"
|
|
1859
103
|
);
|
|
1860
104
|
for (const survivor of survivors) {
|
|
1861
105
|
try {
|
|
@@ -1901,7 +145,7 @@ function installReporterLifecycleCheck(projectName) {
|
|
|
1901
145
|
return;
|
|
1902
146
|
}
|
|
1903
147
|
process.stderr.write(
|
|
1904
|
-
'\n\x1B[33m\x1B[
|
|
148
|
+
'\n\x1B[33m\x1B[1mArchal Vitest could not upload test results\n\x1B[0m\x1B[33mThe Archal reporter started, but Vitest did not call its final upload\nstep. Test results will not appear in the dashboard.\n\nCommon causes:\n - A Vitest upgrade changed per-project reporter lifecycle timing.\n - A consumer config filtered out reporters (look for reporter overrides).\n - The ArchalReporter threw before reaching collectAndReport.\n\nWhat to check:\n 1. Grep stderr for "[archal/reporter]". If any line appears, the\n reporter did run and this warning is a false positive.\n 2. If no [archal/reporter] lines exist at all, the reporter was\n installed but never called. Verify your vitest config wires it\n at the level Vitest actually honors (workspace root vs project).\n'
|
|
1905
149
|
);
|
|
1906
150
|
process.stderr.write("\x1B[0m\n");
|
|
1907
151
|
for (const survivor of survivors) {
|
|
@@ -1949,7 +193,7 @@ function installWorkspaceReporterCheck(projectNames) {
|
|
|
1949
193
|
return;
|
|
1950
194
|
}
|
|
1951
195
|
process.stderr.write(
|
|
1952
|
-
"\n\x1B[33m\x1B[
|
|
196
|
+
"\n\x1B[33m\x1B[1mArchal Vitest did not upload workspace test results\n\x1B[0m\x1B[33marchalVitestWorkspace() configured hosted clone projects, but no\nroot Archal reporter was registered. Requests were routed to the\nhosted clones, but dashboard upload was skipped.\n\nFix: add a root vitest.config.ts alongside vitest.workspace.ts:\n\n import { defineConfig } from 'vitest/config';\n import { archalVitestRootConfig } from 'archal/vitest';\n\n export default defineConfig(archalVitestRootConfig());\n\nIf you do not need workspace mode, use withArchal() instead.\n\x1B[0m\n"
|
|
1953
197
|
);
|
|
1954
198
|
for (const survivor of survivors) {
|
|
1955
199
|
try {
|
|
@@ -1986,15 +230,58 @@ function markWorkspaceReporterInstalled(markerPath) {
|
|
|
1986
230
|
} catch {
|
|
1987
231
|
}
|
|
1988
232
|
}
|
|
233
|
+
var importSentinelInstalled = false;
|
|
234
|
+
var helperWasCalled = false;
|
|
235
|
+
var registeredBeforeExitListener = null;
|
|
236
|
+
var registeredSigintListener = null;
|
|
237
|
+
var registeredSigtermListener = null;
|
|
238
|
+
function markHelperCalled() {
|
|
239
|
+
helperWasCalled = true;
|
|
240
|
+
}
|
|
241
|
+
function installImportSentinel() {
|
|
242
|
+
if (importSentinelInstalled) return;
|
|
243
|
+
importSentinelInstalled = true;
|
|
244
|
+
if (process.env["ARCHAL_VITEST_INTERNAL_SUPPRESS_IMPORT_SENTINEL"] === "1") {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
let warningWritten = false;
|
|
248
|
+
const warnIfNeverWired = () => {
|
|
249
|
+
if (warningWritten) return;
|
|
250
|
+
if (helperWasCalled) return;
|
|
251
|
+
if (wiringMarkers.size > 0) return;
|
|
252
|
+
if (reporterMarkers.size > 0) return;
|
|
253
|
+
if (workspaceReporterMarkers.size > 0) return;
|
|
254
|
+
if (process.env[ARCHAL_VITEST_CONFIG_ENV2]) return;
|
|
255
|
+
warningWritten = true;
|
|
256
|
+
process.stderr.write(
|
|
257
|
+
"\n\x1B[33m\x1B[1mArchal Vitest was imported but not configured\n\x1B[0m\x1B[33mSomething in your test run imported `archal/vitest`, but no\nArchal Vitest helper was called (`withArchal`, `archalVitestProject`,\n`archalVitestRootConfig`). Test results will not appear in the dashboard.\n\nFix: in your vitest.config.ts, wrap your test block with withArchal():\n\n import { defineConfig } from 'vitest/config';\n import { withArchal } from 'archal/vitest';\n export default defineConfig({\n test: withArchal({}, { services: {} }),\n });\n\nOr run `archal init` from your project root and we will wire it for you.\n\x1B[0m\n"
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
const sigintHandler = () => {
|
|
261
|
+
warnIfNeverWired();
|
|
262
|
+
setImmediate(() => process.exit(130));
|
|
263
|
+
};
|
|
264
|
+
const sigtermHandler = () => {
|
|
265
|
+
warnIfNeverWired();
|
|
266
|
+
setImmediate(() => process.exit(143));
|
|
267
|
+
};
|
|
268
|
+
process.on("beforeExit", warnIfNeverWired);
|
|
269
|
+
process.on("SIGINT", sigintHandler);
|
|
270
|
+
process.on("SIGTERM", sigtermHandler);
|
|
271
|
+
registeredBeforeExitListener = warnIfNeverWired;
|
|
272
|
+
registeredSigintListener = sigintHandler;
|
|
273
|
+
registeredSigtermListener = sigtermHandler;
|
|
274
|
+
}
|
|
1989
275
|
|
|
1990
276
|
// src/reporter.ts
|
|
1991
|
-
|
|
277
|
+
import picomatch from "picomatch";
|
|
1992
278
|
var LOG_PREFIX = "[archal/reporter]";
|
|
1993
279
|
var STRICT_ENV = "ARCHAL_REPORTER_STRICT";
|
|
1994
280
|
var REPORTER_TOKEN_ENV = "ARCHAL_REPORTER_TOKEN";
|
|
1995
281
|
var REPORTER_AUTH_URL_ENV = "ARCHAL_REPORTER_AUTH_URL";
|
|
1996
282
|
var REPORTER_AUTH_BASE_URL_ENV = "ARCHAL_REPORTER_AUTH_BASE_URL";
|
|
1997
283
|
var REPORTER_BYPASS_SECRET_ENV = "ARCHAL_REPORTER_VERCEL_AUTOMATION_BYPASS_SECRET";
|
|
284
|
+
var REPORTER_WORKSPACE_ENV = "ARCHAL_REPORTER_WORKSPACE_ID";
|
|
1998
285
|
var WORKSPACE_REPORTER_MARKER_ENV = "ARCHAL_VITEST_WORKSPACE_REPORTER_MARKER";
|
|
1999
286
|
function isStrict() {
|
|
2000
287
|
return process.env[STRICT_ENV] === "1";
|
|
@@ -2017,7 +304,6 @@ async function resolveReporterToken() {
|
|
|
2017
304
|
return explicitReporterToken;
|
|
2018
305
|
}
|
|
2019
306
|
try {
|
|
2020
|
-
const { getCredentials } = await import("./src-JGHX6UKK.js");
|
|
2021
307
|
const creds = getCredentials();
|
|
2022
308
|
return creds?.token ?? process.env["ARCHAL_TOKEN"]?.trim();
|
|
2023
309
|
} catch (authErr) {
|
|
@@ -2037,15 +323,27 @@ function buildReporterHeaders(token) {
|
|
|
2037
323
|
if (bypassSecret) {
|
|
2038
324
|
headers.set("x-vercel-protection-bypass", bypassSecret);
|
|
2039
325
|
}
|
|
326
|
+
const workspaceId = resolveReporterWorkspaceId();
|
|
327
|
+
if (workspaceId) {
|
|
328
|
+
headers.set("x-archal-workspace", workspaceId);
|
|
329
|
+
}
|
|
2040
330
|
return headers;
|
|
2041
331
|
}
|
|
332
|
+
function resolveReporterWorkspaceId() {
|
|
333
|
+
const reporterWorkspaceId = process.env[REPORTER_WORKSPACE_ENV]?.trim();
|
|
334
|
+
if (reporterWorkspaceId) {
|
|
335
|
+
return reporterWorkspaceId;
|
|
336
|
+
}
|
|
337
|
+
const cliWorkspaceId = process.env["ARCHAL_WORKSPACE_ID"]?.trim();
|
|
338
|
+
return cliWorkspaceId || void 0;
|
|
339
|
+
}
|
|
2042
340
|
function normalizePathForMatch(path) {
|
|
2043
341
|
return path.replaceAll("\\", "/");
|
|
2044
342
|
}
|
|
2045
343
|
function buildIncludeMatcher(pattern) {
|
|
2046
344
|
const normalizedPattern = normalizePathForMatch(pattern).replace(/^\.?\//, "");
|
|
2047
345
|
const patterns = normalizedPattern.startsWith("**/") ? [normalizedPattern] : [normalizedPattern, `**/${normalizedPattern}`];
|
|
2048
|
-
const matchers = patterns.map((candidate) => (
|
|
346
|
+
const matchers = patterns.map((candidate) => picomatch(candidate, { dot: true }));
|
|
2049
347
|
return (filePath) => {
|
|
2050
348
|
const normalizedFile = normalizePathForMatch(filePath);
|
|
2051
349
|
return matchers.some((matcher) => matcher(normalizedFile));
|
|
@@ -2058,7 +356,9 @@ function readEncodedConfigFromTarget(target) {
|
|
|
2058
356
|
function readProjectIncludePatterns(project) {
|
|
2059
357
|
const config = project?.config;
|
|
2060
358
|
const include = Array.isArray(config?.include) ? config.include : Array.isArray(config?.test?.include) ? config.test.include : [];
|
|
2061
|
-
return include.filter(
|
|
359
|
+
return include.filter(
|
|
360
|
+
(pattern) => typeof pattern === "string" && pattern.length > 0
|
|
361
|
+
);
|
|
2062
362
|
}
|
|
2063
363
|
var ArchalReporter = class {
|
|
2064
364
|
startTime = 0;
|
|
@@ -2066,6 +366,15 @@ var ArchalReporter = class {
|
|
|
2066
366
|
lifecycleMarkerPath = "";
|
|
2067
367
|
workspaceReporterMarkerPath = "";
|
|
2068
368
|
projects = [];
|
|
369
|
+
/**
|
|
370
|
+
* In-flight upload promise for the current run. Vitest v3+ fires both
|
|
371
|
+
* `onFinished` and `onTestRunEnd` in parallel via `Promise.all` (see
|
|
372
|
+
* vitest@3.x packages/vitest/src/node/test-run.ts), so without this guard
|
|
373
|
+
* the reporter uploads results twice and the dashboard shows duplicate
|
|
374
|
+
* rows. Reset at the start of each run (onTestRunStart / onWatcherRerun)
|
|
375
|
+
* so watch-mode reruns still upload.
|
|
376
|
+
*/
|
|
377
|
+
activeUpload = null;
|
|
2069
378
|
onInit(ctx) {
|
|
2070
379
|
this.startTime = Date.now();
|
|
2071
380
|
this.ctx = ctx;
|
|
@@ -2076,6 +385,22 @@ var ArchalReporter = class {
|
|
|
2076
385
|
markWorkspaceReporterInstalled(this.workspaceReporterMarkerPath);
|
|
2077
386
|
this.workspaceReporterMarkerPath = "";
|
|
2078
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* v3+ canonical start-of-run hook. Resetting the upload guard here lets
|
|
390
|
+
* watch-mode reruns upload their own results.
|
|
391
|
+
*/
|
|
392
|
+
onTestRunStart(_specifications) {
|
|
393
|
+
this.activeUpload = null;
|
|
394
|
+
this.startTime = Date.now();
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* v2 watch-mode start-of-rerun hook. Same purpose as onTestRunStart for
|
|
398
|
+
* v3+. Vitest v2 has no onTestRunStart, so we reset here instead.
|
|
399
|
+
*/
|
|
400
|
+
onWatcherRerun(_files, _trigger) {
|
|
401
|
+
this.activeUpload = null;
|
|
402
|
+
this.startTime = Date.now();
|
|
403
|
+
}
|
|
2079
404
|
decodeConfig(encoded) {
|
|
2080
405
|
try {
|
|
2081
406
|
return readArchalVitestConfig(encoded);
|
|
@@ -2109,14 +434,30 @@ var ArchalReporter = class {
|
|
|
2109
434
|
* `.type` ('test' | 'suite'), `.name`, `.result?.state`, `.result?.duration`.
|
|
2110
435
|
*/
|
|
2111
436
|
async onFinished(files, _errors) {
|
|
2112
|
-
await this.collectAndReport(files ?? [], "v2");
|
|
437
|
+
await this.runUploadOnce(() => this.collectAndReport(files ?? [], "v2"));
|
|
2113
438
|
}
|
|
2114
439
|
/**
|
|
2115
|
-
* vitest
|
|
2116
|
-
* The argument is an array of
|
|
440
|
+
* vitest v3+ calls onTestRunEnd alongside onFinished (in parallel via
|
|
441
|
+
* Promise.all). v4 drops onFinished entirely. The argument is an array of
|
|
442
|
+
* test modules, each with nested children.
|
|
2117
443
|
*/
|
|
2118
444
|
async onTestRunEnd(testModules) {
|
|
2119
|
-
await this.collectAndReport(testModules ?? [], "v4");
|
|
445
|
+
await this.runUploadOnce(() => this.collectAndReport(testModules ?? [], "v4"));
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Dedupe upload work when Vitest fires multiple end-of-run hooks. In
|
|
449
|
+
* Vitest v3+ both `onFinished` and `onTestRunEnd` fire from the same
|
|
450
|
+
* `Promise.all` in TestRun.end(); the first hook to enter wins and the
|
|
451
|
+
* second awaits the same in-flight upload instead of POSTing a duplicate
|
|
452
|
+
* row to /api/test-results. The resolved promise is kept on the instance
|
|
453
|
+
* so any late hook still no-ops — the guard is only cleared at the start
|
|
454
|
+
* of a new run (onTestRunStart / onWatcherRerun).
|
|
455
|
+
*/
|
|
456
|
+
async runUploadOnce(work) {
|
|
457
|
+
if (!this.activeUpload) {
|
|
458
|
+
this.activeUpload = work();
|
|
459
|
+
}
|
|
460
|
+
await this.activeUpload;
|
|
2120
461
|
}
|
|
2121
462
|
async collectAndReport(items, version) {
|
|
2122
463
|
markReporterFired(this.lifecycleMarkerPath);
|
|
@@ -2126,22 +467,25 @@ var ArchalReporter = class {
|
|
|
2126
467
|
}
|
|
2127
468
|
if (this.projects.length === 0) {
|
|
2128
469
|
warn(
|
|
2129
|
-
"Archal
|
|
470
|
+
"Archal Vitest config was unreadable. Using the default project name. If this persists, make sure withArchal() or archalVitestProject() wraps your test config."
|
|
2130
471
|
);
|
|
2131
472
|
this.projects = [
|
|
2132
|
-
this.buildProjectContext(
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
473
|
+
this.buildProjectContext(
|
|
474
|
+
{
|
|
475
|
+
projectName: "vitest",
|
|
476
|
+
services: {}
|
|
477
|
+
},
|
|
478
|
+
[]
|
|
479
|
+
)
|
|
2136
480
|
];
|
|
2137
481
|
}
|
|
2138
482
|
if (items.length === 0) {
|
|
2139
|
-
warn(`
|
|
483
|
+
warn(`No ${version === "v2" ? "files" : "test modules"} received. Nothing to upload.`);
|
|
2140
484
|
return;
|
|
2141
485
|
}
|
|
2142
486
|
const results = version === "v2" ? this.collectV2Files(items) : this.collectV4Modules(items);
|
|
2143
487
|
if (results.length === 0) {
|
|
2144
|
-
warn("
|
|
488
|
+
warn("Collected 0 tests after reading the test tree. Nothing to upload.");
|
|
2145
489
|
return;
|
|
2146
490
|
}
|
|
2147
491
|
const buckets = this.partitionResults(results);
|
|
@@ -2154,9 +498,7 @@ var ArchalReporter = class {
|
|
|
2154
498
|
await this.sendResults(bucket.project, bucket.results);
|
|
2155
499
|
}
|
|
2156
500
|
} catch (err) {
|
|
2157
|
-
warn(
|
|
2158
|
-
`failed to upload test results: ${err instanceof Error ? err.message : String(err)}`
|
|
2159
|
-
);
|
|
501
|
+
warn(`failed to upload test results: ${err instanceof Error ? err.message : String(err)}`);
|
|
2160
502
|
}
|
|
2161
503
|
}
|
|
2162
504
|
/**
|
|
@@ -2256,7 +598,7 @@ var ArchalReporter = class {
|
|
|
2256
598
|
const project = this.resolveProjectForFile(result.file);
|
|
2257
599
|
if (!project) {
|
|
2258
600
|
warn(
|
|
2259
|
-
`
|
|
601
|
+
`Could not map ${result.file} to a Vitest project config. Skipping reporter upload for that file.`
|
|
2260
602
|
);
|
|
2261
603
|
continue;
|
|
2262
604
|
}
|
|
@@ -2304,9 +646,7 @@ var ArchalReporter = class {
|
|
|
2304
646
|
body: JSON.stringify(payload)
|
|
2305
647
|
});
|
|
2306
648
|
if (res.ok) {
|
|
2307
|
-
info(
|
|
2308
|
-
`uploaded ${summary.passed}/${summary.total} tests (project=${project.config.projectName}, sessionId=${sessionId ?? "none"})`
|
|
2309
|
-
);
|
|
649
|
+
info(`Uploaded ${summary.passed}/${summary.total} tests to Archal Tests.`);
|
|
2310
650
|
if (sessionId) {
|
|
2311
651
|
try {
|
|
2312
652
|
const syncRes = await fetch(`${baseUrl}/api/sessions/sync`, {
|
|
@@ -2330,21 +670,21 @@ var ArchalReporter = class {
|
|
|
2330
670
|
});
|
|
2331
671
|
if (!syncRes.ok) {
|
|
2332
672
|
const body = await syncRes.text().catch(() => "");
|
|
2333
|
-
warn(`
|
|
673
|
+
warn(`Session sync failed (${syncRes.status}): ${body.slice(0, 200)}`);
|
|
2334
674
|
}
|
|
2335
675
|
} catch (syncErr) {
|
|
2336
676
|
warn(
|
|
2337
|
-
`
|
|
677
|
+
`Session sync failed: ${syncErr instanceof Error ? syncErr.message : String(syncErr)}`
|
|
2338
678
|
);
|
|
2339
679
|
}
|
|
2340
680
|
} else {
|
|
2341
681
|
warn(
|
|
2342
|
-
"
|
|
682
|
+
"Uploaded test results, but could not link them to a session. The run may not appear in Activity."
|
|
2343
683
|
);
|
|
2344
684
|
}
|
|
2345
685
|
} else {
|
|
2346
686
|
const body = await res.text().catch(() => "");
|
|
2347
|
-
warn(`
|
|
687
|
+
warn(`Upload failed (${res.status}): ${body.slice(0, 200)}`);
|
|
2348
688
|
}
|
|
2349
689
|
}
|
|
2350
690
|
async readSessionId(sessionKey) {
|
|
@@ -2352,10 +692,7 @@ var ArchalReporter = class {
|
|
|
2352
692
|
const { dirname: dirname2, join: join2 } = await import("path");
|
|
2353
693
|
if (sessionKey?.trim()) {
|
|
2354
694
|
try {
|
|
2355
|
-
const keyed = readFileSync2(
|
|
2356
|
-
getSessionIdFilePath(sessionKey),
|
|
2357
|
-
"utf-8"
|
|
2358
|
-
).trim();
|
|
695
|
+
const keyed = readFileSync2(getSessionIdFilePath(sessionKey), "utf-8").trim();
|
|
2359
696
|
if (keyed) return keyed;
|
|
2360
697
|
} catch {
|
|
2361
698
|
}
|
|
@@ -2401,7 +738,7 @@ function classifySeed(value) {
|
|
|
2401
738
|
if (ext === ".md") return { type: "file", path: trimmed, format: "markdown" };
|
|
2402
739
|
throw new Error(
|
|
2403
740
|
`Seed file must be .json or .md, got "${ext || "(no extension)"}": ${trimmed}
|
|
2404
|
-
.json \u2192 exact
|
|
741
|
+
.json \u2192 exact clone state loaded directly
|
|
2405
742
|
.md \u2192 plain-English description, Archal generates the state`
|
|
2406
743
|
);
|
|
2407
744
|
}
|
|
@@ -2465,7 +802,7 @@ function wrapDelivery(serviceName, raw) {
|
|
|
2465
802
|
};
|
|
2466
803
|
}
|
|
2467
804
|
async function listArchalWebhooks(serviceName) {
|
|
2468
|
-
const res = await
|
|
805
|
+
const res = await fetchArchalClone(serviceName, "/webhooks/pending");
|
|
2469
806
|
if (res.status === 404) return [];
|
|
2470
807
|
if (!res.ok) {
|
|
2471
808
|
throw new Error(
|
|
@@ -2476,7 +813,7 @@ async function listArchalWebhooks(serviceName) {
|
|
|
2476
813
|
return raw.map((d) => wrapDelivery(serviceName, d));
|
|
2477
814
|
}
|
|
2478
815
|
async function clearArchalWebhooks(serviceName) {
|
|
2479
|
-
const res = await
|
|
816
|
+
const res = await fetchArchalClone(serviceName, "/webhooks/pending", { method: "DELETE" });
|
|
2480
817
|
if (res.status === 404) return;
|
|
2481
818
|
if (!res.ok) {
|
|
2482
819
|
throw new Error(
|
|
@@ -2517,6 +854,7 @@ ${lines}`
|
|
|
2517
854
|
}
|
|
2518
855
|
|
|
2519
856
|
// src/index.ts
|
|
857
|
+
installImportSentinel();
|
|
2520
858
|
var DEFAULT_ARCHAL_HOOK_TIMEOUT_MS = 12e4;
|
|
2521
859
|
var DEFAULT_ARCHAL_TEST_TIMEOUT_MS = 12e4;
|
|
2522
860
|
var DEFAULT_EXCLUDE_PATTERNS = [
|
|
@@ -2527,11 +865,10 @@ var DEFAULT_EXCLUDE_PATTERNS = [
|
|
|
2527
865
|
];
|
|
2528
866
|
var ARCHAL_VITEST_WIRING_MARKER_ENV = "ARCHAL_VITEST_WIRING_MARKER";
|
|
2529
867
|
var ARCHAL_VITEST_WORKSPACE_REPORTER_MARKER_ENV = "ARCHAL_VITEST_WORKSPACE_REPORTER_MARKER";
|
|
2530
|
-
var ARCHAL_TEST_SANDBOX_ID_ENV = "ARCHAL_TEST_SANDBOX_ID";
|
|
2531
|
-
var SHARED_AUTH_SANDBOX_ID = `archal-vitest-${process.pid}-${createHash2("sha256").update(`${process.pid}-${process.cwd()}`).digest("hex").slice(0, 8)}`;
|
|
2532
868
|
var currentModuleFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
|
|
2533
869
|
var reporterEntryModule = resolve2(dirname(currentModuleFile), "../reporter-entry.js");
|
|
2534
870
|
function buildTestConfig(options, testOptions) {
|
|
871
|
+
markHelperCalled();
|
|
2535
872
|
assertSupportedArchalVitestServices(options.services);
|
|
2536
873
|
const projectName = options.name ?? "archal";
|
|
2537
874
|
const markerPath = installMisuseDetector(projectName);
|
|
@@ -2566,9 +903,8 @@ function buildTestConfig(options, testOptions) {
|
|
|
2566
903
|
hookTimeout: testOptions.hookTimeout ?? DEFAULT_ARCHAL_HOOK_TIMEOUT_MS,
|
|
2567
904
|
testTimeout: testOptions.testTimeout ?? DEFAULT_ARCHAL_TEST_TIMEOUT_MS,
|
|
2568
905
|
env: {
|
|
2569
|
-
...testOptions.env
|
|
2570
|
-
[ARCHAL_VITEST_CONFIG_ENV]: encodedConfig
|
|
2571
|
-
[ARCHAL_TEST_SANDBOX_ID_ENV]: testOptions.env?.[ARCHAL_TEST_SANDBOX_ID_ENV] ?? process.env[ARCHAL_TEST_SANDBOX_ID_ENV] ?? SHARED_AUTH_SANDBOX_ID
|
|
906
|
+
...testOptions.env,
|
|
907
|
+
[ARCHAL_VITEST_CONFIG_ENV]: encodedConfig
|
|
2572
908
|
},
|
|
2573
909
|
setupFiles: [
|
|
2574
910
|
resolveRuntimeModule("./runtime/setup-files.js", ".js")
|
|
@@ -2596,6 +932,7 @@ function archalVitestConfig(options, testOptions = {}) {
|
|
|
2596
932
|
return built;
|
|
2597
933
|
}
|
|
2598
934
|
function archalVitestRootConfig() {
|
|
935
|
+
markHelperCalled();
|
|
2599
936
|
return {
|
|
2600
937
|
test: {
|
|
2601
938
|
reporters: ["default", reporterEntryModule]
|
|
@@ -2636,6 +973,7 @@ function toArray(value) {
|
|
|
2636
973
|
return Array.isArray(value) ? value : [value];
|
|
2637
974
|
}
|
|
2638
975
|
function archalVitestWorkspace(projects) {
|
|
976
|
+
markHelperCalled();
|
|
2639
977
|
const archalProjectNames = Array.isArray(projects) ? projects.flatMap((project) => {
|
|
2640
978
|
if (!project || typeof project !== "object" || !("test" in project)) {
|
|
2641
979
|
return [];
|
|
@@ -2649,7 +987,7 @@ function archalVitestWorkspace(projects) {
|
|
|
2649
987
|
if (archalProjectNames.length > 0) {
|
|
2650
988
|
process.env[ARCHAL_VITEST_WORKSPACE_REPORTER_MARKER_ENV] = installWorkspaceReporterCheck(archalProjectNames);
|
|
2651
989
|
}
|
|
2652
|
-
return
|
|
990
|
+
return projects;
|
|
2653
991
|
}
|
|
2654
992
|
export {
|
|
2655
993
|
ArchalReporter,
|
|
@@ -2663,7 +1001,7 @@ export {
|
|
|
2663
1001
|
getInstalledArchalVitestRuntime,
|
|
2664
1002
|
getInstalledArchalVitestSession,
|
|
2665
1003
|
listArchalWebhooks,
|
|
2666
|
-
|
|
1004
|
+
resetArchalClones,
|
|
2667
1005
|
waitForArchalWebhook,
|
|
2668
1006
|
withArchal
|
|
2669
1007
|
};
|