@socketsecurity/lib 1.3.2 → 1.3.4

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 (338) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/abort.js +1 -60
  3. package/dist/abort.js.map +2 -2
  4. package/dist/agent.js +1 -289
  5. package/dist/agent.js.map +2 -2
  6. package/dist/ansi.js +1 -60
  7. package/dist/ansi.js.map +2 -2
  8. package/dist/argv/flags.js +1 -282
  9. package/dist/argv/flags.js.map +2 -2
  10. package/dist/argv/parse.js +1 -171
  11. package/dist/argv/parse.js.map +2 -2
  12. package/dist/arrays.js +1 -85
  13. package/dist/arrays.js.map +2 -2
  14. package/dist/bin.js +1 -402
  15. package/dist/bin.js.map +2 -2
  16. package/dist/cacache.js +1 -137
  17. package/dist/cacache.js.map +2 -2
  18. package/dist/cache-with-ttl.js +1 -223
  19. package/dist/cache-with-ttl.js.map +2 -2
  20. package/dist/constants/agents.js +1 -126
  21. package/dist/constants/agents.js.map +2 -2
  22. package/dist/constants/core.js +2 -57
  23. package/dist/constants/core.js.map +2 -2
  24. package/dist/constants/encoding.js +1 -48
  25. package/dist/constants/encoding.js.map +2 -2
  26. package/dist/constants/github.js +1 -30
  27. package/dist/constants/github.js.map +2 -2
  28. package/dist/constants/licenses.js +1 -66
  29. package/dist/constants/licenses.js.map +2 -2
  30. package/dist/constants/node.d.ts +2 -3
  31. package/dist/constants/node.js +1 -171
  32. package/dist/constants/node.js.map +3 -3
  33. package/dist/constants/packages.js +1 -128
  34. package/dist/constants/packages.js.map +2 -2
  35. package/dist/constants/paths.js +1 -150
  36. package/dist/constants/paths.js.map +2 -2
  37. package/dist/constants/platform.js +1 -41
  38. package/dist/constants/platform.js.map +2 -2
  39. package/dist/constants/process.js +1 -52
  40. package/dist/constants/process.js.map +2 -2
  41. package/dist/constants/socket.js +1 -81
  42. package/dist/constants/socket.js.map +2 -2
  43. package/dist/constants/testing.js +1 -36
  44. package/dist/constants/testing.js.map +2 -2
  45. package/dist/constants/time.js +1 -39
  46. package/dist/constants/time.js.map +2 -2
  47. package/dist/constants/typescript.js +1 -54
  48. package/dist/constants/typescript.js.map +2 -2
  49. package/dist/cover/code.js +1 -135
  50. package/dist/cover/code.js.map +2 -2
  51. package/dist/cover/formatters.js +11 -101
  52. package/dist/cover/formatters.js.map +2 -2
  53. package/dist/cover/type.js +1 -63
  54. package/dist/cover/type.js.map +2 -2
  55. package/dist/cover/types.js +1 -15
  56. package/dist/cover/types.js.map +2 -2
  57. package/dist/debug.js +2 -343
  58. package/dist/debug.js.map +2 -2
  59. package/dist/dlx-binary.js +1 -259
  60. package/dist/dlx-binary.js.map +2 -2
  61. package/dist/dlx-package.js +1 -149
  62. package/dist/dlx-package.js.map +2 -2
  63. package/dist/dlx.js +1 -166
  64. package/dist/dlx.js.map +2 -2
  65. package/dist/download-lock.js +1 -137
  66. package/dist/download-lock.js.map +2 -2
  67. package/dist/effects/pulse-frames.js +1 -64
  68. package/dist/effects/pulse-frames.js.map +2 -2
  69. package/dist/effects/text-shimmer.js +1 -174
  70. package/dist/effects/text-shimmer.js.map +2 -2
  71. package/dist/effects/types.js +1 -15
  72. package/dist/effects/types.js.map +2 -2
  73. package/dist/effects/ultra.js +1 -61
  74. package/dist/effects/ultra.js.map +2 -2
  75. package/dist/env/appdata.js +1 -28
  76. package/dist/env/appdata.js.map +2 -2
  77. package/dist/env/ci.js +1 -29
  78. package/dist/env/ci.js.map +2 -2
  79. package/dist/env/comspec.js +1 -28
  80. package/dist/env/comspec.js.map +2 -2
  81. package/dist/env/debug.js +1 -28
  82. package/dist/env/debug.js.map +2 -2
  83. package/dist/env/getters.js +1 -281
  84. package/dist/env/getters.js.map +2 -2
  85. package/dist/env/github-api-url.js +1 -28
  86. package/dist/env/github-api-url.js.map +2 -2
  87. package/dist/env/github-base-ref.js +1 -28
  88. package/dist/env/github-base-ref.js.map +2 -2
  89. package/dist/env/github-ref-name.js +1 -28
  90. package/dist/env/github-ref-name.js.map +2 -2
  91. package/dist/env/github-ref-type.js +1 -28
  92. package/dist/env/github-ref-type.js.map +2 -2
  93. package/dist/env/github-repository.js +1 -28
  94. package/dist/env/github-repository.js.map +2 -2
  95. package/dist/env/github-server-url.js +1 -28
  96. package/dist/env/github-server-url.js.map +2 -2
  97. package/dist/env/github-token.js +1 -28
  98. package/dist/env/github-token.js.map +2 -2
  99. package/dist/env/helpers.js +1 -47
  100. package/dist/env/helpers.js.map +2 -2
  101. package/dist/env/home.js +1 -28
  102. package/dist/env/home.js.map +2 -2
  103. package/dist/env/jest-worker-id.js +1 -28
  104. package/dist/env/jest-worker-id.js.map +2 -2
  105. package/dist/env/lang.js +1 -28
  106. package/dist/env/lang.js.map +2 -2
  107. package/dist/env/lc-all.js +1 -28
  108. package/dist/env/lc-all.js.map +2 -2
  109. package/dist/env/lc-messages.js +1 -28
  110. package/dist/env/lc-messages.js.map +2 -2
  111. package/dist/env/localappdata.js +1 -28
  112. package/dist/env/localappdata.js.map +2 -2
  113. package/dist/env/node-auth-token.js +1 -28
  114. package/dist/env/node-auth-token.js.map +2 -2
  115. package/dist/env/node-env.js +1 -28
  116. package/dist/env/node-env.js.map +2 -2
  117. package/dist/env/npm-config-registry.js +1 -28
  118. package/dist/env/npm-config-registry.js.map +2 -2
  119. package/dist/env/npm-config-user-agent.js +1 -28
  120. package/dist/env/npm-config-user-agent.js.map +2 -2
  121. package/dist/env/npm-lifecycle-event.js +1 -28
  122. package/dist/env/npm-lifecycle-event.js.map +2 -2
  123. package/dist/env/npm-registry.js +1 -28
  124. package/dist/env/npm-registry.js.map +2 -2
  125. package/dist/env/npm-token.js +1 -28
  126. package/dist/env/npm-token.js.map +2 -2
  127. package/dist/env/path.js +1 -28
  128. package/dist/env/path.js.map +2 -2
  129. package/dist/env/pre-commit.js +1 -29
  130. package/dist/env/pre-commit.js.map +2 -2
  131. package/dist/env/shell.js +1 -28
  132. package/dist/env/shell.js.map +2 -2
  133. package/dist/env/socket-accept-risks.js +1 -29
  134. package/dist/env/socket-accept-risks.js.map +2 -2
  135. package/dist/env/socket-api-base-url.js +1 -28
  136. package/dist/env/socket-api-base-url.js.map +2 -2
  137. package/dist/env/socket-api-proxy.js +1 -28
  138. package/dist/env/socket-api-proxy.js.map +2 -2
  139. package/dist/env/socket-api-timeout.js +1 -29
  140. package/dist/env/socket-api-timeout.js.map +2 -2
  141. package/dist/env/socket-api-token.js +1 -28
  142. package/dist/env/socket-api-token.js.map +2 -2
  143. package/dist/env/socket-cacache-dir.js +1 -28
  144. package/dist/env/socket-cacache-dir.js.map +2 -2
  145. package/dist/env/socket-cli-accept-risks.js +1 -31
  146. package/dist/env/socket-cli-accept-risks.js.map +2 -2
  147. package/dist/env/socket-cli-api-base-url.js +1 -28
  148. package/dist/env/socket-cli-api-base-url.js.map +2 -2
  149. package/dist/env/socket-cli-api-proxy.js +1 -28
  150. package/dist/env/socket-cli-api-proxy.js.map +2 -2
  151. package/dist/env/socket-cli-api-timeout.js +1 -29
  152. package/dist/env/socket-cli-api-timeout.js.map +2 -2
  153. package/dist/env/socket-cli-api-token.js +1 -28
  154. package/dist/env/socket-cli-api-token.js.map +2 -2
  155. package/dist/env/socket-cli-config.js +1 -28
  156. package/dist/env/socket-cli-config.js.map +2 -2
  157. package/dist/env/socket-cli-fix.js +1 -28
  158. package/dist/env/socket-cli-fix.js.map +2 -2
  159. package/dist/env/socket-cli-no-api-token.js +1 -31
  160. package/dist/env/socket-cli-no-api-token.js.map +2 -2
  161. package/dist/env/socket-cli-optimize.js +1 -29
  162. package/dist/env/socket-cli-optimize.js.map +2 -2
  163. package/dist/env/socket-cli-org-slug.js +1 -28
  164. package/dist/env/socket-cli-org-slug.js.map +2 -2
  165. package/dist/env/socket-cli-shadow-accept-risks.js +1 -31
  166. package/dist/env/socket-cli-shadow-accept-risks.js.map +2 -2
  167. package/dist/env/socket-cli-shadow-api-token.js +1 -28
  168. package/dist/env/socket-cli-shadow-api-token.js.map +2 -2
  169. package/dist/env/socket-cli-shadow-bin.js +1 -28
  170. package/dist/env/socket-cli-shadow-bin.js.map +2 -2
  171. package/dist/env/socket-cli-shadow-progress.js +1 -31
  172. package/dist/env/socket-cli-shadow-progress.js.map +2 -2
  173. package/dist/env/socket-cli-shadow-silent.js +1 -31
  174. package/dist/env/socket-cli-shadow-silent.js.map +2 -2
  175. package/dist/env/socket-cli-view-all-risks.js +1 -31
  176. package/dist/env/socket-cli-view-all-risks.js.map +2 -2
  177. package/dist/env/socket-config.js +1 -28
  178. package/dist/env/socket-config.js.map +2 -2
  179. package/dist/env/socket-debug.js +1 -28
  180. package/dist/env/socket-debug.js.map +2 -2
  181. package/dist/env/socket-home.js +1 -28
  182. package/dist/env/socket-home.js.map +2 -2
  183. package/dist/env/socket-no-api-token.js +1 -29
  184. package/dist/env/socket-no-api-token.js.map +2 -2
  185. package/dist/env/socket-npm-registry.js +1 -28
  186. package/dist/env/socket-npm-registry.js.map +2 -2
  187. package/dist/env/socket-org-slug.js +1 -28
  188. package/dist/env/socket-org-slug.js.map +2 -2
  189. package/dist/env/socket-registry-url.js +1 -28
  190. package/dist/env/socket-registry-url.js.map +2 -2
  191. package/dist/env/socket-view-all-risks.js +1 -29
  192. package/dist/env/socket-view-all-risks.js.map +2 -2
  193. package/dist/env/temp.js +1 -28
  194. package/dist/env/temp.js.map +2 -2
  195. package/dist/env/term.js +1 -28
  196. package/dist/env/term.js.map +2 -2
  197. package/dist/env/tmp.js +1 -28
  198. package/dist/env/tmp.js.map +2 -2
  199. package/dist/env/tmpdir.js +1 -28
  200. package/dist/env/tmpdir.js.map +2 -2
  201. package/dist/env/userprofile.js +1 -28
  202. package/dist/env/userprofile.js.map +2 -2
  203. package/dist/env/vitest.js +1 -29
  204. package/dist/env/vitest.js.map +2 -2
  205. package/dist/env/xdg-cache-home.js +1 -28
  206. package/dist/env/xdg-cache-home.js.map +2 -2
  207. package/dist/env/xdg-config-home.js +1 -28
  208. package/dist/env/xdg-config-home.js.map +2 -2
  209. package/dist/env/xdg-data-home.js +1 -28
  210. package/dist/env/xdg-data-home.js.map +2 -2
  211. package/dist/env.js +1 -61
  212. package/dist/env.js.map +2 -2
  213. package/dist/fs.js +3 -626
  214. package/dist/fs.js.map +2 -2
  215. package/dist/functions.js +1 -68
  216. package/dist/functions.js.map +2 -2
  217. package/dist/git.js +2 -320
  218. package/dist/git.js.map +2 -2
  219. package/dist/github.js +1 -201
  220. package/dist/github.js.map +2 -2
  221. package/dist/globs.js +1 -152
  222. package/dist/globs.js.map +2 -2
  223. package/dist/http-request.js +1 -313
  224. package/dist/http-request.js.map +2 -2
  225. package/dist/index.js +1 -62
  226. package/dist/index.js.map +2 -2
  227. package/dist/ipc.js +1 -232
  228. package/dist/ipc.js.map +2 -2
  229. package/dist/json.js +1 -73
  230. package/dist/json.js.map +2 -2
  231. package/dist/logger.js +1 -1254
  232. package/dist/logger.js.map +2 -2
  233. package/dist/maintained-node-versions.js +1 -35
  234. package/dist/maintained-node-versions.js.map +2 -2
  235. package/dist/memoization.js +1 -210
  236. package/dist/memoization.js.map +2 -2
  237. package/dist/objects.d.ts +0 -3
  238. package/dist/objects.js +1 -319
  239. package/dist/objects.js.map +3 -3
  240. package/dist/packages/editable.js +9 -356
  241. package/dist/packages/editable.js.map +2 -2
  242. package/dist/packages/exports.js +1 -162
  243. package/dist/packages/exports.js.map +2 -2
  244. package/dist/packages/isolation.js +1 -195
  245. package/dist/packages/isolation.js.map +2 -2
  246. package/dist/packages/licenses.js +1 -214
  247. package/dist/packages/licenses.js.map +2 -2
  248. package/dist/packages/manifest.js +1 -190
  249. package/dist/packages/manifest.js.map +2 -2
  250. package/dist/packages/normalize.js +1 -120
  251. package/dist/packages/normalize.js.map +2 -2
  252. package/dist/packages/operations.js +1 -304
  253. package/dist/packages/operations.js.map +2 -2
  254. package/dist/packages/paths.js +1 -53
  255. package/dist/packages/paths.js.map +2 -2
  256. package/dist/packages/provenance.js +1 -178
  257. package/dist/packages/provenance.js.map +2 -2
  258. package/dist/packages/registry.js +1 -28
  259. package/dist/packages/registry.js.map +2 -2
  260. package/dist/packages/specs.js +1 -83
  261. package/dist/packages/specs.js.map +2 -2
  262. package/dist/packages/validation.js +1 -51
  263. package/dist/packages/validation.js.map +2 -2
  264. package/dist/packages.js +1 -129
  265. package/dist/packages.js.map +2 -2
  266. package/dist/path.js +1 -448
  267. package/dist/path.js.map +2 -2
  268. package/dist/paths.js +1 -143
  269. package/dist/paths.js.map +2 -2
  270. package/dist/performance.js +15 -216
  271. package/dist/performance.js.map +2 -2
  272. package/dist/promise-queue.js +1 -109
  273. package/dist/promise-queue.js.map +2 -2
  274. package/dist/promises.js +1 -269
  275. package/dist/promises.js.map +2 -2
  276. package/dist/prompts.js +1 -58
  277. package/dist/prompts.js.map +2 -2
  278. package/dist/regexps.js +1 -30
  279. package/dist/regexps.js.map +2 -2
  280. package/dist/sea.js +1 -44
  281. package/dist/sea.js.map +2 -2
  282. package/dist/shadow.js +1 -58
  283. package/dist/shadow.js.map +2 -2
  284. package/dist/signal-exit.js +1 -248
  285. package/dist/signal-exit.js.map +2 -2
  286. package/dist/sorts.js +1 -94
  287. package/dist/sorts.js.map +2 -2
  288. package/dist/spawn.js +1 -199
  289. package/dist/spawn.js.map +2 -2
  290. package/dist/spinner.js +1 -865
  291. package/dist/spinner.js.map +2 -2
  292. package/dist/ssri.js +1 -71
  293. package/dist/ssri.js.map +2 -2
  294. package/dist/stdio/clear.js +1 -82
  295. package/dist/stdio/clear.js.map +2 -2
  296. package/dist/stdio/divider.js +3 -89
  297. package/dist/stdio/divider.js.map +2 -2
  298. package/dist/stdio/footer.js +2 -94
  299. package/dist/stdio/footer.js.map +2 -2
  300. package/dist/stdio/header.js +2 -100
  301. package/dist/stdio/header.js.map +2 -2
  302. package/dist/stdio/mask.js +5 -206
  303. package/dist/stdio/mask.js.map +2 -2
  304. package/dist/stdio/progress.js +2 -209
  305. package/dist/stdio/progress.js.map +2 -2
  306. package/dist/stdio/prompts.js +1 -88
  307. package/dist/stdio/prompts.js.map +2 -2
  308. package/dist/stdio/stderr.js +2 -89
  309. package/dist/stdio/stderr.js.map +2 -2
  310. package/dist/stdio/stdout.js +2 -103
  311. package/dist/stdio/stdout.js.map +2 -2
  312. package/dist/streams.js +1 -78
  313. package/dist/streams.js.map +2 -2
  314. package/dist/strings.js +3 -251
  315. package/dist/strings.js.map +2 -2
  316. package/dist/suppress-warnings.js +1 -98
  317. package/dist/suppress-warnings.js.map +2 -2
  318. package/dist/tables.js +3 -128
  319. package/dist/tables.js.map +2 -2
  320. package/dist/temporary-executor.js +1 -53
  321. package/dist/temporary-executor.js.map +2 -2
  322. package/dist/types.js +1 -72
  323. package/dist/types.js.map +2 -2
  324. package/dist/url.js +1 -142
  325. package/dist/url.js.map +2 -2
  326. package/dist/utils/get-ipc.js +1 -58
  327. package/dist/utils/get-ipc.js.map +2 -2
  328. package/dist/validation/json-parser.js +1 -127
  329. package/dist/validation/json-parser.js.map +2 -2
  330. package/dist/validation/types.js +1 -15
  331. package/dist/validation/types.js.map +2 -2
  332. package/dist/versions.js +1 -153
  333. package/dist/versions.js.map +2 -2
  334. package/dist/words.js +1 -50
  335. package/dist/words.js.map +2 -2
  336. package/dist/zod.js +1 -27
  337. package/dist/zod.js.map +2 -2
  338. package/package.json +4 -4
