@vltpkg/cli-js 1.3.7 → 1.3.8

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 (67) hide show
  1. package/{access-4W6PMOGC.js → access-WLKANIOE.js} +2 -2
  2. package/{bugs-FJHQFPZF.js → bugs-5Q3QSTWP.js} +5 -5
  3. package/{build-SPWU3NOH.js → build-XSFR63AW.js} +3 -3
  4. package/{cache-SBNEPOMQ.js → cache-UVPK5J5A.js} +2 -2
  5. package/{chunk-L3K2ZAOO.js → chunk-43HNQWPQ.js} +1 -1
  6. package/chunk-4JAZZRKR.js +76 -0
  7. package/{chunk-QVPNKMUU.js → chunk-5KOLUYXH.js} +59 -9
  8. package/{chunk-VBDNOU76.js → chunk-6BQKR2FM.js} +1 -1
  9. package/{chunk-2M2O6A4R.js → chunk-6P5CFJR7.js} +1 -1
  10. package/{chunk-QYS5MGGM.js → chunk-BGA3WB7H.js} +83 -7
  11. package/{chunk-3D3IB4YN.js → chunk-DL3H4EMY.js} +41 -14
  12. package/{chunk-I7SCSGUO.js → chunk-FIUUAQGC.js} +2 -2
  13. package/{chunk-SPWJ3X5Y.js → chunk-IUL6MPP6.js} +1 -1
  14. package/{chunk-7BHHCB5C.js → chunk-NWHKSRO3.js} +257 -16
  15. package/{chunk-5ZCDGBVU.js → chunk-OAP2ROTL.js} +1 -1
  16. package/{chunk-W2ZO5RZL.js → chunk-PJJCFMLW.js} +1 -1
  17. package/{chunk-F5D3DVC5.js → chunk-QNDM4DVO.js} +7 -3
  18. package/{chunk-FKZ5I53D.js → chunk-WHLYMMI2.js} +3 -3
  19. package/{chunk-KOFQTETH.js → chunk-WKA5UYNA.js} +1 -1
  20. package/{chunk-OWUICQFY.js → chunk-XCDLOQZZ.js} +1 -1
  21. package/{ci-76TAJGF5.js → ci-EDRETPUF.js} +4 -4
  22. package/cli-package.json +1 -1
  23. package/{config-3UQXAYAA.js → config-MVNXGEOQ.js} +2 -2
  24. package/{config-AFIHF54I.js → config-OKBXU7TU.js} +2 -2
  25. package/{create-5ADQTH6K.js → create-R7BXYJSU.js} +7 -7
  26. package/{deprecate-RTQVLJDZ.js → deprecate-YSUKBKQM.js} +3 -3
  27. package/{dist-tag-V4DRDHWA.js → dist-tag-MIGYSR4F.js} +2 -2
  28. package/{docs-RRULRTKQ.js → docs-4WVIN75H.js} +5 -5
  29. package/{exec-NXQUCX3I.js → exec-IXHDQLAM.js} +15 -7
  30. package/{exec-cache-KVZJHFZD.js → exec-cache-EA7GHIK7.js} +5 -5
  31. package/{exec-local-53B5IRKG.js → exec-local-GM4LH56M.js} +5 -5
  32. package/{help-EN4XUTMS.js → help-TCXGBICU.js} +1 -1
  33. package/{init-4L6CQMIL.js → init-MWZDWQHM.js} +4 -4
  34. package/{install-MHWLYW3X.js → install-HPI5HU3C.js} +8 -8
  35. package/{list-XZRF7TBW.js → list-2CX6REPJ.js} +7 -7
  36. package/{login-6GRRY4H7.js → login-RAY23CVG.js} +4 -4
  37. package/{logout-KI2AOYRT.js → logout-ICB5OMGY.js} +2 -2
  38. package/{outdated-TWUPFRCD.js → outdated-FYHPXRMT.js} +23 -21
  39. package/{pack-2ZQLDYFD.js → pack-E5MNPQXK.js} +4 -4
  40. package/package.json +1 -1
  41. package/{ping-ZOTGLOKY.js → ping-REQ2KSAR.js} +2 -2
  42. package/{pkg-HRNOTFXB.js → pkg-YB4GSRII.js} +5 -5
  43. package/{profile-5V3FFDMG.js → profile-GKBW6GRI.js} +2 -2
  44. package/{publish-7ZXEMWTW.js → publish-4ZQJYYLF.js} +5 -5
  45. package/{query-62UDNMGR.js → query-SKXBF3MJ.js} +7 -7
  46. package/registry-client-src-revalidate.js +58 -9
  47. package/{repo-HDUGP5PH.js → repo-ACPTZI2C.js} +5 -5
  48. package/{reporter-TGBPLNR5.js → reporter-4KK2JNGO.js} +3 -3
  49. package/{run-6NRDZD4T.js → run-YW3ITX2A.js} +5 -5
  50. package/{run-exec-I4IIXTLW.js → run-exec-7VQX3OFG.js} +5 -5
  51. package/security-archive-src-update-expired.js +1 -1
  52. package/{setup-UVXEFUUJ.js → setup-PLEKCMXN.js} +4 -4
  53. package/{src-6CJEMSVB.js → src-PXDFMQ6W.js} +4 -2
  54. package/{src-QEJ6WZQ7.js → src-XQ7KVUVN.js} +3 -3
  55. package/{token-WTN27E7A.js → token-GB7RPE5J.js} +2 -2
  56. package/{uninstall-ZJOKXIVQ.js → uninstall-RLCECX37.js} +5 -5
  57. package/{unpublish-LMUGR7GI.js → unpublish-3ZXEAVHF.js} +2 -2
  58. package/{update-WVWMRUYY.js → update-VDZP6EZN.js} +17 -8
  59. package/{version-OJTRHNKV.js → version-MRELJPOK.js} +4 -4
  60. package/{view-6Q5B7ZYN.js → view-LCXMTGCJ.js} +65 -17
  61. package/vlr.js +1 -1
  62. package/vlrx.js +1 -1
  63. package/vlt.js +1 -1
  64. package/vlx.js +1 -1
  65. package/vlxl.js +1 -1
  66. package/{whoami-SPF34TV6.js → whoami-PNRDBS45.js} +2 -2
  67. package/chunk-A6FAI65V.js +0 -76
