@vltpkg/cli-js 1.0.0-rc.32 → 1.0.0-rc.34

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 (85) hide show
  1. package/{access-SQZRJLJA.js → access-SXQICNAN.js} +23 -12
  2. package/{bugs-BMZ5UERM.js → bugs-OOPMFRCI.js} +19 -17
  3. package/{build-LGQI6OGM.js → build-HDXI5OA7.js} +13 -9
  4. package/{cache-JWHNATAX.js → cache-RW4Y4XNQ.js} +19 -14
  5. package/cache-unzip-src-unzip.js +434 -428
  6. package/{chunk-6YXVQ5HC.js → chunk-2PLIV3N3.js} +1 -27
  7. package/{chunk-G6PG3AGN.js → chunk-3SQ5Y324.js} +11 -8
  8. package/{chunk-ZUP6UTME.js → chunk-4RZDJQ5U.js} +42 -61
  9. package/{chunk-M2WD7IBO.js → chunk-4ZXA6RLP.js} +1 -1
  10. package/{chunk-R44FR7BY.js → chunk-7NHXV6AH.js} +439 -433
  11. package/{chunk-SIXXDCBI.js → chunk-CCQYIYTA.js} +7 -7
  12. package/{chunk-FXDRM4ZO.js → chunk-CLVRCGOZ.js} +247 -235
  13. package/{chunk-YCQTLBWF.js → chunk-CNSTFT7U.js} +1 -1
  14. package/{chunk-7XE7OES7.js → chunk-D5CP6O6G.js} +3 -3
  15. package/{chunk-YQXDHMHG.js → chunk-E5YE7UTZ.js} +3167 -2991
  16. package/chunk-E74WGW5C.js +49 -0
  17. package/{chunk-DFNHGGGV.js → chunk-EFWPI6IY.js} +1 -1
  18. package/{chunk-5UXEBLLT.js → chunk-EHEVBLDB.js} +68 -7
  19. package/{chunk-JBVLIV37.js → chunk-EQ633HIM.js} +14 -13
  20. package/{chunk-DM3WGEVB.js → chunk-F2FKLPZD.js} +7 -7
  21. package/chunk-FAG776ZD.js +137 -0
  22. package/{chunk-HQ4US6G3.js → chunk-FWKQ7YDF.js} +1049 -980
  23. package/chunk-HB7CKTYO.js +75 -0
  24. package/{chunk-KRGA5VLT.js → chunk-ICJRCXSG.js} +31 -27
  25. package/{chunk-FBTBHRPG.js → chunk-LCDBW6IT.js} +1 -1
  26. package/{chunk-IAKUGHGT.js → chunk-MT76WHSM.js} +1 -1
  27. package/{chunk-3TVABXAG.js → chunk-MU7Y4R5E.js} +3 -3
  28. package/{chunk-JKAZKVQU.js → chunk-PW6S6AIO.js} +15 -11
  29. package/{chunk-DI2CYYXF.js → chunk-U6DM3ROE.js} +706 -442
  30. package/chunk-UBLFPJHV.js +40 -0
  31. package/{chunk-SDBTQF2Y.js → chunk-UCD3RJYG.js} +5 -5
  32. package/{chunk-XFQ2EH5D.js → chunk-VM2RMMY4.js} +3 -3
  33. package/{chunk-DIKKTUBV.js → chunk-VZ7UNZHR.js} +3 -3
  34. package/{chunk-2V4AQPBR.js → chunk-WP6CYBPM.js} +81 -46
  35. package/{chunk-LEX7YPHR.js → chunk-WXMYKCQW.js} +118 -92
  36. package/{chunk-LRPTCGTW.js → chunk-XA47WS4N.js} +11 -15
  37. package/{chunk-NLFBANVO.js → chunk-Y7CQIZ7Y.js} +106 -150
  38. package/{ci-FQJANSQW.js → ci-MTYU2K2A.js} +14 -10
  39. package/cli-package.json +6 -2
  40. package/{config-4KQTTXJH.js → config-6NXV2BXW.js} +15 -13
  41. package/{config-LRL3N7TN.js → config-TVAXCTQO.js} +13 -11
  42. package/{create-KN6AXEA6.js → create-LXI5DCDW.js} +24 -19
  43. package/{deprecate-P26WHVFB.js → deprecate-2AQBL5XT.js} +22 -14
  44. package/{devtools-6NFQDW4L.js → devtools-HGLF4KAO.js} +82 -28
  45. package/{dist-tag-FA2BT7SA.js → dist-tag-BFSYLRIH.js} +16 -9
  46. package/{docs-OAPIY4SC.js → docs-ADPJ4B4C.js} +19 -17
  47. package/{exec-CVZGHJZS.js → exec-GMS54RAC.js} +24 -19
  48. package/{exec-cache-3AHODVRN.js → exec-cache-R5LVZL5Z.js} +22 -17
  49. package/{exec-local-I4OJX76E.js → exec-local-TVCLZGIM.js} +17 -14
  50. package/{help-QFIQSPNS.js → help-6CECUD6C.js} +5 -4
  51. package/{init-QLADIAP5.js → init-XXFLGYVP.js} +12 -10
  52. package/{install-B7CU2BLC.js → install-6KMXYSF5.js} +27 -12
  53. package/{list-OTFV3LOM.js → list-RUO3SUKY.js} +20 -15
  54. package/{login-LG2ZOIDQ.js → login-6I2CGO7I.js} +23 -9
  55. package/{logout-KUI773AM.js → logout-JTU4BJKH.js} +19 -8
  56. package/{pack-C55TTBIQ.js → pack-NCWH2TUA.js} +17 -13
  57. package/package.json +8 -1
  58. package/{ping-VNUOC26G.js → ping-4MEAC2WD.js} +17 -10
  59. package/{pkg-H4RJEBK5.js → pkg-ENSKG6G7.js} +13 -11
  60. package/{profile-DIJ5JUSE.js → profile-62YHNFSO.js} +16 -8
  61. package/{publish-XF2TRBPH.js → publish-PPY724N2.js} +58 -23
  62. package/{query-BGP5JMJ7.js → query-NLWXKOOT.js} +61 -15
  63. package/registry-QGI44LG4.js +117 -0
  64. package/registry-client-package.json +6 -2
  65. package/registry-client-src-revalidate.js +1245 -977
  66. package/{repo-NCEHK7KB.js → repo-BFRAXIVU.js} +19 -17
  67. package/{reporter-OB6SNHOZ.js → reporter-2XBYWAVU.js} +3 -2
  68. package/{run-ZNJJYEJF.js → run-7O65747G.js} +17 -14
  69. package/{run-exec-F5OV7MVN.js → run-exec-2OYWHL6K.js} +19 -14
  70. package/security-archive-src-update-expired.js +16 -11
  71. package/setup-MMIDAIJI.js +181 -0
  72. package/{src-M3WI7TSB.js → src-OK3KHDYR.js} +25 -17
  73. package/{token-KXCVRJGF.js → token-VLVXUW54.js} +20 -9
  74. package/{uninstall-33SUWR6K.js → uninstall-TAG6QIAG.js} +15 -11
  75. package/{unpublish-7AZPBZF2.js → unpublish-Y4L5J2IA.js} +17 -9
  76. package/{update-2EQF6IKZ.js → update-RYH4RKBS.js} +14 -10
  77. package/{version-HFYI3SEX.js → version-COHB32ON.js} +12 -10
  78. package/{view-C5OT36OB.js → view-P7U4MF43.js} +18 -14
  79. package/vlr.js +1 -1
  80. package/vlrx.js +1 -1
  81. package/vlt.js +1 -1
  82. package/vlx.js +1 -1
  83. package/vlxl.js +1 -1
  84. package/{whoami-KKFV3XR6.js → whoami-47MVFMZC.js} +19 -8
  85. package/chunk-FXIBCUIM.js +0 -73
