@unbrained/pm-cli 2026.12.1 → 2026.12.3
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/commander-usage.js +4 -4
- package/dist/cli/expected-revisions.js +1 -1
- package/dist/cli/extension-command-help.js +4 -4
- package/dist/cli/main.js +5 -5
- package/dist/cli/runtime/invocation-rewrites.js +1 -1
- package/dist/cli/runtime-field-commands.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3ESBFEQC.js +2 -0
- package/dist/cli-bundle/chunks/chunk-46AZP5QW.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-OBPO6V7H.js → chunk-5WTBF4M4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3KEMIPKG.js → chunk-6TOZQ5BQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YYFY33T.js → chunk-AHVOEE7F.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-CQHB3ZZH.js +2 -0
- package/dist/cli-bundle/chunks/chunk-DZPOS3YT.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-OKEJ4U2I.js → chunk-E5ADC3HT.js} +65 -65
- package/dist/cli-bundle/chunks/{chunk-SY5C3U32.js → chunk-E5HO7HWP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3HKPVOAN.js → chunk-EDJ3KR2H.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XME6GIFQ.js → chunk-FWQNWPIV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CWPR234D.js → chunk-H4U3LEOD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MZZ4ZJ5Z.js → chunk-HNMED75Y.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-U7RBJGLF.js → chunk-HPCMM74Q.js} +22 -22
- package/dist/cli-bundle/chunks/{chunk-WSEIEDEK.js → chunk-ITM4AMVM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q6K7HWZ7.js → chunk-IW4A3I4N.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YQMQOUO.js → chunk-JJ73G5UT.js} +52 -52
- package/dist/cli-bundle/chunks/chunk-L4HMFRHB.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-YSVOXCYH.js → chunk-LTQWPQ7H.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q6GLSAJY.js → chunk-MRT3ADO4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZL6J6JYT.js → chunk-PBMLIV74.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NA6D75V5.js → chunk-PJMGWJKU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-Q2HMDV56.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-OXC5KBIQ.js → chunk-RRBNCL63.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CBUC4X7Q.js → chunk-TDOF7BKO.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-UXEZXGAD.js +113 -0
- package/dist/cli-bundle/chunks/{chunk-PCDTWL6V.js → chunk-W7HA65EO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-I4SPJQQI.js → chunk-XGNUDSCG.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-AHV3CSQG.js → chunk-XKJ5NWQ7.js} +2 -2
- package/dist/cli-bundle/chunks/{field-option-collisions-BBGTV7AD.js → field-option-collisions-DXKTKW6J.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-DXEF4XBU.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-EANA7V4W.js +2 -0
- package/dist/cli-bundle/chunks/{linked-resource-value-list-E2DX52LY.js → linked-resource-value-list-5JRGUDUB.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-actor-NHN33ITJ.js → mutation-actor-S5G7FMNG.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-PGKJTCG6.js → mutation-admission-HQVNPOXV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-7S5QWDTI.js → register-list-query-SQF5PSJ4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-2F6JUBST.js → register-mutation-4AQ4CEBL.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-ET3UKPYK.js → register-operations-76P7OM4P.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-I63QTFCU.js → register-setup-T6OEOZK3.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-4ZCF74G4.js → stage-KUICZHSF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-4SCFAWAW.js → chunk-3LHBKFPD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-4DDXERKN.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-JPZGC3W4.js → chunk-4YU75CWI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TXTPAFHJ.js → chunk-5JQVPQMN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KNBGHCIP.js → chunk-5Z4DXYBZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7DOP5HEZ.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TR22GU7M.js → chunk-AX4RBJ7B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7A6SEZEY.js → chunk-BEHQCHQV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-BUIF6CMZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-E2IWEJL5.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-GBU7GKNJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-EQCQTYKO.js → chunk-K35KTBDZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VQIC3UZB.js → chunk-KNST4PGF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-P2H3GTJK.js → chunk-L2XJB5PK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-L6NOGC4N.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-VK3IE3TS.js → chunk-LWIIDPAV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6IY5CVGJ.js → chunk-M54BMYG4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6BKT6XQN.js → chunk-NEK7RX3N.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BHNBPCHP.js → chunk-OKGWIW6C.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2DGKVXFT.js → chunk-RFDSSOTZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SSX5YBDC.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OG57ESZK.js → chunk-TIEQVIFN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SQ72CVUH.js → chunk-VEUBDQDP.js} +54 -54
- package/dist/cli-bundle/focused-chunks/{chunk-2UWKU2BQ.js → chunk-WDHNPNHX.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-2C6DLUC4.js → field-option-collisions-32X7FP3H.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-GUYSVVQD.js +2 -0
- package/dist/cli-bundle/focused-chunks/{item-transaction-2K4SFLJ7.js → item-transaction-MLKHZPL7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-DJMZUIZI.js → mutation-actor-RDZJTRW2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-SDWQVVHN.js → mutation-admission-IQB6XL75.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-QBZIK3T5.js → stage-AA7LORZ2.js} +2 -2
- package/dist/cli-bundle/main.js +27 -27
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +63 -63
- package/dist/cli-bundle/sdk-query.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 +9 -9
- package/dist/core/extensions/loader.d.ts +8 -0
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/item/actionability.js +1 -1
- package/dist/core/output/output.js +16 -16
- package/dist/mcp/server.js +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +25 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/extension/install-sources.d.ts +2 -2
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/lifecycle/expect-hash-admission.d.ts +27 -8
- package/dist/sdk/lifecycle/expect-hash-admission.js +1 -1
- package/dist/sdk/lifecycle/item-revision.d.ts +12 -4
- package/dist/sdk/lifecycle/item-revision.js +1 -1
- package/dist/sdk/output-projection.d.ts +1 -1
- package/dist/sdk/output-projection.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output/surfaces.js +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/runtime-input.d.ts +6 -0
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.js +1 -1
- package/docs/COMMANDS.md +23 -5
- package/docs/EXTENSIONS.md +1 -1
- package/docs/SDK.md +15 -2
- 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-A5ZEMOVR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-AJLU6KLW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-C6WM6ZN4.js +0 -9
- package/dist/cli-bundle/chunks/chunk-HZZLSBIJ.js +0 -2
- package/dist/cli-bundle/chunks/chunk-L2ZSSMYY.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NRQCBUYD.js +0 -113
- package/dist/cli-bundle/chunks/chunk-QDV7S2QS.js +0 -2
- package/dist/cli-bundle/chunks/item-revision-3LENTXYF.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-66RDV7PH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HTDYNY4L.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-N64AC5G6.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-PT7RT3T6.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-QZRYGYTI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-SQMOF65W.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-T3ILWAEV.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-W4JMV7GF.js +0 -3
- package/dist/cli-bundle/focused-chunks/item-revision-723XCQPS.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
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// the PEND/UNPEND stuff tracks whether we're ready to emit end/close yet.
|
|
3
|
-
// but the path reservations are required to avoid race conditions where
|
|
4
|
-
// parallelized unpack ops may mess with one another, due to dependencies
|
|
5
|
-
// (like a Link depending on its target) or destructive operations (like
|
|
6
|
-
// clobbering an fs object to create one of a different type.)
|
|
7
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
3
|
if (k2 === undefined) k2 = k;
|
|
9
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -37,376 +32,336 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
37
32
|
return result;
|
|
38
33
|
};
|
|
39
34
|
})();
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.UnpackSync = exports.Unpack = void 0;
|
|
45
|
-
const
|
|
46
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
47
|
-
const node_crypto_1 = require("node:crypto");
|
|
48
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
49
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
50
|
-
const get_write_flag_js_1 = require("./get-write-flag.js");
|
|
51
|
-
const mkdir_js_1 = require("./mkdir.js");
|
|
52
|
-
const normalize_windows_path_js_1 = require("./normalize-windows-path.js");
|
|
53
|
-
const parse_js_1 = require("./parse.js");
|
|
54
|
-
const strip_absolute_path_js_1 = require("./strip-absolute-path.js");
|
|
36
|
+
exports.UnpackSync = exports.Unpack = exports.UnpackBase = void 0;
|
|
37
|
+
const symlink_error_js_1 = require("./symlink-error.js");
|
|
55
38
|
const wc = __importStar(require("./winchars.js"));
|
|
39
|
+
const entries_js_1 = require("./entries.js");
|
|
40
|
+
const mkdir_js_1 = require("./mkdir.js");
|
|
41
|
+
const options_js_1 = require("./options.js");
|
|
56
42
|
const path_reservations_js_1 = require("./path-reservations.js");
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const ISREUSABLE = Symbol('isReusable');
|
|
63
|
-
const MAKEFS = Symbol('makeFs');
|
|
64
|
-
const FILE = Symbol('file');
|
|
65
|
-
const DIRECTORY = Symbol('directory');
|
|
66
|
-
const LINK = Symbol('link');
|
|
67
|
-
const SYMLINK = Symbol('symlink');
|
|
68
|
-
const HARDLINK = Symbol('hardlink');
|
|
69
|
-
const ENSURE_NO_SYMLINK = Symbol('ensureNoSymlink');
|
|
70
|
-
const UNSUPPORTED = Symbol('unsupported');
|
|
71
|
-
const CHECKPATH = Symbol('checkPath');
|
|
72
|
-
const STRIPABSOLUTEPATH = Symbol('stripAbsolutePath');
|
|
73
|
-
const MKDIR = Symbol('mkdir');
|
|
74
|
-
const ONERROR = Symbol('onError');
|
|
75
|
-
const PENDING = Symbol('pending');
|
|
76
|
-
const PEND = Symbol('pend');
|
|
77
|
-
const UNPEND = Symbol('unpend');
|
|
78
|
-
const ENDED = Symbol('ended');
|
|
79
|
-
const MAYBECLOSE = Symbol('maybeClose');
|
|
80
|
-
const SKIP = Symbol('skip');
|
|
81
|
-
const DOCHOWN = Symbol('doChown');
|
|
82
|
-
const UID = Symbol('uid');
|
|
83
|
-
const GID = Symbol('gid');
|
|
84
|
-
const CHECKED_CWD = Symbol('checkedCwd');
|
|
85
|
-
const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
86
|
-
const isWindows = platform === 'win32';
|
|
43
|
+
const path_js_1 = require("./path.js");
|
|
44
|
+
const strip_absolute_path_js_1 = require("./strip-absolute-path.js");
|
|
45
|
+
const warn_js_1 = require("./warn.js");
|
|
46
|
+
const win32_path_js_1 = require("./win32-path.js");
|
|
47
|
+
const write_flag_js_1 = require("./write-flag.js");
|
|
87
48
|
const DEFAULT_MAX_DEPTH = 1024;
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
// See: https://github.com/npm/node-tar/issues/183
|
|
103
|
-
/* c8 ignore start */
|
|
104
|
-
const unlinkFile = (path, cb) => {
|
|
105
|
-
if (!isWindows) {
|
|
106
|
-
return node_fs_1.default.unlink(path, cb);
|
|
107
|
-
}
|
|
108
|
-
const name = path + '.DELETE.' + (0, node_crypto_1.randomBytes)(16).toString('hex');
|
|
109
|
-
node_fs_1.default.rename(path, name, er => {
|
|
110
|
-
if (er) {
|
|
111
|
-
return cb(er);
|
|
112
|
-
}
|
|
113
|
-
node_fs_1.default.unlink(name, cb);
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
/* c8 ignore stop */
|
|
117
|
-
/* c8 ignore start */
|
|
118
|
-
const unlinkFileSync = (path) => {
|
|
119
|
-
if (!isWindows) {
|
|
120
|
-
return node_fs_1.default.unlinkSync(path);
|
|
121
|
-
}
|
|
122
|
-
const name = path + '.DELETE.' + (0, node_crypto_1.randomBytes)(16).toString('hex');
|
|
123
|
-
node_fs_1.default.renameSync(path, name);
|
|
124
|
-
node_fs_1.default.unlinkSync(name);
|
|
125
|
-
};
|
|
126
|
-
/* c8 ignore stop */
|
|
127
|
-
// this.gid, entry.gid, this.processUid
|
|
128
|
-
const uint32 = (a, b, c) => a !== undefined && a === a >>> 0 ? a
|
|
49
|
+
// Longer than any path that a supported platform can create.
|
|
50
|
+
const MAX_PATH_LENGTH = 32768;
|
|
51
|
+
const DEFAULT_JOBS = 16;
|
|
52
|
+
const fileTypes = new Set([
|
|
53
|
+
'File',
|
|
54
|
+
'OldFile',
|
|
55
|
+
'ContiguousFile',
|
|
56
|
+
]);
|
|
57
|
+
const dirTypes = new Set(['Directory', 'GNUDumpDir']);
|
|
58
|
+
const linkTypes = new Set(['Link', 'SymbolicLink']);
|
|
59
|
+
// The first of the values that is an unsigned 32-bit integer, or the
|
|
60
|
+
// last value.
|
|
61
|
+
const uint32 = (a, b, c) => a !== undefined ? a
|
|
129
62
|
: b !== undefined && b === b >>> 0 ? b
|
|
130
63
|
: c;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The parts of the extraction that do not use the file system: the
|
|
66
|
+
* options, the checks of each entry, and the warnings. `Unpack` and
|
|
67
|
+
* `UnpackSync` add the file system work.
|
|
68
|
+
*/
|
|
69
|
+
class UnpackBase {
|
|
70
|
+
/** The options, with no prototype. */
|
|
71
|
+
opt;
|
|
72
|
+
/** The absolute path of the extraction directory. */
|
|
73
|
+
cwd;
|
|
74
|
+
win32;
|
|
75
|
+
strip;
|
|
76
|
+
maxDepth;
|
|
77
|
+
preservePaths;
|
|
78
|
+
unlink;
|
|
79
|
+
keep;
|
|
80
|
+
newer;
|
|
81
|
+
noMtime;
|
|
82
|
+
chmod;
|
|
139
83
|
uid;
|
|
140
84
|
gid;
|
|
141
|
-
setOwner;
|
|
142
85
|
preserveOwner;
|
|
143
|
-
processGid;
|
|
144
|
-
processUid;
|
|
145
|
-
maxDepth;
|
|
146
86
|
forceChown;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
keep;
|
|
150
|
-
noMtime;
|
|
151
|
-
preservePaths;
|
|
152
|
-
unlink;
|
|
153
|
-
cwd;
|
|
154
|
-
strip;
|
|
87
|
+
processUid;
|
|
88
|
+
processGid;
|
|
155
89
|
processUmask;
|
|
156
90
|
umask;
|
|
157
91
|
dmode;
|
|
158
92
|
fmode;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
93
|
+
/** Gives the `open` flag for a new file of a given size. */
|
|
94
|
+
writeFlag;
|
|
95
|
+
/** Resolve a path from an absolute path. */
|
|
96
|
+
resolve;
|
|
97
|
+
/** The parent directory of an absolute path. */
|
|
98
|
+
dirname;
|
|
99
|
+
/** Set when an error stops the extraction. */
|
|
100
|
+
fatal;
|
|
101
|
+
constructor(options) {
|
|
102
|
+
const opt = (this.opt = (0, options_js_1.ownOptions)(options));
|
|
103
|
+
const win32 = (this.win32 = opt.platform === 'win32');
|
|
104
|
+
this.resolve = win32 ? win32_path_js_1.win32Resolve : path_js_1.resolve;
|
|
105
|
+
this.dirname = win32 ? win32_path_js_1.win32Dirname : path_js_1.dirname;
|
|
106
|
+
if (typeof opt.cwd !== 'string') {
|
|
107
|
+
throw new TypeError('cwd is required');
|
|
108
|
+
}
|
|
109
|
+
const cwd = win32 ? opt.cwd.replaceAll('\\', '/') : opt.cwd;
|
|
110
|
+
if (!(win32 ? win32_path_js_1.win32IsAbsolute : path_js_1.isAbsolute)(cwd)) {
|
|
111
|
+
throw new TypeError('cwd must be an absolute path');
|
|
112
|
+
}
|
|
113
|
+
this.cwd = this.resolve(cwd, '');
|
|
168
114
|
if (typeof opt.uid === 'number' || typeof opt.gid === 'number') {
|
|
169
115
|
// need both or neither
|
|
170
116
|
if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number') {
|
|
171
117
|
throw new TypeError('cannot set owner without number uid and gid');
|
|
172
118
|
}
|
|
119
|
+
// A value that is not valid must not fall back to the owner
|
|
120
|
+
// in the archive.
|
|
121
|
+
if (opt.uid !== opt.uid >>> 0 || opt.gid !== opt.gid >>> 0) {
|
|
122
|
+
throw new TypeError('uid and gid must be unsigned 32-bit integers');
|
|
123
|
+
}
|
|
173
124
|
if (opt.preserveOwner) {
|
|
174
125
|
throw new TypeError('cannot preserve owner in archive and also set owner explicitly');
|
|
175
126
|
}
|
|
176
127
|
this.uid = opt.uid;
|
|
177
128
|
this.gid = opt.gid;
|
|
178
|
-
this.setOwner = true;
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
this.uid = undefined;
|
|
182
|
-
this.gid = undefined;
|
|
183
|
-
this.setOwner = false;
|
|
184
129
|
}
|
|
185
|
-
|
|
130
|
+
this.processUid = opt.processUid;
|
|
131
|
+
this.processGid = opt.processGid;
|
|
186
132
|
this.preserveOwner =
|
|
187
133
|
opt.preserveOwner === undefined && typeof opt.uid !== 'number' ?
|
|
188
|
-
|
|
134
|
+
opt.processUid === 0
|
|
189
135
|
: !!opt.preserveOwner;
|
|
190
|
-
this.
|
|
191
|
-
(this.preserveOwner || this.setOwner) && process.getuid ?
|
|
192
|
-
process.getuid()
|
|
193
|
-
: undefined;
|
|
194
|
-
this.processGid =
|
|
195
|
-
(this.preserveOwner || this.setOwner) && process.getgid ?
|
|
196
|
-
process.getgid()
|
|
197
|
-
: undefined;
|
|
198
|
-
// prevent excessively deep nesting of subfolders
|
|
199
|
-
// set to `Infinity` to remove this restriction
|
|
136
|
+
this.forceChown = opt.forceChown === true;
|
|
200
137
|
this.maxDepth =
|
|
201
138
|
typeof opt.maxDepth === 'number' ? opt.maxDepth : DEFAULT_MAX_DEPTH;
|
|
202
|
-
|
|
203
|
-
// Forcibly trigger a chown on every entry, no matter what
|
|
204
|
-
this.forceChown = opt.forceChown === true;
|
|
205
|
-
// turn ><?| in filenames into 0xf000-higher encoded forms
|
|
206
|
-
this.win32 = !!opt.win32 || isWindows;
|
|
207
|
-
// do not unpack over files that are newer than what's in the archive
|
|
208
|
-
this.newer = !!opt.newer;
|
|
209
|
-
// do not unpack over ANY files
|
|
210
|
-
this.keep = !!opt.keep;
|
|
211
|
-
// do not set mtime/atime of extracted entries
|
|
212
|
-
this.noMtime = !!opt.noMtime;
|
|
213
|
-
// allow .., absolute path entries, and unpacking through symlinks
|
|
214
|
-
// without this, warn and skip .., relativize absolutes, and error
|
|
215
|
-
// on symlinks in extraction path
|
|
139
|
+
this.strip = Number(opt.strip) || 0;
|
|
216
140
|
this.preservePaths = !!opt.preservePaths;
|
|
217
|
-
// unlink files and links before writing. This breaks existing hard
|
|
218
|
-
// links, and removes symlink directories rather than erroring
|
|
219
141
|
this.unlink = !!opt.unlink;
|
|
220
|
-
this.
|
|
221
|
-
this.
|
|
222
|
-
|
|
142
|
+
this.keep = !!opt.keep;
|
|
143
|
+
this.newer = !!opt.newer;
|
|
144
|
+
this.noMtime = !!opt.noMtime;
|
|
145
|
+
this.chmod = !!opt.chmod;
|
|
146
|
+
// Without chmod, the umask of the process is not needed.
|
|
223
147
|
this.processUmask =
|
|
224
148
|
!this.chmod ? 0
|
|
225
149
|
: typeof opt.processUmask === 'number' ? opt.processUmask
|
|
226
|
-
:
|
|
150
|
+
: 0o22;
|
|
227
151
|
this.umask =
|
|
228
152
|
typeof opt.umask === 'number' ? opt.umask : this.processUmask;
|
|
229
|
-
|
|
230
|
-
this.
|
|
231
|
-
this.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
153
|
+
this.dmode = opt.dmode || 0o777 & ~this.umask;
|
|
154
|
+
this.fmode = opt.fmode || 0o666 & ~this.umask;
|
|
155
|
+
this.writeFlag = (0, write_flag_js_1.writeFlags)(opt.fs.constants, win32);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Report a problem to `onwarn`, or throw it if `strict` is set. A
|
|
159
|
+
* damaged archive is always an error here, because the extraction
|
|
160
|
+
* cannot be complete.
|
|
161
|
+
*/
|
|
162
|
+
warn(code, message, data = {}) {
|
|
238
163
|
if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT') {
|
|
239
164
|
data.recoverable = false;
|
|
240
165
|
}
|
|
241
|
-
|
|
166
|
+
data.cwd = this.cwd;
|
|
167
|
+
(0, warn_js_1.warn)(this.opt, code, message, data);
|
|
242
168
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
this.
|
|
248
|
-
}
|
|
169
|
+
/** The options for the reader. Its warnings go to `warn()`. */
|
|
170
|
+
readerOptions() {
|
|
171
|
+
return (0, options_js_1.ownOptions)(this.opt, {
|
|
172
|
+
strict: false,
|
|
173
|
+
onwarn: (code, message, data) => this.warn(code, message, data),
|
|
174
|
+
});
|
|
249
175
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Report the failure of one entry as a `TAR_ENTRY_ERROR` warning.
|
|
178
|
+
* Throws the error if it stops the extraction: the extraction
|
|
179
|
+
* directory is not usable, the archive cannot be read, or `strict`
|
|
180
|
+
* is set.
|
|
181
|
+
*/
|
|
182
|
+
entryError(er, entry) {
|
|
183
|
+
if (this.fatal?.error === er || er?.name === 'CwdError') {
|
|
184
|
+
throw er;
|
|
185
|
+
}
|
|
186
|
+
this.warn('TAR_ENTRY_ERROR', er, { entry });
|
|
187
|
+
}
|
|
188
|
+
/** Record the error that stops the extraction. Returns it. */
|
|
189
|
+
fail(error) {
|
|
190
|
+
this.fatal ??= { error };
|
|
191
|
+
return error;
|
|
192
|
+
}
|
|
193
|
+
// Remove the root of an absolute path, and refuse a path that can
|
|
194
|
+
// leave the extraction directory. False if the entry is refused.
|
|
195
|
+
#stripAbsolutePath(entry, field) {
|
|
253
196
|
const p = entry[field];
|
|
254
|
-
const { type } = entry;
|
|
255
197
|
if (!p || this.preservePaths)
|
|
256
198
|
return true;
|
|
257
|
-
// strip off the root
|
|
258
199
|
const [root, stripped] = (0, strip_absolute_path_js_1.stripAbsolutePath)(p);
|
|
259
|
-
const parts = stripped.replaceAll(
|
|
260
|
-
if (parts.includes('..')
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
//
|
|
264
|
-
|
|
265
|
-
// '../sibling/file' are valid if they resolve within the cwd.
|
|
266
|
-
// For paths, they just simply may not ever use .. at all.
|
|
267
|
-
if (field === 'path' || type === 'Link') {
|
|
200
|
+
const parts = stripped.replaceAll('\\', '/').split('/');
|
|
201
|
+
if (parts.includes('..')) {
|
|
202
|
+
// A path, and the target of a hard link, cannot have '..' at
|
|
203
|
+
// all. The target of a symbolic link is relative to the
|
|
204
|
+
// directory of the link, so '../sibling/file' can be valid.
|
|
205
|
+
if (field === 'path' || entry.type === 'Link') {
|
|
268
206
|
this.warn('TAR_ENTRY_ERROR', `${field} contains '..'`, {
|
|
269
207
|
entry,
|
|
270
208
|
[field]: p,
|
|
271
209
|
});
|
|
272
|
-
// not ok!
|
|
273
210
|
return false;
|
|
274
211
|
}
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
212
|
+
// A '..' is only safe at the start of the target. Any named
|
|
213
|
+
// part before it can be a symlink, and then the '..' goes to
|
|
214
|
+
// the parent of the target of that symlink.
|
|
215
|
+
const firstName = parts.findIndex(part => part !== '..' && part !== '.' && part !== '');
|
|
216
|
+
if (firstName !== -1 && parts.includes('..', firstName)) {
|
|
217
|
+
this.warn('TAR_ENTRY_ERROR', `${field} contains '..' after a path portion`, { entry, [field]: p });
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
// Normalize the path, so that the directory is the one where
|
|
221
|
+
// the link is created. The path 'x/.' creates the link 'x'.
|
|
222
|
+
const entryDir = (0, path_js_1.dirname)((0, path_js_1.normalize)(entry.path));
|
|
223
|
+
const resolved = (0, path_js_1.normalize)((0, path_js_1.join)(entryDir, parts.join('/')));
|
|
281
224
|
if (resolved.startsWith('../') || resolved === '..') {
|
|
282
|
-
this.warn('TAR_ENTRY_ERROR', `${field} escapes extraction directory`, {
|
|
283
|
-
entry,
|
|
284
|
-
[field]: p,
|
|
285
|
-
});
|
|
225
|
+
this.warn('TAR_ENTRY_ERROR', `${field} escapes extraction directory`, { entry, [field]: p });
|
|
286
226
|
return false;
|
|
287
227
|
}
|
|
288
228
|
}
|
|
289
229
|
if (root) {
|
|
290
|
-
|
|
291
|
-
entry[field] =
|
|
292
|
-
this.warn('TAR_ENTRY_INFO', `stripping ${root} from absolute ${field}`, {
|
|
293
|
-
entry,
|
|
294
|
-
[field]: p,
|
|
295
|
-
});
|
|
230
|
+
;
|
|
231
|
+
entry[field] = stripped;
|
|
232
|
+
this.warn('TAR_ENTRY_INFO', `stripping ${root} from absolute ${field}`, { entry, [field]: p });
|
|
296
233
|
}
|
|
297
234
|
return true;
|
|
298
235
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Check the entry, with no use of the file system. Set its
|
|
238
|
+
* `absolute` path, and change its `path`, `linkpath`, and `mode` to
|
|
239
|
+
* the values to extract. False if the entry must not be extracted.
|
|
240
|
+
*/
|
|
241
|
+
check(entry) {
|
|
242
|
+
const p = entry.path;
|
|
302
243
|
const parts = p.split('/');
|
|
303
244
|
if (this.strip) {
|
|
304
|
-
if (parts.length < this.strip)
|
|
245
|
+
if (parts.length < this.strip)
|
|
305
246
|
return false;
|
|
306
|
-
}
|
|
307
247
|
if (entry.type === 'Link') {
|
|
308
|
-
const linkparts =
|
|
309
|
-
if (linkparts.length
|
|
310
|
-
entry.linkpath = linkparts.slice(this.strip).join('/');
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
248
|
+
const linkparts = String(entry.linkpath).split('/');
|
|
249
|
+
if (linkparts.length < this.strip)
|
|
313
250
|
return false;
|
|
314
|
-
|
|
251
|
+
entry.linkpath = linkparts.slice(this.strip).join('/');
|
|
315
252
|
}
|
|
316
253
|
parts.splice(0, this.strip);
|
|
254
|
+
// No part of the path is left, as for the top directory of a
|
|
255
|
+
// package. The entry must not change the extraction directory.
|
|
256
|
+
if (parts.every(part => part === ''))
|
|
257
|
+
return false;
|
|
317
258
|
entry.path = parts.join('/');
|
|
318
259
|
}
|
|
319
|
-
|
|
260
|
+
const { maxDepth } = this;
|
|
261
|
+
if (isFinite(maxDepth) && parts.length > maxDepth) {
|
|
320
262
|
this.warn('TAR_ENTRY_ERROR', 'path excessively deep', {
|
|
321
263
|
entry,
|
|
322
264
|
path: p,
|
|
323
265
|
depth: parts.length,
|
|
324
|
-
maxDepth
|
|
266
|
+
maxDepth,
|
|
267
|
+
});
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
// The path reservations do work for each parent directory of the
|
|
271
|
+
// path and of the linkpath.
|
|
272
|
+
const { linkpath } = entry;
|
|
273
|
+
if (linkpath &&
|
|
274
|
+
isFinite(maxDepth) &&
|
|
275
|
+
linkpath.split('/').length > maxDepth) {
|
|
276
|
+
this.warn('TAR_ENTRY_ERROR', 'linkpath excessively deep', {
|
|
277
|
+
entry,
|
|
278
|
+
path: p,
|
|
279
|
+
linkpath,
|
|
280
|
+
maxDepth,
|
|
325
281
|
});
|
|
326
282
|
return false;
|
|
327
283
|
}
|
|
328
|
-
|
|
329
|
-
|
|
284
|
+
for (const field of ['path', 'linkpath']) {
|
|
285
|
+
const { length } = entry[field] ?? '';
|
|
286
|
+
if (length > MAX_PATH_LENGTH) {
|
|
287
|
+
this.warn('TAR_ENTRY_ERROR', `${field} excessively long`, {
|
|
288
|
+
entry,
|
|
289
|
+
path: p,
|
|
290
|
+
length,
|
|
291
|
+
maxLength: MAX_PATH_LENGTH,
|
|
292
|
+
});
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (!this.#stripAbsolutePath(entry, 'path') ||
|
|
297
|
+
!this.#stripAbsolutePath(entry, 'linkpath')) {
|
|
330
298
|
return false;
|
|
331
299
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
// if we somehow ended up with a path that escapes the cwd, and we are
|
|
337
|
-
// not in preservePaths mode, then something is fishy! This should have
|
|
338
|
-
// been prevented above, so ignore this for coverage.
|
|
339
|
-
/* c8 ignore start - defense in depth */
|
|
300
|
+
const { cwd } = this;
|
|
301
|
+
let absolute = this.resolve(cwd, entry.path);
|
|
302
|
+
// The checks above refuse a path that leaves the extraction
|
|
303
|
+
// directory. This check is defense in depth.
|
|
340
304
|
if (!this.preservePaths &&
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
305
|
+
absolute !== cwd &&
|
|
306
|
+
// A root, such as `/` or `c:/`, ends with a slash.
|
|
307
|
+
!absolute.startsWith(cwd.endsWith('/') ? cwd : cwd + '/')) {
|
|
344
308
|
this.warn('TAR_ENTRY_ERROR', 'path escaped extraction target', {
|
|
345
309
|
entry,
|
|
346
|
-
path:
|
|
347
|
-
resolvedPath:
|
|
348
|
-
cwd
|
|
310
|
+
path: entry.path,
|
|
311
|
+
resolvedPath: absolute,
|
|
312
|
+
cwd,
|
|
349
313
|
});
|
|
350
314
|
return false;
|
|
351
315
|
}
|
|
352
|
-
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
if (entry.absolute === this.cwd &&
|
|
356
|
-
entry.type !== 'Directory' &&
|
|
357
|
-
entry.type !== 'GNUDumpDir') {
|
|
316
|
+
// An archive can set properties of the extraction directory, but
|
|
317
|
+
// it cannot replace it with a different kind of thing.
|
|
318
|
+
if (absolute === cwd && !dirTypes.has(entry.type))
|
|
358
319
|
return false;
|
|
359
|
-
|
|
360
|
-
// only encode : chars that aren't drive letter indicators
|
|
320
|
+
// Do not change the ':' of a drive letter.
|
|
361
321
|
if (this.win32) {
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const { root: pRoot } = node_path_1.default.win32.parse(entry.path);
|
|
322
|
+
const aRoot = (0, win32_path_js_1.win32Root)(absolute);
|
|
323
|
+
absolute = aRoot + wc.encode(absolute.slice(aRoot.length));
|
|
324
|
+
const pRoot = (0, win32_path_js_1.win32Root)(entry.path);
|
|
366
325
|
entry.path = pRoot + wc.encode(entry.path.slice(pRoot.length));
|
|
367
326
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
// eslint-disable-next-line no-fallthrough
|
|
382
|
-
case 'File':
|
|
383
|
-
case 'OldFile':
|
|
384
|
-
case 'ContiguousFile':
|
|
385
|
-
case 'Link':
|
|
386
|
-
case 'SymbolicLink':
|
|
387
|
-
return this[CHECKFS](entry);
|
|
388
|
-
case 'CharacterDevice':
|
|
389
|
-
case 'BlockDevice':
|
|
390
|
-
case 'FIFO':
|
|
391
|
-
default:
|
|
392
|
-
return this[UNSUPPORTED](entry);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
[ONERROR](er, entry) {
|
|
396
|
-
// Cwd has to exist, or else nothing works. That's serious.
|
|
397
|
-
// Other errors are warnings, which raise the error in strict
|
|
398
|
-
// mode, but otherwise continue on.
|
|
399
|
-
if (er.name === 'CwdError') {
|
|
400
|
-
this.emit('error', er);
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
this.warn('TAR_ENTRY_ERROR', er, { entry });
|
|
404
|
-
this[UNPEND]();
|
|
405
|
-
entry.resume();
|
|
327
|
+
entry.absolute = absolute;
|
|
328
|
+
// Never set the setuid, setgid, or sticky bit from an archive.
|
|
329
|
+
if (typeof entry.mode === 'number')
|
|
330
|
+
entry.mode &= 0o777;
|
|
331
|
+
if (dirTypes.has(entry.type)) {
|
|
332
|
+
if (entry.mode)
|
|
333
|
+
entry.mode |= 0o700;
|
|
334
|
+
}
|
|
335
|
+
else if (!fileTypes.has(entry.type) && !linkTypes.has(entry.type)) {
|
|
336
|
+
// A device or a FIFO is never made.
|
|
337
|
+
entry.unsupported = true;
|
|
338
|
+
this.warn('TAR_ENTRY_UNSUPPORTED', `unsupported entry type: ${entry.type}`, { entry });
|
|
339
|
+
return false;
|
|
406
340
|
}
|
|
341
|
+
return true;
|
|
407
342
|
}
|
|
408
|
-
|
|
409
|
-
|
|
343
|
+
/**
|
|
344
|
+
* The paths that the entry must have for itself while it is made.
|
|
345
|
+
* A link also reserves its target, so that an entry that makes the
|
|
346
|
+
* target, and an entry that goes through the link, do not run at
|
|
347
|
+
* the same time as the link.
|
|
348
|
+
*/
|
|
349
|
+
reservedPaths(entry) {
|
|
350
|
+
const { path, linkpath } = entry;
|
|
351
|
+
if (!linkpath)
|
|
352
|
+
return [path];
|
|
353
|
+
// The target of a symlink is relative to the directory of the
|
|
354
|
+
// link. The target of a hard link is relative to the cwd.
|
|
355
|
+
return [
|
|
356
|
+
path,
|
|
357
|
+
entry.type === 'SymbolicLink' && !(0, path_js_1.isAbsolute)(linkpath) ?
|
|
358
|
+
(0, path_js_1.join)((0, path_js_1.dirname)(path), linkpath)
|
|
359
|
+
: linkpath,
|
|
360
|
+
];
|
|
361
|
+
}
|
|
362
|
+
/** The options to make a directory with a mode. */
|
|
363
|
+
mkdirOptions(mode) {
|
|
364
|
+
return {
|
|
410
365
|
uid: this.uid,
|
|
411
366
|
gid: this.gid,
|
|
412
367
|
processUid: this.processUid,
|
|
@@ -415,517 +370,617 @@ class Unpack extends parse_js_1.Parser {
|
|
|
415
370
|
preserve: this.preservePaths,
|
|
416
371
|
unlink: this.unlink,
|
|
417
372
|
cwd: this.cwd,
|
|
418
|
-
mode
|
|
419
|
-
}
|
|
373
|
+
mode,
|
|
374
|
+
};
|
|
420
375
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
376
|
+
/**
|
|
377
|
+
* The owner to set on the entry, if it needs one: with
|
|
378
|
+
* `preserveOwner`, when the owner in the archive is not the process
|
|
379
|
+
* owner, and with `uid` and `gid`, when they are not the process
|
|
380
|
+
* owner.
|
|
381
|
+
*/
|
|
382
|
+
owner(entry) {
|
|
383
|
+
const doChown = this.forceChown ||
|
|
425
384
|
(this.preserveOwner &&
|
|
426
385
|
((typeof entry.uid === 'number' &&
|
|
427
386
|
entry.uid !== this.processUid) ||
|
|
428
387
|
(typeof entry.gid === 'number' &&
|
|
429
388
|
entry.gid !== this.processGid))) ||
|
|
430
389
|
(typeof this.uid === 'number' && this.uid !== this.processUid) ||
|
|
431
|
-
(typeof this.gid === 'number' && this.gid !== this.processGid)
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
return
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
390
|
+
(typeof this.gid === 'number' && this.gid !== this.processGid);
|
|
391
|
+
const uid = uint32(this.uid, entry.uid, this.processUid);
|
|
392
|
+
const gid = uint32(this.gid, entry.gid, this.processGid);
|
|
393
|
+
return doChown && typeof uid === 'number' && typeof gid === 'number' ?
|
|
394
|
+
{ uid, gid }
|
|
395
|
+
: undefined;
|
|
396
|
+
}
|
|
397
|
+
/** The times to set on the entry, if it needs them. */
|
|
398
|
+
times(entry) {
|
|
399
|
+
return entry.mtime && !this.noMtime ?
|
|
400
|
+
{ atime: entry.atime || new Date(), mtime: entry.mtime }
|
|
401
|
+
: undefined;
|
|
402
|
+
}
|
|
403
|
+
/** True if the object on disk at the path of the entry must stay. */
|
|
404
|
+
skip(entry, st) {
|
|
405
|
+
return (this.keep || (this.newer && st.mtime > (entry.mtime ?? st.mtime)));
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* True if the entry can be written into the file that is on disk.
|
|
409
|
+
* A file with more than one link is not used, because the write
|
|
410
|
+
* would change the other links. Windows does not report a useful
|
|
411
|
+
* link count.
|
|
412
|
+
*/
|
|
413
|
+
isReusable(entry, st) {
|
|
414
|
+
return (entry.type === 'File' &&
|
|
415
|
+
!this.unlink &&
|
|
416
|
+
st.isFile() &&
|
|
417
|
+
st.nlink <= 1 &&
|
|
418
|
+
!this.win32);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* The parts of the path from the extraction directory to the
|
|
422
|
+
* target of a link entry. None of them can be a symbolic link.
|
|
423
|
+
*/
|
|
424
|
+
linkParts(entry, absolute) {
|
|
425
|
+
const linkpath = String(entry.linkpath);
|
|
426
|
+
return entry.type === 'Link' ?
|
|
427
|
+
linkpath.split('/')
|
|
428
|
+
: (0, path_js_1.relative)(this.cwd, this.resolve(this.dirname(absolute), linkpath)).split('/');
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* The parts of the path from the extraction directory to the
|
|
432
|
+
* parent directory of an entry. The extraction checks them again
|
|
433
|
+
* after it makes the entry: none of them can be a symbolic link
|
|
434
|
+
* then. So a directory that another process replaced with a
|
|
435
|
+
* symbolic link during the extraction is an error of the entry.
|
|
436
|
+
*/
|
|
437
|
+
parentParts(absolute) {
|
|
438
|
+
const { cwd } = this;
|
|
439
|
+
const parent = absolute === cwd ? cwd : this.dirname(absolute);
|
|
440
|
+
return parent === cwd ? [] : (0, path_js_1.relative)(cwd, parent).split('/');
|
|
441
|
+
}
|
|
442
|
+
/** The error for a link target that goes through a symbolic link. */
|
|
443
|
+
symlinkError(symlink, parts) {
|
|
444
|
+
return new symlink_error_js_1.SymlinkError(symlink, this.resolve(this.cwd, parts.join('/')));
|
|
438
445
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
446
|
+
}
|
|
447
|
+
exports.UnpackBase = UnpackBase;
|
|
448
|
+
// Unlinks on Windows are not atomic. A file that is made at the path
|
|
449
|
+
// of a file that was just removed can be removed with it. So rename
|
|
450
|
+
// the file first, and then remove it under the new name.
|
|
451
|
+
const deleteName = (path) => path +
|
|
452
|
+
'.DELETE.' +
|
|
453
|
+
Array.from(crypto.getRandomValues(new Uint8Array(16)), b => b.toString(16).padStart(2, '0')).join('');
|
|
454
|
+
/**
|
|
455
|
+
* Extracts the entries of an archive with async file system
|
|
456
|
+
* functions.
|
|
457
|
+
*
|
|
458
|
+
* Several entries are extracted at one time. Entries that use the
|
|
459
|
+
* same path, or a path and a directory above it, are extracted in
|
|
460
|
+
* the order of the archive.
|
|
461
|
+
*/
|
|
462
|
+
class Unpack extends UnpackBase {
|
|
463
|
+
#fs;
|
|
464
|
+
#reservations;
|
|
465
|
+
#jobs;
|
|
466
|
+
// the number of entries that are in work
|
|
467
|
+
#active = 0;
|
|
468
|
+
#wake;
|
|
469
|
+
#checkedCwd = false;
|
|
470
|
+
#cwdCheck;
|
|
471
|
+
constructor(opt) {
|
|
472
|
+
super(opt);
|
|
473
|
+
this.#fs = this.opt.fs;
|
|
474
|
+
this.#reservations = new path_reservations_js_1.PathReservations(this.win32);
|
|
475
|
+
this.#jobs = (0, options_js_1.countOption)('jobs', this.opt.jobs, DEFAULT_JOBS);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Extract the archive. The promise settles when all the file
|
|
479
|
+
* system work is done. It rejects with the first error that stops
|
|
480
|
+
* the extraction.
|
|
481
|
+
*/
|
|
482
|
+
async extract(input) {
|
|
483
|
+
const reader = new entries_js_1.TarReader(input, this.readerOptions());
|
|
484
|
+
const { onEntry } = this.opt;
|
|
485
|
+
const stream = !!this.opt.transform;
|
|
486
|
+
try {
|
|
487
|
+
while (!this.fatal) {
|
|
488
|
+
const entry = reader.poll();
|
|
489
|
+
if (entry === null)
|
|
490
|
+
break;
|
|
491
|
+
if (entry === undefined) {
|
|
492
|
+
await reader.fill();
|
|
493
|
+
continue;
|
|
464
494
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
495
|
+
if (onEntry)
|
|
496
|
+
await onEntry(entry);
|
|
497
|
+
// The caller took the content, so there is nothing to write.
|
|
498
|
+
if (entry.bodyUsed)
|
|
499
|
+
continue;
|
|
500
|
+
if (!this.check(entry))
|
|
501
|
+
continue;
|
|
502
|
+
// A file whose content is all in memory is written while the
|
|
503
|
+
// next entries are read. Other files are written as their
|
|
504
|
+
// content arrives.
|
|
505
|
+
const body = [];
|
|
506
|
+
let inMemory = !stream;
|
|
507
|
+
if (inMemory && fileTypes.has(entry.type)) {
|
|
508
|
+
for (;;) {
|
|
509
|
+
const part = reader.readBody(entry);
|
|
510
|
+
if (part === null)
|
|
511
|
+
break;
|
|
512
|
+
if (part === undefined) {
|
|
513
|
+
inMemory = false;
|
|
514
|
+
break;
|
|
475
515
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
fullyDone();
|
|
480
|
-
});
|
|
516
|
+
body.push(part);
|
|
517
|
+
}
|
|
481
518
|
}
|
|
519
|
+
const work = this.#start(entry, body, inMemory ? undefined : reader);
|
|
520
|
+
if (!inMemory)
|
|
521
|
+
await work;
|
|
522
|
+
while (this.#active >= this.#jobs)
|
|
523
|
+
await this.#idle();
|
|
482
524
|
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
node_fs_1.default.futimes(fd, atime, mtime, er => er ?
|
|
495
|
-
node_fs_1.default.utimes(abs, atime, mtime, er2 => done(er2 && er))
|
|
496
|
-
: done());
|
|
497
|
-
}
|
|
498
|
-
if (typeof fd === 'number' && this[DOCHOWN](entry)) {
|
|
499
|
-
actions++;
|
|
500
|
-
const uid = this[UID](entry);
|
|
501
|
-
const gid = this[GID](entry);
|
|
502
|
-
if (typeof uid === 'number' && typeof gid === 'number') {
|
|
503
|
-
node_fs_1.default.fchown(fd, uid, gid, er => er ? node_fs_1.default.chown(abs, uid, gid, er2 => done(er2 && er)) : done());
|
|
504
|
-
}
|
|
525
|
+
}
|
|
526
|
+
catch (er) {
|
|
527
|
+
this.fail(er);
|
|
528
|
+
}
|
|
529
|
+
await reader.return().catch(er => this.fail(er));
|
|
530
|
+
while (this.#active > 0)
|
|
531
|
+
await this.#idle();
|
|
532
|
+
if (this.fatal) {
|
|
533
|
+
const { error } = this.fatal;
|
|
534
|
+
if (error && typeof error === 'object' && 'tarCode' in error) {
|
|
535
|
+
Object.assign(error, { cwd: this.cwd });
|
|
505
536
|
}
|
|
506
|
-
|
|
507
|
-
});
|
|
508
|
-
const tx = this.transform ? this.transform(entry) || entry : entry;
|
|
509
|
-
if (tx !== entry) {
|
|
510
|
-
tx.on('error', er => {
|
|
511
|
-
this[ONERROR](er, entry);
|
|
512
|
-
fullyDone();
|
|
513
|
-
});
|
|
514
|
-
entry.pipe(tx);
|
|
537
|
+
throw error;
|
|
515
538
|
}
|
|
516
|
-
tx.pipe(stream);
|
|
517
539
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
540
|
+
// Resolves when an entry that is in work is done.
|
|
541
|
+
#idle() {
|
|
542
|
+
return new Promise(res => {
|
|
543
|
+
this.#wake = res;
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
// Extract the entry when its paths are free. The promise never
|
|
547
|
+
// rejects: a failure is a warning, or it sets `fatal`.
|
|
548
|
+
#start(entry, body, reader) {
|
|
549
|
+
this.#active++;
|
|
550
|
+
return this.#reservations.reserve(this.reservedPaths(entry), async () => {
|
|
551
|
+
try {
|
|
552
|
+
if (!this.fatal)
|
|
553
|
+
await this.#extract(entry, body, reader);
|
|
525
554
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
555
|
+
catch (er) {
|
|
556
|
+
try {
|
|
557
|
+
this.entryError(er, entry);
|
|
558
|
+
}
|
|
559
|
+
catch (fatal) {
|
|
560
|
+
this.fail(fatal);
|
|
532
561
|
}
|
|
533
|
-
};
|
|
534
|
-
if (entry.mtime && !this.noMtime) {
|
|
535
|
-
actions++;
|
|
536
|
-
node_fs_1.default.utimes(String(entry.absolute), entry.atime || new Date(), entry.mtime, done);
|
|
537
|
-
}
|
|
538
|
-
if (this[DOCHOWN](entry)) {
|
|
539
|
-
actions++;
|
|
540
|
-
node_fs_1.default.chown(String(entry.absolute), Number(this[UID](entry)), Number(this[GID](entry)), done);
|
|
541
562
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
[UNSUPPORTED](entry) {
|
|
546
|
-
entry.unsupported = true;
|
|
547
|
-
this.warn('TAR_ENTRY_UNSUPPORTED', `unsupported entry type: ${entry.type}`, { entry });
|
|
548
|
-
entry.resume();
|
|
549
|
-
}
|
|
550
|
-
[SYMLINK](entry, done) {
|
|
551
|
-
const parts = (0, normalize_windows_path_js_1.normalizeWindowsPath)(node_path_1.default.relative(this.cwd, node_path_1.default.resolve(node_path_1.default.dirname(String(entry.absolute)), String(entry.linkpath)))).split('/');
|
|
552
|
-
this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, String(entry.linkpath), 'symlink', done), er => {
|
|
553
|
-
this[ONERROR](er, entry);
|
|
554
|
-
done();
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
[HARDLINK](entry, done) {
|
|
558
|
-
const linkpath = (0, normalize_windows_path_js_1.normalizeWindowsPath)(node_path_1.default.resolve(this.cwd, String(entry.linkpath)));
|
|
559
|
-
const parts = (0, normalize_windows_path_js_1.normalizeWindowsPath)(String(entry.linkpath)).split('/');
|
|
560
|
-
this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, linkpath, 'link', done), er => {
|
|
561
|
-
this[ONERROR](er, entry);
|
|
562
|
-
done();
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
[ENSURE_NO_SYMLINK](entry, cwd, parts, done, onError) {
|
|
566
|
-
const p = parts.shift();
|
|
567
|
-
if (this.preservePaths || p === undefined)
|
|
568
|
-
return done();
|
|
569
|
-
const t = node_path_1.default.resolve(cwd, p);
|
|
570
|
-
node_fs_1.default.lstat(t, (er, st) => {
|
|
571
|
-
if (er)
|
|
572
|
-
return done();
|
|
573
|
-
if (st?.isSymbolicLink()) {
|
|
574
|
-
return onError(new symlink_error_js_1.SymlinkError(t, node_path_1.default.resolve(t, parts.join('/'))));
|
|
575
|
-
}
|
|
576
|
-
this[ENSURE_NO_SYMLINK](entry, t, parts, done, onError);
|
|
563
|
+
this.#active--;
|
|
564
|
+
this.#wake?.();
|
|
577
565
|
});
|
|
578
566
|
}
|
|
579
|
-
|
|
580
|
-
this
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
567
|
+
#mkdir(dir, mode) {
|
|
568
|
+
return (0, mkdir_js_1.mkdir)(this.#fs, dir, this.mkdirOptions(mode));
|
|
569
|
+
}
|
|
570
|
+
// The extraction directory must exist. Entries that start at the
|
|
571
|
+
// same time share one check.
|
|
572
|
+
#checkCwd() {
|
|
573
|
+
return (this.#cwdCheck ??= this.#mkdir(this.cwd, this.dmode).then(() => {
|
|
574
|
+
this.#checkedCwd = true;
|
|
575
|
+
}, er => {
|
|
576
|
+
this.#cwdCheck = undefined;
|
|
577
|
+
throw er;
|
|
578
|
+
}));
|
|
579
|
+
}
|
|
580
|
+
async #extract(entry, body, reader) {
|
|
581
|
+
const fs = this.#fs;
|
|
582
|
+
const absolute = entry.absolute;
|
|
583
|
+
const { cwd } = this;
|
|
584
|
+
if (!this.#checkedCwd)
|
|
585
|
+
await this.#checkCwd();
|
|
586
|
+
if (absolute !== cwd) {
|
|
587
|
+
const parent = this.dirname(absolute);
|
|
588
|
+
if (parent !== cwd)
|
|
589
|
+
await this.#mkdir(parent, this.dmode);
|
|
590
|
+
}
|
|
591
|
+
// Remove what is at the path, if the entry cannot use it.
|
|
592
|
+
const st = await fs.lstat(absolute).catch(() => undefined);
|
|
593
|
+
if (st && this.skip(entry, st))
|
|
594
|
+
return;
|
|
595
|
+
if (st && !this.isReusable(entry, st)) {
|
|
596
|
+
if (st.isDirectory() && dirTypes.has(entry.type)) {
|
|
597
|
+
if (this.chmod &&
|
|
598
|
+
entry.mode &&
|
|
599
|
+
(st.mode & 0o7777) !== entry.mode) {
|
|
600
|
+
await fs.chmod(absolute, entry.mode);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
else if (absolute !== cwd) {
|
|
604
|
+
if (st.isDirectory())
|
|
605
|
+
await fs.rmdir(absolute);
|
|
606
|
+
else
|
|
607
|
+
await this.#unlink(absolute);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
if (fileTypes.has(entry.type)) {
|
|
611
|
+
return this.#file(entry, absolute, body, reader);
|
|
612
|
+
}
|
|
613
|
+
if (dirTypes.has(entry.type))
|
|
614
|
+
await this.#directory(entry, absolute);
|
|
615
|
+
else {
|
|
616
|
+
await this.#ensureNoSymlink(this.linkParts(entry, absolute));
|
|
617
|
+
const linkpath = String(entry.linkpath);
|
|
618
|
+
if (entry.type === 'Link') {
|
|
619
|
+
await fs.link(this.resolve(cwd, linkpath), absolute);
|
|
620
|
+
}
|
|
621
|
+
else {
|
|
622
|
+
await fs.symlink(linkpath, absolute);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
await this.#ensureNoSymlink(this.parentParts(absolute));
|
|
585
626
|
}
|
|
586
|
-
|
|
587
|
-
this
|
|
588
|
-
|
|
627
|
+
async #unlink(path) {
|
|
628
|
+
const fs = this.#fs;
|
|
629
|
+
if (!this.win32)
|
|
630
|
+
return fs.unlink(path);
|
|
631
|
+
const name = deleteName(path);
|
|
632
|
+
await fs.rename(path, name);
|
|
633
|
+
await fs.unlink(name);
|
|
589
634
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
st.
|
|
597
|
-
st
|
|
598
|
-
|
|
635
|
+
async #ensureNoSymlink(parts) {
|
|
636
|
+
if (this.preservePaths)
|
|
637
|
+
return;
|
|
638
|
+
let t = this.cwd;
|
|
639
|
+
for (const p of parts) {
|
|
640
|
+
t = this.resolve(t, p);
|
|
641
|
+
const st = await this.#fs.lstat(t).catch(() => undefined);
|
|
642
|
+
if (!st)
|
|
643
|
+
return;
|
|
644
|
+
if (st.isSymbolicLink())
|
|
645
|
+
throw this.symlinkError(t, parts);
|
|
646
|
+
}
|
|
599
647
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
this
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
648
|
+
async #directory(entry, absolute) {
|
|
649
|
+
const fs = this.#fs;
|
|
650
|
+
await this.#mkdir(absolute, entry.mode ?? this.dmode);
|
|
651
|
+
// These do not follow a symbolic link that replaced the
|
|
652
|
+
// directory. A failure is not an error of the entry.
|
|
653
|
+
const times = this.times(entry);
|
|
654
|
+
if (times) {
|
|
655
|
+
await fs.lutimes(absolute, times.atime, times.mtime).catch(() => { });
|
|
656
|
+
}
|
|
657
|
+
const owner = this.owner(entry);
|
|
658
|
+
if (owner) {
|
|
659
|
+
await fs.lchown(absolute, owner.uid, owner.gid).catch(() => { });
|
|
606
660
|
}
|
|
607
|
-
this.reservations.reserve(paths, done => this[CHECKFS2](entry, done));
|
|
608
661
|
}
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
662
|
+
async #file(entry, absolute, body, reader) {
|
|
663
|
+
const fs = this.#fs;
|
|
664
|
+
const handle = await fs.open(absolute, this.writeFlag(entry.size), entry.mode ?? this.fmode);
|
|
665
|
+
try {
|
|
666
|
+
// The file is open. Write to it only if no parent directory
|
|
667
|
+
// became a symbolic link before the open.
|
|
668
|
+
await this.#ensureNoSymlink(this.parentParts(absolute));
|
|
669
|
+
if (reader)
|
|
670
|
+
await this.#pipe(entry, body, reader, handle);
|
|
671
|
+
else
|
|
672
|
+
for (const part of body)
|
|
673
|
+
await handle.write(part);
|
|
674
|
+
// Use the open file, so that a symbolic link that replaced the
|
|
675
|
+
// path is not followed. If that fails, use the path.
|
|
676
|
+
const times = this.times(entry);
|
|
677
|
+
if (times) {
|
|
678
|
+
const { atime, mtime } = times;
|
|
679
|
+
await handle.utimes(atime, mtime).catch(async (er) => {
|
|
680
|
+
await fs.utimes(absolute, atime, mtime).catch(() => {
|
|
681
|
+
throw er;
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
const owner = this.owner(entry);
|
|
686
|
+
if (owner) {
|
|
687
|
+
const { uid, gid } = owner;
|
|
688
|
+
await handle.chown(uid, gid).catch(async (er) => {
|
|
689
|
+
await fs.chown(absolute, uid, gid).catch(() => {
|
|
690
|
+
throw er;
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
catch (er) {
|
|
696
|
+
await handle.close().catch(() => { });
|
|
697
|
+
throw er;
|
|
698
|
+
}
|
|
699
|
+
await handle.close();
|
|
700
|
+
}
|
|
701
|
+
// Write the content of the entry as it arrives, through the
|
|
702
|
+
// transform stream if there is one.
|
|
703
|
+
async #pipe(entry, body, reader, handle) {
|
|
704
|
+
let i = 0;
|
|
705
|
+
const next = async () => {
|
|
706
|
+
if (i < body.length)
|
|
707
|
+
return body[i++];
|
|
708
|
+
try {
|
|
709
|
+
for (;;) {
|
|
710
|
+
const part = reader.readBody(entry);
|
|
711
|
+
if (part !== undefined)
|
|
712
|
+
return part;
|
|
713
|
+
await reader.fill();
|
|
619
714
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
715
|
+
}
|
|
716
|
+
catch (er) {
|
|
717
|
+
// The archive cannot be read.
|
|
718
|
+
throw this.fail(er);
|
|
719
|
+
}
|
|
623
720
|
};
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
721
|
+
const tx = this.opt.transform?.(entry);
|
|
722
|
+
if (!tx) {
|
|
723
|
+
// Write one part while the next part is read.
|
|
724
|
+
let writing;
|
|
725
|
+
let failed;
|
|
726
|
+
try {
|
|
727
|
+
for (let part; (part = await next());) {
|
|
728
|
+
await writing;
|
|
729
|
+
if (failed)
|
|
730
|
+
break;
|
|
731
|
+
writing = handle.write(part).then(() => { }, error => {
|
|
732
|
+
failed = { error };
|
|
635
733
|
});
|
|
636
734
|
}
|
|
637
735
|
}
|
|
638
|
-
|
|
736
|
+
finally {
|
|
737
|
+
await writing;
|
|
738
|
+
}
|
|
739
|
+
if (failed)
|
|
740
|
+
throw failed.error;
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const writer = tx.writable.getWriter();
|
|
744
|
+
const out = tx.readable.getReader();
|
|
745
|
+
let failed;
|
|
746
|
+
// Stop the two streams. A read that waits gets the end of the
|
|
747
|
+
// stream, and a write that waits fails.
|
|
748
|
+
const stop = async (error) => {
|
|
749
|
+
failed ??= { error };
|
|
750
|
+
await out.cancel(error).catch(() => { });
|
|
751
|
+
await writer.abort(error).catch(() => { });
|
|
639
752
|
};
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
(
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
}
|
|
653
|
-
if (
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
753
|
+
const feed = (async () => {
|
|
754
|
+
try {
|
|
755
|
+
for (let part; (part = await next());)
|
|
756
|
+
await writer.write(part);
|
|
757
|
+
await writer.close();
|
|
758
|
+
}
|
|
759
|
+
catch (er) {
|
|
760
|
+
await stop(er);
|
|
761
|
+
}
|
|
762
|
+
})();
|
|
763
|
+
try {
|
|
764
|
+
for (;;) {
|
|
765
|
+
const { done, value } = await out.read();
|
|
766
|
+
if (done)
|
|
767
|
+
break;
|
|
768
|
+
await handle.write(value);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
catch (er) {
|
|
772
|
+
await stop(er);
|
|
773
|
+
}
|
|
774
|
+
// The feed reads the archive, so it must end before the next
|
|
775
|
+
// entry is read.
|
|
776
|
+
await feed;
|
|
777
|
+
if (failed)
|
|
778
|
+
throw failed.error;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
exports.Unpack = Unpack;
|
|
782
|
+
/**
|
|
783
|
+
* Extracts the entries of an archive with sync file system
|
|
784
|
+
* functions, one entry at a time.
|
|
785
|
+
*/
|
|
786
|
+
class UnpackSync extends UnpackBase {
|
|
787
|
+
#fs;
|
|
788
|
+
#checkedCwd = false;
|
|
789
|
+
constructor(opt) {
|
|
790
|
+
super(opt);
|
|
791
|
+
this.#fs = this.opt.fs;
|
|
792
|
+
}
|
|
793
|
+
/** Extract the archive. Throws the first error that stops it. */
|
|
794
|
+
extract(input) {
|
|
795
|
+
const reader = new entries_js_1.TarReaderSync(input, this.readerOptions());
|
|
796
|
+
const { onEntry } = this.opt;
|
|
797
|
+
try {
|
|
798
|
+
for (const entry of reader) {
|
|
799
|
+
onEntry?.(entry);
|
|
800
|
+
if (entry.bodyUsed)
|
|
801
|
+
continue;
|
|
802
|
+
if (!this.check(entry))
|
|
803
|
+
continue;
|
|
804
|
+
try {
|
|
805
|
+
this.#extract(entry, reader);
|
|
672
806
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (entry.absolute === this.cwd) {
|
|
676
|
-
return this[MAKEFS](null, entry, done);
|
|
807
|
+
catch (er) {
|
|
808
|
+
this.entryError(er, entry);
|
|
677
809
|
}
|
|
678
|
-
|
|
679
|
-
});
|
|
680
|
-
};
|
|
681
|
-
if (this[CHECKED_CWD]) {
|
|
682
|
-
start();
|
|
810
|
+
}
|
|
683
811
|
}
|
|
684
|
-
|
|
685
|
-
|
|
812
|
+
catch (error) {
|
|
813
|
+
if (error && typeof error === 'object' && 'tarCode' in error) {
|
|
814
|
+
Object.assign(error, { cwd: this.cwd });
|
|
815
|
+
}
|
|
816
|
+
throw error;
|
|
686
817
|
}
|
|
687
818
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
819
|
+
#mkdir(dir, mode) {
|
|
820
|
+
(0, mkdir_js_1.mkdirSync)(this.#fs, dir, this.mkdirOptions(mode));
|
|
821
|
+
}
|
|
822
|
+
#extract(entry, reader) {
|
|
823
|
+
const fs = this.#fs;
|
|
824
|
+
const absolute = entry.absolute;
|
|
825
|
+
const { cwd } = this;
|
|
826
|
+
if (!this.#checkedCwd) {
|
|
827
|
+
this.#mkdir(cwd, this.dmode);
|
|
828
|
+
this.#checkedCwd = true;
|
|
829
|
+
}
|
|
830
|
+
if (absolute !== cwd) {
|
|
831
|
+
const parent = this.dirname(absolute);
|
|
832
|
+
if (parent !== cwd)
|
|
833
|
+
this.#mkdir(parent, this.dmode);
|
|
834
|
+
}
|
|
835
|
+
// Remove what is at the path, if the entry cannot use it.
|
|
836
|
+
let st;
|
|
837
|
+
try {
|
|
838
|
+
st = fs.lstatSync(absolute);
|
|
839
|
+
}
|
|
840
|
+
catch { }
|
|
841
|
+
if (st && this.skip(entry, st))
|
|
692
842
|
return;
|
|
843
|
+
if (st && !this.isReusable(entry, st)) {
|
|
844
|
+
if (st.isDirectory() && dirTypes.has(entry.type)) {
|
|
845
|
+
if (this.chmod &&
|
|
846
|
+
entry.mode &&
|
|
847
|
+
(st.mode & 0o7777) !== entry.mode) {
|
|
848
|
+
fs.chmodSync(absolute, entry.mode);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
else if (absolute !== cwd) {
|
|
852
|
+
if (st.isDirectory())
|
|
853
|
+
fs.rmdirSync(absolute);
|
|
854
|
+
else
|
|
855
|
+
this.#unlink(absolute);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
if (fileTypes.has(entry.type)) {
|
|
859
|
+
return this.#file(entry, absolute, reader);
|
|
693
860
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
case 'SymbolicLink':
|
|
702
|
-
return this[SYMLINK](entry, done);
|
|
703
|
-
case 'Directory':
|
|
704
|
-
case 'GNUDumpDir':
|
|
705
|
-
return this[DIRECTORY](entry, done);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
[LINK](entry, linkpath, link, done) {
|
|
709
|
-
node_fs_1.default[link](linkpath, String(entry.absolute), er => {
|
|
710
|
-
if (er) {
|
|
711
|
-
this[ONERROR](er, entry);
|
|
861
|
+
if (dirTypes.has(entry.type))
|
|
862
|
+
this.#directory(entry, absolute);
|
|
863
|
+
else {
|
|
864
|
+
this.#ensureNoSymlink(this.linkParts(entry, absolute));
|
|
865
|
+
const linkpath = String(entry.linkpath);
|
|
866
|
+
if (entry.type === 'Link') {
|
|
867
|
+
fs.linkSync(this.resolve(cwd, linkpath), absolute);
|
|
712
868
|
}
|
|
713
869
|
else {
|
|
714
|
-
|
|
715
|
-
entry.resume();
|
|
716
|
-
}
|
|
717
|
-
done();
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
exports.Unpack = Unpack;
|
|
722
|
-
const callSync = (fn) => {
|
|
723
|
-
try {
|
|
724
|
-
return [null, fn()];
|
|
725
|
-
}
|
|
726
|
-
catch (er) {
|
|
727
|
-
return [er, null];
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
class UnpackSync extends Unpack {
|
|
731
|
-
sync = true;
|
|
732
|
-
[MAKEFS](er, entry) {
|
|
733
|
-
return super[MAKEFS](er, entry, () => { });
|
|
734
|
-
}
|
|
735
|
-
[CHECKFS](entry) {
|
|
736
|
-
if (!this[CHECKED_CWD]) {
|
|
737
|
-
const er = this[MKDIR](this.cwd, this.dmode);
|
|
738
|
-
if (er) {
|
|
739
|
-
return this[ONERROR](er, entry);
|
|
740
|
-
}
|
|
741
|
-
this[CHECKED_CWD] = true;
|
|
742
|
-
}
|
|
743
|
-
// don't bother to make the parent if the current entry is the cwd,
|
|
744
|
-
// we've already checked it.
|
|
745
|
-
if (entry.absolute !== this.cwd) {
|
|
746
|
-
const parent = (0, normalize_windows_path_js_1.normalizeWindowsPath)(node_path_1.default.dirname(String(entry.absolute)));
|
|
747
|
-
if (parent !== this.cwd) {
|
|
748
|
-
const mkParent = this[MKDIR](parent, this.dmode);
|
|
749
|
-
if (mkParent) {
|
|
750
|
-
return this[ONERROR](mkParent, entry);
|
|
751
|
-
}
|
|
870
|
+
fs.symlinkSync(linkpath, absolute);
|
|
752
871
|
}
|
|
753
872
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
return
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
: [];
|
|
772
|
-
return this[MAKEFS](er, entry);
|
|
773
|
-
}
|
|
774
|
-
// not a dir entry, have to remove it
|
|
775
|
-
const [er] = callSync(() => node_fs_1.default.rmdirSync(String(entry.absolute)));
|
|
776
|
-
this[MAKEFS](er, entry);
|
|
777
|
-
}
|
|
778
|
-
// not a dir, and not reusable.
|
|
779
|
-
// don't remove if it's the cwd, since we want that error.
|
|
780
|
-
const [er] = entry.absolute === this.cwd ?
|
|
781
|
-
[]
|
|
782
|
-
: callSync(() => unlinkFileSync(String(entry.absolute)));
|
|
783
|
-
this[MAKEFS](er, entry);
|
|
784
|
-
}
|
|
785
|
-
[FILE](entry, done) {
|
|
786
|
-
const mode = typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.fmode;
|
|
787
|
-
const oner = (er) => {
|
|
788
|
-
let closeError;
|
|
873
|
+
this.#ensureNoSymlink(this.parentParts(absolute));
|
|
874
|
+
}
|
|
875
|
+
#unlink(path) {
|
|
876
|
+
const fs = this.#fs;
|
|
877
|
+
if (!this.win32)
|
|
878
|
+
return fs.unlinkSync(path);
|
|
879
|
+
const name = deleteName(path);
|
|
880
|
+
fs.renameSync(path, name);
|
|
881
|
+
fs.unlinkSync(name);
|
|
882
|
+
}
|
|
883
|
+
#ensureNoSymlink(parts) {
|
|
884
|
+
if (this.preservePaths)
|
|
885
|
+
return;
|
|
886
|
+
let t = this.cwd;
|
|
887
|
+
for (const p of parts) {
|
|
888
|
+
t = this.resolve(t, p);
|
|
889
|
+
let st;
|
|
789
890
|
try {
|
|
790
|
-
|
|
891
|
+
st = this.#fs.lstatSync(t);
|
|
791
892
|
}
|
|
792
|
-
catch
|
|
793
|
-
|
|
794
|
-
}
|
|
795
|
-
if (er || closeError) {
|
|
796
|
-
this[ONERROR](er || closeError, entry);
|
|
893
|
+
catch {
|
|
894
|
+
return;
|
|
797
895
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
let fd;
|
|
801
|
-
try {
|
|
802
|
-
fd = node_fs_1.default.openSync(String(entry.absolute), (0, get_write_flag_js_1.getWriteFlag)(entry.size), mode);
|
|
803
|
-
/* c8 ignore start - This is only a problem if the file was successfully
|
|
804
|
-
* statted, BUT failed to open. Testing this is annoying, and we
|
|
805
|
-
* already have ample testint for other uses of oner() methods.
|
|
806
|
-
*/
|
|
896
|
+
if (st.isSymbolicLink())
|
|
897
|
+
throw this.symlinkError(t, parts);
|
|
807
898
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
899
|
+
}
|
|
900
|
+
#directory(entry, absolute) {
|
|
901
|
+
const fs = this.#fs;
|
|
902
|
+
this.#mkdir(absolute, entry.mode ?? this.dmode);
|
|
903
|
+
// These do not follow a symbolic link that replaced the
|
|
904
|
+
// directory. A failure is not an error of the entry.
|
|
905
|
+
const times = this.times(entry);
|
|
906
|
+
if (times) {
|
|
907
|
+
try {
|
|
908
|
+
fs.lutimesSync(absolute, times.atime, times.mtime);
|
|
909
|
+
}
|
|
910
|
+
catch { }
|
|
816
911
|
}
|
|
817
|
-
|
|
912
|
+
const owner = this.owner(entry);
|
|
913
|
+
if (owner) {
|
|
818
914
|
try {
|
|
819
|
-
|
|
915
|
+
fs.lchownSync(absolute, owner.uid, owner.gid);
|
|
820
916
|
}
|
|
821
|
-
catch
|
|
822
|
-
|
|
917
|
+
catch { }
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
#file(entry, absolute, reader) {
|
|
921
|
+
const fs = this.#fs;
|
|
922
|
+
const fd = fs.openSync(absolute, this.writeFlag(entry.size), entry.mode ?? this.fmode);
|
|
923
|
+
try {
|
|
924
|
+
// The file is open. Write to it only if no parent directory
|
|
925
|
+
// became a symbolic link before the open.
|
|
926
|
+
this.#ensureNoSymlink(this.parentParts(absolute));
|
|
927
|
+
const tx = this.opt.transform?.(entry);
|
|
928
|
+
for (;;) {
|
|
929
|
+
let part;
|
|
930
|
+
try {
|
|
931
|
+
part = reader.readBody(entry);
|
|
932
|
+
}
|
|
933
|
+
catch (er) {
|
|
934
|
+
// The archive cannot be read.
|
|
935
|
+
throw this.fail(er);
|
|
936
|
+
}
|
|
937
|
+
if (!part)
|
|
938
|
+
break;
|
|
939
|
+
fs.writeSync(fd, tx ? tx(part) : part);
|
|
823
940
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
if (entry.mtime && !this.noMtime) {
|
|
830
|
-
const atime = entry.atime || new Date();
|
|
831
|
-
const mtime = entry.mtime;
|
|
941
|
+
// Use the open file, so that a symbolic link that replaced the
|
|
942
|
+
// path is not followed. If that fails, use the path.
|
|
943
|
+
const times = this.times(entry);
|
|
944
|
+
if (times) {
|
|
945
|
+
const { atime, mtime } = times;
|
|
832
946
|
try {
|
|
833
|
-
|
|
947
|
+
fs.futimesSync(fd, atime, mtime);
|
|
834
948
|
}
|
|
835
|
-
catch (
|
|
949
|
+
catch (er) {
|
|
836
950
|
try {
|
|
837
|
-
|
|
951
|
+
fs.utimesSync(absolute, atime, mtime);
|
|
838
952
|
}
|
|
839
953
|
catch {
|
|
840
|
-
er
|
|
954
|
+
throw er;
|
|
841
955
|
}
|
|
842
956
|
}
|
|
843
957
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
const gid =
|
|
958
|
+
const owner = this.owner(entry);
|
|
959
|
+
if (owner) {
|
|
960
|
+
const { uid, gid } = owner;
|
|
847
961
|
try {
|
|
848
|
-
|
|
962
|
+
fs.fchownSync(fd, uid, gid);
|
|
849
963
|
}
|
|
850
|
-
catch (
|
|
964
|
+
catch (er) {
|
|
851
965
|
try {
|
|
852
|
-
|
|
966
|
+
fs.chownSync(absolute, uid, gid);
|
|
853
967
|
}
|
|
854
968
|
catch {
|
|
855
|
-
|
|
969
|
+
throw er;
|
|
856
970
|
}
|
|
857
971
|
}
|
|
858
972
|
}
|
|
859
|
-
oner(er);
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
[DIRECTORY](entry, done) {
|
|
863
|
-
const mode = typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.dmode;
|
|
864
|
-
const er = this[MKDIR](String(entry.absolute), mode);
|
|
865
|
-
if (er) {
|
|
866
|
-
this[ONERROR](er, entry);
|
|
867
|
-
done();
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
if (entry.mtime && !this.noMtime) {
|
|
871
|
-
try {
|
|
872
|
-
node_fs_1.default.utimesSync(String(entry.absolute), entry.atime || new Date(), entry.mtime);
|
|
873
|
-
/* c8 ignore next */
|
|
874
|
-
}
|
|
875
|
-
catch { }
|
|
876
973
|
}
|
|
877
|
-
|
|
974
|
+
catch (er) {
|
|
975
|
+
// Close the file one time, and do not use the descriptor again:
|
|
976
|
+
// the system can give its number to a different file.
|
|
878
977
|
try {
|
|
879
|
-
|
|
978
|
+
fs.closeSync(fd);
|
|
880
979
|
}
|
|
881
980
|
catch { }
|
|
981
|
+
throw er;
|
|
882
982
|
}
|
|
883
|
-
|
|
884
|
-
entry.resume();
|
|
885
|
-
}
|
|
886
|
-
[MKDIR](dir, mode) {
|
|
887
|
-
try {
|
|
888
|
-
return (0, mkdir_js_1.mkdirSync)((0, normalize_windows_path_js_1.normalizeWindowsPath)(dir), {
|
|
889
|
-
uid: this.uid,
|
|
890
|
-
gid: this.gid,
|
|
891
|
-
processUid: this.processUid,
|
|
892
|
-
processGid: this.processGid,
|
|
893
|
-
umask: this.processUmask,
|
|
894
|
-
preserve: this.preservePaths,
|
|
895
|
-
unlink: this.unlink,
|
|
896
|
-
cwd: this.cwd,
|
|
897
|
-
mode: mode,
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
catch (er) {
|
|
901
|
-
return er;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
[ENSURE_NO_SYMLINK](_entry, cwd, parts, done, onError) {
|
|
905
|
-
if (this.preservePaths || parts.length === 0)
|
|
906
|
-
return done();
|
|
907
|
-
let t = cwd;
|
|
908
|
-
for (const p of parts) {
|
|
909
|
-
t = node_path_1.default.resolve(t, p);
|
|
910
|
-
const [er, st] = callSync(() => node_fs_1.default.lstatSync(t));
|
|
911
|
-
if (er)
|
|
912
|
-
return done();
|
|
913
|
-
if (st.isSymbolicLink()) {
|
|
914
|
-
return onError(new symlink_error_js_1.SymlinkError(t, node_path_1.default.resolve(cwd, parts.join('/'))));
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
done();
|
|
918
|
-
}
|
|
919
|
-
[LINK](entry, linkpath, link, done) {
|
|
920
|
-
const linkSync = `${link}Sync`;
|
|
921
|
-
try {
|
|
922
|
-
node_fs_1.default[linkSync](linkpath, String(entry.absolute));
|
|
923
|
-
done();
|
|
924
|
-
entry.resume();
|
|
925
|
-
}
|
|
926
|
-
catch (er) {
|
|
927
|
-
return this[ONERROR](er, entry);
|
|
928
|
-
}
|
|
983
|
+
fs.closeSync(fd);
|
|
929
984
|
}
|
|
930
985
|
}
|
|
931
986
|
exports.UnpackSync = UnpackSync;
|