An open source design system that's fully customizable and agent ready
TypeScript
fix(cli): make doctor text output use its JSON field names (#6516)
Joeya2d80a27fe1a
diff --git a/.changeset/cli-spec-doctor-text-keys.md b/.changeset/cli-spec-doctor-text-keys.mdnew file mode 100644index 0000000000..93ef6a1c06--- /dev/null+++ b/.changeset/cli-spec-doctor-text-keys.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[fix] `astryx doctor` text output now uses the same field names as `--json`: each check prints its `id` and `label` (the label was shown as `check`, and the id was missing), and the summary prints `pass`, `warn`, `fail`, and `info` under a `summary` heading instead of a prose line.++@josephfarinadiff --git a/packages/cli/README.md b/packages/cli/README.mdindex 7ec42eaf06..69ecb5fd5c 100644--- a/packages/cli/README.md+++ b/packages/cli/README.md@@ -462,25 +462,33 @@ Every response has a `type` discriminant. The full set is below (generated from`astryx doctor` runs read-only health checks against your project andenvironment. Each record uses `[ok]`, `[warn]`, `[fail]`, or `[info]`, and-includes an actionable `fix` when one is available. The exact checks and values-depend on the project; the output shape is stable:+includes an actionable `fix` when one is available. Field names match the+`--json` keys. The exact checks and values depend on the project; the output+shape is stable:```$ astryx doctorastryx doctor - diagnosing your setup+id: node-versionstatus: [ok]-check: Node.js version+label: Node.js versionmessage: Node v24.18.1 meets the minimum (>=22.13.0).+id: themesstatus: [warn]-check: Theme packages+label: Theme packagesmessage: No @astryxdesign/theme-* packages are installed.fix: Install a theme, e.g. `npm install @astryxdesign/theme-neutral`, then import its CSS or set astryx.theme....-Summary: 4 passed, 2 warnings, 0 failures, 2 info+summary++pass: 4+warn: 2+fail: 0+info: 2No failures - but review the [warn] warnings above when you can.```diff --git a/packages/cli/clients/cli/commands/doctor.mjs b/packages/cli/clients/cli/commands/doctor.mjsindex a7a4e54cee..cfcebfadfa 100644--- a/packages/cli/clients/cli/commands/doctor.mjs+++ b/packages/cli/clients/cli/commands/doctor.mjs@@ -17,7 +17,7 @@ import {validateIntegration,} from '../../../api/integration/validate-integration.mjs';import {jsonOut} from '../../../foundation/response/json.mjs';-import {emit, section, records, text} from '../formatters/index.mjs';+import {emit, section, record, records, text} from '../formatters/index.mjs';import {defineCommand} from '../lib/define-command.mjs';import {doc as doctorCommand} from './doctor.doc.mjs';import {doc as doctorIntegrationGroup} from './doctor-integration.doc.mjs';@@ -55,7 +55,7 @@ function integrationLabel(data) {* @param {import('../../../api/doctor/doctor.mjs').DoctorReport} report*/function printHuman(report) {- const {pass, warn, fail, info} = report.summary;+ const {warn, fail} = report.summary;const closing =fail > 0? 'Some checks failed. Address the items marked [fail] above.'@@ -63,18 +63,15 @@ function printHuman(report) {? 'No failures — but review the [warn] warnings above when you can.': 'All checks passed. Your Astryx setup looks healthy.';+ // Field names are the JSON keys, so text and --json map one to one.emit(section('astryx doctor — diagnosing your setup'),records(report.checks, {- fields: ['status', 'label', 'message', 'fix'],- labels: {label: 'check'},+ fields: ['id', 'status', 'label', 'message', 'fix'],format: {status: statusToken},}),- text(- `Summary: ${pass} passed, ${warn} warning${warn === 1 ? '' : 's'}, ` +- `${fail} failure${fail === 1 ? '' : 's'}` +- (info ? `, ${info} info` : ''),- ),+ section('summary'),+ record(report.summary, {fields: ['pass', 'warn', 'fail', 'info']}),text(closing),);}diff --git a/packages/cli/clients/cli/commands/doctor.test.mjs b/packages/cli/clients/cli/commands/doctor.test.mjsindex 49e7421c84..ed54add32f 100644--- a/packages/cli/clients/cli/commands/doctor.test.mjs+++ b/packages/cli/clients/cli/commands/doctor.test.mjs@@ -354,3 +354,45 @@ describe('doctor — command', () => {}});});++describe('doctor — text output mirrors the JSON', () => {+ /** @param {string} line */+ const field = line => /^(\w+):\s+(.*)$/.exec(line)?.slice(1) ?? [line, ''];++ it('prints every check and summary field under its JSON key', async () => {+ const prevCwd = process.cwd();+ const prevExit = process.exitCode;+ process.chdir(tmpDir);+ try {+ await createProgram().parseAsync(['node', 'astryx', '--json', 'doctor']);+ const {checks, summary} = JSON.parse(logCalls.join('\n')).data;+ logCalls = [];+ await createProgram().parseAsync(['node', 'astryx', 'doctor']);+ const blocks = logCalls+ .join('\n')+ .split(/\n{2,}/)+ .map(block => block.split('\n').map(field));++ for (const check of checks) {+ const block = blocks.find(fields =>+ fields.some(([key, value]) => key === 'id' && value === check.id),+ );+ expect(block, `no text record for check ${check.id}`).toBeDefined();+ expect(+ /** @type {string[][]} */ (block).map(([key]) => key).sort(),+ ).toEqual(Object.keys(check).sort());+ }++ const heading = blocks.findIndex(+ fields => fields.length === 1 && fields[0][0] === 'summary',+ );+ expect(heading, 'no summary section').toBeGreaterThan(-1);+ expect(blocks[heading + 1]).toEqual(+ Object.entries(summary).map(([key, count]) => [key, String(count)]),+ );+ } finally {+ process.chdir(prevCwd);+ process.exitCode = prevExit;+ }+ }, 60_000);+});