@@ -0,0 +1,49 @@
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
+
13
+ // ../../node_modules/.vlt/~npm~package-json-from-dist@1.0.1/node_modules/package-json-from-dist/dist/esm/index.js
14
+ import { readFileSync } from "node:fs";
15
+ import { dirname, resolve, sep } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+ var NM = `${sep}node_modules${sep}`;
18
+ var STORE = `.store${sep}`;
19
+ var PKG = `${sep}package${sep}`;
20
+ var DIST = `${sep}dist${sep}`;
21
+ var findPackageJson = (from, pathFromSrc = "../package.json") => {
22
+ const f = typeof from === "object" || from.startsWith("file://") ? fileURLToPath(from) : from;
23
+ const __dirname = dirname(f);
24
+ const nms = __dirname.lastIndexOf(NM);
25
+ if (nms !== -1) {
26
+ const nm = __dirname.substring(0, nms + NM.length);
27
+ const pkgDir = __dirname.substring(nms + NM.length);
28
+ if (pkgDir.startsWith(STORE)) {
29
+ const pkg = pkgDir.indexOf(PKG, STORE.length);
30
+ if (pkg) {
31
+ return resolve(nm, pkgDir.substring(0, pkg + PKG.length), "package.json");
32
+ }
33
+ }
34
+ const pkgName = pkgDir.startsWith("@") ? pkgDir.split(sep, 2).join(sep) : String(pkgDir.split(sep)[0]);
35
+ return resolve(nm, pkgName, "package.json");
36
+ } else {
37
+ const d = __dirname.lastIndexOf(DIST);
38
+ if (d !== -1) {
39
+ return resolve(__dirname.substring(0, d), "package.json");
40
+ } else {
41
+ return resolve(__dirname, pathFromSrc);
42
+ }
43
+ }
44
+ };
45
+ var loadPackageJson = (from, pathFromSrc = "../package.json") => JSON.parse(readFileSync(findPackageJson(from, pathFromSrc), "utf8"));
46
+
47
+ export {
48
+ loadPackageJson
49
+ };
@@ -12,7 +12,7 @@ var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  isError,
14
14
  isObject
