@socketsecurity/lib 2.8.4 → 2.9.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.9.0](https://github.com/SocketDev/socket-lib/releases/tag/v2.9.0) - 2025-10-30
9
+
10
+ ### Added
11
+
12
+ - **Socket.dev URL constants**: Added centralized URL constants for Socket.dev services
13
+ - `SOCKET_WEBSITE_URL`: Main Socket.dev website
14
+ - `SOCKET_CONTACT_URL`: Contact page
15
+ - `SOCKET_DASHBOARD_URL`: Dashboard homepage
16
+ - `SOCKET_API_TOKENS_URL`: API tokens settings page
17
+ - `SOCKET_PRICING_URL`: Pricing information
18
+ - `SOCKET_STATUS_URL`: Service status page
19
+ - `SOCKET_DOCS_URL`: Documentation site
20
+ - Available via `@socketsecurity/lib/constants/socket`
21
+
22
+ ### Changed
23
+
24
+ - **Enhanced error messages across library**: Comprehensive audit and improvement of error handling
25
+ - Added actionable error messages with resolution steps throughout modules
26
+ - Improved file system operation errors (permissions, read-only filesystems, path issues)
27
+ - Enhanced DLX error messages with clear troubleshooting guidance
28
+ - Better error context in process locking, binary downloads, and package operations
29
+ - Consistent error formatting with helpful user guidance
30
+ - **Consolidated process locking**: Standardized on directory-based lock format across all modules
31
+ - All locking operations now use `process-lock` module exclusively
32
+ - Lock directories provide atomic guarantees across all filesystems including NFS
33
+ - Consistent mtime-based stale detection with 5-second timeout (aligned with npm npx)
34
+ - Automatic cleanup on process exit with proper signal handling
35
+
8
36
  ## [2.8.4](https://github.com/SocketDev/socket-lib/releases/tag/v2.8.4) - 2025-10-30
9
37
 
10
38
  ### Added
package/dist/bin.js CHANGED
@@ -1,3 +1,11 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var j=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var X=(n,e)=>{for(var i in e)j(n,i,{get:e[i],enumerable:!0})},k=(n,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of W(e))!F.call(n,s)&&s!==i&&j(n,s,{get:()=>e[s],enumerable:!(c=J(e,s))||c.enumerable});return n};var q=n=>k(j({},"__esModule",{value:!0}),n);var U={};X(U,{execBin:()=>M,findRealBin:()=>_,findRealNpm:()=>Y,findRealPnpm:()=>H,findRealYarn:()=>T,isShadowBinPath:()=>C,resolveBinPathSync:()=>g,which:()=>z,whichBin:()=>D,whichBinSync:()=>A,whichSync:()=>R});module.exports=q(U);var h=require("#env/home"),x=require("#env/windows"),O=require("#env/xdg"),$=require("#constants/platform"),B=require("./fs"),l=require("./path"),E=require("./spawn");let I;function P(){return I===void 0&&(I=require("node:fs")),I}let v;function y(){return v===void 0&&(v=require("node:path")),v}let N;function w(){return N===void 0&&(N=require("./external/which")),N}async function M(n,e,i){const c=(0,l.isPath)(n)?g(n):await D(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,E.spawn)(s,e??[],{shell:$.WIN32,...i})}async function z(n,e){return await w()(n,e)}function R(n,e){return w().sync(n,e)}async function D(n,e){const i=w(),c={nothrow:!0,...e},s=await i(n,c);if(c?.all){const r=Array.isArray(s)?s:typeof s=="string"?[s]:void 0;return r?.length?r.map(p=>g(p)):r}if(s)return g(s)}function A(n,e){const i={nothrow:!0,...e},c=R(n,i);if(i.all){const s=Array.isArray(c)?c:typeof c=="string"?[c]:void 0;return s?.length?s.map(r=>g(r)):s}if(c)return g(c)}function C(n){return n?n.replace(/\\/g,"/").includes("node_modules/.bin"):!1}function _(n,e=[]){const i=P(),c=y(),s=w();for(const p of e)if(i?.existsSync(p))return p;const r=s?.sync(n,{nothrow:!0});if(r){const p=c?.dirname(r);if(C(p)){const a=s?.sync(n,{all:!0,nothrow:!0})||[],d=Array.isArray(a)?a:typeof a=="string"?[a]:[];for(const m of d){const o=c?.dirname(m);if(!C(o))return m}}return r}}function Y(){const n=P(),e=y(),i=e?.dirname(process.execPath),c=e?.join(i,"npm");if(n?.existsSync(c))return c;const r=_("npm",["/usr/local/bin/npm","/usr/bin/npm"]);if(r&&n?.existsSync(r))return r;const p=A("npm",{nothrow:!0});return p&&typeof p=="string"&&n?.existsSync(p)?p:"npm"}function H(){const n=y(),e=$.WIN32?[n?.join((0,x.getAppdata)(),"npm","pnpm.cmd"),n?.join((0,x.getAppdata)(),"npm","pnpm"),n?.join((0,x.getLocalappdata)(),"pnpm","pnpm.cmd"),n?.join((0,x.getLocalappdata)(),"pnpm","pnpm"),"C:\\Program Files\\nodejs\\pnpm.cmd","C:\\Program Files\\nodejs\\pnpm"].filter(Boolean):["/usr/local/bin/pnpm","/usr/bin/pnpm",n?.join((0,O.getXdgDataHome)()||`${(0,h.getHome)()}/.local/share`,"pnpm/pnpm"),n?.join((0,h.getHome)(),".pnpm/pnpm")].filter(Boolean);return _("pnpm",e)??""}function T(){const n=y(),e=["/usr/local/bin/yarn","/usr/bin/yarn",n?.join((0,h.getHome)(),".yarn/bin/yarn"),n?.join((0,h.getHome)(),".config/yarn/global/node_modules/.bin/yarn")].filter(Boolean);return _("yarn",e)??""}function g(n){const e=P(),i=y();if(!i?.isAbsolute(n))try{const a=A(n);a&&(n=a)}catch{}if(n=(0,l.normalizePath)(n),n===".")return n;const c=i?.extname(n),s=c.toLowerCase(),r=i?.basename(n,c),p=r==="node"?-1:/(?<=\/)\.volta\//i.exec(n)?.index??-1;if(p!==-1){const a=n.slice(0,p),d=i?.join(a,"tools"),m=i?.join(d,"image"),o=i?.join(d,"user"),t=(0,B.readJsonSync)(i?.join(o,"platform.json"),{throws:!1}),u=t?.node?.runtime,L=t?.node?.npm;let f="";if(r==="npm"||r==="npx"){if(L){const S=`bin/${r}-cli.js`;f=i?.join(m,`npm/${L}/${S}`),u&&!e?.existsSync(f)&&(f=i?.join(m,`node/${u}/lib/node_modules/npm/${S}`),e?.existsSync(f)||(f=""))}}else{const S=i?.join(o,"bin"),b=(0,B.readJsonSync)(i?.join(S,`${r}.json`),{throws:!1})?.package;b&&(f=i?.join(m,`packages/${b}/bin/${r}`),e?.existsSync(f)||(f=`${f}.cmd`,e?.existsSync(f)||(f="")))}if(f){try{return(0,l.normalizePath)(e?.realpathSync.native(f))}catch{}return f}}if($.WIN32){const a=s===""||s===".cmd"||s===".exe"||s===".ps1",d=r==="npm"||r==="npx",m=r==="pnpm"||r==="yarn";if(a&&d){const t=i?.join(i?.dirname(n),`node_modules/npm/bin/${r}-cli.js`);if(e?.existsSync(t)){try{return e?.realpathSync.native(t)}catch{}return t}}let o="";if(a&&s!==".exe"&&e?.existsSync(n)){const t=e?.readFileSync(n,"utf8");d?s===".cmd"?o=r==="npm"?/(?<="NPM_CLI_JS=%~dp0\\).*(?=")/.exec(t)?.[0]||"":/(?<="NPX_CLI_JS=%~dp0\\).*(?=")/.exec(t)?.[0]||"":s===""?o=r==="npm"?/(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(t)?.[0]||"":/(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(t)?.[0]||"":s===".ps1"&&(o=r==="npm"?/(?<=\$NPM_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(t)?.[0]||"":/(?<=\$NPX_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(t)?.[0]||""):m?s===".cmd"?(o=/(?<=node\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(t)?.[1]||"",o||(o=/(?<="%~dp0\\[^"]*node[^"]*"\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(t)?.[1]||""),o||(o=/(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(t)?.[0]||"")):s===""?(o=/(?<="\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(t)?.[0]||"",o||(o=/(?<=exec\s+node\s+"\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(t)?.[0]||""),o||(o=/(?<="\$basedir\/).*(?=" "\$@"\n)/.exec(t)?.[0]||"")):s===".ps1"&&(o=/(?<="\$basedir\/).*(?=" $args\n)/.exec(t)?.[0]||""):s===".cmd"?o=/(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(t)?.[0]||"":s===""?o=/(?<="$basedir\/).*(?=" "\$@"\n)/.exec(t)?.[0]||"":s===".ps1"&&(o=/(?<="\$basedir\/).*(?=" $args\n)/.exec(t)?.[0]||""),o&&(n=(0,l.normalizePath)(i?.resolve(i?.dirname(n),o)))}}else{let a=s==="";const d=r==="pnpm"||r==="yarn",m=r==="npm"||r==="npx";if(d&&n.includes("/.bin/pnpm/bin/")){const o=n.indexOf("/.bin/pnpm");if(o!==-1){const t=n.slice(0,o+10);try{(e?.statSync(t)).isFile()&&(n=(0,l.normalizePath)(t),a=!i?.extname(n))}catch{}}}if(a&&(d||m)&&e?.existsSync(n)){const o=e?.readFileSync(n,"utf8");let t="";if(d){if(t=/(?<="\$basedir\/)\.tools\/[^"]+(?="\s+"\$@")/.exec(o)?.[0]||"",t||(t=/(?<="\$basedir\/)[^"]+(?="\s+"\$@")/.exec(o)?.[0]||""),!t){const u=/exec\s+node\s+"?\$basedir\/([^"]+)"?\s+"\$@"/.exec(o);u&&(t=u[1]||"")}t&&r==="pnpm"&&t.startsWith("pnpm/")&&(t=`../${t}`)}else m&&(t=r==="npm"?/(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(o)?.[0]||"":/(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(o)?.[0]||"");t&&(n=(0,l.normalizePath)(i?.resolve(i?.dirname(n),t)))}}try{const a=e?.realpathSync.native(n);return(0,l.normalizePath)(a)}catch{}return(0,l.normalizePath)(n)}0&&(module.exports={execBin,findRealBin,findRealNpm,findRealPnpm,findRealYarn,isShadowBinPath,resolveBinPathSync,which,whichBin,whichBinSync,whichSync});
2
+ var j=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var T=(n,e)=>{for(var r in e)j(n,r,{get:e[r],enumerable:!0})},k=(n,e,r,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of W(e))!F.call(n,s)&&s!==r&&j(n,s,{get:()=>e[s],enumerable:!(c=J(e,s))||c.enumerable});return n};var H=n=>k(j({},"__esModule",{value:!0}),n);var V={};T(V,{execBin:()=>X,findRealBin:()=>_,findRealNpm:()=>M,findRealPnpm:()=>z,findRealYarn:()=>U,isShadowBinPath:()=>A,resolveBinPathSync:()=>g,which:()=>q,whichBin:()=>D,whichBinSync:()=>P,whichSync:()=>R});module.exports=H(V);var y=require("#env/home"),x=require("#env/windows"),O=require("#env/xdg"),S=require("#constants/platform"),N=require("./fs"),m=require("./path"),E=require("./spawn");let I;function C(){return I===void 0&&(I=require("node:fs")),I}let v;function h(){return v===void 0&&(v=require("node:path")),v}let B;function w(){return B===void 0&&(B=require("./external/which")),B}async function X(n,e,r){const c=(0,m.isPath)(n)?g(n):await D(n);if(!c){const i=new Error(`Binary not found: ${n}
3
+ Possible causes:
4
+ - Binary "${n}" is not installed or not in PATH
5
+ - Binary name is incorrect or misspelled
6
+ - Installation directory is not in system PATH
7
+ To resolve:
8
+ 1. Verify "${n}" is installed: which ${n} (Unix) or where ${n} (Windows)
9
+ 2. Install the binary if missing, ex: npm install -g ${n}
10
+ 3. Check PATH environment variable includes the binary location`);throw i.code="ENOENT",i}const s=Array.isArray(c)?c[0]:c;return await(0,E.spawn)(s,e??[],{shell:S.WIN32,...r})}async function q(n,e){return await w()(n,e)}function R(n,e){return w().sync(n,e)}async function D(n,e){const r=w(),c={nothrow:!0,...e},s=await r(n,c);if(c?.all){const i=Array.isArray(s)?s:typeof s=="string"?[s]:void 0;return i?.length?i.map(p=>g(p)):i}if(s)return g(s)}function P(n,e){const r={nothrow:!0,...e},c=R(n,r);if(r.all){const s=Array.isArray(c)?c:typeof c=="string"?[c]:void 0;return s?.length?s.map(i=>g(i)):s}if(c)return g(c)}function A(n){return n?n.replace(/\\/g,"/").includes("node_modules/.bin"):!1}function _(n,e=[]){const r=C(),c=h(),s=w();for(const p of e)if(r?.existsSync(p))return p;const i=s?.sync(n,{nothrow:!0});if(i){const p=c?.dirname(i);if(A(p)){const a=s?.sync(n,{all:!0,nothrow:!0})||[],l=Array.isArray(a)?a:typeof a=="string"?[a]:[];for(const d of l){const o=c?.dirname(d);if(!A(o))return d}}return i}}function M(){const n=C(),e=h(),r=e?.dirname(process.execPath),c=e?.join(r,"npm");if(n?.existsSync(c))return c;const i=_("npm",["/usr/local/bin/npm","/usr/bin/npm"]);if(i&&n?.existsSync(i))return i;const p=P("npm",{nothrow:!0});return p&&typeof p=="string"&&n?.existsSync(p)?p:"npm"}function z(){const n=h(),e=S.WIN32?[n?.join((0,x.getAppdata)(),"npm","pnpm.cmd"),n?.join((0,x.getAppdata)(),"npm","pnpm"),n?.join((0,x.getLocalappdata)(),"pnpm","pnpm.cmd"),n?.join((0,x.getLocalappdata)(),"pnpm","pnpm"),"C:\\Program Files\\nodejs\\pnpm.cmd","C:\\Program Files\\nodejs\\pnpm"].filter(Boolean):["/usr/local/bin/pnpm","/usr/bin/pnpm",n?.join((0,O.getXdgDataHome)()||`${(0,y.getHome)()}/.local/share`,"pnpm/pnpm"),n?.join((0,y.getHome)(),".pnpm/pnpm")].filter(Boolean);return _("pnpm",e)??""}function U(){const n=h(),e=["/usr/local/bin/yarn","/usr/bin/yarn",n?.join((0,y.getHome)(),".yarn/bin/yarn"),n?.join((0,y.getHome)(),".config/yarn/global/node_modules/.bin/yarn")].filter(Boolean);return _("yarn",e)??""}function g(n){const e=C(),r=h();if(!r?.isAbsolute(n))try{const a=P(n);a&&(n=a)}catch{}if(n=(0,m.normalizePath)(n),n===".")return n;const c=r?.extname(n),s=c.toLowerCase(),i=r?.basename(n,c),p=i==="node"?-1:/(?<=\/)\.volta\//i.exec(n)?.index??-1;if(p!==-1){const a=n.slice(0,p),l=r?.join(a,"tools"),d=r?.join(l,"image"),o=r?.join(l,"user"),t=(0,N.readJsonSync)(r?.join(o,"platform.json"),{throws:!1}),u=t?.node?.runtime,L=t?.node?.npm;let f="";if(i==="npm"||i==="npx"){if(L){const $=`bin/${i}-cli.js`;f=r?.join(d,`npm/${L}/${$}`),u&&!e?.existsSync(f)&&(f=r?.join(d,`node/${u}/lib/node_modules/npm/${$}`),e?.existsSync(f)||(f=""))}}else{const $=r?.join(o,"bin"),b=(0,N.readJsonSync)(r?.join($,`${i}.json`),{throws:!1})?.package;b&&(f=r?.join(d,`packages/${b}/bin/${i}`),e?.existsSync(f)||(f=`${f}.cmd`,e?.existsSync(f)||(f="")))}if(f){try{return(0,m.normalizePath)(e?.realpathSync.native(f))}catch{}return f}}if(S.WIN32){const a=s===""||s===".cmd"||s===".exe"||s===".ps1",l=i==="npm"||i==="npx",d=i==="pnpm"||i==="yarn";if(a&&l){const t=r?.join(r?.dirname(n),`node_modules/npm/bin/${i}-cli.js`);if(e?.existsSync(t)){try{return e?.realpathSync.native(t)}catch{}return t}}let o="";if(a&&s!==".exe"&&e?.existsSync(n)){const t=e?.readFileSync(n,"utf8");l?s===".cmd"?o=i==="npm"?/(?<="NPM_CLI_JS=%~dp0\\).*(?=")/.exec(t)?.[0]||"":/(?<="NPX_CLI_JS=%~dp0\\).*(?=")/.exec(t)?.[0]||"":s===""?o=i==="npm"?/(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(t)?.[0]||"":/(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(t)?.[0]||"":s===".ps1"&&(o=i==="npm"?/(?<=\$NPM_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(t)?.[0]||"":/(?<=\$NPX_CLI_JS="\$PSScriptRoot\/).*(?=")/.exec(t)?.[0]||""):d?s===".cmd"?(o=/(?<=node\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(t)?.[1]||"",o||(o=/(?<="%~dp0\\[^"]*node[^"]*"\s+")%~dp0\\([^"]+)(?="\s+%\*)/.exec(t)?.[1]||""),o||(o=/(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(t)?.[0]||"")):s===""?(o=/(?<="\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(t)?.[0]||"",o||(o=/(?<=exec\s+node\s+"\$basedir\/)\.tools\/pnpm\/[^"]+(?="\s+"\$@")/.exec(t)?.[0]||""),o||(o=/(?<="\$basedir\/).*(?=" "\$@"\n)/.exec(t)?.[0]||"")):s===".ps1"&&(o=/(?<="\$basedir\/).*(?=" $args\n)/.exec(t)?.[0]||""):s===".cmd"?o=/(?<="%dp0%\\).*(?=" %\*\r\n)/.exec(t)?.[0]||"":s===""?o=/(?<="$basedir\/).*(?=" "\$@"\n)/.exec(t)?.[0]||"":s===".ps1"&&(o=/(?<="\$basedir\/).*(?=" $args\n)/.exec(t)?.[0]||""),o&&(n=(0,m.normalizePath)(r?.resolve(r?.dirname(n),o)))}}else{let a=s==="";const l=i==="pnpm"||i==="yarn",d=i==="npm"||i==="npx";if(l&&n.includes("/.bin/pnpm/bin/")){const o=n.indexOf("/.bin/pnpm");if(o!==-1){const t=n.slice(0,o+10);try{(e?.statSync(t)).isFile()&&(n=(0,m.normalizePath)(t),a=!r?.extname(n))}catch{}}}if(a&&(l||d)&&e?.existsSync(n)){const o=e?.readFileSync(n,"utf8");let t="";if(l){if(t=/(?<="\$basedir\/)\.tools\/[^"]+(?="\s+"\$@")/.exec(o)?.[0]||"",t||(t=/(?<="\$basedir\/)[^"]+(?="\s+"\$@")/.exec(o)?.[0]||""),!t){const u=/exec\s+node\s+"?\$basedir\/([^"]+)"?\s+"\$@"/.exec(o);u&&(t=u[1]||"")}t&&i==="pnpm"&&t.startsWith("pnpm/")&&(t=`../${t}`)}else d&&(t=i==="npm"?/(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(o)?.[0]||"":/(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(o)?.[0]||"");t&&(n=(0,m.normalizePath)(r?.resolve(r?.dirname(n),t)))}}try{const a=e?.realpathSync.native(n);return(0,m.normalizePath)(a)}catch{}return(0,m.normalizePath)(n)}0&&(module.exports={execBin,findRealBin,findRealNpm,findRealPnpm,findRealYarn,isShadowBinPath,resolveBinPathSync,which,whichBin,whichBinSync,whichSync});
3
11
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/bin.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Binary path resolution and execution utilities for package managers.\n * Provides cross-platform bin path lookup, command execution, and path normalization.\n */\n\nimport { getHome } from '#env/home'\nimport { getAppdata, getLocalappdata } from '#env/windows'\nimport { getXdgDataHome } from '#env/xdg'\n\nimport { WIN32 } from '#constants/platform'\nimport { readJsonSync } from './fs'\nimport { isPath, normalizePath } from './path'\nimport { spawn } from './spawn'\n\nlet _fs: typeof import('node:fs') | undefined\n/**\n * Lazily load the fs module to avoid Webpack errors.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs!\n}\n\nlet _path: typeof import('node:path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path!\n}\n\nlet _which: typeof import('which') | undefined\n/**\n * Lazily load the which module for finding executables.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getWhich() {\n if (_which === undefined) {\n _which = /*@__PURE__*/ require('./external/which')\n }\n return _which!\n}\n\n/**\n * Execute a binary with the given arguments.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function execBin(\n binPath: string,\n args?: string[],\n options?: import('./spawn').SpawnOptions,\n) {\n // Resolve the binary path.\n const resolvedPath = isPath(binPath)\n ? resolveBinPathSync(binPath)\n : await whichBin(binPath)\n\n if (!resolvedPath) {\n const error = new Error(`Binary not found: ${binPath}`) as Error & {\n code: string\n }\n error.code = 'ENOENT'\n throw error\n }\n\n // Execute the binary directly.\n const binCommand = Array.isArray(resolvedPath)\n ? resolvedPath[0]!\n : resolvedPath\n // On Windows, binaries are often .cmd files that require shell to execute.\n return await spawn(binCommand, args ?? [], {\n shell: WIN32,\n ...options,\n })\n}\n\n/**\n * Options for the which function.\n */\nexport interface WhichOptions {\n /** If true, return all matches instead of just the first one. */\n all?: boolean | undefined\n /** If true, return null instead of throwing when no match is found. */\n nothrow?: boolean | undefined\n /** Path to search in. */\n path?: string | undefined\n /** Path separator character. */\n pathExt?: string | undefined\n /** Environment variables to use. */\n env?: Record<string, string | undefined> | undefined\n}\n\n/**\n * Find an executable in the system PATH asynchronously.\n * Wrapper around the which package for lazy loading.\n */\n/* c8 ignore start */\nexport async function which(\n binName: string,\n options?: WhichOptions,\n): Promise<string | string[] | undefined> {\n return await getWhich()(binName, options)\n}\n/* c8 ignore stop */\n\n/**\n * Find an executable in the system PATH synchronously.\n * Wrapper around the which package for lazy loading.\n */\n/* c8 ignore start */\nexport function whichSync(\n binName: string,\n options?: WhichOptions,\n): string | string[] | undefined {\n return getWhich().sync(binName, options)\n}\n/* c8 ignore stop */\n\n/**\n * Find and resolve a binary in the system PATH asynchronously.\n * @throws {Error} If the binary is not found and nothrow is false.\n */\nexport async function whichBin(\n binName: string,\n options?: WhichOptions,\n): Promise<string | string[] | undefined> {\n const which = getWhich()\n // Default to nothrow: true if not specified to return undefined instead of throwing\n const opts = { nothrow: true, ...options }\n // Depending on options `which` may throw if `binName` is not found.\n // With nothrow: true, it returns null when `binName` is not found.\n const result = await which(binName, opts)\n\n // When 'all: true' is specified, ensure we always return an array.\n if (opts?.all) {\n const paths = Array.isArray(result)\n ? result\n : typeof result === 'string'\n ? [result]\n : undefined\n // If all is true and we have paths, resolve each one.\n return paths?.length ? paths.map(p => resolveBinPathSync(p)) : paths\n }\n\n // If result is undefined (binary not found), return undefined\n if (!result) {\n return undefined\n }\n\n return resolveBinPathSync(result)\n}\n\n/**\n * Find and resolve a binary in the system PATH synchronously.\n * @throws {Error} If the binary is not found and nothrow is false.\n */\nexport function whichBinSync(\n binName: string,\n options?: WhichOptions,\n): string | string[] | undefined {\n // Default to nothrow: true if not specified to return undefined instead of throwing\n const opts = { nothrow: true, ...options }\n // Depending on options `which` may throw if `binName` is not found.\n // With nothrow: true, it returns null when `binName` is not found.\n const result = whichSync(binName, opts)\n\n // When 'all: true' is specified, ensure we always return an array.\n if (opts.all) {\n const paths = Array.isArray(result)\n ? result\n : typeof result === 'string'\n ? [result]\n : undefined\n // If all is true and we have paths, resolve each one.\n return paths?.length ? paths.map(p => resolveBinPathSync(p)) : paths\n }\n\n // If result is undefined (binary not found), return undefined\n if (!result) {\n return undefined\n }\n\n return resolveBinPathSync(result as string)\n}\n\n/**\n * Check if a directory path contains any shadow bin patterns.\n */\nexport function isShadowBinPath(dirPath: string | undefined): boolean {\n if (!dirPath) {\n return false\n }\n // Check for node_modules/.bin pattern (Unix and Windows)\n const normalized = dirPath.replace(/\\\\/g, '/')\n return normalized.includes('node_modules/.bin')\n}\n\n/**\n * Find the real executable for a binary, bypassing shadow bins.\n */\nexport function findRealBin(\n binName: string,\n commonPaths: string[] = [],\n): string | undefined {\n const fs = getFs()\n const path = getPath()\n const which = getWhich()\n\n // Try common locations first.\n for (const binPath of commonPaths) {\n if (fs?.existsSync(binPath)) {\n return binPath\n }\n }\n\n // Fall back to which.sync if no direct path found.\n const binPath = which?.sync(binName, { nothrow: true })\n if (binPath) {\n const binDir = path?.dirname(binPath)\n\n if (isShadowBinPath(binDir)) {\n // This is likely a shadowed binary, try to find the real one.\n const allPaths = which?.sync(binName, { all: true, nothrow: true }) || []\n // Ensure allPaths is an array.\n const pathsArray = Array.isArray(allPaths)\n ? allPaths\n : typeof allPaths === 'string'\n ? [allPaths]\n : []\n\n for (const altPath of pathsArray) {\n const altDir = path?.dirname(altPath)\n if (!isShadowBinPath(altDir)) {\n return altPath\n }\n }\n }\n return binPath\n }\n // If all else fails, return undefined to indicate binary not found.\n return undefined\n}\n\n/**\n * Find the real npm executable, bypassing any aliases and shadow bins.\n */\nexport function findRealNpm(): string {\n const fs = getFs()\n const path = getPath()\n\n // Try to find npm in the same directory as the node executable.\n const nodeDir = path?.dirname(process.execPath)\n const npmInNodeDir = path?.join(nodeDir, 'npm')\n\n if (fs?.existsSync(npmInNodeDir)) {\n return npmInNodeDir\n }\n\n // Try common npm locations.\n const commonPaths = ['/usr/local/bin/npm', '/usr/bin/npm']\n const result = findRealBin('npm', commonPaths)\n\n // If we found a valid path, return it.\n if (result && fs?.existsSync(result)) {\n return result\n }\n\n // As a last resort, try to use whichBinSync to find npm.\n // This handles cases where npm is installed in non-standard locations.\n const npmPath = whichBinSync('npm', { nothrow: true })\n if (npmPath && typeof npmPath === 'string' && fs?.existsSync(npmPath)) {\n return npmPath\n }\n\n // Return the basic 'npm' and let the system resolve it.\n return 'npm'\n}\n\n/**\n * Find the real pnpm executable, bypassing any aliases and shadow bins.\n */\nexport function findRealPnpm(): string {\n const path = getPath()\n\n // Try common pnpm locations.\n const commonPaths = WIN32\n ? [\n // Windows common paths.\n path?.join(getAppdata() as string, 'npm', 'pnpm.cmd'),\n path?.join(getAppdata() as string, 'npm', 'pnpm'),\n path?.join(getLocalappdata() as string, 'pnpm', 'pnpm.cmd'),\n path?.join(getLocalappdata() as string, 'pnpm', 'pnpm'),\n 'C:\\\\Program Files\\\\nodejs\\\\pnpm.cmd',\n 'C:\\\\Program Files\\\\nodejs\\\\pnpm',\n ].filter(Boolean)\n : [\n // Unix common paths.\n '/usr/local/bin/pnpm',\n '/usr/bin/pnpm',\n path?.join(\n (getXdgDataHome() as string) || `${getHome() as string}/.local/share`,\n 'pnpm/pnpm',\n ),\n path?.join(getHome() as string, '.pnpm/pnpm'),\n ].filter(Boolean)\n\n return findRealBin('pnpm', commonPaths) ?? ''\n}\n\n/**\n * Find the real yarn executable, bypassing any aliases and shadow bins.\n */\nexport function findRealYarn(): string {\n const path = getPath()\n\n // Try common yarn locations.\n const commonPaths = [\n '/usr/local/bin/yarn',\n '/usr/bin/yarn',\n path?.join(getHome() as string, '.yarn/bin/yarn'),\n path?.join(\n getHome() as string,\n '.config/yarn/global/node_modules/.bin/yarn',\n ),\n ].filter(Boolean)\n\n return findRealBin('yarn', commonPaths) ?? ''\n}\n\n/*@__NO_SIDE_EFFECTS__*/\n/**\n * Resolve a binary path to its actual executable file.\n * Handles Windows .cmd wrappers and Unix shell scripts.\n */\nexport function resolveBinPathSync(binPath: string): string {\n const fs = getFs()\n const path = getPath()\n\n // If it's not an absolute path, try to find it in PATH first\n if (!path?.isAbsolute(binPath)) {\n try {\n const resolved = whichBinSync(binPath)\n if (resolved) {\n binPath = resolved as string\n }\n } catch {}\n }\n\n // Normalize the path once for consistent pattern matching.\n binPath = normalizePath(binPath)\n\n // Handle empty string that normalized to '.' (current directory)\n if (binPath === '.') {\n return binPath\n }\n\n const ext = path?.extname(binPath)\n const extLowered = ext.toLowerCase()\n const basename = path?.basename(binPath, ext)\n const voltaIndex =\n basename === 'node' ? -1 : (/(?<=\\/)\\.volta\\//i.exec(binPath)?.index ?? -1)\n if (voltaIndex !== -1) {\n const voltaPath = binPath.slice(0, voltaIndex)\n const voltaToolsPath = path?.join(voltaPath, 'tools')\n const voltaImagePath = path?.join(voltaToolsPath, 'image')\n const voltaUserPath = path?.join(voltaToolsPath, 'user')\n const voltaPlatform = readJsonSync(\n path?.join(voltaUserPath, 'platform.json'),\n { throws: false },\n ) as any\n const voltaNodeVersion = voltaPlatform?.node?.runtime\n const voltaNpmVersion = voltaPlatform?.node?.npm\n let voltaBinPath = ''\n if (basename === 'npm' || basename === 'npx') {\n if (voltaNpmVersion) {\n const relCliPath = `bin/${basename}-cli.js`\n voltaBinPath = path?.join(\n voltaImagePath,\n `npm/${voltaNpmVersion}/${relCliPath}`,\n )\n if (voltaNodeVersion && !fs?.existsSync(voltaBinPath)) {\n voltaBinPath = path?.join(\n voltaImagePath,\n `node/${voltaNodeVersion}/lib/node_modules/npm/${relCliPath}`,\n )\n if (!fs?.existsSync(voltaBinPath)) {\n voltaBinPath = ''\n }\n }\n }\n } else {\n const voltaUserBinPath = path?.join(voltaUserPath, 'bin')\n const binInfo = readJsonSync(\n path?.join(voltaUserBinPath, `${basename}.json`),\n { throws: false },\n ) as any\n const binPackage = binInfo?.package\n if (binPackage) {\n voltaBinPath = path?.join(\n voltaImagePath,\n `packages/${binPackage}/bin/${basename}`,\n )\n if (!fs?.existsSync(voltaBinPath)) {\n voltaBinPath = `${voltaBinPath}.cmd`\n if (!fs?.existsSync(voltaBinPath)) {\n voltaBinPath = ''\n }\n }\n }\n }\n if (voltaBinPath) {\n try {\n return normalizePath(fs?.realpathSync.native(voltaBinPath))\n } catch {}\n return voltaBinPath\n }\n }\n if (WIN32) {\n const hasKnownExt =\n extLowered === '' ||\n extLowered === '.cmd' ||\n extLowered === '.exe' ||\n extLowered === '.ps1'\n const isNpmOrNpx = basename === 'npm' || basename === 'npx'\n const isPnpmOrYarn = basename === 'pnpm' || basename === 'yarn'\n if (hasKnownExt && isNpmOrNpx) {\n // The quick route assumes a bin path like: C:\\Program Files\\nodejs\\npm.cmd\n const quickPath = path?.join(\n path?.dirname(binPath),\n `node_modules/npm/bin/${basename}-cli.js`,\n )\n if (fs?.existsSync(quickPath)) {\n try {\n return fs?.realpathSync.native(quickPath)\n } catch {}\n return quickPath\n }\n }\n let relPath = ''\n if (\n hasKnownExt &&\n // Only parse shell scripts and batch files, not actual executables.\n // .exe files are already executables and don't need path resolution from wrapper scripts.\n extLowered !== '.exe' &&\n // Check if file exists before attempting to read it to avoid ENOENT errors.\n fs?.existsSync(binPath)\n ) {\n const source = fs?.readFileSync(binPath, 'utf8')\n if (isNpmOrNpx) {\n if (extLowered === '.cmd') {\n // \"npm.cmd\" and \"npx.cmd\" defined by\n // https://github.com/npm/cli/blob/v11.4.2/bin/npm.cmd\n // https://github.com/npm/cli/blob/v11.4.2/bin/npx.cmd\n relPath =\n basename === 'npm'\n ? /(?<=\"NPM_CLI_JS=%~dp0\\\\).*(?=\")/.exec(source)?.[0] || ''\n : /(?<=\"NPX_CLI_JS=%~dp0\\\\).*(?=\")/.exec(source)?.[0] || ''\n } else if (extLowered === '') {\n // Extensionless \"npm\" and \"npx\" defined by\n // https://github.com/npm/cli/blob/v11.4.2/bin/npm\n // https://github.com/npm/cli/blob/v11.4.2/bin/npx\n relPath =\n basename === 'npm'\n ? /(?<=NPM_CLI_JS=\"\\$CLI_BASEDIR\\/).*(?=\")/.exec(source)?.[0] ||\n ''\n : /(?<=NPX_CLI_JS=\"\\$CLI_BASEDIR\\/).*(?=\")/.exec(source)?.[0] ||\n ''\n } else if (extLowered === '.ps1') {\n // \"npm.ps1\" and \"npx.ps1\" defined by\n // https://github.com/npm/cli/blob/v11.4.2/bin/npm.ps1\n // https://github.com/npm/cli/blob/v11.4.2/bin/npx.ps1\n relPath =\n basename === 'npm'\n ? /(?<=\\$NPM_CLI_JS=\"\\$PSScriptRoot\\/).*(?=\")/.exec(\n source,\n )?.[0] || ''\n : /(?<=\\$NPX_CLI_JS=\"\\$PSScriptRoot\\/).*(?=\")/.exec(\n source,\n )?.[0] || ''\n }\n } else if (isPnpmOrYarn) {\n if (extLowered === '.cmd') {\n // pnpm.cmd and yarn.cmd can have different formats depending on installation method\n // Common formats include:\n // 1. Setup-pnpm action format: node \"%~dp0\\..\\pnpm\\bin\\pnpm.cjs\" %*\n // 2. npm install -g pnpm format: similar to cmd-shim\n // 3. Standalone installer format: various patterns\n\n // Try setup-pnpm/setup-yarn action format first\n relPath =\n /(?<=node\\s+\")%~dp0\\\\([^\"]+)(?=\"\\s+%\\*)/.exec(source)?.[1] || ''\n\n // Try alternative format: \"%~dp0\\node.exe\" \"%~dp0\\..\\package\\bin\\binary.js\" %*\n if (!relPath) {\n relPath =\n /(?<=\"%~dp0\\\\[^\"]*node[^\"]*\"\\s+\")%~dp0\\\\([^\"]+)(?=\"\\s+%\\*)/.exec(\n source,\n )?.[1] || ''\n }\n\n // Try cmd-shim format as fallback\n if (!relPath) {\n relPath = /(?<=\"%dp0%\\\\).*(?=\" %\\*\\r\\n)/.exec(source)?.[0] || ''\n }\n } else if (extLowered === '') {\n // Extensionless pnpm/yarn - try common shebang formats\n // Handle pnpm installed via standalone installer or global install\n // Format: exec \"$basedir/node\" \"$basedir/.tools/pnpm/VERSION/...\" \"$@\"\n // Note: may have multiple spaces between arguments\n relPath =\n /(?<=\"\\$basedir\\/)\\.tools\\/pnpm\\/[^\"]+(?=\"\\s+\"\\$@\")/.exec(\n source,\n )?.[0] || ''\n if (!relPath) {\n // Also try: exec node \"$basedir/.tools/pnpm/VERSION/...\" \"$@\"\n relPath =\n /(?<=exec\\s+node\\s+\"\\$basedir\\/)\\.tools\\/pnpm\\/[^\"]+(?=\"\\s+\"\\$@\")/.exec(\n source,\n )?.[0] || ''\n }\n if (!relPath) {\n // Try standard cmd-shim format: exec node \"$basedir/../package/bin/binary.js\" \"$@\"\n relPath = /(?<=\"\\$basedir\\/).*(?=\" \"\\$@\"\\n)/.exec(source)?.[0] || ''\n }\n } else if (extLowered === '.ps1') {\n // PowerShell format\n relPath = /(?<=\"\\$basedir\\/).*(?=\" $args\\n)/.exec(source)?.[0] || ''\n }\n } else if (extLowered === '.cmd') {\n // \"bin.CMD\" generated by\n // https://github.com/npm/cmd-shim/blob/v7.0.0/lib/index.js#L98:\n //\n // @ECHO off\n // GOTO start\n // :find_dp0\n // SET dp0=%~dp0\n // EXIT /b\n // :start\n // SETLOCAL\n // CALL :find_dp0\n //\n // IF EXIST \"%dp0%\\node.exe\" (\n // SET \"_prog=%dp0%\\node.exe\"\n // ) ELSE (\n // SET \"_prog=node\"\n // SET PATHEXT=%PATHEXT:;.JS;=;%\n // )\n //\n // endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & \"%_prog%\" \"%dp0%\\..\\<PACKAGE_NAME>\\path\\to\\bin.js\" %*\n relPath = /(?<=\"%dp0%\\\\).*(?=\" %\\*\\r\\n)/.exec(source)?.[0] || ''\n } else if (extLowered === '') {\n // Extensionless \"bin\" generated by\n // https://github.com/npm/cmd-shim/blob/v7.0.0/lib/index.js#L138:\n //\n // #!/bin/sh\n // basedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")\n //\n // case `uname` in\n // *CYGWIN*|*MINGW*|*MSYS*)\n // if command -v cygpath > /dev/null 2>&1; then\n // basedir=`cygpath -w \"$basedir\"`\n // fi\n // ;;\n // esac\n //\n // if [ -x \"$basedir/node\" ]; then\n // exec \"$basedir/node\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" \"$@\"\n // else\n // exec node \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" \"$@\"\n // fi\n relPath = /(?<=\"$basedir\\/).*(?=\" \"\\$@\"\\n)/.exec(source)?.[0] || ''\n } else if (extLowered === '.ps1') {\n // \"bin.PS1\" generated by\n // https://github.com/npm/cmd-shim/blob/v7.0.0/lib/index.js#L192:\n //\n // #!/usr/bin/env pwsh\n // $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent\n //\n // $exe=\"\"\n // if ($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 // $ret=0\n // if (Test-Path \"$basedir/node$exe\") {\n // # Support pipeline input\n // if ($MyInvocation.ExpectingInput) {\n // $input | & \"$basedir/node$exe\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" $args\n // } else {\n // & \"$basedir/node$exe\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" $args\n // }\n // $ret=$LASTEXITCODE\n // } else {\n // # Support pipeline input\n // if ($MyInvocation.ExpectingInput) {\n // $input | & \"node$exe\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" $args\n // } else {\n // & \"node$exe\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" $args\n // }\n // $ret=$LASTEXITCODE\n // }\n // exit $ret\n relPath = /(?<=\"\\$basedir\\/).*(?=\" $args\\n)/.exec(source)?.[0] || ''\n }\n if (relPath) {\n binPath = normalizePath(path?.resolve(path?.dirname(binPath), relPath))\n }\n }\n } else {\n // Handle Unix shell scripts (non-Windows platforms)\n let hasNoExt = extLowered === ''\n const isPnpmOrYarn = basename === 'pnpm' || basename === 'yarn'\n const isNpmOrNpx = basename === 'npm' || basename === 'npx'\n\n // Handle special case where pnpm path in CI has extra segments.\n // In setup-pnpm GitHub Action, the path might be malformed like:\n // /home/user/setup-pnpm/node_modules/.bin/pnpm/bin/pnpm.cjs\n // This happens when the shell script contains a relative path that\n // when resolved, creates an invalid nested structure.\n if (isPnpmOrYarn && binPath.includes('/.bin/pnpm/bin/')) {\n // Extract the correct pnpm bin path.\n const binIndex = binPath.indexOf('/.bin/pnpm')\n if (binIndex !== -1) {\n // Get the base path up to /.bin/pnpm.\n const baseBinPath = binPath.slice(0, binIndex + '/.bin/pnpm'.length)\n // Check if the original shell script exists.\n try {\n const stats = fs?.statSync(baseBinPath)\n // Only use this path if it's a file (the shell script).\n if (stats.isFile()) {\n binPath = normalizePath(baseBinPath)\n // Recompute hasNoExt since we changed the path.\n hasNoExt = !path?.extname(binPath)\n }\n } catch {\n // If stat fails, continue with the original path.\n }\n }\n }\n\n if (\n hasNoExt &&\n (isPnpmOrYarn || isNpmOrNpx) &&\n // For extensionless files (Unix shell scripts), verify existence before reading.\n // This prevents ENOENT errors when the bin path doesn't exist.\n fs?.existsSync(binPath)\n ) {\n const source = fs?.readFileSync(binPath, 'utf8')\n let relPath = ''\n\n if (isPnpmOrYarn) {\n // Handle pnpm/yarn Unix shell scripts.\n // Format: exec \"$basedir/node\" \"$basedir/.tools/pnpm/VERSION/...\" \"$@\"\n // or: exec node \"$basedir/.tools/pnpm/VERSION/...\" \"$@\"\n relPath =\n /(?<=\"\\$basedir\\/)\\.tools\\/[^\"]+(?=\"\\s+\"\\$@\")/.exec(source)?.[0] || ''\n if (!relPath) {\n // Try standard cmd-shim format: exec node \"$basedir/../package/bin/binary.js\" \"$@\"\n // Example: exec node \"$basedir/../pnpm/bin/pnpm.cjs\" \"$@\"\n // ^^^^^^^^^^^^^^^^^^^^^ captures this part\n // This regex needs to be more careful to not match \"$@\" at the end.\n relPath =\n /(?<=\"\\$basedir\\/)[^\"]+(?=\"\\s+\"\\$@\")/.exec(source)?.[0] || ''\n }\n // Special case for setup-pnpm GitHub Action which may use a different format.\n // The setup-pnpm action creates a shell script that references ../pnpm/bin/pnpm.cjs\n if (!relPath) {\n // Try to match: exec node \"$basedir/../pnpm/bin/pnpm.cjs\" \"$@\"\n const match = /exec\\s+node\\s+\"?\\$basedir\\/([^\"]+)\"?\\s+\"\\$@\"/.exec(\n source,\n )\n if (match) {\n relPath = match[1] || ''\n }\n }\n // Check if the extracted path looks wrong (e.g., pnpm/bin/pnpm.cjs without ../).\n // This happens with setup-pnpm action when it creates a malformed shell script.\n if (relPath && basename === 'pnpm' && relPath.startsWith('pnpm/')) {\n // The path should be ../pnpm/... not pnpm/...\n // Prepend ../ to fix the relative path.\n relPath = `../${relPath}`\n }\n } else if (isNpmOrNpx) {\n // Handle npm/npx Unix shell scripts\n relPath =\n basename === 'npm'\n ? /(?<=NPM_CLI_JS=\"\\$CLI_BASEDIR\\/).*(?=\")/.exec(source)?.[0] || ''\n : /(?<=NPX_CLI_JS=\"\\$CLI_BASEDIR\\/).*(?=\")/.exec(source)?.[0] || ''\n }\n\n if (relPath) {\n // Resolve the relative path to handle .. segments properly.\n binPath = normalizePath(path?.resolve(path?.dirname(binPath), relPath))\n }\n }\n }\n try {\n const realPath = fs?.realpathSync.native(binPath)\n return normalizePath(realPath)\n } catch {}\n // Return normalized path even if realpath fails.\n return normalizePath(binPath)\n}\n"],
5
- "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,gBAAAC,EAAA,gBAAAC,EAAA,iBAAAC,EAAA,iBAAAC,EAAA,oBAAAC,EAAA,uBAAAC,EAAA,UAAAC,EAAA,aAAAC,EAAA,iBAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAb,GAKA,IAAAc,EAAwB,qBACxBC,EAA4C,wBAC5CC,EAA+B,oBAE/BC,EAAsB,+BACtBC,EAA6B,gBAC7BC,EAAsC,kBACtCC,EAAsB,mBAEtB,IAAIC,EAKJ,SAASC,GAAQ,CACf,OAAID,IAAQ,SAGVA,EAAoB,QAAQ,SAAS,GAEhCA,CACT,CAEA,IAAIE,EAKJ,SAASC,GAAU,CACjB,OAAID,IAAU,SAGZA,EAAsB,QAAQ,WAAW,GAEpCA,CACT,CAEA,IAAIE,EAKJ,SAASC,GAAW,CAClB,OAAID,IAAW,SACbA,EAAuB,QAAQ,kBAAkB,GAE5CA,CACT,CAMA,eAAsBvB,EACpByB,EACAC,EACAC,EACA,CAEA,MAAMC,KAAe,UAAOH,CAAO,EAC/BnB,EAAmBmB,CAAO,EAC1B,MAAMjB,EAASiB,CAAO,EAE1B,GAAI,CAACG,EAAc,CACjB,MAAMC,EAAQ,IAAI,MAAM,qBAAqBJ,CAAO,EAAE,EAGtD,MAAAI,EAAM,KAAO,SACPA,CACR,CAGA,MAAMC,EAAa,MAAM,QAAQF,CAAY,EACzCA,EAAa,CAAC,EACdA,EAEJ,OAAO,QAAM,SAAME,EAAYJ,GAAQ,CAAC,EAAG,CACzC,MAAO,QACP,GAAGC,CACL,CAAC,CACH,CAuBA,eAAsBpB,EACpBwB,EACAJ,EACwC,CACxC,OAAO,MAAMH,EAAS,EAAEO,EAASJ,CA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OtD,GAAIe,GAAgBzC,EAAQ,SAAS,iBAAiB,EAAG,CAEvD,MAAM8C,EAAW9C,EAAQ,QAAQ,YAAY,EAC7C,GAAI8C,IAAa,GAAI,CAEnB,MAAMC,EAAc/C,EAAQ,MAAM,EAAG8C,EAAW,EAAmB,EAEnE,GAAI,EACYjC,GAAI,SAASkC,CAAW,GAE5B,OAAO,IACf/C,KAAU,iBAAc+C,CAAW,EAEnCF,EAAW,CAAC/B,GAAM,QAAQd,CAAO,EAErC,MAAQ,CAER,CACF,CACF,CAEA,GACE6C,IACCJ,GAAgBD,IAGjB3B,GAAI,WAAWb,CAAO,EACtB,CACA,MAAM4C,EAAS/B,GAAI,aAAab,EAAS,MAAM,EAC/C,IAAI2C,EAAU,GAEd,GAAIF,EAAc,CAgBhB,GAZAE,EACE,+CAA+C,KAAKC,CAAM,IAAI,CAAC,GAAK,GACjED,IAKHA,EACE,sCAAsC,KAAKC,CAAM,IAAI,CAAC,GAAK,IAI3D,CAACD,EAAS,CAEZ,MAAMK,EAAQ,+CAA+C,KAC3DJ,CACF,EACII,IACFL,EAAUK,EAAM,CAAC,GAAK,GAE1B,CAGIL,GAAWjB,IAAa,QAAUiB,EAAQ,WAAW,OAAO,IAG9DA,EAAU,MAAMA,CAAO,GAE3B,MAAWH,IAETG,EACEjB,IAAa,MACT,0CAA0C,KAAKkB,CAAM,IAAI,CAAC,GAAK,GAC/D,0CAA0C,KAAKA,CAAM,IAAI,CAAC,GAAK,IAGnED,IAEF3C,KAAU,iBAAcc,GAAM,QAAQA,GAAM,QAAQd,CAAO,EAAG2C,CAAO,CAAC,EAE1E,CACF,CACA,GAAI,CACF,MAAMM,EAAWpC,GAAI,aAAa,OAAOb,CAAO,EAChD,SAAO,iBAAciD,CAAQ,CAC/B,MAAQ,CAAC,CAET,SAAO,iBAAcjD,CAAO,CAC9B",
4
+ "sourcesContent": ["/**\n * @fileoverview Binary path resolution and execution utilities for package managers.\n * Provides cross-platform bin path lookup, command execution, and path normalization.\n */\n\nimport { getHome } from '#env/home'\nimport { getAppdata, getLocalappdata } from '#env/windows'\nimport { getXdgDataHome } from '#env/xdg'\n\nimport { WIN32 } from '#constants/platform'\nimport { readJsonSync } from './fs'\nimport { isPath, normalizePath } from './path'\nimport { spawn } from './spawn'\n\nlet _fs: typeof import('node:fs') | undefined\n/**\n * Lazily load the fs module to avoid Webpack errors.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs!\n}\n\nlet _path: typeof import('node:path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path!\n}\n\nlet _which: typeof import('which') | undefined\n/**\n * Lazily load the which module for finding executables.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getWhich() {\n if (_which === undefined) {\n _which = /*@__PURE__*/ require('./external/which')\n }\n return _which!\n}\n\n/**\n * Execute a binary with the given arguments.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport async function execBin(\n binPath: string,\n args?: string[],\n options?: import('./spawn').SpawnOptions,\n) {\n // Resolve the binary path.\n const resolvedPath = isPath(binPath)\n ? resolveBinPathSync(binPath)\n : await whichBin(binPath)\n\n if (!resolvedPath) {\n const error = new Error(\n `Binary not found: ${binPath}\\n` +\n 'Possible causes:\\n' +\n ` - Binary \"${binPath}\" is not installed or not in PATH\\n` +\n ' - Binary name is incorrect or misspelled\\n' +\n ' - Installation directory is not in system PATH\\n' +\n 'To resolve:\\n' +\n ` 1. Verify \"${binPath}\" is installed: which ${binPath} (Unix) or where ${binPath} (Windows)\\n` +\n ` 2. Install the binary if missing, ex: npm install -g ${binPath}\\n` +\n ' 3. Check PATH environment variable includes the binary location',\n ) as Error & {\n code: string\n }\n error.code = 'ENOENT'\n throw error\n }\n\n // Execute the binary directly.\n const binCommand = Array.isArray(resolvedPath)\n ? resolvedPath[0]!\n : resolvedPath\n // On Windows, binaries are often .cmd files that require shell to execute.\n return await spawn(binCommand, args ?? [], {\n shell: WIN32,\n ...options,\n })\n}\n\n/**\n * Options for the which function.\n */\nexport interface WhichOptions {\n /** If true, return all matches instead of just the first one. */\n all?: boolean | undefined\n /** If true, return null instead of throwing when no match is found. */\n nothrow?: boolean | undefined\n /** Path to search in. */\n path?: string | undefined\n /** Path separator character. */\n pathExt?: string | undefined\n /** Environment variables to use. */\n env?: Record<string, string | undefined> | undefined\n}\n\n/**\n * Find an executable in the system PATH asynchronously.\n * Wrapper around the which package for lazy loading.\n */\n/* c8 ignore start */\nexport async function which(\n binName: string,\n options?: WhichOptions,\n): Promise<string | string[] | undefined> {\n return await getWhich()(binName, options)\n}\n/* c8 ignore stop */\n\n/**\n * Find an executable in the system PATH synchronously.\n * Wrapper around the which package for lazy loading.\n */\n/* c8 ignore start */\nexport function whichSync(\n binName: string,\n options?: WhichOptions,\n): string | string[] | undefined {\n return getWhich().sync(binName, options)\n}\n/* c8 ignore stop */\n\n/**\n * Find and resolve a binary in the system PATH asynchronously.\n * @throws {Error} If the binary is not found and nothrow is false.\n */\nexport async function whichBin(\n binName: string,\n options?: WhichOptions,\n): Promise<string | string[] | undefined> {\n const which = getWhich()\n // Default to nothrow: true if not specified to return undefined instead of throwing\n const opts = { nothrow: true, ...options }\n // Depending on options `which` may throw if `binName` is not found.\n // With nothrow: true, it returns null when `binName` is not found.\n const result = await which(binName, opts)\n\n // When 'all: true' is specified, ensure we always return an array.\n if (opts?.all) {\n const paths = Array.isArray(result)\n ? result\n : typeof result === 'string'\n ? [result]\n : undefined\n // If all is true and we have paths, resolve each one.\n return paths?.length ? paths.map(p => resolveBinPathSync(p)) : paths\n }\n\n // If result is undefined (binary not found), return undefined\n if (!result) {\n return undefined\n }\n\n return resolveBinPathSync(result)\n}\n\n/**\n * Find and resolve a binary in the system PATH synchronously.\n * @throws {Error} If the binary is not found and nothrow is false.\n */\nexport function whichBinSync(\n binName: string,\n options?: WhichOptions,\n): string | string[] | undefined {\n // Default to nothrow: true if not specified to return undefined instead of throwing\n const opts = { nothrow: true, ...options }\n // Depending on options `which` may throw if `binName` is not found.\n // With nothrow: true, it returns null when `binName` is not found.\n const result = whichSync(binName, opts)\n\n // When 'all: true' is specified, ensure we always return an array.\n if (opts.all) {\n const paths = Array.isArray(result)\n ? result\n : typeof result === 'string'\n ? [result]\n : undefined\n // If all is true and we have paths, resolve each one.\n return paths?.length ? paths.map(p => resolveBinPathSync(p)) : paths\n }\n\n // If result is undefined (binary not found), return undefined\n if (!result) {\n return undefined\n }\n\n return resolveBinPathSync(result as string)\n}\n\n/**\n * Check if a directory path contains any shadow bin patterns.\n */\nexport function isShadowBinPath(dirPath: string | undefined): boolean {\n if (!dirPath) {\n return false\n }\n // Check for node_modules/.bin pattern (Unix and Windows)\n const normalized = dirPath.replace(/\\\\/g, '/')\n return normalized.includes('node_modules/.bin')\n}\n\n/**\n * Find the real executable for a binary, bypassing shadow bins.\n */\nexport function findRealBin(\n binName: string,\n commonPaths: string[] = [],\n): string | undefined {\n const fs = getFs()\n const path = getPath()\n const which = getWhich()\n\n // Try common locations first.\n for (const binPath of commonPaths) {\n if (fs?.existsSync(binPath)) {\n return binPath\n }\n }\n\n // Fall back to which.sync if no direct path found.\n const binPath = which?.sync(binName, { nothrow: true })\n if (binPath) {\n const binDir = path?.dirname(binPath)\n\n if (isShadowBinPath(binDir)) {\n // This is likely a shadowed binary, try to find the real one.\n const allPaths = which?.sync(binName, { all: true, nothrow: true }) || []\n // Ensure allPaths is an array.\n const pathsArray = Array.isArray(allPaths)\n ? allPaths\n : typeof allPaths === 'string'\n ? [allPaths]\n : []\n\n for (const altPath of pathsArray) {\n const altDir = path?.dirname(altPath)\n if (!isShadowBinPath(altDir)) {\n return altPath\n }\n }\n }\n return binPath\n }\n // If all else fails, return undefined to indicate binary not found.\n return undefined\n}\n\n/**\n * Find the real npm executable, bypassing any aliases and shadow bins.\n */\nexport function findRealNpm(): string {\n const fs = getFs()\n const path = getPath()\n\n // Try to find npm in the same directory as the node executable.\n const nodeDir = path?.dirname(process.execPath)\n const npmInNodeDir = path?.join(nodeDir, 'npm')\n\n if (fs?.existsSync(npmInNodeDir)) {\n return npmInNodeDir\n }\n\n // Try common npm locations.\n const commonPaths = ['/usr/local/bin/npm', '/usr/bin/npm']\n const result = findRealBin('npm', commonPaths)\n\n // If we found a valid path, return it.\n if (result && fs?.existsSync(result)) {\n return result\n }\n\n // As a last resort, try to use whichBinSync to find npm.\n // This handles cases where npm is installed in non-standard locations.\n const npmPath = whichBinSync('npm', { nothrow: true })\n if (npmPath && typeof npmPath === 'string' && fs?.existsSync(npmPath)) {\n return npmPath\n }\n\n // Return the basic 'npm' and let the system resolve it.\n return 'npm'\n}\n\n/**\n * Find the real pnpm executable, bypassing any aliases and shadow bins.\n */\nexport function findRealPnpm(): string {\n const path = getPath()\n\n // Try common pnpm locations.\n const commonPaths = WIN32\n ? [\n // Windows common paths.\n path?.join(getAppdata() as string, 'npm', 'pnpm.cmd'),\n path?.join(getAppdata() as string, 'npm', 'pnpm'),\n path?.join(getLocalappdata() as string, 'pnpm', 'pnpm.cmd'),\n path?.join(getLocalappdata() as string, 'pnpm', 'pnpm'),\n 'C:\\\\Program Files\\\\nodejs\\\\pnpm.cmd',\n 'C:\\\\Program Files\\\\nodejs\\\\pnpm',\n ].filter(Boolean)\n : [\n // Unix common paths.\n '/usr/local/bin/pnpm',\n '/usr/bin/pnpm',\n path?.join(\n (getXdgDataHome() as string) || `${getHome() as string}/.local/share`,\n 'pnpm/pnpm',\n ),\n path?.join(getHome() as string, '.pnpm/pnpm'),\n ].filter(Boolean)\n\n return findRealBin('pnpm', commonPaths) ?? ''\n}\n\n/**\n * Find the real yarn executable, bypassing any aliases and shadow bins.\n */\nexport function findRealYarn(): string {\n const path = getPath()\n\n // Try common yarn locations.\n const commonPaths = [\n '/usr/local/bin/yarn',\n '/usr/bin/yarn',\n path?.join(getHome() as string, '.yarn/bin/yarn'),\n path?.join(\n getHome() as string,\n '.config/yarn/global/node_modules/.bin/yarn',\n ),\n ].filter(Boolean)\n\n return findRealBin('yarn', commonPaths) ?? ''\n}\n\n/*@__NO_SIDE_EFFECTS__*/\n/**\n * Resolve a binary path to its actual executable file.\n * Handles Windows .cmd wrappers and Unix shell scripts.\n */\nexport function resolveBinPathSync(binPath: string): string {\n const fs = getFs()\n const path = getPath()\n\n // If it's not an absolute path, try to find it in PATH first\n if (!path?.isAbsolute(binPath)) {\n try {\n const resolved = whichBinSync(binPath)\n if (resolved) {\n binPath = resolved as string\n }\n } catch {}\n }\n\n // Normalize the path once for consistent pattern matching.\n binPath = normalizePath(binPath)\n\n // Handle empty string that normalized to '.' (current directory)\n if (binPath === '.') {\n return binPath\n }\n\n const ext = path?.extname(binPath)\n const extLowered = ext.toLowerCase()\n const basename = path?.basename(binPath, ext)\n const voltaIndex =\n basename === 'node' ? -1 : (/(?<=\\/)\\.volta\\//i.exec(binPath)?.index ?? -1)\n if (voltaIndex !== -1) {\n const voltaPath = binPath.slice(0, voltaIndex)\n const voltaToolsPath = path?.join(voltaPath, 'tools')\n const voltaImagePath = path?.join(voltaToolsPath, 'image')\n const voltaUserPath = path?.join(voltaToolsPath, 'user')\n const voltaPlatform = readJsonSync(\n path?.join(voltaUserPath, 'platform.json'),\n { throws: false },\n ) as any\n const voltaNodeVersion = voltaPlatform?.node?.runtime\n const voltaNpmVersion = voltaPlatform?.node?.npm\n let voltaBinPath = ''\n if (basename === 'npm' || basename === 'npx') {\n if (voltaNpmVersion) {\n const relCliPath = `bin/${basename}-cli.js`\n voltaBinPath = path?.join(\n voltaImagePath,\n `npm/${voltaNpmVersion}/${relCliPath}`,\n )\n if (voltaNodeVersion && !fs?.existsSync(voltaBinPath)) {\n voltaBinPath = path?.join(\n voltaImagePath,\n `node/${voltaNodeVersion}/lib/node_modules/npm/${relCliPath}`,\n )\n if (!fs?.existsSync(voltaBinPath)) {\n voltaBinPath = ''\n }\n }\n }\n } else {\n const voltaUserBinPath = path?.join(voltaUserPath, 'bin')\n const binInfo = readJsonSync(\n path?.join(voltaUserBinPath, `${basename}.json`),\n { throws: false },\n ) as any\n const binPackage = binInfo?.package\n if (binPackage) {\n voltaBinPath = path?.join(\n voltaImagePath,\n `packages/${binPackage}/bin/${basename}`,\n )\n if (!fs?.existsSync(voltaBinPath)) {\n voltaBinPath = `${voltaBinPath}.cmd`\n if (!fs?.existsSync(voltaBinPath)) {\n voltaBinPath = ''\n }\n }\n }\n }\n if (voltaBinPath) {\n try {\n return normalizePath(fs?.realpathSync.native(voltaBinPath))\n } catch {}\n return voltaBinPath\n }\n }\n if (WIN32) {\n const hasKnownExt =\n extLowered === '' ||\n extLowered === '.cmd' ||\n extLowered === '.exe' ||\n extLowered === '.ps1'\n const isNpmOrNpx = basename === 'npm' || basename === 'npx'\n const isPnpmOrYarn = basename === 'pnpm' || basename === 'yarn'\n if (hasKnownExt && isNpmOrNpx) {\n // The quick route assumes a bin path like: C:\\Program Files\\nodejs\\npm.cmd\n const quickPath = path?.join(\n path?.dirname(binPath),\n `node_modules/npm/bin/${basename}-cli.js`,\n )\n if (fs?.existsSync(quickPath)) {\n try {\n return fs?.realpathSync.native(quickPath)\n } catch {}\n return quickPath\n }\n }\n let relPath = ''\n if (\n hasKnownExt &&\n // Only parse shell scripts and batch files, not actual executables.\n // .exe files are already executables and don't need path resolution from wrapper scripts.\n extLowered !== '.exe' &&\n // Check if file exists before attempting to read it to avoid ENOENT errors.\n fs?.existsSync(binPath)\n ) {\n const source = fs?.readFileSync(binPath, 'utf8')\n if (isNpmOrNpx) {\n if (extLowered === '.cmd') {\n // \"npm.cmd\" and \"npx.cmd\" defined by\n // https://github.com/npm/cli/blob/v11.4.2/bin/npm.cmd\n // https://github.com/npm/cli/blob/v11.4.2/bin/npx.cmd\n relPath =\n basename === 'npm'\n ? /(?<=\"NPM_CLI_JS=%~dp0\\\\).*(?=\")/.exec(source)?.[0] || ''\n : /(?<=\"NPX_CLI_JS=%~dp0\\\\).*(?=\")/.exec(source)?.[0] || ''\n } else if (extLowered === '') {\n // Extensionless \"npm\" and \"npx\" defined by\n // https://github.com/npm/cli/blob/v11.4.2/bin/npm\n // https://github.com/npm/cli/blob/v11.4.2/bin/npx\n relPath =\n basename === 'npm'\n ? /(?<=NPM_CLI_JS=\"\\$CLI_BASEDIR\\/).*(?=\")/.exec(source)?.[0] ||\n ''\n : /(?<=NPX_CLI_JS=\"\\$CLI_BASEDIR\\/).*(?=\")/.exec(source)?.[0] ||\n ''\n } else if (extLowered === '.ps1') {\n // \"npm.ps1\" and \"npx.ps1\" defined by\n // https://github.com/npm/cli/blob/v11.4.2/bin/npm.ps1\n // https://github.com/npm/cli/blob/v11.4.2/bin/npx.ps1\n relPath =\n basename === 'npm'\n ? /(?<=\\$NPM_CLI_JS=\"\\$PSScriptRoot\\/).*(?=\")/.exec(\n source,\n )?.[0] || ''\n : /(?<=\\$NPX_CLI_JS=\"\\$PSScriptRoot\\/).*(?=\")/.exec(\n source,\n )?.[0] || ''\n }\n } else if (isPnpmOrYarn) {\n if (extLowered === '.cmd') {\n // pnpm.cmd and yarn.cmd can have different formats depending on installation method\n // Common formats include:\n // 1. Setup-pnpm action format: node \"%~dp0\\..\\pnpm\\bin\\pnpm.cjs\" %*\n // 2. npm install -g pnpm format: similar to cmd-shim\n // 3. Standalone installer format: various patterns\n\n // Try setup-pnpm/setup-yarn action format first\n relPath =\n /(?<=node\\s+\")%~dp0\\\\([^\"]+)(?=\"\\s+%\\*)/.exec(source)?.[1] || ''\n\n // Try alternative format: \"%~dp0\\node.exe\" \"%~dp0\\..\\package\\bin\\binary.js\" %*\n if (!relPath) {\n relPath =\n /(?<=\"%~dp0\\\\[^\"]*node[^\"]*\"\\s+\")%~dp0\\\\([^\"]+)(?=\"\\s+%\\*)/.exec(\n source,\n )?.[1] || ''\n }\n\n // Try cmd-shim format as fallback\n if (!relPath) {\n relPath = /(?<=\"%dp0%\\\\).*(?=\" %\\*\\r\\n)/.exec(source)?.[0] || ''\n }\n } else if (extLowered === '') {\n // Extensionless pnpm/yarn - try common shebang formats\n // Handle pnpm installed via standalone installer or global install\n // Format: exec \"$basedir/node\" \"$basedir/.tools/pnpm/VERSION/...\" \"$@\"\n // Note: may have multiple spaces between arguments\n relPath =\n /(?<=\"\\$basedir\\/)\\.tools\\/pnpm\\/[^\"]+(?=\"\\s+\"\\$@\")/.exec(\n source,\n )?.[0] || ''\n if (!relPath) {\n // Also try: exec node \"$basedir/.tools/pnpm/VERSION/...\" \"$@\"\n relPath =\n /(?<=exec\\s+node\\s+\"\\$basedir\\/)\\.tools\\/pnpm\\/[^\"]+(?=\"\\s+\"\\$@\")/.exec(\n source,\n )?.[0] || ''\n }\n if (!relPath) {\n // Try standard cmd-shim format: exec node \"$basedir/../package/bin/binary.js\" \"$@\"\n relPath = /(?<=\"\\$basedir\\/).*(?=\" \"\\$@\"\\n)/.exec(source)?.[0] || ''\n }\n } else if (extLowered === '.ps1') {\n // PowerShell format\n relPath = /(?<=\"\\$basedir\\/).*(?=\" $args\\n)/.exec(source)?.[0] || ''\n }\n } else if (extLowered === '.cmd') {\n // \"bin.CMD\" generated by\n // https://github.com/npm/cmd-shim/blob/v7.0.0/lib/index.js#L98:\n //\n // @ECHO off\n // GOTO start\n // :find_dp0\n // SET dp0=%~dp0\n // EXIT /b\n // :start\n // SETLOCAL\n // CALL :find_dp0\n //\n // IF EXIST \"%dp0%\\node.exe\" (\n // SET \"_prog=%dp0%\\node.exe\"\n // ) ELSE (\n // SET \"_prog=node\"\n // SET PATHEXT=%PATHEXT:;.JS;=;%\n // )\n //\n // endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & \"%_prog%\" \"%dp0%\\..\\<PACKAGE_NAME>\\path\\to\\bin.js\" %*\n relPath = /(?<=\"%dp0%\\\\).*(?=\" %\\*\\r\\n)/.exec(source)?.[0] || ''\n } else if (extLowered === '') {\n // Extensionless \"bin\" generated by\n // https://github.com/npm/cmd-shim/blob/v7.0.0/lib/index.js#L138:\n //\n // #!/bin/sh\n // basedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")\n //\n // case `uname` in\n // *CYGWIN*|*MINGW*|*MSYS*)\n // if command -v cygpath > /dev/null 2>&1; then\n // basedir=`cygpath -w \"$basedir\"`\n // fi\n // ;;\n // esac\n //\n // if [ -x \"$basedir/node\" ]; then\n // exec \"$basedir/node\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" \"$@\"\n // else\n // exec node \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" \"$@\"\n // fi\n relPath = /(?<=\"$basedir\\/).*(?=\" \"\\$@\"\\n)/.exec(source)?.[0] || ''\n } else if (extLowered === '.ps1') {\n // \"bin.PS1\" generated by\n // https://github.com/npm/cmd-shim/blob/v7.0.0/lib/index.js#L192:\n //\n // #!/usr/bin/env pwsh\n // $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent\n //\n // $exe=\"\"\n // if ($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 // $ret=0\n // if (Test-Path \"$basedir/node$exe\") {\n // # Support pipeline input\n // if ($MyInvocation.ExpectingInput) {\n // $input | & \"$basedir/node$exe\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" $args\n // } else {\n // & \"$basedir/node$exe\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" $args\n // }\n // $ret=$LASTEXITCODE\n // } else {\n // # Support pipeline input\n // if ($MyInvocation.ExpectingInput) {\n // $input | & \"node$exe\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" $args\n // } else {\n // & \"node$exe\" \"$basedir/../<PACKAGE_NAME>/path/to/bin.js\" $args\n // }\n // $ret=$LASTEXITCODE\n // }\n // exit $ret\n relPath = /(?<=\"\\$basedir\\/).*(?=\" $args\\n)/.exec(source)?.[0] || ''\n }\n if (relPath) {\n binPath = normalizePath(path?.resolve(path?.dirname(binPath), relPath))\n }\n }\n } else {\n // Handle Unix shell scripts (non-Windows platforms)\n let hasNoExt = extLowered === ''\n const isPnpmOrYarn = basename === 'pnpm' || basename === 'yarn'\n const isNpmOrNpx = basename === 'npm' || basename === 'npx'\n\n // Handle special case where pnpm path in CI has extra segments.\n // In setup-pnpm GitHub Action, the path might be malformed like:\n // /home/user/setup-pnpm/node_modules/.bin/pnpm/bin/pnpm.cjs\n // This happens when the shell script contains a relative path that\n // when resolved, creates an invalid nested structure.\n if (isPnpmOrYarn && binPath.includes('/.bin/pnpm/bin/')) {\n // Extract the correct pnpm bin path.\n const binIndex = binPath.indexOf('/.bin/pnpm')\n if (binIndex !== -1) {\n // Get the base path up to /.bin/pnpm.\n const baseBinPath = binPath.slice(0, binIndex + '/.bin/pnpm'.length)\n // Check if the original shell script exists.\n try {\n const stats = fs?.statSync(baseBinPath)\n // Only use this path if it's a file (the shell script).\n if (stats.isFile()) {\n binPath = normalizePath(baseBinPath)\n // Recompute hasNoExt since we changed the path.\n hasNoExt = !path?.extname(binPath)\n }\n } catch {\n // If stat fails, continue with the original path.\n }\n }\n }\n\n if (\n hasNoExt &&\n (isPnpmOrYarn || isNpmOrNpx) &&\n // For extensionless files (Unix shell scripts), verify existence before reading.\n // This prevents ENOENT errors when the bin path doesn't exist.\n fs?.existsSync(binPath)\n ) {\n const source = fs?.readFileSync(binPath, 'utf8')\n let relPath = ''\n\n if (isPnpmOrYarn) {\n // Handle pnpm/yarn Unix shell scripts.\n // Format: exec \"$basedir/node\" \"$basedir/.tools/pnpm/VERSION/...\" \"$@\"\n // or: exec node \"$basedir/.tools/pnpm/VERSION/...\" \"$@\"\n relPath =\n /(?<=\"\\$basedir\\/)\\.tools\\/[^\"]+(?=\"\\s+\"\\$@\")/.exec(source)?.[0] || ''\n if (!relPath) {\n // Try standard cmd-shim format: exec node \"$basedir/../package/bin/binary.js\" \"$@\"\n // Example: exec node \"$basedir/../pnpm/bin/pnpm.cjs\" \"$@\"\n // ^^^^^^^^^^^^^^^^^^^^^ captures this part\n // This regex needs to be more careful to not match \"$@\" at the end.\n relPath =\n /(?<=\"\\$basedir\\/)[^\"]+(?=\"\\s+\"\\$@\")/.exec(source)?.[0] || ''\n }\n // Special case for setup-pnpm GitHub Action which may use a different format.\n // The setup-pnpm action creates a shell script that references ../pnpm/bin/pnpm.cjs\n if (!relPath) {\n // Try to match: exec node \"$basedir/../pnpm/bin/pnpm.cjs\" \"$@\"\n const match = /exec\\s+node\\s+\"?\\$basedir\\/([^\"]+)\"?\\s+\"\\$@\"/.exec(\n source,\n )\n if (match) {\n relPath = match[1] || ''\n }\n }\n // Check if the extracted path looks wrong (e.g., pnpm/bin/pnpm.cjs without ../).\n // This happens with setup-pnpm action when it creates a malformed shell script.\n if (relPath && basename === 'pnpm' && relPath.startsWith('pnpm/')) {\n // The path should be ../pnpm/... not pnpm/...\n // Prepend ../ to fix the relative path.\n relPath = `../${relPath}`\n }\n } else if (isNpmOrNpx) {\n // Handle npm/npx Unix shell scripts\n relPath =\n basename === 'npm'\n ? /(?<=NPM_CLI_JS=\"\\$CLI_BASEDIR\\/).*(?=\")/.exec(source)?.[0] || ''\n : /(?<=NPX_CLI_JS=\"\\$CLI_BASEDIR\\/).*(?=\")/.exec(source)?.[0] || ''\n }\n\n if (relPath) {\n // Resolve the relative path to handle .. segments properly.\n binPath = normalizePath(path?.resolve(path?.dirname(binPath), relPath))\n }\n }\n }\n try {\n const realPath = fs?.realpathSync.native(binPath)\n return normalizePath(realPath)\n } catch {}\n // Return normalized path even if realpath fails.\n return normalizePath(binPath)\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,gBAAAC,EAAA,gBAAAC,EAAA,iBAAAC,EAAA,iBAAAC,EAAA,oBAAAC,EAAA,uBAAAC,EAAA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,EAAW,EAAmB,EAEnE,GAAI,EACYjC,GAAI,SAASkC,CAAW,GAE5B,OAAO,IACf/C,KAAU,iBAAc+C,CAAW,EAEnCF,EAAW,CAAC/B,GAAM,QAAQd,CAAO,EAErC,MAAQ,CAER,CACF,CACF,CAEA,GACE6C,IACCJ,GAAgBD,IAGjB3B,GAAI,WAAWb,CAAO,EACtB,CACA,MAAM4C,EAAS/B,GAAI,aAAab,EAAS,MAAM,EAC/C,IAAI2C,EAAU,GAEd,GAAIF,EAAc,CAgBhB,GAZAE,EACE,+CAA+C,KAAKC,CAAM,IAAI,CAAC,GAAK,GACjED,IAKHA,EACE,sCAAsC,KAAKC,CAAM,IAAI,CAAC,GAAK,IAI3D,CAACD,EAAS,CAEZ,MAAMK,EAAQ,+CAA+C,KAC3DJ,CACF,EACII,IACFL,EAAUK,EAAM,CAAC,GAAK,GAE1B,CAGIL,GAAWjB,IAAa,QAAUiB,EAAQ,WAAW,OAAO,IAG9DA,EAAU,MAAMA,CAAO,GAE3B,MAAWH,IAETG,EACEjB,IAAa,MACT,0CAA0C,KAAKkB,CAAM,IAAI,CAAC,GAAK,GAC/D,0CAA0C,KAAKA,CAAM,IAAI,CAAC,GAAK,IAGnED,IAEF3C,KAAU,iBAAcc,GAAM,QAAQA,GAAM,QAAQd,CAAO,EAAG2C,CAAO,CAAC,EAE1E,CACF,CACA,GAAI,CACF,MAAMM,EAAWpC,GAAI,aAAa,OAAOb,CAAO,EAChD,SAAO,iBAAciD,CAAQ,CAC/B,MAAQ,CAAC,CAET,SAAO,iBAAcjD,CAAO,CAC9B",
6
6
  "names": ["bin_exports", "__export", "execBin", "findRealBin", "findRealNpm", "findRealPnpm", "findRealYarn", "isShadowBinPath", "resolveBinPathSync", "which", "whichBin", "whichBinSync", "whichSync", "__toCommonJS", "import_home", "import_windows", "import_xdg", "import_platform", "import_fs", "import_path", "import_spawn", "_fs", "getFs", "_path", "getPath", "_which", "getWhich", "binPath", "args", "options", "resolvedPath", "error", "binCommand", "binName", "opts", "result", "paths", "p", "dirPath", "commonPaths", "fs", "path", "binDir", "allPaths", "pathsArray", "altPath", "altDir", "nodeDir", "npmInNodeDir", "npmPath", "resolved", "ext", "extLowered", "basename", "voltaIndex", "voltaPath", "voltaToolsPath", "voltaImagePath", "voltaUserPath", "voltaPlatform", "voltaNodeVersion", "voltaNpmVersion", "voltaBinPath", "relCliPath", "voltaUserBinPath", "binPackage", "hasKnownExt", "isNpmOrNpx", "isPnpmOrYarn", "quickPath", "relPath", "source", "hasNoExt", "binIndex", "baseBinPath", "match", "realPath"]
7
7
  }
