An open source design system that's fully customizable and agent ready
TypeScript
fix(cli): name layout expand's text fields after its JSON keys (#6569)
Joeye8a63f80993b
diff --git a/.changeset/cli-spec-layout-expand-text-keys.md b/.changeset/cli-spec-layout-expand-text-keys.mdnew file mode 100644index 0000000000..462bc83cf2--- /dev/null+++ b/.changeset/cli-spec-layout-expand-text-keys.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[fix] `astryx layout expand <expr> <path>` now labels its text fields `componentsUsed` and `todos`, the keys the `--json` output uses, instead of `Components` and `TODOs`.++@josephfarinadiff --git a/packages/cli/clients/cli/commands/layout.mjs b/packages/cli/clients/cli/commands/layout.mjsindex bfa705e525..6740846eb2 100644--- a/packages/cli/clients/cli/commands/layout.mjs+++ b/packages/cli/clients/cli/commands/layout.mjs@@ -154,15 +154,15 @@ export function registerLayout(program) {if (result.data.written) {out.push(text(`[ok] Expanded to ${result.data.written}`),+ // Field names are the JSON keys; todos are summarised, not listed.record(+ {componentsUsed: result.data.componentsUsed, todos: result.data.todos},{- components: result.data.componentsUsed,- todos:- result.data.todos.length > 0- ? `${result.data.todos.length} (search for "TODO(xle)")`- : '',+ format: {+ todos: (/** @type {string[]} */ todos) =>+ `${todos.length} (search for "TODO(xle)")`,+ },},- {labels: {components: 'Components', todos: 'TODOs'}},),);} else {diff --git a/packages/cli/clients/cli/commands/layout.text-fields.test.mjs b/packages/cli/clients/cli/commands/layout.text-fields.test.mjsnew file mode 100644index 0000000000..fb64a0feef--- /dev/null+++ b/packages/cli/clients/cli/commands/layout.text-fields.test.mjs@@ -0,0 +1,39 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file `layout expand` text output names its fields after the JSON keys, so+ * the two views stay greppable against each other.+ */++import {describe, it, expect, beforeEach, afterEach} from 'vitest';+import * as fs from 'node:fs';+import * as path from 'node:path';+import {runCli} from '../../../test-utils/run-cli.mjs';++const SLOW = 60_000;++describe('layout expand text fields mirror the JSON keys', () => {+ let cwd;+ beforeEach(() => {+ // Inside the workspace so @astryxdesign/core resolves.+ cwd = fs.mkdtempSync(path.join(process.cwd(), '.xle-text-fields-'));+ });+ afterEach(() => fs.rmSync(cwd, {recursive: true, force: true}));++ it('labels every record field with a key of the layout.expand data', async () => {+ const expr = 'V > B + {not-a-real-block}';+ const json = await runCli(['layout', 'expand', expr, './a', '--loose', '--json'], cwd);+ expect(json.status).toBe(0);+ const {data} = JSON.parse(json.stdout);+ expect(data.todos.length).toBeGreaterThan(0);++ const human = await runCli(['layout', 'expand', expr, './b', '--loose'], cwd);+ expect(human.status).toBe(0);+ const fields = human.stdout+ .split('\n')+ .map(line => /^([A-Za-z]+):\s/.exec(line)?.[1])+ .filter(Boolean);+ expect(fields).toEqual(['componentsUsed', 'todos']);+ for (const field of fields) expect(Object.keys(data)).toContain(field);+ }, SLOW);+});