@@ -19,12 +19,12 @@ import "./chunk-GZ5MYMBT.js";
19
19
  import "./chunk-SE2FSMBR.js";
20
20
  import {
21
21
  RegistryClient
22
- } from "./chunk-QVPNKMUU.js";
22
+ } from "./chunk-5KOLUYXH.js";
23
23
  import "./chunk-APMYKJI2.js";
24
24
  import {
25
25
  assertOk
26
26
  } from "./chunk-6D54UN4T.js";
27
- import "./chunk-VBDNOU76.js";
27
+ import "./chunk-6BQKR2FM.js";
28
28
  import "./chunk-U7TEQCBN.js";
29
29
  import "./chunk-XNLSTHDK.js";
30
30
  import "./chunk-PDWPFR5T.js";
@@ -17,24 +17,24 @@ import {
17
17
  } from "./chunk-OWMR2EDW.js";
18
18
  import {
19
19
  createHostContextsMap
20
- } from "./chunk-FKZ5I53D.js";
20
+ } from "./chunk-WHLYMMI2.js";
21
21
  import "./chunk-XDSZO74H.js";
22
22
  import "./chunk-KMOOTBHM.js";
23
23
  import "./chunk-G2YT2GWF.js";
24
24
  import "./chunk-IHXJVKAE.js";
25
25
  import {
26
26
  PackageInfoClient
27
- } from "./chunk-3D3IB4YN.js";
27
+ } from "./chunk-DL3H4EMY.js";
28
28
  import "./chunk-SRWDPPLX.js";
29
29
  import "./chunk-WGDTG44V.js";
30
30
  import "./chunk-A2TSRXZD.js";
31
31
  import {
32
32
  Query,
33
33
  actual
34
- } from "./chunk-7BHHCB5C.js";
34
+ } from "./chunk-NWHKSRO3.js";
35
35
  import {
36
36
  SecurityArchive
37
- } from "./chunk-OWUICQFY.js";
37
+ } from "./chunk-XCDLOQZZ.js";
38
38
  import {
39
39
  commandUsage
40
40
  } from "./chunk-TLY4VGMH.js";
@@ -48,7 +48,7 @@ import "./chunk-SE2FSMBR.js";
48
48
  import "./chunk-HTOTG4TS.js";
49
49
  import "./chunk-APMYKJI2.js";
50
50
  import "./chunk-6D54UN4T.js";
51
- import "./chunk-VBDNOU76.js";
51
+ import "./chunk-6BQKR2FM.js";
52
52
  import "./chunk-U7TEQCBN.js";
53
53
  import "./chunk-XNLSTHDK.js";
54
54
  import "./chunk-PDWPFR5T.js";