package/dist/arrays.js CHANGED
@@ -1,87 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var arrays_exports = {};
20
- __export(arrays_exports, {
21
- arrayChunk: () => arrayChunk,
22
- arrayUnique: () => arrayUnique,
23
- isArray: () => isArray,
24
- joinAnd: () => joinAnd,
25
- joinOr: () => joinOr
26
- });
27
- module.exports = __toCommonJS(arrays_exports);
28
- let _conjunctionFormatter;
29
- // @__NO_SIDE_EFFECTS__
30
- function getConjunctionFormatter() {
31
- if (_conjunctionFormatter === void 0) {
32
- _conjunctionFormatter = new Intl.ListFormat("en", {
33
- style: "long",
34
- // "and" lists.
35
- type: "conjunction"
36
- });
37
- }
38
- return _conjunctionFormatter;
39
- }
40
- let _disjunctionFormatter;
41
- // @__NO_SIDE_EFFECTS__
42
- function getDisjunctionFormatter() {
43
- if (_disjunctionFormatter === void 0) {
44
- _disjunctionFormatter = new Intl.ListFormat("en", {
45
- style: "long",
46
- // "or" lists.
47
- type: "disjunction"
48
- });
49
- }
50
- return _disjunctionFormatter;
51
- }
52
- // @__NO_SIDE_EFFECTS__
53
- function arrayChunk(arr, size) {
54
- const chunkSize = size ?? 2;
55
- if (chunkSize <= 0) {
56
- throw new Error("Chunk size must be greater than 0");
57
- }
58
- const { length } = arr;
59
- const actualChunkSize = Math.min(length, chunkSize);
60
- const chunks = [];
61
- for (let i = 0; i < length; i += actualChunkSize) {
62
- chunks.push(arr.slice(i, i + actualChunkSize));
63
- }
64
- return chunks;
65
- }
66
- // @__NO_SIDE_EFFECTS__
67
- function arrayUnique(arr) {
68
- return [...new Set(arr)];
69
- }
70
- const isArray = Array.isArray;
71
- // @__NO_SIDE_EFFECTS__
72
- function joinAnd(arr) {
73
- return (/* @__PURE__ */ getConjunctionFormatter()).format(arr);
74
- }
75
- // @__NO_SIDE_EFFECTS__
76
- function joinOr(arr) {
77
- return (/* @__PURE__ */ getDisjunctionFormatter()).format(arr);
78
- }
79
- // Annotate the CommonJS export names for ESM import in node:
80
- 0 && (module.exports = {
81
- arrayChunk,
82
- arrayUnique,
83
- isArray,
84
- joinAnd,
85
- joinOr
86
- });
2
+ var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var m=(n,t)=>{for(var e in t)u(n,e,{get:t[e],enumerable:!0})},y=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of d(t))!f.call(n,r)&&r!==e&&u(n,r,{get:()=>t[r],enumerable:!(o=l(t,r))||o.enumerable});return n};var g=n=>y(u({},"__esModule",{value:!0}),n);var x={};m(x,{arrayChunk:()=>j,arrayUnique:()=>p,isArray:()=>F,joinAnd:()=>k,joinOr:()=>w});module.exports=g(x);let s;function h(){return s===void 0&&(s=new Intl.ListFormat("en",{style:"long",type:"conjunction"})),s}let a;function T(){return a===void 0&&(a=new Intl.ListFormat("en",{style:"long",type:"disjunction"})),a}function j(n,t){const e=t??2;if(e<=0)throw new Error("Chunk size must be greater than 0");const{length:o}=n,r=Math.min(o,e),c=[];for(let i=0;i<o;i+=r)c.push(n.slice(i,i+r));return c}function p(n){return[...new Set(n)]}const F=Array.isArray;function k(n){return h().format(n)}function w(n){return T().format(n)}0&&(module.exports={arrayChunk,arrayUnique,isArray,joinAnd,joinOr});
87
3
  //# sourceMappingURL=arrays.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/arrays.ts"],
