@dotenvx/next-env 2.1.2 → 2.2.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 +1979 -51
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5965,8 +5965,8 @@ var require_dist = __commonJS({
|
|
|
5965
5965
|
const processEnv2 = options.processEnv || process.env;
|
|
5966
5966
|
const runningParsed = options.runningParsed || {};
|
|
5967
5967
|
const matches = value.match(/\$\(([^)]+(?:\)[^(]*)*)\)/g) || [];
|
|
5968
|
-
return matches.reduce((newValue,
|
|
5969
|
-
const command =
|
|
5968
|
+
return matches.reduce((newValue, match2) => {
|
|
5969
|
+
const command = match2.slice(2, -1);
|
|
5970
5970
|
let result;
|
|
5971
5971
|
try {
|
|
5972
5972
|
result = execSync(command, { env: { ...processEnv2, ...runningParsed } }).toString();
|
|
@@ -5974,7 +5974,7 @@ var require_dist = __commonJS({
|
|
|
5974
5974
|
throw new Errors({ command, message: e.message.trim() }).commandSubstitutionFailed();
|
|
5975
5975
|
}
|
|
5976
5976
|
result = chomp(result);
|
|
5977
|
-
return newValue.replace(
|
|
5977
|
+
return newValue.replace(match2, result);
|
|
5978
5978
|
}, value);
|
|
5979
5979
|
}
|
|
5980
5980
|
module22.exports = evaluate2;
|
|
@@ -5993,29 +5993,30 @@ var require_dist = __commonJS({
|
|
|
5993
5993
|
}
|
|
5994
5994
|
const regex = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
5995
5995
|
let result = value;
|
|
5996
|
-
let
|
|
5997
|
-
while ((
|
|
5998
|
-
const [template, bracedExpression, unbracedExpression] =
|
|
5996
|
+
let match2;
|
|
5997
|
+
while ((match2 = regex.exec(result)) !== null) {
|
|
5998
|
+
const [template, bracedExpression, unbracedExpression] = match2;
|
|
5999
5999
|
const expression = bracedExpression || unbracedExpression;
|
|
6000
6000
|
const opRegex = /(:\+|\+|:-|-)/;
|
|
6001
6001
|
const opMatch = expression.match(opRegex);
|
|
6002
6002
|
const splitter = opMatch ? opMatch[0] : null;
|
|
6003
6003
|
const r = expression.split(splitter);
|
|
6004
|
-
let defaultValue;
|
|
6005
|
-
let value2;
|
|
6006
6004
|
const name = r.shift();
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6005
|
+
const rest = r.join(splitter);
|
|
6006
|
+
const hasValue = Object.prototype.hasOwnProperty.call(env, name);
|
|
6007
|
+
let replacementValue;
|
|
6008
|
+
if (splitter === ":-") {
|
|
6009
|
+
replacementValue = env[name] || rest;
|
|
6010
|
+
} else if (splitter === "-") {
|
|
6011
|
+
replacementValue = hasValue ? env[name] : rest;
|
|
6012
|
+
} else if (splitter === ":+") {
|
|
6013
|
+
replacementValue = env[name] ? rest : "";
|
|
6014
|
+
} else if (splitter === "+") {
|
|
6015
|
+
replacementValue = hasValue ? rest : "";
|
|
6010
6016
|
} else {
|
|
6011
|
-
|
|
6012
|
-
value2 = env[name];
|
|
6013
|
-
}
|
|
6014
|
-
if (value2) {
|
|
6015
|
-
result = result.replace(template, value2);
|
|
6016
|
-
} else {
|
|
6017
|
-
result = result.replace(template, defaultValue);
|
|
6017
|
+
replacementValue = env[name] || "";
|
|
6018
6018
|
}
|
|
6019
|
+
result = result.replace(template, replacementValue);
|
|
6019
6020
|
if (result === env[name]) {
|
|
6020
6021
|
break;
|
|
6021
6022
|
}
|
|
@@ -6032,7 +6033,14 @@ var require_dist = __commonJS({
|
|
|
6032
6033
|
var require_keypair = __commonJS2({
|
|
6033
6034
|
"src/keypair.js"(exports22, module22) {
|
|
6034
6035
|
var { PrivateKey } = require_dist2();
|
|
6035
|
-
|
|
6036
|
+
var derive2 = require_derive();
|
|
6037
|
+
function keypair2(privateKey) {
|
|
6038
|
+
if (privateKey) {
|
|
6039
|
+
return {
|
|
6040
|
+
publicKey: derive2(privateKey),
|
|
6041
|
+
privateKey
|
|
6042
|
+
};
|
|
6043
|
+
}
|
|
6036
6044
|
const kp = new PrivateKey();
|
|
6037
6045
|
return {
|
|
6038
6046
|
publicKey: kp.publicKey.toHex(),
|
|
@@ -6042,8 +6050,1765 @@ var require_dist = __commonJS({
|
|
|
6042
6050
|
module22.exports = keypair2;
|
|
6043
6051
|
}
|
|
6044
6052
|
});
|
|
6053
|
+
var require_constants = __commonJS2({
|
|
6054
|
+
"node_modules/picomatch/lib/constants.js"(exports22, module22) {
|
|
6055
|
+
"use strict";
|
|
6056
|
+
var WIN_SLASH = "\\\\/";
|
|
6057
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
6058
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
6059
|
+
var DOT_LITERAL = "\\.";
|
|
6060
|
+
var PLUS_LITERAL = "\\+";
|
|
6061
|
+
var QMARK_LITERAL = "\\?";
|
|
6062
|
+
var SLASH_LITERAL = "\\/";
|
|
6063
|
+
var ONE_CHAR = "(?=.)";
|
|
6064
|
+
var QMARK = "[^/]";
|
|
6065
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
6066
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
6067
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
6068
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
6069
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
6070
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
6071
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
6072
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
6073
|
+
var STAR = `${QMARK}*?`;
|
|
6074
|
+
var SEP = "/";
|
|
6075
|
+
var POSIX_CHARS = {
|
|
6076
|
+
DOT_LITERAL,
|
|
6077
|
+
PLUS_LITERAL,
|
|
6078
|
+
QMARK_LITERAL,
|
|
6079
|
+
SLASH_LITERAL,
|
|
6080
|
+
ONE_CHAR,
|
|
6081
|
+
QMARK,
|
|
6082
|
+
END_ANCHOR,
|
|
6083
|
+
DOTS_SLASH,
|
|
6084
|
+
NO_DOT,
|
|
6085
|
+
NO_DOTS,
|
|
6086
|
+
NO_DOT_SLASH,
|
|
6087
|
+
NO_DOTS_SLASH,
|
|
6088
|
+
QMARK_NO_DOT,
|
|
6089
|
+
STAR,
|
|
6090
|
+
START_ANCHOR,
|
|
6091
|
+
SEP
|
|
6092
|
+
};
|
|
6093
|
+
var WINDOWS_CHARS = {
|
|
6094
|
+
...POSIX_CHARS,
|
|
6095
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
6096
|
+
QMARK: WIN_NO_SLASH,
|
|
6097
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
6098
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
6099
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
6100
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
6101
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
6102
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
6103
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
6104
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
6105
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
6106
|
+
SEP: "\\"
|
|
6107
|
+
};
|
|
6108
|
+
var POSIX_REGEX_SOURCE = {
|
|
6109
|
+
__proto__: null,
|
|
6110
|
+
alnum: "a-zA-Z0-9",
|
|
6111
|
+
alpha: "a-zA-Z",
|
|
6112
|
+
ascii: "\\x00-\\x7F",
|
|
6113
|
+
blank: " \\t",
|
|
6114
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
6115
|
+
digit: "0-9",
|
|
6116
|
+
graph: "\\x21-\\x7E",
|
|
6117
|
+
lower: "a-z",
|
|
6118
|
+
print: "\\x20-\\x7E ",
|
|
6119
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
6120
|
+
space: " \\t\\r\\n\\v\\f",
|
|
6121
|
+
upper: "A-Z",
|
|
6122
|
+
word: "A-Za-z0-9_",
|
|
6123
|
+
xdigit: "A-Fa-f0-9"
|
|
6124
|
+
};
|
|
6125
|
+
module22.exports = {
|
|
6126
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
6127
|
+
MAX_LENGTH: 1024 * 64,
|
|
6128
|
+
POSIX_REGEX_SOURCE,
|
|
6129
|
+
// regular expressions
|
|
6130
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
6131
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
6132
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
6133
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
6134
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
6135
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
6136
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
6137
|
+
REPLACEMENTS: {
|
|
6138
|
+
__proto__: null,
|
|
6139
|
+
"***": "*",
|
|
6140
|
+
"**/**": "**",
|
|
6141
|
+
"**/**/**": "**"
|
|
6142
|
+
},
|
|
6143
|
+
// Digits
|
|
6144
|
+
CHAR_0: 48,
|
|
6145
|
+
/* 0 */
|
|
6146
|
+
CHAR_9: 57,
|
|
6147
|
+
/* 9 */
|
|
6148
|
+
// Alphabet chars.
|
|
6149
|
+
CHAR_UPPERCASE_A: 65,
|
|
6150
|
+
/* A */
|
|
6151
|
+
CHAR_LOWERCASE_A: 97,
|
|
6152
|
+
/* a */
|
|
6153
|
+
CHAR_UPPERCASE_Z: 90,
|
|
6154
|
+
/* Z */
|
|
6155
|
+
CHAR_LOWERCASE_Z: 122,
|
|
6156
|
+
/* z */
|
|
6157
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
6158
|
+
/* ( */
|
|
6159
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
6160
|
+
/* ) */
|
|
6161
|
+
CHAR_ASTERISK: 42,
|
|
6162
|
+
/* * */
|
|
6163
|
+
// Non-alphabetic chars.
|
|
6164
|
+
CHAR_AMPERSAND: 38,
|
|
6165
|
+
/* & */
|
|
6166
|
+
CHAR_AT: 64,
|
|
6167
|
+
/* @ */
|
|
6168
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
6169
|
+
/* \ */
|
|
6170
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
6171
|
+
/* \r */
|
|
6172
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
6173
|
+
/* ^ */
|
|
6174
|
+
CHAR_COLON: 58,
|
|
6175
|
+
/* : */
|
|
6176
|
+
CHAR_COMMA: 44,
|
|
6177
|
+
/* , */
|
|
6178
|
+
CHAR_DOT: 46,
|
|
6179
|
+
/* . */
|
|
6180
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
6181
|
+
/* " */
|
|
6182
|
+
CHAR_EQUAL: 61,
|
|
6183
|
+
/* = */
|
|
6184
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
6185
|
+
/* ! */
|
|
6186
|
+
CHAR_FORM_FEED: 12,
|
|
6187
|
+
/* \f */
|
|
6188
|
+
CHAR_FORWARD_SLASH: 47,
|
|
6189
|
+
/* / */
|
|
6190
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
6191
|
+
/* ` */
|
|
6192
|
+
CHAR_HASH: 35,
|
|
6193
|
+
/* # */
|
|
6194
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
6195
|
+
/* - */
|
|
6196
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
6197
|
+
/* < */
|
|
6198
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
6199
|
+
/* { */
|
|
6200
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
6201
|
+
/* [ */
|
|
6202
|
+
CHAR_LINE_FEED: 10,
|
|
6203
|
+
/* \n */
|
|
6204
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
6205
|
+
/* \u00A0 */
|
|
6206
|
+
CHAR_PERCENT: 37,
|
|
6207
|
+
/* % */
|
|
6208
|
+
CHAR_PLUS: 43,
|
|
6209
|
+
/* + */
|
|
6210
|
+
CHAR_QUESTION_MARK: 63,
|
|
6211
|
+
/* ? */
|
|
6212
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
6213
|
+
/* > */
|
|
6214
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
6215
|
+
/* } */
|
|
6216
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
6217
|
+
/* ] */
|
|
6218
|
+
CHAR_SEMICOLON: 59,
|
|
6219
|
+
/* ; */
|
|
6220
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
6221
|
+
/* ' */
|
|
6222
|
+
CHAR_SPACE: 32,
|
|
6223
|
+
/* */
|
|
6224
|
+
CHAR_TAB: 9,
|
|
6225
|
+
/* \t */
|
|
6226
|
+
CHAR_UNDERSCORE: 95,
|
|
6227
|
+
/* _ */
|
|
6228
|
+
CHAR_VERTICAL_LINE: 124,
|
|
6229
|
+
/* | */
|
|
6230
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
6231
|
+
/* \uFEFF */
|
|
6232
|
+
/**
|
|
6233
|
+
* Create EXTGLOB_CHARS
|
|
6234
|
+
*/
|
|
6235
|
+
extglobChars(chars) {
|
|
6236
|
+
return {
|
|
6237
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
6238
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
6239
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
6240
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
6241
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
6242
|
+
};
|
|
6243
|
+
},
|
|
6244
|
+
/**
|
|
6245
|
+
* Create GLOB_CHARS
|
|
6246
|
+
*/
|
|
6247
|
+
globChars(win32) {
|
|
6248
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
6249
|
+
}
|
|
6250
|
+
};
|
|
6251
|
+
}
|
|
6252
|
+
});
|
|
6253
|
+
var require_utils5 = __commonJS2({
|
|
6254
|
+
"node_modules/picomatch/lib/utils.js"(exports22) {
|
|
6255
|
+
"use strict";
|
|
6256
|
+
var {
|
|
6257
|
+
REGEX_BACKSLASH,
|
|
6258
|
+
REGEX_REMOVE_BACKSLASH,
|
|
6259
|
+
REGEX_SPECIAL_CHARS,
|
|
6260
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
6261
|
+
} = require_constants();
|
|
6262
|
+
exports22.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
6263
|
+
exports22.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
6264
|
+
exports22.isRegexChar = (str) => str.length === 1 && exports22.hasRegexChars(str);
|
|
6265
|
+
exports22.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
6266
|
+
exports22.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
6267
|
+
exports22.isWindows = () => {
|
|
6268
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
6269
|
+
const platform = navigator.platform.toLowerCase();
|
|
6270
|
+
return platform === "win32" || platform === "windows";
|
|
6271
|
+
}
|
|
6272
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
6273
|
+
return process.platform === "win32";
|
|
6274
|
+
}
|
|
6275
|
+
return false;
|
|
6276
|
+
};
|
|
6277
|
+
exports22.removeBackslashes = (str) => {
|
|
6278
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match2) => {
|
|
6279
|
+
return match2 === "\\" ? "" : match2;
|
|
6280
|
+
});
|
|
6281
|
+
};
|
|
6282
|
+
exports22.escapeLast = (input, char, lastIdx) => {
|
|
6283
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
6284
|
+
if (idx === -1) return input;
|
|
6285
|
+
if (input[idx - 1] === "\\") return exports22.escapeLast(input, char, idx - 1);
|
|
6286
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
6287
|
+
};
|
|
6288
|
+
exports22.removePrefix = (input, state = {}) => {
|
|
6289
|
+
let output = input;
|
|
6290
|
+
if (output.startsWith("./")) {
|
|
6291
|
+
output = output.slice(2);
|
|
6292
|
+
state.prefix = "./";
|
|
6293
|
+
}
|
|
6294
|
+
return output;
|
|
6295
|
+
};
|
|
6296
|
+
exports22.wrapOutput = (input, state = {}, options = {}) => {
|
|
6297
|
+
const prepend = options.contains ? "" : "^";
|
|
6298
|
+
const append = options.contains ? "" : "$";
|
|
6299
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
6300
|
+
if (state.negated === true) {
|
|
6301
|
+
output = `(?:^(?!${output}).*$)`;
|
|
6302
|
+
}
|
|
6303
|
+
return output;
|
|
6304
|
+
};
|
|
6305
|
+
exports22.basename = (path2, { windows } = {}) => {
|
|
6306
|
+
const segs = path2.split(windows ? /[\\/]/ : "/");
|
|
6307
|
+
const last = segs[segs.length - 1];
|
|
6308
|
+
if (last === "") {
|
|
6309
|
+
return segs[segs.length - 2];
|
|
6310
|
+
}
|
|
6311
|
+
return last;
|
|
6312
|
+
};
|
|
6313
|
+
}
|
|
6314
|
+
});
|
|
6045
6315
|
var require_scan = __commonJS2({
|
|
6316
|
+
"node_modules/picomatch/lib/scan.js"(exports22, module22) {
|
|
6317
|
+
"use strict";
|
|
6318
|
+
var utils = require_utils5();
|
|
6319
|
+
var {
|
|
6320
|
+
CHAR_ASTERISK,
|
|
6321
|
+
/* * */
|
|
6322
|
+
CHAR_AT,
|
|
6323
|
+
/* @ */
|
|
6324
|
+
CHAR_BACKWARD_SLASH,
|
|
6325
|
+
/* \ */
|
|
6326
|
+
CHAR_COMMA,
|
|
6327
|
+
/* , */
|
|
6328
|
+
CHAR_DOT,
|
|
6329
|
+
/* . */
|
|
6330
|
+
CHAR_EXCLAMATION_MARK,
|
|
6331
|
+
/* ! */
|
|
6332
|
+
CHAR_FORWARD_SLASH,
|
|
6333
|
+
/* / */
|
|
6334
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
6335
|
+
/* { */
|
|
6336
|
+
CHAR_LEFT_PARENTHESES,
|
|
6337
|
+
/* ( */
|
|
6338
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
6339
|
+
/* [ */
|
|
6340
|
+
CHAR_PLUS,
|
|
6341
|
+
/* + */
|
|
6342
|
+
CHAR_QUESTION_MARK,
|
|
6343
|
+
/* ? */
|
|
6344
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
6345
|
+
/* } */
|
|
6346
|
+
CHAR_RIGHT_PARENTHESES,
|
|
6347
|
+
/* ) */
|
|
6348
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
6349
|
+
/* ] */
|
|
6350
|
+
} = require_constants();
|
|
6351
|
+
var isPathSeparator = (code) => {
|
|
6352
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
6353
|
+
};
|
|
6354
|
+
var depth = (token) => {
|
|
6355
|
+
if (token.isPrefix !== true) {
|
|
6356
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
6357
|
+
}
|
|
6358
|
+
};
|
|
6359
|
+
var scan2 = (input, options) => {
|
|
6360
|
+
const opts = options || {};
|
|
6361
|
+
const length = input.length - 1;
|
|
6362
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
6363
|
+
const slashes = [];
|
|
6364
|
+
const tokens = [];
|
|
6365
|
+
const parts = [];
|
|
6366
|
+
let str = input;
|
|
6367
|
+
let index = -1;
|
|
6368
|
+
let start = 0;
|
|
6369
|
+
let lastIndex = 0;
|
|
6370
|
+
let isBrace = false;
|
|
6371
|
+
let isBracket = false;
|
|
6372
|
+
let isGlob = false;
|
|
6373
|
+
let isExtglob = false;
|
|
6374
|
+
let isGlobstar = false;
|
|
6375
|
+
let braceEscaped = false;
|
|
6376
|
+
let backslashes = false;
|
|
6377
|
+
let negated = false;
|
|
6378
|
+
let negatedExtglob = false;
|
|
6379
|
+
let finished = false;
|
|
6380
|
+
let braces = 0;
|
|
6381
|
+
let prev;
|
|
6382
|
+
let code;
|
|
6383
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
6384
|
+
const eos = () => index >= length;
|
|
6385
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
6386
|
+
const advance = () => {
|
|
6387
|
+
prev = code;
|
|
6388
|
+
return str.charCodeAt(++index);
|
|
6389
|
+
};
|
|
6390
|
+
while (index < length) {
|
|
6391
|
+
code = advance();
|
|
6392
|
+
let next;
|
|
6393
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
6394
|
+
backslashes = token.backslashes = true;
|
|
6395
|
+
code = advance();
|
|
6396
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
6397
|
+
braceEscaped = true;
|
|
6398
|
+
}
|
|
6399
|
+
continue;
|
|
6400
|
+
}
|
|
6401
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
6402
|
+
braces++;
|
|
6403
|
+
while (eos() !== true && (code = advance())) {
|
|
6404
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
6405
|
+
backslashes = token.backslashes = true;
|
|
6406
|
+
advance();
|
|
6407
|
+
continue;
|
|
6408
|
+
}
|
|
6409
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
6410
|
+
braces++;
|
|
6411
|
+
continue;
|
|
6412
|
+
}
|
|
6413
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
6414
|
+
isBrace = token.isBrace = true;
|
|
6415
|
+
isGlob = token.isGlob = true;
|
|
6416
|
+
finished = true;
|
|
6417
|
+
if (scanToEnd === true) {
|
|
6418
|
+
continue;
|
|
6419
|
+
}
|
|
6420
|
+
break;
|
|
6421
|
+
}
|
|
6422
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
6423
|
+
isBrace = token.isBrace = true;
|
|
6424
|
+
isGlob = token.isGlob = true;
|
|
6425
|
+
finished = true;
|
|
6426
|
+
if (scanToEnd === true) {
|
|
6427
|
+
continue;
|
|
6428
|
+
}
|
|
6429
|
+
break;
|
|
6430
|
+
}
|
|
6431
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
6432
|
+
braces--;
|
|
6433
|
+
if (braces === 0) {
|
|
6434
|
+
braceEscaped = false;
|
|
6435
|
+
isBrace = token.isBrace = true;
|
|
6436
|
+
finished = true;
|
|
6437
|
+
break;
|
|
6438
|
+
}
|
|
6439
|
+
}
|
|
6440
|
+
}
|
|
6441
|
+
if (scanToEnd === true) {
|
|
6442
|
+
continue;
|
|
6443
|
+
}
|
|
6444
|
+
break;
|
|
6445
|
+
}
|
|
6446
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
6447
|
+
slashes.push(index);
|
|
6448
|
+
tokens.push(token);
|
|
6449
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
6450
|
+
if (finished === true) continue;
|
|
6451
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
6452
|
+
start += 2;
|
|
6453
|
+
continue;
|
|
6454
|
+
}
|
|
6455
|
+
lastIndex = index + 1;
|
|
6456
|
+
continue;
|
|
6457
|
+
}
|
|
6458
|
+
if (opts.noext !== true) {
|
|
6459
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
6460
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
6461
|
+
isGlob = token.isGlob = true;
|
|
6462
|
+
isExtglob = token.isExtglob = true;
|
|
6463
|
+
finished = true;
|
|
6464
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
6465
|
+
negatedExtglob = true;
|
|
6466
|
+
}
|
|
6467
|
+
if (scanToEnd === true) {
|
|
6468
|
+
while (eos() !== true && (code = advance())) {
|
|
6469
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
6470
|
+
backslashes = token.backslashes = true;
|
|
6471
|
+
code = advance();
|
|
6472
|
+
continue;
|
|
6473
|
+
}
|
|
6474
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
6475
|
+
isGlob = token.isGlob = true;
|
|
6476
|
+
finished = true;
|
|
6477
|
+
break;
|
|
6478
|
+
}
|
|
6479
|
+
}
|
|
6480
|
+
continue;
|
|
6481
|
+
}
|
|
6482
|
+
break;
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
if (code === CHAR_ASTERISK) {
|
|
6486
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
6487
|
+
isGlob = token.isGlob = true;
|
|
6488
|
+
finished = true;
|
|
6489
|
+
if (scanToEnd === true) {
|
|
6490
|
+
continue;
|
|
6491
|
+
}
|
|
6492
|
+
break;
|
|
6493
|
+
}
|
|
6494
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
6495
|
+
isGlob = token.isGlob = true;
|
|
6496
|
+
finished = true;
|
|
6497
|
+
if (scanToEnd === true) {
|
|
6498
|
+
continue;
|
|
6499
|
+
}
|
|
6500
|
+
break;
|
|
6501
|
+
}
|
|
6502
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
6503
|
+
while (eos() !== true && (next = advance())) {
|
|
6504
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
6505
|
+
backslashes = token.backslashes = true;
|
|
6506
|
+
advance();
|
|
6507
|
+
continue;
|
|
6508
|
+
}
|
|
6509
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
6510
|
+
isBracket = token.isBracket = true;
|
|
6511
|
+
isGlob = token.isGlob = true;
|
|
6512
|
+
finished = true;
|
|
6513
|
+
break;
|
|
6514
|
+
}
|
|
6515
|
+
}
|
|
6516
|
+
if (scanToEnd === true) {
|
|
6517
|
+
continue;
|
|
6518
|
+
}
|
|
6519
|
+
break;
|
|
6520
|
+
}
|
|
6521
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
6522
|
+
negated = token.negated = true;
|
|
6523
|
+
start++;
|
|
6524
|
+
continue;
|
|
6525
|
+
}
|
|
6526
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
6527
|
+
isGlob = token.isGlob = true;
|
|
6528
|
+
if (scanToEnd === true) {
|
|
6529
|
+
while (eos() !== true && (code = advance())) {
|
|
6530
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
6531
|
+
backslashes = token.backslashes = true;
|
|
6532
|
+
code = advance();
|
|
6533
|
+
continue;
|
|
6534
|
+
}
|
|
6535
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
6536
|
+
finished = true;
|
|
6537
|
+
break;
|
|
6538
|
+
}
|
|
6539
|
+
}
|
|
6540
|
+
continue;
|
|
6541
|
+
}
|
|
6542
|
+
break;
|
|
6543
|
+
}
|
|
6544
|
+
if (isGlob === true) {
|
|
6545
|
+
finished = true;
|
|
6546
|
+
if (scanToEnd === true) {
|
|
6547
|
+
continue;
|
|
6548
|
+
}
|
|
6549
|
+
break;
|
|
6550
|
+
}
|
|
6551
|
+
}
|
|
6552
|
+
if (opts.noext === true) {
|
|
6553
|
+
isExtglob = false;
|
|
6554
|
+
isGlob = false;
|
|
6555
|
+
}
|
|
6556
|
+
let base = str;
|
|
6557
|
+
let prefix = "";
|
|
6558
|
+
let glob = "";
|
|
6559
|
+
if (start > 0) {
|
|
6560
|
+
prefix = str.slice(0, start);
|
|
6561
|
+
str = str.slice(start);
|
|
6562
|
+
lastIndex -= start;
|
|
6563
|
+
}
|
|
6564
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
6565
|
+
base = str.slice(0, lastIndex);
|
|
6566
|
+
glob = str.slice(lastIndex);
|
|
6567
|
+
} else if (isGlob === true) {
|
|
6568
|
+
base = "";
|
|
6569
|
+
glob = str;
|
|
6570
|
+
} else {
|
|
6571
|
+
base = str;
|
|
6572
|
+
}
|
|
6573
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
6574
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
6575
|
+
base = base.slice(0, -1);
|
|
6576
|
+
}
|
|
6577
|
+
}
|
|
6578
|
+
if (opts.unescape === true) {
|
|
6579
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
6580
|
+
if (base && backslashes === true) {
|
|
6581
|
+
base = utils.removeBackslashes(base);
|
|
6582
|
+
}
|
|
6583
|
+
}
|
|
6584
|
+
const state = {
|
|
6585
|
+
prefix,
|
|
6586
|
+
input,
|
|
6587
|
+
start,
|
|
6588
|
+
base,
|
|
6589
|
+
glob,
|
|
6590
|
+
isBrace,
|
|
6591
|
+
isBracket,
|
|
6592
|
+
isGlob,
|
|
6593
|
+
isExtglob,
|
|
6594
|
+
isGlobstar,
|
|
6595
|
+
negated,
|
|
6596
|
+
negatedExtglob
|
|
6597
|
+
};
|
|
6598
|
+
if (opts.tokens === true) {
|
|
6599
|
+
state.maxDepth = 0;
|
|
6600
|
+
if (!isPathSeparator(code)) {
|
|
6601
|
+
tokens.push(token);
|
|
6602
|
+
}
|
|
6603
|
+
state.tokens = tokens;
|
|
6604
|
+
}
|
|
6605
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
6606
|
+
let prevIndex;
|
|
6607
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
6608
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
6609
|
+
const i = slashes[idx];
|
|
6610
|
+
const value = input.slice(n, i);
|
|
6611
|
+
if (opts.tokens) {
|
|
6612
|
+
if (idx === 0 && start !== 0) {
|
|
6613
|
+
tokens[idx].isPrefix = true;
|
|
6614
|
+
tokens[idx].value = prefix;
|
|
6615
|
+
} else {
|
|
6616
|
+
tokens[idx].value = value;
|
|
6617
|
+
}
|
|
6618
|
+
depth(tokens[idx]);
|
|
6619
|
+
state.maxDepth += tokens[idx].depth;
|
|
6620
|
+
}
|
|
6621
|
+
if (idx !== 0 || value !== "") {
|
|
6622
|
+
parts.push(value);
|
|
6623
|
+
}
|
|
6624
|
+
prevIndex = i;
|
|
6625
|
+
}
|
|
6626
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
6627
|
+
const value = input.slice(prevIndex + 1);
|
|
6628
|
+
parts.push(value);
|
|
6629
|
+
if (opts.tokens) {
|
|
6630
|
+
tokens[tokens.length - 1].value = value;
|
|
6631
|
+
depth(tokens[tokens.length - 1]);
|
|
6632
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
6635
|
+
state.slashes = slashes;
|
|
6636
|
+
state.parts = parts;
|
|
6637
|
+
}
|
|
6638
|
+
return state;
|
|
6639
|
+
};
|
|
6640
|
+
module22.exports = scan2;
|
|
6641
|
+
}
|
|
6642
|
+
});
|
|
6643
|
+
var require_parse = __commonJS2({
|
|
6644
|
+
"node_modules/picomatch/lib/parse.js"(exports22, module22) {
|
|
6645
|
+
"use strict";
|
|
6646
|
+
var constants = require_constants();
|
|
6647
|
+
var utils = require_utils5();
|
|
6648
|
+
var {
|
|
6649
|
+
MAX_LENGTH,
|
|
6650
|
+
POSIX_REGEX_SOURCE,
|
|
6651
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
6652
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
6653
|
+
REPLACEMENTS
|
|
6654
|
+
} = constants;
|
|
6655
|
+
var expandRange = (args, options) => {
|
|
6656
|
+
if (typeof options.expandRange === "function") {
|
|
6657
|
+
return options.expandRange(...args, options);
|
|
6658
|
+
}
|
|
6659
|
+
args.sort();
|
|
6660
|
+
const value = `[${args.join("-")}]`;
|
|
6661
|
+
try {
|
|
6662
|
+
new RegExp(value);
|
|
6663
|
+
} catch (ex) {
|
|
6664
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
6665
|
+
}
|
|
6666
|
+
return value;
|
|
6667
|
+
};
|
|
6668
|
+
var syntaxError = (type, char) => {
|
|
6669
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
6670
|
+
};
|
|
6671
|
+
var splitTopLevel = (input) => {
|
|
6672
|
+
const parts = [];
|
|
6673
|
+
let bracket = 0;
|
|
6674
|
+
let paren = 0;
|
|
6675
|
+
let quote = 0;
|
|
6676
|
+
let value = "";
|
|
6677
|
+
let escaped = false;
|
|
6678
|
+
for (const ch of input) {
|
|
6679
|
+
if (escaped === true) {
|
|
6680
|
+
value += ch;
|
|
6681
|
+
escaped = false;
|
|
6682
|
+
continue;
|
|
6683
|
+
}
|
|
6684
|
+
if (ch === "\\") {
|
|
6685
|
+
value += ch;
|
|
6686
|
+
escaped = true;
|
|
6687
|
+
continue;
|
|
6688
|
+
}
|
|
6689
|
+
if (ch === '"') {
|
|
6690
|
+
quote = quote === 1 ? 0 : 1;
|
|
6691
|
+
value += ch;
|
|
6692
|
+
continue;
|
|
6693
|
+
}
|
|
6694
|
+
if (quote === 0) {
|
|
6695
|
+
if (ch === "[") {
|
|
6696
|
+
bracket++;
|
|
6697
|
+
} else if (ch === "]" && bracket > 0) {
|
|
6698
|
+
bracket--;
|
|
6699
|
+
} else if (bracket === 0) {
|
|
6700
|
+
if (ch === "(") {
|
|
6701
|
+
paren++;
|
|
6702
|
+
} else if (ch === ")" && paren > 0) {
|
|
6703
|
+
paren--;
|
|
6704
|
+
} else if (ch === "|" && paren === 0) {
|
|
6705
|
+
parts.push(value);
|
|
6706
|
+
value = "";
|
|
6707
|
+
continue;
|
|
6708
|
+
}
|
|
6709
|
+
}
|
|
6710
|
+
}
|
|
6711
|
+
value += ch;
|
|
6712
|
+
}
|
|
6713
|
+
parts.push(value);
|
|
6714
|
+
return parts;
|
|
6715
|
+
};
|
|
6716
|
+
var isPlainBranch = (branch) => {
|
|
6717
|
+
let escaped = false;
|
|
6718
|
+
for (const ch of branch) {
|
|
6719
|
+
if (escaped === true) {
|
|
6720
|
+
escaped = false;
|
|
6721
|
+
continue;
|
|
6722
|
+
}
|
|
6723
|
+
if (ch === "\\") {
|
|
6724
|
+
escaped = true;
|
|
6725
|
+
continue;
|
|
6726
|
+
}
|
|
6727
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
6728
|
+
return false;
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6731
|
+
return true;
|
|
6732
|
+
};
|
|
6733
|
+
var normalizeSimpleBranch = (branch) => {
|
|
6734
|
+
let value = branch.trim();
|
|
6735
|
+
let changed = true;
|
|
6736
|
+
while (changed === true) {
|
|
6737
|
+
changed = false;
|
|
6738
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
6739
|
+
value = value.slice(2, -1);
|
|
6740
|
+
changed = true;
|
|
6741
|
+
}
|
|
6742
|
+
}
|
|
6743
|
+
if (!isPlainBranch(value)) {
|
|
6744
|
+
return;
|
|
6745
|
+
}
|
|
6746
|
+
return value.replace(/\\(.)/g, "$1");
|
|
6747
|
+
};
|
|
6748
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
6749
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
6750
|
+
for (let i = 0; i < values.length; i++) {
|
|
6751
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
6752
|
+
const a = values[i];
|
|
6753
|
+
const b = values[j];
|
|
6754
|
+
const char = a[0];
|
|
6755
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
6756
|
+
continue;
|
|
6757
|
+
}
|
|
6758
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
6759
|
+
return true;
|
|
6760
|
+
}
|
|
6761
|
+
}
|
|
6762
|
+
}
|
|
6763
|
+
return false;
|
|
6764
|
+
};
|
|
6765
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
6766
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
6767
|
+
return;
|
|
6768
|
+
}
|
|
6769
|
+
let bracket = 0;
|
|
6770
|
+
let paren = 0;
|
|
6771
|
+
let quote = 0;
|
|
6772
|
+
let escaped = false;
|
|
6773
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
6774
|
+
const ch = pattern[i];
|
|
6775
|
+
if (escaped === true) {
|
|
6776
|
+
escaped = false;
|
|
6777
|
+
continue;
|
|
6778
|
+
}
|
|
6779
|
+
if (ch === "\\") {
|
|
6780
|
+
escaped = true;
|
|
6781
|
+
continue;
|
|
6782
|
+
}
|
|
6783
|
+
if (ch === '"') {
|
|
6784
|
+
quote = quote === 1 ? 0 : 1;
|
|
6785
|
+
continue;
|
|
6786
|
+
}
|
|
6787
|
+
if (quote === 1) {
|
|
6788
|
+
continue;
|
|
6789
|
+
}
|
|
6790
|
+
if (ch === "[") {
|
|
6791
|
+
bracket++;
|
|
6792
|
+
continue;
|
|
6793
|
+
}
|
|
6794
|
+
if (ch === "]" && bracket > 0) {
|
|
6795
|
+
bracket--;
|
|
6796
|
+
continue;
|
|
6797
|
+
}
|
|
6798
|
+
if (bracket > 0) {
|
|
6799
|
+
continue;
|
|
6800
|
+
}
|
|
6801
|
+
if (ch === "(") {
|
|
6802
|
+
paren++;
|
|
6803
|
+
continue;
|
|
6804
|
+
}
|
|
6805
|
+
if (ch === ")") {
|
|
6806
|
+
paren--;
|
|
6807
|
+
if (paren === 0) {
|
|
6808
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
6809
|
+
return;
|
|
6810
|
+
}
|
|
6811
|
+
return {
|
|
6812
|
+
type: pattern[0],
|
|
6813
|
+
body: pattern.slice(2, i),
|
|
6814
|
+
end: i
|
|
6815
|
+
};
|
|
6816
|
+
}
|
|
6817
|
+
}
|
|
6818
|
+
}
|
|
6819
|
+
};
|
|
6820
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
6821
|
+
let index = 0;
|
|
6822
|
+
const chars = [];
|
|
6823
|
+
while (index < pattern.length) {
|
|
6824
|
+
const match2 = parseRepeatedExtglob(pattern.slice(index), false);
|
|
6825
|
+
if (!match2 || match2.type !== "*") {
|
|
6826
|
+
return;
|
|
6827
|
+
}
|
|
6828
|
+
const branches = splitTopLevel(match2.body).map((branch2) => branch2.trim());
|
|
6829
|
+
if (branches.length !== 1) {
|
|
6830
|
+
return;
|
|
6831
|
+
}
|
|
6832
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
6833
|
+
if (!branch || branch.length !== 1) {
|
|
6834
|
+
return;
|
|
6835
|
+
}
|
|
6836
|
+
chars.push(branch);
|
|
6837
|
+
index += match2.end + 1;
|
|
6838
|
+
}
|
|
6839
|
+
if (chars.length < 1) {
|
|
6840
|
+
return;
|
|
6841
|
+
}
|
|
6842
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
6843
|
+
return `${source}*`;
|
|
6844
|
+
};
|
|
6845
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
6846
|
+
let depth = 0;
|
|
6847
|
+
let value = pattern.trim();
|
|
6848
|
+
let match2 = parseRepeatedExtglob(value);
|
|
6849
|
+
while (match2) {
|
|
6850
|
+
depth++;
|
|
6851
|
+
value = match2.body.trim();
|
|
6852
|
+
match2 = parseRepeatedExtglob(value);
|
|
6853
|
+
}
|
|
6854
|
+
return depth;
|
|
6855
|
+
};
|
|
6856
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
6857
|
+
if (options.maxExtglobRecursion === false) {
|
|
6858
|
+
return { risky: false };
|
|
6859
|
+
}
|
|
6860
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
6861
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
6862
|
+
if (branches.length > 1) {
|
|
6863
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
6864
|
+
return { risky: true };
|
|
6865
|
+
}
|
|
6866
|
+
}
|
|
6867
|
+
for (const branch of branches) {
|
|
6868
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
6869
|
+
if (safeOutput) {
|
|
6870
|
+
return { risky: true, safeOutput };
|
|
6871
|
+
}
|
|
6872
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
6873
|
+
return { risky: true };
|
|
6874
|
+
}
|
|
6875
|
+
}
|
|
6876
|
+
return { risky: false };
|
|
6877
|
+
};
|
|
6878
|
+
var parse2 = (input, options) => {
|
|
6879
|
+
if (typeof input !== "string") {
|
|
6880
|
+
throw new TypeError("Expected a string");
|
|
6881
|
+
}
|
|
6882
|
+
input = REPLACEMENTS[input] || input;
|
|
6883
|
+
const opts = { ...options };
|
|
6884
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
6885
|
+
let len = input.length;
|
|
6886
|
+
if (len > max) {
|
|
6887
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
6888
|
+
}
|
|
6889
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
6890
|
+
const tokens = [bos];
|
|
6891
|
+
const capture = opts.capture ? "" : "?:";
|
|
6892
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
6893
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
6894
|
+
const {
|
|
6895
|
+
DOT_LITERAL,
|
|
6896
|
+
PLUS_LITERAL,
|
|
6897
|
+
SLASH_LITERAL,
|
|
6898
|
+
ONE_CHAR,
|
|
6899
|
+
DOTS_SLASH,
|
|
6900
|
+
NO_DOT,
|
|
6901
|
+
NO_DOT_SLASH,
|
|
6902
|
+
NO_DOTS_SLASH,
|
|
6903
|
+
QMARK,
|
|
6904
|
+
QMARK_NO_DOT,
|
|
6905
|
+
STAR,
|
|
6906
|
+
START_ANCHOR
|
|
6907
|
+
} = PLATFORM_CHARS;
|
|
6908
|
+
const globstar = (opts2) => {
|
|
6909
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
6910
|
+
};
|
|
6911
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
6912
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
6913
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
6914
|
+
if (opts.capture) {
|
|
6915
|
+
star = `(${star})`;
|
|
6916
|
+
}
|
|
6917
|
+
if (typeof opts.noext === "boolean") {
|
|
6918
|
+
opts.noextglob = opts.noext;
|
|
6919
|
+
}
|
|
6920
|
+
const state = {
|
|
6921
|
+
input,
|
|
6922
|
+
index: -1,
|
|
6923
|
+
start: 0,
|
|
6924
|
+
dot: opts.dot === true,
|
|
6925
|
+
consumed: "",
|
|
6926
|
+
output: "",
|
|
6927
|
+
prefix: "",
|
|
6928
|
+
backtrack: false,
|
|
6929
|
+
negated: false,
|
|
6930
|
+
brackets: 0,
|
|
6931
|
+
braces: 0,
|
|
6932
|
+
parens: 0,
|
|
6933
|
+
quotes: 0,
|
|
6934
|
+
globstar: false,
|
|
6935
|
+
tokens
|
|
6936
|
+
};
|
|
6937
|
+
input = utils.removePrefix(input, state);
|
|
6938
|
+
len = input.length;
|
|
6939
|
+
const extglobs = [];
|
|
6940
|
+
const braces = [];
|
|
6941
|
+
const stack = [];
|
|
6942
|
+
let prev = bos;
|
|
6943
|
+
let value;
|
|
6944
|
+
const eos = () => state.index === len - 1;
|
|
6945
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
6946
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
6947
|
+
const remaining = () => input.slice(state.index + 1);
|
|
6948
|
+
const consume = (value2 = "", num = 0) => {
|
|
6949
|
+
state.consumed += value2;
|
|
6950
|
+
state.index += num;
|
|
6951
|
+
};
|
|
6952
|
+
const append = (token) => {
|
|
6953
|
+
state.output += token.output != null ? token.output : token.value;
|
|
6954
|
+
consume(token.value);
|
|
6955
|
+
};
|
|
6956
|
+
const negate = () => {
|
|
6957
|
+
let count = 1;
|
|
6958
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
6959
|
+
advance();
|
|
6960
|
+
state.start++;
|
|
6961
|
+
count++;
|
|
6962
|
+
}
|
|
6963
|
+
if (count % 2 === 0) {
|
|
6964
|
+
return false;
|
|
6965
|
+
}
|
|
6966
|
+
state.negated = true;
|
|
6967
|
+
state.start++;
|
|
6968
|
+
return true;
|
|
6969
|
+
};
|
|
6970
|
+
const increment = (type) => {
|
|
6971
|
+
state[type]++;
|
|
6972
|
+
stack.push(type);
|
|
6973
|
+
};
|
|
6974
|
+
const decrement = (type) => {
|
|
6975
|
+
state[type]--;
|
|
6976
|
+
stack.pop();
|
|
6977
|
+
};
|
|
6978
|
+
const push = (tok) => {
|
|
6979
|
+
if (prev.type === "globstar") {
|
|
6980
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
6981
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
6982
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
6983
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
6984
|
+
prev.type = "star";
|
|
6985
|
+
prev.value = "*";
|
|
6986
|
+
prev.output = star;
|
|
6987
|
+
state.output += prev.output;
|
|
6988
|
+
}
|
|
6989
|
+
}
|
|
6990
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
6991
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
6992
|
+
}
|
|
6993
|
+
if (tok.value || tok.output) append(tok);
|
|
6994
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
6995
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
6996
|
+
prev.value += tok.value;
|
|
6997
|
+
return;
|
|
6998
|
+
}
|
|
6999
|
+
tok.prev = prev;
|
|
7000
|
+
tokens.push(tok);
|
|
7001
|
+
prev = tok;
|
|
7002
|
+
};
|
|
7003
|
+
const extglobOpen = (type, value2) => {
|
|
7004
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
7005
|
+
token.prev = prev;
|
|
7006
|
+
token.parens = state.parens;
|
|
7007
|
+
token.output = state.output;
|
|
7008
|
+
token.startIndex = state.index;
|
|
7009
|
+
token.tokensIndex = tokens.length;
|
|
7010
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
7011
|
+
increment("parens");
|
|
7012
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
7013
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
7014
|
+
extglobs.push(token);
|
|
7015
|
+
};
|
|
7016
|
+
const extglobClose = (token) => {
|
|
7017
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
7018
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
7019
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
7020
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
7021
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
7022
|
+
const open = tokens[token.tokensIndex];
|
|
7023
|
+
open.type = "text";
|
|
7024
|
+
open.value = literal;
|
|
7025
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
7026
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
7027
|
+
tokens[i].value = "";
|
|
7028
|
+
tokens[i].output = "";
|
|
7029
|
+
delete tokens[i].suffix;
|
|
7030
|
+
}
|
|
7031
|
+
state.output = token.output + open.output;
|
|
7032
|
+
state.backtrack = true;
|
|
7033
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
7034
|
+
decrement("parens");
|
|
7035
|
+
return;
|
|
7036
|
+
}
|
|
7037
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
7038
|
+
let rest;
|
|
7039
|
+
if (token.type === "negate") {
|
|
7040
|
+
let extglobStar = star;
|
|
7041
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
7042
|
+
extglobStar = globstar(opts);
|
|
7043
|
+
}
|
|
7044
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
7045
|
+
output = token.close = `)$))${extglobStar}`;
|
|
7046
|
+
}
|
|
7047
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
7048
|
+
const expression = parse2(rest, { ...options, fastpaths: false }).output;
|
|
7049
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
7050
|
+
}
|
|
7051
|
+
if (token.prev.type === "bos") {
|
|
7052
|
+
state.negatedExtglob = true;
|
|
7053
|
+
}
|
|
7054
|
+
}
|
|
7055
|
+
push({ type: "paren", extglob: true, value, output });
|
|
7056
|
+
decrement("parens");
|
|
7057
|
+
};
|
|
7058
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
7059
|
+
let backslashes = false;
|
|
7060
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
7061
|
+
if (first === "\\") {
|
|
7062
|
+
backslashes = true;
|
|
7063
|
+
return m;
|
|
7064
|
+
}
|
|
7065
|
+
if (first === "?") {
|
|
7066
|
+
if (esc) {
|
|
7067
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
7068
|
+
}
|
|
7069
|
+
if (index === 0) {
|
|
7070
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
7071
|
+
}
|
|
7072
|
+
return QMARK.repeat(chars.length);
|
|
7073
|
+
}
|
|
7074
|
+
if (first === ".") {
|
|
7075
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
7076
|
+
}
|
|
7077
|
+
if (first === "*") {
|
|
7078
|
+
if (esc) {
|
|
7079
|
+
return esc + first + (rest ? star : "");
|
|
7080
|
+
}
|
|
7081
|
+
return star;
|
|
7082
|
+
}
|
|
7083
|
+
return esc ? m : `\\${m}`;
|
|
7084
|
+
});
|
|
7085
|
+
if (backslashes === true) {
|
|
7086
|
+
if (opts.unescape === true) {
|
|
7087
|
+
output = output.replace(/\\/g, "");
|
|
7088
|
+
} else {
|
|
7089
|
+
output = output.replace(/\\+/g, (m) => {
|
|
7090
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
7091
|
+
});
|
|
7092
|
+
}
|
|
7093
|
+
}
|
|
7094
|
+
if (output === input && opts.contains === true) {
|
|
7095
|
+
state.output = input;
|
|
7096
|
+
return state;
|
|
7097
|
+
}
|
|
7098
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
7099
|
+
return state;
|
|
7100
|
+
}
|
|
7101
|
+
while (!eos()) {
|
|
7102
|
+
value = advance();
|
|
7103
|
+
if (value === "\0") {
|
|
7104
|
+
continue;
|
|
7105
|
+
}
|
|
7106
|
+
if (value === "\\") {
|
|
7107
|
+
const next = peek();
|
|
7108
|
+
if (next === "/" && opts.bash !== true) {
|
|
7109
|
+
continue;
|
|
7110
|
+
}
|
|
7111
|
+
if (next === "." || next === ";") {
|
|
7112
|
+
continue;
|
|
7113
|
+
}
|
|
7114
|
+
if (!next) {
|
|
7115
|
+
value += "\\";
|
|
7116
|
+
push({ type: "text", value });
|
|
7117
|
+
continue;
|
|
7118
|
+
}
|
|
7119
|
+
const match2 = /^\\+/.exec(remaining());
|
|
7120
|
+
let slashes = 0;
|
|
7121
|
+
if (match2 && match2[0].length > 2) {
|
|
7122
|
+
slashes = match2[0].length;
|
|
7123
|
+
state.index += slashes;
|
|
7124
|
+
if (slashes % 2 !== 0) {
|
|
7125
|
+
value += "\\";
|
|
7126
|
+
}
|
|
7127
|
+
}
|
|
7128
|
+
if (opts.unescape === true) {
|
|
7129
|
+
value = advance();
|
|
7130
|
+
} else {
|
|
7131
|
+
value += advance();
|
|
7132
|
+
}
|
|
7133
|
+
if (state.brackets === 0) {
|
|
7134
|
+
push({ type: "text", value });
|
|
7135
|
+
continue;
|
|
7136
|
+
}
|
|
7137
|
+
}
|
|
7138
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
7139
|
+
if (opts.posix !== false && value === ":") {
|
|
7140
|
+
const inner = prev.value.slice(1);
|
|
7141
|
+
if (inner.includes("[")) {
|
|
7142
|
+
prev.posix = true;
|
|
7143
|
+
if (inner.includes(":")) {
|
|
7144
|
+
const idx = prev.value.lastIndexOf("[");
|
|
7145
|
+
const pre = prev.value.slice(0, idx);
|
|
7146
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
7147
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
7148
|
+
if (posix) {
|
|
7149
|
+
prev.value = pre + posix;
|
|
7150
|
+
state.backtrack = true;
|
|
7151
|
+
advance();
|
|
7152
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
7153
|
+
bos.output = ONE_CHAR;
|
|
7154
|
+
}
|
|
7155
|
+
continue;
|
|
7156
|
+
}
|
|
7157
|
+
}
|
|
7158
|
+
}
|
|
7159
|
+
}
|
|
7160
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
7161
|
+
value = `\\${value}`;
|
|
7162
|
+
}
|
|
7163
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
7164
|
+
value = `\\${value}`;
|
|
7165
|
+
}
|
|
7166
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
7167
|
+
value = "^";
|
|
7168
|
+
}
|
|
7169
|
+
prev.value += value;
|
|
7170
|
+
append({ value });
|
|
7171
|
+
continue;
|
|
7172
|
+
}
|
|
7173
|
+
if (state.quotes === 1 && value !== '"') {
|
|
7174
|
+
value = utils.escapeRegex(value);
|
|
7175
|
+
prev.value += value;
|
|
7176
|
+
append({ value });
|
|
7177
|
+
continue;
|
|
7178
|
+
}
|
|
7179
|
+
if (value === '"') {
|
|
7180
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
7181
|
+
if (opts.keepQuotes === true) {
|
|
7182
|
+
push({ type: "text", value });
|
|
7183
|
+
}
|
|
7184
|
+
continue;
|
|
7185
|
+
}
|
|
7186
|
+
if (value === "(") {
|
|
7187
|
+
increment("parens");
|
|
7188
|
+
push({ type: "paren", value });
|
|
7189
|
+
continue;
|
|
7190
|
+
}
|
|
7191
|
+
if (value === ")") {
|
|
7192
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
7193
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
7194
|
+
}
|
|
7195
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
7196
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
7197
|
+
extglobClose(extglobs.pop());
|
|
7198
|
+
continue;
|
|
7199
|
+
}
|
|
7200
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
7201
|
+
decrement("parens");
|
|
7202
|
+
continue;
|
|
7203
|
+
}
|
|
7204
|
+
if (value === "[") {
|
|
7205
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
7206
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
7207
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
7208
|
+
}
|
|
7209
|
+
value = `\\${value}`;
|
|
7210
|
+
} else {
|
|
7211
|
+
increment("brackets");
|
|
7212
|
+
}
|
|
7213
|
+
push({ type: "bracket", value });
|
|
7214
|
+
continue;
|
|
7215
|
+
}
|
|
7216
|
+
if (value === "]") {
|
|
7217
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
7218
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
7219
|
+
continue;
|
|
7220
|
+
}
|
|
7221
|
+
if (state.brackets === 0) {
|
|
7222
|
+
if (opts.strictBrackets === true) {
|
|
7223
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
7224
|
+
}
|
|
7225
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
7226
|
+
continue;
|
|
7227
|
+
}
|
|
7228
|
+
decrement("brackets");
|
|
7229
|
+
const prevValue = prev.value.slice(1);
|
|
7230
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
7231
|
+
value = `/${value}`;
|
|
7232
|
+
}
|
|
7233
|
+
prev.value += value;
|
|
7234
|
+
append({ value });
|
|
7235
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
7236
|
+
continue;
|
|
7237
|
+
}
|
|
7238
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
7239
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
7240
|
+
if (opts.literalBrackets === true) {
|
|
7241
|
+
state.output += escaped;
|
|
7242
|
+
prev.value = escaped;
|
|
7243
|
+
continue;
|
|
7244
|
+
}
|
|
7245
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
7246
|
+
state.output += prev.value;
|
|
7247
|
+
continue;
|
|
7248
|
+
}
|
|
7249
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
7250
|
+
increment("braces");
|
|
7251
|
+
const open = {
|
|
7252
|
+
type: "brace",
|
|
7253
|
+
value,
|
|
7254
|
+
output: "(",
|
|
7255
|
+
outputIndex: state.output.length,
|
|
7256
|
+
tokensIndex: state.tokens.length
|
|
7257
|
+
};
|
|
7258
|
+
braces.push(open);
|
|
7259
|
+
push(open);
|
|
7260
|
+
continue;
|
|
7261
|
+
}
|
|
7262
|
+
if (value === "}") {
|
|
7263
|
+
const brace = braces[braces.length - 1];
|
|
7264
|
+
if (opts.nobrace === true || !brace) {
|
|
7265
|
+
push({ type: "text", value, output: value });
|
|
7266
|
+
continue;
|
|
7267
|
+
}
|
|
7268
|
+
let output = ")";
|
|
7269
|
+
if (brace.dots === true) {
|
|
7270
|
+
const arr = tokens.slice();
|
|
7271
|
+
const range = [];
|
|
7272
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
7273
|
+
tokens.pop();
|
|
7274
|
+
if (arr[i].type === "brace") {
|
|
7275
|
+
break;
|
|
7276
|
+
}
|
|
7277
|
+
if (arr[i].type !== "dots") {
|
|
7278
|
+
range.unshift(arr[i].value);
|
|
7279
|
+
}
|
|
7280
|
+
}
|
|
7281
|
+
output = expandRange(range, opts);
|
|
7282
|
+
state.backtrack = true;
|
|
7283
|
+
}
|
|
7284
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
7285
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
7286
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
7287
|
+
brace.value = brace.output = "\\{";
|
|
7288
|
+
value = output = "\\}";
|
|
7289
|
+
state.output = out;
|
|
7290
|
+
for (const t of toks) {
|
|
7291
|
+
state.output += t.output || t.value;
|
|
7292
|
+
}
|
|
7293
|
+
}
|
|
7294
|
+
push({ type: "brace", value, output });
|
|
7295
|
+
decrement("braces");
|
|
7296
|
+
braces.pop();
|
|
7297
|
+
continue;
|
|
7298
|
+
}
|
|
7299
|
+
if (value === "|") {
|
|
7300
|
+
if (extglobs.length > 0) {
|
|
7301
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
7302
|
+
}
|
|
7303
|
+
push({ type: "text", value });
|
|
7304
|
+
continue;
|
|
7305
|
+
}
|
|
7306
|
+
if (value === ",") {
|
|
7307
|
+
let output = value;
|
|
7308
|
+
const brace = braces[braces.length - 1];
|
|
7309
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
7310
|
+
brace.comma = true;
|
|
7311
|
+
output = "|";
|
|
7312
|
+
}
|
|
7313
|
+
push({ type: "comma", value, output });
|
|
7314
|
+
continue;
|
|
7315
|
+
}
|
|
7316
|
+
if (value === "/") {
|
|
7317
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
7318
|
+
state.start = state.index + 1;
|
|
7319
|
+
state.consumed = "";
|
|
7320
|
+
state.output = "";
|
|
7321
|
+
tokens.pop();
|
|
7322
|
+
prev = bos;
|
|
7323
|
+
continue;
|
|
7324
|
+
}
|
|
7325
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
7326
|
+
continue;
|
|
7327
|
+
}
|
|
7328
|
+
if (value === ".") {
|
|
7329
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
7330
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
7331
|
+
const brace = braces[braces.length - 1];
|
|
7332
|
+
prev.type = "dots";
|
|
7333
|
+
prev.output += value;
|
|
7334
|
+
prev.value += value;
|
|
7335
|
+
brace.dots = true;
|
|
7336
|
+
continue;
|
|
7337
|
+
}
|
|
7338
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
7339
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
7340
|
+
continue;
|
|
7341
|
+
}
|
|
7342
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
7343
|
+
continue;
|
|
7344
|
+
}
|
|
7345
|
+
if (value === "?") {
|
|
7346
|
+
const isGroup = prev && prev.value === "(";
|
|
7347
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
7348
|
+
extglobOpen("qmark", value);
|
|
7349
|
+
continue;
|
|
7350
|
+
}
|
|
7351
|
+
if (prev && prev.type === "paren") {
|
|
7352
|
+
const next = peek();
|
|
7353
|
+
let output = value;
|
|
7354
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
7355
|
+
output = `\\${value}`;
|
|
7356
|
+
}
|
|
7357
|
+
push({ type: "text", value, output });
|
|
7358
|
+
continue;
|
|
7359
|
+
}
|
|
7360
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
7361
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
7362
|
+
continue;
|
|
7363
|
+
}
|
|
7364
|
+
push({ type: "qmark", value, output: QMARK });
|
|
7365
|
+
continue;
|
|
7366
|
+
}
|
|
7367
|
+
if (value === "!") {
|
|
7368
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
7369
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
7370
|
+
extglobOpen("negate", value);
|
|
7371
|
+
continue;
|
|
7372
|
+
}
|
|
7373
|
+
}
|
|
7374
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
7375
|
+
negate();
|
|
7376
|
+
continue;
|
|
7377
|
+
}
|
|
7378
|
+
}
|
|
7379
|
+
if (value === "+") {
|
|
7380
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
7381
|
+
extglobOpen("plus", value);
|
|
7382
|
+
continue;
|
|
7383
|
+
}
|
|
7384
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
7385
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
7386
|
+
continue;
|
|
7387
|
+
}
|
|
7388
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
7389
|
+
push({ type: "plus", value });
|
|
7390
|
+
continue;
|
|
7391
|
+
}
|
|
7392
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
7393
|
+
continue;
|
|
7394
|
+
}
|
|
7395
|
+
if (value === "@") {
|
|
7396
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
7397
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
7398
|
+
continue;
|
|
7399
|
+
}
|
|
7400
|
+
push({ type: "text", value });
|
|
7401
|
+
continue;
|
|
7402
|
+
}
|
|
7403
|
+
if (value !== "*") {
|
|
7404
|
+
if (value === "$" || value === "^") {
|
|
7405
|
+
value = `\\${value}`;
|
|
7406
|
+
}
|
|
7407
|
+
const match2 = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
7408
|
+
if (match2) {
|
|
7409
|
+
value += match2[0];
|
|
7410
|
+
state.index += match2[0].length;
|
|
7411
|
+
}
|
|
7412
|
+
push({ type: "text", value });
|
|
7413
|
+
continue;
|
|
7414
|
+
}
|
|
7415
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
7416
|
+
prev.type = "star";
|
|
7417
|
+
prev.star = true;
|
|
7418
|
+
prev.value += value;
|
|
7419
|
+
prev.output = star;
|
|
7420
|
+
state.backtrack = true;
|
|
7421
|
+
state.globstar = true;
|
|
7422
|
+
consume(value);
|
|
7423
|
+
continue;
|
|
7424
|
+
}
|
|
7425
|
+
let rest = remaining();
|
|
7426
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
7427
|
+
extglobOpen("star", value);
|
|
7428
|
+
continue;
|
|
7429
|
+
}
|
|
7430
|
+
if (prev.type === "star") {
|
|
7431
|
+
if (opts.noglobstar === true) {
|
|
7432
|
+
consume(value);
|
|
7433
|
+
continue;
|
|
7434
|
+
}
|
|
7435
|
+
const prior = prev.prev;
|
|
7436
|
+
const before = prior.prev;
|
|
7437
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
7438
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
7439
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
7440
|
+
push({ type: "star", value, output: "" });
|
|
7441
|
+
continue;
|
|
7442
|
+
}
|
|
7443
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
7444
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
7445
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
7446
|
+
push({ type: "star", value, output: "" });
|
|
7447
|
+
continue;
|
|
7448
|
+
}
|
|
7449
|
+
while (rest.slice(0, 3) === "/**") {
|
|
7450
|
+
const after = input[state.index + 4];
|
|
7451
|
+
if (after && after !== "/") {
|
|
7452
|
+
break;
|
|
7453
|
+
}
|
|
7454
|
+
rest = rest.slice(3);
|
|
7455
|
+
consume("/**", 3);
|
|
7456
|
+
}
|
|
7457
|
+
if (prior.type === "bos" && eos()) {
|
|
7458
|
+
prev.type = "globstar";
|
|
7459
|
+
prev.value += value;
|
|
7460
|
+
prev.output = globstar(opts);
|
|
7461
|
+
state.output = prev.output;
|
|
7462
|
+
state.globstar = true;
|
|
7463
|
+
consume(value);
|
|
7464
|
+
continue;
|
|
7465
|
+
}
|
|
7466
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
7467
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
7468
|
+
prior.output = `(?:${prior.output}`;
|
|
7469
|
+
prev.type = "globstar";
|
|
7470
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
7471
|
+
prev.value += value;
|
|
7472
|
+
state.globstar = true;
|
|
7473
|
+
state.output += prior.output + prev.output;
|
|
7474
|
+
consume(value);
|
|
7475
|
+
continue;
|
|
7476
|
+
}
|
|
7477
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
7478
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
7479
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
7480
|
+
prior.output = `(?:${prior.output}`;
|
|
7481
|
+
prev.type = "globstar";
|
|
7482
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
7483
|
+
prev.value += value;
|
|
7484
|
+
state.output += prior.output + prev.output;
|
|
7485
|
+
state.globstar = true;
|
|
7486
|
+
consume(value + advance());
|
|
7487
|
+
push({ type: "slash", value: "/", output: "" });
|
|
7488
|
+
continue;
|
|
7489
|
+
}
|
|
7490
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
7491
|
+
prev.type = "globstar";
|
|
7492
|
+
prev.value += value;
|
|
7493
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
7494
|
+
state.output = prev.output;
|
|
7495
|
+
state.globstar = true;
|
|
7496
|
+
consume(value + advance());
|
|
7497
|
+
push({ type: "slash", value: "/", output: "" });
|
|
7498
|
+
continue;
|
|
7499
|
+
}
|
|
7500
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
7501
|
+
prev.type = "globstar";
|
|
7502
|
+
prev.output = globstar(opts);
|
|
7503
|
+
prev.value += value;
|
|
7504
|
+
state.output += prev.output;
|
|
7505
|
+
state.globstar = true;
|
|
7506
|
+
consume(value);
|
|
7507
|
+
continue;
|
|
7508
|
+
}
|
|
7509
|
+
const token = { type: "star", value, output: star };
|
|
7510
|
+
if (opts.bash === true) {
|
|
7511
|
+
token.output = ".*?";
|
|
7512
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
7513
|
+
token.output = nodot + token.output;
|
|
7514
|
+
}
|
|
7515
|
+
push(token);
|
|
7516
|
+
continue;
|
|
7517
|
+
}
|
|
7518
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
7519
|
+
token.output = value;
|
|
7520
|
+
push(token);
|
|
7521
|
+
continue;
|
|
7522
|
+
}
|
|
7523
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
7524
|
+
if (prev.type === "dot") {
|
|
7525
|
+
state.output += NO_DOT_SLASH;
|
|
7526
|
+
prev.output += NO_DOT_SLASH;
|
|
7527
|
+
} else if (opts.dot === true) {
|
|
7528
|
+
state.output += NO_DOTS_SLASH;
|
|
7529
|
+
prev.output += NO_DOTS_SLASH;
|
|
7530
|
+
} else {
|
|
7531
|
+
state.output += nodot;
|
|
7532
|
+
prev.output += nodot;
|
|
7533
|
+
}
|
|
7534
|
+
if (peek() !== "*") {
|
|
7535
|
+
state.output += ONE_CHAR;
|
|
7536
|
+
prev.output += ONE_CHAR;
|
|
7537
|
+
}
|
|
7538
|
+
}
|
|
7539
|
+
push(token);
|
|
7540
|
+
}
|
|
7541
|
+
while (state.brackets > 0) {
|
|
7542
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
7543
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
7544
|
+
decrement("brackets");
|
|
7545
|
+
}
|
|
7546
|
+
while (state.parens > 0) {
|
|
7547
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
7548
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
7549
|
+
decrement("parens");
|
|
7550
|
+
}
|
|
7551
|
+
while (state.braces > 0) {
|
|
7552
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
7553
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
7554
|
+
decrement("braces");
|
|
7555
|
+
}
|
|
7556
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
7557
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
7558
|
+
}
|
|
7559
|
+
if (state.backtrack === true) {
|
|
7560
|
+
state.output = "";
|
|
7561
|
+
for (const token of state.tokens) {
|
|
7562
|
+
state.output += token.output != null ? token.output : token.value;
|
|
7563
|
+
if (token.suffix) {
|
|
7564
|
+
state.output += token.suffix;
|
|
7565
|
+
}
|
|
7566
|
+
}
|
|
7567
|
+
}
|
|
7568
|
+
return state;
|
|
7569
|
+
};
|
|
7570
|
+
parse2.fastpaths = (input, options) => {
|
|
7571
|
+
const opts = { ...options };
|
|
7572
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
7573
|
+
const len = input.length;
|
|
7574
|
+
if (len > max) {
|
|
7575
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
7576
|
+
}
|
|
7577
|
+
input = REPLACEMENTS[input] || input;
|
|
7578
|
+
const {
|
|
7579
|
+
DOT_LITERAL,
|
|
7580
|
+
SLASH_LITERAL,
|
|
7581
|
+
ONE_CHAR,
|
|
7582
|
+
DOTS_SLASH,
|
|
7583
|
+
NO_DOT,
|
|
7584
|
+
NO_DOTS,
|
|
7585
|
+
NO_DOTS_SLASH,
|
|
7586
|
+
STAR,
|
|
7587
|
+
START_ANCHOR
|
|
7588
|
+
} = constants.globChars(opts.windows);
|
|
7589
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
7590
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
7591
|
+
const capture = opts.capture ? "" : "?:";
|
|
7592
|
+
const state = { negated: false, prefix: "" };
|
|
7593
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
7594
|
+
if (opts.capture) {
|
|
7595
|
+
star = `(${star})`;
|
|
7596
|
+
}
|
|
7597
|
+
const globstar = (opts2) => {
|
|
7598
|
+
if (opts2.noglobstar === true) return star;
|
|
7599
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
7600
|
+
};
|
|
7601
|
+
const create = (str) => {
|
|
7602
|
+
switch (str) {
|
|
7603
|
+
case "*":
|
|
7604
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
7605
|
+
case ".*":
|
|
7606
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
7607
|
+
case "*.*":
|
|
7608
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
7609
|
+
case "*/*":
|
|
7610
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
7611
|
+
case "**":
|
|
7612
|
+
return nodot + globstar(opts);
|
|
7613
|
+
case "**/*":
|
|
7614
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
7615
|
+
case "**/*.*":
|
|
7616
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
7617
|
+
case "**/.*":
|
|
7618
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
7619
|
+
default: {
|
|
7620
|
+
const match2 = /^(.*?)\.(\w+)$/.exec(str);
|
|
7621
|
+
if (!match2) return;
|
|
7622
|
+
const source2 = create(match2[1]);
|
|
7623
|
+
if (!source2) return;
|
|
7624
|
+
return source2 + DOT_LITERAL + match2[2];
|
|
7625
|
+
}
|
|
7626
|
+
}
|
|
7627
|
+
};
|
|
7628
|
+
const output = utils.removePrefix(input, state);
|
|
7629
|
+
let source = create(output);
|
|
7630
|
+
if (source && opts.strictSlashes !== true) {
|
|
7631
|
+
source += `${SLASH_LITERAL}?`;
|
|
7632
|
+
}
|
|
7633
|
+
return source;
|
|
7634
|
+
};
|
|
7635
|
+
module22.exports = parse2;
|
|
7636
|
+
}
|
|
7637
|
+
});
|
|
7638
|
+
var require_picomatch = __commonJS2({
|
|
7639
|
+
"node_modules/picomatch/lib/picomatch.js"(exports22, module22) {
|
|
7640
|
+
"use strict";
|
|
7641
|
+
var scan2 = require_scan();
|
|
7642
|
+
var parse2 = require_parse();
|
|
7643
|
+
var utils = require_utils5();
|
|
7644
|
+
var constants = require_constants();
|
|
7645
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
7646
|
+
var picomatch = (glob, options, returnState = false) => {
|
|
7647
|
+
if (Array.isArray(glob)) {
|
|
7648
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
7649
|
+
const arrayMatcher = (str) => {
|
|
7650
|
+
for (const isMatch of fns) {
|
|
7651
|
+
const state2 = isMatch(str);
|
|
7652
|
+
if (state2) return state2;
|
|
7653
|
+
}
|
|
7654
|
+
return false;
|
|
7655
|
+
};
|
|
7656
|
+
return arrayMatcher;
|
|
7657
|
+
}
|
|
7658
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
7659
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
7660
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
7661
|
+
}
|
|
7662
|
+
const opts = options || {};
|
|
7663
|
+
const posix = opts.windows;
|
|
7664
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
7665
|
+
const state = regex.state;
|
|
7666
|
+
delete regex.state;
|
|
7667
|
+
let isIgnored = () => false;
|
|
7668
|
+
if (opts.ignore) {
|
|
7669
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
7670
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
7671
|
+
}
|
|
7672
|
+
const matcher = (input, returnObject = false) => {
|
|
7673
|
+
const { isMatch, match: match2, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
7674
|
+
const result = { glob, state, regex, posix, input, output, match: match2, isMatch };
|
|
7675
|
+
if (typeof opts.onResult === "function") {
|
|
7676
|
+
opts.onResult(result);
|
|
7677
|
+
}
|
|
7678
|
+
if (isMatch === false) {
|
|
7679
|
+
result.isMatch = false;
|
|
7680
|
+
return returnObject ? result : false;
|
|
7681
|
+
}
|
|
7682
|
+
if (isIgnored(input)) {
|
|
7683
|
+
if (typeof opts.onIgnore === "function") {
|
|
7684
|
+
opts.onIgnore(result);
|
|
7685
|
+
}
|
|
7686
|
+
result.isMatch = false;
|
|
7687
|
+
return returnObject ? result : false;
|
|
7688
|
+
}
|
|
7689
|
+
if (typeof opts.onMatch === "function") {
|
|
7690
|
+
opts.onMatch(result);
|
|
7691
|
+
}
|
|
7692
|
+
return returnObject ? result : true;
|
|
7693
|
+
};
|
|
7694
|
+
if (returnState) {
|
|
7695
|
+
matcher.state = state;
|
|
7696
|
+
}
|
|
7697
|
+
return matcher;
|
|
7698
|
+
};
|
|
7699
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
7700
|
+
if (typeof input !== "string") {
|
|
7701
|
+
throw new TypeError("Expected input to be a string");
|
|
7702
|
+
}
|
|
7703
|
+
if (input === "") {
|
|
7704
|
+
return { isMatch: false, output: "" };
|
|
7705
|
+
}
|
|
7706
|
+
const opts = options || {};
|
|
7707
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
7708
|
+
let match2 = input === glob;
|
|
7709
|
+
let output = match2 && format ? format(input) : input;
|
|
7710
|
+
if (match2 === false) {
|
|
7711
|
+
output = format ? format(input) : input;
|
|
7712
|
+
match2 = output === glob;
|
|
7713
|
+
}
|
|
7714
|
+
if (match2 === false || opts.capture === true) {
|
|
7715
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
7716
|
+
match2 = picomatch.matchBase(input, regex, options, posix);
|
|
7717
|
+
} else {
|
|
7718
|
+
match2 = regex.exec(output);
|
|
7719
|
+
}
|
|
7720
|
+
}
|
|
7721
|
+
return { isMatch: Boolean(match2), match: match2, output };
|
|
7722
|
+
};
|
|
7723
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
7724
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
7725
|
+
return regex.test(utils.basename(input));
|
|
7726
|
+
};
|
|
7727
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
7728
|
+
picomatch.parse = (pattern, options) => {
|
|
7729
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
7730
|
+
return parse2(pattern, { ...options, fastpaths: false });
|
|
7731
|
+
};
|
|
7732
|
+
picomatch.scan = (input, options) => scan2(input, options);
|
|
7733
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
7734
|
+
if (returnOutput === true) {
|
|
7735
|
+
return state.output;
|
|
7736
|
+
}
|
|
7737
|
+
const opts = options || {};
|
|
7738
|
+
const prepend = opts.contains ? "" : "^";
|
|
7739
|
+
const append = opts.contains ? "" : "$";
|
|
7740
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
7741
|
+
if (state && state.negated === true) {
|
|
7742
|
+
source = `^(?!${source}).*$`;
|
|
7743
|
+
}
|
|
7744
|
+
const regex = picomatch.toRegex(source, options);
|
|
7745
|
+
if (returnState === true) {
|
|
7746
|
+
regex.state = state;
|
|
7747
|
+
}
|
|
7748
|
+
return regex;
|
|
7749
|
+
};
|
|
7750
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
7751
|
+
if (!input || typeof input !== "string") {
|
|
7752
|
+
throw new TypeError("Expected a non-empty string");
|
|
7753
|
+
}
|
|
7754
|
+
let parsed = { negated: false, fastpaths: true };
|
|
7755
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
7756
|
+
parsed.output = parse2.fastpaths(input, options);
|
|
7757
|
+
}
|
|
7758
|
+
if (!parsed.output) {
|
|
7759
|
+
parsed = parse2(input, options);
|
|
7760
|
+
}
|
|
7761
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
7762
|
+
};
|
|
7763
|
+
picomatch.toRegex = (source, options) => {
|
|
7764
|
+
try {
|
|
7765
|
+
const opts = options || {};
|
|
7766
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
7767
|
+
} catch (err) {
|
|
7768
|
+
if (options && options.debug === true) throw err;
|
|
7769
|
+
return /$^/;
|
|
7770
|
+
}
|
|
7771
|
+
};
|
|
7772
|
+
picomatch.constants = constants;
|
|
7773
|
+
module22.exports = picomatch;
|
|
7774
|
+
}
|
|
7775
|
+
});
|
|
7776
|
+
var require_picomatch2 = __commonJS2({
|
|
7777
|
+
"node_modules/picomatch/index.js"(exports22, module22) {
|
|
7778
|
+
"use strict";
|
|
7779
|
+
var pico = require_picomatch();
|
|
7780
|
+
var utils = require_utils5();
|
|
7781
|
+
function picomatch(glob, options, returnState = false) {
|
|
7782
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
7783
|
+
options = { ...options, windows: utils.isWindows() };
|
|
7784
|
+
}
|
|
7785
|
+
return pico(glob, options, returnState);
|
|
7786
|
+
}
|
|
7787
|
+
Object.assign(picomatch, pico);
|
|
7788
|
+
module22.exports = picomatch;
|
|
7789
|
+
}
|
|
7790
|
+
});
|
|
7791
|
+
var require_match = __commonJS2({
|
|
7792
|
+
"src/match.js"(exports22, module22) {
|
|
7793
|
+
var picomatch = require_picomatch2();
|
|
7794
|
+
function match2(patterns, options) {
|
|
7795
|
+
return picomatch(patterns, options);
|
|
7796
|
+
}
|
|
7797
|
+
module22.exports = match2;
|
|
7798
|
+
}
|
|
7799
|
+
});
|
|
7800
|
+
var require_scan2 = __commonJS2({
|
|
6046
7801
|
"src/scan.js"(exports22, module22) {
|
|
7802
|
+
var createMatch = require_match();
|
|
7803
|
+
function list(value) {
|
|
7804
|
+
if (value === void 0 || value === null) {
|
|
7805
|
+
return [];
|
|
7806
|
+
}
|
|
7807
|
+
if (!Array.isArray(value)) {
|
|
7808
|
+
return [value];
|
|
7809
|
+
}
|
|
7810
|
+
return value;
|
|
7811
|
+
}
|
|
6047
7812
|
function trimmer(value) {
|
|
6048
7813
|
return (value || "").trim();
|
|
6049
7814
|
}
|
|
@@ -6085,16 +7850,23 @@ var require_dist = __commonJS({
|
|
|
6085
7850
|
transform = options;
|
|
6086
7851
|
options = {};
|
|
6087
7852
|
}
|
|
7853
|
+
const ik = list(options.ik);
|
|
7854
|
+
const ek = list(options.ek);
|
|
7855
|
+
const include = createMatch(ik, { ignore: ek });
|
|
7856
|
+
const exclude = createMatch(ek);
|
|
6088
7857
|
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
6089
7858
|
const parsed = {};
|
|
6090
7859
|
let lines = (src || "").toString();
|
|
6091
7860
|
if (options.convertWindowsNewlines !== false) {
|
|
6092
7861
|
lines = lines.replace(/\r\n?/mg, "\n");
|
|
6093
7862
|
}
|
|
6094
|
-
let
|
|
6095
|
-
while ((
|
|
6096
|
-
const name =
|
|
6097
|
-
|
|
7863
|
+
let match2;
|
|
7864
|
+
while ((match2 = LINE.exec(lines)) !== null) {
|
|
7865
|
+
const name = match2[1];
|
|
7866
|
+
if (exclude(name) || ik.length > 0 && !include(name)) {
|
|
7867
|
+
continue;
|
|
7868
|
+
}
|
|
7869
|
+
const raw = match2[2];
|
|
6098
7870
|
const quote = getQuote(raw);
|
|
6099
7871
|
const value = clean(raw, quote, options);
|
|
6100
7872
|
let parsedValue = value;
|
|
@@ -6119,7 +7891,7 @@ var require_dist = __commonJS({
|
|
|
6119
7891
|
"src/keyring.js"(exports22, module22) {
|
|
6120
7892
|
var fs2 = require("fs");
|
|
6121
7893
|
var derive2 = require_derive();
|
|
6122
|
-
var scan2 =
|
|
7894
|
+
var scan2 = require_scan2();
|
|
6123
7895
|
async function keysFromFile(filepath = ".env.keys") {
|
|
6124
7896
|
try {
|
|
6125
7897
|
const src = await fs2.promises.readFile(filepath, "utf8");
|
|
@@ -6127,7 +7899,13 @@ var require_dist = __commonJS({
|
|
|
6127
7899
|
const result = [];
|
|
6128
7900
|
for (const name in parsed) {
|
|
6129
7901
|
if (name.startsWith("DOTENV_PRIVATE_KEY")) {
|
|
6130
|
-
|
|
7902
|
+
const values = parsed[name];
|
|
7903
|
+
for (const value of values) {
|
|
7904
|
+
const splits = value.split(",");
|
|
7905
|
+
for (const split of splits) {
|
|
7906
|
+
result.push(split);
|
|
7907
|
+
}
|
|
7908
|
+
}
|
|
6131
7909
|
}
|
|
6132
7910
|
}
|
|
6133
7911
|
return result;
|
|
@@ -6142,7 +7920,13 @@ var require_dist = __commonJS({
|
|
|
6142
7920
|
const result = [];
|
|
6143
7921
|
for (const name in parsed) {
|
|
6144
7922
|
if (name.startsWith("DOTENV_PRIVATE_KEY")) {
|
|
6145
|
-
|
|
7923
|
+
const values = parsed[name];
|
|
7924
|
+
for (const value of values) {
|
|
7925
|
+
const splits = value.split(",");
|
|
7926
|
+
for (const split of splits) {
|
|
7927
|
+
result.push(split);
|
|
7928
|
+
}
|
|
7929
|
+
}
|
|
6146
7930
|
}
|
|
6147
7931
|
}
|
|
6148
7932
|
return result;
|
|
@@ -6160,6 +7944,10 @@ var require_dist = __commonJS({
|
|
|
6160
7944
|
privateKeyValues.push(...await keysFromFile(filepath));
|
|
6161
7945
|
}
|
|
6162
7946
|
for (const name in processEnv2) {
|
|
7947
|
+
if (name.startsWith("DOTENV_PUBLIC_KEY")) {
|
|
7948
|
+
const publicKeyHex = processEnv2[name];
|
|
7949
|
+
ring[publicKeyHex] ||= "";
|
|
7950
|
+
}
|
|
6163
7951
|
if (name.startsWith("DOTENV_PRIVATE_KEY")) {
|
|
6164
7952
|
privateKeyValues.push(processEnv2[name]);
|
|
6165
7953
|
}
|
|
@@ -6176,9 +7964,12 @@ var require_dist = __commonJS({
|
|
|
6176
7964
|
if (ring[publicKeyHex]) {
|
|
6177
7965
|
continue;
|
|
6178
7966
|
}
|
|
6179
|
-
const
|
|
6180
|
-
|
|
6181
|
-
|
|
7967
|
+
const providerRing = await provider(publicKeyHex);
|
|
7968
|
+
for (const providerPublicKeyHex in providerRing || {}) {
|
|
7969
|
+
const providerPrivateKeyHex = providerRing[providerPublicKeyHex];
|
|
7970
|
+
if (providerPrivateKeyHex) {
|
|
7971
|
+
ring[providerPublicKeyHex] = providerPrivateKeyHex;
|
|
7972
|
+
}
|
|
6182
7973
|
}
|
|
6183
7974
|
}
|
|
6184
7975
|
}
|
|
@@ -6193,6 +7984,10 @@ var require_dist = __commonJS({
|
|
|
6193
7984
|
return acc.concat(keysFromFileSync(filepath));
|
|
6194
7985
|
}, []);
|
|
6195
7986
|
for (const name in processEnv2) {
|
|
7987
|
+
if (name.startsWith("DOTENV_PUBLIC_KEY")) {
|
|
7988
|
+
const publicKeyHex = processEnv2[name];
|
|
7989
|
+
ring[publicKeyHex] ||= "";
|
|
7990
|
+
}
|
|
6196
7991
|
if (name.startsWith("DOTENV_PRIVATE_KEY")) {
|
|
6197
7992
|
privateKeyValues.push(processEnv2[name]);
|
|
6198
7993
|
}
|
|
@@ -6209,9 +8004,12 @@ var require_dist = __commonJS({
|
|
|
6209
8004
|
if (ring[publicKeyHex]) {
|
|
6210
8005
|
continue;
|
|
6211
8006
|
}
|
|
6212
|
-
const
|
|
6213
|
-
|
|
6214
|
-
|
|
8007
|
+
const providerRing = provider(publicKeyHex);
|
|
8008
|
+
for (const providerPublicKeyHex in providerRing || {}) {
|
|
8009
|
+
const providerPrivateKeyHex = providerRing[providerPublicKeyHex];
|
|
8010
|
+
if (providerPrivateKeyHex) {
|
|
8011
|
+
ring[providerPublicKeyHex] = providerPrivateKeyHex;
|
|
8012
|
+
}
|
|
6215
8013
|
}
|
|
6216
8014
|
}
|
|
6217
8015
|
}
|
|
@@ -6223,7 +8021,7 @@ var require_dist = __commonJS({
|
|
|
6223
8021
|
});
|
|
6224
8022
|
var require_publickeys = __commonJS2({
|
|
6225
8023
|
"src/publickeys.js"(exports22, module22) {
|
|
6226
|
-
var scan2 =
|
|
8024
|
+
var scan2 = require_scan2();
|
|
6227
8025
|
function publickeys2(src) {
|
|
6228
8026
|
const { parsed } = scan2(src);
|
|
6229
8027
|
const result = [];
|
|
@@ -6237,16 +8035,27 @@ var require_dist = __commonJS({
|
|
|
6237
8035
|
module22.exports = publickeys2;
|
|
6238
8036
|
}
|
|
6239
8037
|
});
|
|
6240
|
-
var
|
|
8038
|
+
var require_parse2 = __commonJS2({
|
|
6241
8039
|
"src/parse.js"(exports22, module22) {
|
|
6242
8040
|
var decrypt2 = require_decrypt();
|
|
8041
|
+
var Errors = require_errors();
|
|
6243
8042
|
var keyring2 = require_keyring();
|
|
6244
8043
|
var keyringSync2 = require_keyring().sync;
|
|
6245
8044
|
var encrypted2 = require_encrypted();
|
|
6246
8045
|
var evaluate2 = require_evaluate();
|
|
6247
8046
|
var expand2 = require_expand();
|
|
8047
|
+
var match2 = require_match();
|
|
6248
8048
|
var publickeys2 = require_publickeys();
|
|
6249
|
-
var scan2 =
|
|
8049
|
+
var scan2 = require_scan2();
|
|
8050
|
+
function list(value) {
|
|
8051
|
+
if (value === void 0 || value === null) {
|
|
8052
|
+
return [];
|
|
8053
|
+
}
|
|
8054
|
+
if (!Array.isArray(value)) {
|
|
8055
|
+
return [value];
|
|
8056
|
+
}
|
|
8057
|
+
return value;
|
|
8058
|
+
}
|
|
6250
8059
|
function resolveEscapeSequences(value) {
|
|
6251
8060
|
return value.replace(/\\\$/g, "$");
|
|
6252
8061
|
}
|
|
@@ -6274,18 +8083,32 @@ var require_dist = __commonJS({
|
|
|
6274
8083
|
}
|
|
6275
8084
|
return value;
|
|
6276
8085
|
}
|
|
8086
|
+
function unresolvedEncryptedError(unresolved) {
|
|
8087
|
+
const keys = Object.keys(unresolved);
|
|
8088
|
+
if (keys.length === 0) {
|
|
8089
|
+
return null;
|
|
8090
|
+
}
|
|
8091
|
+
const error = new Errors({ message: `could not decrypt ${keys.join(", ")}` }).decryptionFailed();
|
|
8092
|
+
return {
|
|
8093
|
+
code: error.code,
|
|
8094
|
+
message: error.message
|
|
8095
|
+
};
|
|
8096
|
+
}
|
|
6277
8097
|
async function parse2(src, options = {}) {
|
|
6278
|
-
const { overload, processEnv: processEnv2, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
8098
|
+
const { overload, array, ik, ek, processEnv: processEnv2, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
6279
8099
|
const ring = await keyring2({ processEnv: processEnv2, ring: initialRing, fk, provider });
|
|
6280
|
-
return parseWithRing(src, { overload, processEnv: processEnv2, ring, publicKeyHexes });
|
|
8100
|
+
return parseWithRing(src, { overload, array, ik, ek, processEnv: processEnv2, ring, publicKeyHexes });
|
|
6281
8101
|
}
|
|
6282
8102
|
function parseSync22(src, options = {}) {
|
|
6283
|
-
const { overload, processEnv: processEnv2, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
8103
|
+
const { overload, array, ik, ek, processEnv: processEnv2, fk, provider, publicKeyHexes, ring: initialRing } = keyringOptions(src, options);
|
|
6284
8104
|
const ring = keyringSync2({ processEnv: processEnv2, ring: initialRing, fk, provider });
|
|
6285
|
-
return parseWithRing(src, { overload, processEnv: processEnv2, ring, publicKeyHexes });
|
|
8105
|
+
return parseWithRing(src, { overload, array, ik, ek, processEnv: processEnv2, ring, publicKeyHexes });
|
|
6286
8106
|
}
|
|
6287
8107
|
function keyringOptions(src, options = {}) {
|
|
6288
8108
|
const overload = options.overload;
|
|
8109
|
+
const array = options.array;
|
|
8110
|
+
const ik = list(options.ik);
|
|
8111
|
+
const ek = list(options.ek);
|
|
6289
8112
|
const processEnv2 = options.processEnv || process.env;
|
|
6290
8113
|
const fk = options.fk;
|
|
6291
8114
|
const provider = options.provider;
|
|
@@ -6294,13 +8117,18 @@ var require_dist = __commonJS({
|
|
|
6294
8117
|
for (const publicKeyHex of publicKeyHexes) {
|
|
6295
8118
|
ring[publicKeyHex] = "";
|
|
6296
8119
|
}
|
|
6297
|
-
return { overload, processEnv: processEnv2, fk, provider, publicKeyHexes, ring };
|
|
8120
|
+
return { overload, array, ik, ek, processEnv: processEnv2, fk, provider, publicKeyHexes, ring };
|
|
6298
8121
|
}
|
|
6299
8122
|
function parseWithRing(src, options = {}) {
|
|
6300
8123
|
const overload = options.overload;
|
|
8124
|
+
const array = options.array;
|
|
8125
|
+
const ik = options.ik || [];
|
|
8126
|
+
const ek = options.ek || [];
|
|
6301
8127
|
const processEnv2 = options.processEnv || process.env;
|
|
6302
8128
|
const ring = options.ring || {};
|
|
6303
8129
|
const publicKeyHexes = options.publicKeyHexes || [];
|
|
8130
|
+
const include = match2(ik, { ignore: ek });
|
|
8131
|
+
const exclude = match2(ek);
|
|
6304
8132
|
function inProcessEnv(name) {
|
|
6305
8133
|
return Object.prototype.hasOwnProperty.call(processEnv2, name);
|
|
6306
8134
|
}
|
|
@@ -6309,12 +8137,19 @@ var require_dist = __commonJS({
|
|
|
6309
8137
|
const parsed = {};
|
|
6310
8138
|
const injected = {};
|
|
6311
8139
|
const existed = {};
|
|
8140
|
+
const unresolvedEncrypted = {};
|
|
6312
8141
|
scan2(src, ({ name, value, quote }) => {
|
|
6313
8142
|
let parsedValue = value;
|
|
6314
8143
|
if (!overload && inProcessEnv(name)) {
|
|
6315
8144
|
parsedValue = processEnv2[name];
|
|
6316
8145
|
}
|
|
6317
|
-
|
|
8146
|
+
const encryptedBefore = encrypted2(parsedValue);
|
|
8147
|
+
if (!exclude(name) && (ik.length === 0 || include(name))) {
|
|
8148
|
+
parsedValue = decryptWithKeyring(ring, parsedValue, publicKeyHexes);
|
|
8149
|
+
if (encryptedBefore && encrypted2(parsedValue)) {
|
|
8150
|
+
unresolvedEncrypted[name] = true;
|
|
8151
|
+
}
|
|
8152
|
+
}
|
|
6318
8153
|
const encryptedPrefixed = encrypted2(parsedValue);
|
|
6319
8154
|
let evaled = false;
|
|
6320
8155
|
if (!encryptedPrefixed && quote !== "'" && (!inProcessEnv(name) || processEnv2[name] === parsedValue)) {
|
|
@@ -6334,18 +8169,39 @@ var require_dist = __commonJS({
|
|
|
6334
8169
|
literals[name] = parsedValue;
|
|
6335
8170
|
}
|
|
6336
8171
|
runningParsed[name] = parsedValue;
|
|
6337
|
-
|
|
8172
|
+
if (array) {
|
|
8173
|
+
parsed[name] = parsed[name] || [];
|
|
8174
|
+
parsed[name].push(parsedValue);
|
|
8175
|
+
} else {
|
|
8176
|
+
parsed[name] = parsedValue;
|
|
8177
|
+
}
|
|
6338
8178
|
if (Object.prototype.hasOwnProperty.call(processEnv2, name) && !overload) {
|
|
6339
|
-
|
|
8179
|
+
if (array) {
|
|
8180
|
+
existed[name] = existed[name] || [];
|
|
8181
|
+
existed[name].push(processEnv2[name]);
|
|
8182
|
+
} else {
|
|
8183
|
+
existed[name] = processEnv2[name];
|
|
8184
|
+
}
|
|
6340
8185
|
} else {
|
|
6341
|
-
|
|
8186
|
+
if (array) {
|
|
8187
|
+
injected[name] = injected[name] || [];
|
|
8188
|
+
injected[name].push(parsedValue);
|
|
8189
|
+
} else {
|
|
8190
|
+
injected[name] = parsed[name];
|
|
8191
|
+
}
|
|
6342
8192
|
}
|
|
6343
8193
|
return parsedValue;
|
|
6344
8194
|
});
|
|
8195
|
+
const errors = [];
|
|
8196
|
+
const error = unresolvedEncryptedError(unresolvedEncrypted);
|
|
8197
|
+
if (error) {
|
|
8198
|
+
errors.push(error);
|
|
8199
|
+
}
|
|
6345
8200
|
return {
|
|
6346
8201
|
parsed,
|
|
6347
8202
|
injected,
|
|
6348
|
-
existed
|
|
8203
|
+
existed,
|
|
8204
|
+
errors
|
|
6349
8205
|
};
|
|
6350
8206
|
}
|
|
6351
8207
|
module22.exports = parse2;
|
|
@@ -6355,15 +8211,21 @@ var require_dist = __commonJS({
|
|
|
6355
8211
|
var require_sealed = __commonJS2({
|
|
6356
8212
|
"src/sealed.js"(exports22, module22) {
|
|
6357
8213
|
var encrypted2 = require_encrypted();
|
|
6358
|
-
var scan2 =
|
|
8214
|
+
var scan2 = require_scan2();
|
|
6359
8215
|
function publicKey(name) {
|
|
6360
8216
|
return name.startsWith("DOTENV_PUBLIC_KEY");
|
|
6361
8217
|
}
|
|
8218
|
+
function plainKey(name) {
|
|
8219
|
+
return name.endsWith("_PLAIN");
|
|
8220
|
+
}
|
|
6362
8221
|
function sealed2(src) {
|
|
6363
8222
|
const { parsed } = scan2(src);
|
|
6364
8223
|
for (const [name, values] of Object.entries(parsed)) {
|
|
8224
|
+
if (publicKey(name) || plainKey(name)) {
|
|
8225
|
+
continue;
|
|
8226
|
+
}
|
|
6365
8227
|
for (const value of values) {
|
|
6366
|
-
if (!encrypted2(value)
|
|
8228
|
+
if (!encrypted2(value)) {
|
|
6367
8229
|
return false;
|
|
6368
8230
|
}
|
|
6369
8231
|
}
|
|
@@ -6373,6 +8235,68 @@ var require_dist = __commonJS({
|
|
|
6373
8235
|
module22.exports = sealed2;
|
|
6374
8236
|
}
|
|
6375
8237
|
});
|
|
8238
|
+
var require_upsert = __commonJS2({
|
|
8239
|
+
"src/upsert.js"(exports22, module22) {
|
|
8240
|
+
var scan2 = require_scan2();
|
|
8241
|
+
function escapeForRegex(str) {
|
|
8242
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
8243
|
+
}
|
|
8244
|
+
function replaceExistingValue(src, key, originalValue, replaceValue) {
|
|
8245
|
+
const escapedKey = escapeForRegex(key);
|
|
8246
|
+
const escapedOriginalValue = escapeForRegex(originalValue);
|
|
8247
|
+
let enforceEndOfLine = "";
|
|
8248
|
+
if (escapedOriginalValue === "") {
|
|
8249
|
+
enforceEndOfLine = "$";
|
|
8250
|
+
}
|
|
8251
|
+
const currentPart = new RegExp(
|
|
8252
|
+
"^(\\s*)?(export\\s+)?" + escapedKey + "\\s*=\\s*([\"'`]?)" + escapedOriginalValue + "\\3" + enforceEndOfLine,
|
|
8253
|
+
"m"
|
|
8254
|
+
);
|
|
8255
|
+
return src.replace(currentPart, function(match2, spaces = "", exportPart = "", quote = "") {
|
|
8256
|
+
let newPart = `${key}=${quote}${replaceValue}${quote}`;
|
|
8257
|
+
const newlineMatch = src.match(new RegExp(`${escapedKey}\\s*=\\s*
|
|
8258
|
+
|
|
8259
|
+
`, "m"));
|
|
8260
|
+
if (escapedOriginalValue === "" && quote === "" && newlineMatch) {
|
|
8261
|
+
const newlineCount = newlineMatch[0].match(/\n/g).length - 1;
|
|
8262
|
+
for (let i = 0; i < newlineCount; i++) {
|
|
8263
|
+
newPart += "\n";
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
return `${spaces}${exportPart}${newPart}`;
|
|
8267
|
+
});
|
|
8268
|
+
}
|
|
8269
|
+
function upsert2(src, key, replaceValue) {
|
|
8270
|
+
let output;
|
|
8271
|
+
let newPart = "";
|
|
8272
|
+
const { parsed } = scan2(src, { expandDoubleQuotedNewlines: false, convertWindowsNewlines: false });
|
|
8273
|
+
if (Object.prototype.hasOwnProperty.call(parsed, key)) {
|
|
8274
|
+
const allValues = parsed[key];
|
|
8275
|
+
let duplicateOutput = src;
|
|
8276
|
+
const replacements = Array.isArray(replaceValue) ? replaceValue : allValues.map(() => replaceValue);
|
|
8277
|
+
allValues.forEach((value, index) => {
|
|
8278
|
+
duplicateOutput = replaceExistingValue(duplicateOutput, key, value, `\0DOTENVX_UPSERT_${index}\0`);
|
|
8279
|
+
});
|
|
8280
|
+
replacements.forEach((replacement, index) => {
|
|
8281
|
+
duplicateOutput = duplicateOutput.split(`\0DOTENVX_UPSERT_${index}\0`).join(replacement);
|
|
8282
|
+
});
|
|
8283
|
+
return duplicateOutput;
|
|
8284
|
+
} else {
|
|
8285
|
+
newPart += `${key}="${replaceValue}"`;
|
|
8286
|
+
if (src === "") {
|
|
8287
|
+
newPart = newPart + "\n";
|
|
8288
|
+
} else if (src.endsWith("\n")) {
|
|
8289
|
+
newPart = newPart + "\n";
|
|
8290
|
+
} else {
|
|
8291
|
+
newPart = "\n" + newPart;
|
|
8292
|
+
}
|
|
8293
|
+
output = src + newPart;
|
|
8294
|
+
}
|
|
8295
|
+
return output;
|
|
8296
|
+
}
|
|
8297
|
+
module22.exports = upsert2;
|
|
8298
|
+
}
|
|
8299
|
+
});
|
|
6376
8300
|
var decrypt = require_decrypt();
|
|
6377
8301
|
var derive = require_derive();
|
|
6378
8302
|
var encrypt = require_encrypt();
|
|
@@ -6382,11 +8306,13 @@ var require_dist = __commonJS({
|
|
|
6382
8306
|
var keypair = require_keypair();
|
|
6383
8307
|
var keyring = require_keyring();
|
|
6384
8308
|
var keyringSync = require_keyring().sync;
|
|
6385
|
-
var
|
|
6386
|
-
var
|
|
8309
|
+
var match = require_match();
|
|
8310
|
+
var parse = require_parse2();
|
|
8311
|
+
var parseSync2 = require_parse2().sync;
|
|
6387
8312
|
var publickeys = require_publickeys();
|
|
6388
|
-
var scan =
|
|
8313
|
+
var scan = require_scan2();
|
|
6389
8314
|
var sealed = require_sealed();
|
|
8315
|
+
var upsert = require_upsert();
|
|
6390
8316
|
module2.exports = {
|
|
6391
8317
|
decrypt,
|
|
6392
8318
|
derive,
|
|
@@ -6397,11 +8323,13 @@ var require_dist = __commonJS({
|
|
|
6397
8323
|
keypair,
|
|
6398
8324
|
keyring,
|
|
6399
8325
|
keyringSync,
|
|
8326
|
+
match,
|
|
6400
8327
|
parse,
|
|
6401
8328
|
parseSync: parseSync2,
|
|
6402
8329
|
publickeys,
|
|
6403
8330
|
scan,
|
|
6404
|
-
sealed
|
|
8331
|
+
sealed,
|
|
8332
|
+
upsert
|
|
6405
8333
|
};
|
|
6406
8334
|
}
|
|
6407
8335
|
});
|