@poe-platform/safe-bash 0.1.613 → 0.1.615
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/zip/options.d.ts +7 -0
- package/dist/safe-bash/commands/archive/zip/options.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/options.js +50 -0
- package/dist/safe-bash/commands/archive/zip/options.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip.js +71 -26
- package/dist/safe-bash/commands/archive/zip.js.map +1 -1
- package/dist/safe-bash/core.browser.js +163 -21
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/package.json +2 -2
|
@@ -3245,7 +3245,7 @@ async function parseEnvOptions(args, environment, signal, argumentValues) {
|
|
|
3245
3245
|
const values = /* @__PURE__ */ new Map();
|
|
3246
3246
|
const operands = [];
|
|
3247
3247
|
const operandValues = [];
|
|
3248
|
-
const
|
|
3248
|
+
const longOptions2 = /* @__PURE__ */ new Map([
|
|
3249
3249
|
["ignore-environment", "i"],
|
|
3250
3250
|
["unset", "u"],
|
|
3251
3251
|
["null", "0"],
|
|
@@ -3280,7 +3280,7 @@ async function parseEnvOptions(args, environment, signal, argumentValues) {
|
|
|
3280
3280
|
if (argument2.startsWith("--")) {
|
|
3281
3281
|
const equals = argument2.indexOf("=");
|
|
3282
3282
|
const name2 = argument2.slice(2, equals < 0 ? void 0 : equals);
|
|
3283
|
-
const key =
|
|
3283
|
+
const key = longOptions2.get(name2);
|
|
3284
3284
|
if (!key) throw new UsageError(`unrecognized option '${argument2}'`);
|
|
3285
3285
|
const required = key === "u" || key === "C" || key === "S";
|
|
3286
3286
|
if (!required && equals >= 0) throw new UsageError(`option '--${name2}' does not take an argument`);
|
|
@@ -3555,11 +3555,11 @@ function executionCommands(execute4, configuration = {}) {
|
|
|
3555
3555
|
const operandIndices = [];
|
|
3556
3556
|
let replacementOrigin;
|
|
3557
3557
|
const shortOptions = "0rn:s:I:d:tP:xE:";
|
|
3558
|
-
const
|
|
3558
|
+
const longOptions2 = { null: "0", "no-run-if-empty": "r", "max-args": "n", "max-chars": "s", replace: "I", delimiter: "d", verbose: "t", "max-procs": "P", exit: "x", eof: "E" };
|
|
3559
3559
|
const parsed = options(
|
|
3560
3560
|
argumentValues.args,
|
|
3561
3561
|
shortOptions,
|
|
3562
|
-
|
|
3562
|
+
longOptions2,
|
|
3563
3563
|
true,
|
|
3564
3564
|
(index) => {
|
|
3565
3565
|
operandIndices.push(index);
|
|
@@ -27376,7 +27376,8 @@ var Answers = class {
|
|
|
27376
27376
|
}
|
|
27377
27377
|
};
|
|
27378
27378
|
|
|
27379
|
-
// packages/safe-bash/src/commands/archive/zip.ts
|
|
27379
|
+
// packages/safe-bash/src/commands/archive/zip/options.ts
|
|
27380
|
+
init_platform();
|
|
27380
27381
|
var ZipFailure = class extends Error {
|
|
27381
27382
|
constructor(status2, label, detail) {
|
|
27382
27383
|
super(detail);
|
|
@@ -27386,6 +27387,107 @@ var ZipFailure = class extends Error {
|
|
|
27386
27387
|
status;
|
|
27387
27388
|
label;
|
|
27388
27389
|
};
|
|
27390
|
+
var longOptions = {
|
|
27391
|
+
"recurse-paths": "r",
|
|
27392
|
+
quiet: "q",
|
|
27393
|
+
"junk-paths": "j",
|
|
27394
|
+
"no-dir-entries": "D",
|
|
27395
|
+
symlinks: "y",
|
|
27396
|
+
test: "T",
|
|
27397
|
+
"names-stdin": "@",
|
|
27398
|
+
update: "u",
|
|
27399
|
+
freshen: "f",
|
|
27400
|
+
delete: "d",
|
|
27401
|
+
include: "i",
|
|
27402
|
+
exclude: "x",
|
|
27403
|
+
suffixes: "n",
|
|
27404
|
+
store: "0",
|
|
27405
|
+
"compression-method": "Z",
|
|
27406
|
+
"compress-1": "1",
|
|
27407
|
+
"compress-2": "2",
|
|
27408
|
+
"compress-3": "3",
|
|
27409
|
+
"compress-4": "4",
|
|
27410
|
+
"compress-5": "5",
|
|
27411
|
+
"compress-6": "6",
|
|
27412
|
+
"compress-7": "7",
|
|
27413
|
+
"compress-8": "8",
|
|
27414
|
+
"compress-9": "9"
|
|
27415
|
+
};
|
|
27416
|
+
var reservedOptions = [
|
|
27417
|
+
"adjust-sfx",
|
|
27418
|
+
"temp-path",
|
|
27419
|
+
"entry-comments",
|
|
27420
|
+
"display-bytes",
|
|
27421
|
+
"display-counts",
|
|
27422
|
+
"display-dots",
|
|
27423
|
+
"display-globaldots",
|
|
27424
|
+
"dot-size",
|
|
27425
|
+
"display-usize",
|
|
27426
|
+
"display-volume",
|
|
27427
|
+
"difference-archive",
|
|
27428
|
+
"encrypt",
|
|
27429
|
+
"fix",
|
|
27430
|
+
"fixfix",
|
|
27431
|
+
"fifo",
|
|
27432
|
+
"filesync",
|
|
27433
|
+
"force-descriptors",
|
|
27434
|
+
"force-zip64",
|
|
27435
|
+
"grow",
|
|
27436
|
+
"help",
|
|
27437
|
+
"more-help",
|
|
27438
|
+
"junk-sfx",
|
|
27439
|
+
"DOS-names",
|
|
27440
|
+
"to-crlf",
|
|
27441
|
+
"from-crlf",
|
|
27442
|
+
"logfile-path",
|
|
27443
|
+
"log-append",
|
|
27444
|
+
"log-info",
|
|
27445
|
+
"license",
|
|
27446
|
+
"move",
|
|
27447
|
+
"must-match",
|
|
27448
|
+
"no-wild",
|
|
27449
|
+
"latest-time",
|
|
27450
|
+
"output-file",
|
|
27451
|
+
"paths",
|
|
27452
|
+
"password",
|
|
27453
|
+
"recurse-patterns",
|
|
27454
|
+
"regex",
|
|
27455
|
+
"split-size",
|
|
27456
|
+
"split-pause",
|
|
27457
|
+
"split-verbose",
|
|
27458
|
+
"split-bell",
|
|
27459
|
+
"show-command",
|
|
27460
|
+
"show-debug",
|
|
27461
|
+
"show-files",
|
|
27462
|
+
"show-options",
|
|
27463
|
+
"from-date",
|
|
27464
|
+
"before-date",
|
|
27465
|
+
"unzip-command",
|
|
27466
|
+
"copy-entries",
|
|
27467
|
+
"verbose",
|
|
27468
|
+
"version",
|
|
27469
|
+
"wild-stop-dirs",
|
|
27470
|
+
"strip-extra",
|
|
27471
|
+
"archive-comment"
|
|
27472
|
+
];
|
|
27473
|
+
function normalizeZipOption(argument2) {
|
|
27474
|
+
if (!argument2.startsWith("--") || argument2 === "--") return argument2;
|
|
27475
|
+
const equal2 = argument2.indexOf("=");
|
|
27476
|
+
const name2 = argument2.slice(2, equal2 < 0 ? void 0 : equal2);
|
|
27477
|
+
const names = [...Object.keys(longOptions), ...reservedOptions];
|
|
27478
|
+
const matches2 = names.includes(name2) ? [name2] : names.filter((option) => option.startsWith(name2));
|
|
27479
|
+
if (matches2.length > 1) throw new ZipFailure(16, "Invalid command arguments", `long option '${name2}' ambiguous`);
|
|
27480
|
+
const matched = matches2[0];
|
|
27481
|
+
const short = matched === void 0 ? void 0 : longOptions[matched];
|
|
27482
|
+
if (!short) throw new ZipFailure(16, "Invalid command arguments", `unsupported option: ${argument2}`);
|
|
27483
|
+
if (equal2 >= 0 && short !== "i" && short !== "x" && short !== "n" && short !== "Z") {
|
|
27484
|
+
throw new ZipFailure(16, "Invalid command arguments", `option '${matched}' does not allow a value`);
|
|
27485
|
+
}
|
|
27486
|
+
return `-${short}${equal2 < 0 ? "" : argument2.slice(equal2)}`;
|
|
27487
|
+
}
|
|
27488
|
+
|
|
27489
|
+
// packages/safe-bash/src/commands/archive/zip.ts
|
|
27490
|
+
var defaultStoreSuffixes = [".Z", ".zip", ".zoo", ".arc", ".lzh", ".arj"];
|
|
27389
27491
|
async function parse12(scope, limits) {
|
|
27390
27492
|
const context2 = scope.context;
|
|
27391
27493
|
if (context2.args.length > limits.maxArgumentBytes) fail("argument count limit exceeded");
|
|
@@ -27414,6 +27516,8 @@ async function parse12(scope, limits) {
|
|
|
27414
27516
|
let storeLinks = false;
|
|
27415
27517
|
let test = false;
|
|
27416
27518
|
let level = 6;
|
|
27519
|
+
let method = "deflate";
|
|
27520
|
+
let suffixes = defaultStoreSuffixes;
|
|
27417
27521
|
let stdinNames = false;
|
|
27418
27522
|
let literal = false;
|
|
27419
27523
|
let firstOperand = -1;
|
|
@@ -27421,8 +27525,9 @@ async function parse12(scope, limits) {
|
|
|
27421
27525
|
const includes = [];
|
|
27422
27526
|
const excludes = [];
|
|
27423
27527
|
for (let index = 0; index < context2.args.length; index++) {
|
|
27424
|
-
const
|
|
27425
|
-
checkPath(
|
|
27528
|
+
const original = context2.args[index];
|
|
27529
|
+
checkPath(original, limits);
|
|
27530
|
+
const argument2 = literal ? original : normalizeZipOption(original);
|
|
27426
27531
|
if (!literal && argument2 === "--") {
|
|
27427
27532
|
if (archive === void 0) throw new ZipFailure(16, "Invalid command arguments", "can't use -- before archive name");
|
|
27428
27533
|
literal = true;
|
|
@@ -27430,24 +27535,53 @@ async function parse12(scope, limits) {
|
|
|
27430
27535
|
for (let offset = 1; offset < argument2.length; offset++) {
|
|
27431
27536
|
const flag = argument2[offset];
|
|
27432
27537
|
if (flag === "r") recursive = true;
|
|
27433
|
-
else if (flag === "d"
|
|
27434
|
-
|
|
27538
|
+
else if (flag === "d" || flag === "u" || flag === "f") {
|
|
27539
|
+
const next = flag === "d" ? "delete" : flag === "u" ? "update" : "freshen";
|
|
27540
|
+
if (action !== "add" && action !== next) throw new ZipFailure(16, "Invalid command arguments", "specify just one action");
|
|
27541
|
+
action = next;
|
|
27542
|
+
} else if (flag === "q") quiet = true;
|
|
27435
27543
|
else if (flag === "j") junkPaths = true;
|
|
27436
27544
|
else if (flag === "D") omitDirectories = true;
|
|
27437
27545
|
else if (flag === "y") storeLinks = true;
|
|
27438
27546
|
else if (flag === "T") test = true;
|
|
27439
27547
|
else if (flag === "@") stdinNames = true;
|
|
27440
|
-
else if (flag !== void 0 && flag >= "0" && flag <= "9")
|
|
27441
|
-
|
|
27548
|
+
else if (flag !== void 0 && flag >= "0" && flag <= "9") {
|
|
27549
|
+
level = Number(flag);
|
|
27550
|
+
if (level === 0) method = "store";
|
|
27551
|
+
} else if (flag === "n" || flag === "Z") {
|
|
27552
|
+
let value2 = argument2.slice(offset + 1);
|
|
27553
|
+
if (!value2) {
|
|
27554
|
+
const next = context2.args[index + 1];
|
|
27555
|
+
if (next === void 0 || next.startsWith("-") && next !== "-") throw new ZipFailure(16, "Invalid command arguments", `option '${flag}' requires a value`);
|
|
27556
|
+
value2 = next;
|
|
27557
|
+
index++;
|
|
27558
|
+
}
|
|
27559
|
+
if (value2.startsWith("=")) value2 = value2.slice(1);
|
|
27560
|
+
if (flag === "n") {
|
|
27561
|
+
suffixes = value2 ? value2.split(":").filter((suffix2) => suffix2.length > 0) : defaultStoreSuffixes;
|
|
27562
|
+
if (value2 && suffixes.length > limits.maxMembers) fail("suffix count limit exceeded");
|
|
27563
|
+
} else {
|
|
27564
|
+
const matches2 = ["store", "deflate", "bzip2"].filter((name2) => name2.startsWith(value2.toLowerCase()));
|
|
27565
|
+
const selected = matches2.length === 1 ? matches2[0] : void 0;
|
|
27566
|
+
if (!selected) throw new ZipFailure(16, "Invalid command arguments", "Option -Z (--compression-method): unknown method");
|
|
27567
|
+
if (selected === "bzip2") throw new ZipFailure(19, "Not supported", "Compression method bzip2 not enabled");
|
|
27568
|
+
method = selected === "store" ? "store" : "deflate";
|
|
27569
|
+
}
|
|
27570
|
+
break;
|
|
27571
|
+
} else if (flag === "i" || flag === "x") {
|
|
27442
27572
|
const patterns2 = flag === "i" ? includes : excludes;
|
|
27443
27573
|
const before = patterns2.length;
|
|
27444
27574
|
const append = (pattern) => {
|
|
27445
|
-
checkPath(pattern, limits);
|
|
27575
|
+
if (pattern) checkPath(pattern, limits);
|
|
27446
27576
|
if (includes.length + excludes.length >= limits.maxMembers) fail("pattern count limit exceeded");
|
|
27447
27577
|
patterns2.push(pattern);
|
|
27448
27578
|
};
|
|
27449
|
-
|
|
27450
|
-
|
|
27579
|
+
const attached = offset + 1 < argument2.length;
|
|
27580
|
+
if (attached) {
|
|
27581
|
+
const value2 = argument2.slice(offset + 1);
|
|
27582
|
+
append(value2.startsWith("=") ? value2.slice(1) : value2);
|
|
27583
|
+
}
|
|
27584
|
+
while (!attached && index + 1 < context2.args.length) {
|
|
27451
27585
|
const next = context2.args[index + 1];
|
|
27452
27586
|
if (next === "@") {
|
|
27453
27587
|
index++;
|
|
@@ -27493,7 +27627,7 @@ async function parse12(scope, limits) {
|
|
|
27493
27627
|
start = end + 1;
|
|
27494
27628
|
}
|
|
27495
27629
|
}
|
|
27496
|
-
return { action, archive, recursive, quiet, junkPaths, omitDirectories, storeLinks, test, includes, excludes, level, operands: [...names, ...operands], firstOperand };
|
|
27630
|
+
return { action, archive, recursive, quiet, junkPaths, omitDirectories, storeLinks, test, includes, excludes, level, method, suffixes, operands: [...names, ...operands], firstOperand };
|
|
27497
27631
|
}
|
|
27498
27632
|
function memberName(path, limits) {
|
|
27499
27633
|
if (path.startsWith("//") && !path.startsWith("///")) fail("UNC source paths are unsupported");
|
|
@@ -27553,6 +27687,8 @@ async function prepare(scope, parsed, budget) {
|
|
|
27553
27687
|
if (!current || !unchanged4(existing2, current)) fail("archive changed while reading");
|
|
27554
27688
|
}
|
|
27555
27689
|
const old = new Map(archive.entries.map((entry) => [entry.name, entry]));
|
|
27690
|
+
if (!archive.entries.length && !parsed.quiet && (parsed.action === "update" || parsed.action === "freshen")) await budget.output(` zip warning: ${parsed.archive} not found or empty
|
|
27691
|
+
`);
|
|
27556
27692
|
const selected = /* @__PURE__ */ new Map();
|
|
27557
27693
|
const deleted = /* @__PURE__ */ new Set();
|
|
27558
27694
|
const selection = new Selection([...parsed.includes, ...parsed.excludes], limits, context2.signal);
|
|
@@ -27593,7 +27729,9 @@ async function prepare(scope, parsed, budget) {
|
|
|
27593
27729
|
const included = await filterName(name2, selection, parsed.includes.length);
|
|
27594
27730
|
const sourceName = name2;
|
|
27595
27731
|
if (parsed.junkPaths) name2 = directory2 ? "" : name2.slice(name2.lastIndexOf("/") + 1);
|
|
27596
|
-
|
|
27732
|
+
const prior = old.get(name2);
|
|
27733
|
+
const eligible = parsed.action !== "update" && parsed.action !== "freshen" || (prior ? Math.floor(stat.mtimeMs / 1e3) > Math.floor(prior.modified.getTime() / 1e3) : parsed.action === "update");
|
|
27734
|
+
if (name2 && included && eligible && !(directory2 && parsed.omitDirectories)) {
|
|
27597
27735
|
checkPath(name2, limits);
|
|
27598
27736
|
const previous = selected.get(name2);
|
|
27599
27737
|
if (previous && previous.source !== source2) {
|
|
@@ -27616,9 +27754,10 @@ async function prepare(scope, parsed, budget) {
|
|
|
27616
27754
|
if (!directory2 && bytes4.length !== stat.size) fail(`source changed while reading: ${source2}`);
|
|
27617
27755
|
const current = await inspectSource(scope, path, parsed.storeLinks);
|
|
27618
27756
|
if (current.canonical !== canonical || !unchanged4(stat, current.stat)) fail(`source changed while reading: ${source2}`);
|
|
27619
|
-
|
|
27620
|
-
if (
|
|
27621
|
-
const
|
|
27757
|
+
const store = parsed.method === "store" || parsed.level !== 9 && parsed.suffixes.some((suffix2) => name2.endsWith(suffix2));
|
|
27758
|
+
if (!store && parsed.level === 0 && stat.size && !directory2 && !symlink) throw new ZipFailure(5, "Internal logic error", "bad pack level");
|
|
27759
|
+
const level = store ? 0 : parsed.level;
|
|
27760
|
+
let entry = await makeZipEntry(name2, bytes4, { modified: new Date(stat.mtimeMs), mode: stat.mode, directory: directory2, symlink }, limits, context2.signal, level);
|
|
27622
27761
|
if (prior?.comment) entry = { ...entry, comment: prior.comment };
|
|
27623
27762
|
if (entry.data.length > limits.maxArchiveBytes - compressedBytes) fail("archive byte limit exceeded");
|
|
27624
27763
|
compressedBytes += entry.data.length;
|
|
@@ -27658,8 +27797,10 @@ async function prepare(scope, parsed, budget) {
|
|
|
27658
27797
|
}
|
|
27659
27798
|
}
|
|
27660
27799
|
} else {
|
|
27661
|
-
|
|
27800
|
+
const operands = parsed.operands.length || parsed.action === "add" ? parsed.operands : archive.entries.map((entry) => entry.name);
|
|
27801
|
+
for (const operand of operands) await visit(operand, memberName(operand, limits), 0);
|
|
27662
27802
|
}
|
|
27803
|
+
if (!selected.size && (parsed.action === "freshen" || parsed.action === "update" && (existing2 || !parsed.includes.length))) return void 0;
|
|
27663
27804
|
if (!selected.size && !deleted.size && (parsed.action === "delete" || !parsed.includes.length)) {
|
|
27664
27805
|
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;
|
|
27665
27806
|
throw new ZipFailure(12, "Nothing to do!", detail);
|
|
@@ -27676,7 +27817,7 @@ async function prepare(scope, parsed, budget) {
|
|
|
27676
27817
|
};
|
|
27677
27818
|
const append = (entry, update) => {
|
|
27678
27819
|
const percentage = entry.size ? Math.trunc((Math.trunc(200 * (entry.size - entry.data.length) / entry.size) + 1) / 2) : 0;
|
|
27679
|
-
queue(`${update ? "updating:" : " adding:"} ${entry.name} (${entry.method === 8 ? `deflated ${percentage}%` : "stored 0%"})
|
|
27820
|
+
queue(`${update ? parsed.action === "freshen" ? "freshening:" : "updating:" : " adding:"} ${entry.name} (${entry.method === 8 ? `deflated ${percentage}%` : "stored 0%"})
|
|
27680
27821
|
`);
|
|
27681
27822
|
};
|
|
27682
27823
|
for (const entry of archive.entries) {
|
|
@@ -27739,6 +27880,7 @@ function createZipCommand(options2 = {}) {
|
|
|
27739
27880
|
try {
|
|
27740
27881
|
const parsed = await parse12(scope, limits);
|
|
27741
27882
|
const prepared = await prepare(scope, parsed, budget);
|
|
27883
|
+
if (!prepared) return { exitCode: 12 };
|
|
27742
27884
|
await writeFileOutput(context2, prepared.bytes, () => scope.operation(() => publishZip(scope, prepared)));
|
|
27743
27885
|
for (const message3 of prepared.progress) await budget.output(message3);
|
|
27744
27886
|
return { exitCode: 0 };
|