@dotenvx/primitives 1.2.0 → 1.3.1
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/dist/index.cjs +1801 -10
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -6300,6 +6300,1756 @@ var require_keyring = __commonJS({
|
|
|
6300
6300
|
}
|
|
6301
6301
|
});
|
|
6302
6302
|
|
|
6303
|
+
// node_modules/picomatch/lib/constants.js
|
|
6304
|
+
var require_constants = __commonJS({
|
|
6305
|
+
"node_modules/picomatch/lib/constants.js"(exports2, module2) {
|
|
6306
|
+
"use strict";
|
|
6307
|
+
var WIN_SLASH = "\\\\/";
|
|
6308
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
6309
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
6310
|
+
var DOT_LITERAL = "\\.";
|
|
6311
|
+
var PLUS_LITERAL = "\\+";
|
|
6312
|
+
var QMARK_LITERAL = "\\?";
|
|
6313
|
+
var SLASH_LITERAL = "\\/";
|
|
6314
|
+
var ONE_CHAR = "(?=.)";
|
|
6315
|
+
var QMARK = "[^/]";
|
|
6316
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
6317
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
6318
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
6319
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
6320
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
6321
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
6322
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
6323
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
6324
|
+
var STAR = `${QMARK}*?`;
|
|
6325
|
+
var SEP = "/";
|
|
6326
|
+
var POSIX_CHARS = {
|
|
6327
|
+
DOT_LITERAL,
|
|
6328
|
+
PLUS_LITERAL,
|
|
6329
|
+
QMARK_LITERAL,
|
|
6330
|
+
SLASH_LITERAL,
|
|
6331
|
+
ONE_CHAR,
|
|
6332
|
+
QMARK,
|
|
6333
|
+
END_ANCHOR,
|
|
6334
|
+
DOTS_SLASH,
|
|
6335
|
+
NO_DOT,
|
|
6336
|
+
NO_DOTS,
|
|
6337
|
+
NO_DOT_SLASH,
|
|
6338
|
+
NO_DOTS_SLASH,
|
|
6339
|
+
QMARK_NO_DOT,
|
|
6340
|
+
STAR,
|
|
6341
|
+
START_ANCHOR,
|
|
6342
|
+
SEP
|
|
6343
|
+
};
|
|
6344
|
+
var WINDOWS_CHARS = {
|
|
6345
|
+
...POSIX_CHARS,
|
|
6346
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
6347
|
+
QMARK: WIN_NO_SLASH,
|
|
6348
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
6349
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
6350
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
6351
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
6352
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
6353
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
6354
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
6355
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
6356
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
6357
|
+
SEP: "\\"
|
|
6358
|
+
};
|
|
6359
|
+
var POSIX_REGEX_SOURCE = {
|
|
6360
|
+
__proto__: null,
|
|
6361
|
+
alnum: "a-zA-Z0-9",
|
|
6362
|
+
alpha: "a-zA-Z",
|
|
6363
|
+
ascii: "\\x00-\\x7F",
|
|
6364
|
+
blank: " \\t",
|
|
6365
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
6366
|
+
digit: "0-9",
|
|
6367
|
+
graph: "\\x21-\\x7E",
|
|
6368
|
+
lower: "a-z",
|
|
6369
|
+
print: "\\x20-\\x7E ",
|
|
6370
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
6371
|
+
space: " \\t\\r\\n\\v\\f",
|
|
6372
|
+
upper: "A-Z",
|
|
6373
|
+
word: "A-Za-z0-9_",
|
|
6374
|
+
xdigit: "A-Fa-f0-9"
|
|
6375
|
+
};
|
|
6376
|
+
module2.exports = {
|
|
6377
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
6378
|
+
MAX_LENGTH: 1024 * 64,
|
|
6379
|
+
POSIX_REGEX_SOURCE,
|
|
6380
|
+
// regular expressions
|
|
6381
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
6382
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
6383
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
6384
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
6385
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
6386
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
6387
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
6388
|
+
REPLACEMENTS: {
|
|
6389
|
+
__proto__: null,
|
|
6390
|
+
"***": "*",
|
|
6391
|
+
"**/**": "**",
|
|
6392
|
+
"**/**/**": "**"
|
|
6393
|
+
},
|
|
6394
|
+
// Digits
|
|
6395
|
+
CHAR_0: 48,
|
|
6396
|
+
/* 0 */
|
|
6397
|
+
CHAR_9: 57,
|
|
6398
|
+
/* 9 */
|
|
6399
|
+
// Alphabet chars.
|
|
6400
|
+
CHAR_UPPERCASE_A: 65,
|
|
6401
|
+
/* A */
|
|
6402
|
+
CHAR_LOWERCASE_A: 97,
|
|
6403
|
+
/* a */
|
|
6404
|
+
CHAR_UPPERCASE_Z: 90,
|
|
6405
|
+
/* Z */
|
|
6406
|
+
CHAR_LOWERCASE_Z: 122,
|
|
6407
|
+
/* z */
|
|
6408
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
6409
|
+
/* ( */
|
|
6410
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
6411
|
+
/* ) */
|
|
6412
|
+
CHAR_ASTERISK: 42,
|
|
6413
|
+
/* * */
|
|
6414
|
+
// Non-alphabetic chars.
|
|
6415
|
+
CHAR_AMPERSAND: 38,
|
|
6416
|
+
/* & */
|
|
6417
|
+
CHAR_AT: 64,
|
|
6418
|
+
/* @ */
|
|
6419
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
6420
|
+
/* \ */
|
|
6421
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
6422
|
+
/* \r */
|
|
6423
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
6424
|
+
/* ^ */
|
|
6425
|
+
CHAR_COLON: 58,
|
|
6426
|
+
/* : */
|
|
6427
|
+
CHAR_COMMA: 44,
|
|
6428
|
+
/* , */
|
|
6429
|
+
CHAR_DOT: 46,
|
|
6430
|
+
/* . */
|
|
6431
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
6432
|
+
/* " */
|
|
6433
|
+
CHAR_EQUAL: 61,
|
|
6434
|
+
/* = */
|
|
6435
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
6436
|
+
/* ! */
|
|
6437
|
+
CHAR_FORM_FEED: 12,
|
|
6438
|
+
/* \f */
|
|
6439
|
+
CHAR_FORWARD_SLASH: 47,
|
|
6440
|
+
/* / */
|
|
6441
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
6442
|
+
/* ` */
|
|
6443
|
+
CHAR_HASH: 35,
|
|
6444
|
+
/* # */
|
|
6445
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
6446
|
+
/* - */
|
|
6447
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
6448
|
+
/* < */
|
|
6449
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
6450
|
+
/* { */
|
|
6451
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
6452
|
+
/* [ */
|
|
6453
|
+
CHAR_LINE_FEED: 10,
|
|
6454
|
+
/* \n */
|
|
6455
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
6456
|
+
/* \u00A0 */
|
|
6457
|
+
CHAR_PERCENT: 37,
|
|
6458
|
+
/* % */
|
|
6459
|
+
CHAR_PLUS: 43,
|
|
6460
|
+
/* + */
|
|
6461
|
+
CHAR_QUESTION_MARK: 63,
|
|
6462
|
+
/* ? */
|
|
6463
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
6464
|
+
/* > */
|
|
6465
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
6466
|
+
/* } */
|
|
6467
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
6468
|
+
/* ] */
|
|
6469
|
+
CHAR_SEMICOLON: 59,
|
|
6470
|
+
/* ; */
|
|
6471
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
6472
|
+
/* ' */
|
|
6473
|
+
CHAR_SPACE: 32,
|
|
6474
|
+
/* */
|
|
6475
|
+
CHAR_TAB: 9,
|
|
6476
|
+
/* \t */
|
|
6477
|
+
CHAR_UNDERSCORE: 95,
|
|
6478
|
+
/* _ */
|
|
6479
|
+
CHAR_VERTICAL_LINE: 124,
|
|
6480
|
+
/* | */
|
|
6481
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
6482
|
+
/* \uFEFF */
|
|
6483
|
+
/**
|
|
6484
|
+
* Create EXTGLOB_CHARS
|
|
6485
|
+
*/
|
|
6486
|
+
extglobChars(chars) {
|
|
6487
|
+
return {
|
|
6488
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
6489
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
6490
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
6491
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
6492
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
6493
|
+
};
|
|
6494
|
+
},
|
|
6495
|
+
/**
|
|
6496
|
+
* Create GLOB_CHARS
|
|
6497
|
+
*/
|
|
6498
|
+
globChars(win32) {
|
|
6499
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
6500
|
+
}
|
|
6501
|
+
};
|
|
6502
|
+
}
|
|
6503
|
+
});
|
|
6504
|
+
|
|
6505
|
+
// node_modules/picomatch/lib/utils.js
|
|
6506
|
+
var require_utils5 = __commonJS({
|
|
6507
|
+
"node_modules/picomatch/lib/utils.js"(exports2) {
|
|
6508
|
+
"use strict";
|
|
6509
|
+
var {
|
|
6510
|
+
REGEX_BACKSLASH,
|
|
6511
|
+
REGEX_REMOVE_BACKSLASH,
|
|
6512
|
+
REGEX_SPECIAL_CHARS,
|
|
6513
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
6514
|
+
} = require_constants();
|
|
6515
|
+
exports2.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
6516
|
+
exports2.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
6517
|
+
exports2.isRegexChar = (str) => str.length === 1 && exports2.hasRegexChars(str);
|
|
6518
|
+
exports2.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
6519
|
+
exports2.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
6520
|
+
exports2.isWindows = () => {
|
|
6521
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
6522
|
+
const platform = navigator.platform.toLowerCase();
|
|
6523
|
+
return platform === "win32" || platform === "windows";
|
|
6524
|
+
}
|
|
6525
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
6526
|
+
return process.platform === "win32";
|
|
6527
|
+
}
|
|
6528
|
+
return false;
|
|
6529
|
+
};
|
|
6530
|
+
exports2.removeBackslashes = (str) => {
|
|
6531
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
6532
|
+
return match === "\\" ? "" : match;
|
|
6533
|
+
});
|
|
6534
|
+
};
|
|
6535
|
+
exports2.escapeLast = (input, char, lastIdx) => {
|
|
6536
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
6537
|
+
if (idx === -1) return input;
|
|
6538
|
+
if (input[idx - 1] === "\\") return exports2.escapeLast(input, char, idx - 1);
|
|
6539
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
6540
|
+
};
|
|
6541
|
+
exports2.removePrefix = (input, state = {}) => {
|
|
6542
|
+
let output = input;
|
|
6543
|
+
if (output.startsWith("./")) {
|
|
6544
|
+
output = output.slice(2);
|
|
6545
|
+
state.prefix = "./";
|
|
6546
|
+
}
|
|
6547
|
+
return output;
|
|
6548
|
+
};
|
|
6549
|
+
exports2.wrapOutput = (input, state = {}, options = {}) => {
|
|
6550
|
+
const prepend = options.contains ? "" : "^";
|
|
6551
|
+
const append = options.contains ? "" : "$";
|
|
6552
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
6553
|
+
if (state.negated === true) {
|
|
6554
|
+
output = `(?:^(?!${output}).*$)`;
|
|
6555
|
+
}
|
|
6556
|
+
return output;
|
|
6557
|
+
};
|
|
6558
|
+
exports2.basename = (path, { windows } = {}) => {
|
|
6559
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
6560
|
+
const last = segs[segs.length - 1];
|
|
6561
|
+
if (last === "") {
|
|
6562
|
+
return segs[segs.length - 2];
|
|
6563
|
+
}
|
|
6564
|
+
return last;
|
|
6565
|
+
};
|
|
6566
|
+
}
|
|
6567
|
+
});
|
|
6568
|
+
|
|
6569
|
+
// node_modules/picomatch/lib/scan.js
|
|
6570
|
+
var require_scan2 = __commonJS({
|
|
6571
|
+
"node_modules/picomatch/lib/scan.js"(exports2, module2) {
|
|
6572
|
+
"use strict";
|
|
6573
|
+
var utils = require_utils5();
|
|
6574
|
+
var {
|
|
6575
|
+
CHAR_ASTERISK,
|
|
6576
|
+
/* * */
|
|
6577
|
+
CHAR_AT,
|
|
6578
|
+
/* @ */
|
|
6579
|
+
CHAR_BACKWARD_SLASH,
|
|
6580
|
+
/* \ */
|
|
6581
|
+
CHAR_COMMA,
|
|
6582
|
+
/* , */
|
|
6583
|
+
CHAR_DOT,
|
|
6584
|
+
/* . */
|
|
6585
|
+
CHAR_EXCLAMATION_MARK,
|
|
6586
|
+
/* ! */
|
|
6587
|
+
CHAR_FORWARD_SLASH,
|
|
6588
|
+
/* / */
|
|
6589
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
6590
|
+
/* { */
|
|
6591
|
+
CHAR_LEFT_PARENTHESES,
|
|
6592
|
+
/* ( */
|
|
6593
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
6594
|
+
/* [ */
|
|
6595
|
+
CHAR_PLUS,
|
|
6596
|
+
/* + */
|
|
6597
|
+
CHAR_QUESTION_MARK,
|
|
6598
|
+
/* ? */
|
|
6599
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
6600
|
+
/* } */
|
|
6601
|
+
CHAR_RIGHT_PARENTHESES,
|
|
6602
|
+
/* ) */
|
|
6603
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
6604
|
+
/* ] */
|
|
6605
|
+
} = require_constants();
|
|
6606
|
+
var isPathSeparator = (code) => {
|
|
6607
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
6608
|
+
};
|
|
6609
|
+
var depth = (token) => {
|
|
6610
|
+
if (token.isPrefix !== true) {
|
|
6611
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
6612
|
+
}
|
|
6613
|
+
};
|
|
6614
|
+
var scan2 = (input, options) => {
|
|
6615
|
+
const opts = options || {};
|
|
6616
|
+
const length = input.length - 1;
|
|
6617
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
6618
|
+
const slashes = [];
|
|
6619
|
+
const tokens = [];
|
|
6620
|
+
const parts = [];
|
|
6621
|
+
let str = input;
|
|
6622
|
+
let index = -1;
|
|
6623
|
+
let start = 0;
|
|
6624
|
+
let lastIndex = 0;
|
|
6625
|
+
let isBrace = false;
|
|
6626
|
+
let isBracket = false;
|
|
6627
|
+
let isGlob = false;
|
|
6628
|
+
let isExtglob = false;
|
|
6629
|
+
let isGlobstar = false;
|
|
6630
|
+
let braceEscaped = false;
|
|
6631
|
+
let backslashes = false;
|
|
6632
|
+
let negated = false;
|
|
6633
|
+
let negatedExtglob = false;
|
|
6634
|
+
let finished = false;
|
|
6635
|
+
let braces = 0;
|
|
6636
|
+
let prev;
|
|
6637
|
+
let code;
|
|
6638
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
6639
|
+
const eos = () => index >= length;
|
|
6640
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
6641
|
+
const advance = () => {
|
|
6642
|
+
prev = code;
|
|
6643
|
+
return str.charCodeAt(++index);
|
|
6644
|
+
};
|
|
6645
|
+
while (index < length) {
|
|
6646
|
+
code = advance();
|
|
6647
|
+
let next;
|
|
6648
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
6649
|
+
backslashes = token.backslashes = true;
|
|
6650
|
+
code = advance();
|
|
6651
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
6652
|
+
braceEscaped = true;
|
|
6653
|
+
}
|
|
6654
|
+
continue;
|
|
6655
|
+
}
|
|
6656
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
6657
|
+
braces++;
|
|
6658
|
+
while (eos() !== true && (code = advance())) {
|
|
6659
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
6660
|
+
backslashes = token.backslashes = true;
|
|
6661
|
+
advance();
|
|
6662
|
+
continue;
|
|
6663
|
+
}
|
|
6664
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
6665
|
+
braces++;
|
|
6666
|
+
continue;
|
|
6667
|
+
}
|
|
6668
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
6669
|
+
isBrace = token.isBrace = true;
|
|
6670
|
+
isGlob = token.isGlob = true;
|
|
6671
|
+
finished = true;
|
|
6672
|
+
if (scanToEnd === true) {
|
|
6673
|
+
continue;
|
|
6674
|
+
}
|
|
6675
|
+
break;
|
|
6676
|
+
}
|
|
6677
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
6678
|
+
isBrace = token.isBrace = true;
|
|
6679
|
+
isGlob = token.isGlob = true;
|
|
6680
|
+
finished = true;
|
|
6681
|
+
if (scanToEnd === true) {
|
|
6682
|
+
continue;
|
|
6683
|
+
}
|
|
6684
|
+
break;
|
|
6685
|
+
}
|
|
6686
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
6687
|
+
braces--;
|
|
6688
|
+
if (braces === 0) {
|
|
6689
|
+
braceEscaped = false;
|
|
6690
|
+
isBrace = token.isBrace = true;
|
|
6691
|
+
finished = true;
|
|
6692
|
+
break;
|
|
6693
|
+
}
|
|
6694
|
+
}
|
|
6695
|
+
}
|
|
6696
|
+
if (scanToEnd === true) {
|
|
6697
|
+
continue;
|
|
6698
|
+
}
|
|
6699
|
+
break;
|
|
6700
|
+
}
|
|
6701
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
6702
|
+
slashes.push(index);
|
|
6703
|
+
tokens.push(token);
|
|
6704
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
6705
|
+
if (finished === true) continue;
|
|
6706
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
6707
|
+
start += 2;
|
|
6708
|
+
continue;
|
|
6709
|
+
}
|
|
6710
|
+
lastIndex = index + 1;
|
|
6711
|
+
continue;
|
|
6712
|
+
}
|
|
6713
|
+
if (opts.noext !== true) {
|
|
6714
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
6715
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
6716
|
+
isGlob = token.isGlob = true;
|
|
6717
|
+
isExtglob = token.isExtglob = true;
|
|
6718
|
+
finished = true;
|
|
6719
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
6720
|
+
negatedExtglob = true;
|
|
6721
|
+
}
|
|
6722
|
+
if (scanToEnd === true) {
|
|
6723
|
+
while (eos() !== true && (code = advance())) {
|
|
6724
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
6725
|
+
backslashes = token.backslashes = true;
|
|
6726
|
+
code = advance();
|
|
6727
|
+
continue;
|
|
6728
|
+
}
|
|
6729
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
6730
|
+
isGlob = token.isGlob = true;
|
|
6731
|
+
finished = true;
|
|
6732
|
+
break;
|
|
6733
|
+
}
|
|
6734
|
+
}
|
|
6735
|
+
continue;
|
|
6736
|
+
}
|
|
6737
|
+
break;
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
if (code === CHAR_ASTERISK) {
|
|
6741
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
6742
|
+
isGlob = token.isGlob = true;
|
|
6743
|
+
finished = true;
|
|
6744
|
+
if (scanToEnd === true) {
|
|
6745
|
+
continue;
|
|
6746
|
+
}
|
|
6747
|
+
break;
|
|
6748
|
+
}
|
|
6749
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
6750
|
+
isGlob = token.isGlob = true;
|
|
6751
|
+
finished = true;
|
|
6752
|
+
if (scanToEnd === true) {
|
|
6753
|
+
continue;
|
|
6754
|
+
}
|
|
6755
|
+
break;
|
|
6756
|
+
}
|
|
6757
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
6758
|
+
while (eos() !== true && (next = advance())) {
|
|
6759
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
6760
|
+
backslashes = token.backslashes = true;
|
|
6761
|
+
advance();
|
|
6762
|
+
continue;
|
|
6763
|
+
}
|
|
6764
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
6765
|
+
isBracket = token.isBracket = true;
|
|
6766
|
+
isGlob = token.isGlob = true;
|
|
6767
|
+
finished = true;
|
|
6768
|
+
break;
|
|
6769
|
+
}
|
|
6770
|
+
}
|
|
6771
|
+
if (scanToEnd === true) {
|
|
6772
|
+
continue;
|
|
6773
|
+
}
|
|
6774
|
+
break;
|
|
6775
|
+
}
|
|
6776
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
6777
|
+
negated = token.negated = true;
|
|
6778
|
+
start++;
|
|
6779
|
+
continue;
|
|
6780
|
+
}
|
|
6781
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
6782
|
+
isGlob = token.isGlob = true;
|
|
6783
|
+
if (scanToEnd === true) {
|
|
6784
|
+
while (eos() !== true && (code = advance())) {
|
|
6785
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
6786
|
+
backslashes = token.backslashes = true;
|
|
6787
|
+
code = advance();
|
|
6788
|
+
continue;
|
|
6789
|
+
}
|
|
6790
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
6791
|
+
finished = true;
|
|
6792
|
+
break;
|
|
6793
|
+
}
|
|
6794
|
+
}
|
|
6795
|
+
continue;
|
|
6796
|
+
}
|
|
6797
|
+
break;
|
|
6798
|
+
}
|
|
6799
|
+
if (isGlob === true) {
|
|
6800
|
+
finished = true;
|
|
6801
|
+
if (scanToEnd === true) {
|
|
6802
|
+
continue;
|
|
6803
|
+
}
|
|
6804
|
+
break;
|
|
6805
|
+
}
|
|
6806
|
+
}
|
|
6807
|
+
if (opts.noext === true) {
|
|
6808
|
+
isExtglob = false;
|
|
6809
|
+
isGlob = false;
|
|
6810
|
+
}
|
|
6811
|
+
let base = str;
|
|
6812
|
+
let prefix = "";
|
|
6813
|
+
let glob = "";
|
|
6814
|
+
if (start > 0) {
|
|
6815
|
+
prefix = str.slice(0, start);
|
|
6816
|
+
str = str.slice(start);
|
|
6817
|
+
lastIndex -= start;
|
|
6818
|
+
}
|
|
6819
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
6820
|
+
base = str.slice(0, lastIndex);
|
|
6821
|
+
glob = str.slice(lastIndex);
|
|
6822
|
+
} else if (isGlob === true) {
|
|
6823
|
+
base = "";
|
|
6824
|
+
glob = str;
|
|
6825
|
+
} else {
|
|
6826
|
+
base = str;
|
|
6827
|
+
}
|
|
6828
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
6829
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
6830
|
+
base = base.slice(0, -1);
|
|
6831
|
+
}
|
|
6832
|
+
}
|
|
6833
|
+
if (opts.unescape === true) {
|
|
6834
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
6835
|
+
if (base && backslashes === true) {
|
|
6836
|
+
base = utils.removeBackslashes(base);
|
|
6837
|
+
}
|
|
6838
|
+
}
|
|
6839
|
+
const state = {
|
|
6840
|
+
prefix,
|
|
6841
|
+
input,
|
|
6842
|
+
start,
|
|
6843
|
+
base,
|
|
6844
|
+
glob,
|
|
6845
|
+
isBrace,
|
|
6846
|
+
isBracket,
|
|
6847
|
+
isGlob,
|
|
6848
|
+
isExtglob,
|
|
6849
|
+
isGlobstar,
|
|
6850
|
+
negated,
|
|
6851
|
+
negatedExtglob
|
|
6852
|
+
};
|
|
6853
|
+
if (opts.tokens === true) {
|
|
6854
|
+
state.maxDepth = 0;
|
|
6855
|
+
if (!isPathSeparator(code)) {
|
|
6856
|
+
tokens.push(token);
|
|
6857
|
+
}
|
|
6858
|
+
state.tokens = tokens;
|
|
6859
|
+
}
|
|
6860
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
6861
|
+
let prevIndex;
|
|
6862
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
6863
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
6864
|
+
const i = slashes[idx];
|
|
6865
|
+
const value = input.slice(n, i);
|
|
6866
|
+
if (opts.tokens) {
|
|
6867
|
+
if (idx === 0 && start !== 0) {
|
|
6868
|
+
tokens[idx].isPrefix = true;
|
|
6869
|
+
tokens[idx].value = prefix;
|
|
6870
|
+
} else {
|
|
6871
|
+
tokens[idx].value = value;
|
|
6872
|
+
}
|
|
6873
|
+
depth(tokens[idx]);
|
|
6874
|
+
state.maxDepth += tokens[idx].depth;
|
|
6875
|
+
}
|
|
6876
|
+
if (idx !== 0 || value !== "") {
|
|
6877
|
+
parts.push(value);
|
|
6878
|
+
}
|
|
6879
|
+
prevIndex = i;
|
|
6880
|
+
}
|
|
6881
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
6882
|
+
const value = input.slice(prevIndex + 1);
|
|
6883
|
+
parts.push(value);
|
|
6884
|
+
if (opts.tokens) {
|
|
6885
|
+
tokens[tokens.length - 1].value = value;
|
|
6886
|
+
depth(tokens[tokens.length - 1]);
|
|
6887
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
6888
|
+
}
|
|
6889
|
+
}
|
|
6890
|
+
state.slashes = slashes;
|
|
6891
|
+
state.parts = parts;
|
|
6892
|
+
}
|
|
6893
|
+
return state;
|
|
6894
|
+
};
|
|
6895
|
+
module2.exports = scan2;
|
|
6896
|
+
}
|
|
6897
|
+
});
|
|
6898
|
+
|
|
6899
|
+
// node_modules/picomatch/lib/parse.js
|
|
6900
|
+
var require_parse = __commonJS({
|
|
6901
|
+
"node_modules/picomatch/lib/parse.js"(exports2, module2) {
|
|
6902
|
+
"use strict";
|
|
6903
|
+
var constants = require_constants();
|
|
6904
|
+
var utils = require_utils5();
|
|
6905
|
+
var {
|
|
6906
|
+
MAX_LENGTH,
|
|
6907
|
+
POSIX_REGEX_SOURCE,
|
|
6908
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
6909
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
6910
|
+
REPLACEMENTS
|
|
6911
|
+
} = constants;
|
|
6912
|
+
var expandRange = (args, options) => {
|
|
6913
|
+
if (typeof options.expandRange === "function") {
|
|
6914
|
+
return options.expandRange(...args, options);
|
|
6915
|
+
}
|
|
6916
|
+
args.sort();
|
|
6917
|
+
const value = `[${args.join("-")}]`;
|
|
6918
|
+
try {
|
|
6919
|
+
new RegExp(value);
|
|
6920
|
+
} catch (ex) {
|
|
6921
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
6922
|
+
}
|
|
6923
|
+
return value;
|
|
6924
|
+
};
|
|
6925
|
+
var syntaxError = (type, char) => {
|
|
6926
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
6927
|
+
};
|
|
6928
|
+
var splitTopLevel = (input) => {
|
|
6929
|
+
const parts = [];
|
|
6930
|
+
let bracket = 0;
|
|
6931
|
+
let paren = 0;
|
|
6932
|
+
let quote = 0;
|
|
6933
|
+
let value = "";
|
|
6934
|
+
let escaped = false;
|
|
6935
|
+
for (const ch of input) {
|
|
6936
|
+
if (escaped === true) {
|
|
6937
|
+
value += ch;
|
|
6938
|
+
escaped = false;
|
|
6939
|
+
continue;
|
|
6940
|
+
}
|
|
6941
|
+
if (ch === "\\") {
|
|
6942
|
+
value += ch;
|
|
6943
|
+
escaped = true;
|
|
6944
|
+
continue;
|
|
6945
|
+
}
|
|
6946
|
+
if (ch === '"') {
|
|
6947
|
+
quote = quote === 1 ? 0 : 1;
|
|
6948
|
+
value += ch;
|
|
6949
|
+
continue;
|
|
6950
|
+
}
|
|
6951
|
+
if (quote === 0) {
|
|
6952
|
+
if (ch === "[") {
|
|
6953
|
+
bracket++;
|
|
6954
|
+
} else if (ch === "]" && bracket > 0) {
|
|
6955
|
+
bracket--;
|
|
6956
|
+
} else if (bracket === 0) {
|
|
6957
|
+
if (ch === "(") {
|
|
6958
|
+
paren++;
|
|
6959
|
+
} else if (ch === ")" && paren > 0) {
|
|
6960
|
+
paren--;
|
|
6961
|
+
} else if (ch === "|" && paren === 0) {
|
|
6962
|
+
parts.push(value);
|
|
6963
|
+
value = "";
|
|
6964
|
+
continue;
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
6967
|
+
}
|
|
6968
|
+
value += ch;
|
|
6969
|
+
}
|
|
6970
|
+
parts.push(value);
|
|
6971
|
+
return parts;
|
|
6972
|
+
};
|
|
6973
|
+
var isPlainBranch = (branch) => {
|
|
6974
|
+
let escaped = false;
|
|
6975
|
+
for (const ch of branch) {
|
|
6976
|
+
if (escaped === true) {
|
|
6977
|
+
escaped = false;
|
|
6978
|
+
continue;
|
|
6979
|
+
}
|
|
6980
|
+
if (ch === "\\") {
|
|
6981
|
+
escaped = true;
|
|
6982
|
+
continue;
|
|
6983
|
+
}
|
|
6984
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
6985
|
+
return false;
|
|
6986
|
+
}
|
|
6987
|
+
}
|
|
6988
|
+
return true;
|
|
6989
|
+
};
|
|
6990
|
+
var normalizeSimpleBranch = (branch) => {
|
|
6991
|
+
let value = branch.trim();
|
|
6992
|
+
let changed = true;
|
|
6993
|
+
while (changed === true) {
|
|
6994
|
+
changed = false;
|
|
6995
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
6996
|
+
value = value.slice(2, -1);
|
|
6997
|
+
changed = true;
|
|
6998
|
+
}
|
|
6999
|
+
}
|
|
7000
|
+
if (!isPlainBranch(value)) {
|
|
7001
|
+
return;
|
|
7002
|
+
}
|
|
7003
|
+
return value.replace(/\\(.)/g, "$1");
|
|
7004
|
+
};
|
|
7005
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
7006
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
7007
|
+
for (let i = 0; i < values.length; i++) {
|
|
7008
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
7009
|
+
const a = values[i];
|
|
7010
|
+
const b = values[j];
|
|
7011
|
+
const char = a[0];
|
|
7012
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
7013
|
+
continue;
|
|
7014
|
+
}
|
|
7015
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
7016
|
+
return true;
|
|
7017
|
+
}
|
|
7018
|
+
}
|
|
7019
|
+
}
|
|
7020
|
+
return false;
|
|
7021
|
+
};
|
|
7022
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
7023
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
7024
|
+
return;
|
|
7025
|
+
}
|
|
7026
|
+
let bracket = 0;
|
|
7027
|
+
let paren = 0;
|
|
7028
|
+
let quote = 0;
|
|
7029
|
+
let escaped = false;
|
|
7030
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
7031
|
+
const ch = pattern[i];
|
|
7032
|
+
if (escaped === true) {
|
|
7033
|
+
escaped = false;
|
|
7034
|
+
continue;
|
|
7035
|
+
}
|
|
7036
|
+
if (ch === "\\") {
|
|
7037
|
+
escaped = true;
|
|
7038
|
+
continue;
|
|
7039
|
+
}
|
|
7040
|
+
if (ch === '"') {
|
|
7041
|
+
quote = quote === 1 ? 0 : 1;
|
|
7042
|
+
continue;
|
|
7043
|
+
}
|
|
7044
|
+
if (quote === 1) {
|
|
7045
|
+
continue;
|
|
7046
|
+
}
|
|
7047
|
+
if (ch === "[") {
|
|
7048
|
+
bracket++;
|
|
7049
|
+
continue;
|
|
7050
|
+
}
|
|
7051
|
+
if (ch === "]" && bracket > 0) {
|
|
7052
|
+
bracket--;
|
|
7053
|
+
continue;
|
|
7054
|
+
}
|
|
7055
|
+
if (bracket > 0) {
|
|
7056
|
+
continue;
|
|
7057
|
+
}
|
|
7058
|
+
if (ch === "(") {
|
|
7059
|
+
paren++;
|
|
7060
|
+
continue;
|
|
7061
|
+
}
|
|
7062
|
+
if (ch === ")") {
|
|
7063
|
+
paren--;
|
|
7064
|
+
if (paren === 0) {
|
|
7065
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
7066
|
+
return;
|
|
7067
|
+
}
|
|
7068
|
+
return {
|
|
7069
|
+
type: pattern[0],
|
|
7070
|
+
body: pattern.slice(2, i),
|
|
7071
|
+
end: i
|
|
7072
|
+
};
|
|
7073
|
+
}
|
|
7074
|
+
}
|
|
7075
|
+
}
|
|
7076
|
+
};
|
|
7077
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
7078
|
+
let index = 0;
|
|
7079
|
+
const chars = [];
|
|
7080
|
+
while (index < pattern.length) {
|
|
7081
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
7082
|
+
if (!match || match.type !== "*") {
|
|
7083
|
+
return;
|
|
7084
|
+
}
|
|
7085
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
7086
|
+
if (branches.length !== 1) {
|
|
7087
|
+
return;
|
|
7088
|
+
}
|
|
7089
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
7090
|
+
if (!branch || branch.length !== 1) {
|
|
7091
|
+
return;
|
|
7092
|
+
}
|
|
7093
|
+
chars.push(branch);
|
|
7094
|
+
index += match.end + 1;
|
|
7095
|
+
}
|
|
7096
|
+
if (chars.length < 1) {
|
|
7097
|
+
return;
|
|
7098
|
+
}
|
|
7099
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
7100
|
+
return `${source}*`;
|
|
7101
|
+
};
|
|
7102
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
7103
|
+
let depth = 0;
|
|
7104
|
+
let value = pattern.trim();
|
|
7105
|
+
let match = parseRepeatedExtglob(value);
|
|
7106
|
+
while (match) {
|
|
7107
|
+
depth++;
|
|
7108
|
+
value = match.body.trim();
|
|
7109
|
+
match = parseRepeatedExtglob(value);
|
|
7110
|
+
}
|
|
7111
|
+
return depth;
|
|
7112
|
+
};
|
|
7113
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
7114
|
+
if (options.maxExtglobRecursion === false) {
|
|
7115
|
+
return { risky: false };
|
|
7116
|
+
}
|
|
7117
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
7118
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
7119
|
+
if (branches.length > 1) {
|
|
7120
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
7121
|
+
return { risky: true };
|
|
7122
|
+
}
|
|
7123
|
+
}
|
|
7124
|
+
for (const branch of branches) {
|
|
7125
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
7126
|
+
if (safeOutput) {
|
|
7127
|
+
return { risky: true, safeOutput };
|
|
7128
|
+
}
|
|
7129
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
7130
|
+
return { risky: true };
|
|
7131
|
+
}
|
|
7132
|
+
}
|
|
7133
|
+
return { risky: false };
|
|
7134
|
+
};
|
|
7135
|
+
var parse2 = (input, options) => {
|
|
7136
|
+
if (typeof input !== "string") {
|
|
7137
|
+
throw new TypeError("Expected a string");
|
|
7138
|
+
}
|
|
7139
|
+
input = REPLACEMENTS[input] || input;
|
|
7140
|
+
const opts = { ...options };
|
|
7141
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
7142
|
+
let len = input.length;
|
|
7143
|
+
if (len > max) {
|
|
7144
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
7145
|
+
}
|
|
7146
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
7147
|
+
const tokens = [bos];
|
|
7148
|
+
const capture = opts.capture ? "" : "?:";
|
|
7149
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
7150
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
7151
|
+
const {
|
|
7152
|
+
DOT_LITERAL,
|
|
7153
|
+
PLUS_LITERAL,
|
|
7154
|
+
SLASH_LITERAL,
|
|
7155
|
+
ONE_CHAR,
|
|
7156
|
+
DOTS_SLASH,
|
|
7157
|
+
NO_DOT,
|
|
7158
|
+
NO_DOT_SLASH,
|
|
7159
|
+
NO_DOTS_SLASH,
|
|
7160
|
+
QMARK,
|
|
7161
|
+
QMARK_NO_DOT,
|
|
7162
|
+
STAR,
|
|
7163
|
+
START_ANCHOR
|
|
7164
|
+
} = PLATFORM_CHARS;
|
|
7165
|
+
const globstar = (opts2) => {
|
|
7166
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
7167
|
+
};
|
|
7168
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
7169
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
7170
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
7171
|
+
if (opts.capture) {
|
|
7172
|
+
star = `(${star})`;
|
|
7173
|
+
}
|
|
7174
|
+
if (typeof opts.noext === "boolean") {
|
|
7175
|
+
opts.noextglob = opts.noext;
|
|
7176
|
+
}
|
|
7177
|
+
const state = {
|
|
7178
|
+
input,
|
|
7179
|
+
index: -1,
|
|
7180
|
+
start: 0,
|
|
7181
|
+
dot: opts.dot === true,
|
|
7182
|
+
consumed: "",
|
|
7183
|
+
output: "",
|
|
7184
|
+
prefix: "",
|
|
7185
|
+
backtrack: false,
|
|
7186
|
+
negated: false,
|
|
7187
|
+
brackets: 0,
|
|
7188
|
+
braces: 0,
|
|
7189
|
+
parens: 0,
|
|
7190
|
+
quotes: 0,
|
|
7191
|
+
globstar: false,
|
|
7192
|
+
tokens
|
|
7193
|
+
};
|
|
7194
|
+
input = utils.removePrefix(input, state);
|
|
7195
|
+
len = input.length;
|
|
7196
|
+
const extglobs = [];
|
|
7197
|
+
const braces = [];
|
|
7198
|
+
const stack = [];
|
|
7199
|
+
let prev = bos;
|
|
7200
|
+
let value;
|
|
7201
|
+
const eos = () => state.index === len - 1;
|
|
7202
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
7203
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
7204
|
+
const remaining = () => input.slice(state.index + 1);
|
|
7205
|
+
const consume = (value2 = "", num = 0) => {
|
|
7206
|
+
state.consumed += value2;
|
|
7207
|
+
state.index += num;
|
|
7208
|
+
};
|
|
7209
|
+
const append = (token) => {
|
|
7210
|
+
state.output += token.output != null ? token.output : token.value;
|
|
7211
|
+
consume(token.value);
|
|
7212
|
+
};
|
|
7213
|
+
const negate = () => {
|
|
7214
|
+
let count = 1;
|
|
7215
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
7216
|
+
advance();
|
|
7217
|
+
state.start++;
|
|
7218
|
+
count++;
|
|
7219
|
+
}
|
|
7220
|
+
if (count % 2 === 0) {
|
|
7221
|
+
return false;
|
|
7222
|
+
}
|
|
7223
|
+
state.negated = true;
|
|
7224
|
+
state.start++;
|
|
7225
|
+
return true;
|
|
7226
|
+
};
|
|
7227
|
+
const increment = (type) => {
|
|
7228
|
+
state[type]++;
|
|
7229
|
+
stack.push(type);
|
|
7230
|
+
};
|
|
7231
|
+
const decrement = (type) => {
|
|
7232
|
+
state[type]--;
|
|
7233
|
+
stack.pop();
|
|
7234
|
+
};
|
|
7235
|
+
const push = (tok) => {
|
|
7236
|
+
if (prev.type === "globstar") {
|
|
7237
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
7238
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
7239
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
7240
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
7241
|
+
prev.type = "star";
|
|
7242
|
+
prev.value = "*";
|
|
7243
|
+
prev.output = star;
|
|
7244
|
+
state.output += prev.output;
|
|
7245
|
+
}
|
|
7246
|
+
}
|
|
7247
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
7248
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
7249
|
+
}
|
|
7250
|
+
if (tok.value || tok.output) append(tok);
|
|
7251
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
7252
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
7253
|
+
prev.value += tok.value;
|
|
7254
|
+
return;
|
|
7255
|
+
}
|
|
7256
|
+
tok.prev = prev;
|
|
7257
|
+
tokens.push(tok);
|
|
7258
|
+
prev = tok;
|
|
7259
|
+
};
|
|
7260
|
+
const extglobOpen = (type, value2) => {
|
|
7261
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
7262
|
+
token.prev = prev;
|
|
7263
|
+
token.parens = state.parens;
|
|
7264
|
+
token.output = state.output;
|
|
7265
|
+
token.startIndex = state.index;
|
|
7266
|
+
token.tokensIndex = tokens.length;
|
|
7267
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
7268
|
+
increment("parens");
|
|
7269
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
7270
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
7271
|
+
extglobs.push(token);
|
|
7272
|
+
};
|
|
7273
|
+
const extglobClose = (token) => {
|
|
7274
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
7275
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
7276
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
7277
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
7278
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
7279
|
+
const open = tokens[token.tokensIndex];
|
|
7280
|
+
open.type = "text";
|
|
7281
|
+
open.value = literal;
|
|
7282
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
7283
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
7284
|
+
tokens[i].value = "";
|
|
7285
|
+
tokens[i].output = "";
|
|
7286
|
+
delete tokens[i].suffix;
|
|
7287
|
+
}
|
|
7288
|
+
state.output = token.output + open.output;
|
|
7289
|
+
state.backtrack = true;
|
|
7290
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
7291
|
+
decrement("parens");
|
|
7292
|
+
return;
|
|
7293
|
+
}
|
|
7294
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
7295
|
+
let rest;
|
|
7296
|
+
if (token.type === "negate") {
|
|
7297
|
+
let extglobStar = star;
|
|
7298
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
7299
|
+
extglobStar = globstar(opts);
|
|
7300
|
+
}
|
|
7301
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
7302
|
+
output = token.close = `)$))${extglobStar}`;
|
|
7303
|
+
}
|
|
7304
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
7305
|
+
const expression = parse2(rest, { ...options, fastpaths: false }).output;
|
|
7306
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
7307
|
+
}
|
|
7308
|
+
if (token.prev.type === "bos") {
|
|
7309
|
+
state.negatedExtglob = true;
|
|
7310
|
+
}
|
|
7311
|
+
}
|
|
7312
|
+
push({ type: "paren", extglob: true, value, output });
|
|
7313
|
+
decrement("parens");
|
|
7314
|
+
};
|
|
7315
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
7316
|
+
let backslashes = false;
|
|
7317
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
7318
|
+
if (first === "\\") {
|
|
7319
|
+
backslashes = true;
|
|
7320
|
+
return m;
|
|
7321
|
+
}
|
|
7322
|
+
if (first === "?") {
|
|
7323
|
+
if (esc) {
|
|
7324
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
7325
|
+
}
|
|
7326
|
+
if (index === 0) {
|
|
7327
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
7328
|
+
}
|
|
7329
|
+
return QMARK.repeat(chars.length);
|
|
7330
|
+
}
|
|
7331
|
+
if (first === ".") {
|
|
7332
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
7333
|
+
}
|
|
7334
|
+
if (first === "*") {
|
|
7335
|
+
if (esc) {
|
|
7336
|
+
return esc + first + (rest ? star : "");
|
|
7337
|
+
}
|
|
7338
|
+
return star;
|
|
7339
|
+
}
|
|
7340
|
+
return esc ? m : `\\${m}`;
|
|
7341
|
+
});
|
|
7342
|
+
if (backslashes === true) {
|
|
7343
|
+
if (opts.unescape === true) {
|
|
7344
|
+
output = output.replace(/\\/g, "");
|
|
7345
|
+
} else {
|
|
7346
|
+
output = output.replace(/\\+/g, (m) => {
|
|
7347
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
7348
|
+
});
|
|
7349
|
+
}
|
|
7350
|
+
}
|
|
7351
|
+
if (output === input && opts.contains === true) {
|
|
7352
|
+
state.output = input;
|
|
7353
|
+
return state;
|
|
7354
|
+
}
|
|
7355
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
7356
|
+
return state;
|
|
7357
|
+
}
|
|
7358
|
+
while (!eos()) {
|
|
7359
|
+
value = advance();
|
|
7360
|
+
if (value === "\0") {
|
|
7361
|
+
continue;
|
|
7362
|
+
}
|
|
7363
|
+
if (value === "\\") {
|
|
7364
|
+
const next = peek();
|
|
7365
|
+
if (next === "/" && opts.bash !== true) {
|
|
7366
|
+
continue;
|
|
7367
|
+
}
|
|
7368
|
+
if (next === "." || next === ";") {
|
|
7369
|
+
continue;
|
|
7370
|
+
}
|
|
7371
|
+
if (!next) {
|
|
7372
|
+
value += "\\";
|
|
7373
|
+
push({ type: "text", value });
|
|
7374
|
+
continue;
|
|
7375
|
+
}
|
|
7376
|
+
const match = /^\\+/.exec(remaining());
|
|
7377
|
+
let slashes = 0;
|
|
7378
|
+
if (match && match[0].length > 2) {
|
|
7379
|
+
slashes = match[0].length;
|
|
7380
|
+
state.index += slashes;
|
|
7381
|
+
if (slashes % 2 !== 0) {
|
|
7382
|
+
value += "\\";
|
|
7383
|
+
}
|
|
7384
|
+
}
|
|
7385
|
+
if (opts.unescape === true) {
|
|
7386
|
+
value = advance();
|
|
7387
|
+
} else {
|
|
7388
|
+
value += advance();
|
|
7389
|
+
}
|
|
7390
|
+
if (state.brackets === 0) {
|
|
7391
|
+
push({ type: "text", value });
|
|
7392
|
+
continue;
|
|
7393
|
+
}
|
|
7394
|
+
}
|
|
7395
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
7396
|
+
if (opts.posix !== false && value === ":") {
|
|
7397
|
+
const inner = prev.value.slice(1);
|
|
7398
|
+
if (inner.includes("[")) {
|
|
7399
|
+
prev.posix = true;
|
|
7400
|
+
if (inner.includes(":")) {
|
|
7401
|
+
const idx = prev.value.lastIndexOf("[");
|
|
7402
|
+
const pre = prev.value.slice(0, idx);
|
|
7403
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
7404
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
7405
|
+
if (posix) {
|
|
7406
|
+
prev.value = pre + posix;
|
|
7407
|
+
state.backtrack = true;
|
|
7408
|
+
advance();
|
|
7409
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
7410
|
+
bos.output = ONE_CHAR;
|
|
7411
|
+
}
|
|
7412
|
+
continue;
|
|
7413
|
+
}
|
|
7414
|
+
}
|
|
7415
|
+
}
|
|
7416
|
+
}
|
|
7417
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
7418
|
+
value = `\\${value}`;
|
|
7419
|
+
}
|
|
7420
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
7421
|
+
value = `\\${value}`;
|
|
7422
|
+
}
|
|
7423
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
7424
|
+
value = "^";
|
|
7425
|
+
}
|
|
7426
|
+
prev.value += value;
|
|
7427
|
+
append({ value });
|
|
7428
|
+
continue;
|
|
7429
|
+
}
|
|
7430
|
+
if (state.quotes === 1 && value !== '"') {
|
|
7431
|
+
value = utils.escapeRegex(value);
|
|
7432
|
+
prev.value += value;
|
|
7433
|
+
append({ value });
|
|
7434
|
+
continue;
|
|
7435
|
+
}
|
|
7436
|
+
if (value === '"') {
|
|
7437
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
7438
|
+
if (opts.keepQuotes === true) {
|
|
7439
|
+
push({ type: "text", value });
|
|
7440
|
+
}
|
|
7441
|
+
continue;
|
|
7442
|
+
}
|
|
7443
|
+
if (value === "(") {
|
|
7444
|
+
increment("parens");
|
|
7445
|
+
push({ type: "paren", value });
|
|
7446
|
+
continue;
|
|
7447
|
+
}
|
|
7448
|
+
if (value === ")") {
|
|
7449
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
7450
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
7451
|
+
}
|
|
7452
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
7453
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
7454
|
+
extglobClose(extglobs.pop());
|
|
7455
|
+
continue;
|
|
7456
|
+
}
|
|
7457
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
7458
|
+
decrement("parens");
|
|
7459
|
+
continue;
|
|
7460
|
+
}
|
|
7461
|
+
if (value === "[") {
|
|
7462
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
7463
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
7464
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
7465
|
+
}
|
|
7466
|
+
value = `\\${value}`;
|
|
7467
|
+
} else {
|
|
7468
|
+
increment("brackets");
|
|
7469
|
+
}
|
|
7470
|
+
push({ type: "bracket", value });
|
|
7471
|
+
continue;
|
|
7472
|
+
}
|
|
7473
|
+
if (value === "]") {
|
|
7474
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
7475
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
7476
|
+
continue;
|
|
7477
|
+
}
|
|
7478
|
+
if (state.brackets === 0) {
|
|
7479
|
+
if (opts.strictBrackets === true) {
|
|
7480
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
7481
|
+
}
|
|
7482
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
7483
|
+
continue;
|
|
7484
|
+
}
|
|
7485
|
+
decrement("brackets");
|
|
7486
|
+
const prevValue = prev.value.slice(1);
|
|
7487
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
7488
|
+
value = `/${value}`;
|
|
7489
|
+
}
|
|
7490
|
+
prev.value += value;
|
|
7491
|
+
append({ value });
|
|
7492
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
7493
|
+
continue;
|
|
7494
|
+
}
|
|
7495
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
7496
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
7497
|
+
if (opts.literalBrackets === true) {
|
|
7498
|
+
state.output += escaped;
|
|
7499
|
+
prev.value = escaped;
|
|
7500
|
+
continue;
|
|
7501
|
+
}
|
|
7502
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
7503
|
+
state.output += prev.value;
|
|
7504
|
+
continue;
|
|
7505
|
+
}
|
|
7506
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
7507
|
+
increment("braces");
|
|
7508
|
+
const open = {
|
|
7509
|
+
type: "brace",
|
|
7510
|
+
value,
|
|
7511
|
+
output: "(",
|
|
7512
|
+
outputIndex: state.output.length,
|
|
7513
|
+
tokensIndex: state.tokens.length
|
|
7514
|
+
};
|
|
7515
|
+
braces.push(open);
|
|
7516
|
+
push(open);
|
|
7517
|
+
continue;
|
|
7518
|
+
}
|
|
7519
|
+
if (value === "}") {
|
|
7520
|
+
const brace = braces[braces.length - 1];
|
|
7521
|
+
if (opts.nobrace === true || !brace) {
|
|
7522
|
+
push({ type: "text", value, output: value });
|
|
7523
|
+
continue;
|
|
7524
|
+
}
|
|
7525
|
+
let output = ")";
|
|
7526
|
+
if (brace.dots === true) {
|
|
7527
|
+
const arr = tokens.slice();
|
|
7528
|
+
const range = [];
|
|
7529
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
7530
|
+
tokens.pop();
|
|
7531
|
+
if (arr[i].type === "brace") {
|
|
7532
|
+
break;
|
|
7533
|
+
}
|
|
7534
|
+
if (arr[i].type !== "dots") {
|
|
7535
|
+
range.unshift(arr[i].value);
|
|
7536
|
+
}
|
|
7537
|
+
}
|
|
7538
|
+
output = expandRange(range, opts);
|
|
7539
|
+
state.backtrack = true;
|
|
7540
|
+
}
|
|
7541
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
7542
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
7543
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
7544
|
+
brace.value = brace.output = "\\{";
|
|
7545
|
+
value = output = "\\}";
|
|
7546
|
+
state.output = out;
|
|
7547
|
+
for (const t of toks) {
|
|
7548
|
+
state.output += t.output || t.value;
|
|
7549
|
+
}
|
|
7550
|
+
}
|
|
7551
|
+
push({ type: "brace", value, output });
|
|
7552
|
+
decrement("braces");
|
|
7553
|
+
braces.pop();
|
|
7554
|
+
continue;
|
|
7555
|
+
}
|
|
7556
|
+
if (value === "|") {
|
|
7557
|
+
if (extglobs.length > 0) {
|
|
7558
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
7559
|
+
}
|
|
7560
|
+
push({ type: "text", value });
|
|
7561
|
+
continue;
|
|
7562
|
+
}
|
|
7563
|
+
if (value === ",") {
|
|
7564
|
+
let output = value;
|
|
7565
|
+
const brace = braces[braces.length - 1];
|
|
7566
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
7567
|
+
brace.comma = true;
|
|
7568
|
+
output = "|";
|
|
7569
|
+
}
|
|
7570
|
+
push({ type: "comma", value, output });
|
|
7571
|
+
continue;
|
|
7572
|
+
}
|
|
7573
|
+
if (value === "/") {
|
|
7574
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
7575
|
+
state.start = state.index + 1;
|
|
7576
|
+
state.consumed = "";
|
|
7577
|
+
state.output = "";
|
|
7578
|
+
tokens.pop();
|
|
7579
|
+
prev = bos;
|
|
7580
|
+
continue;
|
|
7581
|
+
}
|
|
7582
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
7583
|
+
continue;
|
|
7584
|
+
}
|
|
7585
|
+
if (value === ".") {
|
|
7586
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
7587
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
7588
|
+
const brace = braces[braces.length - 1];
|
|
7589
|
+
prev.type = "dots";
|
|
7590
|
+
prev.output += value;
|
|
7591
|
+
prev.value += value;
|
|
7592
|
+
brace.dots = true;
|
|
7593
|
+
continue;
|
|
7594
|
+
}
|
|
7595
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
7596
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
7597
|
+
continue;
|
|
7598
|
+
}
|
|
7599
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
7600
|
+
continue;
|
|
7601
|
+
}
|
|
7602
|
+
if (value === "?") {
|
|
7603
|
+
const isGroup = prev && prev.value === "(";
|
|
7604
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
7605
|
+
extglobOpen("qmark", value);
|
|
7606
|
+
continue;
|
|
7607
|
+
}
|
|
7608
|
+
if (prev && prev.type === "paren") {
|
|
7609
|
+
const next = peek();
|
|
7610
|
+
let output = value;
|
|
7611
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
7612
|
+
output = `\\${value}`;
|
|
7613
|
+
}
|
|
7614
|
+
push({ type: "text", value, output });
|
|
7615
|
+
continue;
|
|
7616
|
+
}
|
|
7617
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
7618
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
7619
|
+
continue;
|
|
7620
|
+
}
|
|
7621
|
+
push({ type: "qmark", value, output: QMARK });
|
|
7622
|
+
continue;
|
|
7623
|
+
}
|
|
7624
|
+
if (value === "!") {
|
|
7625
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
7626
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
7627
|
+
extglobOpen("negate", value);
|
|
7628
|
+
continue;
|
|
7629
|
+
}
|
|
7630
|
+
}
|
|
7631
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
7632
|
+
negate();
|
|
7633
|
+
continue;
|
|
7634
|
+
}
|
|
7635
|
+
}
|
|
7636
|
+
if (value === "+") {
|
|
7637
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
7638
|
+
extglobOpen("plus", value);
|
|
7639
|
+
continue;
|
|
7640
|
+
}
|
|
7641
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
7642
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
7643
|
+
continue;
|
|
7644
|
+
}
|
|
7645
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
7646
|
+
push({ type: "plus", value });
|
|
7647
|
+
continue;
|
|
7648
|
+
}
|
|
7649
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
7650
|
+
continue;
|
|
7651
|
+
}
|
|
7652
|
+
if (value === "@") {
|
|
7653
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
7654
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
7655
|
+
continue;
|
|
7656
|
+
}
|
|
7657
|
+
push({ type: "text", value });
|
|
7658
|
+
continue;
|
|
7659
|
+
}
|
|
7660
|
+
if (value !== "*") {
|
|
7661
|
+
if (value === "$" || value === "^") {
|
|
7662
|
+
value = `\\${value}`;
|
|
7663
|
+
}
|
|
7664
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
7665
|
+
if (match) {
|
|
7666
|
+
value += match[0];
|
|
7667
|
+
state.index += match[0].length;
|
|
7668
|
+
}
|
|
7669
|
+
push({ type: "text", value });
|
|
7670
|
+
continue;
|
|
7671
|
+
}
|
|
7672
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
7673
|
+
prev.type = "star";
|
|
7674
|
+
prev.star = true;
|
|
7675
|
+
prev.value += value;
|
|
7676
|
+
prev.output = star;
|
|
7677
|
+
state.backtrack = true;
|
|
7678
|
+
state.globstar = true;
|
|
7679
|
+
consume(value);
|
|
7680
|
+
continue;
|
|
7681
|
+
}
|
|
7682
|
+
let rest = remaining();
|
|
7683
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
7684
|
+
extglobOpen("star", value);
|
|
7685
|
+
continue;
|
|
7686
|
+
}
|
|
7687
|
+
if (prev.type === "star") {
|
|
7688
|
+
if (opts.noglobstar === true) {
|
|
7689
|
+
consume(value);
|
|
7690
|
+
continue;
|
|
7691
|
+
}
|
|
7692
|
+
const prior = prev.prev;
|
|
7693
|
+
const before = prior.prev;
|
|
7694
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
7695
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
7696
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
7697
|
+
push({ type: "star", value, output: "" });
|
|
7698
|
+
continue;
|
|
7699
|
+
}
|
|
7700
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
7701
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
7702
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
7703
|
+
push({ type: "star", value, output: "" });
|
|
7704
|
+
continue;
|
|
7705
|
+
}
|
|
7706
|
+
while (rest.slice(0, 3) === "/**") {
|
|
7707
|
+
const after = input[state.index + 4];
|
|
7708
|
+
if (after && after !== "/") {
|
|
7709
|
+
break;
|
|
7710
|
+
}
|
|
7711
|
+
rest = rest.slice(3);
|
|
7712
|
+
consume("/**", 3);
|
|
7713
|
+
}
|
|
7714
|
+
if (prior.type === "bos" && eos()) {
|
|
7715
|
+
prev.type = "globstar";
|
|
7716
|
+
prev.value += value;
|
|
7717
|
+
prev.output = globstar(opts);
|
|
7718
|
+
state.output = prev.output;
|
|
7719
|
+
state.globstar = true;
|
|
7720
|
+
consume(value);
|
|
7721
|
+
continue;
|
|
7722
|
+
}
|
|
7723
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
7724
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
7725
|
+
prior.output = `(?:${prior.output}`;
|
|
7726
|
+
prev.type = "globstar";
|
|
7727
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
7728
|
+
prev.value += value;
|
|
7729
|
+
state.globstar = true;
|
|
7730
|
+
state.output += prior.output + prev.output;
|
|
7731
|
+
consume(value);
|
|
7732
|
+
continue;
|
|
7733
|
+
}
|
|
7734
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
7735
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
7736
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
7737
|
+
prior.output = `(?:${prior.output}`;
|
|
7738
|
+
prev.type = "globstar";
|
|
7739
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
7740
|
+
prev.value += value;
|
|
7741
|
+
state.output += prior.output + prev.output;
|
|
7742
|
+
state.globstar = true;
|
|
7743
|
+
consume(value + advance());
|
|
7744
|
+
push({ type: "slash", value: "/", output: "" });
|
|
7745
|
+
continue;
|
|
7746
|
+
}
|
|
7747
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
7748
|
+
prev.type = "globstar";
|
|
7749
|
+
prev.value += value;
|
|
7750
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
7751
|
+
state.output = prev.output;
|
|
7752
|
+
state.globstar = true;
|
|
7753
|
+
consume(value + advance());
|
|
7754
|
+
push({ type: "slash", value: "/", output: "" });
|
|
7755
|
+
continue;
|
|
7756
|
+
}
|
|
7757
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
7758
|
+
prev.type = "globstar";
|
|
7759
|
+
prev.output = globstar(opts);
|
|
7760
|
+
prev.value += value;
|
|
7761
|
+
state.output += prev.output;
|
|
7762
|
+
state.globstar = true;
|
|
7763
|
+
consume(value);
|
|
7764
|
+
continue;
|
|
7765
|
+
}
|
|
7766
|
+
const token = { type: "star", value, output: star };
|
|
7767
|
+
if (opts.bash === true) {
|
|
7768
|
+
token.output = ".*?";
|
|
7769
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
7770
|
+
token.output = nodot + token.output;
|
|
7771
|
+
}
|
|
7772
|
+
push(token);
|
|
7773
|
+
continue;
|
|
7774
|
+
}
|
|
7775
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
7776
|
+
token.output = value;
|
|
7777
|
+
push(token);
|
|
7778
|
+
continue;
|
|
7779
|
+
}
|
|
7780
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
7781
|
+
if (prev.type === "dot") {
|
|
7782
|
+
state.output += NO_DOT_SLASH;
|
|
7783
|
+
prev.output += NO_DOT_SLASH;
|
|
7784
|
+
} else if (opts.dot === true) {
|
|
7785
|
+
state.output += NO_DOTS_SLASH;
|
|
7786
|
+
prev.output += NO_DOTS_SLASH;
|
|
7787
|
+
} else {
|
|
7788
|
+
state.output += nodot;
|
|
7789
|
+
prev.output += nodot;
|
|
7790
|
+
}
|
|
7791
|
+
if (peek() !== "*") {
|
|
7792
|
+
state.output += ONE_CHAR;
|
|
7793
|
+
prev.output += ONE_CHAR;
|
|
7794
|
+
}
|
|
7795
|
+
}
|
|
7796
|
+
push(token);
|
|
7797
|
+
}
|
|
7798
|
+
while (state.brackets > 0) {
|
|
7799
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
7800
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
7801
|
+
decrement("brackets");
|
|
7802
|
+
}
|
|
7803
|
+
while (state.parens > 0) {
|
|
7804
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
7805
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
7806
|
+
decrement("parens");
|
|
7807
|
+
}
|
|
7808
|
+
while (state.braces > 0) {
|
|
7809
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
7810
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
7811
|
+
decrement("braces");
|
|
7812
|
+
}
|
|
7813
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
7814
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
7815
|
+
}
|
|
7816
|
+
if (state.backtrack === true) {
|
|
7817
|
+
state.output = "";
|
|
7818
|
+
for (const token of state.tokens) {
|
|
7819
|
+
state.output += token.output != null ? token.output : token.value;
|
|
7820
|
+
if (token.suffix) {
|
|
7821
|
+
state.output += token.suffix;
|
|
7822
|
+
}
|
|
7823
|
+
}
|
|
7824
|
+
}
|
|
7825
|
+
return state;
|
|
7826
|
+
};
|
|
7827
|
+
parse2.fastpaths = (input, options) => {
|
|
7828
|
+
const opts = { ...options };
|
|
7829
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
7830
|
+
const len = input.length;
|
|
7831
|
+
if (len > max) {
|
|
7832
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
7833
|
+
}
|
|
7834
|
+
input = REPLACEMENTS[input] || input;
|
|
7835
|
+
const {
|
|
7836
|
+
DOT_LITERAL,
|
|
7837
|
+
SLASH_LITERAL,
|
|
7838
|
+
ONE_CHAR,
|
|
7839
|
+
DOTS_SLASH,
|
|
7840
|
+
NO_DOT,
|
|
7841
|
+
NO_DOTS,
|
|
7842
|
+
NO_DOTS_SLASH,
|
|
7843
|
+
STAR,
|
|
7844
|
+
START_ANCHOR
|
|
7845
|
+
} = constants.globChars(opts.windows);
|
|
7846
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
7847
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
7848
|
+
const capture = opts.capture ? "" : "?:";
|
|
7849
|
+
const state = { negated: false, prefix: "" };
|
|
7850
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
7851
|
+
if (opts.capture) {
|
|
7852
|
+
star = `(${star})`;
|
|
7853
|
+
}
|
|
7854
|
+
const globstar = (opts2) => {
|
|
7855
|
+
if (opts2.noglobstar === true) return star;
|
|
7856
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
7857
|
+
};
|
|
7858
|
+
const create = (str) => {
|
|
7859
|
+
switch (str) {
|
|
7860
|
+
case "*":
|
|
7861
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
7862
|
+
case ".*":
|
|
7863
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
7864
|
+
case "*.*":
|
|
7865
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
7866
|
+
case "*/*":
|
|
7867
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
7868
|
+
case "**":
|
|
7869
|
+
return nodot + globstar(opts);
|
|
7870
|
+
case "**/*":
|
|
7871
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
7872
|
+
case "**/*.*":
|
|
7873
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
7874
|
+
case "**/.*":
|
|
7875
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
7876
|
+
default: {
|
|
7877
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
7878
|
+
if (!match) return;
|
|
7879
|
+
const source2 = create(match[1]);
|
|
7880
|
+
if (!source2) return;
|
|
7881
|
+
return source2 + DOT_LITERAL + match[2];
|
|
7882
|
+
}
|
|
7883
|
+
}
|
|
7884
|
+
};
|
|
7885
|
+
const output = utils.removePrefix(input, state);
|
|
7886
|
+
let source = create(output);
|
|
7887
|
+
if (source && opts.strictSlashes !== true) {
|
|
7888
|
+
source += `${SLASH_LITERAL}?`;
|
|
7889
|
+
}
|
|
7890
|
+
return source;
|
|
7891
|
+
};
|
|
7892
|
+
module2.exports = parse2;
|
|
7893
|
+
}
|
|
7894
|
+
});
|
|
7895
|
+
|
|
7896
|
+
// node_modules/picomatch/lib/picomatch.js
|
|
7897
|
+
var require_picomatch = __commonJS({
|
|
7898
|
+
"node_modules/picomatch/lib/picomatch.js"(exports2, module2) {
|
|
7899
|
+
"use strict";
|
|
7900
|
+
var scan2 = require_scan2();
|
|
7901
|
+
var parse2 = require_parse();
|
|
7902
|
+
var utils = require_utils5();
|
|
7903
|
+
var constants = require_constants();
|
|
7904
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
7905
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
7906
|
+
if (Array.isArray(glob)) {
|
|
7907
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
7908
|
+
const arrayMatcher = (str) => {
|
|
7909
|
+
for (const isMatch of fns) {
|
|
7910
|
+
const state2 = isMatch(str);
|
|
7911
|
+
if (state2) return state2;
|
|
7912
|
+
}
|
|
7913
|
+
return false;
|
|
7914
|
+
};
|
|
7915
|
+
return arrayMatcher;
|
|
7916
|
+
}
|
|
7917
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
7918
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
7919
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
7920
|
+
}
|
|
7921
|
+
const opts = options || {};
|
|
7922
|
+
const posix = opts.windows;
|
|
7923
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
7924
|
+
const state = regex.state;
|
|
7925
|
+
delete regex.state;
|
|
7926
|
+
let isIgnored = () => false;
|
|
7927
|
+
if (opts.ignore) {
|
|
7928
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
7929
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
7930
|
+
}
|
|
7931
|
+
const matcher = (input, returnObject = false) => {
|
|
7932
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
7933
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
7934
|
+
if (typeof opts.onResult === "function") {
|
|
7935
|
+
opts.onResult(result);
|
|
7936
|
+
}
|
|
7937
|
+
if (isMatch === false) {
|
|
7938
|
+
result.isMatch = false;
|
|
7939
|
+
return returnObject ? result : false;
|
|
7940
|
+
}
|
|
7941
|
+
if (isIgnored(input)) {
|
|
7942
|
+
if (typeof opts.onIgnore === "function") {
|
|
7943
|
+
opts.onIgnore(result);
|
|
7944
|
+
}
|
|
7945
|
+
result.isMatch = false;
|
|
7946
|
+
return returnObject ? result : false;
|
|
7947
|
+
}
|
|
7948
|
+
if (typeof opts.onMatch === "function") {
|
|
7949
|
+
opts.onMatch(result);
|
|
7950
|
+
}
|
|
7951
|
+
return returnObject ? result : true;
|
|
7952
|
+
};
|
|
7953
|
+
if (returnState) {
|
|
7954
|
+
matcher.state = state;
|
|
7955
|
+
}
|
|
7956
|
+
return matcher;
|
|
7957
|
+
};
|
|
7958
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
7959
|
+
if (typeof input !== "string") {
|
|
7960
|
+
throw new TypeError("Expected input to be a string");
|
|
7961
|
+
}
|
|
7962
|
+
if (input === "") {
|
|
7963
|
+
return { isMatch: false, output: "" };
|
|
7964
|
+
}
|
|
7965
|
+
const opts = options || {};
|
|
7966
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
7967
|
+
let match = input === glob;
|
|
7968
|
+
let output = match && format ? format(input) : input;
|
|
7969
|
+
if (match === false) {
|
|
7970
|
+
output = format ? format(input) : input;
|
|
7971
|
+
match = output === glob;
|
|
7972
|
+
}
|
|
7973
|
+
if (match === false || opts.capture === true) {
|
|
7974
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
7975
|
+
match = picomatch.matchBase(input, regex, options, posix);
|
|
7976
|
+
} else {
|
|
7977
|
+
match = regex.exec(output);
|
|
7978
|
+
}
|
|
7979
|
+
}
|
|
7980
|
+
return { isMatch: Boolean(match), match, output };
|
|
7981
|
+
};
|
|
7982
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
7983
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
7984
|
+
return regex.test(utils.basename(input));
|
|
7985
|
+
};
|
|
7986
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
7987
|
+
picomatch.parse = (pattern, options) => {
|
|
7988
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
7989
|
+
return parse2(pattern, { ...options, fastpaths: false });
|
|
7990
|
+
};
|
|
7991
|
+
picomatch.scan = (input, options) => scan2(input, options);
|
|
7992
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
7993
|
+
if (returnOutput === true) {
|
|
7994
|
+
return state.output;
|
|
7995
|
+
}
|
|
7996
|
+
const opts = options || {};
|
|
7997
|
+
const prepend = opts.contains ? "" : "^";
|
|
7998
|
+
const append = opts.contains ? "" : "$";
|
|
7999
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
8000
|
+
if (state && state.negated === true) {
|
|
8001
|
+
source = `^(?!${source}).*$`;
|
|
8002
|
+
}
|
|
8003
|
+
const regex = picomatch.toRegex(source, options);
|
|
8004
|
+
if (returnState === true) {
|
|
8005
|
+
regex.state = state;
|
|
8006
|
+
}
|
|
8007
|
+
return regex;
|
|
8008
|
+
};
|
|
8009
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
8010
|
+
if (!input || typeof input !== "string") {
|
|
8011
|
+
throw new TypeError("Expected a non-empty string");
|
|
8012
|
+
}
|
|
8013
|
+
let parsed = { negated: false, fastpaths: true };
|
|
8014
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
8015
|
+
parsed.output = parse2.fastpaths(input, options);
|
|
8016
|
+
}
|
|
8017
|
+
if (!parsed.output) {
|
|
8018
|
+
parsed = parse2(input, options);
|
|
8019
|
+
}
|
|
8020
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
8021
|
+
};
|
|
8022
|
+
picomatch.toRegex = (source, options) => {
|
|
8023
|
+
try {
|
|
8024
|
+
const opts = options || {};
|
|
8025
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
8026
|
+
} catch (err) {
|
|
8027
|
+
if (options && options.debug === true) throw err;
|
|
8028
|
+
return /$^/;
|
|
8029
|
+
}
|
|
8030
|
+
};
|
|
8031
|
+
picomatch.constants = constants;
|
|
8032
|
+
module2.exports = picomatch;
|
|
8033
|
+
}
|
|
8034
|
+
});
|
|
8035
|
+
|
|
8036
|
+
// node_modules/picomatch/index.js
|
|
8037
|
+
var require_picomatch2 = __commonJS({
|
|
8038
|
+
"node_modules/picomatch/index.js"(exports2, module2) {
|
|
8039
|
+
"use strict";
|
|
8040
|
+
var pico = require_picomatch();
|
|
8041
|
+
var utils = require_utils5();
|
|
8042
|
+
function picomatch(glob, options, returnState = false) {
|
|
8043
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
8044
|
+
options = { ...options, windows: utils.isWindows() };
|
|
8045
|
+
}
|
|
8046
|
+
return pico(glob, options, returnState);
|
|
8047
|
+
}
|
|
8048
|
+
Object.assign(picomatch, pico);
|
|
8049
|
+
module2.exports = picomatch;
|
|
8050
|
+
}
|
|
8051
|
+
});
|
|
8052
|
+
|
|
6303
8053
|
// src/publickeys.js
|
|
6304
8054
|
var require_publickeys = __commonJS({
|
|
6305
8055
|
"src/publickeys.js"(exports2, module2) {
|
|
@@ -6319,16 +8069,27 @@ var require_publickeys = __commonJS({
|
|
|
6319
8069
|
});
|
|
6320
8070
|
|
|
6321
8071
|
// src/parse.js
|
|
6322
|
-
var
|
|
8072
|
+
var require_parse2 = __commonJS({
|
|
6323
8073
|
"src/parse.js"(exports2, module2) {
|
|
6324
8074
|
var decrypt2 = require_decrypt();
|
|
8075
|
+
var Errors = require_errors();
|
|
6325
8076
|
var keyring2 = require_keyring();
|
|
6326
8077
|
var keyringSync2 = require_keyring().sync;
|
|
6327
8078
|
var encrypted2 = require_encrypted();
|
|
6328
8079
|
var evaluate2 = require_evaluate();
|
|
6329
8080
|
var expand2 = require_expand();
|
|
8081
|
+
var picomatch = require_picomatch2();
|
|
6330
8082
|
var publickeys2 = require_publickeys();
|
|
6331
8083
|
var scan2 = require_scan();
|
|
8084
|
+
function list(value) {
|
|
8085
|
+
if (value === void 0 || value === null) {
|
|
8086
|
+
return [];
|
|
8087
|
+
}
|
|
8088
|
+
if (!Array.isArray(value)) {
|
|
8089
|
+
return [value];
|
|
8090
|
+
}
|
|
8091
|
+
return value;
|
|
8092
|
+
}
|
|
6332
8093
|
function resolveEscapeSequences(value) {
|
|
6333
8094
|
return value.replace(/\\\$/g, "$");
|
|
6334
8095
|
}
|
|
@@ -6356,19 +8117,32 @@ var require_parse = __commonJS({
|
|
|
6356
8117
|
}
|
|
6357
8118
|
return value;
|
|
6358
8119
|
}
|
|
8120
|
+
function unresolvedEncryptedError(unresolved) {
|
|
8121
|
+
const keys = Object.keys(unresolved);
|
|
8122
|
+
if (keys.length === 0) {
|
|
8123
|
+
return null;
|
|
8124
|
+
}
|
|
8125
|
+
const error = new Errors({ message: `could not decrypt ${keys.join(", ")}` }).decryptionFailed();
|
|
8126
|
+
return {
|
|
8127
|
+
code: error.code,
|
|
8128
|
+
message: error.message
|
|
8129
|
+
};
|
|
8130
|
+
}
|
|
6359
8131
|
async function parse2(src, options = {}) {
|
|
6360
|
-
const { overload, array, processEnv, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
8132
|
+
const { overload, array, ik, ek, processEnv, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
6361
8133
|
const ring = await keyring2({ processEnv, ring: initialRing, fk, provider });
|
|
6362
|
-
return parseWithRing(src, { overload, array, processEnv, ring, publicKeyHexes });
|
|
8134
|
+
return parseWithRing(src, { overload, array, ik, ek, processEnv, ring, publicKeyHexes });
|
|
6363
8135
|
}
|
|
6364
8136
|
function parseSync2(src, options = {}) {
|
|
6365
|
-
const { overload, array, processEnv, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
8137
|
+
const { overload, array, ik, ek, processEnv, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
6366
8138
|
const ring = keyringSync2({ processEnv, ring: initialRing, fk, provider });
|
|
6367
|
-
return parseWithRing(src, { overload, array, processEnv, ring, publicKeyHexes });
|
|
8139
|
+
return parseWithRing(src, { overload, array, ik, ek, processEnv, ring, publicKeyHexes });
|
|
6368
8140
|
}
|
|
6369
8141
|
function keyringOptions(src, options = {}) {
|
|
6370
8142
|
const overload = options.overload;
|
|
6371
8143
|
const array = options.array;
|
|
8144
|
+
const ik = list(options.ik);
|
|
8145
|
+
const ek = list(options.ek);
|
|
6372
8146
|
const processEnv = options.processEnv || process.env;
|
|
6373
8147
|
const fk = options.fk;
|
|
6374
8148
|
const provider = options.provider;
|
|
@@ -6377,14 +8151,18 @@ var require_parse = __commonJS({
|
|
|
6377
8151
|
for (const publicKeyHex of publicKeyHexes) {
|
|
6378
8152
|
ring[publicKeyHex] = "";
|
|
6379
8153
|
}
|
|
6380
|
-
return { overload, array, processEnv, fk, provider, publicKeyHexes, ring };
|
|
8154
|
+
return { overload, array, ik, ek, processEnv, fk, provider, publicKeyHexes, ring };
|
|
6381
8155
|
}
|
|
6382
8156
|
function parseWithRing(src, options = {}) {
|
|
6383
8157
|
const overload = options.overload;
|
|
6384
8158
|
const array = options.array;
|
|
8159
|
+
const ik = options.ik || [];
|
|
8160
|
+
const ek = options.ek || [];
|
|
6385
8161
|
const processEnv = options.processEnv || process.env;
|
|
6386
8162
|
const ring = options.ring || {};
|
|
6387
8163
|
const publicKeyHexes = options.publicKeyHexes || [];
|
|
8164
|
+
const include = picomatch(ik, { ignore: ek });
|
|
8165
|
+
const exclude = picomatch(ek);
|
|
6388
8166
|
function inProcessEnv(name) {
|
|
6389
8167
|
return Object.prototype.hasOwnProperty.call(processEnv, name);
|
|
6390
8168
|
}
|
|
@@ -6393,12 +8171,19 @@ var require_parse = __commonJS({
|
|
|
6393
8171
|
const parsed = {};
|
|
6394
8172
|
const injected = {};
|
|
6395
8173
|
const existed = {};
|
|
8174
|
+
const unresolvedEncrypted = {};
|
|
6396
8175
|
scan2(src, ({ name, value, quote }) => {
|
|
6397
8176
|
let parsedValue = value;
|
|
6398
8177
|
if (!overload && inProcessEnv(name)) {
|
|
6399
8178
|
parsedValue = processEnv[name];
|
|
6400
8179
|
}
|
|
6401
|
-
|
|
8180
|
+
const encryptedBefore = encrypted2(parsedValue);
|
|
8181
|
+
if (!exclude(name) && (ik.length === 0 || include(name))) {
|
|
8182
|
+
parsedValue = decryptWithKeyring(ring, parsedValue, publicKeyHexes);
|
|
8183
|
+
if (encryptedBefore && encrypted2(parsedValue)) {
|
|
8184
|
+
unresolvedEncrypted[name] = true;
|
|
8185
|
+
}
|
|
8186
|
+
}
|
|
6402
8187
|
const encryptedPrefixed = encrypted2(parsedValue);
|
|
6403
8188
|
let evaled = false;
|
|
6404
8189
|
if (!encryptedPrefixed && quote !== "'" && (!inProcessEnv(name) || processEnv[name] === parsedValue)) {
|
|
@@ -6441,10 +8226,16 @@ var require_parse = __commonJS({
|
|
|
6441
8226
|
}
|
|
6442
8227
|
return parsedValue;
|
|
6443
8228
|
});
|
|
8229
|
+
const errors = [];
|
|
8230
|
+
const error = unresolvedEncryptedError(unresolvedEncrypted);
|
|
8231
|
+
if (error) {
|
|
8232
|
+
errors.push(error);
|
|
8233
|
+
}
|
|
6444
8234
|
return {
|
|
6445
8235
|
parsed,
|
|
6446
8236
|
injected,
|
|
6447
|
-
existed
|
|
8237
|
+
existed,
|
|
8238
|
+
errors
|
|
6448
8239
|
};
|
|
6449
8240
|
}
|
|
6450
8241
|
module2.exports = parse2;
|
|
@@ -6547,8 +8338,8 @@ var expand = require_expand();
|
|
|
6547
8338
|
var keypair = require_keypair();
|
|
6548
8339
|
var keyring = require_keyring();
|
|
6549
8340
|
var keyringSync = require_keyring().sync;
|
|
6550
|
-
var parse =
|
|
6551
|
-
var parseSync =
|
|
8341
|
+
var parse = require_parse2();
|
|
8342
|
+
var parseSync = require_parse2().sync;
|
|
6552
8343
|
var publickeys = require_publickeys();
|
|
6553
8344
|
var scan = require_scan();
|
|
6554
8345
|
var sealed = require_sealed();
|