@@ -6,6 +6,14 @@ export declare const SOCKET_API_BASE_URL = "https://api.socket.dev/v0";
6
6
  export declare const SOCKET_PUBLIC_API_KEY = "sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api";
7
7
  // Alias for backward compatibility.
8
8
  export declare const SOCKET_PUBLIC_API_TOKEN = "sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api";
9
+ // Socket.dev URLs.
10
+ export declare const SOCKET_WEBSITE_URL = "https://socket.dev";
11
+ export declare const SOCKET_CONTACT_URL = "https://socket.dev/contact";
12
+ export declare const SOCKET_DASHBOARD_URL = "https://socket.dev/dashboard";
13
+ export declare const SOCKET_API_TOKENS_URL = "https://socket.dev/dashboard/settings/api-tokens";
14
+ export declare const SOCKET_PRICING_URL = "https://socket.dev/pricing";
15
+ export declare const SOCKET_STATUS_URL = "https://status.socket.dev";
16
+ export declare const SOCKET_DOCS_URL = "https://docs.socket.dev";
9
17
  // Socket.dev scopes.
10
18
  export declare const SOCKET_REGISTRY_SCOPE = "@socketregistry";
11
19
  export declare const SOCKET_SECURITY_SCOPE = "@socketsecurity";
@@ -1,3 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var e=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(_,t)=>{for(var E in t)e(_,E,{get:t[E],enumerable:!0})},O=(_,t,E,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of c(t))!C.call(_,o)&&o!==E&&e(_,o,{get:()=>t[o],enumerable:!(s=S(t,o))||s.enumerable});return _};var P=_=>O(e({},"__esModule",{value:!0}),_);var H={};T(H,{CACHE_SOCKET_API_DIR:()=>L,REGISTRY:()=>a,REGISTRY_SCOPE_DELIMITER:()=>g,SOCKET_API_BASE_URL:()=>R,SOCKET_APP_PREFIX:()=>M,SOCKET_CLI_APP_NAME:()=>G,SOCKET_DLX_APP_NAME:()=>N,SOCKET_FIREWALL_APP_NAME:()=>y,SOCKET_GITHUB_ORG:()=>x,SOCKET_IPC_HANDSHAKE:()=>D,SOCKET_OVERRIDE_SCOPE:()=>p,SOCKET_PUBLIC_API_KEY:()=>r,SOCKET_PUBLIC_API_TOKEN:()=>A,SOCKET_REGISTRY_APP_NAME:()=>Y,SOCKET_REGISTRY_NPM_ORG:()=>k,SOCKET_REGISTRY_PACKAGE_NAME:()=>i,SOCKET_REGISTRY_REPO_NAME:()=>n,SOCKET_REGISTRY_SCOPE:()=>K,SOCKET_SECURITY_SCOPE:()=>I});module.exports=P(H);const R="https://api.socket.dev/v0",r="sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api",A=r,K="@socketregistry",I="@socketsecurity",p="@socketoverride",x="SocketDev",n="socket-registry",i="@socketsecurity/registry",k="socketregistry",G="socket",N="dlx",y="sfw",Y="registry",M="_",D="SOCKET_IPC_HANDSHAKE",L="socket-api",a="registry",g="__";0&&(module.exports={CACHE_SOCKET_API_DIR,REGISTRY,REGISTRY_SCOPE_DELIMITER,SOCKET_API_BASE_URL,SOCKET_APP_PREFIX,SOCKET_CLI_APP_NAME,SOCKET_DLX_APP_NAME,SOCKET_FIREWALL_APP_NAME,SOCKET_GITHUB_ORG,SOCKET_IPC_HANDSHAKE,SOCKET_OVERRIDE_SCOPE,SOCKET_PUBLIC_API_KEY,SOCKET_PUBLIC_API_TOKEN,SOCKET_REGISTRY_APP_NAME,SOCKET_REGISTRY_NPM_ORG,SOCKET_REGISTRY_PACKAGE_NAME,SOCKET_REGISTRY_REPO_NAME,SOCKET_REGISTRY_SCOPE,SOCKET_SECURITY_SCOPE});
2
+ var e=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var C=(o,t)=>{for(var s in t)e(o,s,{get:t[s],enumerable:!0})},p=(o,t,s,E)=>{if(t&&typeof t=="object"||typeof t=="function")for(let _ of r(t))!T.call(o,_)&&_!==s&&e(o,_,{get:()=>t[_],enumerable:!(E=S(t,_))||E.enumerable});return o};var O=o=>p(e({},"__esModule",{value:!0}),o);var b={};C(b,{CACHE_SOCKET_API_DIR:()=>B,REGISTRY:()=>H,REGISTRY_SCOPE_DELIMITER:()=>u,SOCKET_API_BASE_URL:()=>R,SOCKET_API_TOKENS_URL:()=>I,SOCKET_APP_PREFIX:()=>M,SOCKET_CLI_APP_NAME:()=>D,SOCKET_CONTACT_URL:()=>A,SOCKET_DASHBOARD_URL:()=>P,SOCKET_DLX_APP_NAME:()=>h,SOCKET_DOCS_URL:()=>i,SOCKET_FIREWALL_APP_NAME:()=>y,SOCKET_GITHUB_ORG:()=>U,SOCKET_IPC_HANDSHAKE:()=>g,SOCKET_OVERRIDE_SCOPE:()=>N,SOCKET_PRICING_URL:()=>x,SOCKET_PUBLIC_API_KEY:()=>c,SOCKET_PUBLIC_API_TOKEN:()=>K,SOCKET_REGISTRY_APP_NAME:()=>Y,SOCKET_REGISTRY_NPM_ORG:()=>G,SOCKET_REGISTRY_PACKAGE_NAME:()=>v,SOCKET_REGISTRY_REPO_NAME:()=>a,SOCKET_REGISTRY_SCOPE:()=>d,SOCKET_SECURITY_SCOPE:()=>L,SOCKET_STATUS_URL:()=>k,SOCKET_WEBSITE_URL:()=>n});module.exports=O(b);const R="https://api.socket.dev/v0",c="sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api",K=c,n="https://socket.dev",A="https://socket.dev/contact",P="https://socket.dev/dashboard",I="https://socket.dev/dashboard/settings/api-tokens",x="https://socket.dev/pricing",k="https://status.socket.dev",i="https://docs.socket.dev",d="@socketregistry",L="@socketsecurity",N="@socketoverride",U="SocketDev",a="socket-registry",v="@socketsecurity/registry",G="socketregistry",D="socket",h="dlx",y="sfw",Y="registry",M="_",g="SOCKET_IPC_HANDSHAKE",B="socket-api",H="registry",u="__";0&&(module.exports={CACHE_SOCKET_API_DIR,REGISTRY,REGISTRY_SCOPE_DELIMITER,SOCKET_API_BASE_URL,SOCKET_API_TOKENS_URL,SOCKET_APP_PREFIX,SOCKET_CLI_APP_NAME,SOCKET_CONTACT_URL,SOCKET_DASHBOARD_URL,SOCKET_DLX_APP_NAME,SOCKET_DOCS_URL,SOCKET_FIREWALL_APP_NAME,SOCKET_GITHUB_ORG,SOCKET_IPC_HANDSHAKE,SOCKET_OVERRIDE_SCOPE,SOCKET_PRICING_URL,SOCKET_PUBLIC_API_KEY,SOCKET_PUBLIC_API_TOKEN,SOCKET_REGISTRY_APP_NAME,SOCKET_REGISTRY_NPM_ORG,SOCKET_REGISTRY_PACKAGE_NAME,SOCKET_REGISTRY_REPO_NAME,SOCKET_REGISTRY_SCOPE,SOCKET_SECURITY_SCOPE,SOCKET_STATUS_URL,SOCKET_WEBSITE_URL});
3
3
  //# sourceMappingURL=socket.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/constants/socket.ts"],
