@poe-platform/safe-bash 0.1.619 → 0.1.620
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/safe-bash/commands/archive/unzip/arguments.d.ts +8 -1
- package/dist/safe-bash/commands/archive/unzip/arguments.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/unzip/arguments.js +24 -11
- package/dist/safe-bash/commands/archive/unzip/arguments.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip/options.js +4 -4
- package/dist/safe-bash/commands/archive/zip/options.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip.js +35 -11
- package/dist/safe-bash/commands/archive/zip.js.map +1 -1
- package/dist/safe-bash/core.browser.js +51 -24
- package/dist/safe-bash/core.browser.js.map +3 -3
- package/package.json +2 -2
|
@@ -27437,18 +27437,23 @@ function parseArguments(context2, limits) {
|
|
|
27437
27437
|
checkPath(archive, limits);
|
|
27438
27438
|
return { list: list && !pipe, pipe, overwrite, destination: destination2, archive, patterns: patterns2 };
|
|
27439
27439
|
}
|
|
27440
|
-
function tokenize2(pattern) {
|
|
27440
|
+
function tokenize2(pattern, noWild, stopAtDirectories) {
|
|
27441
27441
|
const characters = Array.from(pattern);
|
|
27442
27442
|
const tokens2 = [];
|
|
27443
27443
|
for (let index = 0; index < characters.length; index++) {
|
|
27444
27444
|
const character = characters[index];
|
|
27445
|
-
if (character === "*") {
|
|
27446
|
-
|
|
27445
|
+
if (character === "*" && !noWild) {
|
|
27446
|
+
let count2 = 1;
|
|
27447
|
+
while (characters[index + 1] === "*") {
|
|
27448
|
+
count2++;
|
|
27449
|
+
index++;
|
|
27450
|
+
}
|
|
27451
|
+
tokens2.push({ kind: "star", crossDirectories: !stopAtDirectories || count2 > 1 });
|
|
27447
27452
|
} else if (character === "?") tokens2.push({ kind: "any" });
|
|
27448
|
-
else if (character === "\\") {
|
|
27453
|
+
else if (character === "\\" && !noWild) {
|
|
27449
27454
|
const escaped3 = characters[++index];
|
|
27450
27455
|
tokens2.push(escaped3 === void 0 ? { kind: "never" } : { kind: "literal", value: escaped3 });
|
|
27451
|
-
} else if (character === "[") {
|
|
27456
|
+
} else if (character === "[" && !noWild) {
|
|
27452
27457
|
const negative = characters[index + 1] === "!" || characters[index + 1] === "^";
|
|
27453
27458
|
if (negative) index++;
|
|
27454
27459
|
const ranges = [];
|
|
@@ -27474,35 +27479,43 @@ function tokenize2(pattern) {
|
|
|
27474
27479
|
return tokens2;
|
|
27475
27480
|
}
|
|
27476
27481
|
var Selection = class {
|
|
27477
|
-
constructor(patterns2, limits, signal) {
|
|
27482
|
+
constructor(patterns2, limits, signal, options2 = {}) {
|
|
27478
27483
|
this.limits = limits;
|
|
27479
27484
|
this.signal = signal;
|
|
27480
|
-
this.
|
|
27485
|
+
this.options = options2;
|
|
27486
|
+
this.patterns = patterns2.map((pattern) => tokenize2(pattern, options2.noWild === true, options2.stopAtDirectories === true));
|
|
27487
|
+
this.tailComponents = patterns2.map((pattern) => pattern.split("/").length);
|
|
27488
|
+
this.emptyTailMatch = patterns2.map((pattern) => !options2.noWild && (pattern === "*" || options2.stopAtDirectories === true && pattern === "**"));
|
|
27481
27489
|
}
|
|
27482
27490
|
limits;
|
|
27483
27491
|
signal;
|
|
27492
|
+
options;
|
|
27484
27493
|
work = 0;
|
|
27485
27494
|
patterns;
|
|
27495
|
+
tailComponents;
|
|
27496
|
+
emptyTailMatch;
|
|
27486
27497
|
matched = /* @__PURE__ */ new Set();
|
|
27487
27498
|
step() {
|
|
27488
27499
|
if (++this.work > this.limits.maxPatternSteps) fail("pattern work limit exceeded");
|
|
27489
27500
|
}
|
|
27490
27501
|
async matches(name2, firstMatchOnly = false) {
|
|
27491
27502
|
if (!this.patterns.length) return true;
|
|
27492
|
-
const
|
|
27503
|
+
const fullCharacters = Array.from(name2);
|
|
27493
27504
|
let selected = false;
|
|
27494
27505
|
for (let pattern = 0; pattern < this.patterns.length; pattern++) {
|
|
27495
27506
|
this.step();
|
|
27507
|
+
const characters = this.options.trailingComponents ? Array.from(name2.split("/").slice(-this.tailComponents[pattern]).join("/")) : fullCharacters;
|
|
27508
|
+
if (this.options.trailingComponents && !characters.length && !this.emptyTailMatch[pattern]) continue;
|
|
27496
27509
|
let states = new Uint8Array(characters.length + 1);
|
|
27497
27510
|
states[0] = 1;
|
|
27498
27511
|
for (const token of this.patterns[pattern]) {
|
|
27499
27512
|
const next = new Uint8Array(states.length);
|
|
27500
27513
|
for (let index = 0; index < states.length; index++) {
|
|
27501
27514
|
this.step();
|
|
27502
|
-
if (token.kind === "star") next[index] = states[index] || (index > 0 ? next[index - 1] : 0);
|
|
27515
|
+
if (token.kind === "star") next[index] = states[index] || (index > 0 && (token.crossDirectories || characters[index - 1] !== "/") ? next[index - 1] : 0);
|
|
27503
27516
|
else if (states[index] && index < characters.length) {
|
|
27504
27517
|
const character = characters[index];
|
|
27505
|
-
let match = token.kind === "any" || token.kind === "literal" && token.value === character;
|
|
27518
|
+
let match = token.kind === "any" && (!this.options.stopAtDirectories || character !== "/") || token.kind === "literal" && token.value === character;
|
|
27506
27519
|
if (token.kind === "class") {
|
|
27507
27520
|
let inRange = false;
|
|
27508
27521
|
for (const [first, last] of token.ranges) {
|
|
@@ -27603,7 +27616,10 @@ var longOptions = {
|
|
|
27603
27616
|
"compress-9": "9",
|
|
27604
27617
|
"force-zip64": "fz",
|
|
27605
27618
|
"strip-extra": "X",
|
|
27606
|
-
"force-descriptors": "fd"
|
|
27619
|
+
"force-descriptors": "fd",
|
|
27620
|
+
"no-wild": "nw",
|
|
27621
|
+
"wild-stop-dirs": "ws",
|
|
27622
|
+
"recurse-patterns": "R"
|
|
27607
27623
|
};
|
|
27608
27624
|
var reservedOptions = [
|
|
27609
27625
|
"adjust-sfx",
|
|
@@ -27635,12 +27651,10 @@ var reservedOptions = [
|
|
|
27635
27651
|
"license",
|
|
27636
27652
|
"move",
|
|
27637
27653
|
"must-match",
|
|
27638
|
-
"no-wild",
|
|
27639
27654
|
"latest-time",
|
|
27640
27655
|
"output-file",
|
|
27641
27656
|
"paths",
|
|
27642
27657
|
"password",
|
|
27643
|
-
"recurse-patterns",
|
|
27644
27658
|
"regex",
|
|
27645
27659
|
"split-size",
|
|
27646
27660
|
"split-pause",
|
|
@@ -27656,7 +27670,6 @@ var reservedOptions = [
|
|
|
27656
27670
|
"copy-entries",
|
|
27657
27671
|
"verbose",
|
|
27658
27672
|
"version",
|
|
27659
|
-
"wild-stop-dirs",
|
|
27660
27673
|
"archive-comment"
|
|
27661
27674
|
];
|
|
27662
27675
|
function normalizeZipOption(argument2) {
|
|
@@ -27702,6 +27715,9 @@ async function parse12(scope, limits) {
|
|
|
27702
27715
|
let archive;
|
|
27703
27716
|
let action = "add";
|
|
27704
27717
|
let recursive = false;
|
|
27718
|
+
let recursivePatterns = false;
|
|
27719
|
+
let noWild = false;
|
|
27720
|
+
let stopAtDirectories = false;
|
|
27705
27721
|
let quiet = false;
|
|
27706
27722
|
let junkPaths = false;
|
|
27707
27723
|
let omitDirectories = false;
|
|
@@ -27729,8 +27745,11 @@ async function parse12(scope, limits) {
|
|
|
27729
27745
|
} else if (!literal && argument2.startsWith("-") && argument2 !== "-") {
|
|
27730
27746
|
for (let offset = 1; offset < argument2.length; offset++) {
|
|
27731
27747
|
const flag = argument2[offset];
|
|
27732
|
-
if (flag === "r"
|
|
27733
|
-
|
|
27748
|
+
if (flag === "r" || flag === "R") {
|
|
27749
|
+
if (flag === "r") recursive = true;
|
|
27750
|
+
else recursivePatterns = true;
|
|
27751
|
+
if (recursive && recursivePatterns) throw new ZipFailure(16, "Invalid command arguments", "do not specify both -r and -R");
|
|
27752
|
+
} else if (flag === "f" && argument2[offset + 1] === "d") {
|
|
27734
27753
|
if (argument2[offset + 2] === "-") throw new ZipFailure(16, "Invalid command arguments", "option fd is not negatable");
|
|
27735
27754
|
descriptors = true;
|
|
27736
27755
|
offset++;
|
|
@@ -27741,6 +27760,11 @@ async function parse12(scope, limits) {
|
|
|
27741
27760
|
const next = flag === "d" ? "delete" : flag === "u" ? "update" : "freshen";
|
|
27742
27761
|
if (action !== "add" && action !== next) throw new ZipFailure(16, "Invalid command arguments", "specify just one action");
|
|
27743
27762
|
action = next;
|
|
27763
|
+
} else if (flag === "n" && argument2[offset + 1] === "w" || flag === "w" && argument2[offset + 1] === "s") {
|
|
27764
|
+
if (argument2[offset + 2] === "-") throw new ZipFailure(16, "Invalid command arguments", "wildcard control is not negatable");
|
|
27765
|
+
if (flag === "n") noWild = true;
|
|
27766
|
+
else stopAtDirectories = true;
|
|
27767
|
+
offset++;
|
|
27744
27768
|
} else if (flag === "q") quiet = true;
|
|
27745
27769
|
else if (flag === "j") junkPaths = true;
|
|
27746
27770
|
else if (flag === "X") {
|
|
@@ -27835,7 +27859,8 @@ async function parse12(scope, limits) {
|
|
|
27835
27859
|
start = end + 1;
|
|
27836
27860
|
}
|
|
27837
27861
|
}
|
|
27838
|
-
|
|
27862
|
+
if (recursivePatterns && !names.length && !operands.length) throw new ZipFailure(16, "Invalid command arguments", "nothing to select from");
|
|
27863
|
+
return { action, archive, recursive, recursivePatterns, noWild, stopAtDirectories, quiet, junkPaths, omitDirectories, storeLinks, test, descriptors, zip64, metadata: metadata3, includes, excludes, level, method, suffixes, operands: [...names, ...operands], firstOperand };
|
|
27839
27864
|
}
|
|
27840
27865
|
function memberName(path, limits) {
|
|
27841
27866
|
if (path.startsWith("//") && !path.startsWith("///")) fail("UNC source paths are unsupported");
|
|
@@ -27907,7 +27932,8 @@ async function prepare(scope, parsed, budget) {
|
|
|
27907
27932
|
`);
|
|
27908
27933
|
const selected = /* @__PURE__ */ new Map();
|
|
27909
27934
|
const deleted = /* @__PURE__ */ new Set();
|
|
27910
|
-
const selection = new Selection([...parsed.includes, ...parsed.excludes], limits, context2.signal);
|
|
27935
|
+
const selection = new Selection([...parsed.includes, ...parsed.excludes], limits, context2.signal, { noWild: parsed.noWild, stopAtDirectories: parsed.stopAtDirectories });
|
|
27936
|
+
const recursiveSelection = parsed.recursivePatterns ? new Selection(parsed.operands, limits, context2.signal, { noWild: parsed.noWild, stopAtDirectories: parsed.stopAtDirectories, trailingComponents: true }) : void 0;
|
|
27911
27937
|
const ancestors = [];
|
|
27912
27938
|
let visits = 0;
|
|
27913
27939
|
let work = 0;
|
|
@@ -27968,7 +27994,7 @@ async function prepare(scope, parsed, budget) {
|
|
|
27968
27994
|
if (existing2 && !hasIdentity(stat)) fail("cannot exclude archive aliases when source backing identity is unknown");
|
|
27969
27995
|
const directory2 = stat.type === "directory";
|
|
27970
27996
|
if (directory2 && name2 && !name2.endsWith("/")) name2 += "/";
|
|
27971
|
-
const included = await filterName(name2, selection, parsed.includes.length);
|
|
27997
|
+
const included = await filterName(name2, selection, parsed.includes.length) && (!recursiveSelection || await recursiveSelection.matches(name2, true));
|
|
27972
27998
|
const sourceName = name2;
|
|
27973
27999
|
if (parsed.junkPaths) name2 = directory2 ? "" : name2.slice(name2.lastIndexOf("/") + 1);
|
|
27974
28000
|
const prior = old.get(name2);
|
|
@@ -27999,7 +28025,7 @@ async function prepare(scope, parsed, budget) {
|
|
|
27999
28025
|
await encodeSelected(source2, name2, bytes4, { modified: new Date(stat.mtimeMs), mode: stat.mode, directory: directory2, symlink });
|
|
28000
28026
|
}
|
|
28001
28027
|
}
|
|
28002
|
-
if (directory2 && parsed.recursive) {
|
|
28028
|
+
if (directory2 && (parsed.recursive || parsed.recursivePatterns)) {
|
|
28003
28029
|
if (ancestors.some((ancestor) => ancestor.path === canonical || sameIdentity2(ancestor.stat, stat))) fail(`directory cycle while archiving: ${source2}`);
|
|
28004
28030
|
ancestors.push({ path: canonical, stat });
|
|
28005
28031
|
try {
|
|
@@ -28019,8 +28045,8 @@ async function prepare(scope, parsed, budget) {
|
|
|
28019
28045
|
if (!parsed.quiet && parsed.recursive) await budget.output(" zip warning: invalid option(s) used with -d; ignored.\n");
|
|
28020
28046
|
if (!parsed.quiet && !archive.entries.length) await budget.output(` zip warning: ${parsed.archive} not found or empty
|
|
28021
28047
|
`);
|
|
28022
|
-
const operands = new Selection(parsed.operands, limits, context2.signal);
|
|
28023
|
-
if (parsed.operands.length) {
|
|
28048
|
+
const operands = new Selection(parsed.recursivePatterns ? [] : parsed.operands, limits, context2.signal, { noWild: parsed.noWild, stopAtDirectories: parsed.stopAtDirectories });
|
|
28049
|
+
if (parsed.operands.length && !parsed.recursivePatterns) {
|
|
28024
28050
|
for (const entry of archive.entries) {
|
|
28025
28051
|
if (await operands.matches(entry.name) && await filterName(entry.name, selection, parsed.includes.length)) deleted.add(entry.name);
|
|
28026
28052
|
}
|
|
@@ -28033,10 +28059,11 @@ async function prepare(scope, parsed, budget) {
|
|
|
28033
28059
|
}
|
|
28034
28060
|
} else {
|
|
28035
28061
|
const operands = parsed.operands.length || parsed.action === "add" ? parsed.operands : archive.entries.map((entry) => entry.name);
|
|
28036
|
-
|
|
28062
|
+
if (parsed.recursivePatterns) await visit(".", "", 0);
|
|
28063
|
+
else for (const operand of operands) await visit(operand, memberName(operand, limits), 0);
|
|
28037
28064
|
}
|
|
28038
28065
|
if (!selected.size && (parsed.action === "freshen" || parsed.action === "update" && (existing2 || !parsed.includes.length))) return void 0;
|
|
28039
|
-
if (!selected.size && !deleted.size && (parsed.action === "delete" || !parsed.includes.length)) {
|
|
28066
|
+
if (!selected.size && !deleted.size && (parsed.action === "delete" || parsed.recursivePatterns || !parsed.includes.length)) {
|
|
28040
28067
|
const detail = parsed.action !== "delete" && parsed.recursive && parsed.firstOperand >= 0 ? `try: zip ${context2.args.slice(0, parsed.firstOperand).join(" ")} . -i ${context2.args.slice(parsed.firstOperand).join(" ")}` : parsed.archive;
|
|
28041
28068
|
throw new ZipFailure(12, "Nothing to do!", detail);
|
|
28042
28069
|
}
|