@unbrained/pm-cli 2026.12.1 → 2026.12.2
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/.claude-plugin/marketplace.json +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-CWPR234D.js → chunk-7NAO7I75.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YQMQOUO.js → chunk-7V65VACG.js} +52 -52
- package/dist/cli-bundle/chunks/{chunk-NA6D75V5.js → chunk-G6TARHFK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YSVOXCYH.js → chunk-GOEQXVOI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OKEJ4U2I.js → chunk-ROTEELDL.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-U7RBJGLF.js → chunk-SDXCJZKB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XME6GIFQ.js → chunk-TKUG2X24.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q6GLSAJY.js → chunk-UNBW2LF3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-V2S4XAX3.js +2 -0
- package/dist/cli-bundle/chunks/{item-transaction-66RDV7PH.js → item-transaction-56J5OCHA.js} +2 -2
- package/dist/cli-bundle/chunks/{linked-resource-value-list-E2DX52LY.js → linked-resource-value-list-ZBIY4H23.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-2F6JUBST.js → register-mutation-EK6DVIQK.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-ET3UKPYK.js → register-operations-6MURXE4V.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-I63QTFCU.js → register-setup-RW26X3GJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SQ72CVUH.js → chunk-3COWDIPX.js} +54 -54
- package/dist/cli-bundle/focused-chunks/{chunk-PT7RT3T6.js → chunk-J72TRWR5.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{item-transaction-2K4SFLJ7.js → item-transaction-LQLQLZE7.js} +2 -2
- package/dist/cli-bundle/main.js +3 -3
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +1 -1
- package/dist/sdk/extension/install-sources.d.ts +2 -2
- package/dist/sdk/extension/install-sources.js +5 -5
- package/marketplace.json +1 -1
- package/node_modules/tar/README.md +1792 -1147
- package/node_modules/tar/dist/commonjs/bytes.d.ts +21 -0
- package/node_modules/tar/dist/commonjs/bytes.js +83 -0
- package/node_modules/tar/dist/commonjs/codec.d.ts +53 -0
- package/node_modules/tar/dist/commonjs/codec.js +35 -0
- package/node_modules/tar/dist/commonjs/concat.d.ts +3 -0
- package/node_modules/tar/dist/commonjs/concat.js +20 -0
- package/node_modules/tar/dist/commonjs/create.d.ts +39 -2
- package/node_modules/tar/dist/commonjs/create.js +150 -64
- package/node_modules/tar/dist/commonjs/dealias.d.ts +79 -0
- package/node_modules/tar/dist/commonjs/dealias.js +50 -0
- package/node_modules/tar/dist/commonjs/delete.d.ts +19 -0
- package/node_modules/tar/dist/commonjs/delete.js +121 -0
- package/node_modules/tar/dist/commonjs/entries.d.ts +82 -0
- package/node_modules/tar/dist/commonjs/entries.js +398 -0
- package/node_modules/tar/dist/commonjs/extract.d.ts +14 -2
- package/node_modules/tar/dist/commonjs/extract.js +40 -81
- package/node_modules/tar/dist/commonjs/fs.d.ts +201 -0
- package/node_modules/tar/dist/commonjs/fs.js +5 -0
- package/node_modules/tar/dist/commonjs/header.d.ts +4 -4
- package/node_modules/tar/dist/commonjs/header.js +71 -53
- package/node_modules/tar/dist/commonjs/index.d.ts +25 -18
- package/node_modules/tar/dist/commonjs/index.js +46 -18
- package/node_modules/tar/dist/commonjs/index.min.js +2 -3
- package/node_modules/tar/dist/commonjs/large-numbers.d.ts +2 -2
- package/node_modules/tar/dist/commonjs/large-numbers.js +4 -4
- package/node_modules/tar/dist/commonjs/list.d.ts +23 -6
- package/node_modules/tar/dist/commonjs/list.js +99 -138
- package/node_modules/tar/dist/commonjs/mkdir.d.ts +16 -11
- package/node_modules/tar/dist/commonjs/mkdir.js +121 -159
- package/node_modules/tar/dist/commonjs/normalize-unicode.js +9 -0
- package/node_modules/tar/dist/commonjs/options.d.ts +284 -513
- package/node_modules/tar/dist/commonjs/options.js +20 -61
- package/node_modules/tar/dist/commonjs/pack.d.ts +150 -96
- package/node_modules/tar/dist/commonjs/pack.js +752 -445
- package/node_modules/tar/dist/commonjs/parser.d.ts +98 -0
- package/node_modules/tar/dist/commonjs/parser.js +452 -0
- package/node_modules/tar/dist/commonjs/path-reservations.d.ts +17 -7
- package/node_modules/tar/dist/commonjs/path-reservations.js +110 -140
- package/node_modules/tar/dist/commonjs/path.d.ts +19 -0
- package/node_modules/tar/dist/commonjs/path.js +90 -0
- package/node_modules/tar/dist/commonjs/pax.d.ts +3 -1
- package/node_modules/tar/dist/commonjs/pax.js +67 -36
- package/node_modules/tar/dist/commonjs/read-entry.d.ts +97 -11
- package/node_modules/tar/dist/commonjs/read-entry.js +251 -97
- package/node_modules/tar/dist/commonjs/read-file.d.ts +22 -0
- package/node_modules/tar/dist/commonjs/read-file.js +104 -0
- package/node_modules/tar/dist/commonjs/replace.d.ts +45 -1
- package/node_modules/tar/dist/commonjs/replace.js +164 -211
- package/node_modules/tar/dist/commonjs/server/codecs.d.ts +38 -0
- package/node_modules/tar/dist/commonjs/server/codecs.js +252 -0
- package/node_modules/tar/dist/commonjs/server/index.d.ts +115 -0
- package/node_modules/tar/dist/commonjs/server/index.js +166 -0
- package/node_modules/tar/dist/commonjs/server/index.min.js +3 -0
- package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +8 -0
- package/node_modules/tar/dist/commonjs/strip-absolute-path.js +17 -20
- package/node_modules/tar/dist/commonjs/to-stream.d.ts +7 -0
- package/node_modules/tar/dist/commonjs/to-stream.js +22 -0
- package/node_modules/tar/dist/commonjs/types.d.ts +4 -3
- package/node_modules/tar/dist/commonjs/types.js +4 -3
- package/node_modules/tar/dist/commonjs/unpack.d.ts +143 -89
- package/node_modules/tar/dist/commonjs/unpack.js +780 -725
- package/node_modules/tar/dist/commonjs/update.d.ts +11 -1
- package/node_modules/tar/dist/commonjs/update.js +37 -28
- package/node_modules/tar/dist/commonjs/warn.d.ts +27 -0
- package/node_modules/tar/dist/commonjs/warn.js +36 -0
- package/node_modules/tar/dist/commonjs/win32-path.d.ts +16 -0
- package/node_modules/tar/dist/commonjs/win32-path.js +67 -0
- package/node_modules/tar/dist/commonjs/write-entry.d.ts +64 -111
- package/node_modules/tar/dist/commonjs/write-entry.js +108 -672
- package/node_modules/tar/dist/commonjs/write-flag.d.ts +18 -0
- package/node_modules/tar/dist/commonjs/write-flag.js +29 -0
- package/node_modules/tar/dist/esm/bytes.d.ts +21 -0
- package/node_modules/tar/dist/esm/bytes.js +72 -0
- package/node_modules/tar/dist/esm/codec.d.ts +53 -0
- package/node_modules/tar/dist/esm/codec.js +32 -0
- package/node_modules/tar/dist/esm/concat.d.ts +3 -0
- package/node_modules/tar/dist/esm/concat.js +16 -0
- package/node_modules/tar/dist/esm/create.d.ts +39 -2
- package/node_modules/tar/dist/esm/create.js +144 -61
- package/node_modules/tar/dist/esm/dealias.d.ts +79 -0
- package/node_modules/tar/dist/esm/dealias.js +46 -0
- package/node_modules/tar/dist/esm/delete.d.ts +19 -0
- package/node_modules/tar/dist/esm/delete.js +117 -0
- package/node_modules/tar/dist/esm/entries.d.ts +82 -0
- package/node_modules/tar/dist/esm/entries.js +388 -0
- package/node_modules/tar/dist/esm/extract.d.ts +14 -2
- package/node_modules/tar/dist/esm/extract.js +37 -44
- package/node_modules/tar/dist/esm/fs.d.ts +201 -0
- package/node_modules/tar/dist/esm/fs.js +4 -0
- package/node_modules/tar/dist/esm/header.d.ts +4 -4
- package/node_modules/tar/dist/esm/header.js +71 -53
- package/node_modules/tar/dist/esm/index.d.ts +25 -18
- package/node_modules/tar/dist/esm/index.js +23 -18
- package/node_modules/tar/dist/esm/index.min.js +2 -3
- package/node_modules/tar/dist/esm/large-numbers.d.ts +2 -2
- package/node_modules/tar/dist/esm/large-numbers.js +4 -4
- package/node_modules/tar/dist/esm/list.d.ts +23 -6
- package/node_modules/tar/dist/esm/list.js +96 -101
- package/node_modules/tar/dist/esm/mkdir.d.ts +16 -11
- package/node_modules/tar/dist/esm/mkdir.js +119 -154
- package/node_modules/tar/dist/esm/normalize-unicode.js +9 -0
- package/node_modules/tar/dist/esm/options.d.ts +284 -513
- package/node_modules/tar/dist/esm/options.js +17 -51
- package/node_modules/tar/dist/esm/pack.d.ts +150 -96
- package/node_modules/tar/dist/esm/pack.js +750 -441
- package/node_modules/tar/dist/esm/parser.d.ts +98 -0
- package/node_modules/tar/dist/esm/parser.js +448 -0
- package/node_modules/tar/dist/esm/path-reservations.d.ts +17 -7
- package/node_modules/tar/dist/esm/path-reservations.js +110 -140
- package/node_modules/tar/dist/esm/path.d.ts +19 -0
- package/node_modules/tar/dist/esm/path.js +80 -0
- package/node_modules/tar/dist/esm/pax.d.ts +3 -1
- package/node_modules/tar/dist/esm/pax.js +66 -35
- package/node_modules/tar/dist/esm/read-entry.d.ts +97 -11
- package/node_modules/tar/dist/esm/read-entry.js +248 -96
- package/node_modules/tar/dist/esm/read-file.d.ts +22 -0
- package/node_modules/tar/dist/esm/read-file.js +99 -0
- package/node_modules/tar/dist/esm/replace.d.ts +45 -1
- package/node_modules/tar/dist/esm/replace.js +160 -207
- package/node_modules/tar/dist/esm/server/codecs.d.ts +38 -0
- package/node_modules/tar/dist/esm/server/codecs.js +214 -0
- package/node_modules/tar/dist/esm/server/index.d.ts +115 -0
- package/node_modules/tar/dist/esm/server/index.js +102 -0
- package/node_modules/tar/dist/esm/server/index.min.js +3 -0
- package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +8 -0
- package/node_modules/tar/dist/esm/strip-absolute-path.js +17 -20
- package/node_modules/tar/dist/esm/to-stream.d.ts +7 -0
- package/node_modules/tar/dist/esm/to-stream.js +18 -0
- package/node_modules/tar/dist/esm/types.d.ts +4 -3
- package/node_modules/tar/dist/esm/types.js +4 -3
- package/node_modules/tar/dist/esm/unpack.d.ts +143 -89
- package/node_modules/tar/dist/esm/unpack.js +776 -719
- package/node_modules/tar/dist/esm/update.d.ts +11 -1
- package/node_modules/tar/dist/esm/update.js +35 -28
- package/node_modules/tar/dist/esm/warn.d.ts +27 -0
- package/node_modules/tar/dist/esm/warn.js +31 -0
- package/node_modules/tar/dist/esm/win32-path.d.ts +16 -0
- package/node_modules/tar/dist/esm/win32-path.js +60 -0
- package/node_modules/tar/dist/esm/write-entry.d.ts +64 -111
- package/node_modules/tar/dist/esm/write-entry.js +107 -633
- package/node_modules/tar/dist/esm/write-flag.d.ts +18 -0
- package/node_modules/tar/dist/esm/write-flag.js +25 -0
- package/node_modules/tar/package.json +68 -224
- package/package.json +2 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-AJLU6KLW.js +0 -2
- package/node_modules/@isaacs/fs-minipass/LICENSE +0 -15
- package/node_modules/@isaacs/fs-minipass/README.md +0 -71
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +0 -118
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +0 -430
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +0 -3
- package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +0 -118
- package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +0 -420
- package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +0 -3
- package/node_modules/@isaacs/fs-minipass/package.json +0 -72
- package/node_modules/chownr/LICENSE.md +0 -63
- package/node_modules/chownr/README.md +0 -3
- package/node_modules/chownr/dist/commonjs/index.d.ts +0 -3
- package/node_modules/chownr/dist/commonjs/index.js +0 -93
- package/node_modules/chownr/dist/commonjs/package.json +0 -3
- package/node_modules/chownr/dist/esm/index.d.ts +0 -3
- package/node_modules/chownr/dist/esm/index.js +0 -85
- package/node_modules/chownr/dist/esm/package.json +0 -3
- package/node_modules/chownr/package.json +0 -69
- package/node_modules/minipass/LICENSE.md +0 -55
- package/node_modules/minipass/README.md +0 -825
- package/node_modules/minipass/dist/commonjs/index.d.ts +0 -545
- package/node_modules/minipass/dist/commonjs/index.js +0 -1038
- package/node_modules/minipass/dist/commonjs/package.json +0 -3
- package/node_modules/minipass/dist/esm/index.d.ts +0 -545
- package/node_modules/minipass/dist/esm/index.js +0 -1020
- package/node_modules/minipass/dist/esm/package.json +0 -3
- package/node_modules/minipass/package.json +0 -77
- package/node_modules/minizlib/LICENSE +0 -26
- package/node_modules/minizlib/README.md +0 -64
- package/node_modules/minizlib/dist/commonjs/constants.d.ts +0 -2
- package/node_modules/minizlib/dist/commonjs/constants.js +0 -123
- package/node_modules/minizlib/dist/commonjs/index.d.ts +0 -99
- package/node_modules/minizlib/dist/commonjs/index.js +0 -416
- package/node_modules/minizlib/dist/commonjs/package.json +0 -3
- package/node_modules/minizlib/dist/esm/constants.d.ts +0 -2
- package/node_modules/minizlib/dist/esm/constants.js +0 -117
- package/node_modules/minizlib/dist/esm/index.d.ts +0 -99
- package/node_modules/minizlib/dist/esm/index.js +0 -363
- package/node_modules/minizlib/dist/esm/package.json +0 -3
- package/node_modules/minizlib/package.json +0 -80
- package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/get-write-flag.js +0 -32
- package/node_modules/tar/dist/commonjs/make-command.d.ts +0 -49
- package/node_modules/tar/dist/commonjs/make-command.js +0 -52
- package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/normalize-windows-path.js +0 -12
- package/node_modules/tar/dist/commonjs/parse.d.ts +0 -92
- package/node_modules/tar/dist/commonjs/parse.js +0 -655
- package/node_modules/tar/dist/commonjs/process-umask.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/process-umask.js +0 -7
- package/node_modules/tar/dist/commonjs/warn-method.d.ts +0 -24
- package/node_modules/tar/dist/commonjs/warn-method.js +0 -31
- package/node_modules/tar/dist/esm/get-write-flag.d.ts +0 -2
- package/node_modules/tar/dist/esm/get-write-flag.js +0 -26
- package/node_modules/tar/dist/esm/make-command.d.ts +0 -49
- package/node_modules/tar/dist/esm/make-command.js +0 -48
- package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +0 -2
- package/node_modules/tar/dist/esm/normalize-windows-path.js +0 -9
- package/node_modules/tar/dist/esm/parse.d.ts +0 -92
- package/node_modules/tar/dist/esm/parse.js +0 -651
- package/node_modules/tar/dist/esm/process-umask.d.ts +0 -2
- package/node_modules/tar/dist/esm/process-umask.js +0 -3
- package/node_modules/tar/dist/esm/warn-method.d.ts +0 -24
- package/node_modules/tar/dist/esm/warn-method.js +0 -27
- package/node_modules/yallist/LICENSE.md +0 -63
- package/node_modules/yallist/README.md +0 -205
- package/node_modules/yallist/dist/commonjs/index.d.ts +0 -39
- package/node_modules/yallist/dist/commonjs/index.js +0 -384
- package/node_modules/yallist/dist/commonjs/package.json +0 -3
- package/node_modules/yallist/dist/esm/index.d.ts +0 -39
- package/node_modules/yallist/dist/esm/index.js +0 -379
- package/node_modules/yallist/dist/esm/package.json +0 -3
- package/node_modules/yallist/package.json +0 -68
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.delete = exports.deleteSync = void 0;
|
|
4
|
+
const codec_js_1 = require("./codec.js");
|
|
5
|
+
const create_js_1 = require("./create.js");
|
|
6
|
+
const dealias_js_1 = require("./dealias.js");
|
|
7
|
+
const entries_js_1 = require("./entries.js");
|
|
8
|
+
const list_js_1 = require("./list.js");
|
|
9
|
+
const read_file_js_1 = require("./read-file.js");
|
|
10
|
+
const noop = () => { };
|
|
11
|
+
// The codecs to look for, and the filter and the report of the paths
|
|
12
|
+
// to delete.
|
|
13
|
+
const plan = (opt, files) => {
|
|
14
|
+
if (!opt.file)
|
|
15
|
+
throw new TypeError('file is required');
|
|
16
|
+
if (!opt.fs)
|
|
17
|
+
throw new TypeError('the file option needs the fs option');
|
|
18
|
+
const codecs = [...(opt.codecs ?? []), codec_js_1.gzip];
|
|
19
|
+
if (files?.length)
|
|
20
|
+
return [codecs, ...(0, list_js_1.filesFilter)(files, opt.filter)];
|
|
21
|
+
if (opt.filter)
|
|
22
|
+
return [codecs, opt.filter];
|
|
23
|
+
throw new TypeError('no paths specified to delete');
|
|
24
|
+
};
|
|
25
|
+
// The path of the new archive, until it gets the path of the old one.
|
|
26
|
+
const tmpName = (file) => `${file}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
27
|
+
/**
|
|
28
|
+
* Remove entries from an archive file. An entry is removed if
|
|
29
|
+
* `files` lists its path or one of its parent directories. With
|
|
30
|
+
* `opt.filter`, only if the filter also returns true. With no
|
|
31
|
+
* `files`, each entry that the filter accepts is removed. A listed
|
|
32
|
+
* path that no entry matches is a warning.
|
|
33
|
+
*
|
|
34
|
+
* The other entries are written to a new file next to the archive,
|
|
35
|
+
* with the compression and the mode of the archive. The new file
|
|
36
|
+
* then gets the path of the archive. The archive does not change if
|
|
37
|
+
* the command fails.
|
|
38
|
+
*/
|
|
39
|
+
const del = async (options, files) => {
|
|
40
|
+
const opt = (0, dealias_js_1.dealias)(options);
|
|
41
|
+
const [codecs, remove, report] = plan(opt, files);
|
|
42
|
+
const { fs, file, filter: _, maxReadSize, ...read } = opt;
|
|
43
|
+
const head = new Uint8Array((0, entries_js_1.headLength)(codecs));
|
|
44
|
+
let length = 0;
|
|
45
|
+
const handle = await fs.open(file, 'r');
|
|
46
|
+
try {
|
|
47
|
+
for (let n = 1; n > 0 && length < head.length; length += n) {
|
|
48
|
+
n = (await handle.read(head, length, head.length - length, length))
|
|
49
|
+
.bytesRead;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
await handle.close();
|
|
54
|
+
}
|
|
55
|
+
const { mode } = await fs.stat(file);
|
|
56
|
+
const tmp = tmpName(file);
|
|
57
|
+
try {
|
|
58
|
+
await (0, create_js_1.create)({
|
|
59
|
+
...read,
|
|
60
|
+
fs,
|
|
61
|
+
file: tmp,
|
|
62
|
+
mode: mode & 0o777,
|
|
63
|
+
compress: (0, entries_js_1.findCodec)(codecs, head.subarray(0, length), file),
|
|
64
|
+
preservePaths: true,
|
|
65
|
+
filter: (path, entry) => !remove(path, entry),
|
|
66
|
+
}, [new entries_js_1.TarReader((0, read_file_js_1.readFile)(fs, file, maxReadSize), { ...read, file })]);
|
|
67
|
+
report?.(opt);
|
|
68
|
+
await fs.rename(tmp, file);
|
|
69
|
+
}
|
|
70
|
+
catch (er) {
|
|
71
|
+
await fs.unlink(tmp).catch(noop);
|
|
72
|
+
throw er;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.delete = del;
|
|
76
|
+
/** The sync form of `delete`. */
|
|
77
|
+
const deleteSync = (options, files) => {
|
|
78
|
+
const opt = (0, dealias_js_1.dealias)(options);
|
|
79
|
+
const [codecs, remove, report] = plan(opt, files);
|
|
80
|
+
const { fs, file, filter: _, maxReadSize, ...read } = opt;
|
|
81
|
+
const head = new Uint8Array((0, entries_js_1.headLength)(codecs));
|
|
82
|
+
let length = 0;
|
|
83
|
+
const fd = fs.openSync(file, 'r');
|
|
84
|
+
try {
|
|
85
|
+
for (let n = 1; n > 0 && length < head.length; length += n) {
|
|
86
|
+
n = fs.readSync(fd, head, length, head.length - length, length);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
fs.closeSync(fd);
|
|
91
|
+
}
|
|
92
|
+
const { mode } = fs.statSync(file);
|
|
93
|
+
const tmp = tmpName(file);
|
|
94
|
+
try {
|
|
95
|
+
(0, create_js_1.createSync)({
|
|
96
|
+
...read,
|
|
97
|
+
fs,
|
|
98
|
+
file: tmp,
|
|
99
|
+
mode: mode & 0o777,
|
|
100
|
+
compress: (0, entries_js_1.findCodec)(codecs, head.subarray(0, length), file),
|
|
101
|
+
preservePaths: true,
|
|
102
|
+
filter: (path, entry) => !remove(path, entry),
|
|
103
|
+
}, [
|
|
104
|
+
new entries_js_1.TarReaderSync((0, read_file_js_1.readFileSync)(fs, file, maxReadSize), {
|
|
105
|
+
...read,
|
|
106
|
+
file,
|
|
107
|
+
}),
|
|
108
|
+
]);
|
|
109
|
+
report?.(opt);
|
|
110
|
+
fs.renameSync(tmp, file);
|
|
111
|
+
}
|
|
112
|
+
catch (er) {
|
|
113
|
+
try {
|
|
114
|
+
fs.unlinkSync(tmp);
|
|
115
|
+
}
|
|
116
|
+
catch { }
|
|
117
|
+
throw er;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
exports.deleteSync = deleteSync;
|
|
121
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type Codec } from './codec.js';
|
|
2
|
+
import { type ReadOptions, type ReadOptionsSync, type TarInput, type TarInputSync } from './options.js';
|
|
3
|
+
import { Parser } from './parser.js';
|
|
4
|
+
import { ReadEntry, ReadEntrySync, type BodySource, type BodySourceSync, type EntryData } from './read-entry.js';
|
|
5
|
+
export declare const headLength: (codecs: Codec[]) => number;
|
|
6
|
+
export declare const findCodec: (codecs: Codec[], head: Uint8Array, file?: string) => Codec | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Gets entries and the parts of their bodies from a `Parser`. The
|
|
9
|
+
* readers use it. It does not read input.
|
|
10
|
+
*/
|
|
11
|
+
export declare class EntryCursor<E extends EntryData> {
|
|
12
|
+
parser: Parser<E>;
|
|
13
|
+
/** The entry that has a body to read now. */
|
|
14
|
+
current?: E;
|
|
15
|
+
/** True after the end of the archive. */
|
|
16
|
+
ended: boolean;
|
|
17
|
+
constructor(parser: Parser<E>);
|
|
18
|
+
/**
|
|
19
|
+
* The next entry that is not ignored. `null` at the end of the
|
|
20
|
+
* archive. `undefined` if the parser needs more input. The rest of
|
|
21
|
+
* the body of the entry before it is skipped.
|
|
22
|
+
*/
|
|
23
|
+
entry(): E | null | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The next part of the body of `entry`. `null` at the end of the
|
|
26
|
+
* body. `undefined` if the parser needs more input.
|
|
27
|
+
*/
|
|
28
|
+
body(entry: E): Uint8Array | null | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reads the entries of an archive from async input. It is the
|
|
32
|
+
* iterator that `entries()` returns.
|
|
33
|
+
*
|
|
34
|
+
* Input is read only when the consumer asks for the next entry or
|
|
35
|
+
* for more of a body. `poll()` and `fill()` do the same work as
|
|
36
|
+
* `next()`, with no promise for an entry that is in memory.
|
|
37
|
+
*/
|
|
38
|
+
export declare class TarReader implements AsyncIterableIterator<ReadEntry, undefined>, BodySource {
|
|
39
|
+
#private;
|
|
40
|
+
parser: Parser<ReadEntry>;
|
|
41
|
+
constructor(input: TarInput, opt?: ReadOptions);
|
|
42
|
+
/**
|
|
43
|
+
* The next entry, if it is in memory. `null` at the end of the
|
|
44
|
+
* archive. `undefined` if more input is needed: then await `fill()`
|
|
45
|
+
* and call this again.
|
|
46
|
+
*/
|
|
47
|
+
poll(): ReadEntry | null | undefined;
|
|
48
|
+
readBody(entry: ReadEntry): Uint8Array | null | undefined;
|
|
49
|
+
/** Read one chunk of input, and give it to the parser. */
|
|
50
|
+
fill(): Promise<void>;
|
|
51
|
+
next(): Promise<IteratorResult<ReadEntry, undefined>>;
|
|
52
|
+
/** Stop reading, and release the input. */
|
|
53
|
+
return(): Promise<IteratorResult<ReadEntry, undefined>>;
|
|
54
|
+
[Symbol.asyncIterator](): this;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Reads the entries of an archive from sync input. It is the
|
|
58
|
+
* iterator that `entriesSync()` returns.
|
|
59
|
+
*/
|
|
60
|
+
export declare class TarReaderSync implements IterableIterator<ReadEntrySync, undefined>, BodySourceSync {
|
|
61
|
+
#private;
|
|
62
|
+
parser: Parser<ReadEntrySync>;
|
|
63
|
+
constructor(input: TarInputSync, opt?: ReadOptionsSync);
|
|
64
|
+
readBody(entry: ReadEntrySync): Uint8Array | null;
|
|
65
|
+
next(): IteratorResult<ReadEntrySync, undefined>;
|
|
66
|
+
/** Stop reading, and release the input. */
|
|
67
|
+
return(): IteratorResult<ReadEntrySync, undefined>;
|
|
68
|
+
[Symbol.iterator](): this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Read the entries of an archive. Gzip input is decompressed.
|
|
72
|
+
*
|
|
73
|
+
* Read the body of an entry before the next entry: when the iterator
|
|
74
|
+
* moves on, the rest of the body is skipped.
|
|
75
|
+
*/
|
|
76
|
+
export declare const entries: (input: TarInput, opt?: ReadOptions) => AsyncIterableIterator<ReadEntry, undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* Read the entries of an archive with no promises. Compressed input
|
|
79
|
+
* needs a codec with a `decompressSync` function in `opt.codecs`.
|
|
80
|
+
*/
|
|
81
|
+
export declare const entriesSync: (input: TarInputSync, opt?: ReadOptionsSync) => IterableIterator<ReadEntrySync, undefined>;
|
|
82
|
+
//# sourceMappingURL=entries.d.ts.map
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entriesSync = exports.entries = exports.TarReaderSync = exports.TarReader = exports.EntryCursor = exports.findCodec = exports.headLength = void 0;
|
|
4
|
+
const bytes_js_1 = require("./bytes.js");
|
|
5
|
+
const header_js_1 = require("./header.js");
|
|
6
|
+
const codec_js_1 = require("./codec.js");
|
|
7
|
+
const concat_js_1 = require("./concat.js");
|
|
8
|
+
const options_js_1 = require("./options.js");
|
|
9
|
+
const parser_js_1 = require("./parser.js");
|
|
10
|
+
const read_entry_js_1 = require("./read-entry.js");
|
|
11
|
+
const read_file_js_1 = require("./read-file.js");
|
|
12
|
+
const warn_js_1 = require("./warn.js");
|
|
13
|
+
const noop = () => { };
|
|
14
|
+
// The number of bytes to read before the choice of a codec.
|
|
15
|
+
const headLength = (codecs) => Math.max(512, ...codecs.map(c => c.headLength));
|
|
16
|
+
exports.headLength = headLength;
|
|
17
|
+
const isTar = (head) => {
|
|
18
|
+
try {
|
|
19
|
+
const header = new header_js_1.Header(head);
|
|
20
|
+
return header.cksumValid || header.nullBlock;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const findCodec = (codecs, head, file = '') => codecs.find(c => c.detect(head)) ??
|
|
27
|
+
(isTar(head) ? undefined : (codecs.find(c => c.extensions?.some(x => file.endsWith(x)))));
|
|
28
|
+
exports.findCodec = findCodec;
|
|
29
|
+
const maxRatio = (opt) => typeof opt.maxDecompressionRatio === 'number' ?
|
|
30
|
+
opt.maxDecompressionRatio
|
|
31
|
+
: 1000;
|
|
32
|
+
const abort = (opt, er) => (0, warn_js_1.tarError)(opt, 'TAR_ABORT', er, { recoverable: false });
|
|
33
|
+
const ratioError = (opt, ratio, max) => abort(opt, new Error(`max decompression ratio exceeded: ${ratio.toFixed(2)} > ${max}`));
|
|
34
|
+
const notCurrent = () => new TypeError('The body of an entry cannot be read after a later entry');
|
|
35
|
+
/**
|
|
36
|
+
* Gets entries and the parts of their bodies from a `Parser`. The
|
|
37
|
+
* readers use it. It does not read input.
|
|
38
|
+
*/
|
|
39
|
+
class EntryCursor {
|
|
40
|
+
parser;
|
|
41
|
+
/** The entry that has a body to read now. */
|
|
42
|
+
current;
|
|
43
|
+
/** True after the end of the archive. */
|
|
44
|
+
ended = false;
|
|
45
|
+
constructor(parser) {
|
|
46
|
+
this.parser = parser;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The next entry that is not ignored. `null` at the end of the
|
|
50
|
+
* archive. `undefined` if the parser needs more input. The rest of
|
|
51
|
+
* the body of the entry before it is skipped.
|
|
52
|
+
*/
|
|
53
|
+
entry() {
|
|
54
|
+
this.current = undefined;
|
|
55
|
+
if (this.ended)
|
|
56
|
+
return null;
|
|
57
|
+
for (let ev; (ev = this.parser.next());) {
|
|
58
|
+
if (ev.type === 'end') {
|
|
59
|
+
this.ended = true;
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (ev.type === 'entry' && !ev.entry.ignore) {
|
|
63
|
+
return (this.current = ev.entry);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The next part of the body of `entry`. `null` at the end of the
|
|
69
|
+
* body. `undefined` if the parser needs more input.
|
|
70
|
+
*/
|
|
71
|
+
body(entry) {
|
|
72
|
+
if (entry !== this.current)
|
|
73
|
+
throw notCurrent();
|
|
74
|
+
const ev = this.parser.next();
|
|
75
|
+
if (!ev)
|
|
76
|
+
return undefined;
|
|
77
|
+
if (ev.type === 'body')
|
|
78
|
+
return ev.data;
|
|
79
|
+
this.current = undefined;
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.EntryCursor = EntryCursor;
|
|
84
|
+
// Skip the rest of a body that no consumer reads, if it is after the
|
|
85
|
+
// input that the parser has, and the source can skip it. The source
|
|
86
|
+
// must be the input of the reader: decompressed data has no place in
|
|
87
|
+
// the input.
|
|
88
|
+
const skipBody = (cursor, source) => {
|
|
89
|
+
if (cursor.current)
|
|
90
|
+
return;
|
|
91
|
+
const n = cursor.parser.bodyRemain;
|
|
92
|
+
if (n && source[read_file_js_1.SKIP]?.(n))
|
|
93
|
+
cursor.parser.skipBody();
|
|
94
|
+
};
|
|
95
|
+
const toSource = (input) => {
|
|
96
|
+
if ((0, bytes_js_1.isUint8Array)(input))
|
|
97
|
+
return [input].values();
|
|
98
|
+
if ((0, bytes_js_1.isArrayBuffer)(input))
|
|
99
|
+
return [new Uint8Array(input)].values();
|
|
100
|
+
if ((0, bytes_js_1.isBlob)(input))
|
|
101
|
+
input = input.stream();
|
|
102
|
+
if ((0, bytes_js_1.isReadableStream)(input)) {
|
|
103
|
+
const reader = input.getReader();
|
|
104
|
+
return { next: () => reader.read(), return: () => reader.cancel() };
|
|
105
|
+
}
|
|
106
|
+
return Symbol.asyncIterator in input ?
|
|
107
|
+
input[Symbol.asyncIterator]()
|
|
108
|
+
: input[Symbol.iterator]();
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Reads the entries of an archive from async input. It is the
|
|
112
|
+
* iterator that `entries()` returns.
|
|
113
|
+
*
|
|
114
|
+
* Input is read only when the consumer asks for the next entry or
|
|
115
|
+
* for more of a body. `poll()` and `fill()` do the same work as
|
|
116
|
+
* `next()`, with no promise for an entry that is in memory.
|
|
117
|
+
*/
|
|
118
|
+
class TarReader {
|
|
119
|
+
parser;
|
|
120
|
+
#cursor;
|
|
121
|
+
#opt;
|
|
122
|
+
#input;
|
|
123
|
+
#source;
|
|
124
|
+
// the first bytes of input that is not compressed
|
|
125
|
+
#head;
|
|
126
|
+
#filling;
|
|
127
|
+
#done = false;
|
|
128
|
+
constructor(input, opt = {}) {
|
|
129
|
+
opt = (0, options_js_1.ownOptions)(opt);
|
|
130
|
+
const win32 = opt.platform === 'win32';
|
|
131
|
+
this.parser = new parser_js_1.Parser(opt, (header, ex, gex) => new read_entry_js_1.ReadEntry(header, ex, gex, win32, this));
|
|
132
|
+
this.#cursor = new EntryCursor(this.parser);
|
|
133
|
+
this.#opt = opt;
|
|
134
|
+
this.#input = toSource(input);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The next entry, if it is in memory. `null` at the end of the
|
|
138
|
+
* archive. `undefined` if more input is needed: then await `fill()`
|
|
139
|
+
* and call this again.
|
|
140
|
+
*/
|
|
141
|
+
poll() {
|
|
142
|
+
return this.#done ? null : this.#cursor.entry();
|
|
143
|
+
}
|
|
144
|
+
readBody(entry) {
|
|
145
|
+
return this.#cursor.body(entry);
|
|
146
|
+
}
|
|
147
|
+
/** Read one chunk of input, and give it to the parser. */
|
|
148
|
+
fill() {
|
|
149
|
+
return (this.#filling ??= this.#fill());
|
|
150
|
+
}
|
|
151
|
+
async #fill() {
|
|
152
|
+
try {
|
|
153
|
+
const source = (this.#source ??= await this.#open(this.#input));
|
|
154
|
+
const head = this.#head;
|
|
155
|
+
this.#head = undefined;
|
|
156
|
+
if (source === this.#input)
|
|
157
|
+
skipBody(this.#cursor, source);
|
|
158
|
+
const res = head ? { value: head, done: false } : await source.next();
|
|
159
|
+
if (res.done)
|
|
160
|
+
this.parser.end();
|
|
161
|
+
else
|
|
162
|
+
this.parser.push(res.value);
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
this.#filling = undefined;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Read the first bytes, and add the decompression if they need it.
|
|
169
|
+
async #open(input) {
|
|
170
|
+
const opt = this.#opt;
|
|
171
|
+
const codecs = [...(opt.codecs ?? []), codec_js_1.gzip];
|
|
172
|
+
const need = (0, exports.headLength)(codecs);
|
|
173
|
+
let head;
|
|
174
|
+
while (!head || head.length < need) {
|
|
175
|
+
const res = await input.next();
|
|
176
|
+
if (res.done)
|
|
177
|
+
break;
|
|
178
|
+
head = head ? (0, concat_js_1.concat)([head, res.value]) : res.value;
|
|
179
|
+
}
|
|
180
|
+
const codec = head && (0, exports.findCodec)(codecs, head, opt.file);
|
|
181
|
+
if (!codec) {
|
|
182
|
+
this.#head = head;
|
|
183
|
+
return input;
|
|
184
|
+
}
|
|
185
|
+
let compressed = 0;
|
|
186
|
+
let decompressed = 0;
|
|
187
|
+
const { readable, writable } = codec.decompress();
|
|
188
|
+
const writer = writable.getWriter();
|
|
189
|
+
const reader = readable.getReader();
|
|
190
|
+
let stopped = false;
|
|
191
|
+
// Give the input to the codec, as fast as the codec takes it. This
|
|
192
|
+
// loop holds each promise of the writer, so that a write that
|
|
193
|
+
// fails after the consumer stops is not an unhandled rejection.
|
|
194
|
+
const feed = async () => {
|
|
195
|
+
try {
|
|
196
|
+
for (;;) {
|
|
197
|
+
await writer.ready;
|
|
198
|
+
if (stopped)
|
|
199
|
+
return;
|
|
200
|
+
const res = head ? { value: head, done: false } : await input.next();
|
|
201
|
+
head = undefined;
|
|
202
|
+
if (stopped)
|
|
203
|
+
return;
|
|
204
|
+
if (res.done)
|
|
205
|
+
return await writer.close();
|
|
206
|
+
compressed += res.value.length;
|
|
207
|
+
await writer.write(res.value);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch (er) {
|
|
211
|
+
// An error of the input goes to the reader of the output. An
|
|
212
|
+
// error of the codec is there already.
|
|
213
|
+
if (!stopped)
|
|
214
|
+
await writer.abort(er).catch(noop);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
void feed();
|
|
218
|
+
const max = maxRatio(opt);
|
|
219
|
+
return {
|
|
220
|
+
next: async () => {
|
|
221
|
+
const res = await reader.read().catch(er => {
|
|
222
|
+
throw abort(opt, er);
|
|
223
|
+
});
|
|
224
|
+
if (!res.done) {
|
|
225
|
+
decompressed += res.value.length;
|
|
226
|
+
const ratio = decompressed / compressed;
|
|
227
|
+
if (ratio > max)
|
|
228
|
+
throw ratioError(opt, ratio, max);
|
|
229
|
+
}
|
|
230
|
+
return res;
|
|
231
|
+
},
|
|
232
|
+
return: async () => {
|
|
233
|
+
stopped = true;
|
|
234
|
+
await reader.cancel().catch(noop);
|
|
235
|
+
await writer.abort().catch(noop);
|
|
236
|
+
await input.return?.();
|
|
237
|
+
return { value: undefined, done: true };
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
async next() {
|
|
242
|
+
try {
|
|
243
|
+
for (;;) {
|
|
244
|
+
const entry = this.poll();
|
|
245
|
+
if (entry)
|
|
246
|
+
return { value: entry, done: false };
|
|
247
|
+
if (entry === null)
|
|
248
|
+
break;
|
|
249
|
+
await this.fill();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
catch (er) {
|
|
253
|
+
await this.return();
|
|
254
|
+
throw er;
|
|
255
|
+
}
|
|
256
|
+
return this.return();
|
|
257
|
+
}
|
|
258
|
+
/** Stop reading, and release the input. */
|
|
259
|
+
async return() {
|
|
260
|
+
if (!this.#done) {
|
|
261
|
+
this.#done = true;
|
|
262
|
+
this.#cursor.current = undefined;
|
|
263
|
+
await (this.#source ?? this.#input).return?.();
|
|
264
|
+
}
|
|
265
|
+
return { value: undefined, done: true };
|
|
266
|
+
}
|
|
267
|
+
[Symbol.asyncIterator]() {
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
exports.TarReader = TarReader;
|
|
272
|
+
/**
|
|
273
|
+
* Reads the entries of an archive from sync input. It is the
|
|
274
|
+
* iterator that `entriesSync()` returns.
|
|
275
|
+
*/
|
|
276
|
+
class TarReaderSync {
|
|
277
|
+
parser;
|
|
278
|
+
#cursor;
|
|
279
|
+
#opt;
|
|
280
|
+
#input;
|
|
281
|
+
#source;
|
|
282
|
+
// the first bytes of input that is not compressed
|
|
283
|
+
#head;
|
|
284
|
+
#done = false;
|
|
285
|
+
constructor(input, opt = {}) {
|
|
286
|
+
opt = (0, options_js_1.ownOptions)(opt);
|
|
287
|
+
const win32 = opt.platform === 'win32';
|
|
288
|
+
this.parser = new parser_js_1.Parser(opt, (header, ex, gex) => new read_entry_js_1.ReadEntrySync(header, ex, gex, win32, this));
|
|
289
|
+
this.#cursor = new EntryCursor(this.parser);
|
|
290
|
+
this.#opt = opt;
|
|
291
|
+
this.#input =
|
|
292
|
+
(0, bytes_js_1.isUint8Array)(input) ? [input].values()
|
|
293
|
+
: (0, bytes_js_1.isArrayBuffer)(input) ? [new Uint8Array(input)].values()
|
|
294
|
+
: input[Symbol.iterator]();
|
|
295
|
+
}
|
|
296
|
+
readBody(entry) {
|
|
297
|
+
for (;;) {
|
|
298
|
+
const part = this.#cursor.body(entry);
|
|
299
|
+
if (part !== undefined)
|
|
300
|
+
return part;
|
|
301
|
+
this.#fill();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
#fill() {
|
|
305
|
+
const source = (this.#source ??= this.#open(this.#input));
|
|
306
|
+
const head = this.#head;
|
|
307
|
+
this.#head = undefined;
|
|
308
|
+
if (source === this.#input)
|
|
309
|
+
skipBody(this.#cursor, source);
|
|
310
|
+
const res = head ? { value: head, done: false } : source.next();
|
|
311
|
+
if (res.done)
|
|
312
|
+
this.parser.end();
|
|
313
|
+
else
|
|
314
|
+
this.parser.push(res.value);
|
|
315
|
+
}
|
|
316
|
+
// Read the first bytes. If they are compressed, read and decompress
|
|
317
|
+
// all the input.
|
|
318
|
+
#open(input) {
|
|
319
|
+
const opt = this.#opt;
|
|
320
|
+
const codecs = [...(opt.codecs ?? []), codec_js_1.gzip];
|
|
321
|
+
const need = (0, exports.headLength)(codecs);
|
|
322
|
+
let head;
|
|
323
|
+
let res;
|
|
324
|
+
while ((!head || head.length < need) && !(res = input.next()).done) {
|
|
325
|
+
head = head ? (0, concat_js_1.concat)([head, res.value]) : res.value;
|
|
326
|
+
}
|
|
327
|
+
const codec = head && (0, exports.findCodec)(codecs, head, opt.file);
|
|
328
|
+
if (!head || !codec) {
|
|
329
|
+
this.#head = head;
|
|
330
|
+
return input;
|
|
331
|
+
}
|
|
332
|
+
const { decompressSync } = codec;
|
|
333
|
+
if (!decompressSync) {
|
|
334
|
+
throw abort(opt, new Error(`the ${codec.name} codec has no decompressSync function`));
|
|
335
|
+
}
|
|
336
|
+
const parts = [head];
|
|
337
|
+
while (!(res = input.next()).done)
|
|
338
|
+
parts.push(res.value);
|
|
339
|
+
const data = (0, concat_js_1.concat)(parts);
|
|
340
|
+
const max = maxRatio(opt);
|
|
341
|
+
let out;
|
|
342
|
+
try {
|
|
343
|
+
out = decompressSync(data, { maxOutputLength: data.length * max });
|
|
344
|
+
}
|
|
345
|
+
catch (er) {
|
|
346
|
+
throw abort(opt, er);
|
|
347
|
+
}
|
|
348
|
+
const ratio = out.length / data.length;
|
|
349
|
+
if (ratio > max)
|
|
350
|
+
throw ratioError(opt, ratio, max);
|
|
351
|
+
return [out].values();
|
|
352
|
+
}
|
|
353
|
+
next() {
|
|
354
|
+
try {
|
|
355
|
+
for (;;) {
|
|
356
|
+
const entry = this.#done ? null : this.#cursor.entry();
|
|
357
|
+
if (entry)
|
|
358
|
+
return { value: entry, done: false };
|
|
359
|
+
if (entry === null)
|
|
360
|
+
break;
|
|
361
|
+
this.#fill();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
catch (er) {
|
|
365
|
+
this.return();
|
|
366
|
+
throw er;
|
|
367
|
+
}
|
|
368
|
+
return this.return();
|
|
369
|
+
}
|
|
370
|
+
/** Stop reading, and release the input. */
|
|
371
|
+
return() {
|
|
372
|
+
if (!this.#done) {
|
|
373
|
+
this.#done = true;
|
|
374
|
+
this.#cursor.current = undefined;
|
|
375
|
+
(this.#source ?? this.#input).return?.();
|
|
376
|
+
}
|
|
377
|
+
return { value: undefined, done: true };
|
|
378
|
+
}
|
|
379
|
+
[Symbol.iterator]() {
|
|
380
|
+
return this;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
exports.TarReaderSync = TarReaderSync;
|
|
384
|
+
/**
|
|
385
|
+
* Read the entries of an archive. Gzip input is decompressed.
|
|
386
|
+
*
|
|
387
|
+
* Read the body of an entry before the next entry: when the iterator
|
|
388
|
+
* moves on, the rest of the body is skipped.
|
|
389
|
+
*/
|
|
390
|
+
const entries = (input, opt) => new TarReader(input, opt);
|
|
391
|
+
exports.entries = entries;
|
|
392
|
+
/**
|
|
393
|
+
* Read the entries of an archive with no promises. Compressed input
|
|
394
|
+
* needs a codec with a `decompressSync` function in `opt.codecs`.
|
|
395
|
+
*/
|
|
396
|
+
const entriesSync = (input, opt) => new TarReaderSync(input, opt);
|
|
397
|
+
exports.entriesSync = entriesSync;
|
|
398
|
+
//# sourceMappingURL=entries.js.map
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type WithAliases } from './dealias.js';
|
|
2
|
+
import type { ExtractOptions, ExtractOptionsSync } from './options.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extract the entries of an archive into the directory `opt.cwd`.
|
|
5
|
+
* If `files` is set, only the entries that it lists, and the entries
|
|
6
|
+
* in the directories that it lists.
|
|
7
|
+
*
|
|
8
|
+
* A problem with one entry is a warning for `opt.onwarn`, and the
|
|
9
|
+
* extraction continues. A listed path that no entry matches is a
|
|
10
|
+
* warning when the archive ends. With `opt.strict`, each is an error.
|
|
11
|
+
*/
|
|
12
|
+
export declare const extract: (options: WithAliases<ExtractOptions>, files?: string[]) => Promise<void>;
|
|
13
|
+
/** The sync form of `extract`. */
|
|
14
|
+
export declare const extractSync: (options: WithAliases<ExtractOptionsSync>, files?: string[]) => void;
|
|
3
15
|
//# sourceMappingURL=extract.d.ts.map
|