@@ -11,8 +11,8 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  build
14
- } from "./chunk-7BHHCB5C.js";
15
- import "./chunk-OWUICQFY.js";
14
+ } from "./chunk-NWHKSRO3.js";
15
+ import "./chunk-XCDLOQZZ.js";
16
16
  import {
17
17
  commandUsage
18
18
  } from "./chunk-TLY4VGMH.js";
@@ -21,7 +21,7 @@ import "./chunk-SV4WK3KX.js";
21
21
  import "./chunk-GZ5MYMBT.js";
22
22
  import "./chunk-SE2FSMBR.js";
23
23
  import "./chunk-HTOTG4TS.js";
24
- import "./chunk-VBDNOU76.js";
24
+ import "./chunk-6BQKR2FM.js";
25
25
  import "./chunk-U7TEQCBN.js";
26
26
  import "./chunk-XNLSTHDK.js";
27
27
  import "./chunk-PDWPFR5T.js";
@@ -34,12 +34,12 @@ import {
34
34
  import "./chunk-SE2FSMBR.js";
35
35
  import {
36
36
  CacheEntry
37
- } from "./chunk-QVPNKMUU.js";
37
+ } from "./chunk-5KOLUYXH.js";
38
38
  import "./chunk-APMYKJI2.js";
39
39
  import {
40
40
  assertOk
41
41
  } from "./chunk-6D54UN4T.js";
42
- import "./chunk-VBDNOU76.js";
42
+ import "./chunk-6BQKR2FM.js";
43
43
  import "./chunk-U7TEQCBN.js";
44
44
  import "./chunk-XNLSTHDK.js";
