@vltpkg/cli-js 1.4.0 → 1.6.0

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 (105) hide show
  1. package/{access-422UGEWN.js → access-AJ654YKY.js} +13 -12
  2. package/{bugs-RED7Y33Q.js → bugs-N73DVYHD.js} +32 -25
  3. package/{build-IHMPBWRO.js → build-VZ3EZKMM.js} +65 -21
  4. package/{cache-FJP2RZJX.js → cache-VROEWG2C.js} +20 -17
  5. package/cache-unzip-src-unzip.js +58 -15
  6. package/{chunk-TPRK6IDA.js → chunk-22LZBDEC.js} +2 -2
  7. package/chunk-36UIE654.js +6248 -0
  8. package/{chunk-UGCKF5ZE.js → chunk-3JIN46K5.js} +1 -1
  9. package/{chunk-OAJ3PO3Z.js → chunk-44AWMA4F.js} +25 -13
  10. package/chunk-4E65BBTM.js +77 -0
  11. package/{chunk-SR2VOY5J.js → chunk-4GMNWW4C.js} +1 -1
  12. package/{chunk-5IJTPZXP.js → chunk-6D3QAFNZ.js} +1 -1
  13. package/{chunk-X4FVR4R5.js → chunk-75HGJVNG.js} +12 -10
  14. package/{chunk-THSYN5EK.js → chunk-7M2VTFLP.js} +12 -1
  15. package/{chunk-2AMOC4DN.js → chunk-ANW36H4T.js} +4 -4
  16. package/chunk-B6RIGNEO.js +626 -0
  17. package/{chunk-FLH4YC6W.js → chunk-BF5DRGRZ.js} +60 -15
  18. package/chunk-BH5CVXNY.js +115 -0
  19. package/{chunk-PLG3OYCX.js → chunk-CAV7FKWQ.js} +3 -2
  20. package/{chunk-C23TDXRG.js → chunk-CYK6I4M6.js} +1 -1
  21. package/chunk-DXED4ARV.js +436 -0
  22. package/chunk-E74WGW5C.js +49 -0
  23. package/{chunk-WF6KLKRN.js → chunk-EFHOWRKU.js} +103 -1
  24. package/chunk-EMTGRCSE.js +1111 -0
  25. package/{chunk-5Y4SYLJ2.js → chunk-EYGOEAJM.js} +1 -1
  26. package/{chunk-OVPHE4O7.js → chunk-F5LZMLAQ.js} +5335 -10902
  27. package/{chunk-HZXJ423P.js → chunk-FXD3IV2S.js} +4 -2
  28. package/chunk-GCTREKA4.js +115 -0
  29. package/{chunk-ZJMJ7MCT.js → chunk-GEQFMH5M.js} +1 -1
  30. package/{chunk-ISE4IRHF.js → chunk-GZVI75KX.js} +7 -14
  31. package/chunk-HOF7LEIC.js +24 -0
  32. package/{chunk-LHPEBLOU.js → chunk-HT6FS4VB.js} +1 -1
  33. package/{chunk-PHJJPY5G.js → chunk-IXAMCWIT.js} +5 -5
  34. package/{chunk-ASLX43R3.js → chunk-JCNI6ZHH.js} +7 -5
  35. package/chunk-JV5XR5JQ.js +349 -0
  36. package/{chunk-7T3XAYP4.js → chunk-KD5ZK72K.js} +1 -1
  37. package/{chunk-FZUYGJZU.js → chunk-KVWGMSPW.js} +137 -19
  38. package/{chunk-TO23PR7J.js → chunk-LCLRP64K.js} +14 -12
  39. package/{chunk-QCSUWACA.js → chunk-LGQVZTYR.js} +8 -36
  40. package/{chunk-5RHABCYI.js → chunk-LP3ORD3D.js} +143 -17
  41. package/chunk-MCDLJZXT.js +82 -0
  42. package/{chunk-DNRR3XMG.js → chunk-N6HV7JWC.js} +1 -1
  43. package/chunk-O6MQ7NN6.js +1155 -0
  44. package/{chunk-GIIAODRI.js → chunk-PC2HOBAQ.js} +7 -5
  45. package/{chunk-APMYKJI2.js → chunk-QNHBAGXQ.js} +1 -1
  46. package/chunk-RBQO54TG.js +59 -0
  47. package/chunk-SUU2WETN.js +268 -0
  48. package/{chunk-I7UMHYZX.js → chunk-TQQO2F56.js} +113 -1187
  49. package/{chunk-4UCADW6S.js → chunk-TWDSXQPN.js} +9 -7
  50. package/{chunk-MKWPTN3C.js → chunk-VLVMLSIF.js} +2 -2
  51. package/chunk-W4T5CGCO.js +52 -0
  52. package/{chunk-5TNXLRW2.js → chunk-YTDABXPD.js} +50 -12
  53. package/{ci-YSKNNO5M.js → ci-3BVMVQIT.js} +35 -13
  54. package/cli-package.json +3 -1
  55. package/{config-HO7GY3QT.js → config-2KQV7N5A.js} +16 -13
  56. package/{config-CSPCDMR3.js → config-EKHBW6I5.js} +12 -9
  57. package/{create-2TJT3AHJ.js → create-QVHNOIV3.js} +35 -29
  58. package/{deprecate-7FRJI2RL.js → deprecate-E254QBH6.js} +17 -15
  59. package/{dist-tag-WCFF5OEG.js → dist-tag-SITRFD7O.js} +13 -12
  60. package/{docs-JMBPTU23.js → docs-IDL2P7CA.js} +32 -25
  61. package/{exec-FBOUKZZ2.js → exec-7BK2W2WL.js} +35 -29
  62. package/{exec-cache-X3ZWM5S3.js → exec-cache-VY46L7DR.js} +27 -21
  63. package/{exec-local-Y3KQC22N.js → exec-local-D7R5T3DF.js} +26 -20
  64. package/{help-PUKVH5X7.js → help-RMRIEJQL.js} +6 -5
  65. package/{init-GOKAQXXZ.js → init-BGW4HJ6V.js} +15 -11
  66. package/{install-XFN4UFOC.js → install-U5GATZ2N.js} +144 -49
  67. package/{list-43JFFG5D.js → list-3VG4M2XL.js} +41 -28
  68. package/{login-RSTZKNKN.js → login-PHQWI6S6.js} +19 -16
  69. package/{logout-4576FFXZ.js → logout-DJCOGRFF.js} +13 -12
  70. package/{outdated-ACQ5A2Y7.js → outdated-JH3O6R3Y.js} +27 -22
  71. package/{pack-QQVJ3G25.js → pack-U5W5YWHK.js} +23 -18
  72. package/package.json +1 -1
  73. package/{ping-QCDQQRO5.js → ping-EKX43AOW.js} +13 -12
  74. package/{pkg-CSOJV7UC.js → pkg-SW5GMERT.js} +19 -14
  75. package/{profile-VL4HPW3N.js → profile-UGDRDMQ6.js} +13 -12
  76. package/{publish-2YBO6ZXE.js → publish-HTWKK3NN.js} +60 -45
  77. package/{query-IHHFMJRT.js → query-YE3FUVGG.js} +43 -30
  78. package/{registry-W7BRZZZ2.js → registry-ZGGWVLBM.js} +7 -7
  79. package/registry-client-src-revalidate.js +76 -22
  80. package/{repo-L3BXAAWS.js → repo-WDOCU6SE.js} +32 -25
  81. package/{reporter-5NYOHBO7.js → reporter-N5PAXB26.js} +121 -17
  82. package/{run-AMUUVLTI.js → run-IPARVIIQ.js} +26 -20
  83. package/{run-exec-5W3XWQZA.js → run-exec-C4RTREEW.js} +26 -20
  84. package/security-archive-src-update-expired.js +66 -21
  85. package/{setup-TFM4GJF7.js → setup-SYYUEHZL.js} +212 -32
  86. package/skills-KA2VR5Q5.js +480 -0
  87. package/skills-UBBMSBDQ.js +416 -0
  88. package/{src-4CYCUWZL.js → src-FUSTSM4J.js} +33 -22
  89. package/{src-I3GMULFP.js → src-QO5G2S4O.js} +11 -8
  90. package/{src-LUTN2ODD.js → src-W2VQULRG.js} +2 -2
  91. package/{token-OANOBE3G.js → token-UQNABECH.js} +15 -13
  92. package/{uninstall-YXTQ4AIZ.js → uninstall-FHBJ3OUV.js} +59 -18
  93. package/{unpublish-SZXYMYIU.js → unpublish-APJTEUBA.js} +31 -16
  94. package/{update-FHLMWGIM.js → update-NWZTL4S7.js} +52 -25
  95. package/{version-ZWFCTU5V.js → version-EMKKTL77.js} +20 -14
  96. package/{view-NFNJXMLV.js → view-BUUI33RV.js} +17 -15
  97. package/vlr.js +1 -1
  98. package/vlrx.js +1 -1
  99. package/vlt.js +1 -1
  100. package/vlx.js +1 -1
  101. package/vlxl.js +1 -1
  102. package/{whoami-O7GOSGCI.js → whoami-F6BSXGQ2.js} +13 -12
  103. package/chunk-G2YT2GWF.js +0 -120
  104. package/chunk-T6FBP4OU.js +0 -76
  105. package/chunk-U7TEQCBN.js +0 -880