4
4
  "sourcesContent": ["/**\n * @fileoverview Array utility functions for formatting lists and collections.\n * Provides conjunction and disjunction formatters using Intl.ListFormat.\n */\n\nlet _conjunctionFormatter: Intl.ListFormat | undefined\n/**\n * Get a cached Intl.ListFormat instance for conjunction (and) formatting.\n *\n * Creates a singleton formatter for English \"and\" lists using the long style.\n * The formatter is lazily initialized on first use and reused for performance.\n *\n * @returns Cached Intl.ListFormat instance configured for conjunction formatting\n *\n * @example\n * ```ts\n * const formatter = getConjunctionFormatter()\n * formatter.format(['apple', 'banana', 'cherry'])\n * // Returns: \"apple, banana, and cherry\"\n * ```\n *\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getConjunctionFormatter() {\n if (_conjunctionFormatter === undefined) {\n _conjunctionFormatter = new Intl.ListFormat('en', {\n style: 'long',\n // \"and\" lists.\n type: 'conjunction',\n })\n }\n return _conjunctionFormatter\n}\n\nlet _disjunctionFormatter: Intl.ListFormat | undefined\n/**\n * Get a cached Intl.ListFormat instance for disjunction (or) formatting.\n *\n * Creates a singleton formatter for English \"or\" lists using the long style.\n * The formatter is lazily initialized on first use and reused for performance.\n *\n * @returns Cached Intl.ListFormat instance configured for disjunction formatting\n *\n * @example\n * ```ts\n * const formatter = getDisjunctionFormatter()\n * formatter.format(['red', 'blue', 'green'])\n * // Returns: \"red, blue, or green\"\n * ```\n *\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getDisjunctionFormatter() {\n if (_disjunctionFormatter === undefined) {\n _disjunctionFormatter = new Intl.ListFormat('en', {\n style: 'long',\n // \"or\" lists.\n type: 'disjunction',\n })\n }\n return _disjunctionFormatter\n}\n\n/**\n * Split an array into chunks of a specified size.\n *\n * Divides an array into smaller arrays of the specified chunk size.\n * The last chunk may contain fewer elements if the array length is not\n * evenly divisible by the chunk size.\n *\n * @param arr - The array to split into chunks (can be readonly)\n * @param size - Size of each chunk. Must be greater than 0.\n * @default 2\n * @returns Array of chunks, where each chunk is an array of elements\n * @throws {Error} If chunk size is less than or equal to 0\n *\n * @example\n * ```ts\n * // Split into pairs (default)\n * arrayChunk([1, 2, 3, 4, 5])\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * // Split into groups of 3\n * arrayChunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3)\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n *\n * // Works with readonly arrays\n * const readonlyArr = [1, 2, 3] as const\n * arrayChunk(readonlyArr)\n * // Returns: [[1, 2], [3]]\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function arrayChunk<T>(\n arr: T[] | readonly T[],\n size?: number | undefined,\n): T[][] {\n const chunkSize = size ?? 2\n if (chunkSize <= 0) {\n throw new Error('Chunk size must be greater than 0')\n }\n const { length } = arr\n const actualChunkSize = Math.min(length, chunkSize)\n const chunks = []\n for (let i = 0; i < length; i += actualChunkSize) {\n chunks.push(arr.slice(i, i + actualChunkSize) as T[])\n }\n return chunks\n}\n\n/**\n * Get unique values from an array.\n *\n * Returns a new array containing only the unique values from the input array.\n * Uses `Set` internally for efficient deduplication. Order of first occurrence\n * is preserved.\n *\n * @param arr - The array to deduplicate (can be readonly)\n * @returns New array with duplicate values removed\n *\n * @example\n * ```ts\n * // Remove duplicate numbers\n * arrayUnique([1, 2, 2, 3, 1, 4])\n * // Returns: [1, 2, 3, 4]\n *\n * // Remove duplicate strings\n * arrayUnique(['apple', 'banana', 'apple', 'cherry'])\n * // Returns: ['apple', 'banana', 'cherry']\n *\n * // Works with readonly arrays\n * const readonlyArr = [1, 1, 2] as const\n * arrayUnique(readonlyArr)\n * // Returns: [1, 2]\n *\n * // Empty arrays return empty\n * arrayUnique([])\n * // Returns: []\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function arrayUnique<T>(arr: T[] | readonly T[]): T[] {\n return [...new Set(arr)]\n}\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\n\n/**\n * Alias for native Array.isArray.\n * Determines whether the passed value is an array.\n *\n * This is a direct reference to the native `Array.isArray` method,\n * providing a type guard that narrows the type to an array type.\n * Exported for consistency with other array utilities in this module.\n *\n * @param value - The value to check\n * @returns `true` if the value is an array, `false` otherwise\n *\n * @example\n * ```ts\n * // Check if value is an array\n * isArray([1, 2, 3])\n * // Returns: true\n *\n * isArray('not an array')\n * // Returns: false\n *\n * isArray(null)\n * // Returns: false\n *\n * // Type guard usage\n * function processValue(value: unknown) {\n * if (isArray(value)) {\n * // TypeScript knows value is an array here\n * console.log(value.length)\n * }\n * }\n * ```\n */\nexport const isArray = Array.isArray\n\n/**\n * Join array elements with proper \"and\" conjunction formatting.\n *\n * Formats an array of strings into a grammatically correct list using\n * \"and\" as the conjunction. Uses `Intl.ListFormat` for proper English\n * formatting with Oxford comma support.\n *\n * @param arr - Array of strings to join (can be readonly)\n * @returns Formatted string with proper \"and\" conjunction\n *\n * @example\n * ```ts\n * // Two items\n * joinAnd(['apples', 'oranges'])\n * // Returns: \"apples and oranges\"\n *\n * // Three or more items (Oxford comma)\n * joinAnd(['apples', 'oranges', 'bananas'])\n * // Returns: \"apples, oranges, and bananas\"\n *\n * // Single item\n * joinAnd(['apples'])\n * // Returns: \"apples\"\n *\n * // Empty array\n * joinAnd([])\n * // Returns: \"\"\n *\n * // Usage in messages\n * const items = ['React', 'Vue', 'Angular']\n * console.log(`You can choose ${joinAnd(items)}`)\n * // Outputs: \"You can choose React, Vue, and Angular\"\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function joinAnd(arr: string[] | readonly string[]): string {\n return getConjunctionFormatter().format(arr)\n}\n\n/**\n * Join array elements with proper \"or\" disjunction formatting.\n *\n * Formats an array of strings into a grammatically correct list using\n * \"or\" as the disjunction. Uses `Intl.ListFormat` for proper English\n * formatting with Oxford comma support.\n *\n * @param arr - Array of strings to join (can be readonly)\n * @returns Formatted string with proper \"or\" disjunction\n *\n * @example\n * ```ts\n * // Two items\n * joinOr(['yes', 'no'])\n * // Returns: \"yes or no\"\n *\n * // Three or more items (Oxford comma)\n * joinOr(['red', 'green', 'blue'])\n * // Returns: \"red, green, or blue\"\n *\n * // Single item\n * joinOr(['maybe'])\n * // Returns: \"maybe\"\n *\n * // Empty array\n * joinOr([])\n * // Returns: \"\"\n *\n * // Usage in prompts\n * const options = ['npm', 'yarn', 'pnpm']\n * console.log(`Choose a package manager: ${joinOr(options)}`)\n * // Outputs: \"Choose a package manager: npm, yarn, or pnpm\"\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function joinOr(arr: string[] | readonly string[]): string {\n return getDisjunctionFormatter().format(arr)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAI;AAAA;AAmBJ,SAAS,0BAA0B;AACjC,MAAI,0BAA0B,QAAW;AACvC,4BAAwB,IAAI,KAAK,WAAW,MAAM;AAAA,MAChD,OAAO;AAAA;AAAA,MAEP,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,IAAI;AAAA;AAmBJ,SAAS,0BAA0B;AACjC,MAAI,0BAA0B,QAAW;AACvC,4BAAwB,IAAI,KAAK,WAAW,MAAM;AAAA,MAChD,OAAO;AAAA;AAAA,MAEP,MAAM;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAAA;AAgCO,SAAS,WACd,KACA,MACO;AACP,QAAM,YAAY,QAAQ;AAC1B,MAAI,aAAa,GAAG;AAClB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AACA,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,kBAAkB,KAAK,IAAI,QAAQ,SAAS;AAClD,QAAM,SAAS,CAAC;AAChB,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK,iBAAiB;AAChD,WAAO,KAAK,IAAI,MAAM,GAAG,IAAI,eAAe,CAAQ;AAAA,EACtD;AACA,SAAO;AACT;AAAA;AAiCO,SAAS,YAAe,KAA8B;AAC3D,SAAO,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC;AACzB;AAuCO,MAAM,UAAU,MAAM;AAAA;AAqCtB,SAAS,QAAQ,KAA2C;AACjE,UAAO,wCAAwB,GAAE,OAAO,GAAG;AAC7C;AAAA;AAqCO,SAAS,OAAO,KAA2C;AAChE,UAAO,wCAAwB,GAAE,OAAO,GAAG;AAC7C;",
6
- "names": []
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,gBAAAC,EAAA,YAAAC,EAAA,YAAAC,EAAA,WAAAC,IAAA,eAAAC,EAAAP,GAKA,IAAIQ,EAmBJ,SAASC,GAA0B,CACjC,OAAID,IAA0B,SAC5BA,EAAwB,IAAI,KAAK,WAAW,KAAM,CAChD,MAAO,OAEP,KAAM,aACR,CAAC,GAEIA,CACT,CAEA,IAAIE,EAmBJ,SAASC,GAA0B,CACjC,OAAID,IAA0B,SAC5BA,EAAwB,IAAI,KAAK,WAAW,KAAM,CAChD,MAAO,OAEP,KAAM,aACR,CAAC,GAEIA,CACT,CAgCO,SAASR,EACdU,EACAC,EACO,CACP,MAAMC,EAAYD,GAAQ,EAC1B,GAAIC,GAAa,EACf,MAAM,IAAI,MAAM,mCAAmC,EAErD,KAAM,CAAE,OAAAC,CAAO,EAAIH,EACbI,EAAkB,KAAK,IAAID,EAAQD,CAAS,EAC5CG,EAAS,CAAC,EAChB,QAAS,EAAI,EAAG,EAAIF,EAAQ,GAAKC,EAC/BC,EAAO,KAAKL,EAAI,MAAM,EAAG,EAAII,CAAe,CAAQ,EAEtD,OAAOC,CACT,CAiCO,SAASd,EAAeS,EAA8B,CAC3D,MAAO,CAAC,GAAG,IAAI,IAAIA,CAAG,CAAC,CACzB,CAuCO,MAAMR,EAAU,MAAM,QAqCtB,SAASC,EAAQO,EAA2C,CACjE,OAAOH,EAAwB,EAAE,OAAOG,CAAG,CAC7C,CAqCO,SAASN,EAAOM,EAA2C,CAChE,OAAOD,EAAwB,EAAE,OAAOC,CAAG,CAC7C",
6
+ "names": ["arrays_exports", "__export", "arrayChunk", "arrayUnique", "isArray", "joinAnd", "joinOr", "__toCommonJS", "_conjunctionFormatter", "getConjunctionFormatter", "_disjunctionFormatter", "getDisjunctionFormatter", "arr", "size", "chunkSize", "length", "actualChunkSize", "chunks"]
7
7
  }
