raggrep 0.8.1 → 0.8.2
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 +28 -7
- package/dist/cli/main.js +1431 -10
- package/dist/cli/main.js.map +22 -14
- package/dist/domain/entities/searchResult.d.ts +11 -2
- package/dist/index.js +1435 -7
- package/dist/index.js.map +20 -12
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -16,6 +16,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
16
16
|
});
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
20
|
var __export = (target, all) => {
|
|
20
21
|
for (var name in all)
|
|
21
22
|
__defProp(target, name, {
|
|
@@ -6102,6 +6103,1401 @@ var init_indexer = __esm(() => {
|
|
|
6102
6103
|
DEFAULT_CONCURRENCY = getOptimalConcurrency();
|
|
6103
6104
|
});
|
|
6104
6105
|
|
|
6106
|
+
// node_modules/balanced-match/index.js
|
|
6107
|
+
var require_balanced_match = __commonJS((exports, module) => {
|
|
6108
|
+
module.exports = balanced;
|
|
6109
|
+
function balanced(a, b, str) {
|
|
6110
|
+
if (a instanceof RegExp)
|
|
6111
|
+
a = maybeMatch(a, str);
|
|
6112
|
+
if (b instanceof RegExp)
|
|
6113
|
+
b = maybeMatch(b, str);
|
|
6114
|
+
var r = range(a, b, str);
|
|
6115
|
+
return r && {
|
|
6116
|
+
start: r[0],
|
|
6117
|
+
end: r[1],
|
|
6118
|
+
pre: str.slice(0, r[0]),
|
|
6119
|
+
body: str.slice(r[0] + a.length, r[1]),
|
|
6120
|
+
post: str.slice(r[1] + b.length)
|
|
6121
|
+
};
|
|
6122
|
+
}
|
|
6123
|
+
function maybeMatch(reg, str) {
|
|
6124
|
+
var m = str.match(reg);
|
|
6125
|
+
return m ? m[0] : null;
|
|
6126
|
+
}
|
|
6127
|
+
balanced.range = range;
|
|
6128
|
+
function range(a, b, str) {
|
|
6129
|
+
var begs, beg, left, right, result;
|
|
6130
|
+
var ai = str.indexOf(a);
|
|
6131
|
+
var bi = str.indexOf(b, ai + 1);
|
|
6132
|
+
var i = ai;
|
|
6133
|
+
if (ai >= 0 && bi > 0) {
|
|
6134
|
+
if (a === b) {
|
|
6135
|
+
return [ai, bi];
|
|
6136
|
+
}
|
|
6137
|
+
begs = [];
|
|
6138
|
+
left = str.length;
|
|
6139
|
+
while (i >= 0 && !result) {
|
|
6140
|
+
if (i == ai) {
|
|
6141
|
+
begs.push(i);
|
|
6142
|
+
ai = str.indexOf(a, i + 1);
|
|
6143
|
+
} else if (begs.length == 1) {
|
|
6144
|
+
result = [begs.pop(), bi];
|
|
6145
|
+
} else {
|
|
6146
|
+
beg = begs.pop();
|
|
6147
|
+
if (beg < left) {
|
|
6148
|
+
left = beg;
|
|
6149
|
+
right = bi;
|
|
6150
|
+
}
|
|
6151
|
+
bi = str.indexOf(b, i + 1);
|
|
6152
|
+
}
|
|
6153
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
6154
|
+
}
|
|
6155
|
+
if (begs.length) {
|
|
6156
|
+
result = [left, right];
|
|
6157
|
+
}
|
|
6158
|
+
}
|
|
6159
|
+
return result;
|
|
6160
|
+
}
|
|
6161
|
+
});
|
|
6162
|
+
|
|
6163
|
+
// node_modules/brace-expansion/index.js
|
|
6164
|
+
var require_brace_expansion = __commonJS((exports, module) => {
|
|
6165
|
+
var balanced = require_balanced_match();
|
|
6166
|
+
module.exports = expandTop;
|
|
6167
|
+
var escSlash = "\x00SLASH" + Math.random() + "\x00";
|
|
6168
|
+
var escOpen = "\x00OPEN" + Math.random() + "\x00";
|
|
6169
|
+
var escClose = "\x00CLOSE" + Math.random() + "\x00";
|
|
6170
|
+
var escComma = "\x00COMMA" + Math.random() + "\x00";
|
|
6171
|
+
var escPeriod = "\x00PERIOD" + Math.random() + "\x00";
|
|
6172
|
+
function numeric(str) {
|
|
6173
|
+
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
6174
|
+
}
|
|
6175
|
+
function escapeBraces(str) {
|
|
6176
|
+
return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
|
|
6177
|
+
}
|
|
6178
|
+
function unescapeBraces(str) {
|
|
6179
|
+
return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
|
|
6180
|
+
}
|
|
6181
|
+
function parseCommaParts(str) {
|
|
6182
|
+
if (!str)
|
|
6183
|
+
return [""];
|
|
6184
|
+
var parts = [];
|
|
6185
|
+
var m = balanced("{", "}", str);
|
|
6186
|
+
if (!m)
|
|
6187
|
+
return str.split(",");
|
|
6188
|
+
var pre = m.pre;
|
|
6189
|
+
var body = m.body;
|
|
6190
|
+
var post = m.post;
|
|
6191
|
+
var p = pre.split(",");
|
|
6192
|
+
p[p.length - 1] += "{" + body + "}";
|
|
6193
|
+
var postParts = parseCommaParts(post);
|
|
6194
|
+
if (post.length) {
|
|
6195
|
+
p[p.length - 1] += postParts.shift();
|
|
6196
|
+
p.push.apply(p, postParts);
|
|
6197
|
+
}
|
|
6198
|
+
parts.push.apply(parts, p);
|
|
6199
|
+
return parts;
|
|
6200
|
+
}
|
|
6201
|
+
function expandTop(str) {
|
|
6202
|
+
if (!str)
|
|
6203
|
+
return [];
|
|
6204
|
+
if (str.substr(0, 2) === "{}") {
|
|
6205
|
+
str = "\\{\\}" + str.substr(2);
|
|
6206
|
+
}
|
|
6207
|
+
return expand(escapeBraces(str), true).map(unescapeBraces);
|
|
6208
|
+
}
|
|
6209
|
+
function embrace(str) {
|
|
6210
|
+
return "{" + str + "}";
|
|
6211
|
+
}
|
|
6212
|
+
function isPadded(el) {
|
|
6213
|
+
return /^-?0\d/.test(el);
|
|
6214
|
+
}
|
|
6215
|
+
function lte(i, y) {
|
|
6216
|
+
return i <= y;
|
|
6217
|
+
}
|
|
6218
|
+
function gte(i, y) {
|
|
6219
|
+
return i >= y;
|
|
6220
|
+
}
|
|
6221
|
+
function expand(str, isTop) {
|
|
6222
|
+
var expansions = [];
|
|
6223
|
+
var m = balanced("{", "}", str);
|
|
6224
|
+
if (!m)
|
|
6225
|
+
return [str];
|
|
6226
|
+
var pre = m.pre;
|
|
6227
|
+
var post = m.post.length ? expand(m.post, false) : [""];
|
|
6228
|
+
if (/\$$/.test(m.pre)) {
|
|
6229
|
+
for (var k = 0;k < post.length; k++) {
|
|
6230
|
+
var expansion = pre + "{" + m.body + "}" + post[k];
|
|
6231
|
+
expansions.push(expansion);
|
|
6232
|
+
}
|
|
6233
|
+
} else {
|
|
6234
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
6235
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
6236
|
+
var isSequence = isNumericSequence || isAlphaSequence;
|
|
6237
|
+
var isOptions = m.body.indexOf(",") >= 0;
|
|
6238
|
+
if (!isSequence && !isOptions) {
|
|
6239
|
+
if (m.post.match(/,(?!,).*\}/)) {
|
|
6240
|
+
str = m.pre + "{" + m.body + escClose + m.post;
|
|
6241
|
+
return expand(str);
|
|
6242
|
+
}
|
|
6243
|
+
return [str];
|
|
6244
|
+
}
|
|
6245
|
+
var n;
|
|
6246
|
+
if (isSequence) {
|
|
6247
|
+
n = m.body.split(/\.\./);
|
|
6248
|
+
} else {
|
|
6249
|
+
n = parseCommaParts(m.body);
|
|
6250
|
+
if (n.length === 1) {
|
|
6251
|
+
n = expand(n[0], false).map(embrace);
|
|
6252
|
+
if (n.length === 1) {
|
|
6253
|
+
return post.map(function(p) {
|
|
6254
|
+
return m.pre + n[0] + p;
|
|
6255
|
+
});
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6258
|
+
}
|
|
6259
|
+
var N;
|
|
6260
|
+
if (isSequence) {
|
|
6261
|
+
var x = numeric(n[0]);
|
|
6262
|
+
var y = numeric(n[1]);
|
|
6263
|
+
var width = Math.max(n[0].length, n[1].length);
|
|
6264
|
+
var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
|
|
6265
|
+
var test = lte;
|
|
6266
|
+
var reverse = y < x;
|
|
6267
|
+
if (reverse) {
|
|
6268
|
+
incr *= -1;
|
|
6269
|
+
test = gte;
|
|
6270
|
+
}
|
|
6271
|
+
var pad = n.some(isPadded);
|
|
6272
|
+
N = [];
|
|
6273
|
+
for (var i = x;test(i, y); i += incr) {
|
|
6274
|
+
var c;
|
|
6275
|
+
if (isAlphaSequence) {
|
|
6276
|
+
c = String.fromCharCode(i);
|
|
6277
|
+
if (c === "\\")
|
|
6278
|
+
c = "";
|
|
6279
|
+
} else {
|
|
6280
|
+
c = String(i);
|
|
6281
|
+
if (pad) {
|
|
6282
|
+
var need = width - c.length;
|
|
6283
|
+
if (need > 0) {
|
|
6284
|
+
var z = new Array(need + 1).join("0");
|
|
6285
|
+
if (i < 0)
|
|
6286
|
+
c = "-" + z + c.slice(1);
|
|
6287
|
+
else
|
|
6288
|
+
c = z + c;
|
|
6289
|
+
}
|
|
6290
|
+
}
|
|
6291
|
+
}
|
|
6292
|
+
N.push(c);
|
|
6293
|
+
}
|
|
6294
|
+
} else {
|
|
6295
|
+
N = [];
|
|
6296
|
+
for (var j = 0;j < n.length; j++) {
|
|
6297
|
+
N.push.apply(N, expand(n[j], false));
|
|
6298
|
+
}
|
|
6299
|
+
}
|
|
6300
|
+
for (var j = 0;j < N.length; j++) {
|
|
6301
|
+
for (var k = 0;k < post.length; k++) {
|
|
6302
|
+
var expansion = pre + N[j] + post[k];
|
|
6303
|
+
if (!isTop || isSequence || expansion)
|
|
6304
|
+
expansions.push(expansion);
|
|
6305
|
+
}
|
|
6306
|
+
}
|
|
6307
|
+
}
|
|
6308
|
+
return expansions;
|
|
6309
|
+
}
|
|
6310
|
+
});
|
|
6311
|
+
|
|
6312
|
+
// node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
6313
|
+
var MAX_PATTERN_LENGTH, assertValidPattern = (pattern) => {
|
|
6314
|
+
if (typeof pattern !== "string") {
|
|
6315
|
+
throw new TypeError("invalid pattern");
|
|
6316
|
+
}
|
|
6317
|
+
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
6318
|
+
throw new TypeError("pattern is too long");
|
|
6319
|
+
}
|
|
6320
|
+
};
|
|
6321
|
+
var init_assert_valid_pattern = __esm(() => {
|
|
6322
|
+
MAX_PATTERN_LENGTH = 1024 * 64;
|
|
6323
|
+
});
|
|
6324
|
+
|
|
6325
|
+
// node_modules/minimatch/dist/esm/brace-expressions.js
|
|
6326
|
+
var posixClasses, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), rangesToString = (ranges) => ranges.join(""), parseClass = (glob2, position) => {
|
|
6327
|
+
const pos = position;
|
|
6328
|
+
if (glob2.charAt(pos) !== "[") {
|
|
6329
|
+
throw new Error("not in a brace expression");
|
|
6330
|
+
}
|
|
6331
|
+
const ranges = [];
|
|
6332
|
+
const negs = [];
|
|
6333
|
+
let i = pos + 1;
|
|
6334
|
+
let sawStart = false;
|
|
6335
|
+
let uflag = false;
|
|
6336
|
+
let escaping = false;
|
|
6337
|
+
let negate = false;
|
|
6338
|
+
let endPos = pos;
|
|
6339
|
+
let rangeStart = "";
|
|
6340
|
+
WHILE:
|
|
6341
|
+
while (i < glob2.length) {
|
|
6342
|
+
const c = glob2.charAt(i);
|
|
6343
|
+
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
6344
|
+
negate = true;
|
|
6345
|
+
i++;
|
|
6346
|
+
continue;
|
|
6347
|
+
}
|
|
6348
|
+
if (c === "]" && sawStart && !escaping) {
|
|
6349
|
+
endPos = i + 1;
|
|
6350
|
+
break;
|
|
6351
|
+
}
|
|
6352
|
+
sawStart = true;
|
|
6353
|
+
if (c === "\\") {
|
|
6354
|
+
if (!escaping) {
|
|
6355
|
+
escaping = true;
|
|
6356
|
+
i++;
|
|
6357
|
+
continue;
|
|
6358
|
+
}
|
|
6359
|
+
}
|
|
6360
|
+
if (c === "[" && !escaping) {
|
|
6361
|
+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
6362
|
+
if (glob2.startsWith(cls, i)) {
|
|
6363
|
+
if (rangeStart) {
|
|
6364
|
+
return ["$.", false, glob2.length - pos, true];
|
|
6365
|
+
}
|
|
6366
|
+
i += cls.length;
|
|
6367
|
+
if (neg)
|
|
6368
|
+
negs.push(unip);
|
|
6369
|
+
else
|
|
6370
|
+
ranges.push(unip);
|
|
6371
|
+
uflag = uflag || u;
|
|
6372
|
+
continue WHILE;
|
|
6373
|
+
}
|
|
6374
|
+
}
|
|
6375
|
+
}
|
|
6376
|
+
escaping = false;
|
|
6377
|
+
if (rangeStart) {
|
|
6378
|
+
if (c > rangeStart) {
|
|
6379
|
+
ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
|
|
6380
|
+
} else if (c === rangeStart) {
|
|
6381
|
+
ranges.push(braceEscape(c));
|
|
6382
|
+
}
|
|
6383
|
+
rangeStart = "";
|
|
6384
|
+
i++;
|
|
6385
|
+
continue;
|
|
6386
|
+
}
|
|
6387
|
+
if (glob2.startsWith("-]", i + 1)) {
|
|
6388
|
+
ranges.push(braceEscape(c + "-"));
|
|
6389
|
+
i += 2;
|
|
6390
|
+
continue;
|
|
6391
|
+
}
|
|
6392
|
+
if (glob2.startsWith("-", i + 1)) {
|
|
6393
|
+
rangeStart = c;
|
|
6394
|
+
i += 2;
|
|
6395
|
+
continue;
|
|
6396
|
+
}
|
|
6397
|
+
ranges.push(braceEscape(c));
|
|
6398
|
+
i++;
|
|
6399
|
+
}
|
|
6400
|
+
if (endPos < i) {
|
|
6401
|
+
return ["", false, 0, false];
|
|
6402
|
+
}
|
|
6403
|
+
if (!ranges.length && !negs.length) {
|
|
6404
|
+
return ["$.", false, glob2.length - pos, true];
|
|
6405
|
+
}
|
|
6406
|
+
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
6407
|
+
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
6408
|
+
return [regexpEscape(r), false, endPos - pos, false];
|
|
6409
|
+
}
|
|
6410
|
+
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
|
|
6411
|
+
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
6412
|
+
const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
|
|
6413
|
+
return [comb, uflag, endPos - pos, true];
|
|
6414
|
+
};
|
|
6415
|
+
var init_brace_expressions = __esm(() => {
|
|
6416
|
+
posixClasses = {
|
|
6417
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
6418
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
6419
|
+
"[:ascii:]": ["\\x" + "00-\\x" + "7f", false],
|
|
6420
|
+
"[:blank:]": ["\\p{Zs}\\t", true],
|
|
6421
|
+
"[:cntrl:]": ["\\p{Cc}", true],
|
|
6422
|
+
"[:digit:]": ["\\p{Nd}", true],
|
|
6423
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true, true],
|
|
6424
|
+
"[:lower:]": ["\\p{Ll}", true],
|
|
6425
|
+
"[:print:]": ["\\p{C}", true],
|
|
6426
|
+
"[:punct:]": ["\\p{P}", true],
|
|
6427
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
|
|
6428
|
+
"[:upper:]": ["\\p{Lu}", true],
|
|
6429
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
|
|
6430
|
+
"[:xdigit:]": ["A-Fa-f0-9", false]
|
|
6431
|
+
};
|
|
6432
|
+
});
|
|
6433
|
+
|
|
6434
|
+
// node_modules/minimatch/dist/esm/unescape.js
|
|
6435
|
+
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
6436
|
+
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
6437
|
+
};
|
|
6438
|
+
|
|
6439
|
+
// node_modules/minimatch/dist/esm/ast.js
|
|
6440
|
+
class AST {
|
|
6441
|
+
type;
|
|
6442
|
+
#root;
|
|
6443
|
+
#hasMagic;
|
|
6444
|
+
#uflag = false;
|
|
6445
|
+
#parts = [];
|
|
6446
|
+
#parent;
|
|
6447
|
+
#parentIndex;
|
|
6448
|
+
#negs;
|
|
6449
|
+
#filledNegs = false;
|
|
6450
|
+
#options;
|
|
6451
|
+
#toString;
|
|
6452
|
+
#emptyExt = false;
|
|
6453
|
+
constructor(type, parent, options = {}) {
|
|
6454
|
+
this.type = type;
|
|
6455
|
+
if (type)
|
|
6456
|
+
this.#hasMagic = true;
|
|
6457
|
+
this.#parent = parent;
|
|
6458
|
+
this.#root = this.#parent ? this.#parent.#root : this;
|
|
6459
|
+
this.#options = this.#root === this ? options : this.#root.#options;
|
|
6460
|
+
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
6461
|
+
if (type === "!" && !this.#root.#filledNegs)
|
|
6462
|
+
this.#negs.push(this);
|
|
6463
|
+
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
6464
|
+
}
|
|
6465
|
+
get hasMagic() {
|
|
6466
|
+
if (this.#hasMagic !== undefined)
|
|
6467
|
+
return this.#hasMagic;
|
|
6468
|
+
for (const p of this.#parts) {
|
|
6469
|
+
if (typeof p === "string")
|
|
6470
|
+
continue;
|
|
6471
|
+
if (p.type || p.hasMagic)
|
|
6472
|
+
return this.#hasMagic = true;
|
|
6473
|
+
}
|
|
6474
|
+
return this.#hasMagic;
|
|
6475
|
+
}
|
|
6476
|
+
toString() {
|
|
6477
|
+
if (this.#toString !== undefined)
|
|
6478
|
+
return this.#toString;
|
|
6479
|
+
if (!this.type) {
|
|
6480
|
+
return this.#toString = this.#parts.map((p) => String(p)).join("");
|
|
6481
|
+
} else {
|
|
6482
|
+
return this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
#fillNegs() {
|
|
6486
|
+
if (this !== this.#root)
|
|
6487
|
+
throw new Error("should only call on root");
|
|
6488
|
+
if (this.#filledNegs)
|
|
6489
|
+
return this;
|
|
6490
|
+
this.toString();
|
|
6491
|
+
this.#filledNegs = true;
|
|
6492
|
+
let n;
|
|
6493
|
+
while (n = this.#negs.pop()) {
|
|
6494
|
+
if (n.type !== "!")
|
|
6495
|
+
continue;
|
|
6496
|
+
let p = n;
|
|
6497
|
+
let pp = p.#parent;
|
|
6498
|
+
while (pp) {
|
|
6499
|
+
for (let i = p.#parentIndex + 1;!pp.type && i < pp.#parts.length; i++) {
|
|
6500
|
+
for (const part of n.#parts) {
|
|
6501
|
+
if (typeof part === "string") {
|
|
6502
|
+
throw new Error("string part in extglob AST??");
|
|
6503
|
+
}
|
|
6504
|
+
part.copyIn(pp.#parts[i]);
|
|
6505
|
+
}
|
|
6506
|
+
}
|
|
6507
|
+
p = pp;
|
|
6508
|
+
pp = p.#parent;
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
return this;
|
|
6512
|
+
}
|
|
6513
|
+
push(...parts) {
|
|
6514
|
+
for (const p of parts) {
|
|
6515
|
+
if (p === "")
|
|
6516
|
+
continue;
|
|
6517
|
+
if (typeof p !== "string" && !(p instanceof AST && p.#parent === this)) {
|
|
6518
|
+
throw new Error("invalid part: " + p);
|
|
6519
|
+
}
|
|
6520
|
+
this.#parts.push(p);
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
toJSON() {
|
|
6524
|
+
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
6525
|
+
if (this.isStart() && !this.type)
|
|
6526
|
+
ret.unshift([]);
|
|
6527
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
|
|
6528
|
+
ret.push({});
|
|
6529
|
+
}
|
|
6530
|
+
return ret;
|
|
6531
|
+
}
|
|
6532
|
+
isStart() {
|
|
6533
|
+
if (this.#root === this)
|
|
6534
|
+
return true;
|
|
6535
|
+
if (!this.#parent?.isStart())
|
|
6536
|
+
return false;
|
|
6537
|
+
if (this.#parentIndex === 0)
|
|
6538
|
+
return true;
|
|
6539
|
+
const p = this.#parent;
|
|
6540
|
+
for (let i = 0;i < this.#parentIndex; i++) {
|
|
6541
|
+
const pp = p.#parts[i];
|
|
6542
|
+
if (!(pp instanceof AST && pp.type === "!")) {
|
|
6543
|
+
return false;
|
|
6544
|
+
}
|
|
6545
|
+
}
|
|
6546
|
+
return true;
|
|
6547
|
+
}
|
|
6548
|
+
isEnd() {
|
|
6549
|
+
if (this.#root === this)
|
|
6550
|
+
return true;
|
|
6551
|
+
if (this.#parent?.type === "!")
|
|
6552
|
+
return true;
|
|
6553
|
+
if (!this.#parent?.isEnd())
|
|
6554
|
+
return false;
|
|
6555
|
+
if (!this.type)
|
|
6556
|
+
return this.#parent?.isEnd();
|
|
6557
|
+
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
6558
|
+
return this.#parentIndex === pl - 1;
|
|
6559
|
+
}
|
|
6560
|
+
copyIn(part) {
|
|
6561
|
+
if (typeof part === "string")
|
|
6562
|
+
this.push(part);
|
|
6563
|
+
else
|
|
6564
|
+
this.push(part.clone(this));
|
|
6565
|
+
}
|
|
6566
|
+
clone(parent) {
|
|
6567
|
+
const c = new AST(this.type, parent);
|
|
6568
|
+
for (const p of this.#parts) {
|
|
6569
|
+
c.copyIn(p);
|
|
6570
|
+
}
|
|
6571
|
+
return c;
|
|
6572
|
+
}
|
|
6573
|
+
static #parseAST(str, ast, pos, opt) {
|
|
6574
|
+
let escaping = false;
|
|
6575
|
+
let inBrace = false;
|
|
6576
|
+
let braceStart = -1;
|
|
6577
|
+
let braceNeg = false;
|
|
6578
|
+
if (ast.type === null) {
|
|
6579
|
+
let i2 = pos;
|
|
6580
|
+
let acc2 = "";
|
|
6581
|
+
while (i2 < str.length) {
|
|
6582
|
+
const c = str.charAt(i2++);
|
|
6583
|
+
if (escaping || c === "\\") {
|
|
6584
|
+
escaping = !escaping;
|
|
6585
|
+
acc2 += c;
|
|
6586
|
+
continue;
|
|
6587
|
+
}
|
|
6588
|
+
if (inBrace) {
|
|
6589
|
+
if (i2 === braceStart + 1) {
|
|
6590
|
+
if (c === "^" || c === "!") {
|
|
6591
|
+
braceNeg = true;
|
|
6592
|
+
}
|
|
6593
|
+
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
|
6594
|
+
inBrace = false;
|
|
6595
|
+
}
|
|
6596
|
+
acc2 += c;
|
|
6597
|
+
continue;
|
|
6598
|
+
} else if (c === "[") {
|
|
6599
|
+
inBrace = true;
|
|
6600
|
+
braceStart = i2;
|
|
6601
|
+
braceNeg = false;
|
|
6602
|
+
acc2 += c;
|
|
6603
|
+
continue;
|
|
6604
|
+
}
|
|
6605
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
|
|
6606
|
+
ast.push(acc2);
|
|
6607
|
+
acc2 = "";
|
|
6608
|
+
const ext = new AST(c, ast);
|
|
6609
|
+
i2 = AST.#parseAST(str, ext, i2, opt);
|
|
6610
|
+
ast.push(ext);
|
|
6611
|
+
continue;
|
|
6612
|
+
}
|
|
6613
|
+
acc2 += c;
|
|
6614
|
+
}
|
|
6615
|
+
ast.push(acc2);
|
|
6616
|
+
return i2;
|
|
6617
|
+
}
|
|
6618
|
+
let i = pos + 1;
|
|
6619
|
+
let part = new AST(null, ast);
|
|
6620
|
+
const parts = [];
|
|
6621
|
+
let acc = "";
|
|
6622
|
+
while (i < str.length) {
|
|
6623
|
+
const c = str.charAt(i++);
|
|
6624
|
+
if (escaping || c === "\\") {
|
|
6625
|
+
escaping = !escaping;
|
|
6626
|
+
acc += c;
|
|
6627
|
+
continue;
|
|
6628
|
+
}
|
|
6629
|
+
if (inBrace) {
|
|
6630
|
+
if (i === braceStart + 1) {
|
|
6631
|
+
if (c === "^" || c === "!") {
|
|
6632
|
+
braceNeg = true;
|
|
6633
|
+
}
|
|
6634
|
+
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
|
|
6635
|
+
inBrace = false;
|
|
6636
|
+
}
|
|
6637
|
+
acc += c;
|
|
6638
|
+
continue;
|
|
6639
|
+
} else if (c === "[") {
|
|
6640
|
+
inBrace = true;
|
|
6641
|
+
braceStart = i;
|
|
6642
|
+
braceNeg = false;
|
|
6643
|
+
acc += c;
|
|
6644
|
+
continue;
|
|
6645
|
+
}
|
|
6646
|
+
if (isExtglobType(c) && str.charAt(i) === "(") {
|
|
6647
|
+
part.push(acc);
|
|
6648
|
+
acc = "";
|
|
6649
|
+
const ext = new AST(c, part);
|
|
6650
|
+
part.push(ext);
|
|
6651
|
+
i = AST.#parseAST(str, ext, i, opt);
|
|
6652
|
+
continue;
|
|
6653
|
+
}
|
|
6654
|
+
if (c === "|") {
|
|
6655
|
+
part.push(acc);
|
|
6656
|
+
acc = "";
|
|
6657
|
+
parts.push(part);
|
|
6658
|
+
part = new AST(null, ast);
|
|
6659
|
+
continue;
|
|
6660
|
+
}
|
|
6661
|
+
if (c === ")") {
|
|
6662
|
+
if (acc === "" && ast.#parts.length === 0) {
|
|
6663
|
+
ast.#emptyExt = true;
|
|
6664
|
+
}
|
|
6665
|
+
part.push(acc);
|
|
6666
|
+
acc = "";
|
|
6667
|
+
ast.push(...parts, part);
|
|
6668
|
+
return i;
|
|
6669
|
+
}
|
|
6670
|
+
acc += c;
|
|
6671
|
+
}
|
|
6672
|
+
ast.type = null;
|
|
6673
|
+
ast.#hasMagic = undefined;
|
|
6674
|
+
ast.#parts = [str.substring(pos - 1)];
|
|
6675
|
+
return i;
|
|
6676
|
+
}
|
|
6677
|
+
static fromGlob(pattern, options = {}) {
|
|
6678
|
+
const ast = new AST(null, undefined, options);
|
|
6679
|
+
AST.#parseAST(pattern, ast, 0, options);
|
|
6680
|
+
return ast;
|
|
6681
|
+
}
|
|
6682
|
+
toMMPattern() {
|
|
6683
|
+
if (this !== this.#root)
|
|
6684
|
+
return this.#root.toMMPattern();
|
|
6685
|
+
const glob2 = this.toString();
|
|
6686
|
+
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
6687
|
+
const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob2.toUpperCase() !== glob2.toLowerCase();
|
|
6688
|
+
if (!anyMagic) {
|
|
6689
|
+
return body;
|
|
6690
|
+
}
|
|
6691
|
+
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
6692
|
+
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
6693
|
+
_src: re,
|
|
6694
|
+
_glob: glob2
|
|
6695
|
+
});
|
|
6696
|
+
}
|
|
6697
|
+
get options() {
|
|
6698
|
+
return this.#options;
|
|
6699
|
+
}
|
|
6700
|
+
toRegExpSource(allowDot) {
|
|
6701
|
+
const dot = allowDot ?? !!this.#options.dot;
|
|
6702
|
+
if (this.#root === this)
|
|
6703
|
+
this.#fillNegs();
|
|
6704
|
+
if (!this.type) {
|
|
6705
|
+
const noEmpty = this.isStart() && this.isEnd();
|
|
6706
|
+
const src = this.#parts.map((p) => {
|
|
6707
|
+
const [re, _, hasMagic, uflag] = typeof p === "string" ? AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
6708
|
+
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
6709
|
+
this.#uflag = this.#uflag || uflag;
|
|
6710
|
+
return re;
|
|
6711
|
+
}).join("");
|
|
6712
|
+
let start2 = "";
|
|
6713
|
+
if (this.isStart()) {
|
|
6714
|
+
if (typeof this.#parts[0] === "string") {
|
|
6715
|
+
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
|
6716
|
+
if (!dotTravAllowed) {
|
|
6717
|
+
const aps = addPatternStart;
|
|
6718
|
+
const needNoTrav = dot && aps.has(src.charAt(0)) || src.startsWith("\\.") && aps.has(src.charAt(2)) || src.startsWith("\\.\\.") && aps.has(src.charAt(4));
|
|
6719
|
+
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
6720
|
+
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
6721
|
+
}
|
|
6722
|
+
}
|
|
6723
|
+
}
|
|
6724
|
+
let end = "";
|
|
6725
|
+
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
|
|
6726
|
+
end = "(?:$|\\/)";
|
|
6727
|
+
}
|
|
6728
|
+
const final2 = start2 + src + end;
|
|
6729
|
+
return [
|
|
6730
|
+
final2,
|
|
6731
|
+
unescape(src),
|
|
6732
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
6733
|
+
this.#uflag
|
|
6734
|
+
];
|
|
6735
|
+
}
|
|
6736
|
+
const repeated = this.type === "*" || this.type === "+";
|
|
6737
|
+
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
6738
|
+
let body = this.#partsToRegExp(dot);
|
|
6739
|
+
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
6740
|
+
const s = this.toString();
|
|
6741
|
+
this.#parts = [s];
|
|
6742
|
+
this.type = null;
|
|
6743
|
+
this.#hasMagic = undefined;
|
|
6744
|
+
return [s, unescape(this.toString()), false, false];
|
|
6745
|
+
}
|
|
6746
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
|
|
6747
|
+
if (bodyDotAllowed === body) {
|
|
6748
|
+
bodyDotAllowed = "";
|
|
6749
|
+
}
|
|
6750
|
+
if (bodyDotAllowed) {
|
|
6751
|
+
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
6752
|
+
}
|
|
6753
|
+
let final = "";
|
|
6754
|
+
if (this.type === "!" && this.#emptyExt) {
|
|
6755
|
+
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
6756
|
+
} else {
|
|
6757
|
+
const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
6758
|
+
final = start + body + close;
|
|
6759
|
+
}
|
|
6760
|
+
return [
|
|
6761
|
+
final,
|
|
6762
|
+
unescape(body),
|
|
6763
|
+
this.#hasMagic = !!this.#hasMagic,
|
|
6764
|
+
this.#uflag
|
|
6765
|
+
];
|
|
6766
|
+
}
|
|
6767
|
+
#partsToRegExp(dot) {
|
|
6768
|
+
return this.#parts.map((p) => {
|
|
6769
|
+
if (typeof p === "string") {
|
|
6770
|
+
throw new Error("string type in extglob ast??");
|
|
6771
|
+
}
|
|
6772
|
+
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
6773
|
+
this.#uflag = this.#uflag || uflag;
|
|
6774
|
+
return re;
|
|
6775
|
+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
6776
|
+
}
|
|
6777
|
+
static #parseGlob(glob2, hasMagic, noEmpty = false) {
|
|
6778
|
+
let escaping = false;
|
|
6779
|
+
let re = "";
|
|
6780
|
+
let uflag = false;
|
|
6781
|
+
for (let i = 0;i < glob2.length; i++) {
|
|
6782
|
+
const c = glob2.charAt(i);
|
|
6783
|
+
if (escaping) {
|
|
6784
|
+
escaping = false;
|
|
6785
|
+
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
6786
|
+
continue;
|
|
6787
|
+
}
|
|
6788
|
+
if (c === "\\") {
|
|
6789
|
+
if (i === glob2.length - 1) {
|
|
6790
|
+
re += "\\\\";
|
|
6791
|
+
} else {
|
|
6792
|
+
escaping = true;
|
|
6793
|
+
}
|
|
6794
|
+
continue;
|
|
6795
|
+
}
|
|
6796
|
+
if (c === "[") {
|
|
6797
|
+
const [src, needUflag, consumed, magic] = parseClass(glob2, i);
|
|
6798
|
+
if (consumed) {
|
|
6799
|
+
re += src;
|
|
6800
|
+
uflag = uflag || needUflag;
|
|
6801
|
+
i += consumed - 1;
|
|
6802
|
+
hasMagic = hasMagic || magic;
|
|
6803
|
+
continue;
|
|
6804
|
+
}
|
|
6805
|
+
}
|
|
6806
|
+
if (c === "*") {
|
|
6807
|
+
if (noEmpty && glob2 === "*")
|
|
6808
|
+
re += starNoEmpty;
|
|
6809
|
+
else
|
|
6810
|
+
re += star;
|
|
6811
|
+
hasMagic = true;
|
|
6812
|
+
continue;
|
|
6813
|
+
}
|
|
6814
|
+
if (c === "?") {
|
|
6815
|
+
re += qmark;
|
|
6816
|
+
hasMagic = true;
|
|
6817
|
+
continue;
|
|
6818
|
+
}
|
|
6819
|
+
re += regExpEscape(c);
|
|
6820
|
+
}
|
|
6821
|
+
return [re, unescape(glob2), !!hasMagic, uflag];
|
|
6822
|
+
}
|
|
6823
|
+
}
|
|
6824
|
+
var types, isExtglobType = (c) => types.has(c), startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))", startNoDot = "(?!\\.)", addPatternStart, justDots, reSpecials, regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), qmark = "[^/]", star, starNoEmpty;
|
|
6825
|
+
var init_ast = __esm(() => {
|
|
6826
|
+
init_brace_expressions();
|
|
6827
|
+
types = new Set(["!", "?", "+", "*", "@"]);
|
|
6828
|
+
addPatternStart = new Set(["[", "."]);
|
|
6829
|
+
justDots = new Set(["..", "."]);
|
|
6830
|
+
reSpecials = new Set("().*{}+?[]^$\\!");
|
|
6831
|
+
star = qmark + "*?";
|
|
6832
|
+
starNoEmpty = qmark + "+?";
|
|
6833
|
+
});
|
|
6834
|
+
|
|
6835
|
+
// node_modules/minimatch/dist/esm/escape.js
|
|
6836
|
+
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
6837
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
6838
|
+
};
|
|
6839
|
+
|
|
6840
|
+
// node_modules/minimatch/dist/esm/index.js
|
|
6841
|
+
class Minimatch {
|
|
6842
|
+
options;
|
|
6843
|
+
set;
|
|
6844
|
+
pattern;
|
|
6845
|
+
windowsPathsNoEscape;
|
|
6846
|
+
nonegate;
|
|
6847
|
+
negate;
|
|
6848
|
+
comment;
|
|
6849
|
+
empty;
|
|
6850
|
+
preserveMultipleSlashes;
|
|
6851
|
+
partial;
|
|
6852
|
+
globSet;
|
|
6853
|
+
globParts;
|
|
6854
|
+
nocase;
|
|
6855
|
+
isWindows;
|
|
6856
|
+
platform;
|
|
6857
|
+
windowsNoMagicRoot;
|
|
6858
|
+
regexp;
|
|
6859
|
+
constructor(pattern, options = {}) {
|
|
6860
|
+
assertValidPattern(pattern);
|
|
6861
|
+
options = options || {};
|
|
6862
|
+
this.options = options;
|
|
6863
|
+
this.pattern = pattern;
|
|
6864
|
+
this.platform = options.platform || defaultPlatform;
|
|
6865
|
+
this.isWindows = this.platform === "win32";
|
|
6866
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
6867
|
+
if (this.windowsPathsNoEscape) {
|
|
6868
|
+
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
6869
|
+
}
|
|
6870
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
6871
|
+
this.regexp = null;
|
|
6872
|
+
this.negate = false;
|
|
6873
|
+
this.nonegate = !!options.nonegate;
|
|
6874
|
+
this.comment = false;
|
|
6875
|
+
this.empty = false;
|
|
6876
|
+
this.partial = !!options.partial;
|
|
6877
|
+
this.nocase = !!this.options.nocase;
|
|
6878
|
+
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== undefined ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
6879
|
+
this.globSet = [];
|
|
6880
|
+
this.globParts = [];
|
|
6881
|
+
this.set = [];
|
|
6882
|
+
this.make();
|
|
6883
|
+
}
|
|
6884
|
+
hasMagic() {
|
|
6885
|
+
if (this.options.magicalBraces && this.set.length > 1) {
|
|
6886
|
+
return true;
|
|
6887
|
+
}
|
|
6888
|
+
for (const pattern of this.set) {
|
|
6889
|
+
for (const part of pattern) {
|
|
6890
|
+
if (typeof part !== "string")
|
|
6891
|
+
return true;
|
|
6892
|
+
}
|
|
6893
|
+
}
|
|
6894
|
+
return false;
|
|
6895
|
+
}
|
|
6896
|
+
debug(..._) {}
|
|
6897
|
+
make() {
|
|
6898
|
+
const pattern = this.pattern;
|
|
6899
|
+
const options = this.options;
|
|
6900
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
6901
|
+
this.comment = true;
|
|
6902
|
+
return;
|
|
6903
|
+
}
|
|
6904
|
+
if (!pattern) {
|
|
6905
|
+
this.empty = true;
|
|
6906
|
+
return;
|
|
6907
|
+
}
|
|
6908
|
+
this.parseNegate();
|
|
6909
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
6910
|
+
if (options.debug) {
|
|
6911
|
+
this.debug = (...args) => console.error(...args);
|
|
6912
|
+
}
|
|
6913
|
+
this.debug(this.pattern, this.globSet);
|
|
6914
|
+
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
6915
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
6916
|
+
this.debug(this.pattern, this.globParts);
|
|
6917
|
+
let set = this.globParts.map((s, _, __) => {
|
|
6918
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
6919
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
6920
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
6921
|
+
if (isUNC) {
|
|
6922
|
+
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
6923
|
+
} else if (isDrive) {
|
|
6924
|
+
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
6925
|
+
}
|
|
6926
|
+
}
|
|
6927
|
+
return s.map((ss) => this.parse(ss));
|
|
6928
|
+
});
|
|
6929
|
+
this.debug(this.pattern, set);
|
|
6930
|
+
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
6931
|
+
if (this.isWindows) {
|
|
6932
|
+
for (let i = 0;i < this.set.length; i++) {
|
|
6933
|
+
const p = this.set[i];
|
|
6934
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
|
|
6935
|
+
p[2] = "?";
|
|
6936
|
+
}
|
|
6937
|
+
}
|
|
6938
|
+
}
|
|
6939
|
+
this.debug(this.pattern, this.set);
|
|
6940
|
+
}
|
|
6941
|
+
preprocess(globParts) {
|
|
6942
|
+
if (this.options.noglobstar) {
|
|
6943
|
+
for (let i = 0;i < globParts.length; i++) {
|
|
6944
|
+
for (let j = 0;j < globParts[i].length; j++) {
|
|
6945
|
+
if (globParts[i][j] === "**") {
|
|
6946
|
+
globParts[i][j] = "*";
|
|
6947
|
+
}
|
|
6948
|
+
}
|
|
6949
|
+
}
|
|
6950
|
+
}
|
|
6951
|
+
const { optimizationLevel = 1 } = this.options;
|
|
6952
|
+
if (optimizationLevel >= 2) {
|
|
6953
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
6954
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
6955
|
+
} else if (optimizationLevel >= 1) {
|
|
6956
|
+
globParts = this.levelOneOptimize(globParts);
|
|
6957
|
+
} else {
|
|
6958
|
+
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
6959
|
+
}
|
|
6960
|
+
return globParts;
|
|
6961
|
+
}
|
|
6962
|
+
adjascentGlobstarOptimize(globParts) {
|
|
6963
|
+
return globParts.map((parts) => {
|
|
6964
|
+
let gs = -1;
|
|
6965
|
+
while ((gs = parts.indexOf("**", gs + 1)) !== -1) {
|
|
6966
|
+
let i = gs;
|
|
6967
|
+
while (parts[i + 1] === "**") {
|
|
6968
|
+
i++;
|
|
6969
|
+
}
|
|
6970
|
+
if (i !== gs) {
|
|
6971
|
+
parts.splice(gs, i - gs);
|
|
6972
|
+
}
|
|
6973
|
+
}
|
|
6974
|
+
return parts;
|
|
6975
|
+
});
|
|
6976
|
+
}
|
|
6977
|
+
levelOneOptimize(globParts) {
|
|
6978
|
+
return globParts.map((parts) => {
|
|
6979
|
+
parts = parts.reduce((set, part) => {
|
|
6980
|
+
const prev = set[set.length - 1];
|
|
6981
|
+
if (part === "**" && prev === "**") {
|
|
6982
|
+
return set;
|
|
6983
|
+
}
|
|
6984
|
+
if (part === "..") {
|
|
6985
|
+
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
6986
|
+
set.pop();
|
|
6987
|
+
return set;
|
|
6988
|
+
}
|
|
6989
|
+
}
|
|
6990
|
+
set.push(part);
|
|
6991
|
+
return set;
|
|
6992
|
+
}, []);
|
|
6993
|
+
return parts.length === 0 ? [""] : parts;
|
|
6994
|
+
});
|
|
6995
|
+
}
|
|
6996
|
+
levelTwoFileOptimize(parts) {
|
|
6997
|
+
if (!Array.isArray(parts)) {
|
|
6998
|
+
parts = this.slashSplit(parts);
|
|
6999
|
+
}
|
|
7000
|
+
let didSomething = false;
|
|
7001
|
+
do {
|
|
7002
|
+
didSomething = false;
|
|
7003
|
+
if (!this.preserveMultipleSlashes) {
|
|
7004
|
+
for (let i = 1;i < parts.length - 1; i++) {
|
|
7005
|
+
const p = parts[i];
|
|
7006
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
7007
|
+
continue;
|
|
7008
|
+
if (p === "." || p === "") {
|
|
7009
|
+
didSomething = true;
|
|
7010
|
+
parts.splice(i, 1);
|
|
7011
|
+
i--;
|
|
7012
|
+
}
|
|
7013
|
+
}
|
|
7014
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
7015
|
+
didSomething = true;
|
|
7016
|
+
parts.pop();
|
|
7017
|
+
}
|
|
7018
|
+
}
|
|
7019
|
+
let dd = 0;
|
|
7020
|
+
while ((dd = parts.indexOf("..", dd + 1)) !== -1) {
|
|
7021
|
+
const p = parts[dd - 1];
|
|
7022
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
7023
|
+
didSomething = true;
|
|
7024
|
+
parts.splice(dd - 1, 2);
|
|
7025
|
+
dd -= 2;
|
|
7026
|
+
}
|
|
7027
|
+
}
|
|
7028
|
+
} while (didSomething);
|
|
7029
|
+
return parts.length === 0 ? [""] : parts;
|
|
7030
|
+
}
|
|
7031
|
+
firstPhasePreProcess(globParts) {
|
|
7032
|
+
let didSomething = false;
|
|
7033
|
+
do {
|
|
7034
|
+
didSomething = false;
|
|
7035
|
+
for (let parts of globParts) {
|
|
7036
|
+
let gs = -1;
|
|
7037
|
+
while ((gs = parts.indexOf("**", gs + 1)) !== -1) {
|
|
7038
|
+
let gss = gs;
|
|
7039
|
+
while (parts[gss + 1] === "**") {
|
|
7040
|
+
gss++;
|
|
7041
|
+
}
|
|
7042
|
+
if (gss > gs) {
|
|
7043
|
+
parts.splice(gs + 1, gss - gs);
|
|
7044
|
+
}
|
|
7045
|
+
let next = parts[gs + 1];
|
|
7046
|
+
const p = parts[gs + 2];
|
|
7047
|
+
const p2 = parts[gs + 3];
|
|
7048
|
+
if (next !== "..")
|
|
7049
|
+
continue;
|
|
7050
|
+
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
|
|
7051
|
+
continue;
|
|
7052
|
+
}
|
|
7053
|
+
didSomething = true;
|
|
7054
|
+
parts.splice(gs, 1);
|
|
7055
|
+
const other = parts.slice(0);
|
|
7056
|
+
other[gs] = "**";
|
|
7057
|
+
globParts.push(other);
|
|
7058
|
+
gs--;
|
|
7059
|
+
}
|
|
7060
|
+
if (!this.preserveMultipleSlashes) {
|
|
7061
|
+
for (let i = 1;i < parts.length - 1; i++) {
|
|
7062
|
+
const p = parts[i];
|
|
7063
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
7064
|
+
continue;
|
|
7065
|
+
if (p === "." || p === "") {
|
|
7066
|
+
didSomething = true;
|
|
7067
|
+
parts.splice(i, 1);
|
|
7068
|
+
i--;
|
|
7069
|
+
}
|
|
7070
|
+
}
|
|
7071
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
7072
|
+
didSomething = true;
|
|
7073
|
+
parts.pop();
|
|
7074
|
+
}
|
|
7075
|
+
}
|
|
7076
|
+
let dd = 0;
|
|
7077
|
+
while ((dd = parts.indexOf("..", dd + 1)) !== -1) {
|
|
7078
|
+
const p = parts[dd - 1];
|
|
7079
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
7080
|
+
didSomething = true;
|
|
7081
|
+
const needDot = dd === 1 && parts[dd + 1] === "**";
|
|
7082
|
+
const splin = needDot ? ["."] : [];
|
|
7083
|
+
parts.splice(dd - 1, 2, ...splin);
|
|
7084
|
+
if (parts.length === 0)
|
|
7085
|
+
parts.push("");
|
|
7086
|
+
dd -= 2;
|
|
7087
|
+
}
|
|
7088
|
+
}
|
|
7089
|
+
}
|
|
7090
|
+
} while (didSomething);
|
|
7091
|
+
return globParts;
|
|
7092
|
+
}
|
|
7093
|
+
secondPhasePreProcess(globParts) {
|
|
7094
|
+
for (let i = 0;i < globParts.length - 1; i++) {
|
|
7095
|
+
for (let j = i + 1;j < globParts.length; j++) {
|
|
7096
|
+
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
7097
|
+
if (matched) {
|
|
7098
|
+
globParts[i] = [];
|
|
7099
|
+
globParts[j] = matched;
|
|
7100
|
+
break;
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
}
|
|
7104
|
+
return globParts.filter((gs) => gs.length);
|
|
7105
|
+
}
|
|
7106
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
7107
|
+
let ai = 0;
|
|
7108
|
+
let bi = 0;
|
|
7109
|
+
let result = [];
|
|
7110
|
+
let which = "";
|
|
7111
|
+
while (ai < a.length && bi < b.length) {
|
|
7112
|
+
if (a[ai] === b[bi]) {
|
|
7113
|
+
result.push(which === "b" ? b[bi] : a[ai]);
|
|
7114
|
+
ai++;
|
|
7115
|
+
bi++;
|
|
7116
|
+
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
7117
|
+
result.push(a[ai]);
|
|
7118
|
+
ai++;
|
|
7119
|
+
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
7120
|
+
result.push(b[bi]);
|
|
7121
|
+
bi++;
|
|
7122
|
+
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
7123
|
+
if (which === "b")
|
|
7124
|
+
return false;
|
|
7125
|
+
which = "a";
|
|
7126
|
+
result.push(a[ai]);
|
|
7127
|
+
ai++;
|
|
7128
|
+
bi++;
|
|
7129
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
7130
|
+
if (which === "a")
|
|
7131
|
+
return false;
|
|
7132
|
+
which = "b";
|
|
7133
|
+
result.push(b[bi]);
|
|
7134
|
+
ai++;
|
|
7135
|
+
bi++;
|
|
7136
|
+
} else {
|
|
7137
|
+
return false;
|
|
7138
|
+
}
|
|
7139
|
+
}
|
|
7140
|
+
return a.length === b.length && result;
|
|
7141
|
+
}
|
|
7142
|
+
parseNegate() {
|
|
7143
|
+
if (this.nonegate)
|
|
7144
|
+
return;
|
|
7145
|
+
const pattern = this.pattern;
|
|
7146
|
+
let negate = false;
|
|
7147
|
+
let negateOffset = 0;
|
|
7148
|
+
for (let i = 0;i < pattern.length && pattern.charAt(i) === "!"; i++) {
|
|
7149
|
+
negate = !negate;
|
|
7150
|
+
negateOffset++;
|
|
7151
|
+
}
|
|
7152
|
+
if (negateOffset)
|
|
7153
|
+
this.pattern = pattern.slice(negateOffset);
|
|
7154
|
+
this.negate = negate;
|
|
7155
|
+
}
|
|
7156
|
+
matchOne(file, pattern, partial = false) {
|
|
7157
|
+
const options = this.options;
|
|
7158
|
+
if (this.isWindows) {
|
|
7159
|
+
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
7160
|
+
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
7161
|
+
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
7162
|
+
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
7163
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : undefined;
|
|
7164
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : undefined;
|
|
7165
|
+
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
7166
|
+
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
7167
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
7168
|
+
pattern[pdi] = fd;
|
|
7169
|
+
if (pdi > fdi) {
|
|
7170
|
+
pattern = pattern.slice(pdi);
|
|
7171
|
+
} else if (fdi > pdi) {
|
|
7172
|
+
file = file.slice(fdi);
|
|
7173
|
+
}
|
|
7174
|
+
}
|
|
7175
|
+
}
|
|
7176
|
+
}
|
|
7177
|
+
const { optimizationLevel = 1 } = this.options;
|
|
7178
|
+
if (optimizationLevel >= 2) {
|
|
7179
|
+
file = this.levelTwoFileOptimize(file);
|
|
7180
|
+
}
|
|
7181
|
+
this.debug("matchOne", this, { file, pattern });
|
|
7182
|
+
this.debug("matchOne", file.length, pattern.length);
|
|
7183
|
+
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length;fi < fl && pi < pl; fi++, pi++) {
|
|
7184
|
+
this.debug("matchOne loop");
|
|
7185
|
+
var p = pattern[pi];
|
|
7186
|
+
var f = file[fi];
|
|
7187
|
+
this.debug(pattern, p, f);
|
|
7188
|
+
if (p === false) {
|
|
7189
|
+
return false;
|
|
7190
|
+
}
|
|
7191
|
+
if (p === GLOBSTAR) {
|
|
7192
|
+
this.debug("GLOBSTAR", [pattern, p, f]);
|
|
7193
|
+
var fr = fi;
|
|
7194
|
+
var pr = pi + 1;
|
|
7195
|
+
if (pr === pl) {
|
|
7196
|
+
this.debug("** at the end");
|
|
7197
|
+
for (;fi < fl; fi++) {
|
|
7198
|
+
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
7199
|
+
return false;
|
|
7200
|
+
}
|
|
7201
|
+
return true;
|
|
7202
|
+
}
|
|
7203
|
+
while (fr < fl) {
|
|
7204
|
+
var swallowee = file[fr];
|
|
7205
|
+
this.debug(`
|
|
7206
|
+
globstar while`, file, fr, pattern, pr, swallowee);
|
|
7207
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
7208
|
+
this.debug("globstar found match!", fr, fl, swallowee);
|
|
7209
|
+
return true;
|
|
7210
|
+
} else {
|
|
7211
|
+
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
7212
|
+
this.debug("dot detected!", file, fr, pattern, pr);
|
|
7213
|
+
break;
|
|
7214
|
+
}
|
|
7215
|
+
this.debug("globstar swallow a segment, and continue");
|
|
7216
|
+
fr++;
|
|
7217
|
+
}
|
|
7218
|
+
}
|
|
7219
|
+
if (partial) {
|
|
7220
|
+
this.debug(`
|
|
7221
|
+
>>> no match, partial?`, file, fr, pattern, pr);
|
|
7222
|
+
if (fr === fl) {
|
|
7223
|
+
return true;
|
|
7224
|
+
}
|
|
7225
|
+
}
|
|
7226
|
+
return false;
|
|
7227
|
+
}
|
|
7228
|
+
let hit;
|
|
7229
|
+
if (typeof p === "string") {
|
|
7230
|
+
hit = f === p;
|
|
7231
|
+
this.debug("string match", p, f, hit);
|
|
7232
|
+
} else {
|
|
7233
|
+
hit = p.test(f);
|
|
7234
|
+
this.debug("pattern match", p, f, hit);
|
|
7235
|
+
}
|
|
7236
|
+
if (!hit)
|
|
7237
|
+
return false;
|
|
7238
|
+
}
|
|
7239
|
+
if (fi === fl && pi === pl) {
|
|
7240
|
+
return true;
|
|
7241
|
+
} else if (fi === fl) {
|
|
7242
|
+
return partial;
|
|
7243
|
+
} else if (pi === pl) {
|
|
7244
|
+
return fi === fl - 1 && file[fi] === "";
|
|
7245
|
+
} else {
|
|
7246
|
+
throw new Error("wtf?");
|
|
7247
|
+
}
|
|
7248
|
+
}
|
|
7249
|
+
braceExpand() {
|
|
7250
|
+
return braceExpand(this.pattern, this.options);
|
|
7251
|
+
}
|
|
7252
|
+
parse(pattern) {
|
|
7253
|
+
assertValidPattern(pattern);
|
|
7254
|
+
const options = this.options;
|
|
7255
|
+
if (pattern === "**")
|
|
7256
|
+
return GLOBSTAR;
|
|
7257
|
+
if (pattern === "")
|
|
7258
|
+
return "";
|
|
7259
|
+
let m;
|
|
7260
|
+
let fastTest = null;
|
|
7261
|
+
if (m = pattern.match(starRE)) {
|
|
7262
|
+
fastTest = options.dot ? starTestDot : starTest;
|
|
7263
|
+
} else if (m = pattern.match(starDotExtRE)) {
|
|
7264
|
+
fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
7265
|
+
} else if (m = pattern.match(qmarksRE)) {
|
|
7266
|
+
fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
7267
|
+
} else if (m = pattern.match(starDotStarRE)) {
|
|
7268
|
+
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
7269
|
+
} else if (m = pattern.match(dotStarRE)) {
|
|
7270
|
+
fastTest = dotStarTest;
|
|
7271
|
+
}
|
|
7272
|
+
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
7273
|
+
if (fastTest && typeof re === "object") {
|
|
7274
|
+
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
7275
|
+
}
|
|
7276
|
+
return re;
|
|
7277
|
+
}
|
|
7278
|
+
makeRe() {
|
|
7279
|
+
if (this.regexp || this.regexp === false)
|
|
7280
|
+
return this.regexp;
|
|
7281
|
+
const set = this.set;
|
|
7282
|
+
if (!set.length) {
|
|
7283
|
+
this.regexp = false;
|
|
7284
|
+
return this.regexp;
|
|
7285
|
+
}
|
|
7286
|
+
const options = this.options;
|
|
7287
|
+
const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
|
|
7288
|
+
const flags = new Set(options.nocase ? ["i"] : []);
|
|
7289
|
+
let re = set.map((pattern) => {
|
|
7290
|
+
const pp = pattern.map((p) => {
|
|
7291
|
+
if (p instanceof RegExp) {
|
|
7292
|
+
for (const f of p.flags.split(""))
|
|
7293
|
+
flags.add(f);
|
|
7294
|
+
}
|
|
7295
|
+
return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
7296
|
+
});
|
|
7297
|
+
pp.forEach((p, i) => {
|
|
7298
|
+
const next = pp[i + 1];
|
|
7299
|
+
const prev = pp[i - 1];
|
|
7300
|
+
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
7301
|
+
return;
|
|
7302
|
+
}
|
|
7303
|
+
if (prev === undefined) {
|
|
7304
|
+
if (next !== undefined && next !== GLOBSTAR) {
|
|
7305
|
+
pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
7306
|
+
} else {
|
|
7307
|
+
pp[i] = twoStar;
|
|
7308
|
+
}
|
|
7309
|
+
} else if (next === undefined) {
|
|
7310
|
+
pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
|
|
7311
|
+
} else if (next !== GLOBSTAR) {
|
|
7312
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
7313
|
+
pp[i + 1] = GLOBSTAR;
|
|
7314
|
+
}
|
|
7315
|
+
});
|
|
7316
|
+
return pp.filter((p) => p !== GLOBSTAR).join("/");
|
|
7317
|
+
}).join("|");
|
|
7318
|
+
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
7319
|
+
re = "^" + open + re + close + "$";
|
|
7320
|
+
if (this.negate)
|
|
7321
|
+
re = "^(?!" + re + ").+$";
|
|
7322
|
+
try {
|
|
7323
|
+
this.regexp = new RegExp(re, [...flags].join(""));
|
|
7324
|
+
} catch (ex) {
|
|
7325
|
+
this.regexp = false;
|
|
7326
|
+
}
|
|
7327
|
+
return this.regexp;
|
|
7328
|
+
}
|
|
7329
|
+
slashSplit(p) {
|
|
7330
|
+
if (this.preserveMultipleSlashes) {
|
|
7331
|
+
return p.split("/");
|
|
7332
|
+
} else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
|
|
7333
|
+
return ["", ...p.split(/\/+/)];
|
|
7334
|
+
} else {
|
|
7335
|
+
return p.split(/\/+/);
|
|
7336
|
+
}
|
|
7337
|
+
}
|
|
7338
|
+
match(f, partial = this.partial) {
|
|
7339
|
+
this.debug("match", f, this.pattern);
|
|
7340
|
+
if (this.comment) {
|
|
7341
|
+
return false;
|
|
7342
|
+
}
|
|
7343
|
+
if (this.empty) {
|
|
7344
|
+
return f === "";
|
|
7345
|
+
}
|
|
7346
|
+
if (f === "/" && partial) {
|
|
7347
|
+
return true;
|
|
7348
|
+
}
|
|
7349
|
+
const options = this.options;
|
|
7350
|
+
if (this.isWindows) {
|
|
7351
|
+
f = f.split("\\").join("/");
|
|
7352
|
+
}
|
|
7353
|
+
const ff = this.slashSplit(f);
|
|
7354
|
+
this.debug(this.pattern, "split", ff);
|
|
7355
|
+
const set = this.set;
|
|
7356
|
+
this.debug(this.pattern, "set", set);
|
|
7357
|
+
let filename = ff[ff.length - 1];
|
|
7358
|
+
if (!filename) {
|
|
7359
|
+
for (let i = ff.length - 2;!filename && i >= 0; i--) {
|
|
7360
|
+
filename = ff[i];
|
|
7361
|
+
}
|
|
7362
|
+
}
|
|
7363
|
+
for (let i = 0;i < set.length; i++) {
|
|
7364
|
+
const pattern = set[i];
|
|
7365
|
+
let file = ff;
|
|
7366
|
+
if (options.matchBase && pattern.length === 1) {
|
|
7367
|
+
file = [filename];
|
|
7368
|
+
}
|
|
7369
|
+
const hit = this.matchOne(file, pattern, partial);
|
|
7370
|
+
if (hit) {
|
|
7371
|
+
if (options.flipNegate) {
|
|
7372
|
+
return true;
|
|
7373
|
+
}
|
|
7374
|
+
return !this.negate;
|
|
7375
|
+
}
|
|
7376
|
+
}
|
|
7377
|
+
if (options.flipNegate) {
|
|
7378
|
+
return false;
|
|
7379
|
+
}
|
|
7380
|
+
return this.negate;
|
|
7381
|
+
}
|
|
7382
|
+
static defaults(def) {
|
|
7383
|
+
return minimatch.defaults(def).Minimatch;
|
|
7384
|
+
}
|
|
7385
|
+
}
|
|
7386
|
+
var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
7387
|
+
assertValidPattern(pattern);
|
|
7388
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
7389
|
+
return false;
|
|
7390
|
+
}
|
|
7391
|
+
return new Minimatch(pattern, options).match(p);
|
|
7392
|
+
}, starDotExtRE, starDotExtTest = (ext) => (f) => !f.startsWith(".") && f.endsWith(ext), starDotExtTestDot = (ext) => (f) => f.endsWith(ext), starDotExtTestNocase = (ext) => {
|
|
7393
|
+
ext = ext.toLowerCase();
|
|
7394
|
+
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext);
|
|
7395
|
+
}, starDotExtTestNocaseDot = (ext) => {
|
|
7396
|
+
ext = ext.toLowerCase();
|
|
7397
|
+
return (f) => f.toLowerCase().endsWith(ext);
|
|
7398
|
+
}, starDotStarRE, starDotStarTest = (f) => !f.startsWith(".") && f.includes("."), starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes("."), dotStarRE, dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith("."), starRE, starTest = (f) => f.length !== 0 && !f.startsWith("."), starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..", qmarksRE, qmarksTestNocase = ([$0, ext = ""]) => {
|
|
7399
|
+
const noext = qmarksTestNoExt([$0]);
|
|
7400
|
+
if (!ext)
|
|
7401
|
+
return noext;
|
|
7402
|
+
ext = ext.toLowerCase();
|
|
7403
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
7404
|
+
}, qmarksTestNocaseDot = ([$0, ext = ""]) => {
|
|
7405
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
7406
|
+
if (!ext)
|
|
7407
|
+
return noext;
|
|
7408
|
+
ext = ext.toLowerCase();
|
|
7409
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
7410
|
+
}, qmarksTestDot = ([$0, ext = ""]) => {
|
|
7411
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
7412
|
+
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
7413
|
+
}, qmarksTest = ([$0, ext = ""]) => {
|
|
7414
|
+
const noext = qmarksTestNoExt([$0]);
|
|
7415
|
+
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
7416
|
+
}, qmarksTestNoExt = ([$0]) => {
|
|
7417
|
+
const len = $0.length;
|
|
7418
|
+
return (f) => f.length === len && !f.startsWith(".");
|
|
7419
|
+
}, qmarksTestNoExtDot = ([$0]) => {
|
|
7420
|
+
const len = $0.length;
|
|
7421
|
+
return (f) => f.length === len && f !== "." && f !== "..";
|
|
7422
|
+
}, defaultPlatform, path17, sep, GLOBSTAR, qmark2 = "[^/]", star2, twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options), ext = (a, b = {}) => Object.assign({}, a, b), defaults = (def) => {
|
|
7423
|
+
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
7424
|
+
return minimatch;
|
|
7425
|
+
}
|
|
7426
|
+
const orig = minimatch;
|
|
7427
|
+
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
7428
|
+
return Object.assign(m, {
|
|
7429
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
7430
|
+
constructor(pattern, options = {}) {
|
|
7431
|
+
super(pattern, ext(def, options));
|
|
7432
|
+
}
|
|
7433
|
+
static defaults(options) {
|
|
7434
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
7435
|
+
}
|
|
7436
|
+
},
|
|
7437
|
+
AST: class AST2 extends orig.AST {
|
|
7438
|
+
constructor(type, parent, options = {}) {
|
|
7439
|
+
super(type, parent, ext(def, options));
|
|
7440
|
+
}
|
|
7441
|
+
static fromGlob(pattern, options = {}) {
|
|
7442
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
7443
|
+
}
|
|
7444
|
+
},
|
|
7445
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
7446
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
7447
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
7448
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
7449
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
7450
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
7451
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
7452
|
+
sep: orig.sep,
|
|
7453
|
+
GLOBSTAR
|
|
7454
|
+
});
|
|
7455
|
+
}, braceExpand = (pattern, options = {}) => {
|
|
7456
|
+
assertValidPattern(pattern);
|
|
7457
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
7458
|
+
return [pattern];
|
|
7459
|
+
}
|
|
7460
|
+
return import_brace_expansion.default(pattern);
|
|
7461
|
+
}, makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe(), match = (list, pattern, options = {}) => {
|
|
7462
|
+
const mm = new Minimatch(pattern, options);
|
|
7463
|
+
list = list.filter((f) => mm.match(f));
|
|
7464
|
+
if (mm.options.nonull && !list.length) {
|
|
7465
|
+
list.push(pattern);
|
|
7466
|
+
}
|
|
7467
|
+
return list;
|
|
7468
|
+
}, globMagic, regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
7469
|
+
var init_esm = __esm(() => {
|
|
7470
|
+
init_assert_valid_pattern();
|
|
7471
|
+
init_ast();
|
|
7472
|
+
init_ast();
|
|
7473
|
+
import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
7474
|
+
starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
7475
|
+
starDotStarRE = /^\*+\.\*+$/;
|
|
7476
|
+
dotStarRE = /^\.\*+$/;
|
|
7477
|
+
starRE = /^\*+$/;
|
|
7478
|
+
qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
7479
|
+
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
7480
|
+
path17 = {
|
|
7481
|
+
win32: { sep: "\\" },
|
|
7482
|
+
posix: { sep: "/" }
|
|
7483
|
+
};
|
|
7484
|
+
sep = defaultPlatform === "win32" ? path17.win32.sep : path17.posix.sep;
|
|
7485
|
+
minimatch.sep = sep;
|
|
7486
|
+
GLOBSTAR = Symbol("globstar **");
|
|
7487
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
7488
|
+
star2 = qmark2 + "*?";
|
|
7489
|
+
minimatch.filter = filter;
|
|
7490
|
+
minimatch.defaults = defaults;
|
|
7491
|
+
minimatch.braceExpand = braceExpand;
|
|
7492
|
+
minimatch.makeRe = makeRe;
|
|
7493
|
+
minimatch.match = match;
|
|
7494
|
+
globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
7495
|
+
minimatch.AST = AST;
|
|
7496
|
+
minimatch.Minimatch = Minimatch;
|
|
7497
|
+
minimatch.escape = escape;
|
|
7498
|
+
minimatch.unescape = unescape;
|
|
7499
|
+
});
|
|
7500
|
+
|
|
6105
7501
|
// src/types.ts
|
|
6106
7502
|
var init_types = __esm(() => {
|
|
6107
7503
|
init_entities();
|
|
@@ -6114,9 +7510,9 @@ __export(exports_search, {
|
|
|
6114
7510
|
formatSearchResults: () => formatSearchResults
|
|
6115
7511
|
});
|
|
6116
7512
|
import * as fs8 from "fs/promises";
|
|
6117
|
-
import * as
|
|
7513
|
+
import * as path18 from "path";
|
|
6118
7514
|
async function search(rootDir, query, options = {}) {
|
|
6119
|
-
rootDir =
|
|
7515
|
+
rootDir = path18.resolve(rootDir);
|
|
6120
7516
|
const ensureFresh = options.ensureFresh ?? DEFAULT_SEARCH_OPTIONS.ensureFresh;
|
|
6121
7517
|
if (ensureFresh) {
|
|
6122
7518
|
await ensureIndexFresh(rootDir, { quiet: true });
|
|
@@ -6155,7 +7551,15 @@ async function search(rootDir, query, options = {}) {
|
|
|
6155
7551
|
const normalizedFilters = options.pathFilter.map((p) => p.replace(/\\/g, "/").replace(/^\//, "").replace(/\/$/, ""));
|
|
6156
7552
|
filteredResults = allResults.filter((result) => {
|
|
6157
7553
|
const normalizedPath = result.filepath.replace(/\\/g, "/");
|
|
6158
|
-
return normalizedFilters.some((
|
|
7554
|
+
return normalizedFilters.some((filter2) => {
|
|
7555
|
+
const isGlobPattern = /[*?[\]{}!]/.test(filter2);
|
|
7556
|
+
if (isGlobPattern) {
|
|
7557
|
+
const pattern = filter2.startsWith("**/") ? filter2 : `**/${filter2}`;
|
|
7558
|
+
return minimatch(normalizedPath, pattern, { matchBase: true });
|
|
7559
|
+
} else {
|
|
7560
|
+
return normalizedPath.startsWith(filter2 + "/") || normalizedPath === filter2 || normalizedPath.startsWith("./" + filter2 + "/") || normalizedPath === "./" + filter2;
|
|
7561
|
+
}
|
|
7562
|
+
});
|
|
6159
7563
|
});
|
|
6160
7564
|
}
|
|
6161
7565
|
filteredResults.sort((a, b) => b.score - a.score);
|
|
@@ -6169,7 +7573,7 @@ function createSearchContext(rootDir, moduleId, config) {
|
|
|
6169
7573
|
config,
|
|
6170
7574
|
loadFileIndex: async (filepath) => {
|
|
6171
7575
|
const hasExtension = /\.[^./]+$/.test(filepath);
|
|
6172
|
-
const indexFilePath = hasExtension ?
|
|
7576
|
+
const indexFilePath = hasExtension ? path18.join(indexPath, filepath.replace(/\.[^.]+$/, ".json")) : path18.join(indexPath, filepath + ".json");
|
|
6173
7577
|
try {
|
|
6174
7578
|
const content = await fs8.readFile(indexFilePath, "utf-8");
|
|
6175
7579
|
return JSON.parse(content);
|
|
@@ -6181,7 +7585,7 @@ function createSearchContext(rootDir, moduleId, config) {
|
|
|
6181
7585
|
const files = [];
|
|
6182
7586
|
await traverseDirectory(indexPath, files, indexPath);
|
|
6183
7587
|
return files.filter((f) => f.endsWith(".json") && !f.endsWith("manifest.json")).map((f) => {
|
|
6184
|
-
const relative4 =
|
|
7588
|
+
const relative4 = path18.relative(indexPath, f);
|
|
6185
7589
|
return relative4.replace(/\.json$/, "");
|
|
6186
7590
|
});
|
|
6187
7591
|
}
|
|
@@ -6191,7 +7595,7 @@ async function traverseDirectory(dir, files, basePath) {
|
|
|
6191
7595
|
try {
|
|
6192
7596
|
const entries = await fs8.readdir(dir, { withFileTypes: true });
|
|
6193
7597
|
for (const entry of entries) {
|
|
6194
|
-
const fullPath =
|
|
7598
|
+
const fullPath = path18.join(dir, entry.name);
|
|
6195
7599
|
if (entry.isDirectory()) {
|
|
6196
7600
|
await traverseDirectory(fullPath, files, basePath);
|
|
6197
7601
|
} else if (entry.isFile()) {
|
|
@@ -6257,6 +7661,7 @@ function formatSearchResults(results) {
|
|
|
6257
7661
|
return output;
|
|
6258
7662
|
}
|
|
6259
7663
|
var init_search = __esm(() => {
|
|
7664
|
+
init_esm();
|
|
6260
7665
|
init_types();
|
|
6261
7666
|
init_config2();
|
|
6262
7667
|
init_registry();
|
|
@@ -6269,7 +7674,7 @@ init_logger();
|
|
|
6269
7674
|
// package.json
|
|
6270
7675
|
var package_default = {
|
|
6271
7676
|
name: "raggrep",
|
|
6272
|
-
version: "0.8.
|
|
7677
|
+
version: "0.8.2",
|
|
6273
7678
|
description: "Local filesystem-based RAG system for codebases - semantic search using local embeddings",
|
|
6274
7679
|
type: "module",
|
|
6275
7680
|
main: "./dist/index.js",
|
|
@@ -6421,7 +7826,7 @@ function parseFlags(args2) {
|
|
|
6421
7826
|
}
|
|
6422
7827
|
flags.pathFilter.push(filterPath);
|
|
6423
7828
|
} else {
|
|
6424
|
-
console.error(
|
|
7829
|
+
console.error('--filter requires a path or glob pattern (e.g., src/auth, "*.ts")');
|
|
6425
7830
|
process.exit(1);
|
|
6426
7831
|
}
|
|
6427
7832
|
} else if (!arg.startsWith("-")) {
|
|
@@ -6532,7 +7937,7 @@ Options:
|
|
|
6532
7937
|
-k, --top <n> Number of results to return (default: 10)
|
|
6533
7938
|
-s, --min-score <n> Minimum similarity score 0-1 (default: 0.15)
|
|
6534
7939
|
-t, --type <ext> Filter by file extension (e.g., ts, tsx, js)
|
|
6535
|
-
-f, --filter <path> Filter by path
|
|
7940
|
+
-f, --filter <path> Filter by path or glob pattern (can be used multiple times)
|
|
6536
7941
|
-h, --help Show this help message
|
|
6537
7942
|
|
|
6538
7943
|
Note:
|
|
@@ -6542,6 +7947,12 @@ Note:
|
|
|
6542
7947
|
- Deleted files are cleaned up automatically
|
|
6543
7948
|
- Unchanged files use the cached index (instant)
|
|
6544
7949
|
|
|
7950
|
+
Filter Patterns:
|
|
7951
|
+
Path prefix: --filter src/auth (matches src/auth/*)
|
|
7952
|
+
Glob pattern: --filter "*.ts" (matches all .ts files)
|
|
7953
|
+
Glob pattern: --filter "*.md" (matches all .md files)
|
|
7954
|
+
Glob pattern: --filter "src/**/*.test.ts" (matches test files in src/)
|
|
7955
|
+
|
|
6545
7956
|
Examples:
|
|
6546
7957
|
raggrep query "user authentication"
|
|
6547
7958
|
raggrep query "handle errors" --top 5
|
|
@@ -6549,6 +7960,16 @@ Examples:
|
|
|
6549
7960
|
raggrep query "interface" --type ts
|
|
6550
7961
|
raggrep query "login" --filter src/auth
|
|
6551
7962
|
raggrep query "api" --filter src/api --filter src/routes
|
|
7963
|
+
|
|
7964
|
+
# Search only source code files
|
|
7965
|
+
raggrep query "service controller" --filter "*.ts"
|
|
7966
|
+
raggrep query "component state" --filter "*.tsx"
|
|
7967
|
+
|
|
7968
|
+
# Search only documentation
|
|
7969
|
+
raggrep query "deployment workflow" --filter "*.md"
|
|
7970
|
+
|
|
7971
|
+
# Search specific patterns
|
|
7972
|
+
raggrep query "test helpers" --filter "*.test.ts"
|
|
6552
7973
|
`);
|
|
6553
7974
|
process.exit(0);
|
|
6554
7975
|
}
|
|
@@ -6730,4 +8151,4 @@ Run 'raggrep <command> --help' for more information.
|
|
|
6730
8151
|
}
|
|
6731
8152
|
main();
|
|
6732
8153
|
|
|
6733
|
-
//# debugId=
|
|
8154
|
+
//# debugId=A1D76ED5E6F86EB564756E2164756E21
|