fix(cliproxy): address sync review feedback

- Fix auto_sync JSDoc to say (default: true) matching actual default
- Add unlink event handler for profile deletion sync
- Add debug logging for sync failures in api-command
This commit is contained in:
kaitranntt
2026-01-28 13:44:00 -05:00
parent c3f85bc4a8
commit e80d2d2d05
3 changed files with 9 additions and 3 deletions
+1
View File
@@ -130,6 +130,7 @@ export function startAutoSyncWatcher(): void {
watcherInstance.on('change', onFileChange); watcherInstance.on('change', onFileChange);
watcherInstance.on('add', onFileChange); watcherInstance.on('add', onFileChange);
watcherInstance.on('unlink', onFileChange);
watcherInstance.on('error', (error) => { watcherInstance.on('error', (error) => {
log(`Watcher error: ${error.message}`); log(`Watcher error: ${error.message}`);
+7 -2
View File
@@ -277,8 +277,13 @@ async function handleCreate(args: string[]): Promise<void> {
process.exit(1); process.exit(1);
} }
// Trigger sync to local CLIProxy config (best-effort, ignore result) // Trigger sync to local CLIProxy config (best-effort)
syncToLocalConfig(); try {
syncToLocalConfig();
} catch (err) {
const message = err instanceof Error ? err.message : 'Unknown error';
console.log(`[i] Auto-sync to CLIProxy config skipped: ${message}`);
}
// Display success // Display success
console.log(''); console.log('');
+1 -1
View File
@@ -132,7 +132,7 @@ export interface CLIProxyConfig {
auth?: CLIProxyAuthConfig; auth?: CLIProxyAuthConfig;
/** Background token refresh worker settings */ /** Background token refresh worker settings */
token_refresh?: TokenRefreshSettings; token_refresh?: TokenRefreshSettings;
/** Auto-sync API profiles to local CLIProxy config on settings change (default: false) */ /** Auto-sync API profiles to local CLIProxy config on settings change (default: true) */
auto_sync?: boolean; auto_sync?: boolean;
} }