mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 04:18:05 +00:00
fix(cliproxy): improve sync robustness and consistency
- Add timeout warning in restartAutoSyncWatcher when sync exceeds 10s - Improve YAML key detection with regex pattern for safer parsing - Replace --force help with --verbose (no confirmation prompt exists) - Add force flag parsing for future use
This commit is contained in:
@@ -169,6 +169,10 @@ export async function restartAutoSyncWatcher(): Promise<void> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
|
||||
if (isSyncing) {
|
||||
log('Warning: Sync still in progress after 10s timeout, proceeding with restart');
|
||||
}
|
||||
|
||||
await stopAutoSyncWatcher();
|
||||
startAutoSyncWatcher();
|
||||
}
|
||||
|
||||
@@ -124,13 +124,14 @@ function replaceSectionInYaml(content: string, sectionKey: string, newSection: s
|
||||
|
||||
// If we're in the section, skip lines until we hit another top-level key
|
||||
if (inSection) {
|
||||
// Top-level key starts at column 0 and has format "key:" or "key :"
|
||||
// Top-level key: starts at column 0, valid YAML key format (word chars + hyphens)
|
||||
// Must match pattern like "key:", "my-key:", "key_name:" but not comments or strings
|
||||
const isTopLevelKey =
|
||||
line.length > 0 &&
|
||||
!line.startsWith(' ') &&
|
||||
!line.startsWith('\t') &&
|
||||
!line.startsWith('#') &&
|
||||
line.includes(':');
|
||||
/^[a-zA-Z_][a-zA-Z0-9_-]*\s*:/.test(line);
|
||||
|
||||
if (isTopLevelKey) {
|
||||
// We've exited the section, resume normal processing
|
||||
|
||||
@@ -621,7 +621,7 @@ async function showHelp(): Promise<void> {
|
||||
[
|
||||
['sync', 'Sync API profiles to local CLIProxy config'],
|
||||
['sync --dry-run', 'Preview sync without applying'],
|
||||
['sync --force', 'Sync without confirmation prompt'],
|
||||
['sync --verbose', 'Show detailed sync information'],
|
||||
],
|
||||
],
|
||||
[
|
||||
|
||||
@@ -10,6 +10,7 @@ import { initUI, header, subheader, color, dim, ok, fail, warn, info, table } fr
|
||||
interface SyncArgs {
|
||||
dryRun: boolean;
|
||||
verbose: boolean;
|
||||
force: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,7 @@ export function parseSyncArgs(args: string[]): SyncArgs {
|
||||
return {
|
||||
dryRun: args.includes('--dry-run') || args.includes('-n'),
|
||||
verbose: args.includes('--verbose') || args.includes('-v'),
|
||||
force: args.includes('--force') || args.includes('-f'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user