4
- "sourcesContent": ["/**\n * Socket.dev APIs, scopes, organizations, and application names.\n */\n\n// Socket.dev API.\nexport const SOCKET_API_BASE_URL = 'https://api.socket.dev/v0'\nexport const SOCKET_PUBLIC_API_KEY =\n 'sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api'\n// Alias for backward compatibility.\nexport const SOCKET_PUBLIC_API_TOKEN = SOCKET_PUBLIC_API_KEY\n\n// Socket.dev scopes.\nexport const SOCKET_REGISTRY_SCOPE = '@socketregistry'\nexport const SOCKET_SECURITY_SCOPE = '@socketsecurity'\nexport const SOCKET_OVERRIDE_SCOPE = '@socketoverride'\n\n// Socket.dev organization and repositories.\nexport const SOCKET_GITHUB_ORG = 'SocketDev'\nexport const SOCKET_REGISTRY_REPO_NAME = 'socket-registry'\nexport const SOCKET_REGISTRY_PACKAGE_NAME = '@socketsecurity/registry'\nexport const SOCKET_REGISTRY_NPM_ORG = 'socketregistry'\n\n// Socket.dev application names.\nexport const SOCKET_CLI_APP_NAME = 'socket'\nexport const SOCKET_DLX_APP_NAME = 'dlx'\nexport const SOCKET_FIREWALL_APP_NAME = 'sfw'\nexport const SOCKET_REGISTRY_APP_NAME = 'registry'\nexport const SOCKET_APP_PREFIX = '_'\n\n// Socket.dev IPC.\nexport const SOCKET_IPC_HANDSHAKE = 'SOCKET_IPC_HANDSHAKE'\n\n// Socket.dev cache and registry.\nexport const CACHE_SOCKET_API_DIR = 'socket-api'\nexport const REGISTRY = 'registry'\nexport const REGISTRY_SCOPE_DELIMITER = '__'\n"],
5
- "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,aAAAC,EAAA,6BAAAC,EAAA,wBAAAC,EAAA,sBAAAC,EAAA,wBAAAC,EAAA,wBAAAC,EAAA,6BAAAC,EAAA,sBAAAC,EAAA,yBAAAC,EAAA,0BAAAC,EAAA,0BAAAC,EAAA,4BAAAC,EAAA,6BAAAC,EAAA,4BAAAC,EAAA,iCAAAC,EAAA,8BAAAC,EAAA,0BAAAC,EAAA,0BAAAC,IAAA,eAAAC,EAAArB,GAKO,MAAMK,EAAsB,4BACtBQ,EACX,0DAEWC,EAA0BD,EAG1BM,EAAwB,kBACxBC,EAAwB,kBACxBR,EAAwB,kBAGxBF,EAAoB,YACpBQ,EAA4B,kBAC5BD,EAA+B,2BAC/BD,EAA0B,iBAG1BT,EAAsB,SACtBC,EAAsB,MACtBC,EAA2B,MAC3BM,EAA2B,WAC3BT,EAAoB,IAGpBK,EAAuB,uBAGvBT,EAAuB,aACvBC,EAAW,WACXC,EAA2B",
6
- "names": ["socket_exports", "__export", "CACHE_SOCKET_API_DIR", "REGISTRY", "REGISTRY_SCOPE_DELIMITER", "SOCKET_API_BASE_URL", "SOCKET_APP_PREFIX", "SOCKET_CLI_APP_NAME", "SOCKET_DLX_APP_NAME", "SOCKET_FIREWALL_APP_NAME", "SOCKET_GITHUB_ORG", "SOCKET_IPC_HANDSHAKE", "SOCKET_OVERRIDE_SCOPE", "SOCKET_PUBLIC_API_KEY", "SOCKET_PUBLIC_API_TOKEN", "SOCKET_REGISTRY_APP_NAME", "SOCKET_REGISTRY_NPM_ORG", "SOCKET_REGISTRY_PACKAGE_NAME", "SOCKET_REGISTRY_REPO_NAME", "SOCKET_REGISTRY_SCOPE", "SOCKET_SECURITY_SCOPE", "__toCommonJS"]
4
+ "sourcesContent": ["/**\n * Socket.dev APIs, scopes, organizations, and application names.\n */\n\n// Socket.dev API.\nexport const SOCKET_API_BASE_URL = 'https://api.socket.dev/v0'\nexport const SOCKET_PUBLIC_API_KEY =\n 'sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api'\n// Alias for backward compatibility.\nexport const SOCKET_PUBLIC_API_TOKEN = SOCKET_PUBLIC_API_KEY\n\n// Socket.dev URLs.\nexport const SOCKET_WEBSITE_URL = 'https://socket.dev'\nexport const SOCKET_CONTACT_URL = 'https://socket.dev/contact'\nexport const SOCKET_DASHBOARD_URL = 'https://socket.dev/dashboard'\nexport const SOCKET_API_TOKENS_URL =\n 'https://socket.dev/dashboard/settings/api-tokens'\nexport const SOCKET_PRICING_URL = 'https://socket.dev/pricing'\nexport const SOCKET_STATUS_URL = 'https://status.socket.dev'\nexport const SOCKET_DOCS_URL = 'https://docs.socket.dev'\n\n// Socket.dev scopes.\nexport const SOCKET_REGISTRY_SCOPE = '@socketregistry'\nexport const SOCKET_SECURITY_SCOPE = '@socketsecurity'\nexport const SOCKET_OVERRIDE_SCOPE = '@socketoverride'\n\n// Socket.dev organization and repositories.\nexport const SOCKET_GITHUB_ORG = 'SocketDev'\nexport const SOCKET_REGISTRY_REPO_NAME = 'socket-registry'\nexport const SOCKET_REGISTRY_PACKAGE_NAME = '@socketsecurity/registry'\nexport const SOCKET_REGISTRY_NPM_ORG = 'socketregistry'\n\n// Socket.dev application names.\nexport const SOCKET_CLI_APP_NAME = 'socket'\nexport const SOCKET_DLX_APP_NAME = 'dlx'\nexport const SOCKET_FIREWALL_APP_NAME = 'sfw'\nexport const SOCKET_REGISTRY_APP_NAME = 'registry'\nexport const SOCKET_APP_PREFIX = '_'\n\n// Socket.dev IPC.\nexport const SOCKET_IPC_HANDSHAKE = 'SOCKET_IPC_HANDSHAKE'\n\n// Socket.dev cache and registry.\nexport const CACHE_SOCKET_API_DIR = 'socket-api'\nexport const REGISTRY = 'registry'\nexport const REGISTRY_SCOPE_DELIMITER = '__'\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,aAAAC,EAAA,6BAAAC,EAAA,wBAAAC,EAAA,0BAAAC,EAAA,sBAAAC,EAAA,wBAAAC,EAAA,uBAAAC,EAAA,yBAAAC,EAAA,wBAAAC,EAAA,oBAAAC,EAAA,6BAAAC,EAAA,sBAAAC,EAAA,yBAAAC,EAAA,0BAAAC,EAAA,uBAAAC,EAAA,0BAAAC,EAAA,4BAAAC,EAAA,6BAAAC,EAAA,4BAAAC,EAAA,iCAAAC,EAAA,8BAAAC,EAAA,0BAAAC,EAAA,0BAAAC,EAAA,sBAAAC,EAAA,uBAAAC,IAAA,eAAAC,EAAA5B,GAKO,MAAMK,EAAsB,4BACtBa,EACX,0DAEWC,EAA0BD,EAG1BS,EAAqB,qBACrBlB,EAAqB,6BACrBC,EAAuB,+BACvBJ,EACX,mDACWW,EAAqB,6BACrBS,EAAoB,4BACpBd,EAAkB,0BAGlBY,EAAwB,kBACxBC,EAAwB,kBACxBT,EAAwB,kBAGxBF,EAAoB,YACpBS,EAA4B,kBAC5BD,EAA+B,2BAC/BD,EAA0B,iBAG1Bb,EAAsB,SACtBG,EAAsB,MACtBE,EAA2B,MAC3BO,EAA2B,WAC3Bb,EAAoB,IAGpBQ,EAAuB,uBAGvBb,EAAuB,aACvBC,EAAW,WACXC,EAA2B",
6
+ "names": ["socket_exports", "__export", "CACHE_SOCKET_API_DIR", "REGISTRY", "REGISTRY_SCOPE_DELIMITER", "SOCKET_API_BASE_URL", "SOCKET_API_TOKENS_URL", "SOCKET_APP_PREFIX", "SOCKET_CLI_APP_NAME", "SOCKET_CONTACT_URL", "SOCKET_DASHBOARD_URL", "SOCKET_DLX_APP_NAME", "SOCKET_DOCS_URL", "SOCKET_FIREWALL_APP_NAME", "SOCKET_GITHUB_ORG", "SOCKET_IPC_HANDSHAKE", "SOCKET_OVERRIDE_SCOPE", "SOCKET_PRICING_URL", "SOCKET_PUBLIC_API_KEY", "SOCKET_PUBLIC_API_TOKEN", "SOCKET_REGISTRY_APP_NAME", "SOCKET_REGISTRY_NPM_ORG", "SOCKET_REGISTRY_PACKAGE_NAME", "SOCKET_REGISTRY_REPO_NAME", "SOCKET_REGISTRY_SCOPE", "SOCKET_SECURITY_SCOPE", "SOCKET_STATUS_URL", "SOCKET_WEBSITE_URL", "__toCommonJS"]
7
7
  }