package/dist/bin.js CHANGED
@@ -1,404 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var bin_exports = {};
20
- __export(bin_exports, {
21
- execBin: () => execBin,
22
- findRealBin: () => findRealBin,
23
- findRealNpm: () => findRealNpm,
24
- findRealPnpm: () => findRealPnpm,
25
- findRealYarn: () => findRealYarn,
26
- isShadowBinPath: () => isShadowBinPath,
27
- resolveBinPathSync: () => resolveBinPathSync,
28
- whichBin: () => whichBin,
29
- whichBinSync: () => whichBinSync
30
- });
31
- module.exports = __toCommonJS(bin_exports);
32
- var import_appdata = require("#env/appdata");
33
- var import_home = require("#env/home");
34
- var import_localappdata = require("#env/localappdata");
35
- var import_xdg_data_home = require("#env/xdg-data-home");
36
- var import_platform = require("#constants/platform");
37
- var import_fs = require("./fs");
38
- var import_objects = require("./objects");
39
- var import_path = require("./path");
40
- var import_spawn = require("./spawn");
41
- let _fs;
42
- // @__NO_SIDE_EFFECTS__
43
- function getFs() {
44
- if (_fs === void 0) {
45
- _fs = require("node:fs");
46
- }
47
- return _fs;
48
- }
49
- let _path;
50
- // @__NO_SIDE_EFFECTS__
51
- function getPath() {
52
- if (_path === void 0) {
53
- _path = require("node:path");
54
- }
55
- return _path;
56
- }
57
- let _which;
58
- // @__NO_SIDE_EFFECTS__
59
- function getWhich() {
60
- if (_which === void 0) {
61
- _which = require("./external/which");
62
- }
63
- return _which;
64
- }
65
- // @__NO_SIDE_EFFECTS__
66
- async function execBin(binPath, args, options) {
67
- const resolvedPath = (0, import_path.isPath)(binPath) ? /* @__PURE__ */ resolveBinPathSync(binPath) : await whichBin(binPath);
68
- if (!resolvedPath) {
69
- const error = new Error(`Binary not found: ${binPath}`);
70
- error.code = "ENOENT";
71
- throw error;
72
- }
73
- const binCommand = Array.isArray(resolvedPath) ? resolvedPath[0] : resolvedPath;
74
- return await (0, import_spawn.spawn)(binCommand, args ?? [], {
75
- shell: import_platform.WIN32,
76
- ...options
77
- });
78
- }
79
- async function whichBin(binName, options) {
80
- const which = /* @__PURE__ */ getWhich();
81
- const opts = { nothrow: true, ...options };
82
- const result = await which?.(binName, opts);
83
- if (options?.all) {
84
- const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
85
- return paths?.length ? paths.map((p) => /* @__PURE__ */ resolveBinPathSync(p)) : paths;
86
- }
87
- if (!result) {
88
- return void 0;
89
- }
90
- return /* @__PURE__ */ resolveBinPathSync(result);
91
- }
92
- function whichBinSync(binName, options) {
93
- const opts = { nothrow: true, ...options };
94
- const result = (/* @__PURE__ */ getWhich())?.sync(binName, opts);
95
- if ((0, import_objects.getOwn)(options, "all")) {
96
- const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
97
- return paths?.length ? paths.map((p) => /* @__PURE__ */ resolveBinPathSync(p)) : paths;
98
- }
99
- if (!result) {
100
- return void 0;
101
- }
102
- return /* @__PURE__ */ resolveBinPathSync(result);
103
- }
104
- function isShadowBinPath(dirPath) {
105
- if (!dirPath) {
106
- return false;
107
- }
108
- const normalized = dirPath.replace(/\\/g, "/");
109
- return normalized.includes("node_modules/.bin");
110
- }
111
- function findRealBin(binName, commonPaths = []) {
112
- const fs = /* @__PURE__ */ getFs();
113
- const path = /* @__PURE__ */ getPath();
114
- const which = /* @__PURE__ */ getWhich();
115
- for (const binPath2 of commonPaths) {
116
- if (fs?.existsSync(binPath2)) {
117
- return binPath2;
118
- }
119
- }
120
- const binPath = which?.sync(binName, { nothrow: true });
121
- if (binPath) {
122
- const binDir = path?.dirname(binPath);
123
- if (isShadowBinPath(binDir)) {
124
- const allPaths = which?.sync(binName, { all: true, nothrow: true }) || [];
125
- const pathsArray = Array.isArray(allPaths) ? allPaths : typeof allPaths === "string" ? [allPaths] : [];
126
- for (const altPath of pathsArray) {
127
- const altDir = path?.dirname(altPath);
128
- if (!isShadowBinPath(altDir)) {
129
- return altPath;
130
- }
131
- }
132
- }
133
- return binPath;
134
- }
135
- return void 0;
136
- }
137
- function findRealNpm() {
138
- const fs = /* @__PURE__ */ getFs();
139
- const path = /* @__PURE__ */ getPath();
140
- const nodeDir = path?.dirname(process.execPath);
141
- const npmInNodeDir = path?.join(nodeDir, "npm");
142
- if (fs?.existsSync(npmInNodeDir)) {
143
- return npmInNodeDir;
144
- }
145
- const commonPaths = ["/usr/local/bin/npm", "/usr/bin/npm"];
146
- const result = findRealBin("npm", commonPaths);
147
- if (result && fs?.existsSync(result)) {
148
- return result;
149
- }
150
- const npmPath = whichBinSync("npm", { nothrow: true });
151
- if (npmPath && typeof npmPath === "string" && fs?.existsSync(npmPath)) {
152
- return npmPath;
153
- }
154
- return "npm";
155
- }
156
- function findRealPnpm() {
157
- const path = /* @__PURE__ */ getPath();
158
- const commonPaths = import_platform.WIN32 ? [
159
- // Windows common paths.
160
- path?.join(import_appdata.APPDATA, "npm", "pnpm.cmd"),
161
- path?.join(import_appdata.APPDATA, "npm", "pnpm"),
162
- path?.join(import_localappdata.LOCALAPPDATA, "pnpm", "pnpm.cmd"),
163
- path?.join(import_localappdata.LOCALAPPDATA, "pnpm", "pnpm"),
164
- "C:\\Program Files\\nodejs\\pnpm.cmd",
165
- "C:\\Program Files\\nodejs\\pnpm"
166
- ].filter(Boolean) : [
167
- // Unix common paths.
168
- "/usr/local/bin/pnpm",
169
- "/usr/bin/pnpm",
170
- path?.join(
171
- import_xdg_data_home.XDG_DATA_HOME || `${import_home.HOME}/.local/share`,
172
- "pnpm/pnpm"
173
- ),
174
- path?.join(import_home.HOME, ".pnpm/pnpm")
175
- ].filter(Boolean);
176
- return findRealBin("pnpm", commonPaths) ?? "";
177
- }
178
- function findRealYarn() {
179
- const path = /* @__PURE__ */ getPath();
180
- const commonPaths = [
181
- "/usr/local/bin/yarn",
182
- "/usr/bin/yarn",
183
- path?.join(import_home.HOME, ".yarn/bin/yarn"),
184
- path?.join(import_home.HOME, ".config/yarn/global/node_modules/.bin/yarn")
185
- ].filter(Boolean);
186
- return findRealBin("yarn", commonPaths) ?? "";
187
- }
188
- // @__NO_SIDE_EFFECTS__
189
- function resolveBinPathSync(binPath) {
190
- const fs = /* @__PURE__ */ getFs();
191
- const path = /* @__PURE__ */ getPath();
192
- if (!path?.isAbsolute(binPath)) {
193
- try {
194
- const resolved = whichBinSync(binPath);
195
- if (resolved) {
196
- binPath = resolved;
197
- }
198
- } catch {
199
- }
200
- }
201
- binPath = (0, import_path.normalizePath)(binPath);
202
- if (binPath === ".") {
203
- return binPath;
204
- }
205
- const ext = path?.extname(binPath);
206
- const extLowered = ext.toLowerCase();
207
- const basename = path?.basename(binPath, ext);
208
- const voltaIndex = basename === "node" ? -1 : /(?<=\/)\.volta\//i.exec(binPath)?.index ?? -1;
209
- if (voltaIndex !== -1) {
210
- const voltaPath = binPath.slice(0, voltaIndex);
211
- const voltaToolsPath = path?.join(voltaPath, "tools");
212
- const voltaImagePath = path?.join(voltaToolsPath, "image");
213
- const voltaUserPath = path?.join(voltaToolsPath, "user");
214
- const voltaPlatform = (0, import_fs.readJsonSync)(
215
- path?.join(voltaUserPath, "platform.json"),
216
- { throws: false }
217
- );
218
- const voltaNodeVersion = voltaPlatform?.node?.runtime;
219
- const voltaNpmVersion = voltaPlatform?.node?.npm;
220
- let voltaBinPath = "";
221
- if (basename === "npm" || basename === "npx") {
222
- if (voltaNpmVersion) {
223
- const relCliPath = `bin/${basename}-cli.js`;
224
- voltaBinPath = path?.join(
225
- voltaImagePath,
226
- `npm/${voltaNpmVersion}/${relCliPath}`
227
- );
228
- if (voltaNodeVersion && !fs?.existsSync(voltaBinPath)) {
229
- voltaBinPath = path?.join(
230
- voltaImagePath,
231
- `node/${voltaNodeVersion}/lib/node_modules/npm/${relCliPath}`
232
- );
233
- if (!fs?.existsSync(voltaBinPath)) {
234
- voltaBinPath = "";
235
- }
236
- }
237
- }
238
- } else {
239
- const voltaUserBinPath = path?.join(voltaUserPath, "bin");
240
- const binInfo = (0, import_fs.readJsonSync)(
241
- path?.join(voltaUserBinPath, `${basename}.json`),
242
- { throws: false }
243
- );
244
- const binPackage = binInfo?.package;
245
- if (binPackage) {
246
- voltaBinPath = path?.join(
247
- voltaImagePath,
248
- `packages/${binPackage}/bin/${basename}`
249
- );
250
- if (!fs?.existsSync(voltaBinPath)) {
251
- voltaBinPath = `${voltaBinPath}.cmd`;
252
- if (!fs?.existsSync(voltaBinPath)) {
253
- voltaBinPath = "";
254
- }
255
- }
256
- }
257
- }
258
- if (voltaBinPath) {
259
- try {
260
- return (0, import_path.normalizePath)(fs?.realpathSync.native(voltaBinPath));
261
- } catch {
262
- }
263
- return voltaBinPath;
264
- }
265
- }
266
- if (import_platform.WIN32) {
267
- const hasKnownExt = extLowered === "" || extLowered === ".cmd" || extLowered === ".exe" || extLowered === ".ps1";
268
- const isNpmOrNpx = basename === "npm" || basename === "npx";
269
- const isPnpmOrYarn = basename === "pnpm" || basename === "yarn";
270
- if (hasKnownExt && isNpmOrNpx) {
271
- const quickPath = path?.join(
272
- path?.dirname(binPath),
273
- `node_modules/npm/bin/${basename}-cli.js`
274
- );
275
- if (fs?.existsSync(quickPath)) {
276
- try {
277
- return fs?.realpathSync.native(quickPath);
278
- } catch {
279
- }
280
- return quickPath;
281
- }
282
- }
283
- let relPath = "";
284
- if (hasKnownExt && // Only parse shell scripts and batch files, not actual executables.
285
- // .exe files are already executables and don't need path resolution from wrapper scripts.
286
- extLowered !== ".exe" && // Check if file exists before attempting to read it to avoid ENOENT errors.
287
- fs?.existsSync(binPath)) {
288
- const source = fs?.readFileSync(binPath, "utf8");
289
- if (isNpmOrNpx) {
290
- if (extLowered === ".cmd") {
291
- relPath = basename === "npm" ? /(?<="NPM_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "" : /(?<="NPX_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "";
292
- } else if (extLowered === "") {
293
- relPath = basename === "npm" ? /(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "" : /(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "";
294
- } else if (extLowered === ".ps1") {
295
- relPath = basename === "npm" ? /(?<=\$NPM_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(
296
- source
297
- )?.[0] || "" : /(?<=\$NPX_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(
298
- source
299
- )?.[0] || "";
300
- }
301
- } else if (isPnpmOrYarn) {
302
- if (extLowered === ".cmd") {
303
- relPath = /(?<=node\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(source)?.[1] || "";
304
- if (!relPath) {
305
- relPath = /(?<="%~dp0\\[^"]*node[^"]*"\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(
306
- source
307
- )?.[1] || "";
308
- }
309
- if (!relPath) {
310
- relPath = /(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(source)?.[0] || "";
311
- }
312
- } else if (extLowered === "") {
313
- relPath = /(?<="\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(
314
- source
315
- )?.[0] || "";
316
- if (!relPath) {
317
- relPath = /(?<=exec\s+node\s+"\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(
318
- source
319
- )?.[0] || "";
320
- }
321
- if (!relPath) {
322
- relPath = /(?<="\$basedir\/).*(?=" "\$@"\n)/.exec(source)?.[0] || "";
323
- }
324
- } else if (extLowered === ".ps1") {
325
- relPath = /(?<="\$basedir\/).*(?=" $args\n)/.exec(source)?.[0] || "";
326
- }
327
- } else if (extLowered === ".cmd") {
328
- relPath = /(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(source)?.[0] || "";
329
- } else if (extLowered === "") {
330
- relPath = /(?<="$basedir\/).*(?=" "\$@"\n)/.exec(source)?.[0] || "";
331
- } else if (extLowered === ".ps1") {
332
- relPath = /(?<="\$basedir\/).*(?=" $args\n)/.exec(source)?.[0] || "";
333
- }
334
- if (relPath) {
335
- binPath = (0, import_path.normalizePath)(path?.resolve(path?.dirname(binPath), relPath));
336
- }
337
- }
338
- } else {
339
- let hasNoExt = extLowered === "";
340
- const isPnpmOrYarn = basename === "pnpm" || basename === "yarn";
341
- const isNpmOrNpx = basename === "npm" || basename === "npx";
342
- if (isPnpmOrYarn && binPath.includes("/.bin/pnpm/bin/")) {
343
- const binIndex = binPath.indexOf("/.bin/pnpm");
344
- if (binIndex !== -1) {
345
- const baseBinPath = binPath.slice(0, binIndex + "/.bin/pnpm".length);
346
- try {
347
- const stats = fs?.statSync(baseBinPath);
348
- if (stats.isFile()) {
349
- binPath = (0, import_path.normalizePath)(baseBinPath);
350
- hasNoExt = !path?.extname(binPath);
351
- }
352
- } catch {
353
- }
354
- }
355
- }
356
- if (hasNoExt && (isPnpmOrYarn || isNpmOrNpx) && // For extensionless files (Unix shell scripts), verify existence before reading.
357
- // This prevents ENOENT errors when the bin path doesn't exist.
358
- fs?.existsSync(binPath)) {
359
- const source = fs?.readFileSync(binPath, "utf8");
360
- let relPath = "";
361
- if (isPnpmOrYarn) {
362
- relPath = /(?<="\$basedir\/)\.tools\/[^"]+(?="\s+"\$@")/.exec(source)?.[0] || "";
363
- if (!relPath) {
364
- relPath = /(?<="\$basedir\/)[^"]+(?="\s+"\$@")/.exec(source)?.[0] || "";
365
- }
366
- if (!relPath) {
367
- const match = /exec\s+node\s+"?\$basedir\/([^"]+)"?\s+"\$@"/.exec(
368
- source
369
- );
370
- if (match) {
371
- relPath = match[1] || "";
372
- }
373
- }
374
- if (relPath && basename === "pnpm" && relPath.startsWith("pnpm/")) {
375
- relPath = `../${relPath}`;
376
- }
377
- } else if (isNpmOrNpx) {
378
- relPath = basename === "npm" ? /(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "" : /(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "";
379
- }
380
- if (relPath) {
381
- binPath = (0, import_path.normalizePath)(path?.resolve(path?.dirname(binPath), relPath));
382
- }
383
- }
384
- }
385
- try {
386
- const realPath = fs?.realpathSync.native(binPath);
387
- return (0, import_path.normalizePath)(realPath);
388
- } catch {
389
- }
390
- return (0, import_path.normalizePath)(binPath);
391
- }
392
- // Annotate the CommonJS export names for ESM import in node:
393
- 0 && (module.exports = {
394
- execBin,
395
- findRealBin,
396
- findRealNpm,
397
- findRealPnpm,
398
- findRealYarn,
399
- isShadowBinPath,
400
- resolveBinPathSync,
401
- whichBin,
402
- whichBinSync
403
- });
2
+ var _=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var X=(n,e)=>{for(var o in e)_(n,o,{get:e[o],enumerable:!0})},k=(n,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of M(e))!T.call(n,s)&&s!==o&&_(n,s,{get:()=>e[s],enumerable:!(c=F(e,s))||c.enumerable});return n};var q=n=>k(_({},"__esModule",{value:!0}),n);var U={};X(U,{execBin:()=>z,findRealBin:()=>S,findRealNpm:()=>W,findRealPnpm:()=>Y,findRealYarn:()=>H,isShadowBinPath:()=>N,resolveBinPathSync:()=>x,whichBin:()=>J,whichBinSync:()=>L});module.exports=q(U);var I=require("#env/appdata"),y=require("#env/home"),P=require("#env/localappdata"),E=require("#env/xdg-data-home"),$=require("#constants/platform"),v=require("./fs"),b=require("./objects"),d=require("./path"),R=require("./spawn");let w;function C(){return w===void 0&&(w=require("node:fs")),w}let j;function h(){return j===void 0&&(j=require("node:path")),j}let A;function B(){return A===void 0&&(A=require("./external/which")),A}async function z(n,e,o){const c=(0,d.isPath)(n)?x(n):await J(n);if(!c){const r=new Error(`Binary not found: ${n}`);throw r.code="ENOENT",r}const s=Array.isArray(c)?c[0]:c;return await(0,R.spawn)(s,e??[],{shell:$.WIN32,...o})}async function J(n,e){const o=B(),c={nothrow:!0,...e},s=await o?.(n,c);if(e?.all){const r=Array.isArray(s)?s:typeof s=="string"?[s]:void 0;return r?.length?r.map(p=>x(p)):r}if(s)return x(s)}function L(n,e){const o={nothrow:!0,...e},c=B()?.sync(n,o);if((0,b.getOwn)(e,"all")){const s=Array.isArray(c)?c:typeof c=="string"?[c]:void 0;return s?.length?s.map(r=>x(r)):s}if(c)return x(c)}function N(n){return n?n.replace(/\\/g,"/").includes("node_modules/.bin"):!1}function S(n,e=[]){const o=C(),c=h(),s=B();for(const p of e)if(o?.existsSync(p))return p;const r=s?.sync(n,{nothrow:!0});if(r){const p=c?.dirname(r);if(N(p)){const a=s?.sync(n,{all:!0,nothrow:!0})||[],m=Array.isArray(a)?a:typeof a=="string"?[a]:[];for(const l of m){const i=c?.dirname(l);if(!N(i))return l}}return r}}function W(){const n=C(),e=h(),o=e?.dirname(process.execPath),c=e?.join(o,"npm");if(n?.existsSync(c))return c;const r=S("npm",["/usr/local/bin/npm","/usr/bin/npm"]);if(r&&n?.existsSync(r))return r;const p=L("npm",{nothrow:!0});return p&&typeof p=="string"&&n?.existsSync(p)?p:"npm"}function Y(){const n=h(),e=$.WIN32?[n?.join(I.APPDATA,"npm","pnpm.cmd"),n?.join(I.APPDATA,"npm","pnpm"),n?.join(P.LOCALAPPDATA,"pnpm","pnpm.cmd"),n?.join(P.LOCALAPPDATA,"pnpm","pnpm"),"C:\\Program Files\\nodejs\\pnpm.cmd","C:\\Program Files\\nodejs\\pnpm"].filter(Boolean):["/usr/local/bin/pnpm","/usr/bin/pnpm",n?.join(E.XDG_DATA_HOME||`${y.HOME}/.local/share`,"pnpm/pnpm"),n?.join(y.HOME,".pnpm/pnpm")].filter(Boolean);return S("pnpm",e)??""}function H(){const n=h(),e=["/usr/local/bin/yarn","/usr/bin/yarn",n?.join(y.HOME,".yarn/bin/yarn"),n?.join(y.HOME,".config/yarn/global/node_modules/.bin/yarn")].filter(Boolean);return S("yarn",e)??""}function x(n){const e=C(),o=h();if(!o?.isAbsolute(n))try{const a=L(n);a&&(n=a)}catch{}if(n=(0,d.normalizePath)(n),n===".")return n;const c=o?.extname(n),s=c.toLowerCase(),r=o?.basename(n,c),p=r==="node"?-1:/(?<=\/)\.volta\//i.exec(n)?.index??-1;if(p!==-1){const a=n.slice(0,p),m=o?.join(a,"tools"),l=o?.join(m,"image"),i=o?.join(m,"user"),t=(0,v.readJsonSync)(o?.join(i,"platform.json"),{throws:!1}),u=t?.node?.runtime,O=t?.node?.npm;let f="";if(r==="npm"||r==="npx"){if(O){const g=`bin/${r}-cli.js`;f=o?.join(l,`npm/${O}/${g}`),u&&!e?.existsSync(f)&&(f=o?.join(l,`node/${u}/lib/node_modules/npm/${g}`),e?.existsSync(f)||(f=""))}}else{const g=o?.join(i,"bin"),D=(0,v.readJsonSync)(o?.join(g,`${r}.json`),{throws:!1})?.package;D&&(f=o?.join(l,`packages/${D}/bin/${r}`),e?.existsSync(f)||(f=`${f}.cmd`,e?.existsSync(f)||(f="")))}if(f){try{return(0,d.normalizePath)(e?.realpathSync.native(f))}catch{}return f}}if($.WIN32){const a=s===""||s===".cmd"||s===".exe"||s===".ps1",m=r==="npm"||r==="npx",l=r==="pnpm"||r==="yarn";if(a&&m){const t=o?.join(o?.dirname(n),`node_modules/npm/bin/${r}-cli.js`);if(e?.existsSync(t)){try{return e?.realpathSync.native(t)}catch{}return t}}let i="";if(a&&s!==".exe"&&e?.existsSync(n)){const t=e?.readFileSync(n,"utf8");m?s===".cmd"?i=r==="npm"?/(?<="NPM_CLI_JS=%~dp0\\).*(?=")/.exec(t)?.[0]||"":/(?<="NPX_CLI_JS=%~dp0\\).*(?=")/.exec(t)?.[0]||"":s===""?i=r==="npm"?/(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(t)?.[0]||"":/(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(t)?.[0]||"":s===".ps1"&&(i=r==="npm"?/(?<=\$NPM_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(t)?.[0]||"":/(?<=\$NPX_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(t)?.[0]||""):l?s===".cmd"?(i=/(?<=node\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(t)?.[1]||"",i||(i=/(?<="%~dp0\\[^"]*node[^"]*"\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(t)?.[1]||""),i||(i=/(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(t)?.[0]||"")):s===""?(i=/(?<="\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(t)?.[0]||"",i||(i=/(?<=exec\s+node\s+"\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(t)?.[0]||""),i||(i=/(?<="\$basedir\/).*(?=" "\$@"\n)/.exec(t)?.[0]||"")):s===".ps1"&&(i=/(?<="\$basedir\/).*(?=" $args\n)/.exec(t)?.[0]||""):s===".cmd"?i=/(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(t)?.[0]||"":s===""?i=/(?<="$basedir\/).*(?=" "\$@"\n)/.exec(t)?.[0]||"":s===".ps1"&&(i=/(?<="\$basedir\/).*(?=" $args\n)/.exec(t)?.[0]||""),i&&(n=(0,d.normalizePath)(o?.resolve(o?.dirname(n),i)))}}else{let a=s==="";const m=r==="pnpm"||r==="yarn",l=r==="npm"||r==="npx";if(m&&n.includes("/.bin/pnpm/bin/")){const i=n.indexOf("/.bin/pnpm");if(i!==-1){const t=n.slice(0,i+10);try{(e?.statSync(t)).isFile()&&(n=(0,d.normalizePath)(t),a=!o?.extname(n))}catch{}}}if(a&&(m||l)&&e?.existsSync(n)){const i=e?.readFileSync(n,"utf8");let t="";if(m){if(t=/(?<="\$basedir\/)\.tools\/[^"]+(?="\s+"\$@")/.exec(i)?.[0]||"",t||(t=/(?<="\$basedir\/)[^"]+(?="\s+"\$@")/.exec(i)?.[0]||""),!t){const u=/exec\s+node\s+"?\$basedir\/([^"]+)"?\s+"\$@"/.exec(i);u&&(t=u[1]||"")}t&&r==="pnpm"&&t.startsWith("pnpm/")&&(t=`../${t}`)}else l&&(t=r==="npm"?/(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(i)?.[0]||"":/(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(i)?.[0]||"");t&&(n=(0,d.normalizePath)(o?.resolve(o?.dirname(n),t)))}}try{const a=e?.realpathSync.native(n);return(0,d.normalizePath)(a)}catch{}return(0,d.normalizePath)(n)}0&&(module.exports={execBin,findRealBin,findRealNpm,findRealPnpm,findRealYarn,isShadowBinPath,resolveBinPathSync,whichBin,whichBinSync});
404
3
  //# sourceMappingURL=bin.js.map