From 081a5101fb79866c3b0fc9680fb5a3586f1a259f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 06:10:56 +0000 Subject: [PATCH] fix(cli): os doctor --verbose drops the advice to re-run with --verbose The warnings summary told an operator who had passed --verbose to pass it. Gate the hint on the flag being off; pin both arms on the real command. Claude-Session: https://claude.ai/code/session_01L6bhgTyMahdAdhXSzgy2nt Co-authored-by: Claude --- .changeset/34866-doctor-verbose-hint.md | 10 ++++++ .../doctor-deprecation-hint-commands.test.ts | 36 +++++++++++++++++++ packages/cli/src/commands/doctor.ts | 7 +++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .changeset/34866-doctor-verbose-hint.md diff --git a/.changeset/34866-doctor-verbose-hint.md b/.changeset/34866-doctor-verbose-hint.md new file mode 100644 index 00000000000..c05e6c8e3ac --- /dev/null +++ b/.changeset/34866-doctor-verbose-hint.md @@ -0,0 +1,10 @@ +--- +'@objectstack/cli': patch +--- + +fix(cli): `os doctor --verbose` no longer ends by telling you to run with --verbose + +Clause-②: no +Metadata-protocol: none + +When `os doctor` finished with warnings it always closed with "Run with --verbose to see fix suggestions.", including on a run that already passed `--verbose` and had already printed those suggestions. The line is now printed only when `--verbose` is off; a run without the flag reads exactly as before. diff --git a/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts b/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts index 6aeec33d4a6..6b947d6671c 100644 --- a/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts +++ b/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts @@ -334,4 +334,40 @@ describe('os doctor --scan-deprecations, end to end', () => { expect(run.out).toContain('No deprecated patterns found'); expect(run.out).not.toContain('No automated codemod ships with the CLI'); }, E2E_TIMEOUT); + + // The summary's re-run advice follows the same rule as the scan's own line + // above: it is printed only to an operator who has not passed `--verbose`. + // Both arms run the identical warning-bearing tree, and both first prove the + // summary reached its warnings branch — without that, an absent hint could + // mean a run that ended healthy or in error, not the fix. + describe('the warnings summary', () => { + const SUMMARY_WARNINGS = 'Environment is functional but has some warnings.'; + + /** + * What the report prints after the warnings verdict line — the summary's + * own advice and nothing from the checks above it. Judged by the flag it + * names, not by the sentence's wording. + */ + function summaryTail(out: string): string { + const at = out.lastIndexOf(SUMMARY_WARNINGS); + expect(at, 'the run must reach the warnings branch of the summary').toBeGreaterThanOrEqual(0); + return out.slice(at + SUMMARY_WARNINGS.length); + } + + it('advises --verbose when the flag is off', async () => { + writeDeprecatedSource(); + const run = await runDoctor(['--scan-deprecations']); + + expect(summaryTail(run.out)).toContain('--verbose'); + }, E2E_TIMEOUT); + + it('drops that advice under --verbose, where the suggestions are already on screen', async () => { + writeDeprecatedSource(); + const run = await runDoctor(['--scan-deprecations', '--verbose']); + + expect(summaryTail(run.out)).not.toContain('--verbose'); + // What the advice pointed at is printed: the → replacement per finding. + expect(run.out).toContain('Use maxLength (camelCase)'); + }, E2E_TIMEOUT); + }); }); diff --git a/packages/cli/src/commands/doctor.ts b/packages/cli/src/commands/doctor.ts index 2255d0810c7..5b130dc6f94 100644 --- a/packages/cli/src/commands/doctor.ts +++ b/packages/cli/src/commands/doctor.ts @@ -2741,7 +2741,12 @@ export default class Doctor extends Command { process.exit(1); } else if (hasWarnings) { console.log(chalk.yellow('⚠️ Environment is functional but has some warnings.')); - console.log(chalk.dim(' Run with --verbose to see fix suggestions.')); + // Only when the flag is off: under `--verbose` the fix suggestions this + // line points at are already printed above, so advising the operator to + // pass the flag they just passed sends them to re-run for nothing. + if (!flags.verbose) { + console.log(chalk.dim(' Run with --verbose to see fix suggestions.')); + } } else { console.log(chalk.green('✅ Environment is healthy and ready for development!')); }