From 999b3c568e1359cbbafa63d8add0479be9ba7905 Mon Sep 17 00:00:00 2001 From: lonewolfyx Date: Mon, 24 Aug 2026 16:28:28 +0800 Subject: [PATCH] feat(list): add JSON output formatting for component list - Import ComponentDemoRecord type alongside ComponentRecord - Create outputJson function to transform component data for JSON format - Map components to exclude titleZh and code fields in JSON output - Update json property in output call to use transformed data --- src/commands/list.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/commands/list.ts b/src/commands/list.ts index 954b22b..558cbf1 100644 --- a/src/commands/list.ts +++ b/src/commands/list.ts @@ -1,4 +1,4 @@ -import type { ComponentRecord } from '#/components.ts' +import type { ComponentDemoRecord, ComponentRecord } from '#/components.ts' import { defineCommand } from 'citty' import { Table } from 'console-table-printer' import { defaultArgs } from '@/args/default.ts' @@ -40,6 +40,17 @@ function outputTable(components: ComponentRecord[]): string { return p.render() } +export function outputJson(components: ComponentRecord[]): Omit[] { + return components.map((component) => { + return { + name: component.name, + title: component.nameZh, + description: component.description, + descriptionZh: component.descriptionZh, + } + }) +} + export default defineCommand({ meta: { name: 'list', @@ -55,7 +66,7 @@ export default defineCommand({ output({ text: outputTable(components), - json: components, + json: outputJson(components), markdown: outputMarkdown(components), }, args.format) },