flowlint 0.7.8 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -86
- package/dist/cli.js +334 -1847
- package/dist/cli.js.map +1 -1
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -1195,7 +1195,7 @@ var require_command = __commonJS({
|
|
|
1195
1195
|
"use strict";
|
|
1196
1196
|
var EventEmitter2 = require("events").EventEmitter;
|
|
1197
1197
|
var childProcess = require("child_process");
|
|
1198
|
-
var
|
|
1198
|
+
var path4 = require("path");
|
|
1199
1199
|
var fs3 = require("fs");
|
|
1200
1200
|
var process2 = require("process");
|
|
1201
1201
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -2208,11 +2208,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2208
2208
|
let launchWithNode = false;
|
|
2209
2209
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2210
2210
|
function findFile(baseDir, baseName) {
|
|
2211
|
-
const localBin =
|
|
2211
|
+
const localBin = path4.resolve(baseDir, baseName);
|
|
2212
2212
|
if (fs3.existsSync(localBin)) return localBin;
|
|
2213
|
-
if (sourceExt.includes(
|
|
2213
|
+
if (sourceExt.includes(path4.extname(baseName))) return void 0;
|
|
2214
2214
|
const foundExt = sourceExt.find(
|
|
2215
|
-
(
|
|
2215
|
+
(ext) => fs3.existsSync(`${localBin}${ext}`)
|
|
2216
2216
|
);
|
|
2217
2217
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
2218
2218
|
return void 0;
|
|
@@ -2228,17 +2228,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2228
2228
|
} catch {
|
|
2229
2229
|
resolvedScriptPath = this._scriptPath;
|
|
2230
2230
|
}
|
|
2231
|
-
executableDir =
|
|
2232
|
-
|
|
2231
|
+
executableDir = path4.resolve(
|
|
2232
|
+
path4.dirname(resolvedScriptPath),
|
|
2233
2233
|
executableDir
|
|
2234
2234
|
);
|
|
2235
2235
|
}
|
|
2236
2236
|
if (executableDir) {
|
|
2237
2237
|
let localFile = findFile(executableDir, executableFile);
|
|
2238
2238
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2239
|
-
const legacyName =
|
|
2239
|
+
const legacyName = path4.basename(
|
|
2240
2240
|
this._scriptPath,
|
|
2241
|
-
|
|
2241
|
+
path4.extname(this._scriptPath)
|
|
2242
2242
|
);
|
|
2243
2243
|
if (legacyName !== this._name) {
|
|
2244
2244
|
localFile = findFile(
|
|
@@ -2249,7 +2249,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2249
2249
|
}
|
|
2250
2250
|
executableFile = localFile || executableFile;
|
|
2251
2251
|
}
|
|
2252
|
-
launchWithNode = sourceExt.includes(
|
|
2252
|
+
launchWithNode = sourceExt.includes(path4.extname(executableFile));
|
|
2253
2253
|
let proc2;
|
|
2254
2254
|
if (process2.platform !== "win32") {
|
|
2255
2255
|
if (launchWithNode) {
|
|
@@ -3164,7 +3164,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3164
3164
|
* @return {Command}
|
|
3165
3165
|
*/
|
|
3166
3166
|
nameFromFilename(filename) {
|
|
3167
|
-
this._name =
|
|
3167
|
+
this._name = path4.basename(filename, path4.extname(filename));
|
|
3168
3168
|
return this;
|
|
3169
3169
|
}
|
|
3170
3170
|
/**
|
|
@@ -3178,9 +3178,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3178
3178
|
* @param {string} [path]
|
|
3179
3179
|
* @return {(string|null|Command)}
|
|
3180
3180
|
*/
|
|
3181
|
-
executableDir(
|
|
3182
|
-
if (
|
|
3183
|
-
this._executableDir =
|
|
3181
|
+
executableDir(path5) {
|
|
3182
|
+
if (path5 === void 0) return this._executableDir;
|
|
3183
|
+
this._executableDir = path5;
|
|
3184
3184
|
return this;
|
|
3185
3185
|
}
|
|
3186
3186
|
/**
|
|
@@ -3403,20 +3403,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3403
3403
|
let debugOption;
|
|
3404
3404
|
let debugHost = "127.0.0.1";
|
|
3405
3405
|
let debugPort = "9229";
|
|
3406
|
-
let
|
|
3407
|
-
if ((
|
|
3408
|
-
debugOption =
|
|
3409
|
-
} else if ((
|
|
3410
|
-
debugOption =
|
|
3411
|
-
if (/^\d+$/.test(
|
|
3412
|
-
debugPort =
|
|
3406
|
+
let match;
|
|
3407
|
+
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
|
3408
|
+
debugOption = match[1];
|
|
3409
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
|
3410
|
+
debugOption = match[1];
|
|
3411
|
+
if (/^\d+$/.test(match[3])) {
|
|
3412
|
+
debugPort = match[3];
|
|
3413
3413
|
} else {
|
|
3414
|
-
debugHost =
|
|
3414
|
+
debugHost = match[3];
|
|
3415
3415
|
}
|
|
3416
|
-
} else if ((
|
|
3417
|
-
debugOption =
|
|
3418
|
-
debugHost =
|
|
3419
|
-
debugPort =
|
|
3416
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
|
3417
|
+
debugOption = match[1];
|
|
3418
|
+
debugHost = match[3];
|
|
3419
|
+
debugPort = match[4];
|
|
3420
3420
|
}
|
|
3421
3421
|
if (debugOption && debugPort !== "0") {
|
|
3422
3422
|
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
|
@@ -3609,17 +3609,17 @@ var require_visit = __commonJS({
|
|
|
3609
3609
|
visit.BREAK = BREAK;
|
|
3610
3610
|
visit.SKIP = SKIP;
|
|
3611
3611
|
visit.REMOVE = REMOVE;
|
|
3612
|
-
function visit_(key, node, visitor,
|
|
3613
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
3612
|
+
function visit_(key, node, visitor, path4) {
|
|
3613
|
+
const ctrl = callVisitor(key, node, visitor, path4);
|
|
3614
3614
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
3615
|
-
replaceNode(key,
|
|
3616
|
-
return visit_(key, ctrl, visitor,
|
|
3615
|
+
replaceNode(key, path4, ctrl);
|
|
3616
|
+
return visit_(key, ctrl, visitor, path4);
|
|
3617
3617
|
}
|
|
3618
3618
|
if (typeof ctrl !== "symbol") {
|
|
3619
3619
|
if (identity.isCollection(node)) {
|
|
3620
|
-
|
|
3620
|
+
path4 = Object.freeze(path4.concat(node));
|
|
3621
3621
|
for (let i = 0; i < node.items.length; ++i) {
|
|
3622
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
3622
|
+
const ci = visit_(i, node.items[i], visitor, path4);
|
|
3623
3623
|
if (typeof ci === "number")
|
|
3624
3624
|
i = ci - 1;
|
|
3625
3625
|
else if (ci === BREAK)
|
|
@@ -3630,13 +3630,13 @@ var require_visit = __commonJS({
|
|
|
3630
3630
|
}
|
|
3631
3631
|
}
|
|
3632
3632
|
} else if (identity.isPair(node)) {
|
|
3633
|
-
|
|
3634
|
-
const ck = visit_("key", node.key, visitor,
|
|
3633
|
+
path4 = Object.freeze(path4.concat(node));
|
|
3634
|
+
const ck = visit_("key", node.key, visitor, path4);
|
|
3635
3635
|
if (ck === BREAK)
|
|
3636
3636
|
return BREAK;
|
|
3637
3637
|
else if (ck === REMOVE)
|
|
3638
3638
|
node.key = null;
|
|
3639
|
-
const cv = visit_("value", node.value, visitor,
|
|
3639
|
+
const cv = visit_("value", node.value, visitor, path4);
|
|
3640
3640
|
if (cv === BREAK)
|
|
3641
3641
|
return BREAK;
|
|
3642
3642
|
else if (cv === REMOVE)
|
|
@@ -3657,17 +3657,17 @@ var require_visit = __commonJS({
|
|
|
3657
3657
|
visitAsync.BREAK = BREAK;
|
|
3658
3658
|
visitAsync.SKIP = SKIP;
|
|
3659
3659
|
visitAsync.REMOVE = REMOVE;
|
|
3660
|
-
async function visitAsync_(key, node, visitor,
|
|
3661
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
3660
|
+
async function visitAsync_(key, node, visitor, path4) {
|
|
3661
|
+
const ctrl = await callVisitor(key, node, visitor, path4);
|
|
3662
3662
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
3663
|
-
replaceNode(key,
|
|
3664
|
-
return visitAsync_(key, ctrl, visitor,
|
|
3663
|
+
replaceNode(key, path4, ctrl);
|
|
3664
|
+
return visitAsync_(key, ctrl, visitor, path4);
|
|
3665
3665
|
}
|
|
3666
3666
|
if (typeof ctrl !== "symbol") {
|
|
3667
3667
|
if (identity.isCollection(node)) {
|
|
3668
|
-
|
|
3668
|
+
path4 = Object.freeze(path4.concat(node));
|
|
3669
3669
|
for (let i = 0; i < node.items.length; ++i) {
|
|
3670
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
3670
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path4);
|
|
3671
3671
|
if (typeof ci === "number")
|
|
3672
3672
|
i = ci - 1;
|
|
3673
3673
|
else if (ci === BREAK)
|
|
@@ -3678,13 +3678,13 @@ var require_visit = __commonJS({
|
|
|
3678
3678
|
}
|
|
3679
3679
|
}
|
|
3680
3680
|
} else if (identity.isPair(node)) {
|
|
3681
|
-
|
|
3682
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
3681
|
+
path4 = Object.freeze(path4.concat(node));
|
|
3682
|
+
const ck = await visitAsync_("key", node.key, visitor, path4);
|
|
3683
3683
|
if (ck === BREAK)
|
|
3684
3684
|
return BREAK;
|
|
3685
3685
|
else if (ck === REMOVE)
|
|
3686
3686
|
node.key = null;
|
|
3687
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
3687
|
+
const cv = await visitAsync_("value", node.value, visitor, path4);
|
|
3688
3688
|
if (cv === BREAK)
|
|
3689
3689
|
return BREAK;
|
|
3690
3690
|
else if (cv === REMOVE)
|
|
@@ -3711,23 +3711,23 @@ var require_visit = __commonJS({
|
|
|
3711
3711
|
}
|
|
3712
3712
|
return visitor;
|
|
3713
3713
|
}
|
|
3714
|
-
function callVisitor(key, node, visitor,
|
|
3714
|
+
function callVisitor(key, node, visitor, path4) {
|
|
3715
3715
|
if (typeof visitor === "function")
|
|
3716
|
-
return visitor(key, node,
|
|
3716
|
+
return visitor(key, node, path4);
|
|
3717
3717
|
if (identity.isMap(node))
|
|
3718
|
-
return visitor.Map?.(key, node,
|
|
3718
|
+
return visitor.Map?.(key, node, path4);
|
|
3719
3719
|
if (identity.isSeq(node))
|
|
3720
|
-
return visitor.Seq?.(key, node,
|
|
3720
|
+
return visitor.Seq?.(key, node, path4);
|
|
3721
3721
|
if (identity.isPair(node))
|
|
3722
|
-
return visitor.Pair?.(key, node,
|
|
3722
|
+
return visitor.Pair?.(key, node, path4);
|
|
3723
3723
|
if (identity.isScalar(node))
|
|
3724
|
-
return visitor.Scalar?.(key, node,
|
|
3724
|
+
return visitor.Scalar?.(key, node, path4);
|
|
3725
3725
|
if (identity.isAlias(node))
|
|
3726
|
-
return visitor.Alias?.(key, node,
|
|
3726
|
+
return visitor.Alias?.(key, node, path4);
|
|
3727
3727
|
return void 0;
|
|
3728
3728
|
}
|
|
3729
|
-
function replaceNode(key,
|
|
3730
|
-
const parent =
|
|
3729
|
+
function replaceNode(key, path4, node) {
|
|
3730
|
+
const parent = path4[path4.length - 1];
|
|
3731
3731
|
if (identity.isCollection(parent)) {
|
|
3732
3732
|
parent.items[key] = node;
|
|
3733
3733
|
} else if (identity.isPair(parent)) {
|
|
@@ -4263,8 +4263,8 @@ var require_createNode = __commonJS({
|
|
|
4263
4263
|
var defaultTagPrefix = "tag:yaml.org,2002:";
|
|
4264
4264
|
function findTagObject(value, tagName, tags) {
|
|
4265
4265
|
if (tagName) {
|
|
4266
|
-
const
|
|
4267
|
-
const tagObj =
|
|
4266
|
+
const match = tags.filter((t) => t.tag === tagName);
|
|
4267
|
+
const tagObj = match.find((t) => !t.format) ?? match[0];
|
|
4268
4268
|
if (!tagObj)
|
|
4269
4269
|
throw new Error(`Tag ${tagName} not found`);
|
|
4270
4270
|
return tagObj;
|
|
@@ -4335,10 +4335,10 @@ var require_Collection = __commonJS({
|
|
|
4335
4335
|
var createNode = require_createNode();
|
|
4336
4336
|
var identity = require_identity();
|
|
4337
4337
|
var Node = require_Node();
|
|
4338
|
-
function collectionFromPath(schema,
|
|
4338
|
+
function collectionFromPath(schema, path4, value) {
|
|
4339
4339
|
let v = value;
|
|
4340
|
-
for (let i =
|
|
4341
|
-
const k =
|
|
4340
|
+
for (let i = path4.length - 1; i >= 0; --i) {
|
|
4341
|
+
const k = path4[i];
|
|
4342
4342
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
4343
4343
|
const a = [];
|
|
4344
4344
|
a[k] = v;
|
|
@@ -4357,7 +4357,7 @@ var require_Collection = __commonJS({
|
|
|
4357
4357
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
4358
4358
|
});
|
|
4359
4359
|
}
|
|
4360
|
-
var isEmptyPath = (
|
|
4360
|
+
var isEmptyPath = (path4) => path4 == null || typeof path4 === "object" && !!path4[Symbol.iterator]().next().done;
|
|
4361
4361
|
var Collection = class extends Node.NodeBase {
|
|
4362
4362
|
constructor(type, schema) {
|
|
4363
4363
|
super(type);
|
|
@@ -4387,11 +4387,11 @@ var require_Collection = __commonJS({
|
|
|
4387
4387
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
4388
4388
|
* that already exists in the map.
|
|
4389
4389
|
*/
|
|
4390
|
-
addIn(
|
|
4391
|
-
if (isEmptyPath(
|
|
4390
|
+
addIn(path4, value) {
|
|
4391
|
+
if (isEmptyPath(path4))
|
|
4392
4392
|
this.add(value);
|
|
4393
4393
|
else {
|
|
4394
|
-
const [key, ...rest] =
|
|
4394
|
+
const [key, ...rest] = path4;
|
|
4395
4395
|
const node = this.get(key, true);
|
|
4396
4396
|
if (identity.isCollection(node))
|
|
4397
4397
|
node.addIn(rest, value);
|
|
@@ -4405,8 +4405,8 @@ var require_Collection = __commonJS({
|
|
|
4405
4405
|
* Removes a value from the collection.
|
|
4406
4406
|
* @returns `true` if the item was found and removed.
|
|
4407
4407
|
*/
|
|
4408
|
-
deleteIn(
|
|
4409
|
-
const [key, ...rest] =
|
|
4408
|
+
deleteIn(path4) {
|
|
4409
|
+
const [key, ...rest] = path4;
|
|
4410
4410
|
if (rest.length === 0)
|
|
4411
4411
|
return this.delete(key);
|
|
4412
4412
|
const node = this.get(key, true);
|
|
@@ -4420,8 +4420,8 @@ var require_Collection = __commonJS({
|
|
|
4420
4420
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
4421
4421
|
* `true` (collections are always returned intact).
|
|
4422
4422
|
*/
|
|
4423
|
-
getIn(
|
|
4424
|
-
const [key, ...rest] =
|
|
4423
|
+
getIn(path4, keepScalar) {
|
|
4424
|
+
const [key, ...rest] = path4;
|
|
4425
4425
|
const node = this.get(key, true);
|
|
4426
4426
|
if (rest.length === 0)
|
|
4427
4427
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -4439,8 +4439,8 @@ var require_Collection = __commonJS({
|
|
|
4439
4439
|
/**
|
|
4440
4440
|
* Checks if the collection includes a value with the key `key`.
|
|
4441
4441
|
*/
|
|
4442
|
-
hasIn(
|
|
4443
|
-
const [key, ...rest] =
|
|
4442
|
+
hasIn(path4) {
|
|
4443
|
+
const [key, ...rest] = path4;
|
|
4444
4444
|
if (rest.length === 0)
|
|
4445
4445
|
return this.has(key);
|
|
4446
4446
|
const node = this.get(key, true);
|
|
@@ -4450,8 +4450,8 @@ var require_Collection = __commonJS({
|
|
|
4450
4450
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
4451
4451
|
* boolean to add/remove the item from the set.
|
|
4452
4452
|
*/
|
|
4453
|
-
setIn(
|
|
4454
|
-
const [key, ...rest] =
|
|
4453
|
+
setIn(path4, value) {
|
|
4454
|
+
const [key, ...rest] = path4;
|
|
4455
4455
|
if (rest.length === 0) {
|
|
4456
4456
|
this.set(key, value);
|
|
4457
4457
|
} else {
|
|
@@ -4958,21 +4958,21 @@ var require_stringify = __commonJS({
|
|
|
4958
4958
|
}
|
|
4959
4959
|
function getTagObject(tags, item) {
|
|
4960
4960
|
if (item.tag) {
|
|
4961
|
-
const
|
|
4962
|
-
if (
|
|
4963
|
-
return
|
|
4961
|
+
const match = tags.filter((t) => t.tag === item.tag);
|
|
4962
|
+
if (match.length > 0)
|
|
4963
|
+
return match.find((t) => t.format === item.format) ?? match[0];
|
|
4964
4964
|
}
|
|
4965
4965
|
let tagObj = void 0;
|
|
4966
4966
|
let obj;
|
|
4967
4967
|
if (identity.isScalar(item)) {
|
|
4968
4968
|
obj = item.value;
|
|
4969
|
-
let
|
|
4970
|
-
if (
|
|
4971
|
-
const testMatch =
|
|
4969
|
+
let match = tags.filter((t) => t.identify?.(obj));
|
|
4970
|
+
if (match.length > 1) {
|
|
4971
|
+
const testMatch = match.filter((t) => t.test);
|
|
4972
4972
|
if (testMatch.length > 0)
|
|
4973
|
-
|
|
4973
|
+
match = testMatch;
|
|
4974
4974
|
}
|
|
4975
|
-
tagObj =
|
|
4975
|
+
tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
|
|
4976
4976
|
} else {
|
|
4977
4977
|
obj = item;
|
|
4978
4978
|
tagObj = tags.find((t) => t.nodeClass && obj instanceof t.nodeClass);
|
|
@@ -6604,13 +6604,13 @@ var require_timestamp = __commonJS({
|
|
|
6604
6604
|
// assumed to be 00:00:00Z (start of day, UTC).
|
|
6605
6605
|
test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
|
|
6606
6606
|
resolve(str) {
|
|
6607
|
-
const
|
|
6608
|
-
if (!
|
|
6607
|
+
const match = str.match(timestamp.test);
|
|
6608
|
+
if (!match)
|
|
6609
6609
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
6610
|
-
const [, year, month, day, hour, minute, second] =
|
|
6611
|
-
const millisec =
|
|
6610
|
+
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
6611
|
+
const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0;
|
|
6612
6612
|
let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
|
|
6613
|
-
const tz =
|
|
6613
|
+
const tz = match[8];
|
|
6614
6614
|
if (tz && tz !== "Z") {
|
|
6615
6615
|
let d = parseSexagesimal(tz, false);
|
|
6616
6616
|
if (Math.abs(d) < 30)
|
|
@@ -6955,9 +6955,9 @@ var require_Document = __commonJS({
|
|
|
6955
6955
|
this.contents.add(value);
|
|
6956
6956
|
}
|
|
6957
6957
|
/** Adds a value to the document. */
|
|
6958
|
-
addIn(
|
|
6958
|
+
addIn(path4, value) {
|
|
6959
6959
|
if (assertCollection(this.contents))
|
|
6960
|
-
this.contents.addIn(
|
|
6960
|
+
this.contents.addIn(path4, value);
|
|
6961
6961
|
}
|
|
6962
6962
|
/**
|
|
6963
6963
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -7032,14 +7032,14 @@ var require_Document = __commonJS({
|
|
|
7032
7032
|
* Removes a value from the document.
|
|
7033
7033
|
* @returns `true` if the item was found and removed.
|
|
7034
7034
|
*/
|
|
7035
|
-
deleteIn(
|
|
7036
|
-
if (Collection.isEmptyPath(
|
|
7035
|
+
deleteIn(path4) {
|
|
7036
|
+
if (Collection.isEmptyPath(path4)) {
|
|
7037
7037
|
if (this.contents == null)
|
|
7038
7038
|
return false;
|
|
7039
7039
|
this.contents = null;
|
|
7040
7040
|
return true;
|
|
7041
7041
|
}
|
|
7042
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
7042
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path4) : false;
|
|
7043
7043
|
}
|
|
7044
7044
|
/**
|
|
7045
7045
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -7054,10 +7054,10 @@ var require_Document = __commonJS({
|
|
|
7054
7054
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
7055
7055
|
* `true` (collections are always returned intact).
|
|
7056
7056
|
*/
|
|
7057
|
-
getIn(
|
|
7058
|
-
if (Collection.isEmptyPath(
|
|
7057
|
+
getIn(path4, keepScalar) {
|
|
7058
|
+
if (Collection.isEmptyPath(path4))
|
|
7059
7059
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
7060
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
7060
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path4, keepScalar) : void 0;
|
|
7061
7061
|
}
|
|
7062
7062
|
/**
|
|
7063
7063
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -7068,10 +7068,10 @@ var require_Document = __commonJS({
|
|
|
7068
7068
|
/**
|
|
7069
7069
|
* Checks if the document includes a value at `path`.
|
|
7070
7070
|
*/
|
|
7071
|
-
hasIn(
|
|
7072
|
-
if (Collection.isEmptyPath(
|
|
7071
|
+
hasIn(path4) {
|
|
7072
|
+
if (Collection.isEmptyPath(path4))
|
|
7073
7073
|
return this.contents !== void 0;
|
|
7074
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
7074
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path4) : false;
|
|
7075
7075
|
}
|
|
7076
7076
|
/**
|
|
7077
7077
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -7088,13 +7088,13 @@ var require_Document = __commonJS({
|
|
|
7088
7088
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
7089
7089
|
* boolean to add/remove the item from the set.
|
|
7090
7090
|
*/
|
|
7091
|
-
setIn(
|
|
7092
|
-
if (Collection.isEmptyPath(
|
|
7091
|
+
setIn(path4, value) {
|
|
7092
|
+
if (Collection.isEmptyPath(path4)) {
|
|
7093
7093
|
this.contents = value;
|
|
7094
7094
|
} else if (this.contents == null) {
|
|
7095
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
7095
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path4), value);
|
|
7096
7096
|
} else if (assertCollection(this.contents)) {
|
|
7097
|
-
this.contents.setIn(
|
|
7097
|
+
this.contents.setIn(path4, value);
|
|
7098
7098
|
}
|
|
7099
7099
|
}
|
|
7100
7100
|
/**
|
|
@@ -7480,10 +7480,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
7480
7480
|
let offset = bm.offset;
|
|
7481
7481
|
let commentEnd = null;
|
|
7482
7482
|
for (const collItem of bm.items) {
|
|
7483
|
-
const { start, key, sep
|
|
7483
|
+
const { start, key, sep, value } = collItem;
|
|
7484
7484
|
const keyProps = resolveProps.resolveProps(start, {
|
|
7485
7485
|
indicator: "explicit-key-ind",
|
|
7486
|
-
next: key ??
|
|
7486
|
+
next: key ?? sep?.[0],
|
|
7487
7487
|
offset,
|
|
7488
7488
|
onError,
|
|
7489
7489
|
parentIndent: bm.indent,
|
|
@@ -7497,7 +7497,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
7497
7497
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
7498
7498
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
7499
7499
|
}
|
|
7500
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
7500
|
+
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
7501
7501
|
commentEnd = keyProps.end;
|
|
7502
7502
|
if (keyProps.comment) {
|
|
7503
7503
|
if (map.comment)
|
|
@@ -7521,7 +7521,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
7521
7521
|
ctx.atKey = false;
|
|
7522
7522
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
7523
7523
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
7524
|
-
const valueProps = resolveProps.resolveProps(
|
|
7524
|
+
const valueProps = resolveProps.resolveProps(sep ?? [], {
|
|
7525
7525
|
indicator: "map-value-ind",
|
|
7526
7526
|
next: value,
|
|
7527
7527
|
offset: keyNode.range[2],
|
|
@@ -7537,7 +7537,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
7537
7537
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
7538
7538
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
7539
7539
|
}
|
|
7540
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
7540
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
|
|
7541
7541
|
if (ctx.schema.compat)
|
|
7542
7542
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
7543
7543
|
offset = valueNode.range[2];
|
|
@@ -7628,7 +7628,7 @@ var require_resolve_end = __commonJS({
|
|
|
7628
7628
|
let comment = "";
|
|
7629
7629
|
if (end) {
|
|
7630
7630
|
let hasSpace = false;
|
|
7631
|
-
let
|
|
7631
|
+
let sep = "";
|
|
7632
7632
|
for (const token of end) {
|
|
7633
7633
|
const { source, type } = token;
|
|
7634
7634
|
switch (type) {
|
|
@@ -7642,13 +7642,13 @@ var require_resolve_end = __commonJS({
|
|
|
7642
7642
|
if (!comment)
|
|
7643
7643
|
comment = cb;
|
|
7644
7644
|
else
|
|
7645
|
-
comment +=
|
|
7646
|
-
|
|
7645
|
+
comment += sep + cb;
|
|
7646
|
+
sep = "";
|
|
7647
7647
|
break;
|
|
7648
7648
|
}
|
|
7649
7649
|
case "newline":
|
|
7650
7650
|
if (comment)
|
|
7651
|
-
|
|
7651
|
+
sep += source;
|
|
7652
7652
|
hasSpace = true;
|
|
7653
7653
|
break;
|
|
7654
7654
|
default:
|
|
@@ -7691,18 +7691,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7691
7691
|
let offset = fc.offset + fc.start.source.length;
|
|
7692
7692
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
7693
7693
|
const collItem = fc.items[i];
|
|
7694
|
-
const { start, key, sep
|
|
7694
|
+
const { start, key, sep, value } = collItem;
|
|
7695
7695
|
const props = resolveProps.resolveProps(start, {
|
|
7696
7696
|
flow: fcName,
|
|
7697
7697
|
indicator: "explicit-key-ind",
|
|
7698
|
-
next: key ??
|
|
7698
|
+
next: key ?? sep?.[0],
|
|
7699
7699
|
offset,
|
|
7700
7700
|
onError,
|
|
7701
7701
|
parentIndent: fc.indent,
|
|
7702
7702
|
startOnNewline: false
|
|
7703
7703
|
});
|
|
7704
7704
|
if (!props.found) {
|
|
7705
|
-
if (!props.anchor && !props.tag && !
|
|
7705
|
+
if (!props.anchor && !props.tag && !sep && !value) {
|
|
7706
7706
|
if (i === 0 && props.comma)
|
|
7707
7707
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
7708
7708
|
else if (i < fc.items.length - 1)
|
|
@@ -7756,8 +7756,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7756
7756
|
}
|
|
7757
7757
|
}
|
|
7758
7758
|
}
|
|
7759
|
-
if (!isMap && !
|
|
7760
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
7759
|
+
if (!isMap && !sep && !props.found) {
|
|
7760
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError);
|
|
7761
7761
|
coll.items.push(valueNode);
|
|
7762
7762
|
offset = valueNode.range[2];
|
|
7763
7763
|
if (isBlock(value))
|
|
@@ -7769,7 +7769,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7769
7769
|
if (isBlock(key))
|
|
7770
7770
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
7771
7771
|
ctx.atKey = false;
|
|
7772
|
-
const valueProps = resolveProps.resolveProps(
|
|
7772
|
+
const valueProps = resolveProps.resolveProps(sep ?? [], {
|
|
7773
7773
|
flow: fcName,
|
|
7774
7774
|
indicator: "map-value-ind",
|
|
7775
7775
|
next: value,
|
|
@@ -7780,8 +7780,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7780
7780
|
});
|
|
7781
7781
|
if (valueProps.found) {
|
|
7782
7782
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
7783
|
-
if (
|
|
7784
|
-
for (const st of
|
|
7783
|
+
if (sep)
|
|
7784
|
+
for (const st of sep) {
|
|
7785
7785
|
if (st === valueProps.found)
|
|
7786
7786
|
break;
|
|
7787
7787
|
if (st.type === "newline") {
|
|
@@ -7798,7 +7798,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
7798
7798
|
else
|
|
7799
7799
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
7800
7800
|
}
|
|
7801
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
7801
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError) : null;
|
|
7802
7802
|
if (valueNode) {
|
|
7803
7803
|
if (isBlock(value))
|
|
7804
7804
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -7978,7 +7978,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
7978
7978
|
chompStart = i + 1;
|
|
7979
7979
|
}
|
|
7980
7980
|
let value = "";
|
|
7981
|
-
let
|
|
7981
|
+
let sep = "";
|
|
7982
7982
|
let prevMoreIndented = false;
|
|
7983
7983
|
for (let i = 0; i < contentStart; ++i)
|
|
7984
7984
|
value += lines[i][0].slice(trimIndent) + "\n";
|
|
@@ -7995,24 +7995,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
7995
7995
|
indent = "";
|
|
7996
7996
|
}
|
|
7997
7997
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
7998
|
-
value +=
|
|
7999
|
-
|
|
7998
|
+
value += sep + indent.slice(trimIndent) + content;
|
|
7999
|
+
sep = "\n";
|
|
8000
8000
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
8001
|
-
if (
|
|
8002
|
-
|
|
8003
|
-
else if (!prevMoreIndented &&
|
|
8004
|
-
|
|
8005
|
-
value +=
|
|
8006
|
-
|
|
8001
|
+
if (sep === " ")
|
|
8002
|
+
sep = "\n";
|
|
8003
|
+
else if (!prevMoreIndented && sep === "\n")
|
|
8004
|
+
sep = "\n\n";
|
|
8005
|
+
value += sep + indent.slice(trimIndent) + content;
|
|
8006
|
+
sep = "\n";
|
|
8007
8007
|
prevMoreIndented = true;
|
|
8008
8008
|
} else if (content === "") {
|
|
8009
|
-
if (
|
|
8009
|
+
if (sep === "\n")
|
|
8010
8010
|
value += "\n";
|
|
8011
8011
|
else
|
|
8012
|
-
|
|
8012
|
+
sep = "\n";
|
|
8013
8013
|
} else {
|
|
8014
|
-
value +=
|
|
8015
|
-
|
|
8014
|
+
value += sep + content;
|
|
8015
|
+
sep = " ";
|
|
8016
8016
|
prevMoreIndented = false;
|
|
8017
8017
|
}
|
|
8018
8018
|
}
|
|
@@ -8190,29 +8190,29 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
8190
8190
|
first = /(.*?)[ \t]*\r?\n/sy;
|
|
8191
8191
|
line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
|
|
8192
8192
|
}
|
|
8193
|
-
let
|
|
8194
|
-
if (!
|
|
8193
|
+
let match = first.exec(source);
|
|
8194
|
+
if (!match)
|
|
8195
8195
|
return source;
|
|
8196
|
-
let res =
|
|
8197
|
-
let
|
|
8196
|
+
let res = match[1];
|
|
8197
|
+
let sep = " ";
|
|
8198
8198
|
let pos = first.lastIndex;
|
|
8199
8199
|
line.lastIndex = pos;
|
|
8200
|
-
while (
|
|
8201
|
-
if (
|
|
8202
|
-
if (
|
|
8203
|
-
res +=
|
|
8200
|
+
while (match = line.exec(source)) {
|
|
8201
|
+
if (match[1] === "") {
|
|
8202
|
+
if (sep === "\n")
|
|
8203
|
+
res += sep;
|
|
8204
8204
|
else
|
|
8205
|
-
|
|
8205
|
+
sep = "\n";
|
|
8206
8206
|
} else {
|
|
8207
|
-
res +=
|
|
8208
|
-
|
|
8207
|
+
res += sep + match[1];
|
|
8208
|
+
sep = " ";
|
|
8209
8209
|
}
|
|
8210
8210
|
pos = line.lastIndex;
|
|
8211
8211
|
}
|
|
8212
8212
|
const last = /[ \t]*(.*)/sy;
|
|
8213
8213
|
last.lastIndex = pos;
|
|
8214
|
-
|
|
8215
|
-
return res +
|
|
8214
|
+
match = last.exec(source);
|
|
8215
|
+
return res + sep + (match?.[1] ?? "");
|
|
8216
8216
|
}
|
|
8217
8217
|
function doubleQuotedValue(source, onError) {
|
|
8218
8218
|
let res = "";
|
|
@@ -8333,7 +8333,7 @@ var require_compose_scalar = __commonJS({
|
|
|
8333
8333
|
var resolveBlockScalar = require_resolve_block_scalar();
|
|
8334
8334
|
var resolveFlowScalar = require_resolve_flow_scalar();
|
|
8335
8335
|
function composeScalar(ctx, token, tagToken, onError) {
|
|
8336
|
-
const { value, type, comment, range
|
|
8336
|
+
const { value, type, comment, range } = token.type === "block-scalar" ? resolveBlockScalar.resolveBlockScalar(ctx, token, onError) : resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError);
|
|
8337
8337
|
const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null;
|
|
8338
8338
|
let tag;
|
|
8339
8339
|
if (ctx.options.stringKeys && ctx.atKey) {
|
|
@@ -8353,7 +8353,7 @@ var require_compose_scalar = __commonJS({
|
|
|
8353
8353
|
onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
|
|
8354
8354
|
scalar = new Scalar.Scalar(value);
|
|
8355
8355
|
}
|
|
8356
|
-
scalar.range =
|
|
8356
|
+
scalar.range = range;
|
|
8357
8357
|
scalar.source = value;
|
|
8358
8358
|
if (type)
|
|
8359
8359
|
scalar.type = type;
|
|
@@ -9014,14 +9014,14 @@ var require_cst_stringify = __commonJS({
|
|
|
9014
9014
|
}
|
|
9015
9015
|
}
|
|
9016
9016
|
}
|
|
9017
|
-
function stringifyItem({ start, key, sep
|
|
9017
|
+
function stringifyItem({ start, key, sep, value }) {
|
|
9018
9018
|
let res = "";
|
|
9019
9019
|
for (const st of start)
|
|
9020
9020
|
res += st.source;
|
|
9021
9021
|
if (key)
|
|
9022
9022
|
res += stringifyToken(key);
|
|
9023
|
-
if (
|
|
9024
|
-
for (const st of
|
|
9023
|
+
if (sep)
|
|
9024
|
+
for (const st of sep)
|
|
9025
9025
|
res += st.source;
|
|
9026
9026
|
if (value)
|
|
9027
9027
|
res += stringifyToken(value);
|
|
@@ -9046,9 +9046,9 @@ var require_cst_visit = __commonJS({
|
|
|
9046
9046
|
visit.BREAK = BREAK;
|
|
9047
9047
|
visit.SKIP = SKIP;
|
|
9048
9048
|
visit.REMOVE = REMOVE;
|
|
9049
|
-
visit.itemAtPath = (cst,
|
|
9049
|
+
visit.itemAtPath = (cst, path4) => {
|
|
9050
9050
|
let item = cst;
|
|
9051
|
-
for (const [field, index] of
|
|
9051
|
+
for (const [field, index] of path4) {
|
|
9052
9052
|
const tok = item?.[field];
|
|
9053
9053
|
if (tok && "items" in tok) {
|
|
9054
9054
|
item = tok.items[index];
|
|
@@ -9057,23 +9057,23 @@ var require_cst_visit = __commonJS({
|
|
|
9057
9057
|
}
|
|
9058
9058
|
return item;
|
|
9059
9059
|
};
|
|
9060
|
-
visit.parentCollection = (cst,
|
|
9061
|
-
const parent = visit.itemAtPath(cst,
|
|
9062
|
-
const field =
|
|
9060
|
+
visit.parentCollection = (cst, path4) => {
|
|
9061
|
+
const parent = visit.itemAtPath(cst, path4.slice(0, -1));
|
|
9062
|
+
const field = path4[path4.length - 1][0];
|
|
9063
9063
|
const coll = parent?.[field];
|
|
9064
9064
|
if (coll && "items" in coll)
|
|
9065
9065
|
return coll;
|
|
9066
9066
|
throw new Error("Parent collection not found");
|
|
9067
9067
|
};
|
|
9068
|
-
function _visit(
|
|
9069
|
-
let ctrl = visitor(item,
|
|
9068
|
+
function _visit(path4, item, visitor) {
|
|
9069
|
+
let ctrl = visitor(item, path4);
|
|
9070
9070
|
if (typeof ctrl === "symbol")
|
|
9071
9071
|
return ctrl;
|
|
9072
9072
|
for (const field of ["key", "value"]) {
|
|
9073
9073
|
const token = item[field];
|
|
9074
9074
|
if (token && "items" in token) {
|
|
9075
9075
|
for (let i = 0; i < token.items.length; ++i) {
|
|
9076
|
-
const ci = _visit(Object.freeze(
|
|
9076
|
+
const ci = _visit(Object.freeze(path4.concat([[field, i]])), token.items[i], visitor);
|
|
9077
9077
|
if (typeof ci === "number")
|
|
9078
9078
|
i = ci - 1;
|
|
9079
9079
|
else if (ci === BREAK)
|
|
@@ -9084,10 +9084,10 @@ var require_cst_visit = __commonJS({
|
|
|
9084
9084
|
}
|
|
9085
9085
|
}
|
|
9086
9086
|
if (typeof ctrl === "function" && field === "key")
|
|
9087
|
-
ctrl = ctrl(item,
|
|
9087
|
+
ctrl = ctrl(item, path4);
|
|
9088
9088
|
}
|
|
9089
9089
|
}
|
|
9090
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
9090
|
+
return typeof ctrl === "function" ? ctrl(item, path4) : ctrl;
|
|
9091
9091
|
}
|
|
9092
9092
|
exports2.visit = visit;
|
|
9093
9093
|
}
|
|
@@ -10171,18 +10171,18 @@ var require_parser = __commonJS({
|
|
|
10171
10171
|
if (this.type === "map-value-ind") {
|
|
10172
10172
|
const prev = getPrevProps(this.peek(2));
|
|
10173
10173
|
const start = getFirstKeyStartProps(prev);
|
|
10174
|
-
let
|
|
10174
|
+
let sep;
|
|
10175
10175
|
if (scalar.end) {
|
|
10176
|
-
|
|
10177
|
-
|
|
10176
|
+
sep = scalar.end;
|
|
10177
|
+
sep.push(this.sourceToken);
|
|
10178
10178
|
delete scalar.end;
|
|
10179
10179
|
} else
|
|
10180
|
-
|
|
10180
|
+
sep = [this.sourceToken];
|
|
10181
10181
|
const map = {
|
|
10182
10182
|
type: "block-map",
|
|
10183
10183
|
offset: scalar.offset,
|
|
10184
10184
|
indent: scalar.indent,
|
|
10185
|
-
items: [{ start, key: scalar, sep
|
|
10185
|
+
items: [{ start, key: scalar, sep }]
|
|
10186
10186
|
};
|
|
10187
10187
|
this.onKeyLine = true;
|
|
10188
10188
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -10335,15 +10335,15 @@ var require_parser = __commonJS({
|
|
|
10335
10335
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
10336
10336
|
const start2 = getFirstKeyStartProps(it.start);
|
|
10337
10337
|
const key = it.key;
|
|
10338
|
-
const
|
|
10339
|
-
|
|
10338
|
+
const sep = it.sep;
|
|
10339
|
+
sep.push(this.sourceToken);
|
|
10340
10340
|
delete it.key;
|
|
10341
10341
|
delete it.sep;
|
|
10342
10342
|
this.stack.push({
|
|
10343
10343
|
type: "block-map",
|
|
10344
10344
|
offset: this.offset,
|
|
10345
10345
|
indent: this.indent,
|
|
10346
|
-
items: [{ start: start2, key, sep
|
|
10346
|
+
items: [{ start: start2, key, sep }]
|
|
10347
10347
|
});
|
|
10348
10348
|
} else if (start.length > 0) {
|
|
10349
10349
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -10537,13 +10537,13 @@ var require_parser = __commonJS({
|
|
|
10537
10537
|
const prev = getPrevProps(parent);
|
|
10538
10538
|
const start = getFirstKeyStartProps(prev);
|
|
10539
10539
|
fixFlowSeqItems(fc);
|
|
10540
|
-
const
|
|
10541
|
-
|
|
10540
|
+
const sep = fc.end.splice(1, fc.end.length);
|
|
10541
|
+
sep.push(this.sourceToken);
|
|
10542
10542
|
const map = {
|
|
10543
10543
|
type: "block-map",
|
|
10544
10544
|
offset: fc.offset,
|
|
10545
10545
|
indent: fc.indent,
|
|
10546
|
-
items: [{ start, key: fc, sep
|
|
10546
|
+
items: [{ start, key: fc, sep }]
|
|
10547
10547
|
};
|
|
10548
10548
|
this.onKeyLine = true;
|
|
10549
10549
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -12290,37 +12290,37 @@ var require_dataType = __commonJS({
|
|
|
12290
12290
|
DataType2[DataType2["Wrong"] = 1] = "Wrong";
|
|
12291
12291
|
})(DataType || (exports2.DataType = DataType = {}));
|
|
12292
12292
|
function getSchemaTypes(schema) {
|
|
12293
|
-
const
|
|
12294
|
-
const hasNull =
|
|
12293
|
+
const types = getJSONTypes(schema.type);
|
|
12294
|
+
const hasNull = types.includes("null");
|
|
12295
12295
|
if (hasNull) {
|
|
12296
12296
|
if (schema.nullable === false)
|
|
12297
12297
|
throw new Error("type: null contradicts nullable: false");
|
|
12298
12298
|
} else {
|
|
12299
|
-
if (!
|
|
12299
|
+
if (!types.length && schema.nullable !== void 0) {
|
|
12300
12300
|
throw new Error('"nullable" cannot be used without "type"');
|
|
12301
12301
|
}
|
|
12302
12302
|
if (schema.nullable === true)
|
|
12303
|
-
|
|
12303
|
+
types.push("null");
|
|
12304
12304
|
}
|
|
12305
|
-
return
|
|
12305
|
+
return types;
|
|
12306
12306
|
}
|
|
12307
12307
|
exports2.getSchemaTypes = getSchemaTypes;
|
|
12308
12308
|
function getJSONTypes(ts) {
|
|
12309
|
-
const
|
|
12310
|
-
if (
|
|
12311
|
-
return
|
|
12312
|
-
throw new Error("type must be JSONType or JSONType[]: " +
|
|
12309
|
+
const types = Array.isArray(ts) ? ts : ts ? [ts] : [];
|
|
12310
|
+
if (types.every(rules_1.isJSONType))
|
|
12311
|
+
return types;
|
|
12312
|
+
throw new Error("type must be JSONType or JSONType[]: " + types.join(","));
|
|
12313
12313
|
}
|
|
12314
12314
|
exports2.getJSONTypes = getJSONTypes;
|
|
12315
|
-
function coerceAndCheckDataType(it,
|
|
12315
|
+
function coerceAndCheckDataType(it, types) {
|
|
12316
12316
|
const { gen, data, opts } = it;
|
|
12317
|
-
const coerceTo = coerceToTypes(
|
|
12318
|
-
const checkTypes =
|
|
12317
|
+
const coerceTo = coerceToTypes(types, opts.coerceTypes);
|
|
12318
|
+
const checkTypes = types.length > 0 && !(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0]));
|
|
12319
12319
|
if (checkTypes) {
|
|
12320
|
-
const wrongType = checkDataTypes(
|
|
12320
|
+
const wrongType = checkDataTypes(types, data, opts.strictNumbers, DataType.Wrong);
|
|
12321
12321
|
gen.if(wrongType, () => {
|
|
12322
12322
|
if (coerceTo.length)
|
|
12323
|
-
coerceData(it,
|
|
12323
|
+
coerceData(it, types, coerceTo);
|
|
12324
12324
|
else
|
|
12325
12325
|
reportTypeError(it);
|
|
12326
12326
|
});
|
|
@@ -12329,15 +12329,15 @@ var require_dataType = __commonJS({
|
|
|
12329
12329
|
}
|
|
12330
12330
|
exports2.coerceAndCheckDataType = coerceAndCheckDataType;
|
|
12331
12331
|
var COERCIBLE = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
|
|
12332
|
-
function coerceToTypes(
|
|
12333
|
-
return coerceTypes ?
|
|
12332
|
+
function coerceToTypes(types, coerceTypes) {
|
|
12333
|
+
return coerceTypes ? types.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
|
|
12334
12334
|
}
|
|
12335
|
-
function coerceData(it,
|
|
12335
|
+
function coerceData(it, types, coerceTo) {
|
|
12336
12336
|
const { gen, data, opts } = it;
|
|
12337
12337
|
const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data}`);
|
|
12338
12338
|
const coerced = gen.let("coerced", (0, codegen_1._)`undefined`);
|
|
12339
12339
|
if (opts.coerceTypes === "array") {
|
|
12340
|
-
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(
|
|
12340
|
+
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types, data, opts.strictNumbers), () => gen.assign(coerced, data)));
|
|
12341
12341
|
}
|
|
12342
12342
|
gen.if((0, codegen_1._)`${coerced} !== undefined`);
|
|
12343
12343
|
for (const t of coerceTo) {
|
|
@@ -12413,19 +12413,19 @@ var require_dataType = __commonJS({
|
|
|
12413
12413
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
12414
12414
|
}
|
|
12415
12415
|
let cond;
|
|
12416
|
-
const
|
|
12417
|
-
if (
|
|
12416
|
+
const types = (0, util_1.toHash)(dataTypes);
|
|
12417
|
+
if (types.array && types.object) {
|
|
12418
12418
|
const notObj = (0, codegen_1._)`typeof ${data} != "object"`;
|
|
12419
|
-
cond =
|
|
12420
|
-
delete
|
|
12421
|
-
delete
|
|
12422
|
-
delete
|
|
12419
|
+
cond = types.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
|
|
12420
|
+
delete types.null;
|
|
12421
|
+
delete types.array;
|
|
12422
|
+
delete types.object;
|
|
12423
12423
|
} else {
|
|
12424
12424
|
cond = codegen_1.nil;
|
|
12425
12425
|
}
|
|
12426
|
-
if (
|
|
12427
|
-
delete
|
|
12428
|
-
for (const t in
|
|
12426
|
+
if (types.number)
|
|
12427
|
+
delete types.integer;
|
|
12428
|
+
for (const t in types)
|
|
12429
12429
|
cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct));
|
|
12430
12430
|
return cond;
|
|
12431
12431
|
}
|
|
@@ -13230,9 +13230,9 @@ var require_validate = __commonJS({
|
|
|
13230
13230
|
function typeAndKeywords(it, errsCount) {
|
|
13231
13231
|
if (it.opts.jtd)
|
|
13232
13232
|
return schemaKeywords(it, [], false, errsCount);
|
|
13233
|
-
const
|
|
13234
|
-
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it,
|
|
13235
|
-
schemaKeywords(it,
|
|
13233
|
+
const types = (0, dataType_1.getSchemaTypes)(it.schema);
|
|
13234
|
+
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types);
|
|
13235
|
+
schemaKeywords(it, types, !checkedTypes, errsCount);
|
|
13236
13236
|
}
|
|
13237
13237
|
function checkRefsAndKeywords(it) {
|
|
13238
13238
|
const { schema, errSchemaPath, opts, self } = it;
|
|
@@ -13282,7 +13282,7 @@ var require_validate = __commonJS({
|
|
|
13282
13282
|
if (items instanceof codegen_1.Name)
|
|
13283
13283
|
gen.assign((0, codegen_1._)`${evaluated}.items`, items);
|
|
13284
13284
|
}
|
|
13285
|
-
function schemaKeywords(it,
|
|
13285
|
+
function schemaKeywords(it, types, typeErrors, errsCount) {
|
|
13286
13286
|
const { gen, schema, data, allErrors, opts, self } = it;
|
|
13287
13287
|
const { RULES } = self;
|
|
13288
13288
|
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
|
|
@@ -13290,7 +13290,7 @@ var require_validate = __commonJS({
|
|
|
13290
13290
|
return;
|
|
13291
13291
|
}
|
|
13292
13292
|
if (!opts.jtd)
|
|
13293
|
-
checkStrictTypes(it,
|
|
13293
|
+
checkStrictTypes(it, types);
|
|
13294
13294
|
gen.block(() => {
|
|
13295
13295
|
for (const group of RULES.rules)
|
|
13296
13296
|
groupKeywords(group);
|
|
@@ -13302,7 +13302,7 @@ var require_validate = __commonJS({
|
|
|
13302
13302
|
if (group.type) {
|
|
13303
13303
|
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
13304
13304
|
iterateKeywords(it, group);
|
|
13305
|
-
if (
|
|
13305
|
+
if (types.length === 1 && types[0] === group.type && typeErrors) {
|
|
13306
13306
|
gen.else();
|
|
13307
13307
|
(0, dataType_2.reportTypeError)(it);
|
|
13308
13308
|
}
|
|
@@ -13326,27 +13326,27 @@ var require_validate = __commonJS({
|
|
|
13326
13326
|
}
|
|
13327
13327
|
});
|
|
13328
13328
|
}
|
|
13329
|
-
function checkStrictTypes(it,
|
|
13329
|
+
function checkStrictTypes(it, types) {
|
|
13330
13330
|
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
13331
13331
|
return;
|
|
13332
|
-
checkContextTypes(it,
|
|
13332
|
+
checkContextTypes(it, types);
|
|
13333
13333
|
if (!it.opts.allowUnionTypes)
|
|
13334
|
-
checkMultipleTypes(it,
|
|
13334
|
+
checkMultipleTypes(it, types);
|
|
13335
13335
|
checkKeywordTypes(it, it.dataTypes);
|
|
13336
13336
|
}
|
|
13337
|
-
function checkContextTypes(it,
|
|
13338
|
-
if (!
|
|
13337
|
+
function checkContextTypes(it, types) {
|
|
13338
|
+
if (!types.length)
|
|
13339
13339
|
return;
|
|
13340
13340
|
if (!it.dataTypes.length) {
|
|
13341
|
-
it.dataTypes =
|
|
13341
|
+
it.dataTypes = types;
|
|
13342
13342
|
return;
|
|
13343
13343
|
}
|
|
13344
|
-
|
|
13344
|
+
types.forEach((t) => {
|
|
13345
13345
|
if (!includesType(it.dataTypes, t)) {
|
|
13346
13346
|
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
13347
13347
|
}
|
|
13348
13348
|
});
|
|
13349
|
-
narrowSchemaTypes(it,
|
|
13349
|
+
narrowSchemaTypes(it, types);
|
|
13350
13350
|
}
|
|
13351
13351
|
function checkMultipleTypes(it, ts) {
|
|
13352
13352
|
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
@@ -14014,8 +14014,8 @@ var require_utils = __commonJS({
|
|
|
14014
14014
|
}
|
|
14015
14015
|
return ind;
|
|
14016
14016
|
}
|
|
14017
|
-
function removeDotSegments(
|
|
14018
|
-
let input =
|
|
14017
|
+
function removeDotSegments(path4) {
|
|
14018
|
+
let input = path4;
|
|
14019
14019
|
const output = [];
|
|
14020
14020
|
let nextSlash = -1;
|
|
14021
14021
|
let len = 0;
|
|
@@ -14214,8 +14214,8 @@ var require_schemes = __commonJS({
|
|
|
14214
14214
|
wsComponent.secure = void 0;
|
|
14215
14215
|
}
|
|
14216
14216
|
if (wsComponent.resourceName) {
|
|
14217
|
-
const [
|
|
14218
|
-
wsComponent.path =
|
|
14217
|
+
const [path4, query] = wsComponent.resourceName.split("?");
|
|
14218
|
+
wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
|
|
14219
14219
|
wsComponent.query = query;
|
|
14220
14220
|
wsComponent.resourceName = void 0;
|
|
14221
14221
|
}
|
|
@@ -17600,1561 +17600,13 @@ var {
|
|
|
17600
17600
|
|
|
17601
17601
|
// src/commands/scan.ts
|
|
17602
17602
|
var fs = __toESM(require("fs"));
|
|
17603
|
-
var
|
|
17604
|
-
|
|
17605
|
-
// node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
17606
|
-
var balanced = (a, b, str) => {
|
|
17607
|
-
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
17608
|
-
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
17609
|
-
const r = ma !== null && mb != null && range(ma, mb, str);
|
|
17610
|
-
return r && {
|
|
17611
|
-
start: r[0],
|
|
17612
|
-
end: r[1],
|
|
17613
|
-
pre: str.slice(0, r[0]),
|
|
17614
|
-
body: str.slice(r[0] + ma.length, r[1]),
|
|
17615
|
-
post: str.slice(r[1] + mb.length)
|
|
17616
|
-
};
|
|
17617
|
-
};
|
|
17618
|
-
var maybeMatch = (reg, str) => {
|
|
17619
|
-
const m = str.match(reg);
|
|
17620
|
-
return m ? m[0] : null;
|
|
17621
|
-
};
|
|
17622
|
-
var range = (a, b, str) => {
|
|
17623
|
-
let begs, beg, left, right = void 0, result;
|
|
17624
|
-
let ai = str.indexOf(a);
|
|
17625
|
-
let bi = str.indexOf(b, ai + 1);
|
|
17626
|
-
let i = ai;
|
|
17627
|
-
if (ai >= 0 && bi > 0) {
|
|
17628
|
-
if (a === b) {
|
|
17629
|
-
return [ai, bi];
|
|
17630
|
-
}
|
|
17631
|
-
begs = [];
|
|
17632
|
-
left = str.length;
|
|
17633
|
-
while (i >= 0 && !result) {
|
|
17634
|
-
if (i === ai) {
|
|
17635
|
-
begs.push(i);
|
|
17636
|
-
ai = str.indexOf(a, i + 1);
|
|
17637
|
-
} else if (begs.length === 1) {
|
|
17638
|
-
const r = begs.pop();
|
|
17639
|
-
if (r !== void 0)
|
|
17640
|
-
result = [r, bi];
|
|
17641
|
-
} else {
|
|
17642
|
-
beg = begs.pop();
|
|
17643
|
-
if (beg !== void 0 && beg < left) {
|
|
17644
|
-
left = beg;
|
|
17645
|
-
right = bi;
|
|
17646
|
-
}
|
|
17647
|
-
bi = str.indexOf(b, i + 1);
|
|
17648
|
-
}
|
|
17649
|
-
i = ai < bi && ai >= 0 ? ai : bi;
|
|
17650
|
-
}
|
|
17651
|
-
if (begs.length && right !== void 0) {
|
|
17652
|
-
result = [left, right];
|
|
17653
|
-
}
|
|
17654
|
-
}
|
|
17655
|
-
return result;
|
|
17656
|
-
};
|
|
17657
|
-
|
|
17658
|
-
// node_modules/@isaacs/brace-expansion/dist/esm/index.js
|
|
17659
|
-
var escSlash = "\0SLASH" + Math.random() + "\0";
|
|
17660
|
-
var escOpen = "\0OPEN" + Math.random() + "\0";
|
|
17661
|
-
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
17662
|
-
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
17663
|
-
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
17664
|
-
var escSlashPattern = new RegExp(escSlash, "g");
|
|
17665
|
-
var escOpenPattern = new RegExp(escOpen, "g");
|
|
17666
|
-
var escClosePattern = new RegExp(escClose, "g");
|
|
17667
|
-
var escCommaPattern = new RegExp(escComma, "g");
|
|
17668
|
-
var escPeriodPattern = new RegExp(escPeriod, "g");
|
|
17669
|
-
var slashPattern = /\\\\/g;
|
|
17670
|
-
var openPattern = /\\{/g;
|
|
17671
|
-
var closePattern = /\\}/g;
|
|
17672
|
-
var commaPattern = /\\,/g;
|
|
17673
|
-
var periodPattern = /\\./g;
|
|
17674
|
-
function numeric(str) {
|
|
17675
|
-
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
17676
|
-
}
|
|
17677
|
-
function escapeBraces(str) {
|
|
17678
|
-
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
17679
|
-
}
|
|
17680
|
-
function unescapeBraces(str) {
|
|
17681
|
-
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
|
|
17682
|
-
}
|
|
17683
|
-
function parseCommaParts(str) {
|
|
17684
|
-
if (!str) {
|
|
17685
|
-
return [""];
|
|
17686
|
-
}
|
|
17687
|
-
const parts = [];
|
|
17688
|
-
const m = balanced("{", "}", str);
|
|
17689
|
-
if (!m) {
|
|
17690
|
-
return str.split(",");
|
|
17691
|
-
}
|
|
17692
|
-
const { pre, body, post } = m;
|
|
17693
|
-
const p = pre.split(",");
|
|
17694
|
-
p[p.length - 1] += "{" + body + "}";
|
|
17695
|
-
const postParts = parseCommaParts(post);
|
|
17696
|
-
if (post.length) {
|
|
17697
|
-
;
|
|
17698
|
-
p[p.length - 1] += postParts.shift();
|
|
17699
|
-
p.push.apply(p, postParts);
|
|
17700
|
-
}
|
|
17701
|
-
parts.push.apply(parts, p);
|
|
17702
|
-
return parts;
|
|
17703
|
-
}
|
|
17704
|
-
function expand(str) {
|
|
17705
|
-
if (!str) {
|
|
17706
|
-
return [];
|
|
17707
|
-
}
|
|
17708
|
-
if (str.slice(0, 2) === "{}") {
|
|
17709
|
-
str = "\\{\\}" + str.slice(2);
|
|
17710
|
-
}
|
|
17711
|
-
return expand_(escapeBraces(str), true).map(unescapeBraces);
|
|
17712
|
-
}
|
|
17713
|
-
function embrace(str) {
|
|
17714
|
-
return "{" + str + "}";
|
|
17715
|
-
}
|
|
17716
|
-
function isPadded(el) {
|
|
17717
|
-
return /^-?0\d/.test(el);
|
|
17718
|
-
}
|
|
17719
|
-
function lte(i, y) {
|
|
17720
|
-
return i <= y;
|
|
17721
|
-
}
|
|
17722
|
-
function gte(i, y) {
|
|
17723
|
-
return i >= y;
|
|
17724
|
-
}
|
|
17725
|
-
function expand_(str, isTop) {
|
|
17726
|
-
const expansions = [];
|
|
17727
|
-
const m = balanced("{", "}", str);
|
|
17728
|
-
if (!m)
|
|
17729
|
-
return [str];
|
|
17730
|
-
const pre = m.pre;
|
|
17731
|
-
const post = m.post.length ? expand_(m.post, false) : [""];
|
|
17732
|
-
if (/\$$/.test(m.pre)) {
|
|
17733
|
-
for (let k = 0; k < post.length; k++) {
|
|
17734
|
-
const expansion = pre + "{" + m.body + "}" + post[k];
|
|
17735
|
-
expansions.push(expansion);
|
|
17736
|
-
}
|
|
17737
|
-
} else {
|
|
17738
|
-
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
17739
|
-
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
17740
|
-
const isSequence = isNumericSequence || isAlphaSequence;
|
|
17741
|
-
const isOptions = m.body.indexOf(",") >= 0;
|
|
17742
|
-
if (!isSequence && !isOptions) {
|
|
17743
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
17744
|
-
str = m.pre + "{" + m.body + escClose + m.post;
|
|
17745
|
-
return expand_(str);
|
|
17746
|
-
}
|
|
17747
|
-
return [str];
|
|
17748
|
-
}
|
|
17749
|
-
let n;
|
|
17750
|
-
if (isSequence) {
|
|
17751
|
-
n = m.body.split(/\.\./);
|
|
17752
|
-
} else {
|
|
17753
|
-
n = parseCommaParts(m.body);
|
|
17754
|
-
if (n.length === 1 && n[0] !== void 0) {
|
|
17755
|
-
n = expand_(n[0], false).map(embrace);
|
|
17756
|
-
if (n.length === 1) {
|
|
17757
|
-
return post.map((p) => m.pre + n[0] + p);
|
|
17758
|
-
}
|
|
17759
|
-
}
|
|
17760
|
-
}
|
|
17761
|
-
let N;
|
|
17762
|
-
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
|
|
17763
|
-
const x = numeric(n[0]);
|
|
17764
|
-
const y = numeric(n[1]);
|
|
17765
|
-
const width = Math.max(n[0].length, n[1].length);
|
|
17766
|
-
let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
|
|
17767
|
-
let test = lte;
|
|
17768
|
-
const reverse = y < x;
|
|
17769
|
-
if (reverse) {
|
|
17770
|
-
incr *= -1;
|
|
17771
|
-
test = gte;
|
|
17772
|
-
}
|
|
17773
|
-
const pad = n.some(isPadded);
|
|
17774
|
-
N = [];
|
|
17775
|
-
for (let i = x; test(i, y); i += incr) {
|
|
17776
|
-
let c;
|
|
17777
|
-
if (isAlphaSequence) {
|
|
17778
|
-
c = String.fromCharCode(i);
|
|
17779
|
-
if (c === "\\") {
|
|
17780
|
-
c = "";
|
|
17781
|
-
}
|
|
17782
|
-
} else {
|
|
17783
|
-
c = String(i);
|
|
17784
|
-
if (pad) {
|
|
17785
|
-
const need = width - c.length;
|
|
17786
|
-
if (need > 0) {
|
|
17787
|
-
const z = new Array(need + 1).join("0");
|
|
17788
|
-
if (i < 0) {
|
|
17789
|
-
c = "-" + z + c.slice(1);
|
|
17790
|
-
} else {
|
|
17791
|
-
c = z + c;
|
|
17792
|
-
}
|
|
17793
|
-
}
|
|
17794
|
-
}
|
|
17795
|
-
}
|
|
17796
|
-
N.push(c);
|
|
17797
|
-
}
|
|
17798
|
-
} else {
|
|
17799
|
-
N = [];
|
|
17800
|
-
for (let j = 0; j < n.length; j++) {
|
|
17801
|
-
N.push.apply(N, expand_(n[j], false));
|
|
17802
|
-
}
|
|
17803
|
-
}
|
|
17804
|
-
for (let j = 0; j < N.length; j++) {
|
|
17805
|
-
for (let k = 0; k < post.length; k++) {
|
|
17806
|
-
const expansion = pre + N[j] + post[k];
|
|
17807
|
-
if (!isTop || isSequence || expansion) {
|
|
17808
|
-
expansions.push(expansion);
|
|
17809
|
-
}
|
|
17810
|
-
}
|
|
17811
|
-
}
|
|
17812
|
-
}
|
|
17813
|
-
return expansions;
|
|
17814
|
-
}
|
|
17815
|
-
|
|
17816
|
-
// node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
17817
|
-
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
17818
|
-
var assertValidPattern = (pattern) => {
|
|
17819
|
-
if (typeof pattern !== "string") {
|
|
17820
|
-
throw new TypeError("invalid pattern");
|
|
17821
|
-
}
|
|
17822
|
-
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
17823
|
-
throw new TypeError("pattern is too long");
|
|
17824
|
-
}
|
|
17825
|
-
};
|
|
17826
|
-
|
|
17827
|
-
// node_modules/minimatch/dist/esm/brace-expressions.js
|
|
17828
|
-
var posixClasses = {
|
|
17829
|
-
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
17830
|
-
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
17831
|
-
"[:ascii:]": ["\\x00-\\x7f", false],
|
|
17832
|
-
"[:blank:]": ["\\p{Zs}\\t", true],
|
|
17833
|
-
"[:cntrl:]": ["\\p{Cc}", true],
|
|
17834
|
-
"[:digit:]": ["\\p{Nd}", true],
|
|
17835
|
-
"[:graph:]": ["\\p{Z}\\p{C}", true, true],
|
|
17836
|
-
"[:lower:]": ["\\p{Ll}", true],
|
|
17837
|
-
"[:print:]": ["\\p{C}", true],
|
|
17838
|
-
"[:punct:]": ["\\p{P}", true],
|
|
17839
|
-
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
|
|
17840
|
-
"[:upper:]": ["\\p{Lu}", true],
|
|
17841
|
-
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
|
|
17842
|
-
"[:xdigit:]": ["A-Fa-f0-9", false]
|
|
17843
|
-
};
|
|
17844
|
-
var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
17845
|
-
var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
17846
|
-
var rangesToString = (ranges) => ranges.join("");
|
|
17847
|
-
var parseClass = (glob2, position) => {
|
|
17848
|
-
const pos = position;
|
|
17849
|
-
if (glob2.charAt(pos) !== "[") {
|
|
17850
|
-
throw new Error("not in a brace expression");
|
|
17851
|
-
}
|
|
17852
|
-
const ranges = [];
|
|
17853
|
-
const negs = [];
|
|
17854
|
-
let i = pos + 1;
|
|
17855
|
-
let sawStart = false;
|
|
17856
|
-
let uflag = false;
|
|
17857
|
-
let escaping = false;
|
|
17858
|
-
let negate = false;
|
|
17859
|
-
let endPos = pos;
|
|
17860
|
-
let rangeStart = "";
|
|
17861
|
-
WHILE: while (i < glob2.length) {
|
|
17862
|
-
const c = glob2.charAt(i);
|
|
17863
|
-
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
17864
|
-
negate = true;
|
|
17865
|
-
i++;
|
|
17866
|
-
continue;
|
|
17867
|
-
}
|
|
17868
|
-
if (c === "]" && sawStart && !escaping) {
|
|
17869
|
-
endPos = i + 1;
|
|
17870
|
-
break;
|
|
17871
|
-
}
|
|
17872
|
-
sawStart = true;
|
|
17873
|
-
if (c === "\\") {
|
|
17874
|
-
if (!escaping) {
|
|
17875
|
-
escaping = true;
|
|
17876
|
-
i++;
|
|
17877
|
-
continue;
|
|
17878
|
-
}
|
|
17879
|
-
}
|
|
17880
|
-
if (c === "[" && !escaping) {
|
|
17881
|
-
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
17882
|
-
if (glob2.startsWith(cls, i)) {
|
|
17883
|
-
if (rangeStart) {
|
|
17884
|
-
return ["$.", false, glob2.length - pos, true];
|
|
17885
|
-
}
|
|
17886
|
-
i += cls.length;
|
|
17887
|
-
if (neg)
|
|
17888
|
-
negs.push(unip);
|
|
17889
|
-
else
|
|
17890
|
-
ranges.push(unip);
|
|
17891
|
-
uflag = uflag || u;
|
|
17892
|
-
continue WHILE;
|
|
17893
|
-
}
|
|
17894
|
-
}
|
|
17895
|
-
}
|
|
17896
|
-
escaping = false;
|
|
17897
|
-
if (rangeStart) {
|
|
17898
|
-
if (c > rangeStart) {
|
|
17899
|
-
ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
|
|
17900
|
-
} else if (c === rangeStart) {
|
|
17901
|
-
ranges.push(braceEscape(c));
|
|
17902
|
-
}
|
|
17903
|
-
rangeStart = "";
|
|
17904
|
-
i++;
|
|
17905
|
-
continue;
|
|
17906
|
-
}
|
|
17907
|
-
if (glob2.startsWith("-]", i + 1)) {
|
|
17908
|
-
ranges.push(braceEscape(c + "-"));
|
|
17909
|
-
i += 2;
|
|
17910
|
-
continue;
|
|
17911
|
-
}
|
|
17912
|
-
if (glob2.startsWith("-", i + 1)) {
|
|
17913
|
-
rangeStart = c;
|
|
17914
|
-
i += 2;
|
|
17915
|
-
continue;
|
|
17916
|
-
}
|
|
17917
|
-
ranges.push(braceEscape(c));
|
|
17918
|
-
i++;
|
|
17919
|
-
}
|
|
17920
|
-
if (endPos < i) {
|
|
17921
|
-
return ["", false, 0, false];
|
|
17922
|
-
}
|
|
17923
|
-
if (!ranges.length && !negs.length) {
|
|
17924
|
-
return ["$.", false, glob2.length - pos, true];
|
|
17925
|
-
}
|
|
17926
|
-
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
17927
|
-
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
17928
|
-
return [regexpEscape(r), false, endPos - pos, false];
|
|
17929
|
-
}
|
|
17930
|
-
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
|
|
17931
|
-
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
17932
|
-
const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
|
|
17933
|
-
return [comb, uflag, endPos - pos, true];
|
|
17934
|
-
};
|
|
17935
|
-
|
|
17936
|
-
// node_modules/minimatch/dist/esm/unescape.js
|
|
17937
|
-
var unescape2 = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
17938
|
-
if (magicalBraces) {
|
|
17939
|
-
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
17940
|
-
}
|
|
17941
|
-
return windowsPathsNoEscape ? s.replace(/\[([^\/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
|
|
17942
|
-
};
|
|
17943
|
-
|
|
17944
|
-
// node_modules/minimatch/dist/esm/ast.js
|
|
17945
|
-
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
|
|
17946
|
-
var isExtglobType = (c) => types.has(c);
|
|
17947
|
-
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
17948
|
-
var startNoDot = "(?!\\.)";
|
|
17949
|
-
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
17950
|
-
var justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
17951
|
-
var reSpecials = new Set("().*{}+?[]^$\\!");
|
|
17952
|
-
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
17953
|
-
var qmark = "[^/]";
|
|
17954
|
-
var star = qmark + "*?";
|
|
17955
|
-
var starNoEmpty = qmark + "+?";
|
|
17956
|
-
var AST = class _AST {
|
|
17957
|
-
type;
|
|
17958
|
-
#root;
|
|
17959
|
-
#hasMagic;
|
|
17960
|
-
#uflag = false;
|
|
17961
|
-
#parts = [];
|
|
17962
|
-
#parent;
|
|
17963
|
-
#parentIndex;
|
|
17964
|
-
#negs;
|
|
17965
|
-
#filledNegs = false;
|
|
17966
|
-
#options;
|
|
17967
|
-
#toString;
|
|
17968
|
-
// set to true if it's an extglob with no children
|
|
17969
|
-
// (which really means one child of '')
|
|
17970
|
-
#emptyExt = false;
|
|
17971
|
-
constructor(type, parent, options = {}) {
|
|
17972
|
-
this.type = type;
|
|
17973
|
-
if (type)
|
|
17974
|
-
this.#hasMagic = true;
|
|
17975
|
-
this.#parent = parent;
|
|
17976
|
-
this.#root = this.#parent ? this.#parent.#root : this;
|
|
17977
|
-
this.#options = this.#root === this ? options : this.#root.#options;
|
|
17978
|
-
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
17979
|
-
if (type === "!" && !this.#root.#filledNegs)
|
|
17980
|
-
this.#negs.push(this);
|
|
17981
|
-
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
17982
|
-
}
|
|
17983
|
-
get hasMagic() {
|
|
17984
|
-
if (this.#hasMagic !== void 0)
|
|
17985
|
-
return this.#hasMagic;
|
|
17986
|
-
for (const p of this.#parts) {
|
|
17987
|
-
if (typeof p === "string")
|
|
17988
|
-
continue;
|
|
17989
|
-
if (p.type || p.hasMagic)
|
|
17990
|
-
return this.#hasMagic = true;
|
|
17991
|
-
}
|
|
17992
|
-
return this.#hasMagic;
|
|
17993
|
-
}
|
|
17994
|
-
// reconstructs the pattern
|
|
17995
|
-
toString() {
|
|
17996
|
-
if (this.#toString !== void 0)
|
|
17997
|
-
return this.#toString;
|
|
17998
|
-
if (!this.type) {
|
|
17999
|
-
return this.#toString = this.#parts.map((p) => String(p)).join("");
|
|
18000
|
-
} else {
|
|
18001
|
-
return this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
|
|
18002
|
-
}
|
|
18003
|
-
}
|
|
18004
|
-
#fillNegs() {
|
|
18005
|
-
if (this !== this.#root)
|
|
18006
|
-
throw new Error("should only call on root");
|
|
18007
|
-
if (this.#filledNegs)
|
|
18008
|
-
return this;
|
|
18009
|
-
this.toString();
|
|
18010
|
-
this.#filledNegs = true;
|
|
18011
|
-
let n;
|
|
18012
|
-
while (n = this.#negs.pop()) {
|
|
18013
|
-
if (n.type !== "!")
|
|
18014
|
-
continue;
|
|
18015
|
-
let p = n;
|
|
18016
|
-
let pp = p.#parent;
|
|
18017
|
-
while (pp) {
|
|
18018
|
-
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
|
|
18019
|
-
for (const part of n.#parts) {
|
|
18020
|
-
if (typeof part === "string") {
|
|
18021
|
-
throw new Error("string part in extglob AST??");
|
|
18022
|
-
}
|
|
18023
|
-
part.copyIn(pp.#parts[i]);
|
|
18024
|
-
}
|
|
18025
|
-
}
|
|
18026
|
-
p = pp;
|
|
18027
|
-
pp = p.#parent;
|
|
18028
|
-
}
|
|
18029
|
-
}
|
|
18030
|
-
return this;
|
|
18031
|
-
}
|
|
18032
|
-
push(...parts) {
|
|
18033
|
-
for (const p of parts) {
|
|
18034
|
-
if (p === "")
|
|
18035
|
-
continue;
|
|
18036
|
-
if (typeof p !== "string" && !(p instanceof _AST && p.#parent === this)) {
|
|
18037
|
-
throw new Error("invalid part: " + p);
|
|
18038
|
-
}
|
|
18039
|
-
this.#parts.push(p);
|
|
18040
|
-
}
|
|
18041
|
-
}
|
|
18042
|
-
toJSON() {
|
|
18043
|
-
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
18044
|
-
if (this.isStart() && !this.type)
|
|
18045
|
-
ret.unshift([]);
|
|
18046
|
-
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
|
|
18047
|
-
ret.push({});
|
|
18048
|
-
}
|
|
18049
|
-
return ret;
|
|
18050
|
-
}
|
|
18051
|
-
isStart() {
|
|
18052
|
-
if (this.#root === this)
|
|
18053
|
-
return true;
|
|
18054
|
-
if (!this.#parent?.isStart())
|
|
18055
|
-
return false;
|
|
18056
|
-
if (this.#parentIndex === 0)
|
|
18057
|
-
return true;
|
|
18058
|
-
const p = this.#parent;
|
|
18059
|
-
for (let i = 0; i < this.#parentIndex; i++) {
|
|
18060
|
-
const pp = p.#parts[i];
|
|
18061
|
-
if (!(pp instanceof _AST && pp.type === "!")) {
|
|
18062
|
-
return false;
|
|
18063
|
-
}
|
|
18064
|
-
}
|
|
18065
|
-
return true;
|
|
18066
|
-
}
|
|
18067
|
-
isEnd() {
|
|
18068
|
-
if (this.#root === this)
|
|
18069
|
-
return true;
|
|
18070
|
-
if (this.#parent?.type === "!")
|
|
18071
|
-
return true;
|
|
18072
|
-
if (!this.#parent?.isEnd())
|
|
18073
|
-
return false;
|
|
18074
|
-
if (!this.type)
|
|
18075
|
-
return this.#parent?.isEnd();
|
|
18076
|
-
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
18077
|
-
return this.#parentIndex === pl - 1;
|
|
18078
|
-
}
|
|
18079
|
-
copyIn(part) {
|
|
18080
|
-
if (typeof part === "string")
|
|
18081
|
-
this.push(part);
|
|
18082
|
-
else
|
|
18083
|
-
this.push(part.clone(this));
|
|
18084
|
-
}
|
|
18085
|
-
clone(parent) {
|
|
18086
|
-
const c = new _AST(this.type, parent);
|
|
18087
|
-
for (const p of this.#parts) {
|
|
18088
|
-
c.copyIn(p);
|
|
18089
|
-
}
|
|
18090
|
-
return c;
|
|
18091
|
-
}
|
|
18092
|
-
static #parseAST(str, ast, pos, opt) {
|
|
18093
|
-
let escaping = false;
|
|
18094
|
-
let inBrace = false;
|
|
18095
|
-
let braceStart = -1;
|
|
18096
|
-
let braceNeg = false;
|
|
18097
|
-
if (ast.type === null) {
|
|
18098
|
-
let i2 = pos;
|
|
18099
|
-
let acc2 = "";
|
|
18100
|
-
while (i2 < str.length) {
|
|
18101
|
-
const c = str.charAt(i2++);
|
|
18102
|
-
if (escaping || c === "\\") {
|
|
18103
|
-
escaping = !escaping;
|
|
18104
|
-
acc2 += c;
|
|
18105
|
-
continue;
|
|
18106
|
-
}
|
|
18107
|
-
if (inBrace) {
|
|
18108
|
-
if (i2 === braceStart + 1) {
|
|
18109
|
-
if (c === "^" || c === "!") {
|
|
18110
|
-
braceNeg = true;
|
|
18111
|
-
}
|
|
18112
|
-
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
|
18113
|
-
inBrace = false;
|
|
18114
|
-
}
|
|
18115
|
-
acc2 += c;
|
|
18116
|
-
continue;
|
|
18117
|
-
} else if (c === "[") {
|
|
18118
|
-
inBrace = true;
|
|
18119
|
-
braceStart = i2;
|
|
18120
|
-
braceNeg = false;
|
|
18121
|
-
acc2 += c;
|
|
18122
|
-
continue;
|
|
18123
|
-
}
|
|
18124
|
-
if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
|
|
18125
|
-
ast.push(acc2);
|
|
18126
|
-
acc2 = "";
|
|
18127
|
-
const ext2 = new _AST(c, ast);
|
|
18128
|
-
i2 = _AST.#parseAST(str, ext2, i2, opt);
|
|
18129
|
-
ast.push(ext2);
|
|
18130
|
-
continue;
|
|
18131
|
-
}
|
|
18132
|
-
acc2 += c;
|
|
18133
|
-
}
|
|
18134
|
-
ast.push(acc2);
|
|
18135
|
-
return i2;
|
|
18136
|
-
}
|
|
18137
|
-
let i = pos + 1;
|
|
18138
|
-
let part = new _AST(null, ast);
|
|
18139
|
-
const parts = [];
|
|
18140
|
-
let acc = "";
|
|
18141
|
-
while (i < str.length) {
|
|
18142
|
-
const c = str.charAt(i++);
|
|
18143
|
-
if (escaping || c === "\\") {
|
|
18144
|
-
escaping = !escaping;
|
|
18145
|
-
acc += c;
|
|
18146
|
-
continue;
|
|
18147
|
-
}
|
|
18148
|
-
if (inBrace) {
|
|
18149
|
-
if (i === braceStart + 1) {
|
|
18150
|
-
if (c === "^" || c === "!") {
|
|
18151
|
-
braceNeg = true;
|
|
18152
|
-
}
|
|
18153
|
-
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
|
|
18154
|
-
inBrace = false;
|
|
18155
|
-
}
|
|
18156
|
-
acc += c;
|
|
18157
|
-
continue;
|
|
18158
|
-
} else if (c === "[") {
|
|
18159
|
-
inBrace = true;
|
|
18160
|
-
braceStart = i;
|
|
18161
|
-
braceNeg = false;
|
|
18162
|
-
acc += c;
|
|
18163
|
-
continue;
|
|
18164
|
-
}
|
|
18165
|
-
if (isExtglobType(c) && str.charAt(i) === "(") {
|
|
18166
|
-
part.push(acc);
|
|
18167
|
-
acc = "";
|
|
18168
|
-
const ext2 = new _AST(c, part);
|
|
18169
|
-
part.push(ext2);
|
|
18170
|
-
i = _AST.#parseAST(str, ext2, i, opt);
|
|
18171
|
-
continue;
|
|
18172
|
-
}
|
|
18173
|
-
if (c === "|") {
|
|
18174
|
-
part.push(acc);
|
|
18175
|
-
acc = "";
|
|
18176
|
-
parts.push(part);
|
|
18177
|
-
part = new _AST(null, ast);
|
|
18178
|
-
continue;
|
|
18179
|
-
}
|
|
18180
|
-
if (c === ")") {
|
|
18181
|
-
if (acc === "" && ast.#parts.length === 0) {
|
|
18182
|
-
ast.#emptyExt = true;
|
|
18183
|
-
}
|
|
18184
|
-
part.push(acc);
|
|
18185
|
-
acc = "";
|
|
18186
|
-
ast.push(...parts, part);
|
|
18187
|
-
return i;
|
|
18188
|
-
}
|
|
18189
|
-
acc += c;
|
|
18190
|
-
}
|
|
18191
|
-
ast.type = null;
|
|
18192
|
-
ast.#hasMagic = void 0;
|
|
18193
|
-
ast.#parts = [str.substring(pos - 1)];
|
|
18194
|
-
return i;
|
|
18195
|
-
}
|
|
18196
|
-
static fromGlob(pattern, options = {}) {
|
|
18197
|
-
const ast = new _AST(null, void 0, options);
|
|
18198
|
-
_AST.#parseAST(pattern, ast, 0, options);
|
|
18199
|
-
return ast;
|
|
18200
|
-
}
|
|
18201
|
-
// returns the regular expression if there's magic, or the unescaped
|
|
18202
|
-
// string if not.
|
|
18203
|
-
toMMPattern() {
|
|
18204
|
-
if (this !== this.#root)
|
|
18205
|
-
return this.#root.toMMPattern();
|
|
18206
|
-
const glob2 = this.toString();
|
|
18207
|
-
const [re, body, hasMagic2, uflag] = this.toRegExpSource();
|
|
18208
|
-
const anyMagic = hasMagic2 || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob2.toUpperCase() !== glob2.toLowerCase();
|
|
18209
|
-
if (!anyMagic) {
|
|
18210
|
-
return body;
|
|
18211
|
-
}
|
|
18212
|
-
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
18213
|
-
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
18214
|
-
_src: re,
|
|
18215
|
-
_glob: glob2
|
|
18216
|
-
});
|
|
18217
|
-
}
|
|
18218
|
-
get options() {
|
|
18219
|
-
return this.#options;
|
|
18220
|
-
}
|
|
18221
|
-
// returns the string match, the regexp source, whether there's magic
|
|
18222
|
-
// in the regexp (so a regular expression is required) and whether or
|
|
18223
|
-
// not the uflag is needed for the regular expression (for posix classes)
|
|
18224
|
-
// TODO: instead of injecting the start/end at this point, just return
|
|
18225
|
-
// the BODY of the regexp, along with the start/end portions suitable
|
|
18226
|
-
// for binding the start/end in either a joined full-path makeRe context
|
|
18227
|
-
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
18228
|
-
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
18229
|
-
//
|
|
18230
|
-
// In part-matching mode, the start is:
|
|
18231
|
-
// - if not isStart: nothing
|
|
18232
|
-
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
18233
|
-
// - if dots allowed or not possible: ^
|
|
18234
|
-
// - if dots possible and not allowed: ^(?!\.)
|
|
18235
|
-
// end is:
|
|
18236
|
-
// - if not isEnd(): nothing
|
|
18237
|
-
// - else: $
|
|
18238
|
-
//
|
|
18239
|
-
// In full-path matching mode, we put the slash at the START of the
|
|
18240
|
-
// pattern, so start is:
|
|
18241
|
-
// - if first pattern: same as part-matching mode
|
|
18242
|
-
// - if not isStart(): nothing
|
|
18243
|
-
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
18244
|
-
// - if dots allowed or not possible: /
|
|
18245
|
-
// - if dots possible and not allowed: /(?!\.)
|
|
18246
|
-
// end is:
|
|
18247
|
-
// - if last pattern, same as part-matching mode
|
|
18248
|
-
// - else nothing
|
|
18249
|
-
//
|
|
18250
|
-
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
18251
|
-
// there to bind the end of the negated pattern portion, and it's easier to
|
|
18252
|
-
// just stick it in now rather than try to inject it later in the middle of
|
|
18253
|
-
// the pattern.
|
|
18254
|
-
//
|
|
18255
|
-
// We can just always return the same end, and leave it up to the caller
|
|
18256
|
-
// to know whether it's going to be used joined or in parts.
|
|
18257
|
-
// And, if the start is adjusted slightly, can do the same there:
|
|
18258
|
-
// - if not isStart: nothing
|
|
18259
|
-
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
18260
|
-
// - if dots allowed or not possible: (?:/|^)
|
|
18261
|
-
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
18262
|
-
//
|
|
18263
|
-
// But it's better to have a simpler binding without a conditional, for
|
|
18264
|
-
// performance, so probably better to return both start options.
|
|
18265
|
-
//
|
|
18266
|
-
// Then the caller just ignores the end if it's not the first pattern,
|
|
18267
|
-
// and the start always gets applied.
|
|
18268
|
-
//
|
|
18269
|
-
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
18270
|
-
// so the caller can just attach $ at the end of the pattern when building.
|
|
18271
|
-
//
|
|
18272
|
-
// So the todo is:
|
|
18273
|
-
// - better detect what kind of start is needed
|
|
18274
|
-
// - return both flavors of starting pattern
|
|
18275
|
-
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
18276
|
-
//
|
|
18277
|
-
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
18278
|
-
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
18279
|
-
// that dot prevention biz to live in the extglob portions, because eg
|
|
18280
|
-
// +(*|.x*) can match .xy but not .yx.
|
|
18281
|
-
//
|
|
18282
|
-
// So, return the two flavors if it's #root and the first child is not an
|
|
18283
|
-
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
18284
|
-
// use the (?:^|/) style of start binding.
|
|
18285
|
-
//
|
|
18286
|
-
// Even simplified further:
|
|
18287
|
-
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
18288
|
-
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
18289
|
-
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
18290
|
-
toRegExpSource(allowDot) {
|
|
18291
|
-
const dot = allowDot ?? !!this.#options.dot;
|
|
18292
|
-
if (this.#root === this)
|
|
18293
|
-
this.#fillNegs();
|
|
18294
|
-
if (!this.type) {
|
|
18295
|
-
const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
|
|
18296
|
-
const src = this.#parts.map((p) => {
|
|
18297
|
-
const [re, _, hasMagic2, uflag] = typeof p === "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
18298
|
-
this.#hasMagic = this.#hasMagic || hasMagic2;
|
|
18299
|
-
this.#uflag = this.#uflag || uflag;
|
|
18300
|
-
return re;
|
|
18301
|
-
}).join("");
|
|
18302
|
-
let start2 = "";
|
|
18303
|
-
if (this.isStart()) {
|
|
18304
|
-
if (typeof this.#parts[0] === "string") {
|
|
18305
|
-
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
|
18306
|
-
if (!dotTravAllowed) {
|
|
18307
|
-
const aps = addPatternStart;
|
|
18308
|
-
const needNoTrav = (
|
|
18309
|
-
// dots are allowed, and the pattern starts with [ or .
|
|
18310
|
-
dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
18311
|
-
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
18312
|
-
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
|
|
18313
|
-
);
|
|
18314
|
-
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
18315
|
-
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
18316
|
-
}
|
|
18317
|
-
}
|
|
18318
|
-
}
|
|
18319
|
-
let end = "";
|
|
18320
|
-
if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
|
|
18321
|
-
end = "(?:$|\\/)";
|
|
18322
|
-
}
|
|
18323
|
-
const final2 = start2 + src + end;
|
|
18324
|
-
return [
|
|
18325
|
-
final2,
|
|
18326
|
-
unescape2(src),
|
|
18327
|
-
this.#hasMagic = !!this.#hasMagic,
|
|
18328
|
-
this.#uflag
|
|
18329
|
-
];
|
|
18330
|
-
}
|
|
18331
|
-
const repeated = this.type === "*" || this.type === "+";
|
|
18332
|
-
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
18333
|
-
let body = this.#partsToRegExp(dot);
|
|
18334
|
-
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
18335
|
-
const s = this.toString();
|
|
18336
|
-
this.#parts = [s];
|
|
18337
|
-
this.type = null;
|
|
18338
|
-
this.#hasMagic = void 0;
|
|
18339
|
-
return [s, unescape2(this.toString()), false, false];
|
|
18340
|
-
}
|
|
18341
|
-
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
|
|
18342
|
-
if (bodyDotAllowed === body) {
|
|
18343
|
-
bodyDotAllowed = "";
|
|
18344
|
-
}
|
|
18345
|
-
if (bodyDotAllowed) {
|
|
18346
|
-
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
18347
|
-
}
|
|
18348
|
-
let final = "";
|
|
18349
|
-
if (this.type === "!" && this.#emptyExt) {
|
|
18350
|
-
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
18351
|
-
} else {
|
|
18352
|
-
const close = this.type === "!" ? (
|
|
18353
|
-
// !() must match something,but !(x) can match ''
|
|
18354
|
-
"))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
|
|
18355
|
-
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
18356
|
-
final = start + body + close;
|
|
18357
|
-
}
|
|
18358
|
-
return [
|
|
18359
|
-
final,
|
|
18360
|
-
unescape2(body),
|
|
18361
|
-
this.#hasMagic = !!this.#hasMagic,
|
|
18362
|
-
this.#uflag
|
|
18363
|
-
];
|
|
18364
|
-
}
|
|
18365
|
-
#partsToRegExp(dot) {
|
|
18366
|
-
return this.#parts.map((p) => {
|
|
18367
|
-
if (typeof p === "string") {
|
|
18368
|
-
throw new Error("string type in extglob ast??");
|
|
18369
|
-
}
|
|
18370
|
-
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
18371
|
-
this.#uflag = this.#uflag || uflag;
|
|
18372
|
-
return re;
|
|
18373
|
-
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
18374
|
-
}
|
|
18375
|
-
static #parseGlob(glob2, hasMagic2, noEmpty = false) {
|
|
18376
|
-
let escaping = false;
|
|
18377
|
-
let re = "";
|
|
18378
|
-
let uflag = false;
|
|
18379
|
-
for (let i = 0; i < glob2.length; i++) {
|
|
18380
|
-
const c = glob2.charAt(i);
|
|
18381
|
-
if (escaping) {
|
|
18382
|
-
escaping = false;
|
|
18383
|
-
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
18384
|
-
continue;
|
|
18385
|
-
}
|
|
18386
|
-
if (c === "\\") {
|
|
18387
|
-
if (i === glob2.length - 1) {
|
|
18388
|
-
re += "\\\\";
|
|
18389
|
-
} else {
|
|
18390
|
-
escaping = true;
|
|
18391
|
-
}
|
|
18392
|
-
continue;
|
|
18393
|
-
}
|
|
18394
|
-
if (c === "[") {
|
|
18395
|
-
const [src, needUflag, consumed, magic] = parseClass(glob2, i);
|
|
18396
|
-
if (consumed) {
|
|
18397
|
-
re += src;
|
|
18398
|
-
uflag = uflag || needUflag;
|
|
18399
|
-
i += consumed - 1;
|
|
18400
|
-
hasMagic2 = hasMagic2 || magic;
|
|
18401
|
-
continue;
|
|
18402
|
-
}
|
|
18403
|
-
}
|
|
18404
|
-
if (c === "*") {
|
|
18405
|
-
re += noEmpty && glob2 === "*" ? starNoEmpty : star;
|
|
18406
|
-
hasMagic2 = true;
|
|
18407
|
-
continue;
|
|
18408
|
-
}
|
|
18409
|
-
if (c === "?") {
|
|
18410
|
-
re += qmark;
|
|
18411
|
-
hasMagic2 = true;
|
|
18412
|
-
continue;
|
|
18413
|
-
}
|
|
18414
|
-
re += regExpEscape(c);
|
|
18415
|
-
}
|
|
18416
|
-
return [re, unescape2(glob2), !!hasMagic2, uflag];
|
|
18417
|
-
}
|
|
18418
|
-
};
|
|
18419
|
-
|
|
18420
|
-
// node_modules/minimatch/dist/esm/escape.js
|
|
18421
|
-
var escape2 = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
|
|
18422
|
-
if (magicalBraces) {
|
|
18423
|
-
return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
|
|
18424
|
-
}
|
|
18425
|
-
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
18426
|
-
};
|
|
17603
|
+
var path2 = __toESM(require("path"));
|
|
18427
17604
|
|
|
18428
|
-
// node_modules/
|
|
18429
|
-
var
|
|
18430
|
-
assertValidPattern(pattern);
|
|
18431
|
-
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
18432
|
-
return false;
|
|
18433
|
-
}
|
|
18434
|
-
return new Minimatch(pattern, options).match(p);
|
|
18435
|
-
};
|
|
18436
|
-
var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
18437
|
-
var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
|
|
18438
|
-
var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
|
|
18439
|
-
var starDotExtTestNocase = (ext2) => {
|
|
18440
|
-
ext2 = ext2.toLowerCase();
|
|
18441
|
-
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
|
|
18442
|
-
};
|
|
18443
|
-
var starDotExtTestNocaseDot = (ext2) => {
|
|
18444
|
-
ext2 = ext2.toLowerCase();
|
|
18445
|
-
return (f) => f.toLowerCase().endsWith(ext2);
|
|
18446
|
-
};
|
|
18447
|
-
var starDotStarRE = /^\*+\.\*+$/;
|
|
18448
|
-
var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
18449
|
-
var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
18450
|
-
var dotStarRE = /^\.\*+$/;
|
|
18451
|
-
var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
18452
|
-
var starRE = /^\*+$/;
|
|
18453
|
-
var starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
18454
|
-
var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
18455
|
-
var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
18456
|
-
var qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
18457
|
-
const noext = qmarksTestNoExt([$0]);
|
|
18458
|
-
if (!ext2)
|
|
18459
|
-
return noext;
|
|
18460
|
-
ext2 = ext2.toLowerCase();
|
|
18461
|
-
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
18462
|
-
};
|
|
18463
|
-
var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
|
|
18464
|
-
const noext = qmarksTestNoExtDot([$0]);
|
|
18465
|
-
if (!ext2)
|
|
18466
|
-
return noext;
|
|
18467
|
-
ext2 = ext2.toLowerCase();
|
|
18468
|
-
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
18469
|
-
};
|
|
18470
|
-
var qmarksTestDot = ([$0, ext2 = ""]) => {
|
|
18471
|
-
const noext = qmarksTestNoExtDot([$0]);
|
|
18472
|
-
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
18473
|
-
};
|
|
18474
|
-
var qmarksTest = ([$0, ext2 = ""]) => {
|
|
18475
|
-
const noext = qmarksTestNoExt([$0]);
|
|
18476
|
-
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
18477
|
-
};
|
|
18478
|
-
var qmarksTestNoExt = ([$0]) => {
|
|
18479
|
-
const len = $0.length;
|
|
18480
|
-
return (f) => f.length === len && !f.startsWith(".");
|
|
18481
|
-
};
|
|
18482
|
-
var qmarksTestNoExtDot = ([$0]) => {
|
|
18483
|
-
const len = $0.length;
|
|
18484
|
-
return (f) => f.length === len && f !== "." && f !== "..";
|
|
18485
|
-
};
|
|
18486
|
-
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
18487
|
-
var path = {
|
|
18488
|
-
win32: { sep: "\\" },
|
|
18489
|
-
posix: { sep: "/" }
|
|
18490
|
-
};
|
|
18491
|
-
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
18492
|
-
minimatch.sep = sep;
|
|
18493
|
-
var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
|
|
18494
|
-
minimatch.GLOBSTAR = GLOBSTAR;
|
|
18495
|
-
var qmark2 = "[^/]";
|
|
18496
|
-
var star2 = qmark2 + "*?";
|
|
18497
|
-
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
18498
|
-
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
18499
|
-
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
18500
|
-
minimatch.filter = filter;
|
|
18501
|
-
var ext = (a, b = {}) => Object.assign({}, a, b);
|
|
18502
|
-
var defaults = (def) => {
|
|
18503
|
-
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
18504
|
-
return minimatch;
|
|
18505
|
-
}
|
|
18506
|
-
const orig = minimatch;
|
|
18507
|
-
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
18508
|
-
return Object.assign(m, {
|
|
18509
|
-
Minimatch: class Minimatch extends orig.Minimatch {
|
|
18510
|
-
constructor(pattern, options = {}) {
|
|
18511
|
-
super(pattern, ext(def, options));
|
|
18512
|
-
}
|
|
18513
|
-
static defaults(options) {
|
|
18514
|
-
return orig.defaults(ext(def, options)).Minimatch;
|
|
18515
|
-
}
|
|
18516
|
-
},
|
|
18517
|
-
AST: class AST extends orig.AST {
|
|
18518
|
-
/* c8 ignore start */
|
|
18519
|
-
constructor(type, parent, options = {}) {
|
|
18520
|
-
super(type, parent, ext(def, options));
|
|
18521
|
-
}
|
|
18522
|
-
/* c8 ignore stop */
|
|
18523
|
-
static fromGlob(pattern, options = {}) {
|
|
18524
|
-
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
18525
|
-
}
|
|
18526
|
-
},
|
|
18527
|
-
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
18528
|
-
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
18529
|
-
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
18530
|
-
defaults: (options) => orig.defaults(ext(def, options)),
|
|
18531
|
-
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
18532
|
-
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
18533
|
-
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
18534
|
-
sep: orig.sep,
|
|
18535
|
-
GLOBSTAR
|
|
18536
|
-
});
|
|
18537
|
-
};
|
|
18538
|
-
minimatch.defaults = defaults;
|
|
18539
|
-
var braceExpand = (pattern, options = {}) => {
|
|
18540
|
-
assertValidPattern(pattern);
|
|
18541
|
-
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
18542
|
-
return [pattern];
|
|
18543
|
-
}
|
|
18544
|
-
return expand(pattern);
|
|
18545
|
-
};
|
|
18546
|
-
minimatch.braceExpand = braceExpand;
|
|
18547
|
-
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
18548
|
-
minimatch.makeRe = makeRe;
|
|
18549
|
-
var match = (list, pattern, options = {}) => {
|
|
18550
|
-
const mm = new Minimatch(pattern, options);
|
|
18551
|
-
list = list.filter((f) => mm.match(f));
|
|
18552
|
-
if (mm.options.nonull && !list.length) {
|
|
18553
|
-
list.push(pattern);
|
|
18554
|
-
}
|
|
18555
|
-
return list;
|
|
18556
|
-
};
|
|
18557
|
-
minimatch.match = match;
|
|
18558
|
-
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
18559
|
-
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
18560
|
-
var Minimatch = class {
|
|
18561
|
-
options;
|
|
18562
|
-
set;
|
|
18563
|
-
pattern;
|
|
18564
|
-
windowsPathsNoEscape;
|
|
18565
|
-
nonegate;
|
|
18566
|
-
negate;
|
|
18567
|
-
comment;
|
|
18568
|
-
empty;
|
|
18569
|
-
preserveMultipleSlashes;
|
|
18570
|
-
partial;
|
|
18571
|
-
globSet;
|
|
18572
|
-
globParts;
|
|
18573
|
-
nocase;
|
|
18574
|
-
isWindows;
|
|
18575
|
-
platform;
|
|
18576
|
-
windowsNoMagicRoot;
|
|
18577
|
-
regexp;
|
|
18578
|
-
constructor(pattern, options = {}) {
|
|
18579
|
-
assertValidPattern(pattern);
|
|
18580
|
-
options = options || {};
|
|
18581
|
-
this.options = options;
|
|
18582
|
-
this.pattern = pattern;
|
|
18583
|
-
this.platform = options.platform || defaultPlatform;
|
|
18584
|
-
this.isWindows = this.platform === "win32";
|
|
18585
|
-
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
18586
|
-
if (this.windowsPathsNoEscape) {
|
|
18587
|
-
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
18588
|
-
}
|
|
18589
|
-
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
18590
|
-
this.regexp = null;
|
|
18591
|
-
this.negate = false;
|
|
18592
|
-
this.nonegate = !!options.nonegate;
|
|
18593
|
-
this.comment = false;
|
|
18594
|
-
this.empty = false;
|
|
18595
|
-
this.partial = !!options.partial;
|
|
18596
|
-
this.nocase = !!this.options.nocase;
|
|
18597
|
-
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
18598
|
-
this.globSet = [];
|
|
18599
|
-
this.globParts = [];
|
|
18600
|
-
this.set = [];
|
|
18601
|
-
this.make();
|
|
18602
|
-
}
|
|
18603
|
-
hasMagic() {
|
|
18604
|
-
if (this.options.magicalBraces && this.set.length > 1) {
|
|
18605
|
-
return true;
|
|
18606
|
-
}
|
|
18607
|
-
for (const pattern of this.set) {
|
|
18608
|
-
for (const part of pattern) {
|
|
18609
|
-
if (typeof part !== "string")
|
|
18610
|
-
return true;
|
|
18611
|
-
}
|
|
18612
|
-
}
|
|
18613
|
-
return false;
|
|
18614
|
-
}
|
|
18615
|
-
debug(..._) {
|
|
18616
|
-
}
|
|
18617
|
-
make() {
|
|
18618
|
-
const pattern = this.pattern;
|
|
18619
|
-
const options = this.options;
|
|
18620
|
-
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
18621
|
-
this.comment = true;
|
|
18622
|
-
return;
|
|
18623
|
-
}
|
|
18624
|
-
if (!pattern) {
|
|
18625
|
-
this.empty = true;
|
|
18626
|
-
return;
|
|
18627
|
-
}
|
|
18628
|
-
this.parseNegate();
|
|
18629
|
-
this.globSet = [...new Set(this.braceExpand())];
|
|
18630
|
-
if (options.debug) {
|
|
18631
|
-
this.debug = (...args) => console.error(...args);
|
|
18632
|
-
}
|
|
18633
|
-
this.debug(this.pattern, this.globSet);
|
|
18634
|
-
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
18635
|
-
this.globParts = this.preprocess(rawGlobParts);
|
|
18636
|
-
this.debug(this.pattern, this.globParts);
|
|
18637
|
-
let set = this.globParts.map((s, _, __) => {
|
|
18638
|
-
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
18639
|
-
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
18640
|
-
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
18641
|
-
if (isUNC) {
|
|
18642
|
-
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
18643
|
-
} else if (isDrive) {
|
|
18644
|
-
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
18645
|
-
}
|
|
18646
|
-
}
|
|
18647
|
-
return s.map((ss) => this.parse(ss));
|
|
18648
|
-
});
|
|
18649
|
-
this.debug(this.pattern, set);
|
|
18650
|
-
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
18651
|
-
if (this.isWindows) {
|
|
18652
|
-
for (let i = 0; i < this.set.length; i++) {
|
|
18653
|
-
const p = this.set[i];
|
|
18654
|
-
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
|
|
18655
|
-
p[2] = "?";
|
|
18656
|
-
}
|
|
18657
|
-
}
|
|
18658
|
-
}
|
|
18659
|
-
this.debug(this.pattern, this.set);
|
|
18660
|
-
}
|
|
18661
|
-
// various transforms to equivalent pattern sets that are
|
|
18662
|
-
// faster to process in a filesystem walk. The goal is to
|
|
18663
|
-
// eliminate what we can, and push all ** patterns as far
|
|
18664
|
-
// to the right as possible, even if it increases the number
|
|
18665
|
-
// of patterns that we have to process.
|
|
18666
|
-
preprocess(globParts) {
|
|
18667
|
-
if (this.options.noglobstar) {
|
|
18668
|
-
for (let i = 0; i < globParts.length; i++) {
|
|
18669
|
-
for (let j = 0; j < globParts[i].length; j++) {
|
|
18670
|
-
if (globParts[i][j] === "**") {
|
|
18671
|
-
globParts[i][j] = "*";
|
|
18672
|
-
}
|
|
18673
|
-
}
|
|
18674
|
-
}
|
|
18675
|
-
}
|
|
18676
|
-
const { optimizationLevel = 1 } = this.options;
|
|
18677
|
-
if (optimizationLevel >= 2) {
|
|
18678
|
-
globParts = this.firstPhasePreProcess(globParts);
|
|
18679
|
-
globParts = this.secondPhasePreProcess(globParts);
|
|
18680
|
-
} else if (optimizationLevel >= 1) {
|
|
18681
|
-
globParts = this.levelOneOptimize(globParts);
|
|
18682
|
-
} else {
|
|
18683
|
-
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
18684
|
-
}
|
|
18685
|
-
return globParts;
|
|
18686
|
-
}
|
|
18687
|
-
// just get rid of adjascent ** portions
|
|
18688
|
-
adjascentGlobstarOptimize(globParts) {
|
|
18689
|
-
return globParts.map((parts) => {
|
|
18690
|
-
let gs = -1;
|
|
18691
|
-
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
18692
|
-
let i = gs;
|
|
18693
|
-
while (parts[i + 1] === "**") {
|
|
18694
|
-
i++;
|
|
18695
|
-
}
|
|
18696
|
-
if (i !== gs) {
|
|
18697
|
-
parts.splice(gs, i - gs);
|
|
18698
|
-
}
|
|
18699
|
-
}
|
|
18700
|
-
return parts;
|
|
18701
|
-
});
|
|
18702
|
-
}
|
|
18703
|
-
// get rid of adjascent ** and resolve .. portions
|
|
18704
|
-
levelOneOptimize(globParts) {
|
|
18705
|
-
return globParts.map((parts) => {
|
|
18706
|
-
parts = parts.reduce((set, part) => {
|
|
18707
|
-
const prev = set[set.length - 1];
|
|
18708
|
-
if (part === "**" && prev === "**") {
|
|
18709
|
-
return set;
|
|
18710
|
-
}
|
|
18711
|
-
if (part === "..") {
|
|
18712
|
-
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
18713
|
-
set.pop();
|
|
18714
|
-
return set;
|
|
18715
|
-
}
|
|
18716
|
-
}
|
|
18717
|
-
set.push(part);
|
|
18718
|
-
return set;
|
|
18719
|
-
}, []);
|
|
18720
|
-
return parts.length === 0 ? [""] : parts;
|
|
18721
|
-
});
|
|
18722
|
-
}
|
|
18723
|
-
levelTwoFileOptimize(parts) {
|
|
18724
|
-
if (!Array.isArray(parts)) {
|
|
18725
|
-
parts = this.slashSplit(parts);
|
|
18726
|
-
}
|
|
18727
|
-
let didSomething = false;
|
|
18728
|
-
do {
|
|
18729
|
-
didSomething = false;
|
|
18730
|
-
if (!this.preserveMultipleSlashes) {
|
|
18731
|
-
for (let i = 1; i < parts.length - 1; i++) {
|
|
18732
|
-
const p = parts[i];
|
|
18733
|
-
if (i === 1 && p === "" && parts[0] === "")
|
|
18734
|
-
continue;
|
|
18735
|
-
if (p === "." || p === "") {
|
|
18736
|
-
didSomething = true;
|
|
18737
|
-
parts.splice(i, 1);
|
|
18738
|
-
i--;
|
|
18739
|
-
}
|
|
18740
|
-
}
|
|
18741
|
-
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
18742
|
-
didSomething = true;
|
|
18743
|
-
parts.pop();
|
|
18744
|
-
}
|
|
18745
|
-
}
|
|
18746
|
-
let dd = 0;
|
|
18747
|
-
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
18748
|
-
const p = parts[dd - 1];
|
|
18749
|
-
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
18750
|
-
didSomething = true;
|
|
18751
|
-
parts.splice(dd - 1, 2);
|
|
18752
|
-
dd -= 2;
|
|
18753
|
-
}
|
|
18754
|
-
}
|
|
18755
|
-
} while (didSomething);
|
|
18756
|
-
return parts.length === 0 ? [""] : parts;
|
|
18757
|
-
}
|
|
18758
|
-
// First phase: single-pattern processing
|
|
18759
|
-
// <pre> is 1 or more portions
|
|
18760
|
-
// <rest> is 1 or more portions
|
|
18761
|
-
// <p> is any portion other than ., .., '', or **
|
|
18762
|
-
// <e> is . or ''
|
|
18763
|
-
//
|
|
18764
|
-
// **/.. is *brutal* for filesystem walking performance, because
|
|
18765
|
-
// it effectively resets the recursive walk each time it occurs,
|
|
18766
|
-
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
18767
|
-
// or most strings (other than .., ., and '') can be.
|
|
18768
|
-
//
|
|
18769
|
-
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
18770
|
-
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
18771
|
-
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
18772
|
-
// **/**/<rest> -> **/<rest>
|
|
18773
|
-
//
|
|
18774
|
-
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
18775
|
-
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
18776
|
-
firstPhasePreProcess(globParts) {
|
|
18777
|
-
let didSomething = false;
|
|
18778
|
-
do {
|
|
18779
|
-
didSomething = false;
|
|
18780
|
-
for (let parts of globParts) {
|
|
18781
|
-
let gs = -1;
|
|
18782
|
-
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
18783
|
-
let gss = gs;
|
|
18784
|
-
while (parts[gss + 1] === "**") {
|
|
18785
|
-
gss++;
|
|
18786
|
-
}
|
|
18787
|
-
if (gss > gs) {
|
|
18788
|
-
parts.splice(gs + 1, gss - gs);
|
|
18789
|
-
}
|
|
18790
|
-
let next = parts[gs + 1];
|
|
18791
|
-
const p = parts[gs + 2];
|
|
18792
|
-
const p2 = parts[gs + 3];
|
|
18793
|
-
if (next !== "..")
|
|
18794
|
-
continue;
|
|
18795
|
-
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
|
|
18796
|
-
continue;
|
|
18797
|
-
}
|
|
18798
|
-
didSomething = true;
|
|
18799
|
-
parts.splice(gs, 1);
|
|
18800
|
-
const other = parts.slice(0);
|
|
18801
|
-
other[gs] = "**";
|
|
18802
|
-
globParts.push(other);
|
|
18803
|
-
gs--;
|
|
18804
|
-
}
|
|
18805
|
-
if (!this.preserveMultipleSlashes) {
|
|
18806
|
-
for (let i = 1; i < parts.length - 1; i++) {
|
|
18807
|
-
const p = parts[i];
|
|
18808
|
-
if (i === 1 && p === "" && parts[0] === "")
|
|
18809
|
-
continue;
|
|
18810
|
-
if (p === "." || p === "") {
|
|
18811
|
-
didSomething = true;
|
|
18812
|
-
parts.splice(i, 1);
|
|
18813
|
-
i--;
|
|
18814
|
-
}
|
|
18815
|
-
}
|
|
18816
|
-
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
18817
|
-
didSomething = true;
|
|
18818
|
-
parts.pop();
|
|
18819
|
-
}
|
|
18820
|
-
}
|
|
18821
|
-
let dd = 0;
|
|
18822
|
-
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
18823
|
-
const p = parts[dd - 1];
|
|
18824
|
-
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
18825
|
-
didSomething = true;
|
|
18826
|
-
const needDot = dd === 1 && parts[dd + 1] === "**";
|
|
18827
|
-
const splin = needDot ? ["."] : [];
|
|
18828
|
-
parts.splice(dd - 1, 2, ...splin);
|
|
18829
|
-
if (parts.length === 0)
|
|
18830
|
-
parts.push("");
|
|
18831
|
-
dd -= 2;
|
|
18832
|
-
}
|
|
18833
|
-
}
|
|
18834
|
-
}
|
|
18835
|
-
} while (didSomething);
|
|
18836
|
-
return globParts;
|
|
18837
|
-
}
|
|
18838
|
-
// second phase: multi-pattern dedupes
|
|
18839
|
-
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
18840
|
-
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
18841
|
-
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
18842
|
-
//
|
|
18843
|
-
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
18844
|
-
// ^-- not valid because ** doens't follow symlinks
|
|
18845
|
-
secondPhasePreProcess(globParts) {
|
|
18846
|
-
for (let i = 0; i < globParts.length - 1; i++) {
|
|
18847
|
-
for (let j = i + 1; j < globParts.length; j++) {
|
|
18848
|
-
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
18849
|
-
if (matched) {
|
|
18850
|
-
globParts[i] = [];
|
|
18851
|
-
globParts[j] = matched;
|
|
18852
|
-
break;
|
|
18853
|
-
}
|
|
18854
|
-
}
|
|
18855
|
-
}
|
|
18856
|
-
return globParts.filter((gs) => gs.length);
|
|
18857
|
-
}
|
|
18858
|
-
partsMatch(a, b, emptyGSMatch = false) {
|
|
18859
|
-
let ai = 0;
|
|
18860
|
-
let bi = 0;
|
|
18861
|
-
let result = [];
|
|
18862
|
-
let which = "";
|
|
18863
|
-
while (ai < a.length && bi < b.length) {
|
|
18864
|
-
if (a[ai] === b[bi]) {
|
|
18865
|
-
result.push(which === "b" ? b[bi] : a[ai]);
|
|
18866
|
-
ai++;
|
|
18867
|
-
bi++;
|
|
18868
|
-
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
18869
|
-
result.push(a[ai]);
|
|
18870
|
-
ai++;
|
|
18871
|
-
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
18872
|
-
result.push(b[bi]);
|
|
18873
|
-
bi++;
|
|
18874
|
-
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
18875
|
-
if (which === "b")
|
|
18876
|
-
return false;
|
|
18877
|
-
which = "a";
|
|
18878
|
-
result.push(a[ai]);
|
|
18879
|
-
ai++;
|
|
18880
|
-
bi++;
|
|
18881
|
-
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
18882
|
-
if (which === "a")
|
|
18883
|
-
return false;
|
|
18884
|
-
which = "b";
|
|
18885
|
-
result.push(b[bi]);
|
|
18886
|
-
ai++;
|
|
18887
|
-
bi++;
|
|
18888
|
-
} else {
|
|
18889
|
-
return false;
|
|
18890
|
-
}
|
|
18891
|
-
}
|
|
18892
|
-
return a.length === b.length && result;
|
|
18893
|
-
}
|
|
18894
|
-
parseNegate() {
|
|
18895
|
-
if (this.nonegate)
|
|
18896
|
-
return;
|
|
18897
|
-
const pattern = this.pattern;
|
|
18898
|
-
let negate = false;
|
|
18899
|
-
let negateOffset = 0;
|
|
18900
|
-
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
|
|
18901
|
-
negate = !negate;
|
|
18902
|
-
negateOffset++;
|
|
18903
|
-
}
|
|
18904
|
-
if (negateOffset)
|
|
18905
|
-
this.pattern = pattern.slice(negateOffset);
|
|
18906
|
-
this.negate = negate;
|
|
18907
|
-
}
|
|
18908
|
-
// set partial to true to test if, for example,
|
|
18909
|
-
// "/a/b" matches the start of "/*/b/*/d"
|
|
18910
|
-
// Partial means, if you run out of file before you run
|
|
18911
|
-
// out of pattern, then that's fine, as long as all
|
|
18912
|
-
// the parts match.
|
|
18913
|
-
matchOne(file, pattern, partial = false) {
|
|
18914
|
-
const options = this.options;
|
|
18915
|
-
if (this.isWindows) {
|
|
18916
|
-
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
18917
|
-
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
18918
|
-
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
18919
|
-
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
18920
|
-
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
|
|
18921
|
-
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
18922
|
-
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
18923
|
-
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
18924
|
-
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
18925
|
-
pattern[pdi] = fd;
|
|
18926
|
-
if (pdi > fdi) {
|
|
18927
|
-
pattern = pattern.slice(pdi);
|
|
18928
|
-
} else if (fdi > pdi) {
|
|
18929
|
-
file = file.slice(fdi);
|
|
18930
|
-
}
|
|
18931
|
-
}
|
|
18932
|
-
}
|
|
18933
|
-
}
|
|
18934
|
-
const { optimizationLevel = 1 } = this.options;
|
|
18935
|
-
if (optimizationLevel >= 2) {
|
|
18936
|
-
file = this.levelTwoFileOptimize(file);
|
|
18937
|
-
}
|
|
18938
|
-
this.debug("matchOne", this, { file, pattern });
|
|
18939
|
-
this.debug("matchOne", file.length, pattern.length);
|
|
18940
|
-
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
18941
|
-
this.debug("matchOne loop");
|
|
18942
|
-
var p = pattern[pi];
|
|
18943
|
-
var f = file[fi];
|
|
18944
|
-
this.debug(pattern, p, f);
|
|
18945
|
-
if (p === false) {
|
|
18946
|
-
return false;
|
|
18947
|
-
}
|
|
18948
|
-
if (p === GLOBSTAR) {
|
|
18949
|
-
this.debug("GLOBSTAR", [pattern, p, f]);
|
|
18950
|
-
var fr = fi;
|
|
18951
|
-
var pr = pi + 1;
|
|
18952
|
-
if (pr === pl) {
|
|
18953
|
-
this.debug("** at the end");
|
|
18954
|
-
for (; fi < fl; fi++) {
|
|
18955
|
-
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
18956
|
-
return false;
|
|
18957
|
-
}
|
|
18958
|
-
return true;
|
|
18959
|
-
}
|
|
18960
|
-
while (fr < fl) {
|
|
18961
|
-
var swallowee = file[fr];
|
|
18962
|
-
this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
|
|
18963
|
-
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
18964
|
-
this.debug("globstar found match!", fr, fl, swallowee);
|
|
18965
|
-
return true;
|
|
18966
|
-
} else {
|
|
18967
|
-
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
18968
|
-
this.debug("dot detected!", file, fr, pattern, pr);
|
|
18969
|
-
break;
|
|
18970
|
-
}
|
|
18971
|
-
this.debug("globstar swallow a segment, and continue");
|
|
18972
|
-
fr++;
|
|
18973
|
-
}
|
|
18974
|
-
}
|
|
18975
|
-
if (partial) {
|
|
18976
|
-
this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
|
|
18977
|
-
if (fr === fl) {
|
|
18978
|
-
return true;
|
|
18979
|
-
}
|
|
18980
|
-
}
|
|
18981
|
-
return false;
|
|
18982
|
-
}
|
|
18983
|
-
let hit;
|
|
18984
|
-
if (typeof p === "string") {
|
|
18985
|
-
hit = f === p;
|
|
18986
|
-
this.debug("string match", p, f, hit);
|
|
18987
|
-
} else {
|
|
18988
|
-
hit = p.test(f);
|
|
18989
|
-
this.debug("pattern match", p, f, hit);
|
|
18990
|
-
}
|
|
18991
|
-
if (!hit)
|
|
18992
|
-
return false;
|
|
18993
|
-
}
|
|
18994
|
-
if (fi === fl && pi === pl) {
|
|
18995
|
-
return true;
|
|
18996
|
-
} else if (fi === fl) {
|
|
18997
|
-
return partial;
|
|
18998
|
-
} else if (pi === pl) {
|
|
18999
|
-
return fi === fl - 1 && file[fi] === "";
|
|
19000
|
-
} else {
|
|
19001
|
-
throw new Error("wtf?");
|
|
19002
|
-
}
|
|
19003
|
-
}
|
|
19004
|
-
braceExpand() {
|
|
19005
|
-
return braceExpand(this.pattern, this.options);
|
|
19006
|
-
}
|
|
19007
|
-
parse(pattern) {
|
|
19008
|
-
assertValidPattern(pattern);
|
|
19009
|
-
const options = this.options;
|
|
19010
|
-
if (pattern === "**")
|
|
19011
|
-
return GLOBSTAR;
|
|
19012
|
-
if (pattern === "")
|
|
19013
|
-
return "";
|
|
19014
|
-
let m;
|
|
19015
|
-
let fastTest = null;
|
|
19016
|
-
if (m = pattern.match(starRE)) {
|
|
19017
|
-
fastTest = options.dot ? starTestDot : starTest;
|
|
19018
|
-
} else if (m = pattern.match(starDotExtRE)) {
|
|
19019
|
-
fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
19020
|
-
} else if (m = pattern.match(qmarksRE)) {
|
|
19021
|
-
fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
19022
|
-
} else if (m = pattern.match(starDotStarRE)) {
|
|
19023
|
-
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
19024
|
-
} else if (m = pattern.match(dotStarRE)) {
|
|
19025
|
-
fastTest = dotStarTest;
|
|
19026
|
-
}
|
|
19027
|
-
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
19028
|
-
if (fastTest && typeof re === "object") {
|
|
19029
|
-
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
19030
|
-
}
|
|
19031
|
-
return re;
|
|
19032
|
-
}
|
|
19033
|
-
makeRe() {
|
|
19034
|
-
if (this.regexp || this.regexp === false)
|
|
19035
|
-
return this.regexp;
|
|
19036
|
-
const set = this.set;
|
|
19037
|
-
if (!set.length) {
|
|
19038
|
-
this.regexp = false;
|
|
19039
|
-
return this.regexp;
|
|
19040
|
-
}
|
|
19041
|
-
const options = this.options;
|
|
19042
|
-
const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
|
|
19043
|
-
const flags = new Set(options.nocase ? ["i"] : []);
|
|
19044
|
-
let re = set.map((pattern) => {
|
|
19045
|
-
const pp = pattern.map((p) => {
|
|
19046
|
-
if (p instanceof RegExp) {
|
|
19047
|
-
for (const f of p.flags.split(""))
|
|
19048
|
-
flags.add(f);
|
|
19049
|
-
}
|
|
19050
|
-
return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
19051
|
-
});
|
|
19052
|
-
pp.forEach((p, i) => {
|
|
19053
|
-
const next = pp[i + 1];
|
|
19054
|
-
const prev = pp[i - 1];
|
|
19055
|
-
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
19056
|
-
return;
|
|
19057
|
-
}
|
|
19058
|
-
if (prev === void 0) {
|
|
19059
|
-
if (next !== void 0 && next !== GLOBSTAR) {
|
|
19060
|
-
pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
19061
|
-
} else {
|
|
19062
|
-
pp[i] = twoStar;
|
|
19063
|
-
}
|
|
19064
|
-
} else if (next === void 0) {
|
|
19065
|
-
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
|
|
19066
|
-
} else if (next !== GLOBSTAR) {
|
|
19067
|
-
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
19068
|
-
pp[i + 1] = GLOBSTAR;
|
|
19069
|
-
}
|
|
19070
|
-
});
|
|
19071
|
-
const filtered = pp.filter((p) => p !== GLOBSTAR);
|
|
19072
|
-
if (this.partial && filtered.length >= 1) {
|
|
19073
|
-
const prefixes = [];
|
|
19074
|
-
for (let i = 1; i <= filtered.length; i++) {
|
|
19075
|
-
prefixes.push(filtered.slice(0, i).join("/"));
|
|
19076
|
-
}
|
|
19077
|
-
return "(?:" + prefixes.join("|") + ")";
|
|
19078
|
-
}
|
|
19079
|
-
return filtered.join("/");
|
|
19080
|
-
}).join("|");
|
|
19081
|
-
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
19082
|
-
re = "^" + open + re + close + "$";
|
|
19083
|
-
if (this.partial) {
|
|
19084
|
-
re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
|
|
19085
|
-
}
|
|
19086
|
-
if (this.negate)
|
|
19087
|
-
re = "^(?!" + re + ").+$";
|
|
19088
|
-
try {
|
|
19089
|
-
this.regexp = new RegExp(re, [...flags].join(""));
|
|
19090
|
-
} catch (ex) {
|
|
19091
|
-
this.regexp = false;
|
|
19092
|
-
}
|
|
19093
|
-
return this.regexp;
|
|
19094
|
-
}
|
|
19095
|
-
slashSplit(p) {
|
|
19096
|
-
if (this.preserveMultipleSlashes) {
|
|
19097
|
-
return p.split("/");
|
|
19098
|
-
} else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
|
|
19099
|
-
return ["", ...p.split(/\/+/)];
|
|
19100
|
-
} else {
|
|
19101
|
-
return p.split(/\/+/);
|
|
19102
|
-
}
|
|
19103
|
-
}
|
|
19104
|
-
match(f, partial = this.partial) {
|
|
19105
|
-
this.debug("match", f, this.pattern);
|
|
19106
|
-
if (this.comment) {
|
|
19107
|
-
return false;
|
|
19108
|
-
}
|
|
19109
|
-
if (this.empty) {
|
|
19110
|
-
return f === "";
|
|
19111
|
-
}
|
|
19112
|
-
if (f === "/" && partial) {
|
|
19113
|
-
return true;
|
|
19114
|
-
}
|
|
19115
|
-
const options = this.options;
|
|
19116
|
-
if (this.isWindows) {
|
|
19117
|
-
f = f.split("\\").join("/");
|
|
19118
|
-
}
|
|
19119
|
-
const ff = this.slashSplit(f);
|
|
19120
|
-
this.debug(this.pattern, "split", ff);
|
|
19121
|
-
const set = this.set;
|
|
19122
|
-
this.debug(this.pattern, "set", set);
|
|
19123
|
-
let filename = ff[ff.length - 1];
|
|
19124
|
-
if (!filename) {
|
|
19125
|
-
for (let i = ff.length - 2; !filename && i >= 0; i--) {
|
|
19126
|
-
filename = ff[i];
|
|
19127
|
-
}
|
|
19128
|
-
}
|
|
19129
|
-
for (let i = 0; i < set.length; i++) {
|
|
19130
|
-
const pattern = set[i];
|
|
19131
|
-
let file = ff;
|
|
19132
|
-
if (options.matchBase && pattern.length === 1) {
|
|
19133
|
-
file = [filename];
|
|
19134
|
-
}
|
|
19135
|
-
const hit = this.matchOne(file, pattern, partial);
|
|
19136
|
-
if (hit) {
|
|
19137
|
-
if (options.flipNegate) {
|
|
19138
|
-
return true;
|
|
19139
|
-
}
|
|
19140
|
-
return !this.negate;
|
|
19141
|
-
}
|
|
19142
|
-
}
|
|
19143
|
-
if (options.flipNegate) {
|
|
19144
|
-
return false;
|
|
19145
|
-
}
|
|
19146
|
-
return this.negate;
|
|
19147
|
-
}
|
|
19148
|
-
static defaults(def) {
|
|
19149
|
-
return minimatch.defaults(def).Minimatch;
|
|
19150
|
-
}
|
|
19151
|
-
};
|
|
19152
|
-
minimatch.AST = AST;
|
|
19153
|
-
minimatch.Minimatch = Minimatch;
|
|
19154
|
-
minimatch.escape = escape2;
|
|
19155
|
-
minimatch.unescape = unescape2;
|
|
17605
|
+
// node_modules/glob/dist/esm/index.js
|
|
17606
|
+
var import_minimatch6 = require("minimatch");
|
|
19156
17607
|
|
|
19157
17608
|
// node_modules/glob/dist/esm/glob.js
|
|
17609
|
+
var import_minimatch4 = require("minimatch");
|
|
19158
17610
|
var import_node_url2 = require("url");
|
|
19159
17611
|
|
|
19160
17612
|
// node_modules/lru-cache/dist/esm/index.js
|
|
@@ -21731,12 +20183,12 @@ var PathBase = class {
|
|
|
21731
20183
|
/**
|
|
21732
20184
|
* Get the Path object referenced by the string path, resolved from this Path
|
|
21733
20185
|
*/
|
|
21734
|
-
resolve(
|
|
21735
|
-
if (!
|
|
20186
|
+
resolve(path4) {
|
|
20187
|
+
if (!path4) {
|
|
21736
20188
|
return this;
|
|
21737
20189
|
}
|
|
21738
|
-
const rootPath = this.getRootString(
|
|
21739
|
-
const dir =
|
|
20190
|
+
const rootPath = this.getRootString(path4);
|
|
20191
|
+
const dir = path4.substring(rootPath.length);
|
|
21740
20192
|
const dirParts = dir.split(this.splitSep);
|
|
21741
20193
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
21742
20194
|
return result;
|
|
@@ -22488,8 +20940,8 @@ var PathWin32 = class _PathWin32 extends PathBase {
|
|
|
22488
20940
|
/**
|
|
22489
20941
|
* @internal
|
|
22490
20942
|
*/
|
|
22491
|
-
getRootString(
|
|
22492
|
-
return import_node_path.win32.parse(
|
|
20943
|
+
getRootString(path4) {
|
|
20944
|
+
return import_node_path.win32.parse(path4).root;
|
|
22493
20945
|
}
|
|
22494
20946
|
/**
|
|
22495
20947
|
* @internal
|
|
@@ -22535,8 +20987,8 @@ var PathPosix = class _PathPosix extends PathBase {
|
|
|
22535
20987
|
/**
|
|
22536
20988
|
* @internal
|
|
22537
20989
|
*/
|
|
22538
|
-
getRootString(
|
|
22539
|
-
return
|
|
20990
|
+
getRootString(path4) {
|
|
20991
|
+
return path4.startsWith("/") ? "/" : "";
|
|
22540
20992
|
}
|
|
22541
20993
|
/**
|
|
22542
20994
|
* @internal
|
|
@@ -22585,7 +21037,7 @@ var PathScurryBase = class {
|
|
|
22585
21037
|
*
|
|
22586
21038
|
* @internal
|
|
22587
21039
|
*/
|
|
22588
|
-
constructor(cwd = process.cwd(), pathImpl,
|
|
21040
|
+
constructor(cwd = process.cwd(), pathImpl, sep, { nocase, childrenCacheSize = 16 * 1024, fs: fs3 = defaultFS } = {}) {
|
|
22589
21041
|
this.#fs = fsFromOption(fs3);
|
|
22590
21042
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
22591
21043
|
cwd = (0, import_node_url.fileURLToPath)(cwd);
|
|
@@ -22596,7 +21048,7 @@ var PathScurryBase = class {
|
|
|
22596
21048
|
this.#resolveCache = new ResolveCache();
|
|
22597
21049
|
this.#resolvePosixCache = new ResolveCache();
|
|
22598
21050
|
this.#children = new ChildrenCache(childrenCacheSize);
|
|
22599
|
-
const split = cwdPath.substring(this.rootPath.length).split(
|
|
21051
|
+
const split = cwdPath.substring(this.rootPath.length).split(sep);
|
|
22600
21052
|
if (split.length === 1 && !split[0]) {
|
|
22601
21053
|
split.pop();
|
|
22602
21054
|
}
|
|
@@ -22625,11 +21077,11 @@ var PathScurryBase = class {
|
|
|
22625
21077
|
/**
|
|
22626
21078
|
* Get the depth of a provided path, string, or the cwd
|
|
22627
21079
|
*/
|
|
22628
|
-
depth(
|
|
22629
|
-
if (typeof
|
|
22630
|
-
|
|
21080
|
+
depth(path4 = this.cwd) {
|
|
21081
|
+
if (typeof path4 === "string") {
|
|
21082
|
+
path4 = this.cwd.resolve(path4);
|
|
22631
21083
|
}
|
|
22632
|
-
return
|
|
21084
|
+
return path4.depth();
|
|
22633
21085
|
}
|
|
22634
21086
|
/**
|
|
22635
21087
|
* Return the cache of child entries. Exposed so subclasses can create
|
|
@@ -22855,9 +21307,9 @@ var PathScurryBase = class {
|
|
|
22855
21307
|
opts = entry;
|
|
22856
21308
|
entry = this.cwd;
|
|
22857
21309
|
}
|
|
22858
|
-
const { withFileTypes = true, follow = false, filter
|
|
21310
|
+
const { withFileTypes = true, follow = false, filter, walkFilter } = opts;
|
|
22859
21311
|
const results = [];
|
|
22860
|
-
if (!
|
|
21312
|
+
if (!filter || filter(entry)) {
|
|
22861
21313
|
results.push(withFileTypes ? entry : entry.fullpath());
|
|
22862
21314
|
}
|
|
22863
21315
|
const dirs = /* @__PURE__ */ new Set();
|
|
@@ -22876,7 +21328,7 @@ var PathScurryBase = class {
|
|
|
22876
21328
|
}
|
|
22877
21329
|
};
|
|
22878
21330
|
for (const e of entries) {
|
|
22879
|
-
if (!
|
|
21331
|
+
if (!filter || filter(e)) {
|
|
22880
21332
|
results.push(withFileTypes ? e : e.fullpath());
|
|
22881
21333
|
}
|
|
22882
21334
|
if (follow && e.isSymbolicLink()) {
|
|
@@ -22907,16 +21359,16 @@ var PathScurryBase = class {
|
|
|
22907
21359
|
opts = entry;
|
|
22908
21360
|
entry = this.cwd;
|
|
22909
21361
|
}
|
|
22910
|
-
const { withFileTypes = true, follow = false, filter
|
|
21362
|
+
const { withFileTypes = true, follow = false, filter, walkFilter } = opts;
|
|
22911
21363
|
const results = [];
|
|
22912
|
-
if (!
|
|
21364
|
+
if (!filter || filter(entry)) {
|
|
22913
21365
|
results.push(withFileTypes ? entry : entry.fullpath());
|
|
22914
21366
|
}
|
|
22915
21367
|
const dirs = /* @__PURE__ */ new Set([entry]);
|
|
22916
21368
|
for (const dir of dirs) {
|
|
22917
21369
|
const entries = dir.readdirSync();
|
|
22918
21370
|
for (const e of entries) {
|
|
22919
|
-
if (!
|
|
21371
|
+
if (!filter || filter(e)) {
|
|
22920
21372
|
results.push(withFileTypes ? e : e.fullpath());
|
|
22921
21373
|
}
|
|
22922
21374
|
let r = e;
|
|
@@ -22969,15 +21421,15 @@ var PathScurryBase = class {
|
|
|
22969
21421
|
opts = entry;
|
|
22970
21422
|
entry = this.cwd;
|
|
22971
21423
|
}
|
|
22972
|
-
const { withFileTypes = true, follow = false, filter
|
|
22973
|
-
if (!
|
|
21424
|
+
const { withFileTypes = true, follow = false, filter, walkFilter } = opts;
|
|
21425
|
+
if (!filter || filter(entry)) {
|
|
22974
21426
|
yield withFileTypes ? entry : entry.fullpath();
|
|
22975
21427
|
}
|
|
22976
21428
|
const dirs = /* @__PURE__ */ new Set([entry]);
|
|
22977
21429
|
for (const dir of dirs) {
|
|
22978
21430
|
const entries = dir.readdirSync();
|
|
22979
21431
|
for (const e of entries) {
|
|
22980
|
-
if (!
|
|
21432
|
+
if (!filter || filter(e)) {
|
|
22981
21433
|
yield withFileTypes ? e : e.fullpath();
|
|
22982
21434
|
}
|
|
22983
21435
|
let r = e;
|
|
@@ -23000,9 +21452,9 @@ var PathScurryBase = class {
|
|
|
23000
21452
|
opts = entry;
|
|
23001
21453
|
entry = this.cwd;
|
|
23002
21454
|
}
|
|
23003
|
-
const { withFileTypes = true, follow = false, filter
|
|
21455
|
+
const { withFileTypes = true, follow = false, filter, walkFilter } = opts;
|
|
23004
21456
|
const results = new Minipass({ objectMode: true });
|
|
23005
|
-
if (!
|
|
21457
|
+
if (!filter || filter(entry)) {
|
|
23006
21458
|
results.write(withFileTypes ? entry : entry.fullpath());
|
|
23007
21459
|
}
|
|
23008
21460
|
const dirs = /* @__PURE__ */ new Set();
|
|
@@ -23035,7 +21487,7 @@ var PathScurryBase = class {
|
|
|
23035
21487
|
}
|
|
23036
21488
|
}
|
|
23037
21489
|
for (const e of entries) {
|
|
23038
|
-
if (e && (!
|
|
21490
|
+
if (e && (!filter || filter(e))) {
|
|
23039
21491
|
if (!results.write(withFileTypes ? e : e.fullpath())) {
|
|
23040
21492
|
paused = true;
|
|
23041
21493
|
}
|
|
@@ -23069,10 +21521,10 @@ var PathScurryBase = class {
|
|
|
23069
21521
|
opts = entry;
|
|
23070
21522
|
entry = this.cwd;
|
|
23071
21523
|
}
|
|
23072
|
-
const { withFileTypes = true, follow = false, filter
|
|
21524
|
+
const { withFileTypes = true, follow = false, filter, walkFilter } = opts;
|
|
23073
21525
|
const results = new Minipass({ objectMode: true });
|
|
23074
21526
|
const dirs = /* @__PURE__ */ new Set();
|
|
23075
|
-
if (!
|
|
21527
|
+
if (!filter || filter(entry)) {
|
|
23076
21528
|
results.write(withFileTypes ? entry : entry.fullpath());
|
|
23077
21529
|
}
|
|
23078
21530
|
const queue = [entry];
|
|
@@ -23090,7 +21542,7 @@ var PathScurryBase = class {
|
|
|
23090
21542
|
dirs.add(dir);
|
|
23091
21543
|
const entries = dir.readdirSync();
|
|
23092
21544
|
for (const e of entries) {
|
|
23093
|
-
if (!
|
|
21545
|
+
if (!filter || filter(e)) {
|
|
23094
21546
|
if (!results.write(withFileTypes ? e : e.fullpath())) {
|
|
23095
21547
|
paused = true;
|
|
23096
21548
|
}
|
|
@@ -23116,9 +21568,9 @@ var PathScurryBase = class {
|
|
|
23116
21568
|
process2();
|
|
23117
21569
|
return results;
|
|
23118
21570
|
}
|
|
23119
|
-
chdir(
|
|
21571
|
+
chdir(path4 = this.cwd) {
|
|
23120
21572
|
const oldCwd = this.cwd;
|
|
23121
|
-
this.cwd = typeof
|
|
21573
|
+
this.cwd = typeof path4 === "string" ? this.cwd.resolve(path4) : path4;
|
|
23122
21574
|
this.cwd[setAsCwd](oldCwd);
|
|
23123
21575
|
}
|
|
23124
21576
|
};
|
|
@@ -23193,6 +21645,7 @@ var Path = process.platform === "win32" ? PathWin32 : PathPosix;
|
|
|
23193
21645
|
var PathScurry = process.platform === "win32" ? PathScurryWin32 : process.platform === "darwin" ? PathScurryDarwin : PathScurryPosix;
|
|
23194
21646
|
|
|
23195
21647
|
// node_modules/glob/dist/esm/pattern.js
|
|
21648
|
+
var import_minimatch = require("minimatch");
|
|
23196
21649
|
var isPatternList = (pl) => pl.length >= 1;
|
|
23197
21650
|
var isGlobList = (gl) => gl.length >= 1;
|
|
23198
21651
|
var Pattern = class _Pattern {
|
|
@@ -23269,7 +21722,7 @@ var Pattern = class _Pattern {
|
|
|
23269
21722
|
* true of if pattern() returns GLOBSTAR
|
|
23270
21723
|
*/
|
|
23271
21724
|
isGlobstar() {
|
|
23272
|
-
return this.#patternList[this.#index] === GLOBSTAR;
|
|
21725
|
+
return this.#patternList[this.#index] === import_minimatch.GLOBSTAR;
|
|
23273
21726
|
}
|
|
23274
21727
|
/**
|
|
23275
21728
|
* true if pattern() returns a regexp
|
|
@@ -23358,7 +21811,8 @@ var Pattern = class _Pattern {
|
|
|
23358
21811
|
};
|
|
23359
21812
|
|
|
23360
21813
|
// node_modules/glob/dist/esm/ignore.js
|
|
23361
|
-
var
|
|
21814
|
+
var import_minimatch2 = require("minimatch");
|
|
21815
|
+
var defaultPlatform = typeof process === "object" && process && typeof process.platform === "string" ? process.platform : "linux";
|
|
23362
21816
|
var Ignore = class {
|
|
23363
21817
|
relative;
|
|
23364
21818
|
relativeChildren;
|
|
@@ -23366,7 +21820,7 @@ var Ignore = class {
|
|
|
23366
21820
|
absoluteChildren;
|
|
23367
21821
|
platform;
|
|
23368
21822
|
mmopts;
|
|
23369
|
-
constructor(ignored, { nobrace, nocase, noext, noglobstar, platform =
|
|
21823
|
+
constructor(ignored, { nobrace, nocase, noext, noglobstar, platform = defaultPlatform }) {
|
|
23370
21824
|
this.relative = [];
|
|
23371
21825
|
this.absolute = [];
|
|
23372
21826
|
this.relativeChildren = [];
|
|
@@ -23387,7 +21841,7 @@ var Ignore = class {
|
|
|
23387
21841
|
this.add(ign);
|
|
23388
21842
|
}
|
|
23389
21843
|
add(ign) {
|
|
23390
|
-
const mm = new Minimatch(ign, this.mmopts);
|
|
21844
|
+
const mm = new import_minimatch2.Minimatch(ign, this.mmopts);
|
|
23391
21845
|
for (let i = 0; i < mm.set.length; i++) {
|
|
23392
21846
|
const parsed = mm.set[i];
|
|
23393
21847
|
const globParts = mm.globParts[i];
|
|
@@ -23399,7 +21853,7 @@ var Ignore = class {
|
|
|
23399
21853
|
globParts.shift();
|
|
23400
21854
|
}
|
|
23401
21855
|
const p = new Pattern(parsed, globParts, 0, this.platform);
|
|
23402
|
-
const m = new Minimatch(p.globString(), this.mmopts);
|
|
21856
|
+
const m = new import_minimatch2.Minimatch(p.globString(), this.mmopts);
|
|
23403
21857
|
const children = globParts[globParts.length - 1] === "**";
|
|
23404
21858
|
const absolute = p.isAbsolute();
|
|
23405
21859
|
if (absolute)
|
|
@@ -23445,6 +21899,7 @@ var Ignore = class {
|
|
|
23445
21899
|
};
|
|
23446
21900
|
|
|
23447
21901
|
// node_modules/glob/dist/esm/processor.js
|
|
21902
|
+
var import_minimatch3 = require("minimatch");
|
|
23448
21903
|
var HasWalkedCache = class _HasWalkedCache {
|
|
23449
21904
|
store;
|
|
23450
21905
|
constructor(store = /* @__PURE__ */ new Map()) {
|
|
@@ -23474,8 +21929,8 @@ var MatchRecord = class {
|
|
|
23474
21929
|
}
|
|
23475
21930
|
// match, absolute, ifdir
|
|
23476
21931
|
entries() {
|
|
23477
|
-
return [...this.store.entries()].map(([
|
|
23478
|
-
|
|
21932
|
+
return [...this.store.entries()].map(([path4, n]) => [
|
|
21933
|
+
path4,
|
|
23479
21934
|
!!(n & 2),
|
|
23480
21935
|
!!(n & 1)
|
|
23481
21936
|
]);
|
|
@@ -23562,7 +22017,7 @@ var Processor = class _Processor {
|
|
|
23562
22017
|
const ifDir = p === ".." || p === "" || p === ".";
|
|
23563
22018
|
this.matches.add(t.resolve(p), absolute, ifDir);
|
|
23564
22019
|
continue;
|
|
23565
|
-
} else if (p === GLOBSTAR) {
|
|
22020
|
+
} else if (p === import_minimatch3.GLOBSTAR) {
|
|
23566
22021
|
if (!t.isSymbolicLink() || this.follow || pattern.checkFollowGlobstar()) {
|
|
23567
22022
|
this.subwalks.add(t, pattern);
|
|
23568
22023
|
}
|
|
@@ -23604,7 +22059,7 @@ var Processor = class _Processor {
|
|
|
23604
22059
|
const absolute = pattern.isAbsolute();
|
|
23605
22060
|
const p = pattern.pattern();
|
|
23606
22061
|
const rest = pattern.rest();
|
|
23607
|
-
if (p === GLOBSTAR) {
|
|
22062
|
+
if (p === import_minimatch3.GLOBSTAR) {
|
|
23608
22063
|
results.testGlobstar(e, pattern, rest, absolute);
|
|
23609
22064
|
} else if (p instanceof RegExp) {
|
|
23610
22065
|
results.testRegExp(e, p, rest, absolute);
|
|
@@ -23680,9 +22135,9 @@ var GlobUtil = class {
|
|
|
23680
22135
|
signal;
|
|
23681
22136
|
maxDepth;
|
|
23682
22137
|
includeChildMatches;
|
|
23683
|
-
constructor(patterns,
|
|
22138
|
+
constructor(patterns, path4, opts) {
|
|
23684
22139
|
this.patterns = patterns;
|
|
23685
|
-
this.path =
|
|
22140
|
+
this.path = path4;
|
|
23686
22141
|
this.opts = opts;
|
|
23687
22142
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
23688
22143
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -23701,11 +22156,11 @@ var GlobUtil = class {
|
|
|
23701
22156
|
});
|
|
23702
22157
|
}
|
|
23703
22158
|
}
|
|
23704
|
-
#ignored(
|
|
23705
|
-
return this.seen.has(
|
|
22159
|
+
#ignored(path4) {
|
|
22160
|
+
return this.seen.has(path4) || !!this.#ignore?.ignored?.(path4);
|
|
23706
22161
|
}
|
|
23707
|
-
#childrenIgnored(
|
|
23708
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
22162
|
+
#childrenIgnored(path4) {
|
|
22163
|
+
return !!this.#ignore?.childrenIgnored?.(path4);
|
|
23709
22164
|
}
|
|
23710
22165
|
// backpressure mechanism
|
|
23711
22166
|
pause() {
|
|
@@ -23920,8 +22375,8 @@ var GlobUtil = class {
|
|
|
23920
22375
|
};
|
|
23921
22376
|
var GlobWalker = class extends GlobUtil {
|
|
23922
22377
|
matches = /* @__PURE__ */ new Set();
|
|
23923
|
-
constructor(patterns,
|
|
23924
|
-
super(patterns,
|
|
22378
|
+
constructor(patterns, path4, opts) {
|
|
22379
|
+
super(patterns, path4, opts);
|
|
23925
22380
|
}
|
|
23926
22381
|
matchEmit(e) {
|
|
23927
22382
|
this.matches.add(e);
|
|
@@ -23958,8 +22413,8 @@ var GlobWalker = class extends GlobUtil {
|
|
|
23958
22413
|
};
|
|
23959
22414
|
var GlobStream = class extends GlobUtil {
|
|
23960
22415
|
results;
|
|
23961
|
-
constructor(patterns,
|
|
23962
|
-
super(patterns,
|
|
22416
|
+
constructor(patterns, path4, opts) {
|
|
22417
|
+
super(patterns, path4, opts);
|
|
23963
22418
|
this.results = new Minipass({
|
|
23964
22419
|
signal: this.signal,
|
|
23965
22420
|
objectMode: true
|
|
@@ -23993,7 +22448,7 @@ var GlobStream = class extends GlobUtil {
|
|
|
23993
22448
|
};
|
|
23994
22449
|
|
|
23995
22450
|
// node_modules/glob/dist/esm/glob.js
|
|
23996
|
-
var
|
|
22451
|
+
var defaultPlatform2 = typeof process === "object" && process && typeof process.platform === "string" ? process.platform : "linux";
|
|
23997
22452
|
var Glob = class {
|
|
23998
22453
|
absolute;
|
|
23999
22454
|
cwd;
|
|
@@ -24085,7 +22540,7 @@ var Glob = class {
|
|
|
24085
22540
|
pattern = pattern.map((p) => p.includes("/") ? p : `./**/${p}`);
|
|
24086
22541
|
}
|
|
24087
22542
|
this.pattern = pattern;
|
|
24088
|
-
this.platform = opts.platform ||
|
|
22543
|
+
this.platform = opts.platform || defaultPlatform2;
|
|
24089
22544
|
this.opts = { ...opts, platform: this.platform };
|
|
24090
22545
|
if (opts.scurry) {
|
|
24091
22546
|
this.scurry = opts.scurry;
|
|
@@ -24117,7 +22572,7 @@ var Glob = class {
|
|
|
24117
22572
|
windowsPathsNoEscape: this.windowsPathsNoEscape,
|
|
24118
22573
|
debug: !!this.opts.debug
|
|
24119
22574
|
};
|
|
24120
|
-
const mms = this.pattern.map((p) => new Minimatch(p, mmo));
|
|
22575
|
+
const mms = this.pattern.map((p) => new import_minimatch4.Minimatch(p, mmo));
|
|
24121
22576
|
const [matchSet, globParts] = mms.reduce((set, m) => {
|
|
24122
22577
|
set[0].push(...m.set);
|
|
24123
22578
|
set[1].push(...m.globParts);
|
|
@@ -24193,18 +22648,20 @@ var Glob = class {
|
|
|
24193
22648
|
};
|
|
24194
22649
|
|
|
24195
22650
|
// node_modules/glob/dist/esm/has-magic.js
|
|
22651
|
+
var import_minimatch5 = require("minimatch");
|
|
24196
22652
|
var hasMagic = (pattern, options = {}) => {
|
|
24197
22653
|
if (!Array.isArray(pattern)) {
|
|
24198
22654
|
pattern = [pattern];
|
|
24199
22655
|
}
|
|
24200
22656
|
for (const p of pattern) {
|
|
24201
|
-
if (new Minimatch(p, options).hasMagic())
|
|
22657
|
+
if (new import_minimatch5.Minimatch(p, options).hasMagic())
|
|
24202
22658
|
return true;
|
|
24203
22659
|
}
|
|
24204
22660
|
return false;
|
|
24205
22661
|
};
|
|
24206
22662
|
|
|
24207
22663
|
// node_modules/glob/dist/esm/index.js
|
|
22664
|
+
var import_minimatch7 = require("minimatch");
|
|
24208
22665
|
function globStreamSync(pattern, options = {}) {
|
|
24209
22666
|
return new Glob(pattern, options).streamSync();
|
|
24210
22667
|
}
|
|
@@ -24247,12 +22704,13 @@ var glob = Object.assign(glob_, {
|
|
|
24247
22704
|
iterateSync,
|
|
24248
22705
|
Glob,
|
|
24249
22706
|
hasMagic,
|
|
24250
|
-
escape:
|
|
24251
|
-
unescape:
|
|
22707
|
+
escape: import_minimatch6.escape,
|
|
22708
|
+
unescape: import_minimatch6.unescape
|
|
24252
22709
|
});
|
|
24253
22710
|
glob.glob = glob;
|
|
24254
22711
|
|
|
24255
22712
|
// src/commands/scan.ts
|
|
22713
|
+
var import_minimatch8 = require("minimatch");
|
|
24256
22714
|
var import_picocolors = __toESM(require_picocolors());
|
|
24257
22715
|
|
|
24258
22716
|
// node_modules/@replikanti/flowlint-core/dist/index.mjs
|
|
@@ -24563,8 +23021,8 @@ function isTerminalNode(type, name) {
|
|
|
24563
23021
|
return TERMINAL_NODE_PATTERNS.some((pattern) => label.includes(pattern));
|
|
24564
23022
|
}
|
|
24565
23023
|
function readNumber(source, paths) {
|
|
24566
|
-
for (const
|
|
24567
|
-
const value =
|
|
23024
|
+
for (const path4 of paths) {
|
|
23025
|
+
const value = path4.split(".").reduce((acc, key) => acc ? acc[key] : void 0, source);
|
|
24568
23026
|
if (typeof value === "number") return value;
|
|
24569
23027
|
if (typeof value === "string" && !Number.isNaN(Number(value))) return Number(value);
|
|
24570
23028
|
}
|
|
@@ -24699,7 +23157,7 @@ function validateN8nWorkflow(data) {
|
|
|
24699
23157
|
const validate = getValidator();
|
|
24700
23158
|
if (!validate(data)) {
|
|
24701
23159
|
const errors = (validate.errors || []).map((err) => {
|
|
24702
|
-
const
|
|
23160
|
+
const path4 = err.instancePath || err.schemaPath;
|
|
24703
23161
|
const message = err.message || "Validation error";
|
|
24704
23162
|
let suggestion = "";
|
|
24705
23163
|
if (err.keyword === "required") {
|
|
@@ -24711,7 +23169,7 @@ function validateN8nWorkflow(data) {
|
|
|
24711
23169
|
} else if (err.keyword === "minLength") {
|
|
24712
23170
|
suggestion = "This field cannot be empty.";
|
|
24713
23171
|
}
|
|
24714
|
-
return { path:
|
|
23172
|
+
return { path: path4, message, suggestion };
|
|
24715
23173
|
});
|
|
24716
23174
|
throw new ValidationError(errors);
|
|
24717
23175
|
}
|
|
@@ -25456,11 +23914,11 @@ function loadConfigFromFile(configPath) {
|
|
|
25456
23914
|
function loadConfigFromCwd() {
|
|
25457
23915
|
try {
|
|
25458
23916
|
const fs3 = __require("fs");
|
|
25459
|
-
const
|
|
23917
|
+
const path4 = __require("path");
|
|
25460
23918
|
const candidates = [".flowlint.yml", ".flowlint.yaml", "flowlint.config.yml"];
|
|
25461
23919
|
const cwd = process.cwd();
|
|
25462
23920
|
for (const candidate of candidates) {
|
|
25463
|
-
const configPath =
|
|
23921
|
+
const configPath = path4.join(cwd, candidate);
|
|
25464
23922
|
if (fs3.existsSync(configPath)) {
|
|
25465
23923
|
const content = fs3.readFileSync(configPath, "utf-8");
|
|
25466
23924
|
return parseConfig(content);
|
|
@@ -25481,7 +23939,7 @@ function countFindingsBySeverity(findings) {
|
|
|
25481
23939
|
}
|
|
25482
23940
|
|
|
25483
23941
|
// src/reporters/junit.ts
|
|
25484
|
-
var
|
|
23942
|
+
var path = __toESM(require("path"));
|
|
25485
23943
|
function formatJunit(findings) {
|
|
25486
23944
|
const byFile = findings.reduce((acc, finding) => {
|
|
25487
23945
|
const file = finding.location?.file || "unknown";
|
|
@@ -25491,7 +23949,7 @@ function formatJunit(findings) {
|
|
|
25491
23949
|
}, {});
|
|
25492
23950
|
let xml = '<?xml version="1.0" encoding="UTF-8"?>\n<testsuites>\n';
|
|
25493
23951
|
for (const [file, fileFindings] of Object.entries(byFile)) {
|
|
25494
|
-
const filename =
|
|
23952
|
+
const filename = path.basename(file);
|
|
25495
23953
|
const failures = fileFindings.length;
|
|
25496
23954
|
xml += ` <testsuite name="${filename}" tests="${failures}" failures="${failures}" errors="0" skipped="0" timestamp="${(/* @__PURE__ */ new Date()).toISOString()}" time="0" hostname="flowlint">
|
|
25497
23955
|
`;
|
|
@@ -25594,21 +24052,50 @@ function formatJson(findings, stats) {
|
|
|
25594
24052
|
}
|
|
25595
24053
|
|
|
25596
24054
|
// src/commands/scan.ts
|
|
25597
|
-
var scanCommand = new Command("scan").description("Scan workflow files for issues").argument("[path]", "Directory or file to scan", ".").option("--config <path>", "Path to .flowlint.yml config file").option("--format <format>", "Output format: stylish|json|junit|sarif", "stylish").option("--fail-on-error", "Exit with code 1 if errors found", false).action(async (scanPath, options) => {
|
|
24055
|
+
var scanCommand = new Command("scan").description("Scan workflow files (directory or single file) for issues").argument("[path]", "Directory or workflow file to scan", ".").option("--config <path>", "Path to .flowlint.yml config file").option("--format <format>", "Output format: stylish|json|junit|sarif", "stylish").option("--fail-on-error", "Exit with code 1 if errors found", false).action(async (scanPath, options) => {
|
|
25598
24056
|
try {
|
|
25599
|
-
const absolutePath =
|
|
24057
|
+
const absolutePath = path2.resolve(process.cwd(), scanPath);
|
|
25600
24058
|
const isStylish = options.format === "stylish";
|
|
24059
|
+
let stats;
|
|
24060
|
+
try {
|
|
24061
|
+
stats = fs.statSync(absolutePath);
|
|
24062
|
+
} catch (error) {
|
|
24063
|
+
if (error.code === "ENOENT") {
|
|
24064
|
+
console.error(import_picocolors.default.red(`Error: Path not found: ${scanPath}`));
|
|
24065
|
+
process.exit(1);
|
|
24066
|
+
}
|
|
24067
|
+
throw error;
|
|
24068
|
+
}
|
|
24069
|
+
const isFile = stats.isFile();
|
|
24070
|
+
const isDirectory = stats.isDirectory();
|
|
24071
|
+
if (!isFile && !isDirectory) {
|
|
24072
|
+
console.error(import_picocolors.default.red(`Error: Path is neither a file nor a directory: ${scanPath}`));
|
|
24073
|
+
process.exit(1);
|
|
24074
|
+
}
|
|
25601
24075
|
const config = options.config ? loadConfig(options.config) : loadConfig();
|
|
25602
|
-
|
|
25603
|
-
|
|
25604
|
-
|
|
25605
|
-
|
|
25606
|
-
|
|
25607
|
-
|
|
25608
|
-
|
|
25609
|
-
|
|
25610
|
-
|
|
25611
|
-
|
|
24076
|
+
let files = [];
|
|
24077
|
+
if (isDirectory) {
|
|
24078
|
+
const patterns = config.files.include.map(
|
|
24079
|
+
(p) => path2.join(absolutePath, p).replace(/\\/g, "/")
|
|
24080
|
+
);
|
|
24081
|
+
const ignorePatterns = config.files.ignore.map(
|
|
24082
|
+
(p) => path2.join(absolutePath, p).replace(/\\/g, "/")
|
|
24083
|
+
);
|
|
24084
|
+
files = await glob(patterns, {
|
|
24085
|
+
ignore: ignorePatterns,
|
|
24086
|
+
nodir: true
|
|
24087
|
+
});
|
|
24088
|
+
} else if (isFile) {
|
|
24089
|
+
files = [absolutePath];
|
|
24090
|
+
const relativeScanPath = path2.relative(process.cwd(), absolutePath).replace(/\\/g, "/");
|
|
24091
|
+
const isIncluded = config.files.include.some((p) => (0, import_minimatch8.minimatch)(relativeScanPath, p));
|
|
24092
|
+
const isIgnored = config.files.ignore.some((p) => (0, import_minimatch8.minimatch)(relativeScanPath, p));
|
|
24093
|
+
if (!isIncluded || isIgnored) {
|
|
24094
|
+
if (isStylish) {
|
|
24095
|
+
console.log(import_picocolors.default.yellow(`Warning: File "${relativeScanPath}" does not match configured patterns or is ignored.`));
|
|
24096
|
+
}
|
|
24097
|
+
}
|
|
24098
|
+
}
|
|
25612
24099
|
if (files.length === 0) {
|
|
25613
24100
|
if (isStylish) console.log(import_picocolors.default.yellow("No workflow files found."));
|
|
25614
24101
|
return;
|
|
@@ -25622,7 +24109,7 @@ var scanCommand = new Command("scan").description("Scan workflow files for issue
|
|
|
25622
24109
|
for (const file of files) {
|
|
25623
24110
|
try {
|
|
25624
24111
|
const content = fs.readFileSync(file, "utf-8");
|
|
25625
|
-
const relativePath =
|
|
24112
|
+
const relativePath = path2.relative(process.cwd(), file);
|
|
25626
24113
|
const graph = parseN8n(content);
|
|
25627
24114
|
const findings = runAllRules(graph, {
|
|
25628
24115
|
path: relativePath,
|
|
@@ -25647,18 +24134,18 @@ var scanCommand = new Command("scan").description("Scan workflow files for issue
|
|
|
25647
24134
|
rule: "validation-error",
|
|
25648
24135
|
message: error instanceof Error ? error.message : String(error),
|
|
25649
24136
|
severity: "must",
|
|
25650
|
-
path:
|
|
24137
|
+
path: path2.relative(process.cwd(), file),
|
|
25651
24138
|
line: 0
|
|
25652
24139
|
});
|
|
25653
24140
|
errorCount++;
|
|
25654
24141
|
if (isStylish) {
|
|
25655
24142
|
if (error instanceof ValidationError) {
|
|
25656
|
-
console.log(import_picocolors.default.red("x " +
|
|
24143
|
+
console.log(import_picocolors.default.red("x " + path2.relative(process.cwd(), file) + ": Validation error"));
|
|
25657
24144
|
error.errors.forEach((e) => {
|
|
25658
24145
|
console.log(import_picocolors.default.gray(" " + e.path + ": " + e.message));
|
|
25659
24146
|
});
|
|
25660
24147
|
} else {
|
|
25661
|
-
console.log(import_picocolors.default.red("x " +
|
|
24148
|
+
console.log(import_picocolors.default.red("x " + path2.relative(process.cwd(), file) + ": " + (error instanceof Error ? error.message : String(error))));
|
|
25662
24149
|
}
|
|
25663
24150
|
}
|
|
25664
24151
|
}
|
|
@@ -25694,11 +24181,11 @@ var scanCommand = new Command("scan").description("Scan workflow files for issue
|
|
|
25694
24181
|
|
|
25695
24182
|
// src/commands/init.ts
|
|
25696
24183
|
var fs2 = __toESM(require("fs"));
|
|
25697
|
-
var
|
|
24184
|
+
var path3 = __toESM(require("path"));
|
|
25698
24185
|
var import_picocolors2 = __toESM(require_picocolors());
|
|
25699
24186
|
var import_yaml3 = __toESM(require_dist());
|
|
25700
24187
|
var initCommand = new Command("init").description("Initialize FlowLint configuration in the current directory").option("--force", "Overwrite existing config file", false).action((options) => {
|
|
25701
|
-
const configPath =
|
|
24188
|
+
const configPath = path3.join(process.cwd(), ".flowlint.yml");
|
|
25702
24189
|
if (fs2.existsSync(configPath) && !options.force) {
|
|
25703
24190
|
console.log(import_picocolors2.default.yellow(".flowlint.yml already exists. Use --force to overwrite."));
|
|
25704
24191
|
return;
|
|
@@ -25723,7 +24210,7 @@ var initCommand = new Command("init").description("Initialize FlowLint configura
|
|
|
25723
24210
|
|
|
25724
24211
|
// src/cli.ts
|
|
25725
24212
|
var program2 = new Command();
|
|
25726
|
-
program2.name("flowlint").description("Static analysis tool for n8n workflows").version("0.
|
|
24213
|
+
program2.name("flowlint").description("Static analysis tool for n8n workflows").version("0.8.0");
|
|
25727
24214
|
program2.addCommand(scanCommand);
|
|
25728
24215
|
program2.addCommand(initCommand);
|
|
25729
24216
|
program2.parse(process.argv);
|