45
45
  import {
@@ -11,7 +11,7 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  PackageInfoClient
14
- } from "./chunk-3D3IB4YN.js";
14
+ } from "./chunk-DL3H4EMY.js";
15
15
  import {
16
16
  Monorepo,
17
17
  PackageJson,
@@ -0,0 +1,76 @@
1
+ var global = globalThis;
2
+ import {Buffer} from "node:buffer";
3
+ import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
4
+ globalThis.setTimeout = _vlt_setTimeout;
5
+ globalThis.clearTimeout = _vlt_clearTimeout;
6
+ globalThis.setImmediate = _vlt_setImmediate;
7
+ globalThis.clearImmediate = _vlt_clearImmediate;
8
+ globalThis.setInterval = _vlt_setInterval;
9
+ globalThis.clearInterval = _vlt_clearInterval;
10
+ import {createRequire as _vlt_createRequire} from "node:module";
11
+ var require = _vlt_createRequire(import.meta.filename);
12
+ import {
13
+ error
14
+ } from "./chunk-WZWDS3W4.js";
15
+ import {
16
+ __glob
17
+ } from "./chunk-PZLD7RTK.js";
18
+
19
+ // import("./commands/**/*.ts") in ../../src/cli-sdk/src/load-command.ts
20
+ var globImport_commands_ts = __glob({
21
+ "./commands/access.ts": () => import("./access-WLKANIOE.js"),
22
+ "./commands/bugs.ts": () => import("./bugs-5Q3QSTWP.js"),
23
+ "./commands/build.ts": () => import("./build-XSFR63AW.js"),
24
+ "./commands/cache.ts": () => import("./cache-UVPK5J5A.js"),
25
+ "./commands/ci.ts": () => import("./ci-EDRETPUF.js"),
26
+ "./commands/config.ts": () => import("./config-OKBXU7TU.js"),
27
+ "./commands/create.ts": () => import("./create-R7BXYJSU.js"),
28
+ "./commands/deprecate.ts": () => import("./deprecate-YSUKBKQM.js"),
29
+ "./commands/dist-tag.ts": () => import("./dist-tag-MIGYSR4F.js"),
30
+ "./commands/docs.ts": () => import("./docs-4WVIN75H.js"),
31
+ "./commands/exec-cache.ts": () => import("./exec-cache-EA7GHIK7.js"),
32
+ "./commands/exec-local.ts": () => import("./exec-local-GM4LH56M.js"),
33
+ "./commands/exec.ts": () => import("./exec-IXHDQLAM.js"),
34
+ "./commands/help.ts": () => import("./help-TCXGBICU.js"),
35
+ "./commands/init.ts": () => import("./init-MWZDWQHM.js"),
36
+ "./commands/install.ts": () => import("./install-HPI5HU3C.js"),
37
+ "./commands/install/reporter.ts": () => import("./reporter-4KK2JNGO.js"),
38
+ "./commands/list.ts": () => import("./list-2CX6REPJ.js"),
39
+ "./commands/login.ts": () => import("./login-RAY23CVG.js"),
40
+ "./commands/logout.ts": () => import("./logout-ICB5OMGY.js"),
41
+ "./commands/outdated.ts": () => import("./outdated-FYHPXRMT.js"),
42
+ "./commands/pack.ts": () => import("./pack-E5MNPQXK.js"),
43
+ "./commands/ping.ts": () => import("./ping-REQ2KSAR.js"),
44
+ "./commands/pkg.ts": () => import("./pkg-YB4GSRII.js"),
45
+ "./commands/profile.ts": () => import("./profile-GKBW6GRI.js"),
46
+ "./commands/publish.ts": () => import("./publish-4ZQJYYLF.js"),
47
+ "./commands/query.ts": () => import("./query-SKXBF3MJ.js"),
48
+ "./commands/registry.ts": () => import("./registry-MQJJCWJY.js"),
49
+ "./commands/repo.ts": () => import("./repo-ACPTZI2C.js"),
50
+ "./commands/run-exec.ts": () => import("./run-exec-7VQX3OFG.js"),
51
+ "./commands/run.ts": () => import("./run-YW3ITX2A.js"),
52
+ "./commands/setup.ts": () => import("./setup-PLEKCMXN.js"),
53
+ "./commands/token.ts": () => import("./token-GB7RPE5J.js"),
54
+ "./commands/uninstall.ts": () => import("./uninstall-RLCECX37.js"),
55
+ "./commands/unpublish.ts": () => import("./unpublish-3ZXEAVHF.js"),
56
+ "./commands/update.ts": () => import("./update-VDZP6EZN.js"),
57
+ "./commands/version.ts": () => import("./version-MRELJPOK.js"),
58
+ "./commands/view.ts": () => import("./view-LCXMTGCJ.js"),
59
+ "./commands/whoami.ts": () => import("./whoami-PNRDBS45.js")
60
+ });
61
+
62
+ // ../../src/cli-sdk/src/load-command.ts
63
+ var loadCommand = async (command) => {
64
+ try {
65
+ return await globImport_commands_ts(`./commands/${command}.ts`);
66
+ } catch (e) {
67
+ throw error("Could not load command", {
68
+ found: command,
69
+ cause: e
70
+ });
71
+ }
72
+ };
73
+
74
+ export {
75
+ loadCommand
76
+ };
@@ -21,7 +21,7 @@ import {
21
21
  } from "./chunk-6D54UN4T.js";
22
22
  import {
23
23
  userAgent
24
- } from "./chunk-VBDNOU76.js";
24
+ } from "./chunk-6BQKR2FM.js";
25
25
  import {
26
26
  I,
27
27
  logRequest
@@ -26320,10 +26320,15 @@ var getKC = (identity) => {
26320
26320
  return nkc;
26321
26321
  };
26322
26322
  var isToken = (t) => typeof t === "string" && (t.startsWith("Bearer ") || t.startsWith("Basic "));
26323
- var deleteToken = async (registry, identity) => {
26323
+ var deleteToken = async (registry, identity, token) => {
26324
26324
  const kc = getKC(identity);
26325
26325
  await kc.load();
26326
26326
  kc.delete(normalizeRegistryKey(registry));
26327
+ if (token) {
26328
+ for (const key of kc.keysSync()) {
26329
+ if (kc.getSync(key) === token) kc.delete(key);
26330
+ }
26331
+ }
26327
26332
  await kc.save();
26328
26333
  };
26329
26334
  var setToken = async (registry, token, identity) => {
@@ -26346,9 +26351,19 @@ var getToken = async (registry, identity) => {
26346
26351
  if (tok) return `Bearer ${tok}`;
26347
26352
  return kc.get(key);
26348
26353
  };
26349
- var getTokenByURL = async (requestUrl, identity) => {
26354
+ var registryKeys = (o) => [
26355
+ ...new Set(
26356
+ [
26357
+ o.registry,
26358
+ ...Object.values(o.registries ?? {}),
26359
+ ...Object.values(o["scoped-registries"] ?? {}),
26360
+ ...Object.values(o["jsr-registries"] ?? {})
26361
+ ].filter((u) => !!u && URL.canParse(u)).map(normalizeRegistryKey)
26362
+ )
26363
+ ];
26364
+ var getTokenByURL = async (requestUrl, identity, keys = []) => {
26350
26365
  const normalized = normalizeRegistryKey(requestUrl);
26351
- const candidates = [...runtimeTokens.keys()];
26366
+ const candidates = [...runtimeTokens.keys(), ...keys];
26352
26367
  const envReg = process.env.VLT_REGISTRY;
26353
26368
  if (envReg) {
26354
26369
  candidates.push(normalizeRegistryKey(envReg));
@@ -27573,9 +27588,13 @@ var RegistryClient = class {
27573
27588
  agent;
27574
27589
  cache;
27575
27590
  identity;
27591
+ /** configured registry keys; `VLT_TOKEN_<key>` applies under each */
27592
+ registryKeys;
27576
27593
  staleWhileRevalidateFactor;
27577
27594
  #session = randomUUID();
27578
27595
  #decoded = /* @__PURE__ */ new WeakMap();
27596
+ // request() calls not settled yet, awaited by drain()
27597
+ #inFlight = /* @__PURE__ */ new Set();
27579
27598
  constructor(options) {
27580
27599
  const {
27581
27600
  cache = xdg.cache(),
@@ -27588,6 +27607,7 @@ var RegistryClient = class {
27588
27607
  // 48h for a 5min cache
27589
27608
  } = options;
27590
27609
  this.identity = identity;
27610
+ this.registryKeys = registryKeys(options);
27591
27611
  this.staleWhileRevalidateFactor = staleWhileRevalidateFactor;
27592
27612
  const path = resolve4(cache, "registry-client");
27593
27613
  const store = options.storeRoot ?? storeRoot(cache);
@@ -27710,7 +27730,7 @@ var RegistryClient = class {
27710
27730
  }
27711
27731
  }
27712
27732
  } finally {
27713
- await deleteToken(registry, this.identity);
27733
+ await deleteToken(registry, this.identity, tok);
27714
27734
  }
27715
27735
  }
27716
27736
  /**
@@ -27971,7 +27991,11 @@ var RegistryClient = class {
27971
27991
  o.headers = addHeader(
27972
27992
  o.headers,
27973
27993
  "authorization",
27974
- await getTokenByURL(String(u), this.identity)
27994
+ await getTokenByURL(
27995
+ String(u),
27996
+ this.identity,
27997
+ this.registryKeys
27998
+ )
27975
27999
  );
27976
28000
  logRequest(url, "start", { method: o.method });
27977
28001
  const requestStart = Date.now();
@@ -27994,7 +28018,28 @@ var RegistryClient = class {
27994
28018
  }
27995
28019
  return { statusCode: response.statusCode, body };
27996
28020
  }
28021
+ /**
28022
+ * Settle in-flight requests and their cache writes. Await before
28023
+ * removing the cache dir.
28024
+ */
28025
+ async drain() {
28026
+ do {
28027
+ await Promise.all(this.#inFlight);
28028
+ await this.cache.promise();
28029
+ } while (this.#inFlight.size);
28030
+ }
27997
28031
  async request(url, options = {}) {
28032
+ let settle;
28033
+ const tracked = new Promise((res) => settle = res);
28034
+ this.#inFlight.add(tracked);
28035
+ try {
28036
+ return await this.#request(url, options);
28037
+ } finally {
28038
+ this.#inFlight.delete(tracked);
28039
+ settle();
28040
+ }
28041
+ }
28042
+ async #request(url, options) {
27998
28043
  const u = typeof url === "string" ? new URL(url) : url;
27999
28044
  const {
28000
28045
  method = "GET",
@@ -28070,7 +28115,11 @@ var RegistryClient = class {
28070
28115
  options.headers = addHeader(
28071
28116
  options.headers,
28072
28117
  "authorization",
28073
- await getTokenByURL(String(u), this.identity)
28118
+ await getTokenByURL(
28119
+ String(u),
28120
+ this.identity,
28121
+ this.registryKeys
28122
+ )
28074
28123
  );
28075
28124
  }
28076
28125
  let response = null;
@@ -28134,7 +28183,7 @@ var RegistryClient = class {
28134
28183
  if (response.statusCode === 401) {
28135
28184
  const otpResult = await otplease(this, options, response);
28136
28185
  if (otpResult && "retry" in otpResult) {
28137
- return await this.request(url, otpResult.retry);
28186
+ return await this.#request(url, otpResult.retry);
28138
28187
  }
28139
28188
  if (otpResult && "bodyConsumed" in otpResult) {
28140
28189
  consumedBody = otpResult.bodyConsumed;
@@ -28162,7 +28211,7 @@ var RegistryClient = class {
28162
28211
  response.body.resume();
28163
28212
  const [nextURL, nextOptions] = redirect(options, result, url);
28164
28213
  if (nextOptions && nextURL) {
28165
- return await this.request(nextURL, nextOptions);
28214
+ return await this.#request(nextURL, nextOptions);
28166
28215
  }
28167
28216
  return result;
28168
28217
  }
@@ -28188,6 +28237,7 @@ export {
28188
28237
  deleteToken,
28189
28238
  setToken,
28190
28239
  getToken,
28240
+ registryKeys,
28191
28241
  getTokenByURL,
28192
28242
  CacheEntry,
28193
28243
  oidc,
@@ -14,7 +14,7 @@ var require = _vlt_createRequire(import.meta.filename);
14
14
  var package_default = {
15
15
  name: "@vltpkg/user-agent",
16
16
  description: "The User-Agent string that vlt sends with every outbound request",
17
- version: "1.3.7",
17
+ version: "1.3.8",
18
18
  repository: {
19
19
  type: "git",
20
20
  url: "git+https://github.com/vltpkg/vltpkg.git",
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  addKey,
17
17
  asDependency
18
- } from "./chunk-7BHHCB5C.js";
18
+ } from "./chunk-NWHKSRO3.js";
19
19
  import {
20
20
  joinDepIDTuple,
21
21
  splitDepID
@@ -11,11 +11,13 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  PackageInfoClient
14
- } from "./chunk-3D3IB4YN.js";
14
+ } from "./chunk-DL3H4EMY.js";
15
15
  import {
16
+ RollbackRemove,
17
+ cmdShim,
16
18
  findCmdShimIfExists,
17
19
  install
18
- } from "./chunk-7BHHCB5C.js";
20
+ } from "./chunk-NWHKSRO3.js";
19
21
  import {
20
22
  PathScurry
21
23
  } from "./chunk-CB65DPZ2.js";
@@ -221,7 +223,7 @@ var vlxInstall = async (spec, options, promptFn) => {
221
223
  };
222
224
 
223
225
  // ../../src/vlx/src/resolve.ts
224
- import { resolve as resolve6 } from "node:path";
226
+ import { resolve as resolve7 } from "node:path";
225
227
 
226
228
  // ../../src/vlx/src/add-to-path.ts
227
229
  import { delimiter } from "node:path";
@@ -279,6 +281,72 @@ var findPackage = async (name, projectRoot, packageJson) => {
279
281
  }
280
282
  };
281
283
 
284
+ // ../../src/vlx/src/local.ts
285
+ import { createHash as createHash2 } from "node:crypto";
286
+ import {
287
+ mkdir as mkdir2,
288
+ mkdtemp,
289
+ readFile,
290
+ realpath,
291
+ rename,
292
+ rm as rm2
293
+ } from "node:fs/promises";
294
+ import { basename as basename2, resolve as resolve6 } from "node:path";
295
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
296
+ var localDir = async (spec) => {
297
+ const { type, file } = spec.final;
298
+ if (type !== "file" || !file) return;
299
+ const dir = resolve6(file);
300
+ return await dirExists(dir) ? dir : void 0;
301
+ };
302
+ var vlxLocal = async (dir, packageJson) => {
303
+ const manifest = packageJson.read(dir);
304
+ const bins = Object.entries(manifest.bin ?? {});
305
+ const heads = await Promise.all(
306
+ bins.map(async ([k, v]) => {
307
+ const target = resolve6(dir, v);
308
+ const data = await readFile(target, "utf8").catch(
309
+ (cause) => {
310
+ throw error(`Bin target not found: ${k} -> ${v}`, {
311
+ path: target,
312
+ cause
313
+ });
314
+ }
315
+ );
316
+ return `\0${k}\0${v}\0${data.trim().split(/\r*\n/)[0]}`;
317
+ })
318
+ );
319
+ const key = createHash2("sha512").update(dir + heads.join("")).digest("hex").substring(0, 16);
320
+ const cache = new XDG("vlt/vlx-local").cache();
321
+ await mkdir2(cache, { recursive: true });
322
+ const path = resolve6(await realpath(cache), key);
323
+ if (!await dirExists(path)) {
324
+ const tmp = await mkdtemp(`${path}-`);
325
+ const remover = new RollbackRemove();
326
+ await Promise.all(
327
+ bins.map(
328
+ ([k, v]) => cmdShim(
329
+ resolve6(dir, v),
330
+ resolve6(tmp, "node_modules/.bin", k),
331
+ remover
332
+ )
333
+ )
334
+ );
335
+ remover.confirm();
336
+ await rename(tmp, path).catch(async (er) => {
337
+ if (!await dirExists(path)) throw er;
338
+ await rm2(tmp, { recursive: true, force: true });
339
+ });
340
+ }
341
+ return {
342
+ path,
343
+ name: manifest.name ?? basename2(dir),
344
+ version: manifest.version,
345
+ resolved: String(pathToFileURL2(dir)),
346
+ arg0: inferDefaultExecutable(manifest)?.[0]
347
+ };
348
+ };
349
+
282
350
  // ../../src/vlx/src/resolve.ts
283
351
  var vlxResolve = async (positionals, options, promptFn) => {
284
352
  const noArgs = positionals.length === 0;
@@ -289,22 +357,30 @@ var vlxResolve = async (positionals, options, promptFn) => {
289
357
  if (!arg0) {
290
358
  return void 0;
291
359
  }
292
- const found = await findExecutable(arg0, projectRoot);
360
+ const found = arg0 === "." || arg0 === ".." || /[\\/]/.test(arg0) ? void 0 : await findExecutable(arg0, projectRoot);
293
361
  if (found) return found;
294
362
  pkgOption = arg0;
295
363
  arg0 = void 0;
296
364
  }
297
365
  let pkgTarget = void 0;
366
+ let dir;
298
367
  if (pkgOption) {
299
- const pkgSpec = Spec.parseArgs(pkgOption, options);
368
+ const pkgSpec = Spec.parseArgs(
369
+ // bare . / .. are paths, not names
370
+ pkgOption === "." || pkgOption === ".." ? `${pkgOption}/` : pkgOption,
371
+ options
372
+ );
300
373
  const { name, bareSpec } = pkgSpec.final;
301
374
  if (!bareSpec) {
302
375
  pkgTarget = await findPackage(name, projectRoot, packageJson);
376
+ } else {
377
+ dir = await localDir(pkgSpec);
378
+ if (dir) pkgTarget = await vlxLocal(dir, packageJson);
303
379
  }
304
380
  pkgTarget ??= await vlxInstall(pkgSpec, options, promptFn);
305
381
  }
306
382
  if (pkgTarget) {
307
- addToPATH(resolve6(pkgTarget.path, "node_modules/.bin"));
383
+ addToPATH(resolve7(pkgTarget.path, "node_modules/.bin"));
308
384
  if (noArgs) return void 0;
309
385
  }
310
386
  if (!arg0) {
@@ -316,7 +392,7 @@ var vlxResolve = async (positionals, options, promptFn) => {
316
392
  arg0 = pkgTarget.arg0;
317
393
  if (!arg0) {
318
394
  const { name, version, bin } = packageJson.read(
319
- resolve6(pkgTarget.path, "node_modules", pkgTarget.name)
395
+ dir ?? resolve7(pkgTarget.path, "node_modules", pkgTarget.name)
320
396
  );
321
397
  throw error("Package executable could not be inferred", {
322
398
  name,
@@ -299,9 +299,38 @@ var PackageInfoClient = class {
299
299
  #resolveWaiters = /* @__PURE__ */ new Map();
300
300
  #registryClientPromise;
301
301
  #tarPoolPromise;
302
+ // fire-and-forget work, settled by drain()
303
+ #background = /* @__PURE__ */ new Set();
304
+ #inBackground(p) {
305
+ const done = () => {
306
+ this.#background.delete(tracked);
307
+ };
308
+ const tracked = p.then(done, done);
309
+ this.#background.add(tracked);
310
+ }
311
+ /**
312
+ * Wind the client down: abort open resolve streams, settle background
313
+ * work (manifest cache writes, capabilities, hedges), drain the registry
314
+ * client (in-flight requests, cache writes). Await before removing the
315
+ * cache dir or exiting.
316
+ */
317
+ async drain() {
318
+ for (const [sent, owner] of this.#resolveOwners) {
319
+ this.#resolveOwners.delete(sent);
320
+ this.#resolveSent.delete(sent);
321
+ owner.controller.abort();
322
+ }
323
+ while (this.#background.size) {
324
+ await Promise.all(this.#background);
325
+ }
326
+ if (this.#registryClientPromise) {
327
+ await (await this.#registryClientPromise).drain();
328
+ }
329
+ if (this.#background.size) await this.drain();
330
+ }
302
331
  async getRegistryClient() {
303
332
  if (this.#registryClient) return this.#registryClient;
304
- this.#registryClientPromise ??= import("./src-6CJEMSVB.js").then(({ RegistryClient }) => {
333
+ this.#registryClientPromise ??= import("./src-PXDFMQ6W.js").then(({ RegistryClient }) => {
305
334
  this.#registryClient = new RegistryClient(this.options);
306
335
  return this.#registryClient;
307
336
  });
@@ -332,8 +361,7 @@ var PackageInfoClient = class {
332
361
  if (!registry || !isStableSelector(f)) return false;
333
362
  const client = this.#registryClient;
334
363
  if (!client) {
335
- void this.capabilities(registry).catch(() => {
336
- });
364
+ this.#inBackground(this.capabilities(registry));
337
365
  return true;
338
366
  }
339
367
  const caps = peekCapabilities(client, registry);
@@ -379,10 +407,6 @@ var PackageInfoClient = class {
379
407
  this.#storeRoot = options.storeRoot ?? storeRoot(this.#cachePath);
380
408
  const linker = options["store-linker"];
381
409
  this.#storeLinker = linker && storeLinkers.has(linker) ? linker : "unpack";
382
- void mkdir(pathResolve(this.#cachePath, "package-info"), {
383
- recursive: true
384
- }).catch(() => {
385
- });
386
410
  }
387
411
  async extract(spec, target, options = {}) {
388
412
  if (typeof spec === "string")
@@ -560,7 +584,7 @@ var PackageInfoClient = class {
560
584
  }
561
585
  case "remote": {
562
586
  const rc = await this.getRegistryClient();
563
- const { CacheEntry: Entry, cacheKey } = await import("./src-6CJEMSVB.js");
587
+ const { CacheEntry: Entry, cacheKey } = await import("./src-PXDFMQ6W.js");
564
588
  const key = cacheKey("GET", new URL(r.resolved));
565
589
  const unzipped = (entry) => {
566
590
  try {
@@ -934,6 +958,7 @@ var PackageInfoClient = class {
934
958
  inflight
935
959
  );
936
960
  inflight.requests.add(promise);
961
+ this.#inBackground(promise);
937
962
  const clear = () => {
938
963
  inflight.requests.delete(promise);
939
964
  if (this.#resolveOwners.get(sent) === owner)
@@ -1034,6 +1059,7 @@ var PackageInfoClient = class {
1034
1059
  if (early !== graceOver) return early ?? await fetch();
1035
1060
  debug("resolve hedge %s", key);
1036
1061
  const hedge = fetch();
1062
+ this.#inBackground(hedge);
1037
1063
  const outcome = await Promise.race([
1038
1064
  arrival,
1039
1065
  settled,
@@ -1080,8 +1106,7 @@ var PackageInfoClient = class {
1080
1106
  const json = JSON.parse(cached);
1081
1107
  if (st.mtimeMs < this.#manifestCacheMinAge || json.__VLT_MANIFEST_CACHE_TIMESTAMP !== void 0) {
1082
1108
  this.#manifestWritePaths.delete(cachePath);
1083
- void unlink(cachePath).catch(() => {
1084
- });
1109
+ this.#inBackground(unlink(cachePath));
1085
1110
  throw new Error("manifest cache expired");
1086
1111
  }
1087
1112
  if (json.__VLT_PACKUMENT) {
@@ -1104,10 +1129,12 @@ var PackageInfoClient = class {
1104
1129
  const vlt = this.#vltPackuments.has(
1105
1130
  `${f.registry}${f.name}`
1106
1131
  );
1107
- void this.#writeManifestCache(
1108
- cachePath,
1109
- JSON.stringify(
1110
- vlt ? { ...mani, __VLT_PACKUMENT: true } : mani
1132
+ this.#inBackground(
1133
+ this.#writeManifestCache(
1134
+ cachePath,
1135
+ JSON.stringify(
1136
+ vlt ? { ...mani, __VLT_PACKUMENT: true } : mani
1137
+ )
1111
1138
  )
1112
1139
  );
1113
1140
  }
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-RIYFGX27.js";
15
15
  import {
16
16
  createHostContextsMap
17
- } from "./chunk-FKZ5I53D.js";
17
+ } from "./chunk-WHLYMMI2.js";
18
18
  import {
19
19
  stderr,
20
20
  stdout,
@@ -27,7 +27,7 @@ import {
27
27
  Query,
28
28
  actual,
29
29
  isRunResult
30
- } from "./chunk-7BHHCB5C.js";
30
+ } from "./chunk-NWHKSRO3.js";
31
31
  import {
32
32
  Monorepo
33
33
  } from "./chunk-CB65DPZ2.js";
@@ -15,7 +15,7 @@ import {
15
15
  pairsToRecords,
16
16
  registrySelectionFields,
17
17
  registrySelectors
18
- } from "./chunk-L3K2ZAOO.js";
18
+ } from "./chunk-43HNQWPQ.js";
19
19
  import {
20
20
  normalizeRegistryURL
21
21
  } from "./chunk-A2TSRXZD.js";