mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-12 16:15:13 +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:
1 parent
e80d2d2d05
commit
4124780ce0
4 files changed
+10
-3
No files matched your search
@@ -169,6 +169,10 @@ export async function restartAutoSyncWatcher(): Promise<void> {
|
|||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSyncing) {
|
||||||
|
log('Warning: Sync still in progress after 10s timeout, proceeding with restart');
|
||||||
|
}
|
||||||
|
|
||||||
await stopAutoSyncWatcher();
|
await stopAutoSyncWatcher();
|
||||||
startAutoSyncWatcher();
|
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 we're in the section, skip lines until we hit another top-level key
|
||||||
if (inSection) {
|
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 =
|
const isTopLevelKey =
|
||||||
line.length > 0 &&
|
line.length > 0 &&
|
||||||
!line.startsWith(' ') &&
|
!line.startsWith(' ') &&
|
||||||
!line.startsWith('\t') &&
|
!line.startsWith('\t') &&
|
||||||
!line.startsWith('#') &&
|
!line.startsWith('#') &&
|
||||||
line.includes(':');
|
/^[a-zA-Z_][a-zA-Z0-9_-]*\s*:/.test(line);
|
||||||
|
|
||||||
if (isTopLevelKey) {
|
if (isTopLevelKey) {
|
||||||
// We've exited the section, resume normal processing
|
// 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', 'Sync API profiles to local CLIProxy config'],
|
||||||
['sync --dry-run', 'Preview sync without applying'],
|
['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 {
|
interface SyncArgs {
|
||||||
dryRun: boolean;
|
dryRun: boolean;
|
||||||
verbose: boolean;
|
verbose: boolean;
|
||||||
|
force: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,6 +20,7 @@ export function parseSyncArgs(args: string[]): SyncArgs {
|
|||||||
return {
|
return {
|
||||||
dryRun: args.includes('--dry-run') || args.includes('-n'),
|
dryRun: args.includes('--dry-run') || args.includes('-n'),
|
||||||
verbose: args.includes('--verbose') || args.includes('-v'),
|
verbose: args.includes('--verbose') || args.includes('-v'),
|
||||||
|
force: args.includes('--force') || args.includes('-f'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user