@@ -1,3 +1,9 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var z=Object.create;var k=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var X=(t,n)=>{for(var e in n)k(t,e,{get:n[e],enumerable:!0})},S=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of q(n))!W.call(t,r)&&r!==e&&k(t,r,{get:()=>n[r],enumerable:!(i=Y(n,r))||i.enumerable});return t};var j=(t,n,e)=>(e=t!=null?z(K(t)):{},S(n||!t||!t.__esModule?k(e,"default",{value:t,enumerable:!0}):e,t)),J=t=>S(k({},"__esModule",{value:!0}),t);var Z={};X(Z,{cleanDlxCache:()=>M,dlxBinary:()=>V,downloadBinary:()=>G,executeBinary:()=>Q,getDlxCachePath:()=>D,listDlxCache:()=>U});module.exports=J(Z);var B=require("node:crypto"),s=require("node:fs"),b=j(require("node:os")),l=j(require("node:path")),_=require("#constants/platform"),$=require("./dlx"),C=require("./download-lock"),f=require("./fs"),R=require("./objects"),A=require("./path"),v=require("./paths"),O=require("./spawn");function x(t){return l.default.join(t,".dlx-metadata.json")}async function E(t,n){try{const e=x(t);if(!(0,s.existsSync)(e))return!1;const i=await(0,f.readJson)(e,{throws:!1});if(!(0,R.isObjectObject)(i))return!1;const r=Date.now(),a=i.timestamp;return typeof a!="number"||a<=0?!1:r-a<n}catch{return!1}}async function N(t,n,e){await(0,C.downloadWithLock)(t,n,{staleTimeout:1e4,lockTimeout:12e4});const i=await s.promises.readFile(n),r=(0,B.createHash)("sha256");r.update(i);const a=r.digest("hex");if(e&&a!==e)throw await(0,f.safeDelete)(n),new Error(`Checksum mismatch: expected ${e}, got ${a}`);return _.WIN32||await s.promises.chmod(n,493),a}async function I(t,n,e){const i=x(t),r={arch:b.default.arch(),checksum:e,platform:b.default.platform(),timestamp:Date.now(),url:n,version:"1.0.0"};await s.promises.writeFile(i,JSON.stringify(r,null,2))}async function M(t=require("#constants/time").DLX_BINARY_CACHE_TTL){const n=D();if(!(0,s.existsSync)(n))return 0;let e=0;const i=Date.now(),r=await s.promises.readdir(n);for(const a of r){const o=l.default.join(n,a),c=x(o);try{if(!await(0,f.isDir)(o))continue;const u=await(0,f.readJson)(c,{throws:!1});if(!u||typeof u!="object"||Array.isArray(u))continue;const p=u.timestamp;(typeof p=="number"&&p>0?i-p:Number.POSITIVE_INFINITY)>t&&(await(0,f.safeDelete)(o,{force:!0,recursive:!0}),e+=1)}catch{try{(await s.promises.readdir(o)).length||(await(0,f.safeDelete)(o),e+=1)}catch{}}}return e}async function V(t,n,e){const{cacheTtl:i=require("#constants/time").DLX_BINARY_CACHE_TTL,checksum:r,force:a=!1,name:o,spawnOptions:c,url:u}={__proto__:null,...n},p=D(),m=o||`binary-${process.platform}-${b.default.arch()}`,w=`${u}:${m}`,d=(0,$.generateCacheKey)(w),h=l.default.join(p,d),P=(0,A.normalizePath)(l.default.join(h,m));let y=!1,T=r;if(!a&&(0,s.existsSync)(h)&&await E(h,i))try{const F=x(h),g=await(0,f.readJson)(F,{throws:!1});g&&typeof g=="object"&&!Array.isArray(g)&&typeof g.checksum=="string"?T=g.checksum:y=!0}catch{y=!0}else y=!0;y&&(await s.promises.mkdir(h,{recursive:!0}),T=await N(u,P,r),await I(h,u,T||""));const H=_.WIN32&&/\.(?:bat|cmd|ps1)$/i.test(P)?{...c,env:{...c?.env,PATH:`${h}${l.default.delimiter}${process.env.PATH||""}`},shell:!0}:c,L=(0,O.spawn)(P,t,H,e);return{binaryPath:P,downloaded:y,spawnPromise:L}}async function G(t){const{cacheTtl:n=require("#constants/time").DLX_BINARY_CACHE_TTL,checksum:e,force:i=!1,name:r,url:a}={__proto__:null,...t},o=D(),c=r||`binary-${process.platform}-${b.default.arch()}`,u=`${a}:${c}`,p=(0,$.generateCacheKey)(u),m=l.default.join(o,p),w=(0,A.normalizePath)(l.default.join(m,c));let d=!1;if(!i&&(0,s.existsSync)(m)&&await E(m,n))d=!1;else{await s.promises.mkdir(m,{recursive:!0});const h=await N(a,w,e);await I(m,a,h||""),d=!0}return{binaryPath:w,downloaded:d}}function Q(t,n,e,i){const r=_.WIN32&&/\.(?:bat|cmd|ps1)$/i.test(t),a=l.default.dirname(t),o=r?{...e,env:{...e?.env,PATH:`${a}${l.default.delimiter}${process.env.PATH||""}`},shell:!0}:e;return(0,O.spawn)(t,n,o,i)}function D(){return(0,v.getSocketDlxDir)()}async function U(){const t=D();if(!(0,s.existsSync)(t))return[];const n=[],e=Date.now(),i=await s.promises.readdir(t);for(const r of i){const a=l.default.join(t,r);try{if(!await(0,f.isDir)(a))continue;const o=x(a),c=await(0,f.readJson)(o,{throws:!1});if(!c||typeof c!="object"||Array.isArray(c))continue;const p=(await s.promises.readdir(a)).find(m=>!m.startsWith("."));if(p){const m=l.default.join(a,p),w=await s.promises.stat(m),d=c;n.push({age:e-(d.timestamp||0),arch:d.arch||"unknown",checksum:d.checksum||"",name:p,platform:d.platform||"unknown",size:w.size,url:d.url||""})}}catch{}}return n}0&&(module.exports={cleanDlxCache,dlxBinary,downloadBinary,executeBinary,getDlxCachePath,listDlxCache});
2
+ var z=Object.create;var P=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var q=(t,e)=>{for(var n in e)P(t,n,{get:e[n],enumerable:!0})},R=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of X(e))!Y.call(t,r)&&r!==n&&P(t,r,{get:()=>e[r],enumerable:!(i=K(e,r))||i.enumerable});return t};var T=(t,e,n)=>(n=t!=null?z(J(t)):{},R(e||!t||!t.__esModule?P(n,"default",{value:t,enumerable:!0}):n,t)),V=t=>R(P({},"__esModule",{value:!0}),t);var ee={};q(ee,{cleanDlxCache:()=>W,dlxBinary:()=>U,downloadBinary:()=>G,executeBinary:()=>Q,getDlxCachePath:()=>k,listDlxCache:()=>Z});module.exports=V(ee);var S=require("node:crypto"),o=require("node:fs"),D=T(require("node:os")),u=T(require("node:path")),$=require("#constants/platform"),_=require("./dlx"),j=require("./http-request"),p=require("./fs"),B=require("./objects"),O=require("./path"),v=require("./paths"),I=require("./process-lock"),A=require("./spawn");function x(t){return u.default.join(t,".dlx-metadata.json")}async function N(t,e){try{const n=x(t);if(!(0,o.existsSync)(n))return!1;const i=await(0,p.readJson)(n,{throws:!1});if(!(0,B.isObjectObject)(i))return!1;const r=Date.now(),a=i.timestamp;return typeof a!="number"||a<=0?!1:r-a<e}catch{return!1}}async function F(t,e,n){const i=u.default.dirname(e),r=u.default.join(i,"concurrency.lock");return await I.processLock.withLock(r,async()=>{if((0,o.existsSync)(e)&&(await o.promises.stat(e)).size>0){const f=await o.promises.readFile(e),s=(0,S.createHash)("sha256");return s.update(f),s.digest("hex")}try{await(0,j.httpDownload)(t,e)}catch(m){throw new Error(`Failed to download binary from ${t}
3
+ Destination: ${e}
4
+ Check your internet connection or verify the URL is accessible.`,{cause:m})}const a=await o.promises.readFile(e),c=(0,S.createHash)("sha256");c.update(a);const l=c.digest("hex");if(n&&l!==n)throw await(0,p.safeDelete)(e),new Error(`Checksum mismatch: expected ${n}, got ${l}`);return $.WIN32||await o.promises.chmod(e,493),l},{staleMs:5e3,touchIntervalMs:2e3})}async function L(t,e,n){const i=x(t),r={arch:D.default.arch(),checksum:n,platform:D.default.platform(),timestamp:Date.now(),url:e,version:"1.0.0"};await o.promises.writeFile(i,JSON.stringify(r,null,2))}async function W(t=require("#constants/time").DLX_BINARY_CACHE_TTL){const e=k();if(!(0,o.existsSync)(e))return 0;let n=0;const i=Date.now(),r=await o.promises.readdir(e);for(const a of r){const c=u.default.join(e,a),l=x(c);try{if(!await(0,p.isDir)(c))continue;const m=await(0,p.readJson)(l,{throws:!1});if(!m||typeof m!="object"||Array.isArray(m))continue;const f=m.timestamp;(typeof f=="number"&&f>0?i-f:Number.POSITIVE_INFINITY)>t&&(await(0,p.safeDelete)(c,{force:!0,recursive:!0}),n+=1)}catch{try{(await o.promises.readdir(c)).length||(await(0,p.safeDelete)(c),n+=1)}catch{}}}return n}async function U(t,e,n){const{cacheTtl:i=require("#constants/time").DLX_BINARY_CACHE_TTL,checksum:r,force:a=!1,name:c,spawnOptions:l,url:m}={__proto__:null,...e},f=k(),s=c||`binary-${process.platform}-${D.default.arch()}`,b=`${m}:${s}`,h=(0,_.generateCacheKey)(b),d=u.default.join(f,h),w=(0,O.normalizePath)(u.default.join(d,s));let y=!1,C=r;if(!a&&(0,o.existsSync)(d)&&await N(d,i))try{const E=x(d),g=await(0,p.readJson)(E,{throws:!1});g&&typeof g=="object"&&!Array.isArray(g)&&typeof g.checksum=="string"?C=g.checksum:y=!0}catch{y=!0}else y=!0;if(y){try{await o.promises.mkdir(d,{recursive:!0})}catch(E){const g=E.code;throw g==="EACCES"||g==="EPERM"?new Error(`Permission denied creating binary cache directory: ${d}
5
+ Please check directory permissions or run with appropriate access.`,{cause:E}):g==="EROFS"?new Error(`Cannot create binary cache directory on read-only filesystem: ${d}
6
+ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`,{cause:E}):new Error(`Failed to create binary cache directory: ${d}`,{cause:E})}C=await F(m,w,r),await L(d,m,C||"")}const H=$.WIN32&&/\.(?:bat|cmd|ps1)$/i.test(w)?{...l,env:{...l?.env,PATH:`${d}${u.default.delimiter}${process.env.PATH||""}`},shell:!0}:l,M=(0,A.spawn)(w,t,H,n);return{binaryPath:w,downloaded:y,spawnPromise:M}}async function G(t){const{cacheTtl:e=require("#constants/time").DLX_BINARY_CACHE_TTL,checksum:n,force:i=!1,name:r,url:a}={__proto__:null,...t},c=k(),l=r||`binary-${process.platform}-${D.default.arch()}`,m=`${a}:${l}`,f=(0,_.generateCacheKey)(m),s=u.default.join(c,f),b=(0,O.normalizePath)(u.default.join(s,l));let h=!1;if(!i&&(0,o.existsSync)(s)&&await N(s,e))h=!1;else{try{await o.promises.mkdir(s,{recursive:!0})}catch(w){const y=w.code;throw y==="EACCES"||y==="EPERM"?new Error(`Permission denied creating binary cache directory: ${s}
7
+ Please check directory permissions or run with appropriate access.`,{cause:w}):y==="EROFS"?new Error(`Cannot create binary cache directory on read-only filesystem: ${s}
8
+ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`,{cause:w}):new Error(`Failed to create binary cache directory: ${s}`,{cause:w})}const d=await F(a,b,n);await L(s,a,d||""),h=!0}return{binaryPath:b,downloaded:h}}function Q(t,e,n,i){const r=$.WIN32&&/\.(?:bat|cmd|ps1)$/i.test(t),a=u.default.dirname(t),c=r?{...n,env:{...n?.env,PATH:`${a}${u.default.delimiter}${process.env.PATH||""}`},shell:!0}:n;return(0,A.spawn)(t,e,c,i)}function k(){return(0,v.getSocketDlxDir)()}async function Z(){const t=k();if(!(0,o.existsSync)(t))return[];const e=[],n=Date.now(),i=await o.promises.readdir(t);for(const r of i){const a=u.default.join(t,r);try{if(!await(0,p.isDir)(a))continue;const c=x(a),l=await(0,p.readJson)(c,{throws:!1});if(!l||typeof l!="object"||Array.isArray(l))continue;const f=(await o.promises.readdir(a)).find(s=>!s.startsWith("."));if(f){const s=u.default.join(a,f),b=await o.promises.stat(s),h=l;e.push({age:n-(h.timestamp||0),arch:h.arch||"unknown",checksum:h.checksum||"",name:f,platform:h.platform||"unknown",size:b.size,url:h.url||""})}}catch{}}return e}0&&(module.exports={cleanDlxCache,dlxBinary,downloadBinary,executeBinary,getDlxCachePath,listDlxCache});
3
9
  //# sourceMappingURL=dlx-binary.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/dlx-binary.ts"],
