@vltpkg/cli-js 1.0.8 → 1.0.10

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.
Files changed (72) hide show
  1. package/{access-FOYRQGJC.js → access-4RPC3X5N.js} +5 -5
  2. package/{bugs-ORVU4I5O.js → bugs-K6QLQLL4.js} +12 -12
  3. package/{build-JLVAGEEU.js → build-VD4L5IED.js} +8 -8
  4. package/{cache-RIOSSQD3.js → cache-Q6FUUEQF.js} +7 -7
  5. package/{chunk-5CNTLC2U.js → chunk-3564IL5W.js} +1 -1
  6. package/{chunk-YAIKXFLN.js → chunk-5HBKYSTX.js} +1 -1
  7. package/{chunk-PTR5IGFQ.js → chunk-5HPGL5WS.js} +1 -1
  8. package/{chunk-UYIA44HE.js → chunk-B5IILBX7.js} +4 -4
  9. package/{chunk-BJBFEQRR.js → chunk-BHJT53TP.js} +1 -0
  10. package/{chunk-ADLHAQRA.js → chunk-BSPUKIWY.js} +1 -1
  11. package/{chunk-3L2ERW54.js → chunk-DAS7TVRN.js} +3 -3
  12. package/{chunk-7D7SNVBV.js → chunk-FUCQ7ARR.js} +76 -25
  13. package/{chunk-XISRK3R5.js → chunk-MNK55XSE.js} +17 -0
  14. package/{chunk-WY4PAM6D.js → chunk-NA732FNL.js} +3 -3
  15. package/{chunk-AGHW2E24.js → chunk-NWLS3VOQ.js} +79 -15
  16. package/{chunk-YCVPEZRM.js → chunk-P5S2TFCF.js} +50 -16
  17. package/{chunk-5QAFAGO5.js → chunk-TYRKIWGF.js} +6 -6
  18. package/{chunk-JXVDCQZF.js → chunk-VL7RJVNN.js} +27 -5
  19. package/{chunk-NC3QYZPW.js → chunk-WAYVHANF.js} +3 -3
  20. package/{chunk-MUG5K6X2.js → chunk-XFI4THXZ.js} +1 -1
  21. package/{chunk-ZXIF4PVX.js → chunk-XUP35M5Q.js} +4 -4
  22. package/chunk-Y3QEV76Q.js +75 -0
  23. package/{chunk-OB73T23B.js → chunk-ZNCVQQDT.js} +1 -1
  24. package/{ci-2666LKEC.js → ci-G4PJWJQE.js} +7 -7
  25. package/cli-package.json +1 -1
  26. package/{config-3N7PBEXH.js → config-66ARNESN.js} +6 -5
  27. package/{config-WMYY5J37.js → config-WTIWWXRD.js} +8 -7
  28. package/{create-AEQSO6KX.js → create-DF6RQTHC.js} +13 -13
  29. package/{deprecate-MW76DAZ5.js → deprecate-2KTC2HKH.js} +8 -8
  30. package/{dist-tag-XGQLYA6C.js → dist-tag-QKJQIOGN.js} +5 -5
  31. package/{docs-7CCTL3OY.js → docs-YSWJTGYX.js} +12 -12
  32. package/{exec-GWCIDNOH.js → exec-5XIMPSBI.js} +13 -13
  33. package/{exec-cache-AML2HUTJ.js → exec-cache-OGX7WR5P.js} +11 -11
  34. package/{exec-local-JRTO2XG4.js → exec-local-SB7EPYED.js} +11 -11
  35. package/{help-4KSCV7GN.js → help-GMCQHGVN.js} +4 -4
  36. package/{init-OHVBHXB7.js → init-KXIIWHBA.js} +8 -8
  37. package/{install-TFDEHY5J.js → install-ODTEMAMS.js} +8 -8
  38. package/{list-UD4SDHVE.js → list-QS4FLJSU.js} +13 -13
  39. package/{login-B6TIQW62.js → login-6TGYRY43.js} +8 -8
  40. package/{logout-H3CXGLDN.js → logout-GOAB7KHJ.js} +5 -5
  41. package/{pack-YYK4LKBQ.js → pack-PJDH6PKP.js} +9 -9
  42. package/package.json +1 -1
  43. package/{ping-G765RWLM.js → ping-ANBW2IRW.js} +5 -5
  44. package/{pkg-D4S3SPUH.js → pkg-GZWUXU65.js} +9 -9
  45. package/{profile-YDQGMWYP.js → profile-BLY74CMB.js} +5 -5
  46. package/{publish-ANHSZPIM.js → publish-W2KOTNMB.js} +25 -13
  47. package/{query-PZ6C6AZJ.js → query-3PUMU5ON.js} +13 -13
  48. package/{registry-BMWXMQS4.js → registry-ONSDWNPV.js} +3 -3
  49. package/registry-client-package.json +1 -1
  50. package/registry-client-src-revalidate.js +75 -11
  51. package/{repo-ZA3TMERE.js → repo-LZ6STH4C.js} +12 -12
  52. package/{run-N4NK35UT.js → run-JMIBADHE.js} +11 -11
  53. package/{run-exec-N5FT4QO7.js → run-exec-JEKM2O53.js} +11 -11
  54. package/{setup-MWWDSKQZ.js → setup-BTBU3NAI.js} +35 -17
  55. package/{src-6UF5YTTL.js → src-23VBKASP.js} +9 -9
  56. package/{src-6PISL6QX.js → src-J4BAYOBO.js} +3 -3
  57. package/{src-U4EBFPPT.js → src-MOKZQTH2.js} +163 -205
  58. package/{token-FFUAFL43.js → token-PUJ7QN6D.js} +5 -5
  59. package/{uninstall-A4PUG6RI.js → uninstall-OTISP2T7.js} +8 -8
  60. package/{unpublish-OJEGZDGQ.js → unpublish-X75EEQAN.js} +6 -6
  61. package/{update-ENR6ICMR.js → update-CKXX5POE.js} +7 -7
  62. package/{version-K3BUGG7X.js → version-24B2X7M7.js} +23 -17
  63. package/{view-SWVQLQCB.js → view-Q7MAQ6R3.js} +7 -6
  64. package/vlr.js +1 -1
  65. package/vlrx.js +1 -1
  66. package/vlt.js +1 -1
  67. package/vlx.js +1 -1
  68. package/vlxl.js +1 -1
  69. package/{whoami-MA733O2T.js → whoami-S6CQZFE3.js} +5 -5
  70. package/chunk-AQ3XJJUP.js +0 -75
  71. package/{chunk-FG633ZKS.js → chunk-2YJ5MESP.js} +3 -3
  72. package/{chunk-OWML62W5.js → chunk-USTJECVS.js} +3 -3
