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:
kaitranntt
2026-01-27 22:04:46 -05:00
parent b3cde80d0e
commit 9fd9395588
4 changed files with 8 additions and 22 deletions
+2 -1
View File
@@ -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[]
+2 -1
View File
@@ -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) {
+2 -10
View File
@@ -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);
}
+2 -10
View File
@@ -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) {