4
- "sourcesContent": ["/** @fileoverview DLX binary execution utilities for Socket ecosystem. */\n\nimport { createHash } from 'node:crypto'\nimport { existsSync, promises as fs } from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport { WIN32 } from '#constants/platform'\n\nimport { generateCacheKey } from './dlx'\nimport { downloadWithLock } from './download-lock'\nimport { isDir, readJson, safeDelete } from './fs'\nimport { isObjectObject } from './objects'\nimport { normalizePath } from './path'\nimport { getSocketDlxDir } from './paths'\nimport type { SpawnExtra, SpawnOptions } from './spawn'\nimport { spawn } from './spawn'\n\nexport interface DlxBinaryOptions {\n /** URL to download the binary from. */\n url: string\n /** Optional name for the cached binary (defaults to URL hash). */\n name?: string | undefined\n /** Expected checksum (sha256) for verification. */\n checksum?: string | undefined\n /** Cache TTL in milliseconds (default: 7 days). */\n cacheTtl?: number | undefined\n /** Force re-download even if cached. */\n force?: boolean | undefined\n /** Additional spawn options. */\n spawnOptions?: SpawnOptions | undefined\n}\n\nexport interface DlxBinaryResult {\n /** Path to the cached binary. */\n binaryPath: string\n /** Whether the binary was newly downloaded. */\n downloaded: boolean\n /** The spawn promise for the running process. */\n spawnPromise: ReturnType<typeof spawn>\n}\n\n/**\n * Get metadata file path for a cached binary.\n */\nfunction getMetadataPath(cacheEntryPath: string): string {\n return path.join(cacheEntryPath, '.dlx-metadata.json')\n}\n\n/**\n * Check if a cached binary is still valid.\n */\nasync function isCacheValid(\n cacheEntryPath: string,\n cacheTtl: number,\n): Promise<boolean> {\n try {\n const metaPath = getMetadataPath(cacheEntryPath)\n if (!existsSync(metaPath)) {\n return false\n }\n\n const metadata = await readJson(metaPath, { throws: false })\n if (!isObjectObject(metadata)) {\n return false\n }\n const now = Date.now()\n const timestamp = (metadata as Record<string, unknown>)['timestamp']\n // If timestamp is missing or invalid, cache is invalid\n if (typeof timestamp !== 'number' || timestamp <= 0) {\n return false\n }\n const age = now - timestamp\n\n return age < cacheTtl\n } catch {\n return false\n }\n}\n\n/**\n * Download a file from a URL with integrity checking and concurrent download protection.\n * Uses downloadWithLock to prevent multiple processes from downloading the same binary simultaneously.\n * Internal helper function for downloading binary files.\n */\nasync function downloadBinaryFile(\n url: string,\n destPath: string,\n checksum?: string | undefined,\n): Promise<string> {\n // Use downloadWithLock to handle concurrent download protection.\n // This prevents corruption when multiple processes try to download the same binary.\n await downloadWithLock(url, destPath, {\n // Align with npm's npx locking strategy.\n staleTimeout: 10_000,\n // Allow up to 2 minutes for large binary downloads.\n lockTimeout: 120_000,\n })\n\n // Compute checksum of downloaded file.\n const fileBuffer = await fs.readFile(destPath)\n const hasher = createHash('sha256')\n hasher.update(fileBuffer)\n const actualChecksum = hasher.digest('hex')\n\n // Verify checksum if provided.\n if (checksum && actualChecksum !== checksum) {\n // Clean up invalid file.\n await safeDelete(destPath)\n throw new Error(\n `Checksum mismatch: expected ${checksum}, got ${actualChecksum}`,\n )\n }\n\n // Make executable on POSIX systems.\n if (!WIN32) {\n await fs.chmod(destPath, 0o755)\n }\n\n return actualChecksum\n}\n\n/**\n * Write metadata for a cached binary.\n */\nasync function writeMetadata(\n cacheEntryPath: string,\n url: string,\n checksum: string,\n): Promise<void> {\n const metaPath = getMetadataPath(cacheEntryPath)\n const metadata = {\n arch: os.arch(),\n checksum,\n platform: os.platform(),\n timestamp: Date.now(),\n url,\n version: '1.0.0',\n }\n await fs.writeFile(metaPath, JSON.stringify(metadata, null, 2))\n}\n\n/**\n * Clean expired entries from the DLX cache.\n */\nexport async function cleanDlxCache(\n maxAge: number = /*@__INLINE__*/ require('#constants/time').DLX_BINARY_CACHE_TTL,\n): Promise<number> {\n const cacheDir = getDlxCachePath()\n\n if (!existsSync(cacheDir)) {\n return 0\n }\n\n let cleaned = 0\n const now = Date.now()\n const entries = await fs.readdir(cacheDir)\n\n for (const entry of entries) {\n const entryPath = path.join(cacheDir, entry)\n const metaPath = getMetadataPath(entryPath)\n\n try {\n // eslint-disable-next-line no-await-in-loop\n if (!(await isDir(entryPath))) {\n continue\n }\n\n // eslint-disable-next-line no-await-in-loop\n const metadata = await readJson(metaPath, { throws: false })\n if (\n !metadata ||\n typeof metadata !== 'object' ||\n Array.isArray(metadata)\n ) {\n continue\n }\n const timestamp = (metadata as Record<string, unknown>)['timestamp']\n // If timestamp is missing or invalid, treat as expired (age = infinity)\n const age =\n typeof timestamp === 'number' && timestamp > 0\n ? now - timestamp\n : Number.POSITIVE_INFINITY\n\n if (age > maxAge) {\n // Remove entire cache entry directory.\n // eslint-disable-next-line no-await-in-loop\n await safeDelete(entryPath, { force: true, recursive: true })\n cleaned += 1\n }\n } catch {\n // If we can't read metadata, check if directory is empty or corrupted.\n try {\n // eslint-disable-next-line no-await-in-loop\n const contents = await fs.readdir(entryPath)\n if (!contents.length) {\n // Remove empty directory.\n // eslint-disable-next-line no-await-in-loop\n await safeDelete(entryPath)\n cleaned += 1\n }\n } catch {}\n }\n }\n\n return cleaned\n}\n\n/**\n * Download and execute a binary from a URL with caching.\n */\nexport async function dlxBinary(\n args: readonly string[] | string[],\n options?: DlxBinaryOptions | undefined,\n spawnExtra?: SpawnExtra | undefined,\n): Promise<DlxBinaryResult> {\n const {\n cacheTtl = /*@__INLINE__*/ require('#constants/time').DLX_BINARY_CACHE_TTL,\n checksum,\n force = false,\n name,\n spawnOptions,\n url,\n } = { __proto__: null, ...options } as DlxBinaryOptions\n\n // Generate cache paths similar to pnpm/npx structure.\n const cacheDir = getDlxCachePath()\n const binaryName = name || `binary-${process.platform}-${os.arch()}`\n // Create spec from URL and binary name for unique cache identity.\n const spec = `${url}:${binaryName}`\n const cacheKey = generateCacheKey(spec)\n const cacheEntryDir = path.join(cacheDir, cacheKey)\n const binaryPath = normalizePath(path.join(cacheEntryDir, binaryName))\n\n let downloaded = false\n let computedChecksum = checksum\n\n // Check if we need to download.\n if (\n !force &&\n existsSync(cacheEntryDir) &&\n (await isCacheValid(cacheEntryDir, cacheTtl))\n ) {\n // Binary is cached and valid, read the checksum from metadata.\n try {\n const metaPath = getMetadataPath(cacheEntryDir)\n const metadata = await readJson(metaPath, { throws: false })\n if (\n metadata &&\n typeof metadata === 'object' &&\n !Array.isArray(metadata) &&\n typeof (metadata as Record<string, unknown>)['checksum'] === 'string'\n ) {\n computedChecksum = (metadata as Record<string, unknown>)[\n 'checksum'\n ] as string\n } else {\n // If metadata is invalid, re-download.\n downloaded = true\n }\n } catch {\n // If we can't read metadata, re-download.\n downloaded = true\n }\n } else {\n downloaded = true\n }\n\n if (downloaded) {\n // Ensure cache directory exists.\n await fs.mkdir(cacheEntryDir, { recursive: true })\n\n // Download the binary.\n computedChecksum = await downloadBinaryFile(url, binaryPath, checksum)\n await writeMetadata(cacheEntryDir, url, computedChecksum || '')\n }\n\n // Execute the binary.\n // On Windows, script files (.bat, .cmd, .ps1) require shell: true because\n // they are not executable on their own and must be run through cmd.exe.\n // Note: .exe files are actual binaries and don't need shell mode.\n const needsShell = WIN32 && /\\.(?:bat|cmd|ps1)$/i.test(binaryPath)\n // Windows cmd.exe PATH resolution behavior:\n // When shell: true on Windows with .cmd/.bat/.ps1 files, spawn will automatically\n // strip the full path down to just the basename without extension (e.g.,\n // C:\\cache\\test.cmd becomes just \"test\"). Windows cmd.exe then searches for \"test\"\n // in directories listed in PATH, trying each extension from PATHEXT environment\n // variable (.COM, .EXE, .BAT, .CMD, etc.) until it finds a match.\n //\n // Since our binaries are downloaded to a custom cache directory that's not in PATH\n // (unlike system package managers like npm/pnpm/yarn which are already in PATH),\n // we must prepend the cache directory to PATH so cmd.exe can locate the binary.\n //\n // This approach is consistent with how other tools handle Windows command execution:\n // - npm's promise-spawn: uses which.sync() to find commands in PATH\n // - cross-spawn: spawns cmd.exe with escaped arguments\n // - Node.js spawn with shell: true: delegates to cmd.exe which uses PATH\n const finalSpawnOptions = needsShell\n ? {\n ...spawnOptions,\n env: {\n ...spawnOptions?.env,\n PATH: `${cacheEntryDir}${path.delimiter}${process.env['PATH'] || ''}`,\n },\n shell: true,\n }\n : spawnOptions\n const spawnPromise = spawn(binaryPath, args, finalSpawnOptions, spawnExtra)\n\n return {\n binaryPath,\n downloaded,\n spawnPromise,\n }\n}\n\n/**\n * Download a binary from a URL with caching (without execution).\n * Similar to downloadPackage from dlx-package.\n *\n * @returns Object containing the path to the cached binary and whether it was downloaded\n */\nexport async function downloadBinary(\n options: Omit<DlxBinaryOptions, 'spawnOptions'>,\n): Promise<{ binaryPath: string; downloaded: boolean }> {\n const {\n cacheTtl = /*@__INLINE__*/ require('#constants/time').DLX_BINARY_CACHE_TTL,\n checksum,\n force = false,\n name,\n url,\n } = { __proto__: null, ...options } as DlxBinaryOptions\n\n // Generate cache paths similar to pnpm/npx structure.\n const cacheDir = getDlxCachePath()\n const binaryName = name || `binary-${process.platform}-${os.arch()}`\n // Create spec from URL and binary name for unique cache identity.\n const spec = `${url}:${binaryName}`\n const cacheKey = generateCacheKey(spec)\n const cacheEntryDir = path.join(cacheDir, cacheKey)\n const binaryPath = normalizePath(path.join(cacheEntryDir, binaryName))\n\n let downloaded = false\n\n // Check if we need to download.\n if (\n !force &&\n existsSync(cacheEntryDir) &&\n (await isCacheValid(cacheEntryDir, cacheTtl))\n ) {\n // Binary is cached and valid.\n downloaded = false\n } else {\n // Ensure cache directory exists.\n await fs.mkdir(cacheEntryDir, { recursive: true })\n\n // Download the binary.\n const computedChecksum = await downloadBinaryFile(url, binaryPath, checksum)\n await writeMetadata(cacheEntryDir, url, computedChecksum || '')\n downloaded = true\n }\n\n return {\n binaryPath,\n downloaded,\n }\n}\n\n/**\n * Execute a cached binary without re-downloading.\n * Similar to executePackage from dlx-package.\n * Binary must have been previously downloaded via downloadBinary or dlxBinary.\n *\n * @param binaryPath Path to the cached binary (from downloadBinary result)\n * @param args Arguments to pass to the binary\n * @param spawnOptions Spawn options for execution\n * @param spawnExtra Extra spawn configuration\n * @returns The spawn promise for the running process\n */\nexport function executeBinary(\n binaryPath: string,\n args: readonly string[] | string[],\n spawnOptions?: SpawnOptions | undefined,\n spawnExtra?: SpawnExtra | undefined,\n): ReturnType<typeof spawn> {\n // On Windows, script files (.bat, .cmd, .ps1) require shell: true because\n // they are not executable on their own and must be run through cmd.exe.\n // Note: .exe files are actual binaries and don't need shell mode.\n const needsShell = WIN32 && /\\.(?:bat|cmd|ps1)$/i.test(binaryPath)\n\n // Windows cmd.exe PATH resolution behavior:\n // When shell: true on Windows with .cmd/.bat/.ps1 files, spawn will automatically\n // strip the full path down to just the basename without extension. Windows cmd.exe\n // then searches for the binary in directories listed in PATH.\n //\n // Since our binaries are downloaded to a custom cache directory that's not in PATH,\n // we must prepend the cache directory to PATH so cmd.exe can locate the binary.\n const cacheEntryDir = path.dirname(binaryPath)\n const finalSpawnOptions = needsShell\n ? {\n ...spawnOptions,\n env: {\n ...spawnOptions?.env,\n PATH: `${cacheEntryDir}${path.delimiter}${process.env['PATH'] || ''}`,\n },\n shell: true,\n }\n : spawnOptions\n\n return spawn(binaryPath, args, finalSpawnOptions, spawnExtra)\n}\n\n/**\n * Get the DLX binary cache directory path.\n * Returns normalized path for cross-platform compatibility.\n * Uses same directory as dlx-package for unified DLX storage.\n */\nexport function getDlxCachePath(): string {\n return getSocketDlxDir()\n}\n\n/**\n * Get information about cached binaries.\n */\nexport async function listDlxCache(): Promise<\n Array<{\n age: number\n arch: string\n checksum: string\n name: string\n platform: string\n size: number\n url: string\n }>\n> {\n const cacheDir = getDlxCachePath()\n\n if (!existsSync(cacheDir)) {\n return []\n }\n\n const results = []\n const now = Date.now()\n const entries = await fs.readdir(cacheDir)\n\n for (const entry of entries) {\n const entryPath = path.join(cacheDir, entry)\n try {\n // eslint-disable-next-line no-await-in-loop\n if (!(await isDir(entryPath))) {\n continue\n }\n\n const metaPath = getMetadataPath(entryPath)\n // eslint-disable-next-line no-await-in-loop\n const metadata = await readJson(metaPath, { throws: false })\n if (\n !metadata ||\n typeof metadata !== 'object' ||\n Array.isArray(metadata)\n ) {\n continue\n }\n\n // Find the binary file in the directory.\n // eslint-disable-next-line no-await-in-loop\n const files = await fs.readdir(entryPath)\n const binaryFile = files.find(f => !f.startsWith('.'))\n\n if (binaryFile) {\n const binaryPath = path.join(entryPath, binaryFile)\n // eslint-disable-next-line no-await-in-loop\n const binaryStats = await fs.stat(binaryPath)\n\n const metaObj = metadata as Record<string, unknown>\n results.push({\n age: now - ((metaObj['timestamp'] as number) || 0),\n arch: (metaObj['arch'] as string) || 'unknown',\n checksum: (metaObj['checksum'] as string) || '',\n name: binaryFile,\n platform: (metaObj['platform'] as string) || 'unknown',\n size: binaryStats.size,\n url: (metaObj['url'] as string) || '',\n })\n }\n } catch {}\n }\n\n return results\n}\n"],
5
- "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,cAAAC,EAAA,mBAAAC,EAAA,kBAAAC,EAAA,oBAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAR,GAEA,IAAAS,EAA2B,uBAC3BC,EAA2C,mB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C,cAAWmC,CAAQ,EACtB,MAAO,CAAC,EAGV,MAAMqB,EAAU,CAAC,EACXlC,EAAM,KAAK,IAAI,EACfe,EAAU,MAAM,EAAAR,SAAG,QAAQM,CAAQ,EAEzC,UAAWG,KAASD,EAAS,CAC3B,MAAME,EAAY,EAAAtB,QAAK,KAAKkB,EAAUG,CAAK,EAC3C,GAAI,CAEF,GAAI,CAAE,QAAM,SAAMC,CAAS,EACzB,SAGF,MAAMnB,EAAWL,EAAgBwB,CAAS,EAEpClB,EAAW,QAAM,YAASD,EAAU,CAAE,OAAQ,EAAM,CAAC,EAC3D,GACE,CAACC,GACD,OAAOA,GAAa,UACpB,MAAM,QAAQA,CAAQ,EAEtB,SAMF,MAAMoC,GADQ,MAAM,EAAA5B,SAAG,QAAQU,CAAS,GACf,KAAKmB,GAAK,CAACA,EAAE,WAAW,GAAG,CAAC,EAErD,GAAID,EAAY,CACd,MAAMP,EAAa,EAAAjC,QAAK,KAAKsB,EAAWkB,CAAU,EAE5CE,EAAc,MAAM,EAAA9B,SAAG,KAAKqB,CAAU,EAEtCU,EAAUvC,EAChBmC,EAAQ,KAAK,CACX,IAAKlC,GAAQsC,EAAQ,WAA2B,GAChD,KAAOA,EAAQ,MAAsB,UACrC,SAAWA,EAAQ,UAA0B,GAC7C,KAAMH,EACN,SAAWG,EAAQ,UAA0B,UAC7C,KAAMD,EAAY,KAClB,IAAMC,EAAQ,KAAqB,EACrC,CAAC,CACH,CACF,MAAQ,CAAC,CACX,CAEA,OAAOJ,CACT",
6
- "names": ["dlx_binary_exports", "__export", "cleanDlxCache", "dlxBinary", "downloadBinary", "executeBinary", "getDlxCachePath", "listDlxCache", "__toCommonJS", "import_node_crypto", "import_node_fs", "import_node_os", "import_node_path", "import_platform", "import_dlx", "import_download_lock", "import_fs", "import_objects", "import_path", "import_paths", "import_spawn", "getMetadataPath", "cacheEntryPath", "path", "isCacheValid", "cacheTtl", "metaPath", "metadata", "now", "timestamp", "downloadBinaryFile", "url", "destPath", "checksum", "fileBuffer", "fs", "hasher", "actualChecksum", "writeMetadata", "os", "maxAge", "cacheDir", "cleaned", "entries", "entry", "entryPath", "args", "options", "spawnExtra", "force", "name", "spawnOptions", "binaryName", "spec", "cacheKey", "cacheEntryDir", "binaryPath", "downloaded", "computedChecksum", "finalSpawnOptions", "spawnPromise", "needsShell", "results", "binaryFile", "f", "binaryStats", "metaObj"]
4
+ "sourcesContent": ["/** @fileoverview DLX binary execution utilities for Socket ecosystem. */\n\nimport { createHash } from 'node:crypto'\nimport { existsSync, promises as fs } from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport { WIN32 } from '#constants/platform'\n\nimport { generateCacheKey } from './dlx'\nimport { httpDownload } from './http-request'\nimport { isDir, readJson, safeDelete } from './fs'\nimport { isObjectObject } from './objects'\nimport { normalizePath } from './path'\nimport { getSocketDlxDir } from './paths'\nimport { processLock } from './process-lock'\nimport type { SpawnExtra, SpawnOptions } from './spawn'\nimport { spawn } from './spawn'\n\nexport interface DlxBinaryOptions {\n /** URL to download the binary from. */\n url: string\n /** Optional name for the cached binary (defaults to URL hash). */\n name?: string | undefined\n /** Expected checksum (sha256) for verification. */\n checksum?: string | undefined\n /** Cache TTL in milliseconds (default: 7 days). */\n cacheTtl?: number | undefined\n /** Force re-download even if cached. */\n force?: boolean | undefined\n /** Additional spawn options. */\n spawnOptions?: SpawnOptions | undefined\n}\n\nexport interface DlxBinaryResult {\n /** Path to the cached binary. */\n binaryPath: string\n /** Whether the binary was newly downloaded. */\n downloaded: boolean\n /** The spawn promise for the running process. */\n spawnPromise: ReturnType<typeof spawn>\n}\n\n/**\n * Get metadata file path for a cached binary.\n */\nfunction getMetadataPath(cacheEntryPath: string): string {\n return path.join(cacheEntryPath, '.dlx-metadata.json')\n}\n\n/**\n * Check if a cached binary is still valid.\n */\nasync function isCacheValid(\n cacheEntryPath: string,\n cacheTtl: number,\n): Promise<boolean> {\n try {\n const metaPath = getMetadataPath(cacheEntryPath)\n if (!existsSync(metaPath)) {\n return false\n }\n\n const metadata = await readJson(metaPath, { throws: false })\n if (!isObjectObject(metadata)) {\n return false\n }\n const now = Date.now()\n const timestamp = (metadata as Record<string, unknown>)['timestamp']\n // If timestamp is missing or invalid, cache is invalid\n if (typeof timestamp !== 'number' || timestamp <= 0) {\n return false\n }\n const age = now - timestamp\n\n return age < cacheTtl\n } catch {\n return false\n }\n}\n\n/**\n * Download a file from a URL with integrity checking and concurrent download protection.\n * Uses processLock to prevent multiple processes from downloading the same binary simultaneously.\n * Internal helper function for downloading binary files.\n */\nasync function downloadBinaryFile(\n url: string,\n destPath: string,\n checksum?: string | undefined,\n): Promise<string> {\n // Use process lock to prevent concurrent downloads.\n // Lock is placed in the cache entry directory as 'concurrency.lock'.\n const cacheEntryDir = path.dirname(destPath)\n const lockPath = path.join(cacheEntryDir, 'concurrency.lock')\n\n return await processLock.withLock(\n lockPath,\n async () => {\n // Check if file was downloaded while waiting for lock.\n if (existsSync(destPath)) {\n const stats = await fs.stat(destPath)\n if (stats.size > 0) {\n // File exists, compute and return checksum.\n const fileBuffer = await fs.readFile(destPath)\n const hasher = createHash('sha256')\n hasher.update(fileBuffer)\n return hasher.digest('hex')\n }\n }\n\n // Download the file.\n try {\n await httpDownload(url, destPath)\n } catch (e) {\n throw new Error(\n `Failed to download binary from ${url}\\n` +\n `Destination: ${destPath}\\n` +\n 'Check your internet connection or verify the URL is accessible.',\n { cause: e },\n )\n }\n\n // Compute checksum of downloaded file.\n const fileBuffer = await fs.readFile(destPath)\n const hasher = createHash('sha256')\n hasher.update(fileBuffer)\n const actualChecksum = hasher.digest('hex')\n\n // Verify checksum if provided.\n if (checksum && actualChecksum !== checksum) {\n // Clean up invalid file.\n await safeDelete(destPath)\n throw new Error(\n `Checksum mismatch: expected ${checksum}, got ${actualChecksum}`,\n )\n }\n\n // Make executable on POSIX systems.\n if (!WIN32) {\n await fs.chmod(destPath, 0o755)\n }\n\n return actualChecksum\n },\n {\n // Align with npm npx locking strategy.\n staleMs: 5000,\n touchIntervalMs: 2000,\n },\n )\n}\n\n/**\n * Write metadata for a cached binary.\n */\nasync function writeMetadata(\n cacheEntryPath: string,\n url: string,\n checksum: string,\n): Promise<void> {\n const metaPath = getMetadataPath(cacheEntryPath)\n const metadata = {\n arch: os.arch(),\n checksum,\n platform: os.platform(),\n timestamp: Date.now(),\n url,\n version: '1.0.0',\n }\n await fs.writeFile(metaPath, JSON.stringify(metadata, null, 2))\n}\n\n/**\n * Clean expired entries from the DLX cache.\n */\nexport async function cleanDlxCache(\n maxAge: number = /*@__INLINE__*/ require('#constants/time').DLX_BINARY_CACHE_TTL,\n): Promise<number> {\n const cacheDir = getDlxCachePath()\n\n if (!existsSync(cacheDir)) {\n return 0\n }\n\n let cleaned = 0\n const now = Date.now()\n const entries = await fs.readdir(cacheDir)\n\n for (const entry of entries) {\n const entryPath = path.join(cacheDir, entry)\n const metaPath = getMetadataPath(entryPath)\n\n try {\n // eslint-disable-next-line no-await-in-loop\n if (!(await isDir(entryPath))) {\n continue\n }\n\n // eslint-disable-next-line no-await-in-loop\n const metadata = await readJson(metaPath, { throws: false })\n if (\n !metadata ||\n typeof metadata !== 'object' ||\n Array.isArray(metadata)\n ) {\n continue\n }\n const timestamp = (metadata as Record<string, unknown>)['timestamp']\n // If timestamp is missing or invalid, treat as expired (age = infinity)\n const age =\n typeof timestamp === 'number' && timestamp > 0\n ? now - timestamp\n : Number.POSITIVE_INFINITY\n\n if (age > maxAge) {\n // Remove entire cache entry directory.\n // eslint-disable-next-line no-await-in-loop\n await safeDelete(entryPath, { force: true, recursive: true })\n cleaned += 1\n }\n } catch {\n // If we can't read metadata, check if directory is empty or corrupted.\n try {\n // eslint-disable-next-line no-await-in-loop\n const contents = await fs.readdir(entryPath)\n if (!contents.length) {\n // Remove empty directory.\n // eslint-disable-next-line no-await-in-loop\n await safeDelete(entryPath)\n cleaned += 1\n }\n } catch {}\n }\n }\n\n return cleaned\n}\n\n/**\n * Download and execute a binary from a URL with caching.\n */\nexport async function dlxBinary(\n args: readonly string[] | string[],\n options?: DlxBinaryOptions | undefined,\n spawnExtra?: SpawnExtra | undefined,\n): Promise<DlxBinaryResult> {\n const {\n cacheTtl = /*@__INLINE__*/ require('#constants/time').DLX_BINARY_CACHE_TTL,\n checksum,\n force = false,\n name,\n spawnOptions,\n url,\n } = { __proto__: null, ...options } as DlxBinaryOptions\n\n // Generate cache paths similar to pnpm/npx structure.\n const cacheDir = getDlxCachePath()\n const binaryName = name || `binary-${process.platform}-${os.arch()}`\n // Create spec from URL and binary name for unique cache identity.\n const spec = `${url}:${binaryName}`\n const cacheKey = generateCacheKey(spec)\n const cacheEntryDir = path.join(cacheDir, cacheKey)\n const binaryPath = normalizePath(path.join(cacheEntryDir, binaryName))\n\n let downloaded = false\n let computedChecksum = checksum\n\n // Check if we need to download.\n if (\n !force &&\n existsSync(cacheEntryDir) &&\n (await isCacheValid(cacheEntryDir, cacheTtl))\n ) {\n // Binary is cached and valid, read the checksum from metadata.\n try {\n const metaPath = getMetadataPath(cacheEntryDir)\n const metadata = await readJson(metaPath, { throws: false })\n if (\n metadata &&\n typeof metadata === 'object' &&\n !Array.isArray(metadata) &&\n typeof (metadata as Record<string, unknown>)['checksum'] === 'string'\n ) {\n computedChecksum = (metadata as Record<string, unknown>)[\n 'checksum'\n ] as string\n } else {\n // If metadata is invalid, re-download.\n downloaded = true\n }\n } catch {\n // If we can't read metadata, re-download.\n downloaded = true\n }\n } else {\n downloaded = true\n }\n\n if (downloaded) {\n // Ensure cache directory exists before downloading.\n try {\n await fs.mkdir(cacheEntryDir, { recursive: true })\n } catch (e) {\n const code = (e as NodeJS.ErrnoException).code\n if (code === 'EACCES' || code === 'EPERM') {\n throw new Error(\n `Permission denied creating binary cache directory: ${cacheEntryDir}\\n` +\n 'Please check directory permissions or run with appropriate access.',\n { cause: e },\n )\n }\n if (code === 'EROFS') {\n throw new Error(\n `Cannot create binary cache directory on read-only filesystem: ${cacheEntryDir}\\n` +\n 'Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.',\n { cause: e },\n )\n }\n throw new Error(\n `Failed to create binary cache directory: ${cacheEntryDir}`,\n { cause: e },\n )\n }\n\n // Download the binary.\n computedChecksum = await downloadBinaryFile(url, binaryPath, checksum)\n await writeMetadata(cacheEntryDir, url, computedChecksum || '')\n }\n\n // Execute the binary.\n // On Windows, script files (.bat, .cmd, .ps1) require shell: true because\n // they are not executable on their own and must be run through cmd.exe.\n // Note: .exe files are actual binaries and don't need shell mode.\n const needsShell = WIN32 && /\\.(?:bat|cmd|ps1)$/i.test(binaryPath)\n // Windows cmd.exe PATH resolution behavior:\n // When shell: true on Windows with .cmd/.bat/.ps1 files, spawn will automatically\n // strip the full path down to just the basename without extension (e.g.,\n // C:\\cache\\test.cmd becomes just \"test\"). Windows cmd.exe then searches for \"test\"\n // in directories listed in PATH, trying each extension from PATHEXT environment\n // variable (.COM, .EXE, .BAT, .CMD, etc.) until it finds a match.\n //\n // Since our binaries are downloaded to a custom cache directory that's not in PATH\n // (unlike system package managers like npm/pnpm/yarn which are already in PATH),\n // we must prepend the cache directory to PATH so cmd.exe can locate the binary.\n //\n // This approach is consistent with how other tools handle Windows command execution:\n // - npm's promise-spawn: uses which.sync() to find commands in PATH\n // - cross-spawn: spawns cmd.exe with escaped arguments\n // - Node.js spawn with shell: true: delegates to cmd.exe which uses PATH\n const finalSpawnOptions = needsShell\n ? {\n ...spawnOptions,\n env: {\n ...spawnOptions?.env,\n PATH: `${cacheEntryDir}${path.delimiter}${process.env['PATH'] || ''}`,\n },\n shell: true,\n }\n : spawnOptions\n const spawnPromise = spawn(binaryPath, args, finalSpawnOptions, spawnExtra)\n\n return {\n binaryPath,\n downloaded,\n spawnPromise,\n }\n}\n\n/**\n * Download a binary from a URL with caching (without execution).\n * Similar to downloadPackage from dlx-package.\n *\n * @returns Object containing the path to the cached binary and whether it was downloaded\n */\nexport async function downloadBinary(\n options: Omit<DlxBinaryOptions, 'spawnOptions'>,\n): Promise<{ binaryPath: string; downloaded: boolean }> {\n const {\n cacheTtl = /*@__INLINE__*/ require('#constants/time').DLX_BINARY_CACHE_TTL,\n checksum,\n force = false,\n name,\n url,\n } = { __proto__: null, ...options } as DlxBinaryOptions\n\n // Generate cache paths similar to pnpm/npx structure.\n const cacheDir = getDlxCachePath()\n const binaryName = name || `binary-${process.platform}-${os.arch()}`\n // Create spec from URL and binary name for unique cache identity.\n const spec = `${url}:${binaryName}`\n const cacheKey = generateCacheKey(spec)\n const cacheEntryDir = path.join(cacheDir, cacheKey)\n const binaryPath = normalizePath(path.join(cacheEntryDir, binaryName))\n\n let downloaded = false\n\n // Check if we need to download.\n if (\n !force &&\n existsSync(cacheEntryDir) &&\n (await isCacheValid(cacheEntryDir, cacheTtl))\n ) {\n // Binary is cached and valid.\n downloaded = false\n } else {\n // Ensure cache directory exists before downloading.\n try {\n await fs.mkdir(cacheEntryDir, { recursive: true })\n } catch (e) {\n const code = (e as NodeJS.ErrnoException).code\n if (code === 'EACCES' || code === 'EPERM') {\n throw new Error(\n `Permission denied creating binary cache directory: ${cacheEntryDir}\\n` +\n 'Please check directory permissions or run with appropriate access.',\n { cause: e },\n )\n }\n if (code === 'EROFS') {\n throw new Error(\n `Cannot create binary cache directory on read-only filesystem: ${cacheEntryDir}\\n` +\n 'Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.',\n { cause: e },\n )\n }\n throw new Error(\n `Failed to create binary cache directory: ${cacheEntryDir}`,\n { cause: e },\n )\n }\n\n // Download the binary.\n const computedChecksum = await downloadBinaryFile(url, binaryPath, checksum)\n await writeMetadata(cacheEntryDir, url, computedChecksum || '')\n downloaded = true\n }\n\n return {\n binaryPath,\n downloaded,\n }\n}\n\n/**\n * Execute a cached binary without re-downloading.\n * Similar to executePackage from dlx-package.\n * Binary must have been previously downloaded via downloadBinary or dlxBinary.\n *\n * @param binaryPath Path to the cached binary (from downloadBinary result)\n * @param args Arguments to pass to the binary\n * @param spawnOptions Spawn options for execution\n * @param spawnExtra Extra spawn configuration\n * @returns The spawn promise for the running process\n */\nexport function executeBinary(\n binaryPath: string,\n args: readonly string[] | string[],\n spawnOptions?: SpawnOptions | undefined,\n spawnExtra?: SpawnExtra | undefined,\n): ReturnType<typeof spawn> {\n // On Windows, script files (.bat, .cmd, .ps1) require shell: true because\n // they are not executable on their own and must be run through cmd.exe.\n // Note: .exe files are actual binaries and don't need shell mode.\n const needsShell = WIN32 && /\\.(?:bat|cmd|ps1)$/i.test(binaryPath)\n\n // Windows cmd.exe PATH resolution behavior:\n // When shell: true on Windows with .cmd/.bat/.ps1 files, spawn will automatically\n // strip the full path down to just the basename without extension. Windows cmd.exe\n // then searches for the binary in directories listed in PATH.\n //\n // Since our binaries are downloaded to a custom cache directory that's not in PATH,\n // we must prepend the cache directory to PATH so cmd.exe can locate the binary.\n const cacheEntryDir = path.dirname(binaryPath)\n const finalSpawnOptions = needsShell\n ? {\n ...spawnOptions,\n env: {\n ...spawnOptions?.env,\n PATH: `${cacheEntryDir}${path.delimiter}${process.env['PATH'] || ''}`,\n },\n shell: true,\n }\n : spawnOptions\n\n return spawn(binaryPath, args, finalSpawnOptions, spawnExtra)\n}\n\n/**\n * Get the DLX binary cache directory path.\n * Returns normalized path for cross-platform compatibility.\n * Uses same directory as dlx-package for unified DLX storage.\n */\nexport function getDlxCachePath(): string {\n return getSocketDlxDir()\n}\n\n/**\n * Get information about cached binaries.\n */\nexport async function listDlxCache(): Promise<\n Array<{\n age: number\n arch: string\n checksum: string\n name: string\n platform: string\n size: number\n url: string\n }>\n> {\n const cacheDir = getDlxCachePath()\n\n if (!existsSync(cacheDir)) {\n return []\n }\n\n const results = []\n const now = Date.now()\n const entries = await fs.readdir(cacheDir)\n\n for (const entry of entries) {\n const entryPath = path.join(cacheDir, entry)\n try {\n // eslint-disable-next-line no-await-in-loop\n if (!(await isDir(entryPath))) {\n continue\n }\n\n const metaPath = getMetadataPath(entryPath)\n // eslint-disable-next-line no-await-in-loop\n const metadata = await readJson(metaPath, { throws: false })\n if (\n !metadata ||\n typeof metadata !== 'object' ||\n Array.isArray(metadata)\n ) {\n continue\n }\n\n // Find the binary file in the directory.\n // eslint-disable-next-line no-await-in-loop\n const files = await fs.readdir(entryPath)\n const binaryFile = files.find(f => !f.startsWith('.'))\n\n if (binaryFile) {\n const binaryPath = path.join(entryPath, binaryFile)\n // eslint-disable-next-line no-await-in-loop\n const binaryStats = await fs.stat(binaryPath)\n\n const metaObj = metadata as Record<string, unknown>\n results.push({\n age: now - ((metaObj['timestamp'] as number) || 0),\n arch: (metaObj['arch'] as string) || 'unknown',\n checksum: (metaObj['checksum'] as string) || '',\n name: binaryFile,\n platform: (metaObj['platform'] as string) || 'unknown',\n size: binaryStats.size,\n url: (metaObj['url'] as string) || '',\n })\n }\n } catch {}\n }\n\n return results\n}\n"],
5
+ "mappings": ";6iBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,mBAAAE,EAAA,cAAAC,EAAA,mBAAAC,EAAA,kBAAAC,EAAA,oBAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAR,IAEA,IAAAS,EAA2B,uBAC3BC,EAA2C,mBAC3CC,EAAe,sBACfC,EAAiB,wBAEjBC,EAAsB,+BAEtBC,EAAiC,iBACjCC,EAA6B,0BAC7BC,EAA4C,gBAC5CC,EAA+B,qBAC/BC,EAA8B,kBAC9BC,EAAgC,mBAChCC,EAA4B,0BAE5BC,EAAsB,mBA6BtB,SAASC,EAAgBC,EAAgC,CACvD,OAAO,EAAAC,QAAK,KAAKD,EAAgB,oBAAoB,CACvD,CAKA,eAAeE,EACbF,EACAG,EACkB,CAClB,GAAI,CACF,MAAMC,EAAWL,EAAgBC,CAAc,EAC/C,GAAI,IAAC,cAAWI,CAAQ,EACtB,MAAO,GAGT,MAAMC,EAAW,QAAM,YAASD,EAAU,CAAE,OAAQ,EAAM,CAAC,EAC3D,GAAI,IAAC,kBAAeC,CAAQ,EAC1B,MAAO,GAET,MAAMC,EAAM,KAAK,IAAI,EACfC,EAAaF,EAAqC,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KyB,EAAWkB,CAAU,EAE5CE,EAAc,MAAM,EAAAhC,SAAG,KAAKsB,CAAU,EAEtCW,EAAU1C,EAChBsC,EAAQ,KAAK,CACX,IAAKrC,GAAQyC,EAAQ,WAA2B,GAChD,KAAOA,EAAQ,MAAsB,UACrC,SAAWA,EAAQ,UAA0B,GAC7C,KAAMH,EACN,SAAWG,EAAQ,UAA0B,UAC7C,KAAMD,EAAY,KAClB,IAAMC,EAAQ,KAAqB,EACrC,CAAC,CACH,CACF,MAAQ,CAAC,CACX,CAEA,OAAOJ,CACT",
6
+ "names": ["dlx_binary_exports", "__export", "cleanDlxCache", "dlxBinary", "downloadBinary", "executeBinary", "getDlxCachePath", "listDlxCache", "__toCommonJS", "import_node_crypto", "import_node_fs", "import_node_os", "import_node_path", "import_platform", "import_dlx", "import_http_request", "import_fs", "import_objects", "import_path", "import_paths", "import_process_lock", "import_spawn", "getMetadataPath", "cacheEntryPath", "path", "isCacheValid", "cacheTtl", "metaPath", "metadata", "now", "timestamp", "downloadBinaryFile", "url", "destPath", "checksum", "cacheEntryDir", "lockPath", "fs", "fileBuffer", "hasher", "e", "actualChecksum", "writeMetadata", "os", "maxAge", "cacheDir", "cleaned", "entries", "entry", "entryPath", "args", "options", "spawnExtra", "force", "name", "spawnOptions", "binaryName", "spec", "cacheKey", "binaryPath", "downloaded", "computedChecksum", "code", "finalSpawnOptions", "spawnPromise", "needsShell", "results", "binaryFile", "f", "binaryStats", "metaObj"]
7
7
  }
