mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 00:22:34 +00:00
fix: preserve arm64 compatibility for CLIProxy assets
This commit is contained in:
@@ -78,6 +78,10 @@ const ARCH_MAP: Record<string, SupportedArch | undefined> = {
|
||||
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(
|
||||
@@ -195,14 +199,15 @@ export function isPlatformSupported(): boolean {
|
||||
|
||||
/**
|
||||
* Get human-readable platform description
|
||||
* @returns Description string (e.g., "macOS aarch64")
|
||||
* @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_'));
|
||||
|
||||
@@ -524,8 +524,9 @@ export async function preflightCheck(provider: CLIProxyProvider): Promise<Prefli
|
||||
return { proceed: true, accountId: defaultAccount?.id || '' };
|
||||
}
|
||||
|
||||
const { pauseAccountForQuotaCooldown, restoreExpiredQuotaPauses } =
|
||||
await import('../accounts/account-safety');
|
||||
const { pauseAccountForQuotaCooldown, restoreExpiredQuotaPauses } = await import(
|
||||
'../accounts/account-safety'
|
||||
);
|
||||
restoreExpiredQuotaPauses();
|
||||
|
||||
const config = loadOrCreateUnifiedConfig();
|
||||
|
||||
@@ -35,6 +35,7 @@ describe('types.ts backward compatibility', () => {
|
||||
it('exports all platform types', () => {
|
||||
const os: SupportedOS = 'darwin';
|
||||
const arch: SupportedArch = 'aarch64';
|
||||
const nodeArch: SupportedArch = 'arm64';
|
||||
const ext: ArchiveExtension = 'tar.gz';
|
||||
const info: PlatformInfo = {
|
||||
os,
|
||||
@@ -44,6 +45,7 @@ describe('types.ts backward compatibility', () => {
|
||||
};
|
||||
expect(info.os).toBe('darwin');
|
||||
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' | 'aarch64';
|
||||
/** 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';
|
||||
|
||||
@@ -112,8 +112,9 @@ export async function runImageAnalysisCheck(results: HealthCheck): Promise<void>
|
||||
* Fix image analysis configuration issues
|
||||
*/
|
||||
export async function fixImageAnalysisConfig(): Promise<boolean> {
|
||||
const { updateConfig, loadOrCreateUnifiedConfig } =
|
||||
await import('../../config/config-loader-facade');
|
||||
const { updateConfig, loadOrCreateUnifiedConfig } = await import(
|
||||
'../../config/config-loader-facade'
|
||||
);
|
||||
|
||||
const config = loadOrCreateUnifiedConfig();
|
||||
let fixed = false;
|
||||
|
||||
Reference in New Issue
Block a user