@@ -12,39 +12,42 @@ var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  configWriteTarget,
14
14
  registrySelectionFields
15
- } from "./chunk-WY4PAM6D.js";
16
- import "./chunk-YCVPEZRM.js";
15
+ } from "./chunk-NA732FNL.js";
16
+ import "./chunk-P5S2TFCF.js";
17
17
  import "./chunk-ZWKI5OSF.js";
18
18
  import {
19
19
  stdout
20
- } from "./chunk-JXVDCQZF.js";
21
- import "./chunk-YAIKXFLN.js";
20
+ } from "./chunk-VL7RJVNN.js";
21
+ import "./chunk-5HBKYSTX.js";
22
22
  import "./chunk-G2YT2GWF.js";
23
23
  import "./chunk-GDJ7JT2R.js";
24
24
  import "./chunk-5JFRXIK2.js";
25
25
  import "./chunk-WGDTG44V.js";
26
- import "./chunk-OWML62W5.js";
26
+ import "./chunk-USTJECVS.js";
27
27
  import "./chunk-YOE3VZFX.js";
28
28
  import {
29
29
  commandUsage
30
- } from "./chunk-PTR5IGFQ.js";
30
+ } from "./chunk-5HPGL5WS.js";
31
31
  import "./chunk-XKVU23NC.js";
32
- import "./chunk-XISRK3R5.js";
32
+ import "./chunk-MNK55XSE.js";
33
33
  import "./chunk-4KCU2KZL.js";
34
34
  import "./chunk-HTOTG4TS.js";
35
35
  import {
36
36
  RegistryClient
37
- } from "./chunk-AGHW2E24.js";
37
+ } from "./chunk-NWLS3VOQ.js";
38
38
  import "./chunk-HAYXR3MW.js";
