mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 16:14:31 +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:
1 parent
b3cde80d0e
commit
9fd9395588
4 files changed
+8
-22
No files matched your search
@@ -12,6 +12,7 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { CLIProxyProvider } from './types';
|
import { CLIProxyProvider } from './types';
|
||||||
|
import { CLIPROXY_PROFILES } from '../auth/profile-detector';
|
||||||
import { getCliproxyDir, getAuthDir } from './config-generator';
|
import { getCliproxyDir, getAuthDir } from './config-generator';
|
||||||
import { PROVIDER_TYPE_VALUES } from './auth/auth-types';
|
import { PROVIDER_TYPE_VALUES } from './auth/auth-types';
|
||||||
|
|
||||||
@@ -946,7 +947,7 @@ export async function soloAccount(
|
|||||||
* Get summary of all accounts across providers
|
* Get summary of all accounts across providers
|
||||||
*/
|
*/
|
||||||
export function getAllAccountsSummary(): Record<CLIProxyProvider, AccountInfo[]> {
|
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<
|
const summary: Record<CLIProxyProvider, AccountInfo[]> = {} as Record<
|
||||||
CLIProxyProvider,
|
CLIProxyProvider,
|
||||||
AccountInfo[]
|
AccountInfo[]
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { CLIProxyProvider } from '../types';
|
import { CLIProxyProvider } from '../types';
|
||||||
|
import { CLIPROXY_PROFILES } from '../../auth/profile-detector';
|
||||||
import { getProviderAccounts, getAccountTokenPath } from '../account-manager';
|
import { getProviderAccounts, getAccountTokenPath } from '../account-manager';
|
||||||
|
|
||||||
/** Preemptive refresh time: refresh tokens 45 minutes before expiry */
|
/** 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
|
* @returns Array of token expiry info, excluding invalid tokens
|
||||||
*/
|
*/
|
||||||
export function getAllTokenExpiryInfo(): TokenExpiryInfo[] {
|
export function getAllTokenExpiryInfo(): TokenExpiryInfo[] {
|
||||||
const providers: CLIProxyProvider[] = ['gemini', 'codex', 'agy', 'qwen', 'iflow', 'kiro', 'ghcp'];
|
const providers: CLIProxyProvider[] = [...CLIPROXY_PROFILES];
|
||||||
const results: TokenExpiryInfo[] = [];
|
const results: TokenExpiryInfo[] = [];
|
||||||
|
|
||||||
for (const provider of providers) {
|
for (const provider of providers) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { CLIProxyProvider } from '../types';
|
import { CLIProxyProvider } from '../types';
|
||||||
|
import { CLIPROXY_PROFILES } from '../../auth/profile-detector';
|
||||||
import { getProviderAuthDir } from '../config-generator';
|
import { getProviderAuthDir } from '../config-generator';
|
||||||
import { getProviderAccounts, getDefaultAccount } from '../account-manager';
|
import { getProviderAccounts, getDefaultAccount } from '../account-manager';
|
||||||
import {
|
import {
|
||||||
@@ -145,16 +146,7 @@ export function getAuthStatus(provider: CLIProxyProvider): AuthStatus {
|
|||||||
* Get auth status for all providers
|
* Get auth status for all providers
|
||||||
*/
|
*/
|
||||||
export function getAllAuthStatus(): AuthStatus[] {
|
export function getAllAuthStatus(): AuthStatus[] {
|
||||||
const providers: CLIProxyProvider[] = [
|
const providers: CLIProxyProvider[] = [...CLIPROXY_PROFILES];
|
||||||
'agy',
|
|
||||||
'claude',
|
|
||||||
'gemini',
|
|
||||||
'codex',
|
|
||||||
'qwen',
|
|
||||||
'iflow',
|
|
||||||
'kiro',
|
|
||||||
'ghcp',
|
|
||||||
];
|
|
||||||
return providers.map(getAuthStatus);
|
return providers.map(getAuthStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
BindingTestResult,
|
BindingTestResult,
|
||||||
} from '../utils/port-utils';
|
} from '../utils/port-utils';
|
||||||
import { CLIProxyProvider } from '../cliproxy/types';
|
import { CLIProxyProvider } from '../cliproxy/types';
|
||||||
|
import { CLIPROXY_PROFILES } from '../auth/profile-detector';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OAuth callback ports for each provider
|
* OAuth callback ports for each provider
|
||||||
@@ -140,16 +141,7 @@ export async function checkOAuthPort(provider: CLIProxyProvider): Promise<OAuthP
|
|||||||
* Check OAuth ports for all providers
|
* Check OAuth ports for all providers
|
||||||
*/
|
*/
|
||||||
export async function checkAllOAuthPorts(): Promise<OAuthPortDiagnostic[]> {
|
export async function checkAllOAuthPorts(): Promise<OAuthPortDiagnostic[]> {
|
||||||
const providers: CLIProxyProvider[] = [
|
const providers: CLIProxyProvider[] = [...CLIPROXY_PROFILES];
|
||||||
'gemini',
|
|
||||||
'codex',
|
|
||||||
'agy',
|
|
||||||
'qwen',
|
|
||||||
'iflow',
|
|
||||||
'kiro',
|
|
||||||
'ghcp',
|
|
||||||
'claude',
|
|
||||||
];
|
|
||||||
const results: OAuthPortDiagnostic[] = [];
|
const results: OAuthPortDiagnostic[] = [];
|
||||||
|
|
||||||
for (const provider of providers) {
|
for (const provider of providers) {
|
||||||
|
|||||||
Reference in new issue
Block a user