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/35454-doctor-verbose-hint-fixless.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/cli': patch
---

fix(cli): `os doctor` no longer advises `--verbose` when no warning has a fix for it to show

Clause-②: no
Metadata-protocol: none

When `os doctor` finished with warnings it closed with "Run with --verbose to see fix suggestions." whenever any warning fired. Several warnings have no fix suggestion in either mode (a missing `*.test.ts` beside a `*.zod.ts`, `@deprecated` usages, circular dependencies, unused objects, orphan views), so for those the re-run printed nothing new. The line is now printed only when at least one warning that fired carries a fix that `--verbose` would reveal. The warnings themselves, and exit codes, are unchanged.
15 changes: 15 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 @@ -369,5 +369,20 @@ describe('os doctor --scan-deprecations, end to end', () => {
// What the advice pointed at is printed: the → replacement per finding.
expect(run.out).toContain('Use maxLength (camelCase)');
}, E2E_TIMEOUT);

// The advice is a promise that `--verbose` prints a fix the plain run hid.
// A missing `*.test.ts` beside a `*.zod.ts` warns with no fix line in
// either mode, so when it is the only warning the promise has nothing
// behind it and the summary must not make it.
it('makes no such advice when the only warnings carry no fix to reveal', async () => {
const specSrc = path.join(tmp, 'packages', 'spec', 'src');
fs.mkdirSync(specSrc, { recursive: true });
fs.writeFileSync(path.join(specSrc, 'a.zod.ts'), 'export const a = 1;\n', 'utf8');

const run = await runDoctor([]);

expect(run.out).toContain('Missing test: a.test.ts (for a.zod.ts)');
expect(summaryTail(run.out)).not.toContain('--verbose');
}, E2E_TIMEOUT);
});
});
22 changes: 19 additions & 3 deletions packages/cli/src/commands/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2442,6 +2442,13 @@ export default class Doctor extends Command {
// Display environment results
let hasErrors = false;
let hasWarnings = false;
// Whether some warning that fired carries a fix that only `--verbose`
// prints. The summary's re-run advice promises exactly that, so it follows
// this, not `hasWarnings`: a bare `printWarning` (missing tests,
// `@deprecated` usages, circular dependencies, unused objects, orphan
// views) has no fix in either mode, and a fix printed unasked (the
// protocol-gap hint, the unique-scope prescription) is already on screen.
let hasVerboseOnlyFix = false;

console.log('');
results.forEach((result) => {
Expand All @@ -2451,7 +2458,10 @@ export default class Doctor extends Command {
renderHealthCheckResult(result, flags.verbose);

if (result.status === 'error') hasErrors = true;
if (result.status === 'warning') hasWarnings = true;
if (result.status === 'warning') {
hasWarnings = true;
if (result.fix) hasVerboseOnlyFix = true;
}
});

// ── Extended Checks ──────────────────────────────────────────────
Expand Down Expand Up @@ -2641,6 +2651,7 @@ export default class Doctor extends Command {
printError(`${f.where}: ${f.message}`);
} else {
hasWarnings = true;
if (f.hint) hasVerboseOnlyFix = true;
printWarning(`${f.where}: ${f.message}`);
}
if (flags.verbose) {
Expand Down Expand Up @@ -2677,6 +2688,7 @@ export default class Doctor extends Command {
// above a warning. Inert today: that list filters on `error`.
results.push(finding);
hasWarnings = true;
if (finding.fix) hasVerboseOnlyFix = true;
}
}

Expand All @@ -2687,6 +2699,7 @@ export default class Doctor extends Command {
const deprecations = scanDeprecatedPatterns(scanDir);
if (deprecations.length > 0) {
hasWarnings = true;
hasVerboseOnlyFix = true;
for (const dep of deprecations) {
printWarning(`${dep.file}:${dep.line} — ${dep.description}`);
if (flags.verbose) {
Expand Down Expand Up @@ -2743,8 +2756,11 @@ export default class Doctor extends Command {
console.log(chalk.yellow('⚠️ Environment is functional but has some warnings.'));
// 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) {
// pass the flag they just passed sends them to re-run for nothing. And
// only when there is such a suggestion: a re-run whose warnings carry no
// hidden fix prints nothing more, so the advice would send them for
// nothing just the same.
if (!flags.verbose && hasVerboseOnlyFix) {
console.log(chalk.dim(' Run with --verbose to see fix suggestions.'));
}
} else {
Expand Down
Loading