()
| 26 | export type Channel = 'stable' | 'latest' | string; // string = exact version tag |
| 27 | |
| 28 | async function detectPlatform(): Promise<string> { |
| 29 | const os = process.platform; |
| 30 | const arch = process.arch; |
| 31 | |
| 32 | const osMap: Record<string, string> = { darwin: 'darwin', linux: 'linux' }; |
| 33 | const archMap: Record<string, string> = { x64: 'x64', arm64: 'arm64' }; |
| 34 | |
| 35 | const mappedOs = osMap[os]; |
| 36 | const mappedArch = archMap[arch]; |
| 37 | |
| 38 | if (!mappedOs || !mappedArch) { |
| 39 | throw new CLIError(`Unsupported platform: ${os}/${arch}`, ExitCode.GENERAL); |
| 40 | } |
| 41 | |
| 42 | // Detect musl on Linux |
| 43 | if (mappedOs === 'linux') { |
| 44 | try { |
| 45 | const { execSync } = await import('child_process'); |
| 46 | const ldd = execSync('ldd /bin/ls 2>&1', { encoding: 'utf-8' }); |
| 47 | if (ldd.includes('musl')) return `linux-${mappedArch}-musl`; |
| 48 | } catch { /* non-fatal */ } |
| 49 | } |
| 50 | |
| 51 | return `${mappedOs}-${mappedArch}`; |
| 52 | } |
| 53 | |
| 54 | async function ghFetch(path: string): Promise<Response> { |
| 55 | const headers: Record<string, string> = { |
no outgoing calls
no test coverage detected