39
39
  import "./chunk-E74WGW5C.js";
40
40
  import "./chunk-LPIBYUMT.js";
41
41
  import "./chunk-UBLFPJHV.js";
42
- import "./chunk-XNLSTHDK.js";
43
- import "./chunk-BJBFEQRR.js";
44
- import "./chunk-VE6CCH33.js";
45
42
  import {
46
- defaultRegistries
43
+ asError,
44
+ defaultRegistries,
45
+ isErrorWithCause,
46
+ isObject
47
47
  } from "./chunk-VFBCWAOC.js";
48
+ import "./chunk-XNLSTHDK.js";
49
+ import "./chunk-BHJT53TP.js";
50
+ import "./chunk-VE6CCH33.js";
48
51
  import {
49
52
  error
50
53
  } from "./chunk-WZWDS3W4.js";
@@ -56,6 +59,17 @@ var VLT_SIGNUP_URL = "https://www.vlt.io";
56
59
  var VLT_REGISTRY_BASE = "https://registry.vlt.io";
57
60
  var accountRegistries = ["npm", "main"];
58
61
  var accountRegistryURL = (account, name) => `${VLT_REGISTRY_BASE}/${encodeURIComponent(account)}/${name}/`;
62
+ var accountAuthError = (account, er) => isErrorWithCause(er) && isObject(er.cause) && er.cause.status === 404 ? error(
63
+ [
64
+ `No vlt.io account or organization named "${account}".`,
65
+ "",
66
+ `Looked for it at ${accountRegistryURL(account, accountRegistries[0])}`,
67
+ "",
68
+ "Check the spelling of the slug, or sign up / create the",
69
+ `organization at ${VLT_SIGNUP_URL}, then run \`vlt setup\` again.`
70
+ ].join("\n"),
71
+ { code: "ECONFIG", cause: er }
72
+ ) : asError(er);
59
73
  var normalizeRegistryURL = (url) => url.endsWith("/") ? url : `${url}/`;