@@ -1,3 +1,10 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var v=Object.create;var d=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)d(n,t,{get:e[t],enumerable:!0})},m=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of E(e))!J.call(n,a)&&a!==t&&d(n,a,{get:()=>e[a],enumerable:!(o=_(e,a))||o.enumerable});return n};var k=(n,e,t)=>(t=n!=null?v(I(n)):{},m(e||!n||!n.__esModule?d(t,"default",{value:n,enumerable:!0}):t,n)),N=n=>m(d({},"__esModule",{value:!0}),n);var T={};$(T,{dlxPackage:()=>M,downloadPackage:()=>j,executePackage:()=>O});module.exports=N(T);var p=require("node:fs"),i=k(require("node:path")),P=require("./constants/platform"),h=require("./constants/packages"),w=require("./dlx"),y=k(require("./external/pacote")),x=require("./fs"),g=require("./path"),D=require("./paths"),b=require("./process-lock"),S=require("./spawn");const C=/[~^><=xX* ]|\|\|/;function A(n){if(n.startsWith("@")){const t=n.split("@");return t.length===3?{name:t[1],version:t[2]}:t.length===2?{name:`@${t[1]}`,version:void 0}:{name:`@${t[1]}`,version:t[2]}}const e=n.lastIndexOf("@");return e===-1?{name:n,version:void 0}:{name:n.slice(0,e),version:n.slice(e+1)}}async function K(n,e,t){const o=(0,w.generateCacheKey)(e),a=(0,g.normalizePath)(i.default.join((0,D.getSocketDlxDir)(),o)),c=(0,g.normalizePath)(i.default.join(a,"node_modules",n)),r=i.default.join(a,".lock");return await b.processLock.withLock(r,async()=>{if(!t&&(0,p.existsSync)(c)){const l=i.default.join(c,"package.json");if((0,p.existsSync)(l))return{installed:!1,packageDir:a}}await p.promises.mkdir(a,{recursive:!0});const s=(0,h.getPacoteCachePath)();return await y.default.extract(e,c,{cache:s||i.default.join(a,".cache")}),{installed:!0,packageDir:a}},{staleMs:5e3,touchIntervalMs:2e3})}function L(n,e,t){const o=(0,g.normalizePath)(i.default.join(n,"node_modules",e)),a=i.default.join(o,"package.json"),r=(0,x.readJsonSync)(a).bin;let s;if(typeof r=="string")s=r;else if(typeof r=="object"&&r!==null){const l=t||e.split("/").pop();s=r[l]}if(!s)throw new Error(`No binary found for package "${e}"`);return(0,g.normalizePath)(i.default.join(o,s))}async function M(n,e,t){const o=await j(e),a=O(o.binaryPath,n,e?.spawnOptions,t);return{...o,spawnPromise:a}}async function j(n){const{force:e,package:t}={__proto__:null,...n},{name:o,version:a}=A(t),c=a!==void 0&&C.test(a),r=e!==void 0?e:c,s=a?`${o}@${a}`:o,{installed:l,packageDir:u}=await K(o,s,r),f=L(u,o);if(!P.WIN32&&(0,p.existsSync)(f)){const{chmodSync:R}=require("node:fs");try{R(f,493)}catch{}}return{binaryPath:f,installed:l,packageDir:u}}function O(n,e,t,o){return(0,S.spawn)(n,e,t,o)}0&&(module.exports={dlxPackage,downloadPackage,executePackage});
2
+ var S=Object.create;var f=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var _=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},m=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of j(n))!I.call(e,r)&&r!==t&&f(e,r,{get:()=>n[r],enumerable:!(o=$(n,r))||o.enumerable});return e};var w=(e,n,t)=>(t=e!=null?S(C(e)):{},m(n||!e||!e.__esModule?f(t,"default",{value:e,enumerable:!0}):t,e)),N=e=>m(f({},"__esModule",{value:!0}),e);var V={};_(V,{dlxPackage:()=>M,downloadPackage:()=>O,executePackage:()=>R});module.exports=N(V);var d=require("node:fs"),c=w(require("node:path")),h=require("./constants/platform"),k=require("./constants/packages"),y=require("./dlx"),P=w(require("./external/pacote")),E=require("./fs"),g=require("./path"),x=require("./paths"),D=require("./process-lock"),b=require("./spawn");const T=/[~^><=xX* ]|\|\|/;function A(e){if(e.startsWith("@")){const t=e.split("@");return t.length===3?{name:t[1],version:t[2]}:t.length===2?{name:`@${t[1]}`,version:void 0}:{name:`@${t[1]}`,version:t[2]}}const n=e.lastIndexOf("@");return n===-1?{name:e,version:void 0}:{name:e.slice(0,n),version:e.slice(n+1)}}async function J(e,n,t){const o=(0,y.generateCacheKey)(n),r=(0,g.normalizePath)(c.default.join((0,x.getSocketDlxDir)(),o)),l=(0,g.normalizePath)(c.default.join(r,"node_modules",e));try{await d.promises.mkdir(r,{recursive:!0})}catch(i){const a=i.code;throw a==="EACCES"||a==="EPERM"?new Error(`Permission denied creating package directory: ${r}
3
+ Please check directory permissions or run with appropriate access.`,{cause:i}):a==="EROFS"?new Error(`Cannot create package directory on read-only filesystem: ${r}
4
+ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`,{cause:i}):new Error(`Failed to create package directory: ${r}`,{cause:i})}const s=c.default.join(r,"concurrency.lock");return await D.processLock.withLock(s,async()=>{if(!t&&(0,d.existsSync)(l)){const a=c.default.join(l,"package.json");if((0,d.existsSync)(a))return{installed:!1,packageDir:r}}const i=(0,k.getPacoteCachePath)();try{await P.default.extract(n,l,{cache:i||c.default.join(r,".cache")})}catch(a){const p=a.code;throw p==="E404"||p==="ETARGET"?new Error(`Package not found: ${n}
5
+ Verify the package exists on npm registry and check the version.
6
+ Visit https://www.npmjs.com/package/${e} to see available versions.`,{cause:a}):p==="ENOTFOUND"||p==="ETIMEDOUT"||p==="EAI_AGAIN"?new Error(`Network error installing ${n}
7
+ Check your internet connection and try again.`,{cause:a}):new Error(`Failed to install package: ${n}
8
+ Destination: ${l}
9
+ Check npm registry connectivity or package name.`,{cause:a})}return{installed:!0,packageDir:r}},{staleMs:5e3,touchIntervalMs:2e3})}function F(e,n,t){const o=(0,g.normalizePath)(c.default.join(e,"node_modules",n)),r=c.default.join(o,"package.json"),s=(0,E.readJsonSync)(r).bin;let i;if(typeof s=="string")i=s;else if(typeof s=="object"&&s!==null){const a=t||n.split("/").pop();i=s[a]}if(!i)throw new Error(`No binary found for package "${n}"`);return(0,g.normalizePath)(c.default.join(o,i))}async function M(e,n,t){const o=await O(n),r=R(o.binaryPath,e,n?.spawnOptions,t);return{...o,spawnPromise:r}}async function O(e){const{force:n,package:t}={__proto__:null,...e},{name:o,version:r}=A(t),l=r!==void 0&&T.test(r),s=n!==void 0?n:l,i=r?`${o}@${r}`:o,{installed:a,packageDir:p}=await J(o,i,s),u=F(p,o);if(!h.WIN32&&(0,d.existsSync)(u)){const{chmodSync:v}=require("node:fs");try{v(u,493)}catch{}}return{binaryPath:u,installed:a,packageDir:p}}function R(e,n,t,o){return(0,b.spawn)(e,n,t,o)}0&&(module.exports={dlxPackage,downloadPackage,executePackage});
3
10
  //# sourceMappingURL=dlx-package.js.map