From 3ce7c01d95dbb52ba584a376201d3cad99c0b258 Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Wed, 2 Sep 2026 11:29:29 -0400 Subject: [PATCH] chore(cliproxy): refresh formatting, throw-error baseline, and hardening inventory --- docs/reports/hardening-inventory.json | 2 +- docs/reports/hardening-inventory.md | 2 +- eslint-rules/throw-error-baseline.json | 24 +++++++++---------- src/cliproxy/accounts/drain-order.ts | 5 +--- src/cliproxy/binary/platform-detector.ts | 5 +--- .../__tests__/backend-selection.test.js | 8 +++++-- .../__tests__/routing-strategy.test.ts | 3 ++- .../__tests__/order-subcommand.test.ts | 12 ++++++++-- 8 files changed, 34 insertions(+), 27 deletions(-) diff --git a/docs/reports/hardening-inventory.json b/docs/reports/hardening-inventory.json index 91e33acb..c7a97bbc 100644 --- a/docs/reports/hardening-inventory.json +++ b/docs/reports/hardening-inventory.json @@ -1,7 +1,7 @@ { "scope": "src/**/*.{ts,tsx,js,jsx,mjs,cjs}", "syncFs": { - "totalOccurrences": 2509, + "totalOccurrences": 2513, "filesAffected": 263, "hotpathOccurrences": 1183, "hotpathFilesAffected": 156, diff --git a/docs/reports/hardening-inventory.md b/docs/reports/hardening-inventory.md index 506b59c8..ab01fc80 100644 --- a/docs/reports/hardening-inventory.md +++ b/docs/reports/hardening-inventory.md @@ -6,7 +6,7 @@ Scope: `src/**/*.{ts,tsx,js,jsx,mjs,cjs}` | Metric | Value | |---|---:| -| Sync fs occurrences (all) | 2509 | +| Sync fs occurrences (all) | 2513 | | Sync fs files affected (all) | 263 | | Sync fs occurrences (runtime hotpaths) | 1183 | | Sync fs files affected (runtime hotpaths) | 156 | diff --git a/eslint-rules/throw-error-baseline.json b/eslint-rules/throw-error-baseline.json index e1be244b..60d84fa8 100644 --- a/eslint-rules/throw-error-baseline.json +++ b/eslint-rules/throw-error-baseline.json @@ -8,12 +8,12 @@ "src/channels/official-channels-store.ts:291", "src/channels/official-channels-store.ts:296", "src/channels/official-channels-store.ts:299", - "src/cliproxy/accounts/drain-order.ts:131", - "src/cliproxy/accounts/drain-order.ts:139", - "src/cliproxy/accounts/drain-order.ts:246", - "src/cliproxy/accounts/drain-order.ts:253", - "src/cliproxy/accounts/drain-order.ts:279", - "src/cliproxy/accounts/drain-order.ts:342", + "src/cliproxy/accounts/drain-order.ts:149", + "src/cliproxy/accounts/drain-order.ts:157", + "src/cliproxy/accounts/drain-order.ts:264", + "src/cliproxy/accounts/drain-order.ts:271", + "src/cliproxy/accounts/drain-order.ts:297", + "src/cliproxy/accounts/drain-order.ts:360", "src/cliproxy/accounts/registry.ts:521", "src/cliproxy/accounts/registry.ts:536", "src/cliproxy/accounts/registry.ts:544", @@ -38,10 +38,10 @@ "src/cliproxy/binary/installer.ts:74", "src/cliproxy/binary/installer.ts:88", "src/cliproxy/binary/lifecycle.ts:137", - "src/cliproxy/binary/platform-detector.ts:153", - "src/cliproxy/binary/platform-detector.ts:160", + "src/cliproxy/binary/platform-detector.ts:152", + "src/cliproxy/binary/platform-detector.ts:159", "src/cliproxy/binary/verifier.ts:55", - "src/cliproxy/binary/version-checker.ts:108", + "src/cliproxy/binary/version-checker.ts:118", "src/cliproxy/config/base-config-loader.ts:54", "src/cliproxy/config/base-config-loader.ts:66", "src/cliproxy/config/base-config-loader.ts:81", @@ -59,9 +59,9 @@ "src/cliproxy/executor/proxy-resolver.ts:177", "src/cliproxy/executor/session-bridge.ts:147", "src/cliproxy/proxy/https-tunnel-proxy.ts:61", - "src/cliproxy/routing/routing-strategy.ts:480", - "src/cliproxy/routing/routing-strategy.ts:488", - "src/cliproxy/routing/routing-strategy.ts:708", + "src/cliproxy/routing/routing-strategy.ts:490", + "src/cliproxy/routing/routing-strategy.ts:498", + "src/cliproxy/routing/routing-strategy.ts:718", "src/cliproxy/services/remote-auth-fetcher.ts:139", "src/cliproxy/services/remote-auth-fetcher.ts:150", "src/cliproxy/services/remote-auth-fetcher.ts:152", diff --git a/src/cliproxy/accounts/drain-order.ts b/src/cliproxy/accounts/drain-order.ts index b8014818..ec2ee993 100644 --- a/src/cliproxy/accounts/drain-order.ts +++ b/src/cliproxy/accounts/drain-order.ts @@ -40,10 +40,7 @@ export const DRAIN_ORDER_MIN_VERSION: CLIProxyBackendMinVersions = { plus: '6.6.107-0', }; -export function isDrainOrderSupported( - backend: CLIProxyBackend, - installedVersion: string -): boolean { +export function isDrainOrderSupported(backend: CLIProxyBackend, installedVersion: string): boolean { return meetsBackendMinimumVersion(installedVersion, backend, DRAIN_ORDER_MIN_VERSION); } diff --git a/src/cliproxy/binary/platform-detector.ts b/src/cliproxy/binary/platform-detector.ts index 9721afb0..d9e5347b 100644 --- a/src/cliproxy/binary/platform-detector.ts +++ b/src/cliproxy/binary/platform-detector.ts @@ -124,10 +124,7 @@ function getReleaseArchForBackend( publicArch: SupportedArch, releaseArch: SupportedArch ): SupportedArch { - if ( - publicArch === 'arm64' && - !isAtLeastVersion(version, AARCH64_ASSET_MIN_VERSION[backend]) - ) { + if (publicArch === 'arm64' && !isAtLeastVersion(version, AARCH64_ASSET_MIN_VERSION[backend])) { return 'arm64'; } diff --git a/src/cliproxy/config/__tests__/backend-selection.test.js b/src/cliproxy/config/__tests__/backend-selection.test.js index 54bec9a0..40eb3de0 100644 --- a/src/cliproxy/config/__tests__/backend-selection.test.js +++ b/src/cliproxy/config/__tests__/backend-selection.test.js @@ -95,11 +95,15 @@ describe('Backend Selection', () => { it('selects arm64 vs aarch64 release assets across original and plus boundaries', () => { // Original pre-rename boundaries (<= 6.9.47) use arm64 for (const version of [undefined, '6.9.45', '6.9.47']) { - const effectiveVersion = version || platformDetector.BACKEND_CONFIG.original.fallbackVersion; + const effectiveVersion = + version || platformDetector.BACKEND_CONFIG.original.fallbackVersion; withMockedProcessPlatform('darwin', 'arm64', () => { const info = platformDetector.detectPlatform(version, 'original'); assert.strictEqual(info.arch, 'arm64'); - assert.strictEqual(info.binaryName, `CLIProxyAPI_${effectiveVersion}_darwin_arm64.tar.gz`); + assert.strictEqual( + info.binaryName, + `CLIProxyAPI_${effectiveVersion}_darwin_arm64.tar.gz` + ); assert.strictEqual( platformDetector.getDownloadUrl(version, 'original'), `https://github.com/router-for-me/CLIProxyAPI/releases/download/v${effectiveVersion}/CLIProxyAPI_${effectiveVersion}_darwin_arm64.tar.gz` diff --git a/src/cliproxy/routing/__tests__/routing-strategy.test.ts b/src/cliproxy/routing/__tests__/routing-strategy.test.ts index 271496e0..6a9364c1 100644 --- a/src/cliproxy/routing/__tests__/routing-strategy.test.ts +++ b/src/cliproxy/routing/__tests__/routing-strategy.test.ts @@ -18,7 +18,8 @@ describe('cliproxy routing strategy service', () => { let binaryBackend: CLIProxyBackend = 'original'; let binaryVersion = '7.2.127-7'; let installedVersionQueriedBackend: CLIProxyBackend | undefined = undefined; - let loggedWarnings: Array<{ event: string; message: string; context?: Record }> = []; + let loggedWarnings: Array<{ event: string; message: string; context?: Record }> = + []; let responseFactory: (() => Promise) | null = null; beforeEach(async () => { diff --git a/src/commands/cliproxy/__tests__/order-subcommand.test.ts b/src/commands/cliproxy/__tests__/order-subcommand.test.ts index 37fc0893..90727b07 100644 --- a/src/commands/cliproxy/__tests__/order-subcommand.test.ts +++ b/src/commands/cliproxy/__tests__/order-subcommand.test.ts @@ -19,6 +19,8 @@ import * as path from 'path'; mock.module('../../../cliproxy/proxy/proxy-detector', () => ({ detectRunningProxy: async () => ({ running: false, verified: false }), + waitForProxyHealthy: async () => ({ running: false, verified: false }), + reclaimOrphanedProxy: () => {}, })); describe('handleOrderSubcommand', () => { @@ -199,7 +201,7 @@ describe('handleOrderSubcommand', () => { expect(output).toContain('reset to file order'); expect(output).toContain('no priority set'); }); -}); + }); describe('binary version capability gate (#1724)', () => { const cases: Array<{ @@ -225,7 +227,13 @@ describe('handleOrderSubcommand', () => { }, ]; - for (const { backend, belowMinVersion, atMinVersion, backendLabel, requiredMinVersion } of cases) { + for (const { + backend, + belowMinVersion, + atMinVersion, + backendLabel, + requiredMinVersion, + } of cases) { describe(`${backend} backend`, () => { it(`refuses --set below minimum version (${belowMinVersion}) without mutating files`, async () => { await configureBackend(backend, belowMinVersion);