60
74
  var views = {
61
75
  human: (result) => {
@@ -157,11 +171,15 @@ var command = async (conf) => {
157
171
  ", "
158
172
  )})...`
159
173
  );
160
- await rc.login(
161
- accountRegistries.map(
162
- (name) => accountRegistryURL(account, name)
163
- )
164
- );
174
+ try {
175
+ await rc.login(
176
+ accountRegistries.map(
177
+ (name) => accountRegistryURL(account, name)
178
+ )
179
+ );
180
+ } catch (er) {
181
+ throw accountAuthError(account, er);
182
+ }
165
183
  }
166
184
  for (; ; ) {
167
185
  const more = await ask("Add another registry alias? (y/N) ");
@@ -11,11 +11,11 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  loadCommand
14
- } from "./chunk-AQ3XJJUP.js";
14
+ } from "./chunk-Y3QEV76Q.js";
15
15
  import {
16
16
  Config
17
- } from "./chunk-WY4PAM6D.js";
18
- import "./chunk-YCVPEZRM.js";
17
+ } from "./chunk-NA732FNL.js";
18
+ import "./chunk-P5S2TFCF.js";
19
19
  import "./chunk-ZWKI5OSF.js";
20
20
  import {
21
21
  flushAndExit,
@@ -23,21 +23,21 @@ import {
23
23
  outputCommand,
24
24
  stderr,
25
25
  stdout
26
- } from "./chunk-JXVDCQZF.js";
27
- import "./chunk-YAIKXFLN.js";
26
+ } from "./chunk-VL7RJVNN.js";
27
+ import "./chunk-5HBKYSTX.js";
28
28
  import "./chunk-G2YT2GWF.js";
29
29
  import {
30
30
  asRootError
31
31
  } from "./chunk-GDJ7JT2R.js";
32
32
  import "./chunk-5JFRXIK2.js";
33
33
  import "./chunk-WGDTG44V.js";
34
- import "./chunk-OWML62W5.js";
34
+ import "./chunk-USTJECVS.js";
35
35
  import "./chunk-YOE3VZFX.js";
36
36
  import "./chunk-XKVU23NC.js";
37
37
  import {
38
38
  getSortedCliOptions,
39
39
  getSortedKeys
40
- } from "./chunk-XISRK3R5.js";
40
+ } from "./chunk-MNK55XSE.js";
41
41
  import "./chunk-4KCU2KZL.js";
42
42
  import "./chunk-HTOTG4TS.js";
43
43
  import {
@@ -45,9 +45,9 @@ import {
45
45
  } from "./chunk-E74WGW5C.js";
46
46
  import "./chunk-LPIBYUMT.js";
47
47
  import "./chunk-UBLFPJHV.js";
48
+ import "./chunk-VFBCWAOC.js";
48
49
  import "./chunk-XNLSTHDK.js";
49
50
  import "./chunk-VE6CCH33.js";
50
- import "./chunk-VFBCWAOC.js";
51
51
  import "./chunk-WZWDS3W4.js";
52
52
  import "./chunk-PZLD7RTK.js";
53
53
 
@@ -121,7 +121,7 @@ var run = async () => {
121
121
  return flushAndExit(process.exitCode || 1);
122
122
  }
123
123
  if (vlt.command === "registry") {
124
- const { dispatchRegistry } = await import("./registry-BMWXMQS4.js");
124
+ const { dispatchRegistry } = await import("./registry-ONSDWNPV.js");
125
125
  await dispatchRegistry(vlt);
126
126
  }
127
127
  const command = await loadCommand(vlt.command);
@@ -28,15 +28,15 @@ import {
28
28
  setRuntimeToken,
29
29
  setToken,
30
30
  userAgent
31
- } from "./chunk-AGHW2E24.js";
31
+ } from "./chunk-NWLS3VOQ.js";
32
32
  import "./chunk-HAYXR3MW.js";
33
33
  import "./chunk-E74WGW5C.js";
34
34
  import "./chunk-LPIBYUMT.js";
35
35
  import "./chunk-UBLFPJHV.js";
36
+ import "./chunk-VFBCWAOC.js";
36
37
  import "./chunk-XNLSTHDK.js";
37
- import "./chunk-BJBFEQRR.js";
38
+ import "./chunk-BHJT53TP.js";
38
39
  import "./chunk-VE6CCH33.js";
39
- import "./chunk-VFBCWAOC.js";
40
40
  import "./chunk-WZWDS3W4.js";
41
41
  import "./chunk-PZLD7RTK.js";
42
42
  export {
@@ -10,12 +10,10 @@ globalThis.clearInterval = _vlt_clearInterval;
10
10
  import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
- rimraf
14
- } from "./chunk-BJBFEQRR.js";
13
+ rimraf,
14
+ rimrafSync
15
+ } from "./chunk-BHJT53TP.js";
15
16
  import "./chunk-VE6CCH33.js";
16
- import {
17
- asError
18
- } from "./chunk-VFBCWAOC.js";
19
17
  import {
20
18
  error
21
19
  } from "./chunk-WZWDS3W4.js";
@@ -23,6 +21,13 @@ import "./chunk-PZLD7RTK.js";
23
21
 
24
22
  // ../../src/tar/src/unpack.ts
25
23
  import { randomBytes } from "node:crypto";
24
+ import {
25
+ lstatSync,
26
+ mkdirSync,
27
+ readFileSync,
28
+ renameSync,
29
+ writeFileSync
30
+ } from "node:fs";
26
31
  import { lstat, mkdir, rename, writeFile } from "node:fs/promises";
27
32
  import {
28
33
  basename as basename2,
@@ -525,7 +530,7 @@ var parseKVLine = (set, line) => {
525
530
  };
526
531
 
527
532
  // ../../src/tar/src/unpack.ts
528
- import { unzip as unzipCB } from "node:zlib";
533
+ import { unzip as unzipCB, unzipSync as unzipSyncCB } from "node:zlib";
529
534
 
530
535
  // ../../src/tar/src/find-tar-dir.ts
531
536
  var findTarDir = (path, tarDir) => {
@@ -550,24 +555,30 @@ var parseMaxUnpackedBytes = (raw) => {
550
555
  var maxUnpackedBytes = parseMaxUnpackedBytes(
551
556
  process.env.VLT_TAR_MAX_UNPACKED_BYTES
552
557
  );
558
+ var unzipMax = (len) => Math.min(maxUnpackedBytes, len * MAX_DECOMPRESSION_RATIO);
559
+ var unzipError = (er, found, max) => er.code === "ERR_BUFFER_TOO_LARGE" ? error("tarball exceeds maximum unpacked size", {
560
+ found,
561
+ max,
562
+ cause: er
563
+ }) : er;
553
564
  var unzip = async (input) => {
554
- const max = Math.min(
555
- maxUnpackedBytes,
556
- input.length * MAX_DECOMPRESSION_RATIO
557
- );
565
+ const max = unzipMax(input.length);
558
566
  return new Promise(
559
- (res, rej) => unzipCB(input, { maxOutputLength: max }, (er, result) => {
560
- if (!er) return res(result);
561
- return rej(
562
- er.code === "ERR_BUFFER_TOO_LARGE" ? error("tarball exceeds maximum unpacked size", {
563
- found: input.length,
564
- max,
565
- cause: er
566
- }) : er
567
- );
568
- })
567
+ (res, rej) => unzipCB(
568
+ input,
569
+ { maxOutputLength: max },
570
+ (er, result) => er ? rej(unzipError(er, input.length, max)) : res(result)
571
+ )
569
572
  );
570
573
  };
574
+ var unzipSync = (input) => {
575
+ const max = unzipMax(input.length);
576
+ try {
577
+ return unzipSyncCB(input, { maxOutputLength: max });
578
+ } catch (er) {
579
+ throw unzipError(er, input.length, max);
580
+ }
581
+ };
571
582
  var exists = async (path) => {
572
583
  try {
573
584
  await lstat(path);
@@ -673,7 +684,13 @@ var unpack = async (tarData, target) => {
673
684
  target
674
685
  );
675
686
  };
676
- var unpackUnzipped = async (buffer, target) => {
687
+ var unpackSync = (tarData, target) => {
688
+ const isGzip = tarData[0] === 31 && tarData[1] === 139;
689
+ unpackUnzippedSync(isGzip ? unzipSync(tarData) : tarData, target);
690
+ };
691
+ var unpackFileSync = (file, target, offset = 0) => unpackSync(readFileSync(file).subarray(offset), target);
692
+ var tmpName = (target) => dirname(target) + sep + "." + basename2(target) + "." + tmpSuffix();
693
+ var parseTarball = (buffer, tmp2) => {
677
694
  const isGzip = buffer[0] === 31 && buffer[1] === 139;
678
695
  if (isGzip) {
679
696
  throw error("still gzipped after unzipping", {
@@ -689,7 +706,9 @@ var unpackUnzipped = async (buffer, target) => {
689
706
  if (buffer.length < 1024) {
690
707
  throw error(
691
708
  "Invalid tarball: not terminated by 1024 null bytes",
692
- { found: buffer.length }
709
+ {
710
+ found: buffer.length
711
+ }
693
712
  );
694
713
  }
695
714
  for (let i = buffer.length - 1024; i < buffer.length; i++) {
@@ -700,86 +719,90 @@ var unpackUnzipped = async (buffer, target) => {
700
719
  );
701
720
  }
702
721
  }
703
- const tmp2 = dirname(target) + sep + "." + basename2(target) + "." + tmpSuffix();
704
- const og = tmp2 + ".ORIGINAL";
705
- let succeeded = false;
706
- try {
707
- const entries = /* @__PURE__ */ new Map();
708
- let tarDir = void 0;
709
- let offset = 0;
710
- let h;
711
- let ex = void 0;
712
- let gex = void 0;
713
- while (offset < buffer.length && !(h = new Header(buffer, offset, ex, gex)).nullBlock) {
714
- offset += 512;
715
- ex = void 0;
716
- gex = void 0;
717
- const size = h.size ?? 0;
718
- const body = buffer.subarray(offset, offset + size);
719
- if (!h.cksumValid) continue;
720
- offset += 512 * Math.ceil(size / 512);
721
- switch (h.type) {
722
- case "File":
723
- if (!tarDir) tarDir = findTarDir(h.path, tarDir);
724
- if (!tarDir) continue;
725
- if (!checkFs(h, tarDir, tmp2)) continue;
726
- {
727
- const dest = resolve(tmp2, h.path.substring(tarDir.length));
728
- const key = entryKey(dest);
729
- if (entries.get(key)?.dir === true) {
730
- throw error("file/directory collision in tarball", {
731
- path: dest
732
- });
733
- }
734
- entries.set(key, {
735
- path: dest,
736
- body,
737
- executable: 1 === ((h.mode ?? 1638) & 1),
738
- dir: false
722
+ const entries = /* @__PURE__ */ new Map();
723
+ let tarDir = void 0;
724
+ let offset = 0;
725
+ let h;
726
+ let ex = void 0;
727
+ let gex = void 0;
728
+ while (offset < buffer.length && !(h = new Header(buffer, offset, ex, gex)).nullBlock) {
729
+ offset += 512;
730
+ ex = void 0;
731
+ gex = void 0;
732
+ const size = h.size ?? 0;
733
+ const body = buffer.subarray(offset, offset + size);
734
+ if (!h.cksumValid) continue;
735
+ offset += 512 * Math.ceil(size / 512);
736
+ switch (h.type) {
737
+ case "File":
738
+ if (!tarDir) tarDir = findTarDir(h.path, tarDir);
739
+ if (!tarDir) continue;
740
+ if (!checkFs(h, tarDir, tmp2)) continue;
741
+ {
742
+ const dest = resolve(tmp2, h.path.substring(tarDir.length));
743
+ const key = entryKey(dest);
744
+ if (entries.get(key)?.dir === true) {
745
+ throw error("file/directory collision in tarball", {
746
+ path: dest
739
747
  });
740
748
  }
741
- break;
742
- case "Directory":
743
- if (!tarDir) tarDir = findTarDir(h.path, tarDir);
744
- if (!tarDir) continue;
745
- if (!checkFs(h, tarDir, tmp2)) continue;
746
- {
747
- const dest = resolve(tmp2, h.path.substring(tarDir.length));
748
- const key = entryKey(dest);
749
- if (entries.get(key)?.dir === false) {
750
- throw error("file/directory collision in tarball", {
751
- path: dest
752
- });
753
- }
754
- entries.set(key, {
755
- path: dest,
756
- dir: true
749
+ entries.set(key, {
750
+ path: dest,
751
+ body,
752
+ executable: 1 === ((h.mode ?? 1638) & 1),
753
+ dir: false
754
+ });
755
+ }
756
+ break;
757
+ case "Directory":
758
+ if (!tarDir) tarDir = findTarDir(h.path, tarDir);
759
+ if (!tarDir) continue;
760
+ if (!checkFs(h, tarDir, tmp2)) continue;
761
+ {
762
+ const dest = resolve(tmp2, h.path.substring(tarDir.length));
763
+ const key = entryKey(dest);
764
+ if (entries.get(key)?.dir === false) {
765
+ throw error("file/directory collision in tarball", {
766
+ path: dest
757
767
  });
758
768
  }
759
- break;
760
- case "GlobalExtendedHeader":
761
- gex = Pax.parse(body.toString(), gex, true);
762
- break;
763
- case "ExtendedHeader":
764
- case "OldExtendedHeader":
765
- ex = Pax.parse(body.toString(), ex, false);
766
- break;
767
- case "NextFileHasLongPath":
768
- case "OldGnuLongPath":
769
- ex ??= /* @__PURE__ */ Object.create(null);
770
- ex.path = body.toString().replace(/\0.*/, "");
771
- break;
772
- }
773
- }
774
- const dirs = /* @__PURE__ */ new Set();
775
- const files = [];
776
- for (const e of entries.values()) {
777
- if (e.dir) dirs.add(e.path);
778
- else {
779
- dirs.add(dirname(e.path));
780
- files.push(e);
781
- }
782
- }
769
+ entries.set(key, {
770
+ path: dest,
771
+ dir: true
772
+ });
773
+ }
774
+ break;
775
+ case "GlobalExtendedHeader":
776
+ gex = Pax.parse(body.toString(), gex, true);
777
+ break;
778
+ case "ExtendedHeader":
779
+ case "OldExtendedHeader":
780
+ ex = Pax.parse(body.toString(), ex, false);
781
+ break;
782
+ case "NextFileHasLongPath":
783
+ case "OldGnuLongPath":
784
+ ex ??= /* @__PURE__ */ Object.create(null);
785
+ ex.path = body.toString().replace(/\0.*/, "");
786
+ break;
787
+ }
788
+ }
789
+ const dirs = /* @__PURE__ */ new Set();
790
+ const files = [];
791
+ for (const e of entries.values()) {
792
+ if (e.dir) dirs.add(e.path);
793
+ else {
794
+ dirs.add(dirname(e.path));
795
+ files.push(e);
796
+ }
797
+ }
798
+ return { dirs, files };
799
+ };
800
+ var unpackUnzipped = async (buffer, target) => {
801
+ const tmp2 = tmpName(target);
802
+ const og = tmp2 + ".ORIGINAL";
803
+ let succeeded = false;
804
+ try {
805
+ const { dirs, files } = parseTarball(buffer, tmp2);
783
806
  rethrowFirst(
784
807
  await Promise.allSettled(
785
808
  [...dirs].map(
@@ -809,128 +832,63 @@ var unpackUnzipped = async (buffer, target) => {
809
832
  }
810
833
  }
811
834
  };
812
-
813
- // ../../src/tar/src/pool.ts
814
- import os from "node:os";
815
-
816
- // ../../src/tar/src/unpack-request.ts
817
- var ID = 1;
818
- var UnpackRequest = class {
819
- id = ID++;
820
- tarData;
821
- target;
822
- resolve;
823
- reject;
824
- promise = new Promise((res, rej) => {
825
- this.resolve = res;
826
- this.reject = rej;
827
- });
828
- constructor(tarData, target) {
829
- this.tarData = tarData;
830
- this.target = target;
831
- }
832
- };
833
-
834
- // ../../src/tar/src/worker.ts
835
- var isObj = (o) => !!o && typeof o === "object";
836
- var isResponseOK = (o) => isObj(o) && typeof o.id === "number" && o.ok === true;
837
- var Worker = class {
838
- onMessage;
839
- constructor(onMessage) {
840
- this.onMessage = onMessage;
841
- }
842
- async process(req) {
843
- const { target, tarData, id: id2 } = req;
844
- try {
845
- await unpack(tarData, target);
846
- const m = { id: id2, ok: true };
847
- this.onMessage(m);
848
- } catch (error2) {
849
- const m = { id: id2, error: error2 };
850
- this.onMessage(m);
835
+ var unpackUnzippedSync = (buffer, target) => {
836
+ const tmp2 = tmpName(target);
837
+ const og = tmp2 + ".ORIGINAL";
838
+ let succeeded = false;
839
+ try {
840
+ const { dirs, files } = parseTarball(buffer, tmp2);
841
+ for (const d of dirs) {
842
+ mkdirSync(d, { recursive: true, mode: 511 });
843
+ }
844
+ for (const f of files) {
845
+ writeFileSync(f.path, f.body, {
846
+ mode: f.executable ? 511 : 438
847
+ });
848
+ }
849
+ const targetExists = !!lstatSync(target, {
850
+ throwIfNoEntry: false
851
+ });
852
+ if (targetExists) renameSync(target, og);
853
+ renameSync(tmp2, target);
854
+ if (targetExists) rimrafSync(og);
855
+ succeeded = true;
856
+ } finally {
857
+ if (!succeeded) {
858
+ if (lstatSync(og, { throwIfNoEntry: false })) {
859
+ rimrafSync(target);
860
+ renameSync(og, target);
861
+ }
862
+ rimrafSync(tmp2);
851
863
  }
852
864
  }
853
865
  };
854
866
 
855
867
  // ../../src/tar/src/pool.ts
868
+ import { readFile } from "node:fs/promises";
869
+ var syncUnpack = process.env.VLT_TAR_SYNC !== "0";
856
870
  var Pool = class {
857
871
  /**
858
- * Number of workers to employ. Defaults to 8 times one less than
859
- * the number of available CPUs, with a minimum of 8.
860
- */
861
- /* c8 ignore next */
862
- jobs = 8 * (Math.max(os.availableParallelism(), 2) - 1);
863
- /**
864
- * Set of currently active worker threads
865
- */
866
- workers = /* @__PURE__ */ new Set();
867
- /**
868
- * Queue of requests awaiting an available worker
869
- */
870
- queue = [];
871
- /**
872
- * All requests that have not yet been confirmed completed, both
873
- * those currently assigned to a worker and those still waiting in
874
- * the queue. Entries are removed once the request resolves or
875
- * rejects, releasing the reference to its tarball buffer.
872
+ * Provide the tardata to be unpacked, and the location where it's to be
873
+ * placed. Resolves when the tarball has been extracted.
876
874
  */
877
- pending = /* @__PURE__ */ new Map();
878
- // handle a message from the worker
879
- #onMessage(w, m) {
880
- const { id: id2 } = m;
881
- const ur = this.pending.get(id2);
882
- if (!ur) return;
883
- this.pending.delete(id2);
884
- if (isResponseOK(m)) {
885
- ur.resolve();
886
- } else {
887
- ur.reject(
888
- error(
889
- asError(m.error, "failed without error message").message,
890
- {
891
- found: m,
892
- cause: m.error
893
- }
894
- )
895
- );
896
- }
897
- const next = this.queue.shift();
898
- if (!next) {
899
- this.workers.delete(w);
900
- } else {
901
- void w.process(next);
902
- }
903
- }
904
- // create a new worker
905
- #createWorker(req) {
906
- const w = new Worker(
907
- (m) => this.#onMessage(w, m)
908
- );
909
- this.workers.add(w);
910
- void w.process(req);
875
+ async unpack(tarData, target) {
876
+ if (!syncUnpack) return unpack(tarData, target);
877
+ unpackSync(tarData, target);
911
878
  }
912
879
  /**
913
- * Provide the tardata to be unpacked, and the location where it's to be
914
- * placed. Will create a new worker up to the `jobs` value, and then start
915
- * pushing in the queue for workers to pick up as they become available.
916
- *
917
- * Returned promise resolves when the provided tarball has been extracted.
880
+ * Same, reading the tarball from a file and skipping `offset` leading
881
+ * bytes, so a cache entry is unpacked without loading it into the
882
+ * registry client's in-memory cache.
918
883
  */
919
- async unpack(tarData, target) {
920
- const ur = new UnpackRequest(tarData, target);
921
- this.pending.set(ur.id, ur);
922
- if (this.workers.size < this.jobs) {
923
- this.#createWorker(ur);
924
- } else {
925
- this.queue.push(ur);
884
+ async unpackFile(file, target, offset = 0) {
885
+ if (!syncUnpack) {
886
+ return unpack((await readFile(file)).subarray(offset), target);
926
887
  }
927
- return ur.promise;
888
+ unpackFileSync(file, target, offset);
928
889
  }
929
890
  };
930
891
  export {
931
892
  Pool,
932
- UnpackRequest,
933
- Worker,
934
- isResponseOK,
935
893
  unpack
936
894
  };
@@ -14,9 +14,9 @@ import {
14
14
  } from "./chunk-5JFRXIK2.js";
15
15
  import {
16
16
  commandUsage
17
- } from "./chunk-PTR5IGFQ.js";
17
+ } from "./chunk-5HPGL5WS.js";
18
18
  import "./chunk-XKVU23NC.js";
19
- import "./chunk-XISRK3R5.js";
19
+ import "./chunk-MNK55XSE.js";
20
20
  import {
21
21
  RegistryClient,
22
22
  deleteToken,
@@ -25,15 +25,15 @@ import {
25
25
  normalizeRegistryKey,
26
26
  registryBase,
27
27
  setToken
28
- } from "./chunk-AGHW2E24.js";
28
+ } from "./chunk-NWLS3VOQ.js";
29
29
  import "./chunk-HAYXR3MW.js";
30
30
  import "./chunk-E74WGW5C.js";
31
31
  import "./chunk-LPIBYUMT.js";
32
32
  import "./chunk-UBLFPJHV.js";
33
+ import "./chunk-VFBCWAOC.js";
33
34
  import "./chunk-XNLSTHDK.js";
34
- import "./chunk-BJBFEQRR.js";
35
+ import "./chunk-BHJT53TP.js";
35
36
  import "./chunk-VE6CCH33.js";
36
- import "./chunk-VFBCWAOC.js";
37
37
  import {
38
38
  error
39
39
  } from "./chunk-WZWDS3W4.js";