@@ -10,14 +10,16 @@ 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
+ defaultRegistryKey,
13
14
  getTokenByURL,
14
15
  registryKeys
15
- } from "./chunk-OAJ3PO3Z.js";
16
+ } from "./chunk-44AWMA4F.js";
16
17
 
17
18
  // ../../src/cli-sdk/src/query-auth.ts
18
19
  var createGetAuthHeader = (conf) => {
19
20
  const keys = registryKeys(conf.options);
20
- return async (url) => getTokenByURL(url, conf.options.identity, keys);
21
+ const def = defaultRegistryKey(conf.options);
22
+ return async (url) => getTokenByURL(url, conf.options.identity, keys, def);
21
23
  };
22
24
 
23
25
  export {
@@ -0,0 +1,115 @@
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
+ isInside,
14
+ samePath
15
+ } from "./chunk-MCDLJZXT.js";
16
+ import {
17
+ isDepID
18
+ } from "./chunk-CAV7FKWQ.js";
19
+ import {
20
+ isObject
21
+ } from "./chunk-BF5DRGRZ.js";
22
+
23
+ // ../../src/cli-sdk/src/global-state.ts
24
+ import { randomBytes } from "node:crypto";
25
+ import {
26
+ chmod,
27
+ readFile,
28
+ realpath,
29
+ rename,
30
+ rm,
31
+ writeFile
32
+ } from "node:fs/promises";
33
+ import { basename, dirname, isAbsolute, resolve } from "node:path";
34
+ var globalStateFile = (root) => resolve(root, "global-state.json");
35
+ var readGlobalState = async (root) => {
36
+ let data;
37
+ try {
38
+ data = JSON.parse(await readFile(globalStateFile(root), "utf8"));
39
+ } catch {
40
+ return {};
41
+ }
42
+ if (!isObject(data)) return {};
43
+ const state = { ...data };
44
+ const { binDirs, localBinNoticed } = state;
45
+ if (Array.isArray(binDirs)) {
46
+ state.binDirs = binDirs.filter(
47
+ (d) => typeof d === "string" && isAbsolute(d)
48
+ );
49
+ } else delete state.binDirs;
50
+ if (Array.isArray(state.pendingRemove)) {
51
+ state.pendingRemove = state.pendingRemove.filter(
52
+ (d) => typeof d === "string" && isAbsolute(d)
53
+ );
54
+ } else delete state.pendingRemove;
55
+ if (typeof localBinNoticed !== "boolean")
56
+ delete state.localBinNoticed;
57
+ if (state.pathSetup !== "declined") delete state.pathSetup;
58
+ return state;
59
+ };
60
+ var writeFileAtomic = async (file, data, mode) => {
61
+ const tmp = `${file}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
62
+ try {
63
+ await writeFile(tmp, data, {
64
+ flag: "wx",
65
+ ...mode === void 0 ? {} : { mode }
66
+ });
67
+ if (mode !== void 0) await chmod(tmp, mode);
68
+ await rename(tmp, file);
69
+ } catch (er) {
70
+ await rm(tmp, { force: true });
71
+ throw er;
72
+ }
73
+ };
74
+ var writeJsonAtomic = (file, data) => writeFileAtomic(file, JSON.stringify(data, null, 2) + "\n");
75
+ var updateGlobalState = async (root, fn) => {
76
+ const state = fn(await readGlobalState(root));
77
+ await writeJsonAtomic(globalStateFile(root), state);
78
+ return state;
79
+ };
80
+ var sweepPendingRemove = async (root) => {
81
+ try {
82
+ const { pendingRemove = [] } = await readGlobalState(root);
83
+ if (!pendingRemove.length) return;
84
+ const store = resolve(await realpath(root), "node_modules/.vlt");
85
+ const script = process.argv[1];
86
+ const running = script && await realpath(script).catch(() => void 0);
87
+ const left = [];
88
+ for (const entry of pendingRemove) {
89
+ if (!samePath(dirname(entry), store) || !isDepID(basename(entry))) {
90
+ continue;
91
+ }
92
+ if (running && isInside(entry, running)) {
93
+ left.push(entry);
94
+ continue;
95
+ }
96
+ await rm(entry, { recursive: true, force: true }).catch(
97
+ () => left.push(entry)
98
+ );
99
+ }
100
+ if (left.length === pendingRemove.length) return;
101
+ await updateGlobalState(root, (s) => ({
102
+ ...s,
103
+ pendingRemove: left
104
+ }));
105
+ } catch {
106
+ }
107
+ };
108
+
109
+ export {
110
+ readGlobalState,
111
+ writeFileAtomic,
112
+ writeJsonAtomic,
113
+ updateGlobalState,
114
+ sweepPendingRemove
115
+ };
@@ -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.4.0",
17
+ version: "1.6.0",
18
18
  repository: {
19
19
  type: "git",
20
20
  url: "git+https://github.com/vltpkg/vltpkg.git",
@@ -9,20 +9,20 @@ globalThis.setInterval = _vlt_setInterval;
9
9
  globalThis.clearInterval = _vlt_clearInterval;
10
10
  import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
- import {
13
- asUnknownSpecPrefix
14
- } from "./chunk-THSYN5EK.js";
15
12
  import {
16
13
  addKey,
17
14
  asDependency
18
- } from "./chunk-OVPHE4O7.js";
15
+ } from "./chunk-F5LZMLAQ.js";
16
+ import {
17
+ parseSpecArg
18
+ } from "./chunk-7M2VTFLP.js";
19
19
  import {
20
20
  joinDepIDTuple,
21
21
  splitDepID
22
- } from "./chunk-PLG3OYCX.js";
22
+ } from "./chunk-CAV7FKWQ.js";
23
23
  import {
24
24
  Spec
25
- } from "./chunk-5IJTPZXP.js";
25
+ } from "./chunk-6D3QAFNZ.js";
26
26
 
27
27
  // ../../src/cli-sdk/src/parse-add-remove-args.ts
28
28
  import { isAbsolute, relative, resolve } from "node:path";
@@ -68,13 +68,6 @@ var rebaseFileSpec = (spec, importerPath, scurryCwd, specOptions, monorepo) => {
68
68
  if (rebasedPath === spec.file) return spec;
69
69
  return Spec.parseArgs(rebasedPath, specOptions);
70
70
  };
71
- var parseArg = (item, options) => {
72
- try {
73
- return Spec.parseArgs(item, options);
74
- } catch (er) {
75
- throw asUnknownSpecPrefix(er);
76
- }
77
- };
78
71
  var parseAddArgs = (config, scurry, monorepo) => {
79
72
  const add = new AddImportersDependenciesMapImpl();
80
73
  const items = config.positionals;
@@ -84,7 +77,7 @@ var parseAddArgs = (config, scurry, monorepo) => {
84
77
  const parsedItems = [];
85
78
  let hasFileSpecs = false;
86
79
  for (const item of items) {
87
- const spec = parseArg(item, specOptions);
80
+ const spec = parseSpecArg(item, specOptions);
88
81
  parsedItems.push({ spec, type });
89
82
  if (spec.type === "file") hasFileSpecs = true;
90
83
  add.modifiedDependencies = true;
@@ -0,0 +1,24 @@
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
+ // ../../src/cli-sdk/src/publish-config.ts
14
+ var getPublishConfig = (manifest) => {
15
+ const pc = manifest.publishConfig;
16
+ if (pc && typeof pc === "object") {
17
+ return pc;
18
+ }
19
+ return void 0;
20
+ };
21
+
22
+ export {
23
+ getPublishConfig
24
+ };
@@ -12,7 +12,7 @@ var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  commandAliases,
14
14
  jack
15
- } from "./chunk-WF6KLKRN.js";
15
+ } from "./chunk-EFHOWRKU.js";
16
16
 
17
17
  // ../../src/cli-sdk/src/config/usage.ts
18
18
  var toArr = (v) => Array.isArray(v) ? v : [v];
@@ -11,13 +11,13 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  openUrl
14
- } from "./chunk-TPRK6IDA.js";
15
- import {
16
- stderr
17
- } from "./chunk-FZUYGJZU.js";
14
+ } from "./chunk-22LZBDEC.js";
18
15
  import {
19
16
  mermaidOutput
20
- } from "./chunk-OVPHE4O7.js";
17
+ } from "./chunk-36UIE654.js";
18
+ import {
19
+ stderr
20
+ } from "./chunk-KVWGMSPW.js";
21
21
  import {
22
22
  ViewClass
23
23
  } from "./chunk-4KCU2KZL.js";
@@ -11,12 +11,14 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  actual,
14
- callLimit,
15
14
  createVirtualRoot
16
- } from "./chunk-OVPHE4O7.js";
15
+ } from "./chunk-36UIE654.js";
16
+ import {
17
+ callLimit
18
+ } from "./chunk-F5LZMLAQ.js";
17
19
  import {
18
20
  SecurityArchive
19
- } from "./chunk-5TNXLRW2.js";
21
+ } from "./chunk-YTDABXPD.js";
20
22
  import {
21
23
  error
22
24
  } from "./chunk-WZWDS3W4.js";
@@ -140,8 +142,8 @@ var reloadConfig = async (folder) => {
140
142
  unload("project");
141
143
  } catch {
142
144
  }
143
- const { Config } = await import("./config-CSPCDMR3.js");
144
- return Config.load(folder, process.argv, true);
145
+ const { Config } = await import("./config-EKHBW6I5.js");
146
+ return Config.load(folder, process.argv, true, false);
145
147
  };
146
148
 
147
149
  // ../../src/cli-sdk/src/query-host-contexts.ts
@@ -0,0 +1,349 @@
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
+ rimraf
14
+ } from "./chunk-PDWPFR5T.js";
15
+ import {
16
+ error
17
+ } from "./chunk-WZWDS3W4.js";
18
+
19
+ // ../../src/rollback-remove/src/index.ts
20
+ import { spawn } from "node:child_process";
21
+ import { rename } from "node:fs/promises";
22
+ import { basename, dirname } from "node:path";
23
+
24
+ // ../../src/rollback-remove/src/remove.ts
25
+ import { resolve } from "node:path";
26
+ var __CODE_SPLIT_SCRIPT_NAME = resolve(import.meta.dirname, "rollback-remove-src-remove.js");
27
+
28
+ // ../../src/rollback-remove/src/index.ts
29
+ var isDeno = globalThis.Deno != void 0;
30
+ var RollbackRemove = class {
31
+ #key = String(Math.random()).substring(2);
32
+ #paths = /* @__PURE__ */ new Map();
33
+ async rm(path) {
34
+ if (this.#paths.has(path)) return;
35
+ const target = `${dirname(path)}/.VLT.DELETE.${this.#key}.${basename(path)}`;
36
+ try {
37
+ await rename(path, target);
38
+ } catch (e) {
39
+ if (e instanceof Error && "code" in e && /* c8 ignore start - very spurious weirdness on Windows */
40
+ (e.code === "ENOENT" || e.code === "EPERM")) {
41
+ return;
42
+ }
43
+ throw e;
44
+ }
45
+ this.#paths.set(path, target);
46
+ }
47
+ confirm() {
48
+ if (!this.#paths.size) return;
49
+ const env = { ...process.env };
50
+ const args = [];
51
+ const detached = !(isDeno && process.platform === "win32");
52
+ if (isDeno) {
53
+ args.push(
54
+ "--unstable-node-globals",
55
+ "--unstable-bare-node-builtins"
56
+ );
57
+ }
58
+ args.push(__CODE_SPLIT_SCRIPT_NAME);
59
+ const child = spawn(process.execPath, args, {
60
+ stdio: ["pipe", "ignore", "ignore"],
61
+ detached,
62
+ env
63
+ });
64
+ for (const path of this.#paths.values()) {
65
+ child.stdin.write(`${path}\0`);
66
+ }
67
+ child.stdin.end();
68
+ if (detached) {
69
+ child.unref();
70
+ }
71
+ this.#paths.clear();
72
+ }
73
+ async rollback() {
74
+ const promises = [];
75
+ for (const [original, moved] of this.#paths) {
76
+ promises.push(
77
+ rimraf(original).catch(() => {
78
+ }).then(() => rename(moved, original))
79
+ );
80
+ }
81
+ await Promise.all(promises);
82
+ this.#paths.clear();
83
+ }
84
+ };
85
+
86
+ // ../../src/cmd-shim/src/read.ts
87
+ import { lstat, readFile, readlink } from "node:fs/promises";
88
+ import { dirname as dirname2, resolve as resolve2 } from "node:path";
89
+
90
+ // ../../src/cmd-shim/src/paths.ts
91
+ var paths = process.platform === "win32" ? (path) => [
92
+ path + ".cmd",
93
+ path + ".ps1",
94
+ path,
95
+ path + ".pwsh"
96
+ ] : (path) => [path];
97
+
98
+ // ../../src/cmd-shim/src/read.ts
99
+ var extractPath = (path, cmdshimContents) => {
100
+ if (/\.cmd$/i.test(path)) {
101
+ return extractPathFromCmd(cmdshimContents);
102
+ } else if (/\.(ps1|pwsh)$/i.test(path)) {
103
+ return extractPathFromPowershell(cmdshimContents);
104
+ } else {
105
+ return extractPathFromCygwin(cmdshimContents);
106
+ }
107
+ };
108
+ var extractPathFromPowershell = (cmdshimContents) => {
109
+ const matches = /"(?:[$]basedir\/|(?=[a-zA-Z]:[\\/]))([^"]+?)"\s+[$]args/.exec(
110
+ cmdshimContents
111
+ );
112
+ return matches?.[1]?.replace(/\\/g, "/");
113
+ };
114
+ var extractPathFromCmd = (cmdshimContents) => {
115
+ const matches = /"(?:%(?:~dp0|dp0%)\\|(?=[a-zA-Z]:[\\/]))([^"]+?)"\s+%[*]/.exec(
116
+ cmdshimContents
117
+ );
118
+ return matches?.[1]?.replace(/\\/g, "/");
119
+ };
120
+ var extractPathFromCygwin = (cmdshimContents) => {
121
+ const matches = /"(?:[$]basedir\/|(?=[a-zA-Z]:[\\/]))([^"]+?)"\s+"[$]@"/.exec(
122
+ cmdshimContents
123
+ );
124
+ return matches?.[1]?.replace(/\\/g, "/");
125
+ };
126
+ var findCmdShimIfExists = async (path) => {
127
+ path = path.replace(/\.(cmd|pwsh|ps1)$/i, "");
128
+ for (const p of paths(path)) {
129
+ const result = await readCmdShimIfExists(p);
130
+ if (result) return [p, result];
131
+ }
132
+ };
133
+ var readCmdShimIfExists = async (path) => {
134
+ try {
135
+ const st = await lstat(path);
136
+ if (st.isSymbolicLink()) {
137
+ return resolve2(dirname2(path), await readlink(path));
138
+ }
139
+ const contents = await readFile(path);
140
+ const destination = extractPath(path, contents.toString());
141
+ if (destination) return resolve2(dirname2(path), destination);
142
+ } catch {
143
+ }
144
+ };
145
+
146
+ // ../../src/cmd-shim/src/index.ts
147
+ import {
148
+ chmod,
149
+ mkdir,
150
+ readFile as readFile2,
151
+ stat,
152
+ writeFile
153
+ } from "node:fs/promises";
154
+ import { dirname as dirname3, isAbsolute, relative } from "node:path";
155
+
156
+ // ../../src/cmd-shim/src/to-batch-syntax.ts
157
+ var convertToSetCommand = (key, value) => convertToSetCommand_(key.trim(), value.trim());
158
+ var convertToSetCommand_ = (key, value) => key && value ? `@SET ${key}=${replaceDollarWithPercentPair(value)}\r
159
+ ` : "";
160
+ var extractVariableValuePairs = (declarations) => declarations.reduce(
161
+ (pairs, declaration) => {
162
+ const [key = "", val = ""] = declaration.split("=");
163
+ pairs[key] = val;
164
+ return pairs;
165
+ },
166
+ {}
167
+ );
168
+ var convertToSetCommands = (variableString) => Object.entries(extractVariableValuePairs(variableString.split(" "))).map(([key, val]) => convertToSetCommand(key, val)).join("");
169
+ var replaceDollarWithPercentPair = (value) => {
170
+ const dollarExpressions = /\$\{?([^$@#?\- \t{}:]+)\}?/g;
171
+ let result = "";
172
+ let startIndex = 0;
173
+ do {
174
+ const match = dollarExpressions.exec(value);
175
+ if (match) {
176
+ const betweenMatches = value.substring(startIndex, match.index) || "";
177
+ result += betweenMatches + "%" + String(match[1]) + "%";
178
+ startIndex = dollarExpressions.lastIndex;
179
+ }
180
+ } while (dollarExpressions.lastIndex > 0);
181
+ result += value.slice(startIndex);
182
+ return result;
183
+ };
184
+
185
+ // ../../src/cmd-shim/src/index.ts
186
+ var shebangExpr = /^#!\s*(?:\/usr\/bin\/env\s+(?:-S\s+)?((?:[^ \t=]+=[^ \t=]+\s+)*))?([^ \t]+)(.*)$/;
187
+ var cmdShimIfExists = async (from, to, remover) => {
188
+ try {
189
+ await stat(from);
190
+ } catch {
191
+ return;
192
+ }
193
+ await writeShim(from, to, remover);
194
+ };
195
+ var cmdShim = async (from, to, remover) => {
196
+ try {
197
+ await stat(from);
198
+ await writeShim(from, to, remover);
199
+ } catch (er) {
200
+ throw error("Could not shim to executable file", {
201
+ path: from,
202
+ target: to,
203
+ cause: er
204
+ });
205
+ }
206
+ };
207
+ var writeShim = async (from, to, remover) => {
208
+ await Promise.all([
209
+ remover.rm(to),
210
+ remover.rm(to + ".cmd"),
211
+ remover.rm(to + ".ps1"),
212
+ remover.rm(to + ".pwsh")
213
+ ]);
214
+ await mkdir(dirname3(to), { recursive: true });
215
+ const data = await readFile2(from, "utf8").catch(() => "");
216
+ if (!data) {
217
+ return await writeShim_(from, to);
218
+ }
219
+ const firstLine = data.trim().split(/\r*\n/)[0];
220
+ const shebang = firstLine?.match(shebangExpr) ?? void 0;
221
+ return writeShim_(
222
+ from,
223
+ to,
224
+ shebang?.[2],
225
+ shebang?.[3],
226
+ shebang?.[1]
227
+ );
228
+ };
229
+ var writeShim_ = async (from, to, prog, args, variables) => {
230
+ let shTarget = relative(dirname3(to), from);
231
+ const [dp0, basedir] = isAbsolute(shTarget) ? ["", ""] : ["%dp0%\\", "$basedir/"];
232
+ let target = shTarget.split("/").join("\\");
233
+ let longProg;
234
+ let shProg = prog?.split("\\").join("/");
235
+ let shLongProg;
236
+ let pwshProg = shProg && `"${shProg}$exe"`;
237
+ let pwshLongProg;
238
+ shTarget = shTarget.split("\\").join("/");
239
+ args = args || "";
240
+ variables = variables || "";
241
+ if (!prog) {
242
+ prog = `"${dp0}${target}"`;
243
+ shProg = `"${basedir}${shTarget}"`;
244
+ pwshProg = shProg;
245
+ args = "";
246
+ target = "";
247
+ shTarget = "";
248
+ } else {
249
+ longProg = `"%dp0%\\${prog}.exe"`;
250
+ shLongProg = `"$basedir/${prog}"`;
251
+ pwshLongProg = `"$basedir/${prog}$exe"`;
252
+ target = `"${dp0}${target}"`;
253
+ shTarget = `"${basedir}${shTarget}"`;
254
+ }
255
+ const head = "@ECHO off\r\nGOTO start\r\n:find_dp0\r\nSET dp0=%~dp0\r\nEXIT /b\r\n:start\r\nSETLOCAL\r\nCALL :find_dp0\r\n";
256
+ let cmd;
257
+ if (longProg) {
258
+ shLongProg = (shLongProg ?? "").trim();
259
+ args = args.trim();
260
+ const variablesBatch = convertToSetCommands(variables);
261
+ cmd = `${head}${variablesBatch}\r
262
+ IF EXIST ${longProg} (\r
263
+ SET "_prog=${longProg.replace(/(^")|("$)/g, "")}"\r
264
+ ) ELSE (\r
265
+ SET "_prog=${prog.replace(/(^")|("$)/g, "")}"\r
266
+ SET PATHEXT=%PATHEXT:;.JS;=;%\r
267
+ )\r
268
+ \r
269
+ endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" ${args} ${target} %*\r
270
+ `;
271
+ } else {
272
+ cmd = `${head}${prog} ${args} ${target} %*\r
273
+ `;
274
+ }
275
+ let sh = `#!/bin/sh
276
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
277
+
278
+ case \`uname\` in
279
+ *CYGWIN*|*MINGW*|*MSYS*)
280
+ if command -v cygpath > /dev/null 2>&1; then
281
+ basedir=\`cygpath -w "$basedir"\`
282
+ fi
283
+ ;;
284
+ esac
285
+
286
+ `;
287
+ if (shLongProg) {
288
+ sh += `if [ -x ${shLongProg} ]; then
289
+ exec ${variables}${shLongProg} ${args} ${shTarget} "$@"
290
+ else
291
+ exec ${variables}${shProg} ${args} ${shTarget} "$@"
292
+ fi
293
+ `;
294
+ } else {
295
+ sh += `exec ${shProg} ${args} ${shTarget} "$@"
296
+ `;
297
+ }
298
+ let pwsh = '#!/usr/bin/env pwsh\n$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent\n\n$exe=""\nif ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {\n # Fix case when both the Windows and Linux builds of Node\n # are installed in the same directory\n $exe=".exe"\n}\n';
299
+ if (shLongProg) {
300
+ pwsh += `$ret=0
301
+ if (Test-Path ${pwshLongProg}) {
302
+ # Support pipeline input
303
+ if ($MyInvocation.ExpectingInput) {
304
+ $input | & ${pwshLongProg} ${args} ${shTarget} $args
305
+ } else {
306
+ & ${pwshLongProg} ${args} ${shTarget} $args
307
+ }
308
+ $ret=$LASTEXITCODE
309
+ } else {
310
+ # Support pipeline input
311
+ if ($MyInvocation.ExpectingInput) {
312
+ $input | & ${pwshProg} ${args} ${shTarget} $args
313
+ } else {
314
+ & ${pwshProg} ${args} ${shTarget} $args
315
+ }
316
+ $ret=$LASTEXITCODE
317
+ }
318
+ exit $ret
319
+ `;
320
+ } else {
321
+ pwsh += `# Support pipeline input
322
+ if ($MyInvocation.ExpectingInput) {
323
+ $input | & ${pwshProg} ${args} ${shTarget} $args
324
+ } else {
325
+ & ${pwshProg} ${args} ${shTarget} $args
326
+ }
327
+ exit $LASTEXITCODE
328
+ `;
329
+ }
330
+ await Promise.all([
331
+ writeFile(to + ".cmd", cmd, "utf8"),
332
+ writeFile(to + ".ps1", pwsh, "utf8"),
333
+ writeFile(to, sh, "utf8")
334
+ ]);
335
+ await chmodShim(to);
336
+ };
337
+ var chmodShim = async (to) => await Promise.all([
338
+ chmod(to, 493),
339
+ chmod(to + ".cmd", 493),
340
+ chmod(to + ".ps1", 493)
341
+ ]);
342
+
343
+ export {
344
+ findCmdShimIfExists,
345
+ readCmdShimIfExists,
346
+ cmdShimIfExists,
347
+ cmdShim,
348
+ RollbackRemove
349
+ };
@@ -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
  getId
14
- } from "./chunk-PLG3OYCX.js";
14
+ } from "./chunk-CAV7FKWQ.js";
15
15
 
16
16
  // ../../src/cli-sdk/src/stub-node.ts
17
17
  var createStubNode = (spec, name, version, options) => ({