Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(cli): keep component detail text a projection of its JSON (#6574)

Joey8fcc7d1018fe
diff --git a/.changeset/cli-spec-component-detail-related-blocks.md b/.changeset/cli-spec-component-detail-related-blocks.md
new file mode 100644
index 0000000000..4cc683c4aa
--- /dev/null
+++ b/.changeset/cli-spec-component-detail-related-blocks.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[fix] `astryx component <Name>` no longer prints a "Related block templates" list that `--json` never carried, so the text output shows only what the JSON result holds. The same blocks are still listed by `astryx component <Name> --blocks`, in text and JSON.
+
+@josephfarina
diff --git a/packages/cli/clients/cli/commands/component.test.mjs b/packages/cli/clients/cli/commands/component.test.mjs
index 65e8189956..8a59a32be2 100644
--- a/packages/cli/clients/cli/commands/component.test.mjs
+++ b/packages/cli/clients/cli/commands/component.test.mjs
@@ -13,6 +13,9 @@ import {
levenshteinDistance,
findClosestComponents,
} from './component/index.mjs';
+import {runCli} from '../../../test-utils/run-cli.mjs';
+
+const REPO_ROOT = path.resolve(import.meta.dirname, '../../../../..');
let tmpDir;
@@ -591,3 +594,19 @@ describe('searchComponents', () => {
expect(results.length).toBe(0);
});
});
+
+describe('component <Name> text output', () => {
+ // The text is a projection of the JSON envelope: it may show less, never
+ // data the envelope does not carry.
+ it('shows no related-block records that the JSON lacks', async () => {
+ const json = await runCli(['--json', 'component', 'Button'], REPO_ROOT);
+ expect(json.code).toBe(0);
+ expect(JSON.stringify(JSON.parse(json.stdout).data)).not.toContain('dirName');
+
+ const text = await runCli(['component', 'Button'], REPO_ROOT);
+ expect(text.code).toBe(0);
+ expect(text.stdout).toContain('# Button');
+ expect(text.stdout).not.toMatch(/^dirName:/m);
+ expect(text.stdout).not.toContain('Related block templates');
+ }, 30_000);
+});
diff --git a/packages/cli/clients/cli/commands/component/index.mjs b/packages/cli/clients/cli/commands/component/index.mjs
index f39cf19df8..d94d84891b 100644
--- a/packages/cli/clients/cli/commands/component/index.mjs
+++ b/packages/cli/clients/cli/commands/component/index.mjs
@@ -26,7 +26,6 @@ import {defineCommand} from '../../lib/define-command.mjs';
import {resultSet} from '../../../../foundation/debug/index.mjs';
import {ERROR_CODES} from '../../../../foundation/response/error-codes.mjs';
import {component as componentApi} from '../../../../api/component/component.mjs';
-import {findRelatedBlocks} from '../../../../api/template/template.mjs';
import {Project} from '../../../../foundation/config/project.mjs';
import {warnOnIntegrationIssues} from '../../../../foundation/integrations/integration-warnings.mjs';
import {doc as componentCommand} from '../component.doc.mjs';
@@ -241,12 +240,7 @@ export function registerComponent(program) {
: detail === 'compact'
? code(formatCompact(result.data, resolvedName, importHint))
: code(formatFull(result.data, {themeData, importHint}));
- const related = await findRelatedBlocks(resolvedName);
- emit(
- doc,
- related.length > 0 && section('Related block templates'),
- related.length > 0 && records(related, {fields: ['dirName', 'description']}),
- );
+ emit(doc);
break;
}