mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 06:17:27 +00:00
fix(cliproxy): make backend switching work with version pins and status
- Add backend param to isCLIProxyInstalled(), getCLIProxyPath(), getInstalledCliproxyVersion(), installCliproxyVersion() - Update getBinaryStatus() to pass backend to all helper functions - Add getBackendLabel() helper for dynamic CLI messages - Replace hardcoded "CLIProxy Plus" strings with dynamic labels - Pass --backend flag through install/update command handlers - Import CLIProxyBackend type from types.ts instead of redefining Setting `cliproxy.backend: original` in config.yaml now correctly uses the original backend for version pins and binary operations.
This commit is contained in:
1 parent
4fa519d8ae
commit
628148c359
5 files changed
+129
-57
No files matched your search
@@ -58,10 +58,10 @@ export function getBinaryStatus(backend?: CLIProxyBackend): BinaryStatusResult {
|
||||
backend ?? loadOrCreateUnifiedConfig().cliproxy?.backend ?? DEFAULT_BACKEND;
|
||||
const backendConfig = BACKEND_CONFIG[effectiveBackend];
|
||||
return {
|
||||
installed: isCLIProxyInstalled(),
|
||||
currentVersion: getInstalledCliproxyVersion(),
|
||||
pinnedVersion: getPinnedVersion(),
|
||||
binaryPath: getCLIProxyPath(),
|
||||
installed: isCLIProxyInstalled(effectiveBackend),
|
||||
currentVersion: getInstalledCliproxyVersion(effectiveBackend),
|
||||
pinnedVersion: getPinnedVersion(effectiveBackend),
|
||||
binaryPath: getCLIProxyPath(effectiveBackend),
|
||||
fallbackVersion: backendConfig.fallbackVersion,
|
||||
backend: effectiveBackend,
|
||||
};
|
||||
@@ -100,7 +100,11 @@ export function isValidVersionFormat(version: string): boolean {
|
||||
/**
|
||||
* Install a specific version and pin it
|
||||
*/
|
||||
export async function installVersion(version: string, verbose = false): Promise<InstallResult> {
|
||||
export async function installVersion(
|
||||
version: string,
|
||||
verbose = false,
|
||||
backend?: CLIProxyBackend
|
||||
): Promise<InstallResult> {
|
||||
if (!isValidVersionFormat(version)) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -109,9 +113,12 @@ export async function installVersion(version: string, verbose = false): Promise<
|
||||
};
|
||||
}
|
||||
|
||||
const effectiveBackend =
|
||||
backend ?? loadOrCreateUnifiedConfig().cliproxy?.backend ?? DEFAULT_BACKEND;
|
||||
|
||||
try {
|
||||
await installCliproxyVersion(version, verbose);
|
||||
savePinnedVersion(version);
|
||||
await installCliproxyVersion(version, verbose, effectiveBackend);
|
||||
savePinnedVersion(version, effectiveBackend);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -130,13 +137,19 @@ export async function installVersion(version: string, verbose = false): Promise<
|
||||
/**
|
||||
* Install latest version and clear any pin
|
||||
*/
|
||||
export async function installLatest(verbose = false): Promise<InstallResult> {
|
||||
export async function installLatest(
|
||||
verbose = false,
|
||||
backend?: CLIProxyBackend
|
||||
): Promise<InstallResult> {
|
||||
const effectiveBackend =
|
||||
backend ?? loadOrCreateUnifiedConfig().cliproxy?.backend ?? DEFAULT_BACKEND;
|
||||
|
||||
try {
|
||||
const latestVersion = await fetchLatestCliproxyVersion();
|
||||
const currentVersion = getInstalledCliproxyVersion();
|
||||
const wasPinned = isVersionPinned();
|
||||
const currentVersion = getInstalledCliproxyVersion(effectiveBackend);
|
||||
const wasPinned = isVersionPinned(effectiveBackend);
|
||||
|
||||
if (isCLIProxyInstalled() && latestVersion === currentVersion && !wasPinned) {
|
||||
if (isCLIProxyInstalled(effectiveBackend) && latestVersion === currentVersion && !wasPinned) {
|
||||
return {
|
||||
success: true,
|
||||
version: latestVersion,
|
||||
@@ -144,8 +157,8 @@ export async function installLatest(verbose = false): Promise<InstallResult> {
|
||||
};
|
||||
}
|
||||
|
||||
await installCliproxyVersion(latestVersion, verbose);
|
||||
clearPinnedVersion();
|
||||
await installCliproxyVersion(latestVersion, verbose, effectiveBackend);
|
||||
clearPinnedVersion(effectiveBackend);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
||||
Reference in new issue
Block a user