fix: use aarch64 for CLIProxy arm assets

Preserve contributor commits and add maintainer compatibility coverage.
This commit is contained in:
Kai (Tam Nhu) Tran authored and GitHub committed 2026-05-04 10:55:52 -04:00
commit 190e820f99
4 files changed
+22 -10

No files matched your search

+11 -6
View File
@@ -2,7 +2,7 @@
* Platform Detector for CLIProxyAPI Binary Downloads * Platform Detector for CLIProxyAPI Binary Downloads
* *
* Detects OS and architecture to determine correct binary asset. * Detects OS and architecture to determine correct binary asset.
* Supports 6 platforms: darwin/linux/windows x amd64/arm64 * Supports 6 platforms: darwin/linux/windows x amd64/aarch64
*/ */
import { import {
@@ -75,9 +75,13 @@ const OS_MAP: Record<string, SupportedOS | undefined> = {
const ARCH_MAP: Record<string, SupportedArch | undefined> = { const ARCH_MAP: Record<string, SupportedArch | undefined> = {
x64: 'amd64', x64: 'amd64',
arm64: 'arm64', arm64: 'aarch64',
}; };
export function mapNodeArchToReleaseArch(nodeArch: string): SupportedArch | undefined {
return ARCH_MAP[nodeArch];
}
/** /**
* Detect current platform and return binary info * Detect current platform and return binary info
* @param version Optional version for binaryName (defaults to backend fallback) * @param version Optional version for binaryName (defaults to backend fallback)
@@ -92,7 +96,7 @@ export function detectPlatform(
const nodeArch = process.arch; const nodeArch = process.arch;
const os = OS_MAP[nodePlatform]; const os = OS_MAP[nodePlatform];
const arch = ARCH_MAP[nodeArch]; const arch = mapNodeArchToReleaseArch(nodeArch);
if (!os) { if (!os) {
throw new Error( throw new Error(
@@ -103,7 +107,7 @@ export function detectPlatform(
if (!arch) { if (!arch) {
throw new Error( throw new Error(
`Unsupported CPU architecture: ${nodeArch}\n` + `Supported: x64 (amd64), arm64` `Unsupported CPU architecture: ${nodeArch}\n` + `Supported: x64 (amd64), arm64 (aarch64)`
); );
} }
@@ -195,14 +199,15 @@ export function isPlatformSupported(): boolean {
/** /**
* Get human-readable platform description * Get human-readable platform description
* @returns Description string (e.g., "macOS arm64") * @returns Description string (e.g., "macOS ARM64")
*/ */
export function getPlatformDescription(): string { export function getPlatformDescription(): string {
try { try {
const platform = detectPlatform(); const platform = detectPlatform();
const osName = const osName =
platform.os === 'darwin' ? 'macOS' : platform.os === 'linux' ? 'Linux' : 'Windows'; platform.os === 'darwin' ? 'macOS' : platform.os === 'linux' ? 'Linux' : 'Windows';
return `${osName} ${platform.arch}`; const archName = platform.arch === 'aarch64' ? 'ARM64' : platform.arch;
return `${osName} ${archName}`;
} catch { } catch {
return `${process.platform} ${process.arch} (unsupported)`; return `${process.platform} ${process.arch} (unsupported)`;
} }
@@ -34,6 +34,11 @@ describe('Backend Selection', () => {
}); });
describe('detectPlatform', () => { describe('detectPlatform', () => {
it('maps Node arm64 to CLIProxy aarch64 release assets', () => {
assert.strictEqual(platformDetector.mapNodeArchToReleaseArch('arm64'), 'aarch64');
assert.strictEqual(platformDetector.mapNodeArchToReleaseArch('x64'), 'amd64');
});
it('generates correct binary name for original backend', () => { it('generates correct binary name for original backend', () => {
const info = platformDetector.detectPlatform('6.6.51', 'original'); const info = platformDetector.detectPlatform('6.6.51', 'original');
assert(info.binaryName.startsWith('CLIProxyAPI_6.6.51_')); assert(info.binaryName.startsWith('CLIProxyAPI_6.6.51_'));
@@ -34,7 +34,8 @@ import { PLUS_ONLY_PROVIDERS } from '../../types';
describe('types.ts backward compatibility', () => { describe('types.ts backward compatibility', () => {
it('exports all platform types', () => { it('exports all platform types', () => {
const os: SupportedOS = 'darwin'; const os: SupportedOS = 'darwin';
const arch: SupportedArch = 'arm64'; const arch: SupportedArch = 'aarch64';
const nodeArch: SupportedArch = 'arm64';
const ext: ArchiveExtension = 'tar.gz'; const ext: ArchiveExtension = 'tar.gz';
const info: PlatformInfo = { const info: PlatformInfo = {
os, os,
@@ -43,7 +44,8 @@ describe('types.ts backward compatibility', () => {
extension: ext, extension: ext,
}; };
expect(info.os).toBe('darwin'); expect(info.os).toBe('darwin');
expect(info.arch).toBe('arm64'); expect(info.arch).toBe('aarch64');
expect(nodeArch).toBe('arm64');
}); });
it('exports all binary types', () => { it('exports all binary types', () => {
+2 -2
View File
@@ -5,8 +5,8 @@
/** Supported operating systems */ /** Supported operating systems */
export type SupportedOS = 'darwin' | 'linux' | 'windows'; export type SupportedOS = 'darwin' | 'linux' | 'windows';
/** Supported CPU architectures */ /** Supported CPU architecture labels from Node.js and CLIProxy release assets */
export type SupportedArch = 'amd64' | 'arm64'; export type SupportedArch = 'amd64' | 'arm64' | 'aarch64';
/** Archive extension based on platform */ /** Archive extension based on platform */
export type ArchiveExtension = 'tar.gz' | 'zip'; export type ArchiveExtension = 'tar.gz' | 'zip';