ccusage 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/calculate-cost-DMC4FhU4.js +32 -0
- package/dist/calculate-cost.d.ts +31 -0
- package/dist/calculate-cost.js +3 -0
- package/dist/data-loader-D64xoJ7s.js +3302 -0
- package/dist/data-loader-Ds_vUoR2.d.ts +49 -0
- package/dist/data-loader.d.ts +2 -0
- package/dist/data-loader.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +37 -3270
- package/package.json +11 -2
- /package/dist/{prompt-CYpzkwkf.js → prompt-_w55ddDU.js} +0 -0
|
@@ -0,0 +1,3302 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import path$1, { posix } from "path";
|
|
6
|
+
|
|
7
|
+
//#region rolldown:runtime
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __commonJS = (cb, mod) => function() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
+
key = keys[i];
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region node_modules/fast-sort/dist/sort.mjs
|
|
35
|
+
var castComparer = function(comparer) {
|
|
36
|
+
return function(a, b, order) {
|
|
37
|
+
return comparer(a, b, order) * order;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
var throwInvalidConfigErrorIfTrue = function(condition, context) {
|
|
41
|
+
if (condition) throw Error("Invalid sort config: " + context);
|
|
42
|
+
};
|
|
43
|
+
var unpackObjectSorter = function(sortByObj) {
|
|
44
|
+
var _a = sortByObj || {}, asc = _a.asc, desc = _a.desc;
|
|
45
|
+
var order = asc ? 1 : -1;
|
|
46
|
+
var sortBy = asc || desc;
|
|
47
|
+
throwInvalidConfigErrorIfTrue(!sortBy, "Expected `asc` or `desc` property");
|
|
48
|
+
throwInvalidConfigErrorIfTrue(asc && desc, "Ambiguous object with `asc` and `desc` config properties");
|
|
49
|
+
var comparer = sortByObj.comparer && castComparer(sortByObj.comparer);
|
|
50
|
+
return {
|
|
51
|
+
order,
|
|
52
|
+
sortBy,
|
|
53
|
+
comparer
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
var multiPropertySorterProvider = function(defaultComparer$1) {
|
|
57
|
+
return function multiPropertySorter(sortBy, sortByArr, depth$1, order, comparer, a, b) {
|
|
58
|
+
var valA;
|
|
59
|
+
var valB;
|
|
60
|
+
if (typeof sortBy === "string") {
|
|
61
|
+
valA = a[sortBy];
|
|
62
|
+
valB = b[sortBy];
|
|
63
|
+
} else if (typeof sortBy === "function") {
|
|
64
|
+
valA = sortBy(a);
|
|
65
|
+
valB = sortBy(b);
|
|
66
|
+
} else {
|
|
67
|
+
var objectSorterConfig = unpackObjectSorter(sortBy);
|
|
68
|
+
return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth$1, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer$1, a, b);
|
|
69
|
+
}
|
|
70
|
+
var equality = comparer(valA, valB, order);
|
|
71
|
+
if ((equality === 0 || valA == null && valB == null) && sortByArr.length > depth$1) return multiPropertySorter(sortByArr[depth$1], sortByArr, depth$1 + 1, order, comparer, a, b);
|
|
72
|
+
return equality;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
function getSortStrategy(sortBy, comparer, order) {
|
|
76
|
+
if (sortBy === void 0 || sortBy === true) return function(a, b) {
|
|
77
|
+
return comparer(a, b, order);
|
|
78
|
+
};
|
|
79
|
+
if (typeof sortBy === "string") {
|
|
80
|
+
throwInvalidConfigErrorIfTrue(sortBy.includes("."), "String syntax not allowed for nested properties.");
|
|
81
|
+
return function(a, b) {
|
|
82
|
+
return comparer(a[sortBy], b[sortBy], order);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (typeof sortBy === "function") return function(a, b) {
|
|
86
|
+
return comparer(sortBy(a), sortBy(b), order);
|
|
87
|
+
};
|
|
88
|
+
if (Array.isArray(sortBy)) {
|
|
89
|
+
var multiPropSorter_1 = multiPropertySorterProvider(comparer);
|
|
90
|
+
return function(a, b) {
|
|
91
|
+
return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
var objectSorterConfig = unpackObjectSorter(sortBy);
|
|
95
|
+
return getSortStrategy(objectSorterConfig.sortBy, objectSorterConfig.comparer || comparer, objectSorterConfig.order);
|
|
96
|
+
}
|
|
97
|
+
var sortArray = function(order, ctx, sortBy, comparer) {
|
|
98
|
+
var _a;
|
|
99
|
+
if (!Array.isArray(ctx)) return ctx;
|
|
100
|
+
if (Array.isArray(sortBy) && sortBy.length < 2) _a = sortBy, sortBy = _a[0];
|
|
101
|
+
return ctx.sort(getSortStrategy(sortBy, comparer, order));
|
|
102
|
+
};
|
|
103
|
+
function createNewSortInstance(opts) {
|
|
104
|
+
var comparer = castComparer(opts.comparer);
|
|
105
|
+
return function(arrayToSort) {
|
|
106
|
+
var ctx = Array.isArray(arrayToSort) && !opts.inPlaceSorting ? arrayToSort.slice() : arrayToSort;
|
|
107
|
+
return {
|
|
108
|
+
asc: function(sortBy) {
|
|
109
|
+
return sortArray(1, ctx, sortBy, comparer);
|
|
110
|
+
},
|
|
111
|
+
desc: function(sortBy) {
|
|
112
|
+
return sortArray(-1, ctx, sortBy, comparer);
|
|
113
|
+
},
|
|
114
|
+
by: function(sortBy) {
|
|
115
|
+
return sortArray(1, ctx, sortBy, comparer);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
var defaultComparer = function(a, b, order) {
|
|
121
|
+
if (a == null) return order;
|
|
122
|
+
if (b == null) return -order;
|
|
123
|
+
if (typeof a !== typeof b) return typeof a < typeof b ? -1 : 1;
|
|
124
|
+
if (a < b) return -1;
|
|
125
|
+
if (a > b) return 1;
|
|
126
|
+
return 0;
|
|
127
|
+
};
|
|
128
|
+
var sort = createNewSortInstance({ comparer: defaultComparer });
|
|
129
|
+
var inPlaceSort = createNewSortInstance({
|
|
130
|
+
comparer: defaultComparer,
|
|
131
|
+
inPlaceSorting: true
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region node_modules/fdir/dist/utils.js
|
|
136
|
+
var require_utils$1 = __commonJS({ "node_modules/fdir/dist/utils.js"(exports) {
|
|
137
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
138
|
+
exports.cleanPath = cleanPath;
|
|
139
|
+
exports.convertSlashes = convertSlashes;
|
|
140
|
+
exports.isRootDirectory = isRootDirectory;
|
|
141
|
+
exports.normalizePath = normalizePath;
|
|
142
|
+
const path_1$4 = __require("path");
|
|
143
|
+
function cleanPath(path$2) {
|
|
144
|
+
let normalized = (0, path_1$4.normalize)(path$2);
|
|
145
|
+
if (normalized.length > 1 && normalized[normalized.length - 1] === path_1$4.sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
146
|
+
return normalized;
|
|
147
|
+
}
|
|
148
|
+
const SLASHES_REGEX = /[\\/]/g;
|
|
149
|
+
function convertSlashes(path$2, separator) {
|
|
150
|
+
return path$2.replace(SLASHES_REGEX, separator);
|
|
151
|
+
}
|
|
152
|
+
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
153
|
+
function isRootDirectory(path$2) {
|
|
154
|
+
return path$2 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$2);
|
|
155
|
+
}
|
|
156
|
+
function normalizePath(path$2, options) {
|
|
157
|
+
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
158
|
+
const pathNeedsCleaning = process.platform === "win32" && path$2.includes("/") || path$2.startsWith(".");
|
|
159
|
+
if (resolvePaths) path$2 = (0, path_1$4.resolve)(path$2);
|
|
160
|
+
if (normalizePath$1 || pathNeedsCleaning) path$2 = cleanPath(path$2);
|
|
161
|
+
if (path$2 === ".") return "";
|
|
162
|
+
const needsSeperator = path$2[path$2.length - 1] !== pathSeparator;
|
|
163
|
+
return convertSlashes(needsSeperator ? path$2 + pathSeparator : path$2, pathSeparator);
|
|
164
|
+
}
|
|
165
|
+
} });
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region node_modules/fdir/dist/api/functions/join-path.js
|
|
169
|
+
var require_join_path = __commonJS({ "node_modules/fdir/dist/api/functions/join-path.js"(exports) {
|
|
170
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
171
|
+
exports.joinPathWithBasePath = joinPathWithBasePath;
|
|
172
|
+
exports.joinDirectoryPath = joinDirectoryPath;
|
|
173
|
+
exports.build = build$7;
|
|
174
|
+
const path_1$3 = __require("path");
|
|
175
|
+
const utils_1$1 = require_utils$1();
|
|
176
|
+
function joinPathWithBasePath(filename, directoryPath) {
|
|
177
|
+
return directoryPath + filename;
|
|
178
|
+
}
|
|
179
|
+
function joinPathWithRelativePath(root, options) {
|
|
180
|
+
return function(filename, directoryPath) {
|
|
181
|
+
const sameRoot = directoryPath.startsWith(root);
|
|
182
|
+
if (sameRoot) return directoryPath.replace(root, "") + filename;
|
|
183
|
+
else return (0, utils_1$1.convertSlashes)((0, path_1$3.relative)(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function joinPath$1(filename) {
|
|
187
|
+
return filename;
|
|
188
|
+
}
|
|
189
|
+
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
190
|
+
return directoryPath + filename + separator;
|
|
191
|
+
}
|
|
192
|
+
function build$7(root, options) {
|
|
193
|
+
const { relativePaths, includeBasePath } = options;
|
|
194
|
+
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath$1;
|
|
195
|
+
}
|
|
196
|
+
} });
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region node_modules/fdir/dist/api/functions/push-directory.js
|
|
200
|
+
var require_push_directory = __commonJS({ "node_modules/fdir/dist/api/functions/push-directory.js"(exports) {
|
|
201
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
202
|
+
exports.build = build$6;
|
|
203
|
+
function pushDirectoryWithRelativePath(root) {
|
|
204
|
+
return function(directoryPath, paths) {
|
|
205
|
+
paths.push(directoryPath.substring(root.length) || ".");
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function pushDirectoryFilterWithRelativePath(root) {
|
|
209
|
+
return function(directoryPath, paths, filters) {
|
|
210
|
+
const relativePath = directoryPath.substring(root.length) || ".";
|
|
211
|
+
if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const pushDirectory$1 = (directoryPath, paths) => {
|
|
215
|
+
paths.push(directoryPath || ".");
|
|
216
|
+
};
|
|
217
|
+
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
218
|
+
const path$2 = directoryPath || ".";
|
|
219
|
+
if (filters.every((filter) => filter(path$2, true))) paths.push(path$2);
|
|
220
|
+
};
|
|
221
|
+
const empty$2 = () => {};
|
|
222
|
+
function build$6(root, options) {
|
|
223
|
+
const { includeDirs, filters, relativePaths } = options;
|
|
224
|
+
if (!includeDirs) return empty$2;
|
|
225
|
+
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
226
|
+
return filters && filters.length ? pushDirectoryFilter : pushDirectory$1;
|
|
227
|
+
}
|
|
228
|
+
} });
|
|
229
|
+
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region node_modules/fdir/dist/api/functions/push-file.js
|
|
232
|
+
var require_push_file = __commonJS({ "node_modules/fdir/dist/api/functions/push-file.js"(exports) {
|
|
233
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
234
|
+
exports.build = build$5;
|
|
235
|
+
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
236
|
+
if (filters.every((filter) => filter(filename, false))) counts.files++;
|
|
237
|
+
};
|
|
238
|
+
const pushFileFilter = (filename, paths, _counts, filters) => {
|
|
239
|
+
if (filters.every((filter) => filter(filename, false))) paths.push(filename);
|
|
240
|
+
};
|
|
241
|
+
const pushFileCount = (_filename, _paths, counts, _filters) => {
|
|
242
|
+
counts.files++;
|
|
243
|
+
};
|
|
244
|
+
const pushFile$1 = (filename, paths) => {
|
|
245
|
+
paths.push(filename);
|
|
246
|
+
};
|
|
247
|
+
const empty$1 = () => {};
|
|
248
|
+
function build$5(options) {
|
|
249
|
+
const { excludeFiles, filters, onlyCounts } = options;
|
|
250
|
+
if (excludeFiles) return empty$1;
|
|
251
|
+
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
252
|
+
else if (onlyCounts) return pushFileCount;
|
|
253
|
+
else return pushFile$1;
|
|
254
|
+
}
|
|
255
|
+
} });
|
|
256
|
+
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region node_modules/fdir/dist/api/functions/get-array.js
|
|
259
|
+
var require_get_array = __commonJS({ "node_modules/fdir/dist/api/functions/get-array.js"(exports) {
|
|
260
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
261
|
+
exports.build = build$4;
|
|
262
|
+
const getArray$1 = (paths) => {
|
|
263
|
+
return paths;
|
|
264
|
+
};
|
|
265
|
+
const getArrayGroup = () => {
|
|
266
|
+
return [""].slice(0, 0);
|
|
267
|
+
};
|
|
268
|
+
function build$4(options) {
|
|
269
|
+
return options.group ? getArrayGroup : getArray$1;
|
|
270
|
+
}
|
|
271
|
+
} });
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region node_modules/fdir/dist/api/functions/group-files.js
|
|
275
|
+
var require_group_files = __commonJS({ "node_modules/fdir/dist/api/functions/group-files.js"(exports) {
|
|
276
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
277
|
+
exports.build = build$3;
|
|
278
|
+
const groupFiles$1 = (groups, directory, files) => {
|
|
279
|
+
groups.push({
|
|
280
|
+
directory,
|
|
281
|
+
files,
|
|
282
|
+
dir: directory
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
const empty = () => {};
|
|
286
|
+
function build$3(options) {
|
|
287
|
+
return options.group ? groupFiles$1 : empty;
|
|
288
|
+
}
|
|
289
|
+
} });
|
|
290
|
+
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region node_modules/fdir/dist/api/functions/resolve-symlink.js
|
|
293
|
+
var require_resolve_symlink = __commonJS({ "node_modules/fdir/dist/api/functions/resolve-symlink.js"(exports) {
|
|
294
|
+
var __importDefault$1 = void 0 && (void 0).__importDefault || function(mod) {
|
|
295
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
296
|
+
};
|
|
297
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
298
|
+
exports.build = build$2;
|
|
299
|
+
const fs_1$1 = __importDefault$1(__require("fs"));
|
|
300
|
+
const path_1$2 = __require("path");
|
|
301
|
+
const resolveSymlinksAsync = function(path$2, state, callback$1) {
|
|
302
|
+
const { queue, options: { suppressErrors } } = state;
|
|
303
|
+
queue.enqueue();
|
|
304
|
+
fs_1$1.default.realpath(path$2, (error, resolvedPath) => {
|
|
305
|
+
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
306
|
+
fs_1$1.default.stat(resolvedPath, (error$1, stat) => {
|
|
307
|
+
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
308
|
+
if (stat.isDirectory() && isRecursive(path$2, resolvedPath, state)) return queue.dequeue(null, state);
|
|
309
|
+
callback$1(stat, resolvedPath);
|
|
310
|
+
queue.dequeue(null, state);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
const resolveSymlinks = function(path$2, state, callback$1) {
|
|
315
|
+
const { queue, options: { suppressErrors } } = state;
|
|
316
|
+
queue.enqueue();
|
|
317
|
+
try {
|
|
318
|
+
const resolvedPath = fs_1$1.default.realpathSync(path$2);
|
|
319
|
+
const stat = fs_1$1.default.statSync(resolvedPath);
|
|
320
|
+
if (stat.isDirectory() && isRecursive(path$2, resolvedPath, state)) return;
|
|
321
|
+
callback$1(stat, resolvedPath);
|
|
322
|
+
} catch (e) {
|
|
323
|
+
if (!suppressErrors) throw e;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
function build$2(options, isSynchronous) {
|
|
327
|
+
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
328
|
+
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
329
|
+
}
|
|
330
|
+
function isRecursive(path$2, resolved, state) {
|
|
331
|
+
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
332
|
+
let parent = (0, path_1$2.dirname)(path$2);
|
|
333
|
+
let depth$1 = 1;
|
|
334
|
+
while (parent !== state.root && depth$1 < 2) {
|
|
335
|
+
const resolvedPath = state.symlinks.get(parent);
|
|
336
|
+
const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
|
|
337
|
+
if (isSameRoot) depth$1++;
|
|
338
|
+
else parent = (0, path_1$2.dirname)(parent);
|
|
339
|
+
}
|
|
340
|
+
state.symlinks.set(path$2, resolved);
|
|
341
|
+
return depth$1 > 1;
|
|
342
|
+
}
|
|
343
|
+
function isRecursiveUsingRealPaths(resolved, state) {
|
|
344
|
+
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
345
|
+
}
|
|
346
|
+
} });
|
|
347
|
+
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region node_modules/fdir/dist/api/functions/invoke-callback.js
|
|
350
|
+
var require_invoke_callback = __commonJS({ "node_modules/fdir/dist/api/functions/invoke-callback.js"(exports) {
|
|
351
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
352
|
+
exports.build = build$1;
|
|
353
|
+
const onlyCountsSync = (state) => {
|
|
354
|
+
return state.counts;
|
|
355
|
+
};
|
|
356
|
+
const groupsSync = (state) => {
|
|
357
|
+
return state.groups;
|
|
358
|
+
};
|
|
359
|
+
const defaultSync = (state) => {
|
|
360
|
+
return state.paths;
|
|
361
|
+
};
|
|
362
|
+
const limitFilesSync = (state) => {
|
|
363
|
+
return state.paths.slice(0, state.options.maxFiles);
|
|
364
|
+
};
|
|
365
|
+
const onlyCountsAsync = (state, error, callback$1) => {
|
|
366
|
+
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
367
|
+
return null;
|
|
368
|
+
};
|
|
369
|
+
const defaultAsync = (state, error, callback$1) => {
|
|
370
|
+
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
371
|
+
return null;
|
|
372
|
+
};
|
|
373
|
+
const limitFilesAsync = (state, error, callback$1) => {
|
|
374
|
+
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
375
|
+
return null;
|
|
376
|
+
};
|
|
377
|
+
const groupsAsync = (state, error, callback$1) => {
|
|
378
|
+
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
379
|
+
return null;
|
|
380
|
+
};
|
|
381
|
+
function report(error, callback$1, output, suppressErrors) {
|
|
382
|
+
if (error && !suppressErrors) callback$1(error, output);
|
|
383
|
+
else callback$1(null, output);
|
|
384
|
+
}
|
|
385
|
+
function build$1(options, isSynchronous) {
|
|
386
|
+
const { onlyCounts, group, maxFiles } = options;
|
|
387
|
+
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
388
|
+
else if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
389
|
+
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
390
|
+
else return isSynchronous ? defaultSync : defaultAsync;
|
|
391
|
+
}
|
|
392
|
+
} });
|
|
393
|
+
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region node_modules/fdir/dist/api/functions/walk-directory.js
|
|
396
|
+
var require_walk_directory = __commonJS({ "node_modules/fdir/dist/api/functions/walk-directory.js"(exports) {
|
|
397
|
+
var __importDefault = void 0 && (void 0).__importDefault || function(mod) {
|
|
398
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
399
|
+
};
|
|
400
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
401
|
+
exports.build = build;
|
|
402
|
+
const fs_1 = __importDefault(__require("fs"));
|
|
403
|
+
const readdirOpts = { withFileTypes: true };
|
|
404
|
+
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
405
|
+
state.queue.enqueue();
|
|
406
|
+
if (currentDepth <= 0) return state.queue.dequeue(null, state);
|
|
407
|
+
state.visited.push(crawlPath);
|
|
408
|
+
state.counts.directories++;
|
|
409
|
+
fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
410
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
411
|
+
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
415
|
+
if (currentDepth <= 0) return;
|
|
416
|
+
state.visited.push(crawlPath);
|
|
417
|
+
state.counts.directories++;
|
|
418
|
+
let entries = [];
|
|
419
|
+
try {
|
|
420
|
+
entries = fs_1.default.readdirSync(crawlPath || ".", readdirOpts);
|
|
421
|
+
} catch (e) {
|
|
422
|
+
if (!state.options.suppressErrors) throw e;
|
|
423
|
+
}
|
|
424
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
425
|
+
};
|
|
426
|
+
function build(isSynchronous) {
|
|
427
|
+
return isSynchronous ? walkSync : walkAsync;
|
|
428
|
+
}
|
|
429
|
+
} });
|
|
430
|
+
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region node_modules/fdir/dist/api/queue.js
|
|
433
|
+
var require_queue = __commonJS({ "node_modules/fdir/dist/api/queue.js"(exports) {
|
|
434
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
435
|
+
exports.Queue = void 0;
|
|
436
|
+
/**
|
|
437
|
+
* This is a custom stateless queue to track concurrent async fs calls.
|
|
438
|
+
* It increments a counter whenever a call is queued and decrements it
|
|
439
|
+
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
|
440
|
+
*/
|
|
441
|
+
var Queue = class {
|
|
442
|
+
onQueueEmpty;
|
|
443
|
+
count = 0;
|
|
444
|
+
constructor(onQueueEmpty) {
|
|
445
|
+
this.onQueueEmpty = onQueueEmpty;
|
|
446
|
+
}
|
|
447
|
+
enqueue() {
|
|
448
|
+
this.count++;
|
|
449
|
+
return this.count;
|
|
450
|
+
}
|
|
451
|
+
dequeue(error, output) {
|
|
452
|
+
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
453
|
+
this.onQueueEmpty(error, output);
|
|
454
|
+
if (error) {
|
|
455
|
+
output.controller.abort();
|
|
456
|
+
this.onQueueEmpty = void 0;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
exports.Queue = Queue;
|
|
462
|
+
} });
|
|
463
|
+
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region node_modules/fdir/dist/api/counter.js
|
|
466
|
+
var require_counter = __commonJS({ "node_modules/fdir/dist/api/counter.js"(exports) {
|
|
467
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
468
|
+
exports.Counter = void 0;
|
|
469
|
+
var Counter = class {
|
|
470
|
+
_files = 0;
|
|
471
|
+
_directories = 0;
|
|
472
|
+
set files(num) {
|
|
473
|
+
this._files = num;
|
|
474
|
+
}
|
|
475
|
+
get files() {
|
|
476
|
+
return this._files;
|
|
477
|
+
}
|
|
478
|
+
set directories(num) {
|
|
479
|
+
this._directories = num;
|
|
480
|
+
}
|
|
481
|
+
get directories() {
|
|
482
|
+
return this._directories;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* @deprecated use `directories` instead
|
|
486
|
+
*/
|
|
487
|
+
/* c8 ignore next 3 */
|
|
488
|
+
get dirs() {
|
|
489
|
+
return this._directories;
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
exports.Counter = Counter;
|
|
493
|
+
} });
|
|
494
|
+
|
|
495
|
+
//#endregion
|
|
496
|
+
//#region node_modules/fdir/dist/api/walker.js
|
|
497
|
+
var require_walker = __commonJS({ "node_modules/fdir/dist/api/walker.js"(exports) {
|
|
498
|
+
var __createBinding$1 = void 0 && (void 0).__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
499
|
+
if (k2 === void 0) k2 = k;
|
|
500
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
501
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
502
|
+
enumerable: true,
|
|
503
|
+
get: function() {
|
|
504
|
+
return m[k];
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
Object.defineProperty(o, k2, desc);
|
|
508
|
+
} : function(o, m, k, k2) {
|
|
509
|
+
if (k2 === void 0) k2 = k;
|
|
510
|
+
o[k2] = m[k];
|
|
511
|
+
});
|
|
512
|
+
var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function(o, v) {
|
|
513
|
+
Object.defineProperty(o, "default", {
|
|
514
|
+
enumerable: true,
|
|
515
|
+
value: v
|
|
516
|
+
});
|
|
517
|
+
} : function(o, v) {
|
|
518
|
+
o["default"] = v;
|
|
519
|
+
});
|
|
520
|
+
var __importStar = void 0 && (void 0).__importStar || function() {
|
|
521
|
+
var ownKeys = function(o) {
|
|
522
|
+
ownKeys = Object.getOwnPropertyNames || function(o$1) {
|
|
523
|
+
var ar = [];
|
|
524
|
+
for (var k in o$1) if (Object.prototype.hasOwnProperty.call(o$1, k)) ar[ar.length] = k;
|
|
525
|
+
return ar;
|
|
526
|
+
};
|
|
527
|
+
return ownKeys(o);
|
|
528
|
+
};
|
|
529
|
+
return function(mod) {
|
|
530
|
+
if (mod && mod.__esModule) return mod;
|
|
531
|
+
var result = {};
|
|
532
|
+
if (mod != null) {
|
|
533
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding$1(result, mod, k[i]);
|
|
534
|
+
}
|
|
535
|
+
__setModuleDefault(result, mod);
|
|
536
|
+
return result;
|
|
537
|
+
};
|
|
538
|
+
}();
|
|
539
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
540
|
+
exports.Walker = void 0;
|
|
541
|
+
const path_1$1 = __require("path");
|
|
542
|
+
const utils_1 = require_utils$1();
|
|
543
|
+
const joinPath = __importStar(require_join_path());
|
|
544
|
+
const pushDirectory = __importStar(require_push_directory());
|
|
545
|
+
const pushFile = __importStar(require_push_file());
|
|
546
|
+
const getArray = __importStar(require_get_array());
|
|
547
|
+
const groupFiles = __importStar(require_group_files());
|
|
548
|
+
const resolveSymlink = __importStar(require_resolve_symlink());
|
|
549
|
+
const invokeCallback = __importStar(require_invoke_callback());
|
|
550
|
+
const walkDirectory = __importStar(require_walk_directory());
|
|
551
|
+
const queue_1 = require_queue();
|
|
552
|
+
const counter_1 = require_counter();
|
|
553
|
+
var Walker = class {
|
|
554
|
+
root;
|
|
555
|
+
isSynchronous;
|
|
556
|
+
state;
|
|
557
|
+
joinPath;
|
|
558
|
+
pushDirectory;
|
|
559
|
+
pushFile;
|
|
560
|
+
getArray;
|
|
561
|
+
groupFiles;
|
|
562
|
+
resolveSymlink;
|
|
563
|
+
walkDirectory;
|
|
564
|
+
callbackInvoker;
|
|
565
|
+
constructor(root, options, callback$1) {
|
|
566
|
+
this.isSynchronous = !callback$1;
|
|
567
|
+
this.callbackInvoker = invokeCallback.build(options, this.isSynchronous);
|
|
568
|
+
this.root = (0, utils_1.normalizePath)(root, options);
|
|
569
|
+
this.state = {
|
|
570
|
+
root: (0, utils_1.isRootDirectory)(this.root) ? this.root : this.root.slice(0, -1),
|
|
571
|
+
paths: [""].slice(0, 0),
|
|
572
|
+
groups: [],
|
|
573
|
+
counts: new counter_1.Counter(),
|
|
574
|
+
options,
|
|
575
|
+
queue: new queue_1.Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
|
|
576
|
+
symlinks: new Map(),
|
|
577
|
+
visited: [""].slice(0, 0),
|
|
578
|
+
controller: new AbortController()
|
|
579
|
+
};
|
|
580
|
+
this.joinPath = joinPath.build(this.root, options);
|
|
581
|
+
this.pushDirectory = pushDirectory.build(this.root, options);
|
|
582
|
+
this.pushFile = pushFile.build(options);
|
|
583
|
+
this.getArray = getArray.build(options);
|
|
584
|
+
this.groupFiles = groupFiles.build(options);
|
|
585
|
+
this.resolveSymlink = resolveSymlink.build(options, this.isSynchronous);
|
|
586
|
+
this.walkDirectory = walkDirectory.build(this.isSynchronous);
|
|
587
|
+
}
|
|
588
|
+
start() {
|
|
589
|
+
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
590
|
+
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
591
|
+
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
592
|
+
}
|
|
593
|
+
walk = (entries, directoryPath, depth$1) => {
|
|
594
|
+
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
595
|
+
if (controller.signal.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
596
|
+
const files = this.getArray(this.state.paths);
|
|
597
|
+
for (let i = 0; i < entries.length; ++i) {
|
|
598
|
+
const entry = entries[i];
|
|
599
|
+
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
600
|
+
const filename = this.joinPath(entry.name, directoryPath);
|
|
601
|
+
this.pushFile(filename, files, this.state.counts, filters);
|
|
602
|
+
} else if (entry.isDirectory()) {
|
|
603
|
+
let path$2 = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
604
|
+
if (exclude && exclude(entry.name, path$2)) continue;
|
|
605
|
+
this.pushDirectory(path$2, paths, filters);
|
|
606
|
+
this.walkDirectory(this.state, path$2, path$2, depth$1 - 1, this.walk);
|
|
607
|
+
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
608
|
+
let path$2 = joinPath.joinPathWithBasePath(entry.name, directoryPath);
|
|
609
|
+
this.resolveSymlink(path$2, this.state, (stat, resolvedPath) => {
|
|
610
|
+
if (stat.isDirectory()) {
|
|
611
|
+
resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
|
|
612
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$2 + pathSeparator)) return;
|
|
613
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$2 + pathSeparator, depth$1 - 1, this.walk);
|
|
614
|
+
} else {
|
|
615
|
+
resolvedPath = useRealPaths ? resolvedPath : path$2;
|
|
616
|
+
const filename = (0, path_1$1.basename)(resolvedPath);
|
|
617
|
+
const directoryPath$1 = (0, utils_1.normalizePath)((0, path_1$1.dirname)(resolvedPath), this.state.options);
|
|
618
|
+
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
619
|
+
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
this.groupFiles(this.state.groups, directoryPath, files);
|
|
625
|
+
};
|
|
626
|
+
};
|
|
627
|
+
exports.Walker = Walker;
|
|
628
|
+
} });
|
|
629
|
+
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region node_modules/fdir/dist/api/async.js
|
|
632
|
+
var require_async = __commonJS({ "node_modules/fdir/dist/api/async.js"(exports) {
|
|
633
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
634
|
+
exports.promise = promise;
|
|
635
|
+
exports.callback = callback;
|
|
636
|
+
const walker_1$1 = require_walker();
|
|
637
|
+
function promise(root, options) {
|
|
638
|
+
return new Promise((resolve, reject) => {
|
|
639
|
+
callback(root, options, (err, output) => {
|
|
640
|
+
if (err) return reject(err);
|
|
641
|
+
resolve(output);
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
function callback(root, options, callback$1) {
|
|
646
|
+
let walker = new walker_1$1.Walker(root, options, callback$1);
|
|
647
|
+
walker.start();
|
|
648
|
+
}
|
|
649
|
+
} });
|
|
650
|
+
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region node_modules/fdir/dist/api/sync.js
|
|
653
|
+
var require_sync = __commonJS({ "node_modules/fdir/dist/api/sync.js"(exports) {
|
|
654
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
655
|
+
exports.sync = sync;
|
|
656
|
+
const walker_1 = require_walker();
|
|
657
|
+
function sync(root, options) {
|
|
658
|
+
const walker = new walker_1.Walker(root, options);
|
|
659
|
+
return walker.start();
|
|
660
|
+
}
|
|
661
|
+
} });
|
|
662
|
+
|
|
663
|
+
//#endregion
|
|
664
|
+
//#region node_modules/fdir/dist/builder/api-builder.js
|
|
665
|
+
var require_api_builder = __commonJS({ "node_modules/fdir/dist/builder/api-builder.js"(exports) {
|
|
666
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
667
|
+
exports.APIBuilder = void 0;
|
|
668
|
+
const async_1 = require_async();
|
|
669
|
+
const sync_1 = require_sync();
|
|
670
|
+
var APIBuilder = class {
|
|
671
|
+
root;
|
|
672
|
+
options;
|
|
673
|
+
constructor(root, options) {
|
|
674
|
+
this.root = root;
|
|
675
|
+
this.options = options;
|
|
676
|
+
}
|
|
677
|
+
withPromise() {
|
|
678
|
+
return (0, async_1.promise)(this.root, this.options);
|
|
679
|
+
}
|
|
680
|
+
withCallback(cb) {
|
|
681
|
+
(0, async_1.callback)(this.root, this.options, cb);
|
|
682
|
+
}
|
|
683
|
+
sync() {
|
|
684
|
+
return (0, sync_1.sync)(this.root, this.options);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
exports.APIBuilder = APIBuilder;
|
|
688
|
+
} });
|
|
689
|
+
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region node_modules/picomatch/lib/constants.js
|
|
692
|
+
var require_constants = __commonJS({ "node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
693
|
+
const WIN_SLASH = "\\\\/";
|
|
694
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
695
|
+
/**
|
|
696
|
+
* Posix glob regex
|
|
697
|
+
*/
|
|
698
|
+
const DOT_LITERAL = "\\.";
|
|
699
|
+
const PLUS_LITERAL = "\\+";
|
|
700
|
+
const QMARK_LITERAL = "\\?";
|
|
701
|
+
const SLASH_LITERAL = "\\/";
|
|
702
|
+
const ONE_CHAR = "(?=.)";
|
|
703
|
+
const QMARK = "[^/]";
|
|
704
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
705
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
706
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
707
|
+
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
708
|
+
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
709
|
+
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
710
|
+
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
711
|
+
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
712
|
+
const STAR = `${QMARK}*?`;
|
|
713
|
+
const SEP = "/";
|
|
714
|
+
const POSIX_CHARS = {
|
|
715
|
+
DOT_LITERAL,
|
|
716
|
+
PLUS_LITERAL,
|
|
717
|
+
QMARK_LITERAL,
|
|
718
|
+
SLASH_LITERAL,
|
|
719
|
+
ONE_CHAR,
|
|
720
|
+
QMARK,
|
|
721
|
+
END_ANCHOR,
|
|
722
|
+
DOTS_SLASH,
|
|
723
|
+
NO_DOT,
|
|
724
|
+
NO_DOTS,
|
|
725
|
+
NO_DOT_SLASH,
|
|
726
|
+
NO_DOTS_SLASH,
|
|
727
|
+
QMARK_NO_DOT,
|
|
728
|
+
STAR,
|
|
729
|
+
START_ANCHOR,
|
|
730
|
+
SEP
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* Windows glob regex
|
|
734
|
+
*/
|
|
735
|
+
const WINDOWS_CHARS = {
|
|
736
|
+
...POSIX_CHARS,
|
|
737
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
738
|
+
QMARK: WIN_NO_SLASH,
|
|
739
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
740
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
741
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
742
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
743
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
744
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
745
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
746
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
747
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
748
|
+
SEP: "\\"
|
|
749
|
+
};
|
|
750
|
+
/**
|
|
751
|
+
* POSIX Bracket Regex
|
|
752
|
+
*/
|
|
753
|
+
const POSIX_REGEX_SOURCE$1 = {
|
|
754
|
+
alnum: "a-zA-Z0-9",
|
|
755
|
+
alpha: "a-zA-Z",
|
|
756
|
+
ascii: "\\x00-\\x7F",
|
|
757
|
+
blank: " \\t",
|
|
758
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
759
|
+
digit: "0-9",
|
|
760
|
+
graph: "\\x21-\\x7E",
|
|
761
|
+
lower: "a-z",
|
|
762
|
+
print: "\\x20-\\x7E ",
|
|
763
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
764
|
+
space: " \\t\\r\\n\\v\\f",
|
|
765
|
+
upper: "A-Z",
|
|
766
|
+
word: "A-Za-z0-9_",
|
|
767
|
+
xdigit: "A-Fa-f0-9"
|
|
768
|
+
};
|
|
769
|
+
module.exports = {
|
|
770
|
+
MAX_LENGTH: 1024 * 64,
|
|
771
|
+
POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
|
|
772
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
773
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
774
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
775
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
776
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
777
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
778
|
+
REPLACEMENTS: {
|
|
779
|
+
"***": "*",
|
|
780
|
+
"**/**": "**",
|
|
781
|
+
"**/**/**": "**"
|
|
782
|
+
},
|
|
783
|
+
CHAR_0: 48,
|
|
784
|
+
CHAR_9: 57,
|
|
785
|
+
CHAR_UPPERCASE_A: 65,
|
|
786
|
+
CHAR_LOWERCASE_A: 97,
|
|
787
|
+
CHAR_UPPERCASE_Z: 90,
|
|
788
|
+
CHAR_LOWERCASE_Z: 122,
|
|
789
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
790
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
791
|
+
CHAR_ASTERISK: 42,
|
|
792
|
+
CHAR_AMPERSAND: 38,
|
|
793
|
+
CHAR_AT: 64,
|
|
794
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
795
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
796
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
797
|
+
CHAR_COLON: 58,
|
|
798
|
+
CHAR_COMMA: 44,
|
|
799
|
+
CHAR_DOT: 46,
|
|
800
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
801
|
+
CHAR_EQUAL: 61,
|
|
802
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
803
|
+
CHAR_FORM_FEED: 12,
|
|
804
|
+
CHAR_FORWARD_SLASH: 47,
|
|
805
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
806
|
+
CHAR_HASH: 35,
|
|
807
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
808
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
809
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
810
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
811
|
+
CHAR_LINE_FEED: 10,
|
|
812
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
813
|
+
CHAR_PERCENT: 37,
|
|
814
|
+
CHAR_PLUS: 43,
|
|
815
|
+
CHAR_QUESTION_MARK: 63,
|
|
816
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
817
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
818
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
819
|
+
CHAR_SEMICOLON: 59,
|
|
820
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
821
|
+
CHAR_SPACE: 32,
|
|
822
|
+
CHAR_TAB: 9,
|
|
823
|
+
CHAR_UNDERSCORE: 95,
|
|
824
|
+
CHAR_VERTICAL_LINE: 124,
|
|
825
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
826
|
+
extglobChars(chars) {
|
|
827
|
+
return {
|
|
828
|
+
"!": {
|
|
829
|
+
type: "negate",
|
|
830
|
+
open: "(?:(?!(?:",
|
|
831
|
+
close: `))${chars.STAR})`
|
|
832
|
+
},
|
|
833
|
+
"?": {
|
|
834
|
+
type: "qmark",
|
|
835
|
+
open: "(?:",
|
|
836
|
+
close: ")?"
|
|
837
|
+
},
|
|
838
|
+
"+": {
|
|
839
|
+
type: "plus",
|
|
840
|
+
open: "(?:",
|
|
841
|
+
close: ")+"
|
|
842
|
+
},
|
|
843
|
+
"*": {
|
|
844
|
+
type: "star",
|
|
845
|
+
open: "(?:",
|
|
846
|
+
close: ")*"
|
|
847
|
+
},
|
|
848
|
+
"@": {
|
|
849
|
+
type: "at",
|
|
850
|
+
open: "(?:",
|
|
851
|
+
close: ")"
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
},
|
|
855
|
+
globChars(win32) {
|
|
856
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
} });
|
|
860
|
+
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region node_modules/picomatch/lib/utils.js
|
|
863
|
+
var require_utils = __commonJS({ "node_modules/picomatch/lib/utils.js"(exports) {
|
|
864
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
865
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
866
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
867
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
868
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
869
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
870
|
+
exports.isWindows = () => {
|
|
871
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
872
|
+
const platform = navigator.platform.toLowerCase();
|
|
873
|
+
return platform === "win32" || platform === "windows";
|
|
874
|
+
}
|
|
875
|
+
if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
|
|
876
|
+
return false;
|
|
877
|
+
};
|
|
878
|
+
exports.removeBackslashes = (str) => {
|
|
879
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
880
|
+
return match === "\\" ? "" : match;
|
|
881
|
+
});
|
|
882
|
+
};
|
|
883
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
884
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
885
|
+
if (idx === -1) return input;
|
|
886
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
887
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
888
|
+
};
|
|
889
|
+
exports.removePrefix = (input, state = {}) => {
|
|
890
|
+
let output = input;
|
|
891
|
+
if (output.startsWith("./")) {
|
|
892
|
+
output = output.slice(2);
|
|
893
|
+
state.prefix = "./";
|
|
894
|
+
}
|
|
895
|
+
return output;
|
|
896
|
+
};
|
|
897
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
898
|
+
const prepend = options.contains ? "" : "^";
|
|
899
|
+
const append = options.contains ? "" : "$";
|
|
900
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
901
|
+
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
902
|
+
return output;
|
|
903
|
+
};
|
|
904
|
+
exports.basename = (path$2, { windows } = {}) => {
|
|
905
|
+
const segs = path$2.split(windows ? /[\\/]/ : "/");
|
|
906
|
+
const last = segs[segs.length - 1];
|
|
907
|
+
if (last === "") return segs[segs.length - 2];
|
|
908
|
+
return last;
|
|
909
|
+
};
|
|
910
|
+
} });
|
|
911
|
+
|
|
912
|
+
//#endregion
|
|
913
|
+
//#region node_modules/picomatch/lib/scan.js
|
|
914
|
+
var require_scan = __commonJS({ "node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
915
|
+
const utils$3 = require_utils();
|
|
916
|
+
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
917
|
+
const isPathSeparator = (code) => {
|
|
918
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
919
|
+
};
|
|
920
|
+
const depth = (token) => {
|
|
921
|
+
if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
|
|
922
|
+
};
|
|
923
|
+
/**
|
|
924
|
+
* Quickly scans a glob pattern and returns an object with a handful of
|
|
925
|
+
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
926
|
+
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
927
|
+
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
928
|
+
*
|
|
929
|
+
* ```js
|
|
930
|
+
* const pm = require('picomatch');
|
|
931
|
+
* console.log(pm.scan('foo/bar/*.js'));
|
|
932
|
+
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
933
|
+
* ```
|
|
934
|
+
* @param {String} `str`
|
|
935
|
+
* @param {Object} `options`
|
|
936
|
+
* @return {Object} Returns an object with tokens and regex source string.
|
|
937
|
+
* @api public
|
|
938
|
+
*/
|
|
939
|
+
const scan$1 = (input, options) => {
|
|
940
|
+
const opts = options || {};
|
|
941
|
+
const length = input.length - 1;
|
|
942
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
943
|
+
const slashes = [];
|
|
944
|
+
const tokens = [];
|
|
945
|
+
const parts = [];
|
|
946
|
+
let str = input;
|
|
947
|
+
let index = -1;
|
|
948
|
+
let start = 0;
|
|
949
|
+
let lastIndex = 0;
|
|
950
|
+
let isBrace = false;
|
|
951
|
+
let isBracket = false;
|
|
952
|
+
let isGlob = false;
|
|
953
|
+
let isExtglob = false;
|
|
954
|
+
let isGlobstar = false;
|
|
955
|
+
let braceEscaped = false;
|
|
956
|
+
let backslashes = false;
|
|
957
|
+
let negated = false;
|
|
958
|
+
let negatedExtglob = false;
|
|
959
|
+
let finished = false;
|
|
960
|
+
let braces = 0;
|
|
961
|
+
let prev;
|
|
962
|
+
let code;
|
|
963
|
+
let token = {
|
|
964
|
+
value: "",
|
|
965
|
+
depth: 0,
|
|
966
|
+
isGlob: false
|
|
967
|
+
};
|
|
968
|
+
const eos = () => index >= length;
|
|
969
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
970
|
+
const advance = () => {
|
|
971
|
+
prev = code;
|
|
972
|
+
return str.charCodeAt(++index);
|
|
973
|
+
};
|
|
974
|
+
while (index < length) {
|
|
975
|
+
code = advance();
|
|
976
|
+
let next;
|
|
977
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
978
|
+
backslashes = token.backslashes = true;
|
|
979
|
+
code = advance();
|
|
980
|
+
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
984
|
+
braces++;
|
|
985
|
+
while (eos() !== true && (code = advance())) {
|
|
986
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
987
|
+
backslashes = token.backslashes = true;
|
|
988
|
+
advance();
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
991
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
992
|
+
braces++;
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
996
|
+
isBrace = token.isBrace = true;
|
|
997
|
+
isGlob = token.isGlob = true;
|
|
998
|
+
finished = true;
|
|
999
|
+
if (scanToEnd === true) continue;
|
|
1000
|
+
break;
|
|
1001
|
+
}
|
|
1002
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
1003
|
+
isBrace = token.isBrace = true;
|
|
1004
|
+
isGlob = token.isGlob = true;
|
|
1005
|
+
finished = true;
|
|
1006
|
+
if (scanToEnd === true) continue;
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1010
|
+
braces--;
|
|
1011
|
+
if (braces === 0) {
|
|
1012
|
+
braceEscaped = false;
|
|
1013
|
+
isBrace = token.isBrace = true;
|
|
1014
|
+
finished = true;
|
|
1015
|
+
break;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
if (scanToEnd === true) continue;
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
1023
|
+
slashes.push(index);
|
|
1024
|
+
tokens.push(token);
|
|
1025
|
+
token = {
|
|
1026
|
+
value: "",
|
|
1027
|
+
depth: 0,
|
|
1028
|
+
isGlob: false
|
|
1029
|
+
};
|
|
1030
|
+
if (finished === true) continue;
|
|
1031
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
1032
|
+
start += 2;
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
lastIndex = index + 1;
|
|
1036
|
+
continue;
|
|
1037
|
+
}
|
|
1038
|
+
if (opts.noext !== true) {
|
|
1039
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
1040
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1041
|
+
isGlob = token.isGlob = true;
|
|
1042
|
+
isExtglob = token.isExtglob = true;
|
|
1043
|
+
finished = true;
|
|
1044
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
1045
|
+
if (scanToEnd === true) {
|
|
1046
|
+
while (eos() !== true && (code = advance())) {
|
|
1047
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1048
|
+
backslashes = token.backslashes = true;
|
|
1049
|
+
code = advance();
|
|
1050
|
+
continue;
|
|
1051
|
+
}
|
|
1052
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1053
|
+
isGlob = token.isGlob = true;
|
|
1054
|
+
finished = true;
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
continue;
|
|
1059
|
+
}
|
|
1060
|
+
break;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
if (code === CHAR_ASTERISK) {
|
|
1064
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1065
|
+
isGlob = token.isGlob = true;
|
|
1066
|
+
finished = true;
|
|
1067
|
+
if (scanToEnd === true) continue;
|
|
1068
|
+
break;
|
|
1069
|
+
}
|
|
1070
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
1071
|
+
isGlob = token.isGlob = true;
|
|
1072
|
+
finished = true;
|
|
1073
|
+
if (scanToEnd === true) continue;
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1077
|
+
while (eos() !== true && (next = advance())) {
|
|
1078
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
1079
|
+
backslashes = token.backslashes = true;
|
|
1080
|
+
advance();
|
|
1081
|
+
continue;
|
|
1082
|
+
}
|
|
1083
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1084
|
+
isBracket = token.isBracket = true;
|
|
1085
|
+
isGlob = token.isGlob = true;
|
|
1086
|
+
finished = true;
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
if (scanToEnd === true) continue;
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1094
|
+
negated = token.negated = true;
|
|
1095
|
+
start++;
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
1099
|
+
isGlob = token.isGlob = true;
|
|
1100
|
+
if (scanToEnd === true) {
|
|
1101
|
+
while (eos() !== true && (code = advance())) {
|
|
1102
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1103
|
+
backslashes = token.backslashes = true;
|
|
1104
|
+
code = advance();
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1108
|
+
finished = true;
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
continue;
|
|
1113
|
+
}
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
if (isGlob === true) {
|
|
1117
|
+
finished = true;
|
|
1118
|
+
if (scanToEnd === true) continue;
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
if (opts.noext === true) {
|
|
1123
|
+
isExtglob = false;
|
|
1124
|
+
isGlob = false;
|
|
1125
|
+
}
|
|
1126
|
+
let base = str;
|
|
1127
|
+
let prefix = "";
|
|
1128
|
+
let glob$1 = "";
|
|
1129
|
+
if (start > 0) {
|
|
1130
|
+
prefix = str.slice(0, start);
|
|
1131
|
+
str = str.slice(start);
|
|
1132
|
+
lastIndex -= start;
|
|
1133
|
+
}
|
|
1134
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
1135
|
+
base = str.slice(0, lastIndex);
|
|
1136
|
+
glob$1 = str.slice(lastIndex);
|
|
1137
|
+
} else if (isGlob === true) {
|
|
1138
|
+
base = "";
|
|
1139
|
+
glob$1 = str;
|
|
1140
|
+
} else base = str;
|
|
1141
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
1142
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
1143
|
+
}
|
|
1144
|
+
if (opts.unescape === true) {
|
|
1145
|
+
if (glob$1) glob$1 = utils$3.removeBackslashes(glob$1);
|
|
1146
|
+
if (base && backslashes === true) base = utils$3.removeBackslashes(base);
|
|
1147
|
+
}
|
|
1148
|
+
const state = {
|
|
1149
|
+
prefix,
|
|
1150
|
+
input,
|
|
1151
|
+
start,
|
|
1152
|
+
base,
|
|
1153
|
+
glob: glob$1,
|
|
1154
|
+
isBrace,
|
|
1155
|
+
isBracket,
|
|
1156
|
+
isGlob,
|
|
1157
|
+
isExtglob,
|
|
1158
|
+
isGlobstar,
|
|
1159
|
+
negated,
|
|
1160
|
+
negatedExtglob
|
|
1161
|
+
};
|
|
1162
|
+
if (opts.tokens === true) {
|
|
1163
|
+
state.maxDepth = 0;
|
|
1164
|
+
if (!isPathSeparator(code)) tokens.push(token);
|
|
1165
|
+
state.tokens = tokens;
|
|
1166
|
+
}
|
|
1167
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
1168
|
+
let prevIndex;
|
|
1169
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
1170
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
1171
|
+
const i = slashes[idx];
|
|
1172
|
+
const value = input.slice(n, i);
|
|
1173
|
+
if (opts.tokens) {
|
|
1174
|
+
if (idx === 0 && start !== 0) {
|
|
1175
|
+
tokens[idx].isPrefix = true;
|
|
1176
|
+
tokens[idx].value = prefix;
|
|
1177
|
+
} else tokens[idx].value = value;
|
|
1178
|
+
depth(tokens[idx]);
|
|
1179
|
+
state.maxDepth += tokens[idx].depth;
|
|
1180
|
+
}
|
|
1181
|
+
if (idx !== 0 || value !== "") parts.push(value);
|
|
1182
|
+
prevIndex = i;
|
|
1183
|
+
}
|
|
1184
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1185
|
+
const value = input.slice(prevIndex + 1);
|
|
1186
|
+
parts.push(value);
|
|
1187
|
+
if (opts.tokens) {
|
|
1188
|
+
tokens[tokens.length - 1].value = value;
|
|
1189
|
+
depth(tokens[tokens.length - 1]);
|
|
1190
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
state.slashes = slashes;
|
|
1194
|
+
state.parts = parts;
|
|
1195
|
+
}
|
|
1196
|
+
return state;
|
|
1197
|
+
};
|
|
1198
|
+
module.exports = scan$1;
|
|
1199
|
+
} });
|
|
1200
|
+
|
|
1201
|
+
//#endregion
|
|
1202
|
+
//#region node_modules/picomatch/lib/parse.js
|
|
1203
|
+
var require_parse = __commonJS({ "node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
1204
|
+
const constants$1 = require_constants();
|
|
1205
|
+
const utils$2 = require_utils();
|
|
1206
|
+
/**
|
|
1207
|
+
* Constants
|
|
1208
|
+
*/
|
|
1209
|
+
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants$1;
|
|
1210
|
+
/**
|
|
1211
|
+
* Helpers
|
|
1212
|
+
*/
|
|
1213
|
+
const expandRange = (args, options) => {
|
|
1214
|
+
if (typeof options.expandRange === "function") return options.expandRange(...args, options);
|
|
1215
|
+
args.sort();
|
|
1216
|
+
const value = `[${args.join("-")}]`;
|
|
1217
|
+
try {
|
|
1218
|
+
new RegExp(value);
|
|
1219
|
+
} catch (ex) {
|
|
1220
|
+
return args.map((v) => utils$2.escapeRegex(v)).join("..");
|
|
1221
|
+
}
|
|
1222
|
+
return value;
|
|
1223
|
+
};
|
|
1224
|
+
/**
|
|
1225
|
+
* Create the message for a syntax error
|
|
1226
|
+
*/
|
|
1227
|
+
const syntaxError = (type, char) => {
|
|
1228
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
1229
|
+
};
|
|
1230
|
+
/**
|
|
1231
|
+
* Parse the given input string.
|
|
1232
|
+
* @param {String} input
|
|
1233
|
+
* @param {Object} options
|
|
1234
|
+
* @return {Object}
|
|
1235
|
+
*/
|
|
1236
|
+
const parse$1 = (input, options) => {
|
|
1237
|
+
if (typeof input !== "string") throw new TypeError("Expected a string");
|
|
1238
|
+
input = REPLACEMENTS[input] || input;
|
|
1239
|
+
const opts = { ...options };
|
|
1240
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1241
|
+
let len = input.length;
|
|
1242
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1243
|
+
const bos = {
|
|
1244
|
+
type: "bos",
|
|
1245
|
+
value: "",
|
|
1246
|
+
output: opts.prepend || ""
|
|
1247
|
+
};
|
|
1248
|
+
const tokens = [bos];
|
|
1249
|
+
const capture = opts.capture ? "" : "?:";
|
|
1250
|
+
const PLATFORM_CHARS = constants$1.globChars(opts.windows);
|
|
1251
|
+
const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
|
|
1252
|
+
const { DOT_LITERAL: DOT_LITERAL$1, PLUS_LITERAL: PLUS_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT: NO_DOT$1, NO_DOT_SLASH: NO_DOT_SLASH$1, NO_DOTS_SLASH: NO_DOTS_SLASH$1, QMARK: QMARK$1, QMARK_NO_DOT: QMARK_NO_DOT$1, STAR: STAR$1, START_ANCHOR: START_ANCHOR$1 } = PLATFORM_CHARS;
|
|
1253
|
+
const globstar = (opts$1) => {
|
|
1254
|
+
return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
|
|
1255
|
+
};
|
|
1256
|
+
const nodot = opts.dot ? "" : NO_DOT$1;
|
|
1257
|
+
const qmarkNoDot = opts.dot ? QMARK$1 : QMARK_NO_DOT$1;
|
|
1258
|
+
let star = opts.bash === true ? globstar(opts) : STAR$1;
|
|
1259
|
+
if (opts.capture) star = `(${star})`;
|
|
1260
|
+
if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
|
|
1261
|
+
const state = {
|
|
1262
|
+
input,
|
|
1263
|
+
index: -1,
|
|
1264
|
+
start: 0,
|
|
1265
|
+
dot: opts.dot === true,
|
|
1266
|
+
consumed: "",
|
|
1267
|
+
output: "",
|
|
1268
|
+
prefix: "",
|
|
1269
|
+
backtrack: false,
|
|
1270
|
+
negated: false,
|
|
1271
|
+
brackets: 0,
|
|
1272
|
+
braces: 0,
|
|
1273
|
+
parens: 0,
|
|
1274
|
+
quotes: 0,
|
|
1275
|
+
globstar: false,
|
|
1276
|
+
tokens
|
|
1277
|
+
};
|
|
1278
|
+
input = utils$2.removePrefix(input, state);
|
|
1279
|
+
len = input.length;
|
|
1280
|
+
const extglobs = [];
|
|
1281
|
+
const braces = [];
|
|
1282
|
+
const stack = [];
|
|
1283
|
+
let prev = bos;
|
|
1284
|
+
let value;
|
|
1285
|
+
/**
|
|
1286
|
+
* Tokenizing helpers
|
|
1287
|
+
*/
|
|
1288
|
+
const eos = () => state.index === len - 1;
|
|
1289
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1290
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
1291
|
+
const remaining = () => input.slice(state.index + 1);
|
|
1292
|
+
const consume = (value$1 = "", num = 0) => {
|
|
1293
|
+
state.consumed += value$1;
|
|
1294
|
+
state.index += num;
|
|
1295
|
+
};
|
|
1296
|
+
const append = (token) => {
|
|
1297
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1298
|
+
consume(token.value);
|
|
1299
|
+
};
|
|
1300
|
+
const negate = () => {
|
|
1301
|
+
let count = 1;
|
|
1302
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
1303
|
+
advance();
|
|
1304
|
+
state.start++;
|
|
1305
|
+
count++;
|
|
1306
|
+
}
|
|
1307
|
+
if (count % 2 === 0) return false;
|
|
1308
|
+
state.negated = true;
|
|
1309
|
+
state.start++;
|
|
1310
|
+
return true;
|
|
1311
|
+
};
|
|
1312
|
+
const increment = (type) => {
|
|
1313
|
+
state[type]++;
|
|
1314
|
+
stack.push(type);
|
|
1315
|
+
};
|
|
1316
|
+
const decrement = (type) => {
|
|
1317
|
+
state[type]--;
|
|
1318
|
+
stack.pop();
|
|
1319
|
+
};
|
|
1320
|
+
/**
|
|
1321
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
1322
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
1323
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
1324
|
+
* characters are plain text. This improves performance and simplifies
|
|
1325
|
+
* lookbehinds.
|
|
1326
|
+
*/
|
|
1327
|
+
const push = (tok) => {
|
|
1328
|
+
if (prev.type === "globstar") {
|
|
1329
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
1330
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
1331
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
1332
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1333
|
+
prev.type = "star";
|
|
1334
|
+
prev.value = "*";
|
|
1335
|
+
prev.output = star;
|
|
1336
|
+
state.output += prev.output;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
|
|
1340
|
+
if (tok.value || tok.output) append(tok);
|
|
1341
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
1342
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
1343
|
+
prev.value += tok.value;
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
tok.prev = prev;
|
|
1347
|
+
tokens.push(tok);
|
|
1348
|
+
prev = tok;
|
|
1349
|
+
};
|
|
1350
|
+
const extglobOpen = (type, value$1) => {
|
|
1351
|
+
const token = {
|
|
1352
|
+
...EXTGLOB_CHARS[value$1],
|
|
1353
|
+
conditions: 1,
|
|
1354
|
+
inner: ""
|
|
1355
|
+
};
|
|
1356
|
+
token.prev = prev;
|
|
1357
|
+
token.parens = state.parens;
|
|
1358
|
+
token.output = state.output;
|
|
1359
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
1360
|
+
increment("parens");
|
|
1361
|
+
push({
|
|
1362
|
+
type,
|
|
1363
|
+
value: value$1,
|
|
1364
|
+
output: state.output ? "" : ONE_CHAR$1
|
|
1365
|
+
});
|
|
1366
|
+
push({
|
|
1367
|
+
type: "paren",
|
|
1368
|
+
extglob: true,
|
|
1369
|
+
value: advance(),
|
|
1370
|
+
output
|
|
1371
|
+
});
|
|
1372
|
+
extglobs.push(token);
|
|
1373
|
+
};
|
|
1374
|
+
const extglobClose = (token) => {
|
|
1375
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
1376
|
+
let rest;
|
|
1377
|
+
if (token.type === "negate") {
|
|
1378
|
+
let extglobStar = star;
|
|
1379
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
|
|
1380
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
1381
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
1382
|
+
const expression = parse$1(rest, {
|
|
1383
|
+
...options,
|
|
1384
|
+
fastpaths: false
|
|
1385
|
+
}).output;
|
|
1386
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
1387
|
+
}
|
|
1388
|
+
if (token.prev.type === "bos") state.negatedExtglob = true;
|
|
1389
|
+
}
|
|
1390
|
+
push({
|
|
1391
|
+
type: "paren",
|
|
1392
|
+
extglob: true,
|
|
1393
|
+
value,
|
|
1394
|
+
output
|
|
1395
|
+
});
|
|
1396
|
+
decrement("parens");
|
|
1397
|
+
};
|
|
1398
|
+
/**
|
|
1399
|
+
* Fast paths
|
|
1400
|
+
*/
|
|
1401
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1402
|
+
let backslashes = false;
|
|
1403
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1404
|
+
if (first === "\\") {
|
|
1405
|
+
backslashes = true;
|
|
1406
|
+
return m;
|
|
1407
|
+
}
|
|
1408
|
+
if (first === "?") {
|
|
1409
|
+
if (esc) return esc + first + (rest ? QMARK$1.repeat(rest.length) : "");
|
|
1410
|
+
if (index === 0) return qmarkNoDot + (rest ? QMARK$1.repeat(rest.length) : "");
|
|
1411
|
+
return QMARK$1.repeat(chars.length);
|
|
1412
|
+
}
|
|
1413
|
+
if (first === ".") return DOT_LITERAL$1.repeat(chars.length);
|
|
1414
|
+
if (first === "*") {
|
|
1415
|
+
if (esc) return esc + first + (rest ? star : "");
|
|
1416
|
+
return star;
|
|
1417
|
+
}
|
|
1418
|
+
return esc ? m : `\\${m}`;
|
|
1419
|
+
});
|
|
1420
|
+
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
|
|
1421
|
+
else output = output.replace(/\\+/g, (m) => {
|
|
1422
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1423
|
+
});
|
|
1424
|
+
if (output === input && opts.contains === true) {
|
|
1425
|
+
state.output = input;
|
|
1426
|
+
return state;
|
|
1427
|
+
}
|
|
1428
|
+
state.output = utils$2.wrapOutput(output, state, options);
|
|
1429
|
+
return state;
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* Tokenize input until we reach end-of-string
|
|
1433
|
+
*/
|
|
1434
|
+
while (!eos()) {
|
|
1435
|
+
value = advance();
|
|
1436
|
+
if (value === "\0") continue;
|
|
1437
|
+
/**
|
|
1438
|
+
* Escaped characters
|
|
1439
|
+
*/
|
|
1440
|
+
if (value === "\\") {
|
|
1441
|
+
const next = peek();
|
|
1442
|
+
if (next === "/" && opts.bash !== true) continue;
|
|
1443
|
+
if (next === "." || next === ";") continue;
|
|
1444
|
+
if (!next) {
|
|
1445
|
+
value += "\\";
|
|
1446
|
+
push({
|
|
1447
|
+
type: "text",
|
|
1448
|
+
value
|
|
1449
|
+
});
|
|
1450
|
+
continue;
|
|
1451
|
+
}
|
|
1452
|
+
const match = /^\\+/.exec(remaining());
|
|
1453
|
+
let slashes = 0;
|
|
1454
|
+
if (match && match[0].length > 2) {
|
|
1455
|
+
slashes = match[0].length;
|
|
1456
|
+
state.index += slashes;
|
|
1457
|
+
if (slashes % 2 !== 0) value += "\\";
|
|
1458
|
+
}
|
|
1459
|
+
if (opts.unescape === true) value = advance();
|
|
1460
|
+
else value += advance();
|
|
1461
|
+
if (state.brackets === 0) {
|
|
1462
|
+
push({
|
|
1463
|
+
type: "text",
|
|
1464
|
+
value
|
|
1465
|
+
});
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* If we're inside a regex character class, continue
|
|
1471
|
+
* until we reach the closing bracket.
|
|
1472
|
+
*/
|
|
1473
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1474
|
+
if (opts.posix !== false && value === ":") {
|
|
1475
|
+
const inner = prev.value.slice(1);
|
|
1476
|
+
if (inner.includes("[")) {
|
|
1477
|
+
prev.posix = true;
|
|
1478
|
+
if (inner.includes(":")) {
|
|
1479
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1480
|
+
const pre = prev.value.slice(0, idx);
|
|
1481
|
+
const rest$1 = prev.value.slice(idx + 2);
|
|
1482
|
+
const posix$1 = POSIX_REGEX_SOURCE[rest$1];
|
|
1483
|
+
if (posix$1) {
|
|
1484
|
+
prev.value = pre + posix$1;
|
|
1485
|
+
state.backtrack = true;
|
|
1486
|
+
advance();
|
|
1487
|
+
if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR$1;
|
|
1488
|
+
continue;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
|
|
1494
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
|
|
1495
|
+
if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
|
|
1496
|
+
prev.value += value;
|
|
1497
|
+
append({ value });
|
|
1498
|
+
continue;
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* If we're inside a quoted string, continue
|
|
1502
|
+
* until we reach the closing double quote.
|
|
1503
|
+
*/
|
|
1504
|
+
if (state.quotes === 1 && value !== "\"") {
|
|
1505
|
+
value = utils$2.escapeRegex(value);
|
|
1506
|
+
prev.value += value;
|
|
1507
|
+
append({ value });
|
|
1508
|
+
continue;
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Double quotes
|
|
1512
|
+
*/
|
|
1513
|
+
if (value === "\"") {
|
|
1514
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1515
|
+
if (opts.keepQuotes === true) push({
|
|
1516
|
+
type: "text",
|
|
1517
|
+
value
|
|
1518
|
+
});
|
|
1519
|
+
continue;
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Parentheses
|
|
1523
|
+
*/
|
|
1524
|
+
if (value === "(") {
|
|
1525
|
+
increment("parens");
|
|
1526
|
+
push({
|
|
1527
|
+
type: "paren",
|
|
1528
|
+
value
|
|
1529
|
+
});
|
|
1530
|
+
continue;
|
|
1531
|
+
}
|
|
1532
|
+
if (value === ")") {
|
|
1533
|
+
if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
|
|
1534
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1535
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1536
|
+
extglobClose(extglobs.pop());
|
|
1537
|
+
continue;
|
|
1538
|
+
}
|
|
1539
|
+
push({
|
|
1540
|
+
type: "paren",
|
|
1541
|
+
value,
|
|
1542
|
+
output: state.parens ? ")" : "\\)"
|
|
1543
|
+
});
|
|
1544
|
+
decrement("parens");
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Square brackets
|
|
1549
|
+
*/
|
|
1550
|
+
if (value === "[") {
|
|
1551
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1552
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1553
|
+
value = `\\${value}`;
|
|
1554
|
+
} else increment("brackets");
|
|
1555
|
+
push({
|
|
1556
|
+
type: "bracket",
|
|
1557
|
+
value
|
|
1558
|
+
});
|
|
1559
|
+
continue;
|
|
1560
|
+
}
|
|
1561
|
+
if (value === "]") {
|
|
1562
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1563
|
+
push({
|
|
1564
|
+
type: "text",
|
|
1565
|
+
value,
|
|
1566
|
+
output: `\\${value}`
|
|
1567
|
+
});
|
|
1568
|
+
continue;
|
|
1569
|
+
}
|
|
1570
|
+
if (state.brackets === 0) {
|
|
1571
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
|
|
1572
|
+
push({
|
|
1573
|
+
type: "text",
|
|
1574
|
+
value,
|
|
1575
|
+
output: `\\${value}`
|
|
1576
|
+
});
|
|
1577
|
+
continue;
|
|
1578
|
+
}
|
|
1579
|
+
decrement("brackets");
|
|
1580
|
+
const prevValue = prev.value.slice(1);
|
|
1581
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
|
|
1582
|
+
prev.value += value;
|
|
1583
|
+
append({ value });
|
|
1584
|
+
if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) continue;
|
|
1585
|
+
const escaped = utils$2.escapeRegex(prev.value);
|
|
1586
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1587
|
+
if (opts.literalBrackets === true) {
|
|
1588
|
+
state.output += escaped;
|
|
1589
|
+
prev.value = escaped;
|
|
1590
|
+
continue;
|
|
1591
|
+
}
|
|
1592
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1593
|
+
state.output += prev.value;
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Braces
|
|
1598
|
+
*/
|
|
1599
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1600
|
+
increment("braces");
|
|
1601
|
+
const open = {
|
|
1602
|
+
type: "brace",
|
|
1603
|
+
value,
|
|
1604
|
+
output: "(",
|
|
1605
|
+
outputIndex: state.output.length,
|
|
1606
|
+
tokensIndex: state.tokens.length
|
|
1607
|
+
};
|
|
1608
|
+
braces.push(open);
|
|
1609
|
+
push(open);
|
|
1610
|
+
continue;
|
|
1611
|
+
}
|
|
1612
|
+
if (value === "}") {
|
|
1613
|
+
const brace = braces[braces.length - 1];
|
|
1614
|
+
if (opts.nobrace === true || !brace) {
|
|
1615
|
+
push({
|
|
1616
|
+
type: "text",
|
|
1617
|
+
value,
|
|
1618
|
+
output: value
|
|
1619
|
+
});
|
|
1620
|
+
continue;
|
|
1621
|
+
}
|
|
1622
|
+
let output = ")";
|
|
1623
|
+
if (brace.dots === true) {
|
|
1624
|
+
const arr = tokens.slice();
|
|
1625
|
+
const range = [];
|
|
1626
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1627
|
+
tokens.pop();
|
|
1628
|
+
if (arr[i].type === "brace") break;
|
|
1629
|
+
if (arr[i].type !== "dots") range.unshift(arr[i].value);
|
|
1630
|
+
}
|
|
1631
|
+
output = expandRange(range, opts);
|
|
1632
|
+
state.backtrack = true;
|
|
1633
|
+
}
|
|
1634
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1635
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1636
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1637
|
+
brace.value = brace.output = "\\{";
|
|
1638
|
+
value = output = "\\}";
|
|
1639
|
+
state.output = out;
|
|
1640
|
+
for (const t of toks) state.output += t.output || t.value;
|
|
1641
|
+
}
|
|
1642
|
+
push({
|
|
1643
|
+
type: "brace",
|
|
1644
|
+
value,
|
|
1645
|
+
output
|
|
1646
|
+
});
|
|
1647
|
+
decrement("braces");
|
|
1648
|
+
braces.pop();
|
|
1649
|
+
continue;
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Pipes
|
|
1653
|
+
*/
|
|
1654
|
+
if (value === "|") {
|
|
1655
|
+
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
1656
|
+
push({
|
|
1657
|
+
type: "text",
|
|
1658
|
+
value
|
|
1659
|
+
});
|
|
1660
|
+
continue;
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Commas
|
|
1664
|
+
*/
|
|
1665
|
+
if (value === ",") {
|
|
1666
|
+
let output = value;
|
|
1667
|
+
const brace = braces[braces.length - 1];
|
|
1668
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1669
|
+
brace.comma = true;
|
|
1670
|
+
output = "|";
|
|
1671
|
+
}
|
|
1672
|
+
push({
|
|
1673
|
+
type: "comma",
|
|
1674
|
+
value,
|
|
1675
|
+
output
|
|
1676
|
+
});
|
|
1677
|
+
continue;
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Slashes
|
|
1681
|
+
*/
|
|
1682
|
+
if (value === "/") {
|
|
1683
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1684
|
+
state.start = state.index + 1;
|
|
1685
|
+
state.consumed = "";
|
|
1686
|
+
state.output = "";
|
|
1687
|
+
tokens.pop();
|
|
1688
|
+
prev = bos;
|
|
1689
|
+
continue;
|
|
1690
|
+
}
|
|
1691
|
+
push({
|
|
1692
|
+
type: "slash",
|
|
1693
|
+
value,
|
|
1694
|
+
output: SLASH_LITERAL$1
|
|
1695
|
+
});
|
|
1696
|
+
continue;
|
|
1697
|
+
}
|
|
1698
|
+
/**
|
|
1699
|
+
* Dots
|
|
1700
|
+
*/
|
|
1701
|
+
if (value === ".") {
|
|
1702
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1703
|
+
if (prev.value === ".") prev.output = DOT_LITERAL$1;
|
|
1704
|
+
const brace = braces[braces.length - 1];
|
|
1705
|
+
prev.type = "dots";
|
|
1706
|
+
prev.output += value;
|
|
1707
|
+
prev.value += value;
|
|
1708
|
+
brace.dots = true;
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1711
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1712
|
+
push({
|
|
1713
|
+
type: "text",
|
|
1714
|
+
value,
|
|
1715
|
+
output: DOT_LITERAL$1
|
|
1716
|
+
});
|
|
1717
|
+
continue;
|
|
1718
|
+
}
|
|
1719
|
+
push({
|
|
1720
|
+
type: "dot",
|
|
1721
|
+
value,
|
|
1722
|
+
output: DOT_LITERAL$1
|
|
1723
|
+
});
|
|
1724
|
+
continue;
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* Question marks
|
|
1728
|
+
*/
|
|
1729
|
+
if (value === "?") {
|
|
1730
|
+
const isGroup = prev && prev.value === "(";
|
|
1731
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1732
|
+
extglobOpen("qmark", value);
|
|
1733
|
+
continue;
|
|
1734
|
+
}
|
|
1735
|
+
if (prev && prev.type === "paren") {
|
|
1736
|
+
const next = peek();
|
|
1737
|
+
let output = value;
|
|
1738
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
1739
|
+
push({
|
|
1740
|
+
type: "text",
|
|
1741
|
+
value,
|
|
1742
|
+
output
|
|
1743
|
+
});
|
|
1744
|
+
continue;
|
|
1745
|
+
}
|
|
1746
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1747
|
+
push({
|
|
1748
|
+
type: "qmark",
|
|
1749
|
+
value,
|
|
1750
|
+
output: QMARK_NO_DOT$1
|
|
1751
|
+
});
|
|
1752
|
+
continue;
|
|
1753
|
+
}
|
|
1754
|
+
push({
|
|
1755
|
+
type: "qmark",
|
|
1756
|
+
value,
|
|
1757
|
+
output: QMARK$1
|
|
1758
|
+
});
|
|
1759
|
+
continue;
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Exclamation
|
|
1763
|
+
*/
|
|
1764
|
+
if (value === "!") {
|
|
1765
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1766
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1767
|
+
extglobOpen("negate", value);
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1772
|
+
negate();
|
|
1773
|
+
continue;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Plus
|
|
1778
|
+
*/
|
|
1779
|
+
if (value === "+") {
|
|
1780
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1781
|
+
extglobOpen("plus", value);
|
|
1782
|
+
continue;
|
|
1783
|
+
}
|
|
1784
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1785
|
+
push({
|
|
1786
|
+
type: "plus",
|
|
1787
|
+
value,
|
|
1788
|
+
output: PLUS_LITERAL$1
|
|
1789
|
+
});
|
|
1790
|
+
continue;
|
|
1791
|
+
}
|
|
1792
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1793
|
+
push({
|
|
1794
|
+
type: "plus",
|
|
1795
|
+
value
|
|
1796
|
+
});
|
|
1797
|
+
continue;
|
|
1798
|
+
}
|
|
1799
|
+
push({
|
|
1800
|
+
type: "plus",
|
|
1801
|
+
value: PLUS_LITERAL$1
|
|
1802
|
+
});
|
|
1803
|
+
continue;
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Plain text
|
|
1807
|
+
*/
|
|
1808
|
+
if (value === "@") {
|
|
1809
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1810
|
+
push({
|
|
1811
|
+
type: "at",
|
|
1812
|
+
extglob: true,
|
|
1813
|
+
value,
|
|
1814
|
+
output: ""
|
|
1815
|
+
});
|
|
1816
|
+
continue;
|
|
1817
|
+
}
|
|
1818
|
+
push({
|
|
1819
|
+
type: "text",
|
|
1820
|
+
value
|
|
1821
|
+
});
|
|
1822
|
+
continue;
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Plain text
|
|
1826
|
+
*/
|
|
1827
|
+
if (value !== "*") {
|
|
1828
|
+
if (value === "$" || value === "^") value = `\\${value}`;
|
|
1829
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1830
|
+
if (match) {
|
|
1831
|
+
value += match[0];
|
|
1832
|
+
state.index += match[0].length;
|
|
1833
|
+
}
|
|
1834
|
+
push({
|
|
1835
|
+
type: "text",
|
|
1836
|
+
value
|
|
1837
|
+
});
|
|
1838
|
+
continue;
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Stars
|
|
1842
|
+
*/
|
|
1843
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1844
|
+
prev.type = "star";
|
|
1845
|
+
prev.star = true;
|
|
1846
|
+
prev.value += value;
|
|
1847
|
+
prev.output = star;
|
|
1848
|
+
state.backtrack = true;
|
|
1849
|
+
state.globstar = true;
|
|
1850
|
+
consume(value);
|
|
1851
|
+
continue;
|
|
1852
|
+
}
|
|
1853
|
+
let rest = remaining();
|
|
1854
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1855
|
+
extglobOpen("star", value);
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
if (prev.type === "star") {
|
|
1859
|
+
if (opts.noglobstar === true) {
|
|
1860
|
+
consume(value);
|
|
1861
|
+
continue;
|
|
1862
|
+
}
|
|
1863
|
+
const prior = prev.prev;
|
|
1864
|
+
const before = prior.prev;
|
|
1865
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1866
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1867
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1868
|
+
push({
|
|
1869
|
+
type: "star",
|
|
1870
|
+
value,
|
|
1871
|
+
output: ""
|
|
1872
|
+
});
|
|
1873
|
+
continue;
|
|
1874
|
+
}
|
|
1875
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1876
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1877
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1878
|
+
push({
|
|
1879
|
+
type: "star",
|
|
1880
|
+
value,
|
|
1881
|
+
output: ""
|
|
1882
|
+
});
|
|
1883
|
+
continue;
|
|
1884
|
+
}
|
|
1885
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1886
|
+
const after = input[state.index + 4];
|
|
1887
|
+
if (after && after !== "/") break;
|
|
1888
|
+
rest = rest.slice(3);
|
|
1889
|
+
consume("/**", 3);
|
|
1890
|
+
}
|
|
1891
|
+
if (prior.type === "bos" && eos()) {
|
|
1892
|
+
prev.type = "globstar";
|
|
1893
|
+
prev.value += value;
|
|
1894
|
+
prev.output = globstar(opts);
|
|
1895
|
+
state.output = prev.output;
|
|
1896
|
+
state.globstar = true;
|
|
1897
|
+
consume(value);
|
|
1898
|
+
continue;
|
|
1899
|
+
}
|
|
1900
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1901
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1902
|
+
prior.output = `(?:${prior.output}`;
|
|
1903
|
+
prev.type = "globstar";
|
|
1904
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1905
|
+
prev.value += value;
|
|
1906
|
+
state.globstar = true;
|
|
1907
|
+
state.output += prior.output + prev.output;
|
|
1908
|
+
consume(value);
|
|
1909
|
+
continue;
|
|
1910
|
+
}
|
|
1911
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1912
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1913
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1914
|
+
prior.output = `(?:${prior.output}`;
|
|
1915
|
+
prev.type = "globstar";
|
|
1916
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL$1}|${SLASH_LITERAL$1}${end})`;
|
|
1917
|
+
prev.value += value;
|
|
1918
|
+
state.output += prior.output + prev.output;
|
|
1919
|
+
state.globstar = true;
|
|
1920
|
+
consume(value + advance());
|
|
1921
|
+
push({
|
|
1922
|
+
type: "slash",
|
|
1923
|
+
value: "/",
|
|
1924
|
+
output: ""
|
|
1925
|
+
});
|
|
1926
|
+
continue;
|
|
1927
|
+
}
|
|
1928
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1929
|
+
prev.type = "globstar";
|
|
1930
|
+
prev.value += value;
|
|
1931
|
+
prev.output = `(?:^|${SLASH_LITERAL$1}|${globstar(opts)}${SLASH_LITERAL$1})`;
|
|
1932
|
+
state.output = prev.output;
|
|
1933
|
+
state.globstar = true;
|
|
1934
|
+
consume(value + advance());
|
|
1935
|
+
push({
|
|
1936
|
+
type: "slash",
|
|
1937
|
+
value: "/",
|
|
1938
|
+
output: ""
|
|
1939
|
+
});
|
|
1940
|
+
continue;
|
|
1941
|
+
}
|
|
1942
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1943
|
+
prev.type = "globstar";
|
|
1944
|
+
prev.output = globstar(opts);
|
|
1945
|
+
prev.value += value;
|
|
1946
|
+
state.output += prev.output;
|
|
1947
|
+
state.globstar = true;
|
|
1948
|
+
consume(value);
|
|
1949
|
+
continue;
|
|
1950
|
+
}
|
|
1951
|
+
const token = {
|
|
1952
|
+
type: "star",
|
|
1953
|
+
value,
|
|
1954
|
+
output: star
|
|
1955
|
+
};
|
|
1956
|
+
if (opts.bash === true) {
|
|
1957
|
+
token.output = ".*?";
|
|
1958
|
+
if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
|
|
1959
|
+
push(token);
|
|
1960
|
+
continue;
|
|
1961
|
+
}
|
|
1962
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1963
|
+
token.output = value;
|
|
1964
|
+
push(token);
|
|
1965
|
+
continue;
|
|
1966
|
+
}
|
|
1967
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1968
|
+
if (prev.type === "dot") {
|
|
1969
|
+
state.output += NO_DOT_SLASH$1;
|
|
1970
|
+
prev.output += NO_DOT_SLASH$1;
|
|
1971
|
+
} else if (opts.dot === true) {
|
|
1972
|
+
state.output += NO_DOTS_SLASH$1;
|
|
1973
|
+
prev.output += NO_DOTS_SLASH$1;
|
|
1974
|
+
} else {
|
|
1975
|
+
state.output += nodot;
|
|
1976
|
+
prev.output += nodot;
|
|
1977
|
+
}
|
|
1978
|
+
if (peek() !== "*") {
|
|
1979
|
+
state.output += ONE_CHAR$1;
|
|
1980
|
+
prev.output += ONE_CHAR$1;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
push(token);
|
|
1984
|
+
}
|
|
1985
|
+
while (state.brackets > 0) {
|
|
1986
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1987
|
+
state.output = utils$2.escapeLast(state.output, "[");
|
|
1988
|
+
decrement("brackets");
|
|
1989
|
+
}
|
|
1990
|
+
while (state.parens > 0) {
|
|
1991
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1992
|
+
state.output = utils$2.escapeLast(state.output, "(");
|
|
1993
|
+
decrement("parens");
|
|
1994
|
+
}
|
|
1995
|
+
while (state.braces > 0) {
|
|
1996
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1997
|
+
state.output = utils$2.escapeLast(state.output, "{");
|
|
1998
|
+
decrement("braces");
|
|
1999
|
+
}
|
|
2000
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
|
|
2001
|
+
type: "maybe_slash",
|
|
2002
|
+
value: "",
|
|
2003
|
+
output: `${SLASH_LITERAL$1}?`
|
|
2004
|
+
});
|
|
2005
|
+
if (state.backtrack === true) {
|
|
2006
|
+
state.output = "";
|
|
2007
|
+
for (const token of state.tokens) {
|
|
2008
|
+
state.output += token.output != null ? token.output : token.value;
|
|
2009
|
+
if (token.suffix) state.output += token.suffix;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
return state;
|
|
2013
|
+
};
|
|
2014
|
+
/**
|
|
2015
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
2016
|
+
* This can significantly speed up processing and has very little downside
|
|
2017
|
+
* impact when none of the fast paths match.
|
|
2018
|
+
*/
|
|
2019
|
+
parse$1.fastpaths = (input, options) => {
|
|
2020
|
+
const opts = { ...options };
|
|
2021
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
2022
|
+
const len = input.length;
|
|
2023
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
2024
|
+
input = REPLACEMENTS[input] || input;
|
|
2025
|
+
const { DOT_LITERAL: DOT_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT: NO_DOT$1, NO_DOTS: NO_DOTS$1, NO_DOTS_SLASH: NO_DOTS_SLASH$1, STAR: STAR$1, START_ANCHOR: START_ANCHOR$1 } = constants$1.globChars(opts.windows);
|
|
2026
|
+
const nodot = opts.dot ? NO_DOTS$1 : NO_DOT$1;
|
|
2027
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH$1 : NO_DOT$1;
|
|
2028
|
+
const capture = opts.capture ? "" : "?:";
|
|
2029
|
+
const state = {
|
|
2030
|
+
negated: false,
|
|
2031
|
+
prefix: ""
|
|
2032
|
+
};
|
|
2033
|
+
let star = opts.bash === true ? ".*?" : STAR$1;
|
|
2034
|
+
if (opts.capture) star = `(${star})`;
|
|
2035
|
+
const globstar = (opts$1) => {
|
|
2036
|
+
if (opts$1.noglobstar === true) return star;
|
|
2037
|
+
return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
|
|
2038
|
+
};
|
|
2039
|
+
const create = (str) => {
|
|
2040
|
+
switch (str) {
|
|
2041
|
+
case "*": return `${nodot}${ONE_CHAR$1}${star}`;
|
|
2042
|
+
case ".*": return `${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
|
|
2043
|
+
case "*.*": return `${nodot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
|
|
2044
|
+
case "*/*": return `${nodot}${star}${SLASH_LITERAL$1}${ONE_CHAR$1}${slashDot}${star}`;
|
|
2045
|
+
case "**": return nodot + globstar(opts);
|
|
2046
|
+
case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${ONE_CHAR$1}${star}`;
|
|
2047
|
+
case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
|
|
2048
|
+
case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
|
|
2049
|
+
default: {
|
|
2050
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
2051
|
+
if (!match) return;
|
|
2052
|
+
const source$1 = create(match[1]);
|
|
2053
|
+
if (!source$1) return;
|
|
2054
|
+
return source$1 + DOT_LITERAL$1 + match[2];
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
2058
|
+
const output = utils$2.removePrefix(input, state);
|
|
2059
|
+
let source = create(output);
|
|
2060
|
+
if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL$1}?`;
|
|
2061
|
+
return source;
|
|
2062
|
+
};
|
|
2063
|
+
module.exports = parse$1;
|
|
2064
|
+
} });
|
|
2065
|
+
|
|
2066
|
+
//#endregion
|
|
2067
|
+
//#region node_modules/picomatch/lib/picomatch.js
|
|
2068
|
+
var require_picomatch$1 = __commonJS({ "node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
2069
|
+
const scan = require_scan();
|
|
2070
|
+
const parse = require_parse();
|
|
2071
|
+
const utils$1 = require_utils();
|
|
2072
|
+
const constants = require_constants();
|
|
2073
|
+
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
2074
|
+
/**
|
|
2075
|
+
* Creates a matcher function from one or more glob patterns. The
|
|
2076
|
+
* returned function takes a string to match as its first argument,
|
|
2077
|
+
* and returns true if the string is a match. The returned matcher
|
|
2078
|
+
* function also takes a boolean as the second argument that, when true,
|
|
2079
|
+
* returns an object with additional information.
|
|
2080
|
+
*
|
|
2081
|
+
* ```js
|
|
2082
|
+
* const picomatch = require('picomatch');
|
|
2083
|
+
* // picomatch(glob[, options]);
|
|
2084
|
+
*
|
|
2085
|
+
* const isMatch = picomatch('*.!(*a)');
|
|
2086
|
+
* console.log(isMatch('a.a')); //=> false
|
|
2087
|
+
* console.log(isMatch('a.b')); //=> true
|
|
2088
|
+
* ```
|
|
2089
|
+
* @name picomatch
|
|
2090
|
+
* @param {String|Array} `globs` One or more glob patterns.
|
|
2091
|
+
* @param {Object=} `options`
|
|
2092
|
+
* @return {Function=} Returns a matcher function.
|
|
2093
|
+
* @api public
|
|
2094
|
+
*/
|
|
2095
|
+
const picomatch$2 = (glob$1, options, returnState = false) => {
|
|
2096
|
+
if (Array.isArray(glob$1)) {
|
|
2097
|
+
const fns = glob$1.map((input) => picomatch$2(input, options, returnState));
|
|
2098
|
+
const arrayMatcher = (str) => {
|
|
2099
|
+
for (const isMatch of fns) {
|
|
2100
|
+
const state$1 = isMatch(str);
|
|
2101
|
+
if (state$1) return state$1;
|
|
2102
|
+
}
|
|
2103
|
+
return false;
|
|
2104
|
+
};
|
|
2105
|
+
return arrayMatcher;
|
|
2106
|
+
}
|
|
2107
|
+
const isState = isObject(glob$1) && glob$1.tokens && glob$1.input;
|
|
2108
|
+
if (glob$1 === "" || typeof glob$1 !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
|
|
2109
|
+
const opts = options || {};
|
|
2110
|
+
const posix$1 = opts.windows;
|
|
2111
|
+
const regex$1 = isState ? picomatch$2.compileRe(glob$1, options) : picomatch$2.makeRe(glob$1, options, false, true);
|
|
2112
|
+
const state = regex$1.state;
|
|
2113
|
+
delete regex$1.state;
|
|
2114
|
+
let isIgnored = () => false;
|
|
2115
|
+
if (opts.ignore) {
|
|
2116
|
+
const ignoreOpts = {
|
|
2117
|
+
...options,
|
|
2118
|
+
ignore: null,
|
|
2119
|
+
onMatch: null,
|
|
2120
|
+
onResult: null
|
|
2121
|
+
};
|
|
2122
|
+
isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
|
|
2123
|
+
}
|
|
2124
|
+
const matcher = (input, returnObject = false) => {
|
|
2125
|
+
const { isMatch, match, output } = picomatch$2.test(input, regex$1, options, {
|
|
2126
|
+
glob: glob$1,
|
|
2127
|
+
posix: posix$1
|
|
2128
|
+
});
|
|
2129
|
+
const result = {
|
|
2130
|
+
glob: glob$1,
|
|
2131
|
+
state,
|
|
2132
|
+
regex: regex$1,
|
|
2133
|
+
posix: posix$1,
|
|
2134
|
+
input,
|
|
2135
|
+
output,
|
|
2136
|
+
match,
|
|
2137
|
+
isMatch
|
|
2138
|
+
};
|
|
2139
|
+
if (typeof opts.onResult === "function") opts.onResult(result);
|
|
2140
|
+
if (isMatch === false) {
|
|
2141
|
+
result.isMatch = false;
|
|
2142
|
+
return returnObject ? result : false;
|
|
2143
|
+
}
|
|
2144
|
+
if (isIgnored(input)) {
|
|
2145
|
+
if (typeof opts.onIgnore === "function") opts.onIgnore(result);
|
|
2146
|
+
result.isMatch = false;
|
|
2147
|
+
return returnObject ? result : false;
|
|
2148
|
+
}
|
|
2149
|
+
if (typeof opts.onMatch === "function") opts.onMatch(result);
|
|
2150
|
+
return returnObject ? result : true;
|
|
2151
|
+
};
|
|
2152
|
+
if (returnState) matcher.state = state;
|
|
2153
|
+
return matcher;
|
|
2154
|
+
};
|
|
2155
|
+
/**
|
|
2156
|
+
* Test `input` with the given `regex`. This is used by the main
|
|
2157
|
+
* `picomatch()` function to test the input string.
|
|
2158
|
+
*
|
|
2159
|
+
* ```js
|
|
2160
|
+
* const picomatch = require('picomatch');
|
|
2161
|
+
* // picomatch.test(input, regex[, options]);
|
|
2162
|
+
*
|
|
2163
|
+
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
2164
|
+
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
2165
|
+
* ```
|
|
2166
|
+
* @param {String} `input` String to test.
|
|
2167
|
+
* @param {RegExp} `regex`
|
|
2168
|
+
* @return {Object} Returns an object with matching info.
|
|
2169
|
+
* @api public
|
|
2170
|
+
*/
|
|
2171
|
+
picomatch$2.test = (input, regex$1, options, { glob: glob$1, posix: posix$1 } = {}) => {
|
|
2172
|
+
if (typeof input !== "string") throw new TypeError("Expected input to be a string");
|
|
2173
|
+
if (input === "") return {
|
|
2174
|
+
isMatch: false,
|
|
2175
|
+
output: ""
|
|
2176
|
+
};
|
|
2177
|
+
const opts = options || {};
|
|
2178
|
+
const format = opts.format || (posix$1 ? utils$1.toPosixSlashes : null);
|
|
2179
|
+
let match = input === glob$1;
|
|
2180
|
+
let output = match && format ? format(input) : input;
|
|
2181
|
+
if (match === false) {
|
|
2182
|
+
output = format ? format(input) : input;
|
|
2183
|
+
match = output === glob$1;
|
|
2184
|
+
}
|
|
2185
|
+
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch$2.matchBase(input, regex$1, options, posix$1);
|
|
2186
|
+
else match = regex$1.exec(output);
|
|
2187
|
+
return {
|
|
2188
|
+
isMatch: Boolean(match),
|
|
2189
|
+
match,
|
|
2190
|
+
output
|
|
2191
|
+
};
|
|
2192
|
+
};
|
|
2193
|
+
/**
|
|
2194
|
+
* Match the basename of a filepath.
|
|
2195
|
+
*
|
|
2196
|
+
* ```js
|
|
2197
|
+
* const picomatch = require('picomatch');
|
|
2198
|
+
* // picomatch.matchBase(input, glob[, options]);
|
|
2199
|
+
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
2200
|
+
* ```
|
|
2201
|
+
* @param {String} `input` String to test.
|
|
2202
|
+
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
2203
|
+
* @return {Boolean}
|
|
2204
|
+
* @api public
|
|
2205
|
+
*/
|
|
2206
|
+
picomatch$2.matchBase = (input, glob$1, options) => {
|
|
2207
|
+
const regex$1 = glob$1 instanceof RegExp ? glob$1 : picomatch$2.makeRe(glob$1, options);
|
|
2208
|
+
return regex$1.test(utils$1.basename(input));
|
|
2209
|
+
};
|
|
2210
|
+
/**
|
|
2211
|
+
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
2212
|
+
*
|
|
2213
|
+
* ```js
|
|
2214
|
+
* const picomatch = require('picomatch');
|
|
2215
|
+
* // picomatch.isMatch(string, patterns[, options]);
|
|
2216
|
+
*
|
|
2217
|
+
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
2218
|
+
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
2219
|
+
* ```
|
|
2220
|
+
* @param {String|Array} str The string to test.
|
|
2221
|
+
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
2222
|
+
* @param {Object} [options] See available [options](#options).
|
|
2223
|
+
* @return {Boolean} Returns true if any patterns match `str`
|
|
2224
|
+
* @api public
|
|
2225
|
+
*/
|
|
2226
|
+
picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
|
|
2227
|
+
/**
|
|
2228
|
+
* Parse a glob pattern to create the source string for a regular
|
|
2229
|
+
* expression.
|
|
2230
|
+
*
|
|
2231
|
+
* ```js
|
|
2232
|
+
* const picomatch = require('picomatch');
|
|
2233
|
+
* const result = picomatch.parse(pattern[, options]);
|
|
2234
|
+
* ```
|
|
2235
|
+
* @param {String} `pattern`
|
|
2236
|
+
* @param {Object} `options`
|
|
2237
|
+
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
2238
|
+
* @api public
|
|
2239
|
+
*/
|
|
2240
|
+
picomatch$2.parse = (pattern, options) => {
|
|
2241
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch$2.parse(p, options));
|
|
2242
|
+
return parse(pattern, {
|
|
2243
|
+
...options,
|
|
2244
|
+
fastpaths: false
|
|
2245
|
+
});
|
|
2246
|
+
};
|
|
2247
|
+
/**
|
|
2248
|
+
* Scan a glob pattern to separate the pattern into segments.
|
|
2249
|
+
*
|
|
2250
|
+
* ```js
|
|
2251
|
+
* const picomatch = require('picomatch');
|
|
2252
|
+
* // picomatch.scan(input[, options]);
|
|
2253
|
+
*
|
|
2254
|
+
* const result = picomatch.scan('!./foo/*.js');
|
|
2255
|
+
* console.log(result);
|
|
2256
|
+
* { prefix: '!./',
|
|
2257
|
+
* input: '!./foo/*.js',
|
|
2258
|
+
* start: 3,
|
|
2259
|
+
* base: 'foo',
|
|
2260
|
+
* glob: '*.js',
|
|
2261
|
+
* isBrace: false,
|
|
2262
|
+
* isBracket: false,
|
|
2263
|
+
* isGlob: true,
|
|
2264
|
+
* isExtglob: false,
|
|
2265
|
+
* isGlobstar: false,
|
|
2266
|
+
* negated: true }
|
|
2267
|
+
* ```
|
|
2268
|
+
* @param {String} `input` Glob pattern to scan.
|
|
2269
|
+
* @param {Object} `options`
|
|
2270
|
+
* @return {Object} Returns an object with
|
|
2271
|
+
* @api public
|
|
2272
|
+
*/
|
|
2273
|
+
picomatch$2.scan = (input, options) => scan(input, options);
|
|
2274
|
+
/**
|
|
2275
|
+
* Compile a regular expression from the `state` object returned by the
|
|
2276
|
+
* [parse()](#parse) method.
|
|
2277
|
+
*
|
|
2278
|
+
* @param {Object} `state`
|
|
2279
|
+
* @param {Object} `options`
|
|
2280
|
+
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
2281
|
+
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
2282
|
+
* @return {RegExp}
|
|
2283
|
+
* @api public
|
|
2284
|
+
*/
|
|
2285
|
+
picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
2286
|
+
if (returnOutput === true) return state.output;
|
|
2287
|
+
const opts = options || {};
|
|
2288
|
+
const prepend = opts.contains ? "" : "^";
|
|
2289
|
+
const append = opts.contains ? "" : "$";
|
|
2290
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
2291
|
+
if (state && state.negated === true) source = `^(?!${source}).*$`;
|
|
2292
|
+
const regex$1 = picomatch$2.toRegex(source, options);
|
|
2293
|
+
if (returnState === true) regex$1.state = state;
|
|
2294
|
+
return regex$1;
|
|
2295
|
+
};
|
|
2296
|
+
/**
|
|
2297
|
+
* Create a regular expression from a parsed glob pattern.
|
|
2298
|
+
*
|
|
2299
|
+
* ```js
|
|
2300
|
+
* const picomatch = require('picomatch');
|
|
2301
|
+
* const state = picomatch.parse('*.js');
|
|
2302
|
+
* // picomatch.compileRe(state[, options]);
|
|
2303
|
+
*
|
|
2304
|
+
* console.log(picomatch.compileRe(state));
|
|
2305
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2306
|
+
* ```
|
|
2307
|
+
* @param {String} `state` The object returned from the `.parse` method.
|
|
2308
|
+
* @param {Object} `options`
|
|
2309
|
+
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
2310
|
+
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
2311
|
+
* @return {RegExp} Returns a regex created from the given pattern.
|
|
2312
|
+
* @api public
|
|
2313
|
+
*/
|
|
2314
|
+
picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
2315
|
+
if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
|
|
2316
|
+
let parsed = {
|
|
2317
|
+
negated: false,
|
|
2318
|
+
fastpaths: true
|
|
2319
|
+
};
|
|
2320
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
|
|
2321
|
+
if (!parsed.output) parsed = parse(input, options);
|
|
2322
|
+
return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
|
|
2323
|
+
};
|
|
2324
|
+
/**
|
|
2325
|
+
* Create a regular expression from the given regex source string.
|
|
2326
|
+
*
|
|
2327
|
+
* ```js
|
|
2328
|
+
* const picomatch = require('picomatch');
|
|
2329
|
+
* // picomatch.toRegex(source[, options]);
|
|
2330
|
+
*
|
|
2331
|
+
* const { output } = picomatch.parse('*.js');
|
|
2332
|
+
* console.log(picomatch.toRegex(output));
|
|
2333
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2334
|
+
* ```
|
|
2335
|
+
* @param {String} `source` Regular expression source string.
|
|
2336
|
+
* @param {Object} `options`
|
|
2337
|
+
* @return {RegExp}
|
|
2338
|
+
* @api public
|
|
2339
|
+
*/
|
|
2340
|
+
picomatch$2.toRegex = (source, options) => {
|
|
2341
|
+
try {
|
|
2342
|
+
const opts = options || {};
|
|
2343
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
2344
|
+
} catch (err) {
|
|
2345
|
+
if (options && options.debug === true) throw err;
|
|
2346
|
+
return /$^/;
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
/**
|
|
2350
|
+
* Picomatch constants.
|
|
2351
|
+
* @return {Object}
|
|
2352
|
+
*/
|
|
2353
|
+
picomatch$2.constants = constants;
|
|
2354
|
+
/**
|
|
2355
|
+
* Expose "picomatch"
|
|
2356
|
+
*/
|
|
2357
|
+
module.exports = picomatch$2;
|
|
2358
|
+
} });
|
|
2359
|
+
|
|
2360
|
+
//#endregion
|
|
2361
|
+
//#region node_modules/picomatch/index.js
|
|
2362
|
+
var require_picomatch = __commonJS({ "node_modules/picomatch/index.js"(exports, module) {
|
|
2363
|
+
const pico = require_picomatch$1();
|
|
2364
|
+
const utils = require_utils();
|
|
2365
|
+
function picomatch$1(glob$1, options, returnState = false) {
|
|
2366
|
+
if (options && (options.windows === null || options.windows === void 0)) options = {
|
|
2367
|
+
...options,
|
|
2368
|
+
windows: utils.isWindows()
|
|
2369
|
+
};
|
|
2370
|
+
return pico(glob$1, options, returnState);
|
|
2371
|
+
}
|
|
2372
|
+
Object.assign(picomatch$1, pico);
|
|
2373
|
+
module.exports = picomatch$1;
|
|
2374
|
+
} });
|
|
2375
|
+
|
|
2376
|
+
//#endregion
|
|
2377
|
+
//#region node_modules/fdir/dist/builder/index.js
|
|
2378
|
+
var require_builder = __commonJS({ "node_modules/fdir/dist/builder/index.js"(exports) {
|
|
2379
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2380
|
+
exports.Builder = void 0;
|
|
2381
|
+
const path_1 = __require("path");
|
|
2382
|
+
const api_builder_1 = require_api_builder();
|
|
2383
|
+
var pm = null;
|
|
2384
|
+
/* c8 ignore next 6 */
|
|
2385
|
+
try {
|
|
2386
|
+
__require.resolve("picomatch");
|
|
2387
|
+
pm = require_picomatch();
|
|
2388
|
+
} catch (_e) {}
|
|
2389
|
+
var Builder = class {
|
|
2390
|
+
globCache = {};
|
|
2391
|
+
options = {
|
|
2392
|
+
maxDepth: Infinity,
|
|
2393
|
+
suppressErrors: true,
|
|
2394
|
+
pathSeparator: path_1.sep,
|
|
2395
|
+
filters: []
|
|
2396
|
+
};
|
|
2397
|
+
globFunction;
|
|
2398
|
+
constructor(options) {
|
|
2399
|
+
this.options = {
|
|
2400
|
+
...this.options,
|
|
2401
|
+
...options
|
|
2402
|
+
};
|
|
2403
|
+
this.globFunction = this.options.globFunction;
|
|
2404
|
+
}
|
|
2405
|
+
group() {
|
|
2406
|
+
this.options.group = true;
|
|
2407
|
+
return this;
|
|
2408
|
+
}
|
|
2409
|
+
withPathSeparator(separator) {
|
|
2410
|
+
this.options.pathSeparator = separator;
|
|
2411
|
+
return this;
|
|
2412
|
+
}
|
|
2413
|
+
withBasePath() {
|
|
2414
|
+
this.options.includeBasePath = true;
|
|
2415
|
+
return this;
|
|
2416
|
+
}
|
|
2417
|
+
withRelativePaths() {
|
|
2418
|
+
this.options.relativePaths = true;
|
|
2419
|
+
return this;
|
|
2420
|
+
}
|
|
2421
|
+
withDirs() {
|
|
2422
|
+
this.options.includeDirs = true;
|
|
2423
|
+
return this;
|
|
2424
|
+
}
|
|
2425
|
+
withMaxDepth(depth$1) {
|
|
2426
|
+
this.options.maxDepth = depth$1;
|
|
2427
|
+
return this;
|
|
2428
|
+
}
|
|
2429
|
+
withMaxFiles(limit) {
|
|
2430
|
+
this.options.maxFiles = limit;
|
|
2431
|
+
return this;
|
|
2432
|
+
}
|
|
2433
|
+
withFullPaths() {
|
|
2434
|
+
this.options.resolvePaths = true;
|
|
2435
|
+
this.options.includeBasePath = true;
|
|
2436
|
+
return this;
|
|
2437
|
+
}
|
|
2438
|
+
withErrors() {
|
|
2439
|
+
this.options.suppressErrors = false;
|
|
2440
|
+
return this;
|
|
2441
|
+
}
|
|
2442
|
+
withSymlinks({ resolvePaths = true } = {}) {
|
|
2443
|
+
this.options.resolveSymlinks = true;
|
|
2444
|
+
this.options.useRealPaths = resolvePaths;
|
|
2445
|
+
return this.withFullPaths();
|
|
2446
|
+
}
|
|
2447
|
+
withAbortSignal(signal) {
|
|
2448
|
+
this.options.signal = signal;
|
|
2449
|
+
return this;
|
|
2450
|
+
}
|
|
2451
|
+
normalize() {
|
|
2452
|
+
this.options.normalizePath = true;
|
|
2453
|
+
return this;
|
|
2454
|
+
}
|
|
2455
|
+
filter(predicate) {
|
|
2456
|
+
this.options.filters.push(predicate);
|
|
2457
|
+
return this;
|
|
2458
|
+
}
|
|
2459
|
+
onlyDirs() {
|
|
2460
|
+
this.options.excludeFiles = true;
|
|
2461
|
+
this.options.includeDirs = true;
|
|
2462
|
+
return this;
|
|
2463
|
+
}
|
|
2464
|
+
exclude(predicate) {
|
|
2465
|
+
this.options.exclude = predicate;
|
|
2466
|
+
return this;
|
|
2467
|
+
}
|
|
2468
|
+
onlyCounts() {
|
|
2469
|
+
this.options.onlyCounts = true;
|
|
2470
|
+
return this;
|
|
2471
|
+
}
|
|
2472
|
+
crawl(root) {
|
|
2473
|
+
return new api_builder_1.APIBuilder(root || ".", this.options);
|
|
2474
|
+
}
|
|
2475
|
+
withGlobFunction(fn) {
|
|
2476
|
+
this.globFunction = fn;
|
|
2477
|
+
return this;
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2480
|
+
* @deprecated Pass options using the constructor instead:
|
|
2481
|
+
* ```ts
|
|
2482
|
+
* new fdir(options).crawl("/path/to/root");
|
|
2483
|
+
* ```
|
|
2484
|
+
* This method will be removed in v7.0
|
|
2485
|
+
*/
|
|
2486
|
+
/* c8 ignore next 4 */
|
|
2487
|
+
crawlWithOptions(root, options) {
|
|
2488
|
+
this.options = {
|
|
2489
|
+
...this.options,
|
|
2490
|
+
...options
|
|
2491
|
+
};
|
|
2492
|
+
return new api_builder_1.APIBuilder(root || ".", this.options);
|
|
2493
|
+
}
|
|
2494
|
+
glob(...patterns) {
|
|
2495
|
+
if (this.globFunction) return this.globWithOptions(patterns);
|
|
2496
|
+
return this.globWithOptions(patterns, ...[{ dot: true }]);
|
|
2497
|
+
}
|
|
2498
|
+
globWithOptions(patterns, ...options) {
|
|
2499
|
+
const globFn = this.globFunction || pm;
|
|
2500
|
+
/* c8 ignore next 5 */
|
|
2501
|
+
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
2502
|
+
var isMatch = this.globCache[patterns.join("\0")];
|
|
2503
|
+
if (!isMatch) {
|
|
2504
|
+
isMatch = globFn(patterns, ...options);
|
|
2505
|
+
this.globCache[patterns.join("\0")] = isMatch;
|
|
2506
|
+
}
|
|
2507
|
+
this.options.filters.push((path$2) => isMatch(path$2));
|
|
2508
|
+
return this;
|
|
2509
|
+
}
|
|
2510
|
+
};
|
|
2511
|
+
exports.Builder = Builder;
|
|
2512
|
+
} });
|
|
2513
|
+
|
|
2514
|
+
//#endregion
|
|
2515
|
+
//#region node_modules/fdir/dist/types.js
|
|
2516
|
+
var require_types = __commonJS({ "node_modules/fdir/dist/types.js"(exports) {
|
|
2517
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2518
|
+
} });
|
|
2519
|
+
|
|
2520
|
+
//#endregion
|
|
2521
|
+
//#region node_modules/fdir/dist/index.js
|
|
2522
|
+
var require_dist = __commonJS({ "node_modules/fdir/dist/index.js"(exports) {
|
|
2523
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2524
|
+
if (k2 === void 0) k2 = k;
|
|
2525
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2526
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
2527
|
+
enumerable: true,
|
|
2528
|
+
get: function() {
|
|
2529
|
+
return m[k];
|
|
2530
|
+
}
|
|
2531
|
+
};
|
|
2532
|
+
Object.defineProperty(o, k2, desc);
|
|
2533
|
+
} : function(o, m, k, k2) {
|
|
2534
|
+
if (k2 === void 0) k2 = k;
|
|
2535
|
+
o[k2] = m[k];
|
|
2536
|
+
});
|
|
2537
|
+
var __exportStar = void 0 && (void 0).__exportStar || function(m, exports$1) {
|
|
2538
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
2539
|
+
};
|
|
2540
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2541
|
+
exports.fdir = void 0;
|
|
2542
|
+
const builder_1 = require_builder();
|
|
2543
|
+
Object.defineProperty(exports, "fdir", {
|
|
2544
|
+
enumerable: true,
|
|
2545
|
+
get: function() {
|
|
2546
|
+
return builder_1.Builder;
|
|
2547
|
+
}
|
|
2548
|
+
});
|
|
2549
|
+
__exportStar(require_types(), exports);
|
|
2550
|
+
} });
|
|
2551
|
+
|
|
2552
|
+
//#endregion
|
|
2553
|
+
//#region node_modules/tinyglobby/dist/index.mjs
|
|
2554
|
+
var import_dist = __toESM(require_dist(), 1);
|
|
2555
|
+
var import_picomatch = __toESM(require_picomatch(), 1);
|
|
2556
|
+
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
2557
|
+
function getPartialMatcher(patterns, options) {
|
|
2558
|
+
const patternsCount = patterns.length;
|
|
2559
|
+
const patternsParts = Array(patternsCount);
|
|
2560
|
+
const regexes = Array(patternsCount);
|
|
2561
|
+
for (let i = 0; i < patternsCount; i++) {
|
|
2562
|
+
const parts = splitPattern(patterns[i]);
|
|
2563
|
+
patternsParts[i] = parts;
|
|
2564
|
+
const partsCount = parts.length;
|
|
2565
|
+
const partRegexes = Array(partsCount);
|
|
2566
|
+
for (let j = 0; j < partsCount; j++) partRegexes[j] = import_picomatch.default.makeRe(parts[j], options);
|
|
2567
|
+
regexes[i] = partRegexes;
|
|
2568
|
+
}
|
|
2569
|
+
return (input) => {
|
|
2570
|
+
const inputParts = input.split("/");
|
|
2571
|
+
if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
|
2572
|
+
for (let i = 0; i < patterns.length; i++) {
|
|
2573
|
+
const patternParts = patternsParts[i];
|
|
2574
|
+
const regex$1 = regexes[i];
|
|
2575
|
+
const inputPatternCount = inputParts.length;
|
|
2576
|
+
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
2577
|
+
let j = 0;
|
|
2578
|
+
while (j < minParts) {
|
|
2579
|
+
const part = patternParts[j];
|
|
2580
|
+
if (part.includes("/")) return true;
|
|
2581
|
+
const match = regex$1[j].test(inputParts[j]);
|
|
2582
|
+
if (!match) break;
|
|
2583
|
+
if (part === "**") return true;
|
|
2584
|
+
j++;
|
|
2585
|
+
}
|
|
2586
|
+
if (j === inputPatternCount) return true;
|
|
2587
|
+
}
|
|
2588
|
+
return false;
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
const splitPatternOptions = { parts: true };
|
|
2592
|
+
function splitPattern(path$1$1) {
|
|
2593
|
+
var _result$parts;
|
|
2594
|
+
const result = import_picomatch.default.scan(path$1$1, splitPatternOptions);
|
|
2595
|
+
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1$1];
|
|
2596
|
+
}
|
|
2597
|
+
const isWin = process.platform === "win32";
|
|
2598
|
+
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
2599
|
+
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
2600
|
+
const escapePosixPath = (path$1$1) => path$1$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2601
|
+
const escapeWin32Path = (path$1$1) => path$1$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2602
|
+
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
2603
|
+
function isDynamicPattern(pattern, options) {
|
|
2604
|
+
if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
|
|
2605
|
+
const scan$2 = import_picomatch.default.scan(pattern);
|
|
2606
|
+
return scan$2.isGlob || scan$2.negated;
|
|
2607
|
+
}
|
|
2608
|
+
function log(...tasks) {
|
|
2609
|
+
console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`, ...tasks);
|
|
2610
|
+
}
|
|
2611
|
+
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
2612
|
+
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
2613
|
+
const BACKSLASHES = /\\/g;
|
|
2614
|
+
function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
2615
|
+
let result = pattern;
|
|
2616
|
+
if (pattern.endsWith("/")) result = pattern.slice(0, -1);
|
|
2617
|
+
if (!result.endsWith("*") && expandDirectories) result += "/**";
|
|
2618
|
+
const escapedCwd = escapePath(cwd);
|
|
2619
|
+
if (path$1.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = posix.relative(escapedCwd, result);
|
|
2620
|
+
else result = posix.normalize(result);
|
|
2621
|
+
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
2622
|
+
const parts = splitPattern(result);
|
|
2623
|
+
if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
|
|
2624
|
+
const n = (parentDirectoryMatch[0].length + 1) / 3;
|
|
2625
|
+
let i = 0;
|
|
2626
|
+
const cwdParts = escapedCwd.split("/");
|
|
2627
|
+
while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
|
|
2628
|
+
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
2629
|
+
i++;
|
|
2630
|
+
}
|
|
2631
|
+
const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
|
|
2632
|
+
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
|
|
2633
|
+
props.root = potentialRoot;
|
|
2634
|
+
props.depthOffset = -n + i;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
if (!isIgnore && props.depthOffset >= 0) {
|
|
2638
|
+
var _props$commonPath;
|
|
2639
|
+
(_props$commonPath = props.commonPath) !== null && _props$commonPath !== void 0 || (props.commonPath = parts);
|
|
2640
|
+
const newCommonPath = [];
|
|
2641
|
+
const length = Math.min(props.commonPath.length, parts.length);
|
|
2642
|
+
for (let i = 0; i < length; i++) {
|
|
2643
|
+
const part = parts[i];
|
|
2644
|
+
if (part === "**" && !parts[i + 1]) {
|
|
2645
|
+
newCommonPath.pop();
|
|
2646
|
+
break;
|
|
2647
|
+
}
|
|
2648
|
+
if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
|
|
2649
|
+
newCommonPath.push(part);
|
|
2650
|
+
}
|
|
2651
|
+
props.depthOffset = newCommonPath.length;
|
|
2652
|
+
props.commonPath = newCommonPath;
|
|
2653
|
+
props.root = newCommonPath.length > 0 ? path$1.posix.join(cwd, ...newCommonPath) : cwd;
|
|
2654
|
+
}
|
|
2655
|
+
return result;
|
|
2656
|
+
}
|
|
2657
|
+
function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, props) {
|
|
2658
|
+
if (typeof patterns === "string") patterns = [patterns];
|
|
2659
|
+
else if (!patterns) patterns = ["**/*"];
|
|
2660
|
+
if (typeof ignore === "string") ignore = [ignore];
|
|
2661
|
+
const matchPatterns = [];
|
|
2662
|
+
const ignorePatterns = [];
|
|
2663
|
+
for (const pattern of ignore) {
|
|
2664
|
+
if (!pattern) continue;
|
|
2665
|
+
if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
|
|
2666
|
+
}
|
|
2667
|
+
for (const pattern of patterns) {
|
|
2668
|
+
if (!pattern) continue;
|
|
2669
|
+
if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
|
|
2670
|
+
else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
|
|
2671
|
+
}
|
|
2672
|
+
return {
|
|
2673
|
+
match: matchPatterns,
|
|
2674
|
+
ignore: ignorePatterns
|
|
2675
|
+
};
|
|
2676
|
+
}
|
|
2677
|
+
function getRelativePath(path$1$1, cwd, root) {
|
|
2678
|
+
return posix.relative(cwd, `${root}/${path$1$1}`) || ".";
|
|
2679
|
+
}
|
|
2680
|
+
function processPath(path$1$1, cwd, root, isDirectory, absolute) {
|
|
2681
|
+
const relativePath = absolute ? path$1$1.slice(root === "/" ? 1 : root.length + 1) || "." : path$1$1;
|
|
2682
|
+
if (root === cwd) return isDirectory && relativePath !== "." ? relativePath.slice(0, -1) : relativePath;
|
|
2683
|
+
return getRelativePath(relativePath, cwd, root);
|
|
2684
|
+
}
|
|
2685
|
+
function formatPaths(paths, cwd, root) {
|
|
2686
|
+
for (let i = paths.length - 1; i >= 0; i--) {
|
|
2687
|
+
const path$1$1 = paths[i];
|
|
2688
|
+
paths[i] = getRelativePath(path$1$1, cwd, root) + (!path$1$1 || path$1$1.endsWith("/") ? "/" : "");
|
|
2689
|
+
}
|
|
2690
|
+
return paths;
|
|
2691
|
+
}
|
|
2692
|
+
function crawl(options, cwd, sync$1) {
|
|
2693
|
+
if (process.env.TINYGLOBBY_DEBUG) options.debug = true;
|
|
2694
|
+
if (options.debug) log("globbing with options:", options, "cwd:", cwd);
|
|
2695
|
+
if (Array.isArray(options.patterns) && options.patterns.length === 0) return sync$1 ? [] : Promise.resolve([]);
|
|
2696
|
+
const props = {
|
|
2697
|
+
root: cwd,
|
|
2698
|
+
commonPath: null,
|
|
2699
|
+
depthOffset: 0
|
|
2700
|
+
};
|
|
2701
|
+
const processed = processPatterns(options, cwd, props);
|
|
2702
|
+
const nocase = options.caseSensitiveMatch === false;
|
|
2703
|
+
if (options.debug) log("internal processing patterns:", processed);
|
|
2704
|
+
const matcher = (0, import_picomatch.default)(processed.match, {
|
|
2705
|
+
dot: options.dot,
|
|
2706
|
+
nocase,
|
|
2707
|
+
ignore: processed.ignore
|
|
2708
|
+
});
|
|
2709
|
+
const ignore = (0, import_picomatch.default)(processed.ignore, {
|
|
2710
|
+
dot: options.dot,
|
|
2711
|
+
nocase
|
|
2712
|
+
});
|
|
2713
|
+
const partialMatcher = getPartialMatcher(processed.match, {
|
|
2714
|
+
dot: options.dot,
|
|
2715
|
+
nocase
|
|
2716
|
+
});
|
|
2717
|
+
const fdirOptions = {
|
|
2718
|
+
filters: [options.debug ? (p, isDirectory) => {
|
|
2719
|
+
const path$1$1 = processPath(p, cwd, props.root, isDirectory, options.absolute);
|
|
2720
|
+
const matches = matcher(path$1$1);
|
|
2721
|
+
if (matches) log(`matched ${path$1$1}`);
|
|
2722
|
+
return matches;
|
|
2723
|
+
} : (p, isDirectory) => matcher(processPath(p, cwd, props.root, isDirectory, options.absolute))],
|
|
2724
|
+
exclude: options.debug ? (_, p) => {
|
|
2725
|
+
const relativePath = processPath(p, cwd, props.root, true, true);
|
|
2726
|
+
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2727
|
+
if (skipped) log(`skipped ${p}`);
|
|
2728
|
+
else log(`crawling ${p}`);
|
|
2729
|
+
return skipped;
|
|
2730
|
+
} : (_, p) => {
|
|
2731
|
+
const relativePath = processPath(p, cwd, props.root, true, true);
|
|
2732
|
+
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2733
|
+
},
|
|
2734
|
+
pathSeparator: "/",
|
|
2735
|
+
relativePaths: true,
|
|
2736
|
+
resolveSymlinks: true
|
|
2737
|
+
};
|
|
2738
|
+
if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
|
|
2739
|
+
if (options.absolute) {
|
|
2740
|
+
fdirOptions.relativePaths = false;
|
|
2741
|
+
fdirOptions.resolvePaths = true;
|
|
2742
|
+
fdirOptions.includeBasePath = true;
|
|
2743
|
+
}
|
|
2744
|
+
if (options.followSymbolicLinks === false) {
|
|
2745
|
+
fdirOptions.resolveSymlinks = false;
|
|
2746
|
+
fdirOptions.excludeSymlinks = true;
|
|
2747
|
+
}
|
|
2748
|
+
if (options.onlyDirectories) {
|
|
2749
|
+
fdirOptions.excludeFiles = true;
|
|
2750
|
+
fdirOptions.includeDirs = true;
|
|
2751
|
+
} else if (options.onlyFiles === false) fdirOptions.includeDirs = true;
|
|
2752
|
+
props.root = props.root.replace(BACKSLASHES, "");
|
|
2753
|
+
const root = props.root;
|
|
2754
|
+
if (options.debug) log("internal properties:", props);
|
|
2755
|
+
const api = new import_dist.fdir(fdirOptions).crawl(root);
|
|
2756
|
+
if (cwd === root || options.absolute) return sync$1 ? api.sync() : api.withPromise();
|
|
2757
|
+
return sync$1 ? formatPaths(api.sync(), cwd, root) : api.withPromise().then((paths) => formatPaths(paths, cwd, root));
|
|
2758
|
+
}
|
|
2759
|
+
async function glob(patternsOrOptions, options) {
|
|
2760
|
+
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2761
|
+
const opts = Array.isArray(patternsOrOptions) || typeof patternsOrOptions === "string" ? {
|
|
2762
|
+
...options,
|
|
2763
|
+
patterns: patternsOrOptions
|
|
2764
|
+
} : patternsOrOptions;
|
|
2765
|
+
const cwd = opts.cwd ? path$1.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
|
2766
|
+
return crawl(opts, cwd, false);
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
//#endregion
|
|
2770
|
+
//#region node_modules/valibot/dist/index.js
|
|
2771
|
+
var store;
|
|
2772
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2773
|
+
function getGlobalConfig(config2) {
|
|
2774
|
+
return {
|
|
2775
|
+
lang: config2?.lang ?? store?.lang,
|
|
2776
|
+
message: config2?.message,
|
|
2777
|
+
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
2778
|
+
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
2779
|
+
};
|
|
2780
|
+
}
|
|
2781
|
+
var store2;
|
|
2782
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2783
|
+
function getGlobalMessage(lang) {
|
|
2784
|
+
return store2?.get(lang);
|
|
2785
|
+
}
|
|
2786
|
+
var store3;
|
|
2787
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2788
|
+
function getSchemaMessage(lang) {
|
|
2789
|
+
return store3?.get(lang);
|
|
2790
|
+
}
|
|
2791
|
+
var store4;
|
|
2792
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2793
|
+
function getSpecificMessage(reference, lang) {
|
|
2794
|
+
return store4?.get(reference)?.get(lang);
|
|
2795
|
+
}
|
|
2796
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2797
|
+
function _stringify(input) {
|
|
2798
|
+
const type = typeof input;
|
|
2799
|
+
if (type === "string") return `"${input}"`;
|
|
2800
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
2801
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
2802
|
+
return type;
|
|
2803
|
+
}
|
|
2804
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
2805
|
+
const input = other && "input" in other ? other.input : dataset.value;
|
|
2806
|
+
const expected = other?.expected ?? context.expects ?? null;
|
|
2807
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
2808
|
+
const issue = {
|
|
2809
|
+
kind: context.kind,
|
|
2810
|
+
type: context.type,
|
|
2811
|
+
input,
|
|
2812
|
+
expected,
|
|
2813
|
+
received,
|
|
2814
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
2815
|
+
requirement: context.requirement,
|
|
2816
|
+
path: other?.path,
|
|
2817
|
+
issues: other?.issues,
|
|
2818
|
+
lang: config2.lang,
|
|
2819
|
+
abortEarly: config2.abortEarly,
|
|
2820
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
2821
|
+
};
|
|
2822
|
+
const isSchema = context.kind === "schema";
|
|
2823
|
+
const message2 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
2824
|
+
if (message2 !== void 0) issue.message = typeof message2 === "function" ? message2(issue) : message2;
|
|
2825
|
+
if (isSchema) dataset.typed = false;
|
|
2826
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
2827
|
+
else dataset.issues = [issue];
|
|
2828
|
+
}
|
|
2829
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2830
|
+
function _getStandardProps(context) {
|
|
2831
|
+
return {
|
|
2832
|
+
version: 1,
|
|
2833
|
+
vendor: "valibot",
|
|
2834
|
+
validate(value2) {
|
|
2835
|
+
return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2840
|
+
function _isValidObjectKey(object2, key) {
|
|
2841
|
+
return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
2842
|
+
}
|
|
2843
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2844
|
+
function _joinExpects(values2, separator) {
|
|
2845
|
+
const list = [...new Set(values2)];
|
|
2846
|
+
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
2847
|
+
return list[0] ?? "never";
|
|
2848
|
+
}
|
|
2849
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2850
|
+
function regex(requirement, message2) {
|
|
2851
|
+
return {
|
|
2852
|
+
kind: "validation",
|
|
2853
|
+
type: "regex",
|
|
2854
|
+
reference: regex,
|
|
2855
|
+
async: false,
|
|
2856
|
+
expects: `${requirement}`,
|
|
2857
|
+
requirement,
|
|
2858
|
+
message: message2,
|
|
2859
|
+
"~run"(dataset, config2) {
|
|
2860
|
+
if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config2);
|
|
2861
|
+
return dataset;
|
|
2862
|
+
}
|
|
2863
|
+
};
|
|
2864
|
+
}
|
|
2865
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2866
|
+
function getFallback(schema, dataset, config2) {
|
|
2867
|
+
return typeof schema.fallback === "function" ? schema.fallback(dataset, config2) : schema.fallback;
|
|
2868
|
+
}
|
|
2869
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2870
|
+
function getDefault(schema, dataset, config2) {
|
|
2871
|
+
return typeof schema.default === "function" ? schema.default(dataset, config2) : schema.default;
|
|
2872
|
+
}
|
|
2873
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2874
|
+
function boolean(message2) {
|
|
2875
|
+
return {
|
|
2876
|
+
kind: "schema",
|
|
2877
|
+
type: "boolean",
|
|
2878
|
+
reference: boolean,
|
|
2879
|
+
expects: "boolean",
|
|
2880
|
+
async: false,
|
|
2881
|
+
message: message2,
|
|
2882
|
+
get "~standard"() {
|
|
2883
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
2884
|
+
},
|
|
2885
|
+
"~run"(dataset, config2) {
|
|
2886
|
+
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
2887
|
+
else _addIssue(this, "type", dataset, config2);
|
|
2888
|
+
return dataset;
|
|
2889
|
+
}
|
|
2890
|
+
};
|
|
2891
|
+
}
|
|
2892
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2893
|
+
function number(message2) {
|
|
2894
|
+
return {
|
|
2895
|
+
kind: "schema",
|
|
2896
|
+
type: "number",
|
|
2897
|
+
reference: number,
|
|
2898
|
+
expects: "number",
|
|
2899
|
+
async: false,
|
|
2900
|
+
message: message2,
|
|
2901
|
+
get "~standard"() {
|
|
2902
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
2903
|
+
},
|
|
2904
|
+
"~run"(dataset, config2) {
|
|
2905
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
2906
|
+
else _addIssue(this, "type", dataset, config2);
|
|
2907
|
+
return dataset;
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2910
|
+
}
|
|
2911
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2912
|
+
function object(entries2, message2) {
|
|
2913
|
+
return {
|
|
2914
|
+
kind: "schema",
|
|
2915
|
+
type: "object",
|
|
2916
|
+
reference: object,
|
|
2917
|
+
expects: "Object",
|
|
2918
|
+
async: false,
|
|
2919
|
+
entries: entries2,
|
|
2920
|
+
message: message2,
|
|
2921
|
+
get "~standard"() {
|
|
2922
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
2923
|
+
},
|
|
2924
|
+
"~run"(dataset, config2) {
|
|
2925
|
+
const input = dataset.value;
|
|
2926
|
+
if (input && typeof input === "object") {
|
|
2927
|
+
dataset.typed = true;
|
|
2928
|
+
dataset.value = {};
|
|
2929
|
+
for (const key in this.entries) {
|
|
2930
|
+
const valueSchema = this.entries[key];
|
|
2931
|
+
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
2932
|
+
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
2933
|
+
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
2934
|
+
if (valueDataset.issues) {
|
|
2935
|
+
const pathItem = {
|
|
2936
|
+
type: "object",
|
|
2937
|
+
origin: "value",
|
|
2938
|
+
input,
|
|
2939
|
+
key,
|
|
2940
|
+
value: value2
|
|
2941
|
+
};
|
|
2942
|
+
for (const issue of valueDataset.issues) {
|
|
2943
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
2944
|
+
else issue.path = [pathItem];
|
|
2945
|
+
dataset.issues?.push(issue);
|
|
2946
|
+
}
|
|
2947
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
2948
|
+
if (config2.abortEarly) {
|
|
2949
|
+
dataset.typed = false;
|
|
2950
|
+
break;
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
if (!valueDataset.typed) dataset.typed = false;
|
|
2954
|
+
dataset.value[key] = valueDataset.value;
|
|
2955
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
2956
|
+
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
2957
|
+
_addIssue(this, "key", dataset, config2, {
|
|
2958
|
+
input: void 0,
|
|
2959
|
+
expected: `"${key}"`,
|
|
2960
|
+
path: [{
|
|
2961
|
+
type: "object",
|
|
2962
|
+
origin: "key",
|
|
2963
|
+
input,
|
|
2964
|
+
key,
|
|
2965
|
+
value: input[key]
|
|
2966
|
+
}]
|
|
2967
|
+
});
|
|
2968
|
+
if (config2.abortEarly) break;
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
2972
|
+
return dataset;
|
|
2973
|
+
}
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2977
|
+
function optional(wrapped, default_) {
|
|
2978
|
+
return {
|
|
2979
|
+
kind: "schema",
|
|
2980
|
+
type: "optional",
|
|
2981
|
+
reference: optional,
|
|
2982
|
+
expects: `(${wrapped.expects} | undefined)`,
|
|
2983
|
+
async: false,
|
|
2984
|
+
wrapped,
|
|
2985
|
+
default: default_,
|
|
2986
|
+
get "~standard"() {
|
|
2987
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
2988
|
+
},
|
|
2989
|
+
"~run"(dataset, config2) {
|
|
2990
|
+
if (dataset.value === void 0) {
|
|
2991
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
2992
|
+
if (dataset.value === void 0) {
|
|
2993
|
+
dataset.typed = true;
|
|
2994
|
+
return dataset;
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
return this.wrapped["~run"](dataset, config2);
|
|
2998
|
+
}
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
3001
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3002
|
+
function record(key, value2, message2) {
|
|
3003
|
+
return {
|
|
3004
|
+
kind: "schema",
|
|
3005
|
+
type: "record",
|
|
3006
|
+
reference: record,
|
|
3007
|
+
expects: "Object",
|
|
3008
|
+
async: false,
|
|
3009
|
+
key,
|
|
3010
|
+
value: value2,
|
|
3011
|
+
message: message2,
|
|
3012
|
+
get "~standard"() {
|
|
3013
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
3014
|
+
},
|
|
3015
|
+
"~run"(dataset, config2) {
|
|
3016
|
+
const input = dataset.value;
|
|
3017
|
+
if (input && typeof input === "object") {
|
|
3018
|
+
dataset.typed = true;
|
|
3019
|
+
dataset.value = {};
|
|
3020
|
+
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
3021
|
+
const entryValue = input[entryKey];
|
|
3022
|
+
const keyDataset = this.key["~run"]({ value: entryKey }, config2);
|
|
3023
|
+
if (keyDataset.issues) {
|
|
3024
|
+
const pathItem = {
|
|
3025
|
+
type: "object",
|
|
3026
|
+
origin: "key",
|
|
3027
|
+
input,
|
|
3028
|
+
key: entryKey,
|
|
3029
|
+
value: entryValue
|
|
3030
|
+
};
|
|
3031
|
+
for (const issue of keyDataset.issues) {
|
|
3032
|
+
issue.path = [pathItem];
|
|
3033
|
+
dataset.issues?.push(issue);
|
|
3034
|
+
}
|
|
3035
|
+
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
3036
|
+
if (config2.abortEarly) {
|
|
3037
|
+
dataset.typed = false;
|
|
3038
|
+
break;
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
const valueDataset = this.value["~run"]({ value: entryValue }, config2);
|
|
3042
|
+
if (valueDataset.issues) {
|
|
3043
|
+
const pathItem = {
|
|
3044
|
+
type: "object",
|
|
3045
|
+
origin: "value",
|
|
3046
|
+
input,
|
|
3047
|
+
key: entryKey,
|
|
3048
|
+
value: entryValue
|
|
3049
|
+
};
|
|
3050
|
+
for (const issue of valueDataset.issues) {
|
|
3051
|
+
if (issue.path) issue.path.unshift(pathItem);
|
|
3052
|
+
else issue.path = [pathItem];
|
|
3053
|
+
dataset.issues?.push(issue);
|
|
3054
|
+
}
|
|
3055
|
+
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
3056
|
+
if (config2.abortEarly) {
|
|
3057
|
+
dataset.typed = false;
|
|
3058
|
+
break;
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
3062
|
+
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
3063
|
+
}
|
|
3064
|
+
} else _addIssue(this, "type", dataset, config2);
|
|
3065
|
+
return dataset;
|
|
3066
|
+
}
|
|
3067
|
+
};
|
|
3068
|
+
}
|
|
3069
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3070
|
+
function string(message2) {
|
|
3071
|
+
return {
|
|
3072
|
+
kind: "schema",
|
|
3073
|
+
type: "string",
|
|
3074
|
+
reference: string,
|
|
3075
|
+
expects: "string",
|
|
3076
|
+
async: false,
|
|
3077
|
+
message: message2,
|
|
3078
|
+
get "~standard"() {
|
|
3079
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
3080
|
+
},
|
|
3081
|
+
"~run"(dataset, config2) {
|
|
3082
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
3083
|
+
else _addIssue(this, "type", dataset, config2);
|
|
3084
|
+
return dataset;
|
|
3085
|
+
}
|
|
3086
|
+
};
|
|
3087
|
+
}
|
|
3088
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3089
|
+
function _subIssues(datasets) {
|
|
3090
|
+
let issues;
|
|
3091
|
+
if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
|
|
3092
|
+
else issues = dataset.issues;
|
|
3093
|
+
return issues;
|
|
3094
|
+
}
|
|
3095
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3096
|
+
function union(options, message2) {
|
|
3097
|
+
return {
|
|
3098
|
+
kind: "schema",
|
|
3099
|
+
type: "union",
|
|
3100
|
+
reference: union,
|
|
3101
|
+
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
3102
|
+
async: false,
|
|
3103
|
+
options,
|
|
3104
|
+
message: message2,
|
|
3105
|
+
get "~standard"() {
|
|
3106
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
3107
|
+
},
|
|
3108
|
+
"~run"(dataset, config2) {
|
|
3109
|
+
let validDataset;
|
|
3110
|
+
let typedDatasets;
|
|
3111
|
+
let untypedDatasets;
|
|
3112
|
+
for (const schema of this.options) {
|
|
3113
|
+
const optionDataset = schema["~run"]({ value: dataset.value }, config2);
|
|
3114
|
+
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
3115
|
+
else typedDatasets = [optionDataset];
|
|
3116
|
+
else {
|
|
3117
|
+
validDataset = optionDataset;
|
|
3118
|
+
break;
|
|
3119
|
+
}
|
|
3120
|
+
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
3121
|
+
else untypedDatasets = [optionDataset];
|
|
3122
|
+
}
|
|
3123
|
+
if (validDataset) return validDataset;
|
|
3124
|
+
if (typedDatasets) {
|
|
3125
|
+
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
3126
|
+
_addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
3127
|
+
dataset.typed = true;
|
|
3128
|
+
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
3129
|
+
else _addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
3130
|
+
return dataset;
|
|
3131
|
+
}
|
|
3132
|
+
};
|
|
3133
|
+
}
|
|
3134
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3135
|
+
function pipe(...pipe2) {
|
|
3136
|
+
return {
|
|
3137
|
+
...pipe2[0],
|
|
3138
|
+
pipe: pipe2,
|
|
3139
|
+
get "~standard"() {
|
|
3140
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
3141
|
+
},
|
|
3142
|
+
"~run"(dataset, config2) {
|
|
3143
|
+
for (const item of pipe2) if (item.kind !== "metadata") {
|
|
3144
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
3145
|
+
dataset.typed = false;
|
|
3146
|
+
break;
|
|
3147
|
+
}
|
|
3148
|
+
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) dataset = item["~run"](dataset, config2);
|
|
3149
|
+
}
|
|
3150
|
+
return dataset;
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3153
|
+
}
|
|
3154
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3155
|
+
function safeParse(schema, input, config2) {
|
|
3156
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
3157
|
+
return {
|
|
3158
|
+
typed: dataset.typed,
|
|
3159
|
+
success: !dataset.issues,
|
|
3160
|
+
output: dataset.value,
|
|
3161
|
+
issues: dataset.issues
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
//#endregion
|
|
3166
|
+
//#region data-loader.ts
|
|
3167
|
+
const getDefaultClaudePath = () => path.join(homedir(), ".claude");
|
|
3168
|
+
const UsageDataSchema = object({
|
|
3169
|
+
timestamp: string(),
|
|
3170
|
+
message: object({ usage: object({
|
|
3171
|
+
input_tokens: number(),
|
|
3172
|
+
output_tokens: number(),
|
|
3173
|
+
cache_creation_input_tokens: optional(number()),
|
|
3174
|
+
cache_read_input_tokens: optional(number())
|
|
3175
|
+
}) }),
|
|
3176
|
+
costUSD: number()
|
|
3177
|
+
});
|
|
3178
|
+
const DailyUsageSchema = object({
|
|
3179
|
+
date: string(),
|
|
3180
|
+
inputTokens: number(),
|
|
3181
|
+
outputTokens: number(),
|
|
3182
|
+
cacheCreationTokens: number(),
|
|
3183
|
+
cacheReadTokens: number(),
|
|
3184
|
+
totalCost: number()
|
|
3185
|
+
});
|
|
3186
|
+
const SessionUsageSchema = object({
|
|
3187
|
+
sessionId: string(),
|
|
3188
|
+
projectPath: string(),
|
|
3189
|
+
inputTokens: number(),
|
|
3190
|
+
outputTokens: number(),
|
|
3191
|
+
cacheCreationTokens: number(),
|
|
3192
|
+
cacheReadTokens: number(),
|
|
3193
|
+
totalCost: number(),
|
|
3194
|
+
lastActivity: string()
|
|
3195
|
+
});
|
|
3196
|
+
const formatDate = (dateStr) => {
|
|
3197
|
+
const date = new Date(dateStr);
|
|
3198
|
+
const year = date.getFullYear();
|
|
3199
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
3200
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
3201
|
+
return `${year}-${month}-${day}`;
|
|
3202
|
+
};
|
|
3203
|
+
async function loadUsageData(options) {
|
|
3204
|
+
const claudePath = options?.claudePath ?? getDefaultClaudePath();
|
|
3205
|
+
const claudeDir = path.join(claudePath, "projects");
|
|
3206
|
+
const files = await glob(["**/*.jsonl"], {
|
|
3207
|
+
cwd: claudeDir,
|
|
3208
|
+
absolute: true
|
|
3209
|
+
});
|
|
3210
|
+
if (files.length === 0) return [];
|
|
3211
|
+
const dailyMap = new Map();
|
|
3212
|
+
for (const file of files) {
|
|
3213
|
+
const content = await readFile(file, "utf-8");
|
|
3214
|
+
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3215
|
+
for (const line of lines) try {
|
|
3216
|
+
const parsed = JSON.parse(line);
|
|
3217
|
+
const result = safeParse(UsageDataSchema, parsed);
|
|
3218
|
+
if (!result.success) continue;
|
|
3219
|
+
const data = result.output;
|
|
3220
|
+
const date = formatDate(data.timestamp);
|
|
3221
|
+
const existing = dailyMap.get(date) || {
|
|
3222
|
+
date,
|
|
3223
|
+
inputTokens: 0,
|
|
3224
|
+
outputTokens: 0,
|
|
3225
|
+
cacheCreationTokens: 0,
|
|
3226
|
+
cacheReadTokens: 0,
|
|
3227
|
+
totalCost: 0
|
|
3228
|
+
};
|
|
3229
|
+
existing.inputTokens += data.message.usage.input_tokens || 0;
|
|
3230
|
+
existing.outputTokens += data.message.usage.output_tokens || 0;
|
|
3231
|
+
existing.cacheCreationTokens += data.message.usage.cache_creation_input_tokens || 0;
|
|
3232
|
+
existing.cacheReadTokens += data.message.usage.cache_read_input_tokens || 0;
|
|
3233
|
+
existing.totalCost += data.costUSD || 0;
|
|
3234
|
+
dailyMap.set(date, existing);
|
|
3235
|
+
} catch (e) {}
|
|
3236
|
+
}
|
|
3237
|
+
let results = Array.from(dailyMap.values());
|
|
3238
|
+
if (options?.since || options?.until) results = results.filter((data) => {
|
|
3239
|
+
const dateStr = data.date.replace(/-/g, "");
|
|
3240
|
+
if (options.since && dateStr < options.since) return false;
|
|
3241
|
+
if (options.until && dateStr > options.until) return false;
|
|
3242
|
+
return true;
|
|
3243
|
+
});
|
|
3244
|
+
return sort(results).desc((item) => new Date(item.date).getTime());
|
|
3245
|
+
}
|
|
3246
|
+
async function loadSessionData(options) {
|
|
3247
|
+
const claudePath = options?.claudePath ?? getDefaultClaudePath();
|
|
3248
|
+
const claudeDir = path.join(claudePath, "projects");
|
|
3249
|
+
const files = await glob(["**/*.jsonl"], {
|
|
3250
|
+
cwd: claudeDir,
|
|
3251
|
+
absolute: true
|
|
3252
|
+
});
|
|
3253
|
+
if (files.length === 0) return [];
|
|
3254
|
+
const sessionMap = new Map();
|
|
3255
|
+
for (const file of files) {
|
|
3256
|
+
const relativePath = path.relative(claudeDir, file);
|
|
3257
|
+
const parts = relativePath.split(path.sep);
|
|
3258
|
+
const sessionId = parts[parts.length - 2];
|
|
3259
|
+
const projectPath = parts.slice(0, -2).join(path.sep);
|
|
3260
|
+
const content = await readFile(file, "utf-8");
|
|
3261
|
+
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
3262
|
+
let lastTimestamp = "";
|
|
3263
|
+
for (const line of lines) try {
|
|
3264
|
+
const parsed = JSON.parse(line);
|
|
3265
|
+
const result = safeParse(UsageDataSchema, parsed);
|
|
3266
|
+
if (!result.success) continue;
|
|
3267
|
+
const data = result.output;
|
|
3268
|
+
const key = `${projectPath}/${sessionId}`;
|
|
3269
|
+
const existing = sessionMap.get(key) || {
|
|
3270
|
+
sessionId: sessionId || "unknown",
|
|
3271
|
+
projectPath: projectPath || "Unknown Project",
|
|
3272
|
+
inputTokens: 0,
|
|
3273
|
+
outputTokens: 0,
|
|
3274
|
+
cacheCreationTokens: 0,
|
|
3275
|
+
cacheReadTokens: 0,
|
|
3276
|
+
totalCost: 0,
|
|
3277
|
+
lastActivity: ""
|
|
3278
|
+
};
|
|
3279
|
+
existing.inputTokens += data.message.usage.input_tokens || 0;
|
|
3280
|
+
existing.outputTokens += data.message.usage.output_tokens || 0;
|
|
3281
|
+
existing.cacheCreationTokens += data.message.usage.cache_creation_input_tokens || 0;
|
|
3282
|
+
existing.cacheReadTokens += data.message.usage.cache_read_input_tokens || 0;
|
|
3283
|
+
existing.totalCost += data.costUSD || 0;
|
|
3284
|
+
if (data.timestamp > lastTimestamp) {
|
|
3285
|
+
lastTimestamp = data.timestamp;
|
|
3286
|
+
existing.lastActivity = formatDate(data.timestamp);
|
|
3287
|
+
}
|
|
3288
|
+
sessionMap.set(key, existing);
|
|
3289
|
+
} catch (e) {}
|
|
3290
|
+
}
|
|
3291
|
+
let results = Array.from(sessionMap.values());
|
|
3292
|
+
if (options?.since || options?.until) results = results.filter((session) => {
|
|
3293
|
+
const dateStr = session.lastActivity.replace(/-/g, "");
|
|
3294
|
+
if (options.since && dateStr < options.since) return false;
|
|
3295
|
+
if (options.until && dateStr > options.until) return false;
|
|
3296
|
+
return true;
|
|
3297
|
+
});
|
|
3298
|
+
return sort(results).desc((item) => item.totalCost);
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
//#endregion
|
|
3302
|
+
export { DailyUsageSchema, SessionUsageSchema, UsageDataSchema, __commonJS, __require, __toESM, boolean, formatDate, getDefaultClaudePath, loadSessionData, loadUsageData, number, object, optional, pipe, record, regex, safeParse, string, union };
|