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