Repository navigation
Commit f6b095a
fix(cli): os doctor advises --verbose only when a warning has a fix for it to show (#35626)
Fixes #35454
repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt
Clause-②: no
Metadata-protocol: none
## 维护者速读
1.
用户能看到什么变化:开发者在命令行做项目体检时,如果出现的警告都没有修复建议(例如缺少测试文件),结尾不再叫他打开详细模式重跑一次;有修复建议的警告照旧提示。
2. 为什么做:上一张修复 doctor 结尾提示的卡留下的另一半,开发者第一次用 CLI 时被引去重跑一次,却什么新内容也看不到。
3. 出错会怎样:最坏情况是某类有修复建议的警告不再带这句提示,警告本身和退出码都不变;撤回本 PR 即恢复原样。
4. 要你做什么:无。
## What changes
- `packages/cli/src/commands/doctor.ts`: a new `hasVerboseOnlyFix` flag,
tracked beside `hasWarnings`. The summary prints "Run with --verbose to
see fix suggestions." only when `--verbose` is off AND that flag is set.
Each warning path was read and classified:
- sets the flag (a fix that only `--verbose` prints): an environment
`HealthCheckResult` with `status === 'warning'` and a `fix`; a
dashboard-widget warning with a non-empty `hint`; the
config-load-failure finding when it carries a `fix`; any
`--scan-deprecations` hit (its `replacement` is printed only under
`--verbose`).
- does not set it, no fix in either mode: missing tests, `@deprecated`
usages, circular dependencies, unused objects, orphan views.
- does not set it, fix already printed without the flag: the
platform-protocol gap (its hint is printed unconditionally) and the
isolated-posture unique-scope advisory (its prescription is printed
unconditionally).
- The warnings' own text, the verdict line and exit codes are unchanged.
No fix text was added.
- `.changeset/35454-doctor-verbose-hint-fixless.md`: patch,
`@objectstack/cli`.
## Tests
- `packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts`,
in the existing `describe('the warnings summary')`, which uses the real
`Doctor.run()`: a new case writes `packages/spec/src/a.zod.ts` with no
test into the temp cwd and runs plain `os doctor`. It asserts that the
"Missing test" warning fired, that the summary reached its warnings
branch, and that the text after the verdict line does not name
`--verbose`.
- The two existing cases from PR #35377 still cover the fix-bearing
side: a `--scan-deprecations` warning still gets the hint without
`--verbose` and gets none with it.
## Acceptance notes
- Dashboard-widget warnings whose `hint` is the empty string
(`@objectstack/lint` emits `hint: ''` on one path) do not count as
fix-bearing here, since `--verbose` would print only a bare arrow for
them. That empty arrow line under `--verbose` is not changed here.
Observation only, not reproduced at the public door.
- Environment rows with status `ok` also print their `fix` under
`--verbose`. They are not warnings, so they do not count toward the
hint. The behaviour is unchanged.
## Verification
Readings are at HEAD `d559e09a` (the fix commit `1dc43d70` merged with
origin/main `f981dce3`; the merge brought in no package source).
Two-minute check: `pnpm --filter @objectstack/cli exec vitest run
--project unit src/commands/doctor-deprecation-hint-commands.test.ts`.
Expected: 15 passed.
Read first: `packages/cli/src/commands/doctor.ts`, the summary's `if
(!flags.verbose && hasVerboseOnlyFix)` and the four places that set the
flag. The risk is a fix-bearing path left unclassified.
<details><summary>Red first, then green</summary>
- At `86ec0951` (the new pin on an unmodified `doctor.ts`): Tests 1
failed, 14 passed (15). The new case failed with `expected '\n Run with
--verbose to see fix su…' not to contain '--verbose'`.
- At `1dc43d70`: Test Files 1 passed (1), Tests 15 passed (15).
</details>
<details><summary>Ablation (scripts/ablation-replace.mjs, landed on disk
and restored)</summary>
- Anchor `if (!flags.verbose && hasVerboseOnlyFix) {` replaced with `if
(!flags.verbose) {`. The anchor went from 1 to 0 and the blob from
975d2c6 to ab86dda8. Result: Tests 1 failed, 14 passed. Only "makes no
such advice when the only warnings carry no fix to reveal" failed.
- Restore: the blob after restore equals HEAD (975d2c6) and `git diff
HEAD` is empty.
- The test imports the subject as relative source (`./doctor.js`), so
the ablation needed no dist rebuild.
</details>
<details><summary>Package tests and typecheck</summary>
- `pnpm run typecheck` in `packages/cli` (tsc, then
`check:test-typecheck`) followed by `pnpm exec vitest run --project unit
--maxWorkers=2`, as one locked command: VERDICT command-exit 0. Test
Files 431 passed (431), Tests 6163 passed (6163).
- The `integration` tier is left to CI: the diff touches no
integration-tier file and no spawn entry.
</details>
<details><summary>Gates (derived set, local)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `d559e09a` derived 69 families. Each one
was run, with its exit code captured before any pipe.
- 67 exited 0. 2 are NOT MEASURED, both exit 3 PREREQUISITE NOT MET
because they need dist output across the repo: `pnpm
check:dual-build-cjs-loads` (no dist for studio, client-react,
connector-slack, ...) and `pnpm check:i18n-coverage` (the app-showcase
config imports an unbuilt connector-slack dist). CI runs both.
- `--ran` reconciliation: "69 derived famil(ies) accounted for — 67 run,
2 NOT-MEASURED (2 DERIVED from a recorded exit 3)".
- `node scripts/pm/overlap-check.mjs`: VERDICT clean exit 0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgTyMahdAdhXSzgy2nt)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 36e02fd commit f6b095a
3 files changed
Lines changed: 44 additions & 3 deletions
File tree
- .changeset
- packages/cli/src/commands
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
372 | 387 | | |
373 | 388 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2442 | 2442 | | |
2443 | 2443 | | |
2444 | 2444 | | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2445 | 2452 | | |
2446 | 2453 | | |
2447 | 2454 | | |
| |||
2451 | 2458 | | |
2452 | 2459 | | |
2453 | 2460 | | |
2454 | | - | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
2455 | 2465 | | |
2456 | 2466 | | |
2457 | 2467 | | |
| |||
2641 | 2651 | | |
2642 | 2652 | | |
2643 | 2653 | | |
| 2654 | + | |
2644 | 2655 | | |
2645 | 2656 | | |
2646 | 2657 | | |
| |||
2677 | 2688 | | |
2678 | 2689 | | |
2679 | 2690 | | |
| 2691 | + | |
2680 | 2692 | | |
2681 | 2693 | | |
2682 | 2694 | | |
| |||
2687 | 2699 | | |
2688 | 2700 | | |
2689 | 2701 | | |
| 2702 | + | |
2690 | 2703 | | |
2691 | 2704 | | |
2692 | 2705 | | |
| |||
2743 | 2756 | | |
2744 | 2757 | | |
2745 | 2758 | | |
2746 | | - | |
2747 | | - | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
2748 | 2764 | | |
2749 | 2765 | | |
2750 | 2766 | | |
| |||
0 commit comments