From 2c62584c010553f1661077bc98c7680daabc7902 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Tue, 2 Dec 2025 15:21:46 -0600 Subject: [PATCH] =?UTF-8?q?Revert=20"chore(build):=20remove=20code=20prope?= =?UTF-8?q?rty=20from=20generated=20components.json=20(#7=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1b7c2600d8fa5fb02c34c04dc06291c39786aca9. --- packages/react/package.json | 4 ++-- packages/react/script/components-json/build.ts | 10 ++++++---- packages/react/script/hooks-json/build.ts | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/react/package.json b/packages/react/package.json index 320748e84a0..1196037ce2f 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -43,8 +43,8 @@ "build:storybook": "storybook build", "build:docs": "NODE_OPTIONS=--openssl-legacy-provider script/build-docs", "build:docs:preview": "NODE_OPTIONS=--openssl-legacy-provider script/build-docs preview", - "build:components.json": "node script/components-json/build.ts", - "build:hooks.json": "node script/hooks-json/build.ts", + "build:components.json": "tsx script/components-json/build.ts", + "build:hooks.json": "tsx script/hooks-json/build.ts", "build:precompile-color-schemes": "tsx script/precompile-color-schemes.ts", "lint:npm": "publint --types", "storybook": "storybook", diff --git a/packages/react/script/components-json/build.ts b/packages/react/script/components-json/build.ts index 8943a9fc6c3..b9046ded7a1 100644 --- a/packages/react/script/components-json/build.ts +++ b/packages/react/script/components-json/build.ts @@ -15,8 +15,8 @@ import prettier from '@prettier/sync' import chalk from 'chalk' import type {LintError} from 'markdownlint' import {lint as mdLint} from 'markdownlint/sync' -import componentSchema from './component.schema.json' with {type: 'json'} -import outputSchema from './output.schema.json' with {type: 'json'} +import componentSchema from './component.schema.json' +import outputSchema from './output.schema.json' const args = parseArgs({ options: { @@ -160,6 +160,7 @@ const components = docsFiles.map(docsFilepath => { if (id.endsWith('--default')) { return { id, + code: defaultStoryCode, } } const storyName = getStoryName(id) @@ -171,7 +172,7 @@ const components = docsFiles.map(docsFilepath => { ) } - return {id} + return {id, code} }) // Replace the stories array with the new array that includes source code @@ -179,10 +180,11 @@ const components = docsFiles.map(docsFilepath => { // Add default story to the beginning of the array if (defaultStoryCode) { - const hasDefaultStory = docs.stories.find(story => story.id === defaultStoryId) + const hasDefaultStory = docs.stories.find(story => story.code === defaultStoryCode) if (!hasDefaultStory) { docs.stories.unshift({ id: defaultStoryId, + code: defaultStoryCode, }) } } diff --git a/packages/react/script/hooks-json/build.ts b/packages/react/script/hooks-json/build.ts index 9ba7bddb214..4c20cc200ec 100644 --- a/packages/react/script/hooks-json/build.ts +++ b/packages/react/script/hooks-json/build.ts @@ -1,8 +1,8 @@ import glob from 'fast-glob' import fs from 'fs' import keyBy from 'lodash.keyby' -import hookSchema from '../hooks-json/hook.schema.json' with {type: 'json'} -import outputSchema from './output.schema.json' with {type: 'json'} +import hookSchema from '../hooks-json/hook.schema.json' +import outputSchema from './output.schema.json' import Ajv from 'ajv' // Only includes fields we use in this script