Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/34866-doctor-verbose-hint.md
Original file line number Diff line number Diff line change
@@ -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.
36 changes: 36 additions & 0 deletions packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
7 changes: 6 additions & 1 deletion packages/cli/src/commands/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!'));
}
Expand Down
Loading