An open source design system that's fully customizable and agent ready
TypeScript
fix(cli): a Core-scoped lookup of a family member answers with that member (#7838)
Cindy Zhangcab6e9031089
diff --git a/.changeset/cli-scoped-core-member.md b/.changeset/cli-scoped-core-member.mdnew file mode 100644index 0000000000..9c609d8e13--- /dev/null+++ b/.changeset/cli-scoped-core-member.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[fix] `astryx component <Member> --package @astryxdesign/core` now answers with that member, as the unscoped lookup does. A Core component documented in its family's doc (HStack and VStack in the Stack doc) used to come back as the family doc, named after the family and with no props.++@cixzhangdiff --git a/packages/cli/api/component/component.mjs b/packages/cli/api/component/component.mjsindex a3495f4fa0..fca536856d 100644--- a/packages/cli/api/component/component.mjs+++ b/packages/cli/api/component/component.mjs@@ -461,8 +461,22 @@ async function componentRead(name, options = {}) {return componentDetailBlocks(dirName, cwd, owner.package);}const loaded = await loadComponentDoc(owner.docPath, docOpts);- // A family member an integration lists under its own name reads as that- // member, the way a Core sub-component does below.+ // A family member reads as that member, scoped the way the unscoped+ // lookup scopes it: an integration member by its own entry, a Core+ // sub-component (HStack in the Stack doc) by scopeSubComponent.+ const sub =+ scoped.kind === 'core'+ ? scopeSubComponent(loaded, dirName, coreDir)+ : null;+ if (sub) {+ if (props) {+ return componentDetailProps(+ {props: sub.matchingComponent.props},+ owner.package,+ );+ }+ return componentDetail(sub.scoped, owner, dirName, coreDir);+ }const docs =scoped.kind === 'integration'? scopeIntegrationMember(loaded, owner, dirName)diff --git a/packages/cli/api/component/component.test.mjs b/packages/cli/api/component/component.test.mjsindex e48753a212..d86f4e7456 100644--- a/packages/cli/api/component/component.test.mjs+++ b/packages/cli/api/component/component.test.mjs@@ -135,6 +135,21 @@ describe('component list — components whose docs live in a family folder', ()});}, SLOW);+ it('answers a Core-scoped lookup of a member with that member, as the unscoped lookup does', async () => {+ for (const name of ['HStack', 'VStack']) {+ const unscoped = await component(name, {cwd});+ const scoped = await component(name, {+ cwd,+ package: '@astryxdesign/core',+ });+ expect(scoped.data.name).toBe(name);+ expect(scoped.data.parentDoc).toBe('Stack');+ expect(scoped.data.import).toBe(`@astryxdesign/core/${name}`);+ expect(scoped.data.props).toEqual(unscoped.data.props);+ expect(scoped.data.props.length).toBeGreaterThan(0);+ }+ }, SLOW);+it('prints each one\'s own import path in the list, the detail, and search', async () => {// The path `component <Name>` prints is the one docs and examples teach:// the component's own entry point, never its family's (/Stack, /Text) or