mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 04:18:05 +00:00
refactor(cliproxy): use CLIPROXY_PROFILES for provider arrays (DRY)
- Replace hardcoded arrays in token-manager.ts, token-expiry-checker.ts - Replace hardcoded arrays in account-manager.ts, oauth-port-diagnostics.ts - Addresses PR #384 code review feedback
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { CLIProxyProvider } from './types';
|
||||
import { CLIPROXY_PROFILES } from '../auth/profile-detector';
|
||||
import { getCliproxyDir, getAuthDir } from './config-generator';
|
||||
import { PROVIDER_TYPE_VALUES } from './auth/auth-types';
|
||||
|
||||
@@ -946,7 +947,7 @@ export async function soloAccount(
|
||||
* Get summary of all accounts across providers
|
||||
*/
|
||||
export function getAllAccountsSummary(): Record<CLIProxyProvider, AccountInfo[]> {
|
||||
const providers: CLIProxyProvider[] = ['gemini', 'codex', 'agy', 'qwen', 'iflow', 'kiro', 'ghcp'];
|
||||
const providers: CLIProxyProvider[] = [...CLIPROXY_PROFILES];
|
||||
const summary: Record<CLIProxyProvider, AccountInfo[]> = {} as Record<
|
||||
CLIProxyProvider,
|
||||
AccountInfo[]
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { CLIProxyProvider } from '../types';
|
||||
import { CLIPROXY_PROFILES } from '../../auth/profile-detector';
|
||||
import { getProviderAccounts, getAccountTokenPath } from '../account-manager';
|
||||
|
||||
/** Preemptive refresh time: refresh tokens 45 minutes before expiry */
|
||||
@@ -113,7 +114,7 @@ export function getTokenExpiryInfo(
|
||||
* @returns Array of token expiry info, excluding invalid tokens
|
||||
*/
|
||||
export function getAllTokenExpiryInfo(): TokenExpiryInfo[] {
|
||||
const providers: CLIProxyProvider[] = ['gemini', 'codex', 'agy', 'qwen', 'iflow', 'kiro', 'ghcp'];
|
||||
const providers: CLIProxyProvider[] = [...CLIPROXY_PROFILES];
|
||||
const results: TokenExpiryInfo[] = [];
|
||||
|
||||
for (const provider of providers) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { CLIProxyProvider } from '../types';
|
||||
import { CLIPROXY_PROFILES } from '../../auth/profile-detector';
|
||||
import { getProviderAuthDir } from '../config-generator';
|
||||
import { getProviderAccounts, getDefaultAccount } from '../account-manager';
|
||||
import {
|
||||
@@ -145,16 +146,7 @@ export function getAuthStatus(provider: CLIProxyProvider): AuthStatus {
|
||||
* Get auth status for all providers
|
||||
*/
|
||||
export function getAllAuthStatus(): AuthStatus[] {
|
||||
const providers: CLIProxyProvider[] = [
|
||||
'agy',
|
||||
'claude',
|
||||
'gemini',
|
||||
'codex',
|
||||
'qwen',
|
||||
'iflow',
|
||||
'kiro',
|
||||
'ghcp',
|
||||
];
|
||||
const providers: CLIProxyProvider[] = [...CLIPROXY_PROFILES];
|
||||
return providers.map(getAuthStatus);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
BindingTestResult,
|
||||
} from '../utils/port-utils';
|
||||
import { CLIProxyProvider } from '../cliproxy/types';
|
||||
import { CLIPROXY_PROFILES } from '../auth/profile-detector';
|
||||
|
||||
/**
|
||||
* OAuth callback ports for each provider
|
||||
@@ -140,16 +141,7 @@ export async function checkOAuthPort(provider: CLIProxyProvider): Promise<OAuthP
|
||||
* Check OAuth ports for all providers
|
||||
*/
|
||||
export async function checkAllOAuthPorts(): Promise<OAuthPortDiagnostic[]> {
|
||||
const providers: CLIProxyProvider[] = [
|
||||
'gemini',
|
||||
'codex',
|
||||
'agy',
|
||||
'qwen',
|
||||
'iflow',
|
||||
'kiro',
|
||||
'ghcp',
|
||||
'claude',
|
||||
];
|
||||
const providers: CLIProxyProvider[] = [...CLIPROXY_PROFILES];
|
||||
const results: OAuthPortDiagnostic[] = [];
|
||||
|
||||
for (const provider of providers) {
|
||||
|
||||
Reference in New Issue
Block a user