feat(ops): add setup operator pack, heartbeat alert cooldown, and doctor strict mode
This commit is contained in:
+18
-2
@@ -632,12 +632,25 @@ export async function runChecks(ctx: DoctorContext): Promise<CheckResult[]> {
|
||||
return results;
|
||||
}
|
||||
|
||||
export function computeDoctorExitCode(results: CheckResult[], strict: boolean): number {
|
||||
const failCount = results.filter((r) => r.status === 'fail').length;
|
||||
const warnCount = results.filter((r) => r.status === 'warn').length;
|
||||
if (failCount > 0) {
|
||||
return 1;
|
||||
}
|
||||
if (strict && warnCount > 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function registerDoctorCommand(program: Command): void {
|
||||
program
|
||||
.command('doctor')
|
||||
.description('Validate configuration and check system health')
|
||||
.option('-c, --config <path>', 'Config file path')
|
||||
.action(async (opts: { config?: string }) => {
|
||||
.option('--strict', 'Treat warnings as failures')
|
||||
.action(async (opts: { config?: string; strict?: boolean }) => {
|
||||
const configPath = opts.config ?? getConfigPath();
|
||||
const dataDir = getDataDir();
|
||||
|
||||
@@ -662,7 +675,10 @@ export function registerDoctorCommand(program: Command): void {
|
||||
};
|
||||
|
||||
console.log(`Results: ${counts.pass} passed, ${counts.fail} failed, ${counts.warn} warnings, ${counts.skip} skipped`);
|
||||
if (opts.strict && counts.warn > 0) {
|
||||
console.log('Strict mode enabled: warnings are treated as failures.');
|
||||
}
|
||||
|
||||
process.exit(counts.fail > 0 ? 1 : 0);
|
||||
process.exit(computeDoctorExitCode(results, Boolean(opts.strict)));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user