15
- } from "./chunk-6YXVQ5HC.js";
15
+ } from "./chunk-2PLIV3N3.js";
16
16
 
17
17
  // ../../src/output/src/error.ts
18
18
  var parseError = (err) => {
@@ -17,24 +17,31 @@ import {
17
17
  import {
18
18
  generateDefaultHelp,
19
19
  generateFullHelp
20
- } from "./chunk-NLFBANVO.js";
20
+ } from "./chunk-Y7CQIZ7Y.js";
21
21
  import {
22
22
  isViewClass
23
23
  } from "./chunk-RXNA2XCX.js";
24
24
  import {
25
25
  parseError
26
- } from "./chunk-DFNHGGGV.js";
26
+ } from "./chunk-EFWPI6IY.js";
27
27
  import {
28
28
  isGraphRunError,
29
29
  splitDepID
30
- } from "./chunk-IAKUGHGT.js";
30
+ } from "./chunk-MT76WHSM.js";
31
+ import {
32
+ hasConfiguredRegistry,
33
+ missingRegistryError
34
+ } from "./chunk-FAG776ZD.js";
31
35
  import {
32
36
  defaultView
33
- } from "./chunk-2V4AQPBR.js";
37
+ } from "./chunk-WP6CYBPM.js";
38
+ import {
39
+ emitter
40
+ } from "./chunk-UBLFPJHV.js";
34
41
  import {
35
42
  isErrorWithCause,
36
43
  isObject
37
- } from "./chunk-6YXVQ5HC.js";
44
+ } from "./chunk-2PLIV3N3.js";
38
45
  import {
39
46
  XDG
40
47
  } from "./chunk-XNLSTHDK.js";
@@ -53,6 +60,8 @@ var formatURL = (v, format) => v instanceof URL ? v.toString() : (
53
60
  /* c8 ignore next */
54
61
  format(v)
55
62
  );
