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