mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 00:22:34 +00:00
fix: use aarch64 for CLIProxy arm assets
Preserve contributor commits and add maintainer compatibility coverage.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Platform Detector for CLIProxyAPI Binary Downloads
|
||||
*
|
||||
* 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 {
|
||||
@@ -75,9 +75,13 @@ const OS_MAP: Record<string, SupportedOS | undefined> = {
|
||||
|
||||
const ARCH_MAP: Record<string, SupportedArch | undefined> = {
|
||||
x64: 'amd64',
|
||||
arm64: 'arm64',
|
||||
arm64: 'aarch64',
|
||||
};
|
||||
|
||||
export function mapNodeArchToReleaseArch(nodeArch: string): SupportedArch | undefined {
|
||||
return ARCH_MAP[nodeArch];
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect current platform and return binary info
|
||||
* @param version Optional version for binaryName (defaults to backend fallback)
|
||||
@@ -92,7 +96,7 @@ export function detectPlatform(
|
||||
const nodeArch = process.arch;
|
||||
|
||||
const os = OS_MAP[nodePlatform];
|
||||
const arch = ARCH_MAP[nodeArch];
|
||||
const arch = mapNodeArchToReleaseArch(nodeArch);
|
||||
|
||||
if (!os) {
|
||||
throw new Error(
|
||||
@@ -103,7 +107,7 @@ export function detectPlatform(
|
||||
|
||||
if (!arch) {
|
||||
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
|
||||
* @returns Description string (e.g., "macOS arm64")
|
||||
* @returns Description string (e.g., "macOS ARM64")
|
||||
*/
|
||||
export function getPlatformDescription(): string {
|
||||
try {
|
||||
const platform = detectPlatform();
|
||||
const osName =
|
||||
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 {
|
||||
return `${process.platform} ${process.arch} (unsupported)`;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ describe('Backend Selection', () => {
|
||||
});
|
||||
|
||||
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', () => {
|
||||
const info = platformDetector.detectPlatform('6.6.51', 'original');
|
||||
assert(info.binaryName.startsWith('CLIProxyAPI_6.6.51_'));
|
||||
|
||||
@@ -34,7 +34,8 @@ import { PLUS_ONLY_PROVIDERS } from '../../types';
|
||||
describe('types.ts backward compatibility', () => {
|
||||
it('exports all platform types', () => {
|
||||
const os: SupportedOS = 'darwin';
|
||||
const arch: SupportedArch = 'arm64';
|
||||
const arch: SupportedArch = 'aarch64';
|
||||
const nodeArch: SupportedArch = 'arm64';
|
||||
const ext: ArchiveExtension = 'tar.gz';
|
||||
const info: PlatformInfo = {
|
||||
os,
|
||||
@@ -43,7 +44,8 @@ describe('types.ts backward compatibility', () => {
|
||||
extension: ext,
|
||||
};
|
||||
expect(info.os).toBe('darwin');
|
||||
expect(info.arch).toBe('arm64');
|
||||
expect(info.arch).toBe('aarch64');
|
||||
expect(nodeArch).toBe('arm64');
|
||||
});
|
||||
|
||||
it('exports all binary types', () => {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
/** Supported operating systems */
|
||||
export type SupportedOS = 'darwin' | 'linux' | 'windows';
|
||||
|
||||
/** Supported CPU architectures */
|
||||
export type SupportedArch = 'amd64' | 'arm64';
|
||||
/** Supported CPU architecture labels from Node.js and CLIProxy release assets */
|
||||
export type SupportedArch = 'amd64' | 'arm64' | 'aarch64';
|
||||
|
||||
/** Archive extension based on platform */
|
||||
export type ArchiveExtension = 'tar.gz' | 'zip';
|
||||
|
||||
Reference in New Issue
Block a user