63
+ var hasCustomToString = (v) => isObject(v) && v.toString !== Object.prototype.toString;
64
+ var formatToString = (v, format) => hasCustomToString(v) ? v.toString() : format(v);
56
65
  var formatArray = (v, format, joiner = ", ") => Array.isArray(v) ? v.join(joiner) : (
57
66
  /* c8 ignore next */
58
67
  format(v)
@@ -191,7 +200,7 @@ var printCode = (err, usage, stderr2, format) => {
191
200
  stderr2(indent(`While fetching: ${formatURL(url, format)}`));
192
201
  }
193
202
  if (spec) {
194
- stderr2(indent(`To satisfy: ${format(spec)}`));
203
+ stderr2(indent(`To satisfy: ${formatToString(spec, format)}`));
195
204
  }
196
205
  if (from) {
197
206
  stderr2(indent(`From: ${format(from)}`));
@@ -381,6 +390,48 @@ var supportsColor = {
381
390
  stderr: createSupportsColor({ isTTY: tty.isatty(2) })
382
391
  };
383
392
 
393
+ // ../../src/cli-sdk/src/verbose-log.ts
394
+ var rank = {
395
+ silent: 0,
396
+ error: 1,
397
+ warn: 2,
398
+ info: 3,
399
+ verbose: 4,
400
+ debug: 5
401
+ };
402
+ var isVerbose = (level) => rank[level] >= rank.verbose;
403
+ var isDebug = (level) => rank[level] >= rank.debug;
404
+ var identityStyle = (_f, s) => s;
405
+ var tagStyle = (state, statusCode) => {
406
+ switch (state) {
407
+ case "cache":
408
+ case "stale":
409
+ case "304":
410
+ return "green";
411
+ case "start":
412
+ return "gray";
413
+ case "complete":
414
+ return statusCode !== void 0 && statusCode >= 400 ? "red" : "green";
415
+ }
416
+ };
417
+ var formatRequestEvent = (event, style = identityStyle) => {
418
+ const { url, state, method = "GET", statusCode, durationMs } = event;
419
+ const tag = state === "complete" ? String(statusCode ?? "") : state;
420
+ const duration = durationMs === void 0 ? "" : style("gray", ` (${durationMs}ms)`);
421
+ return `${style(tagStyle(state, statusCode), tag.padEnd(8))} ${method} ${String(url)}${duration}`;
422
+ };
423
+ var startRequestLog = (level, write, style = identityStyle) => {
424
+ if (!isVerbose(level)) return () => {
425
+ };
426
+ const debug = isDebug(level);
427
+ const handler = (event) => {
428
+ if (event.state === "start" && !debug) return;
429
+ write(formatRequestEvent(event, style));
430
+ };
431
+ emitter.on("request", handler);
432
+ return () => emitter.off("request", handler);
433
+ };
434
+
384
435
  // ../../src/cli-sdk/src/output.ts
385
436
  var isCI = () => !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.CIRCLECI || process.env.JENKINS_URL || process.env.BUILDKITE || process.env.TRAVIS);
386
437
  var supportsColor2 = (stream) => {
@@ -428,7 +479,7 @@ var startView = (conf, opts, views, { start } = { start: Date.now() }) => {
428
479
  var outputCommand = async (cliCommand, conf, { start, vltVersion } = {
429
480
  start: Date.now()
430
481
  }) => {
431
- const { usage, views, command } = cliCommand;
482
+ const { usage, views, command, needsRegistry } = cliCommand;
432
483
  const stdoutColor = conf.values.color ?? supportsColor2(process.stdout);
433
484
  const stderrColor = conf.values.color ?? supportsColor2(process.stderr);
434
485
  if (conf.values.help) {
@@ -442,6 +493,11 @@ var outputCommand = async (cliCommand, conf, { start, vltVersion } = {
442
493
  }
443
494
  if (stdoutColor) styleTextStdout = styleText;
444
495
  if (stderrColor) styleTextStderr = styleText;
496
+ const stopRequestLog = startRequestLog(
497
+ conf.values.loglevel,
498
+ (line) => stderr(line),
499
+ styleTextStderr
500
+ );
445
501
  const { onDone, onError } = startView(
446
502
  conf,
447
503
  // assume views will always output to stdout so use color support from there
@@ -452,7 +508,11 @@ var outputCommand = async (cliCommand, conf, { start, vltVersion } = {
452
508
  const telemetryEnabled = conf.values.telemetry;
453
509
  const commandName = conf.command;
454
510
  try {
511
+ if (needsRegistry && !hasConfiguredRegistry(conf)) {
512
+ throw missingRegistryError();
513
+ }
455
514
  const output = await onDone(await command(conf));
515
+ stopRequestLog();
456
516
  const duration_ms = Date.now() - start;
457
517
  trackCommand(
458
518
  {
@@ -480,6 +540,7 @@ var outputCommand = async (cliCommand, conf, { start, vltVersion } = {
480
540
  }
481
541
  await flush();
482
542
  } catch (err) {
543
+ stopRequestLog();
483
544
  onError?.(err);
484
545
  process.exitCode ||= 1;
485
546
  const duration_ms = Date.now() - start;
@@ -10,20 +10,20 @@ 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
- It,
14
- Zn,
13
+ Ct,
14
+ Qn,
15
15
  require_lib
16
- } from "./chunk-HQ4US6G3.js";
16
+ } from "./chunk-FWKQ7YDF.js";
17
17
  import {
18
18
  minimatch
19
- } from "./chunk-KRGA5VLT.js";
20
- import {
21
- Spec2 as Spec
22
- } from "./chunk-JKAZKVQU.js";
19
+ } from "./chunk-ICJRCXSG.js";
23
20
  import {
24
21
  parse,
25
22
  stringify
26
23
  } from "./chunk-HTOTG4TS.js";
24
+ import {
25
+ Spec2 as Spec
26
+ } from "./chunk-PW6S6AIO.js";
27
27
  import {
28
28
  error
29
29
  } from "./chunk-WZWDS3W4.js";
@@ -32,9 +32,9 @@ import {
32
32
  __toESM
33
33
  } from "./chunk-PZLD7RTK.js";
34
34
 
35
- // ../../node_modules/.vlt/~npm~ignore@7.0.5/node_modules/ignore/index.js
35
+ // ../../node_modules/.vlt/~npm~ignore@7.0.6/node_modules/ignore/index.js
36
36
  var require_ignore = __commonJS({
37
- "../../node_modules/.vlt/~npm~ignore@7.0.5/node_modules/ignore/index.js"(exports, module) {
37
+ "../../node_modules/.vlt/~npm~ignore@7.0.6/node_modules/ignore/index.js"(exports, module) {
38
38
  function makeArray(subject) {
39
39
  return Array.isArray(subject) ? subject : [subject];
40
40
  }
@@ -65,6 +65,7 @@ var require_ignore = __commonJS({
65
65
  REGEX_REGEXP_RANGE,
66
66
  (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
67
67
  );
68
+ var negateRange = (range) => range.startsWith("!") || range.startsWith("\\^") ? `^${range.slice(range[0] === "!" ? 1 : 2)}` : range;
68
69
  var cleanRangeBackSlash = (slashes) => {
69
70
  const { length } = slashes;
70
71
  return slashes.slice(0, length - length % 2);
@@ -142,7 +143,7 @@ var require_ignore = __commonJS({
142
143
  // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
143
144
  // > under directory "foo".
144
145
  // Notice that the '*'s have been replaced as '\\*'
145
- /^\^*\\\*\\\*\\\//,
146
+ /^\^*(?:\\\*\\\*\\\/)+/,
146
147
  // '**/foo' <-> 'foo'
147
148
  () => "^(?:.*\\/)?"
148
149
  ],
@@ -197,7 +198,7 @@ var require_ignore = __commonJS({
197
198
  // > can be used to match one of the characters in a range.
198
199
  // `\` is escaped by step 3
199
200
  /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
200
- (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
201
+ (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${negateRange(sanitizeRange(range))}${endEscape}]` : "[]" : "[]"
201
202
  ],
202
203
  // ending
203
204
  [
@@ -727,7 +728,7 @@ var packTarball = async (manifest, dir, config) => {
727
728
  try {
728
729
  config.options.packageJson.write(packDir, processedManifest);
729
730
  const packFilter = buildPackFilter(manifest, packDir);
730
- const tarballData = await Zn(
731
+ const tarballData = await Qn(
731
732
  {
732
733
  cwd: packDir,
733
734
  gzip: true,
@@ -740,7 +741,7 @@ var packTarball = async (manifest, dir, config) => {
740
741
  let unpackedSize = 0;
741
742
  const files = [];
742
743
  await new Promise((resolve, reject) => {
743
- const stream = It({
744
+ const stream = Ct({
744
745
  onentry: (entry) => {
745
746
  if (entry.type === "File") {
746
747
  unpackedSize += entry.size;
@@ -13,13 +13,13 @@ import {
13
13
  asDepID,
14
14
  baseDepID,
15
15
  splitDepID
16
- } from "./chunk-IAKUGHGT.js";
16
+ } from "./chunk-MT76WHSM.js";
17
17
  import {
18
- L
19
- } from "./chunk-R44FR7BY.js";
18
+ I
19
+ } from "./chunk-7NHXV6AH.js";
20
20
  import {
21
21
  loadPackageJson
22
- } from "./chunk-2V4AQPBR.js";
22
+ } from "./chunk-E74WGW5C.js";
23
23
  import {
24
24
  XDG
25
25
  } from "./chunk-XNLSTHDK.js";
@@ -33,7 +33,7 @@ import { spawn } from "node:child_process";
33
33
  import { mkdirSync } from "node:fs";
34
34
  import { dirname } from "node:path";
35
35
 
36
- // ../../node_modules/.vlt/~npm~is-network-error@1.3.1/node_modules/is-network-error/index.js
36
+ // ../../node_modules/.vlt/~npm~is-network-error@1.3.2/node_modules/is-network-error/index.js
37
37
  var objectToString = Object.prototype.toString;
38
38
  var isError = (value) => objectToString.call(value) === "[object Error]";
39
39
  var errorMessages = /* @__PURE__ */ new Set([
@@ -60,7 +60,7 @@ function isNetworkError(error2) {
60
60
  return false;
61
61
  }
62
62
  const { message, stack } = error2;
63
- if (message === "Load failed") {
63
+ if (message === "Load failed" || message.startsWith("Load failed (") && message.endsWith(")")) {
64
64
  return stack === void 0 || "__sentry_captured__" in error2;
65
65
  }
66
66
  if (message.startsWith("error sending request for url")) {
@@ -265,7 +265,7 @@ var { version } = loadPackageJson(
265
265
  import.meta.filename,
266
266
  "cli-package.json"
267
267
  );
268
- var SecurityArchive = class _SecurityArchive extends L {
268
+ var SecurityArchive = class _SecurityArchive extends I {
269
269
  #expired = /* @__PURE__ */ new Set();
270
270
  #path;
271
271
  #retries;
@@ -0,0 +1,137 @@
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
+ defaultRegistries
14
+ } from "./chunk-PW6S6AIO.js";
15
+ import {
16
+ error
17
+ } from "./chunk-WZWDS3W4.js";
18
+
19
+ // ../../src/cli-sdk/src/select-registry.ts
20
+ import { createInterface } from "node:readline/promises";
21
+ var selectRegistry = async (candidates, {
22
+ defaultAlias,
23
+ input = process.stdin,
24
+ output = process.stdout
25
+ } = {}) => {
26
+ const defaultIndex = Math.max(
27
+ candidates.findIndex((c) => c.alias === defaultAlias),
28
+ 0
29
+ );
30
+ const fallback = candidates[defaultIndex] ?? candidates[0];
31
+ if (!fallback) {
32
+ throw error("No registries to select from", { code: "ECONFIG" });
33
+ }
34
+ const rl = createInterface({ input, output });
35
+ try {
36
+ output.write("Multiple registries are configured. Select one:\n");
37
+ for (const [i, c] of candidates.entries()) {
38
+ const marker = i === defaultIndex ? " (default)" : "";
39
+ output.write(` ${i + 1}) ${c.alias} -> ${c.url}${marker}
40
+ `);
41
+ }
42
+ const answer = (await rl.question(`Registry [${defaultIndex + 1}]: `)).trim();
43
+ if (!answer) return fallback.url;
44
+ const choice = Number(answer);
45
+ const picked = candidates[choice - 1];
46
+ if (!Number.isInteger(choice) || !picked) {
47
+ throw error("Invalid registry selection", {
48
+ found: answer,
49
+ validOptions: candidates.map((_, i) => String(i + 1)),
50
+ code: "EUSAGE"
51
+ });
52
+ }
53
+ return picked.url;
54
+ } finally {
55
+ rl.close();
56
+ }
57
+ };
58
+
59
+ // ../../src/cli-sdk/src/require-registry.ts
60
+ var missingRegistryError = () => error(
61
+ [
62
+ "Missing registry configuration.",
63
+ "",
64
+ "vlt has no default registry. Run `vlt setup` to get configured.",
65
+ "",
66
+ "See https://docs.vlt.sh/cli for other ways to set a registry."
67
+ ].join("\n"),
68
+ { code: "ECONFIG" }
69
+ );
70
+ var ambiguousRegistryError = (candidates) => error(
71
+ [
72
+ "Multiple registries are configured; specify which one to use.",
73
+ "",
74
+ "Run `vlt registry <alias> <command>` with one of:",
75
+ ...candidates.map((c) => ` ${c.alias} -> ${c.url}`)
76
+ ].join("\n"),
77
+ {
78
+ code: "ECONFIG",
79
+ validOptions: candidates.map((c) => c.alias)
80
+ }
81
+ );
82
+ var resolveRegistryAlias = (conf, alias) => {
83
+ const url = conf.options.registries[alias];
84
+ if (!url) {
85
+ throw error(`Unknown registry alias: ${alias}`, {
86
+ code: "ECONFIG",
87
+ found: alias,
88
+ validOptions: Object.keys(conf.options.registries)
89
+ });
90
+ }
91
+ return url;
92
+ };
93
+ var gatherCandidates = (conf) => {
94
+ const builtins = defaultRegistries;
95
+ return Object.entries(conf.options.registries).filter(([alias, url]) => builtins[alias] !== url).map(([alias, url]) => ({ alias, url }));
96
+ };
97
+ var hasConfiguredRegistry = (conf) => !!conf.options.registry || gatherCandidates(conf).length > 0;
98
+ var requireRegistry = (conf, alias) => {
99
+ if (alias !== void 0) return resolveRegistryAlias(conf, alias);
100
+ const { registry } = conf.options;
101
+ if (registry) return registry;
102
+ const candidates = gatherCandidates(conf);
103
+ const [first, second] = candidates;
104
+ if (!first) throw missingRegistryError();
105
+ if (!second) return first.url;
106
+ const defaultUrl = conf.options.registries[conf.options["default-registry-alias"]];
107
+ if (defaultUrl) return defaultUrl;
108
+ throw ambiguousRegistryError(candidates);
109
+ };
110
+ var resolveRegistry = async (conf, {
111
+ alias,
112
+ interactive = process.stdin.isTTY,
113
+ input,
114
+ output
115
+ } = {}) => {
116
+ if (alias !== void 0) return resolveRegistryAlias(conf, alias);
117
+ const { registry } = conf.options;
118
+ if (registry) return registry;
119
+ const candidates = gatherCandidates(conf);
120
+ const [first, second] = candidates;
121
+ if (!first) throw missingRegistryError();
122
+ if (!second) return first.url;
123
+ const defaultAlias = conf.options["default-registry-alias"];
124
+ if (interactive) {
125
+ return selectRegistry(candidates, { defaultAlias, input, output });
126
+ }
127
+ const defaultUrl = conf.options.registries[defaultAlias];
128
+ if (defaultUrl) return defaultUrl;
129
+ throw ambiguousRegistryError(candidates);
130
+ };
131
+
132
+ export {
133
+ missingRegistryError,
134
+ hasConfiguredRegistry,
135
+ requireRegistry,
136
+ resolveRegistry
137
+ };