Skip to content

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

TypeScript

fix(cli): scope findShowcase to package when package filter is set (#1940)

Cindy Zhang1b0c4edb4452
diff --git a/packages/cli/src/api/component.mjs b/packages/cli/src/api/component.mjs
index 295b35931b..c2ea2f6800 100644
--- a/packages/cli/src/api/component.mjs
+++ b/packages/cli/src/api/component.mjs
@@ -172,7 +172,7 @@ export async function component(name, options = {}) {
}
if (showcase) {
- const match = await findShowcase(dirName, cwd);
+ const match = await findShowcase(dirName, cwd, {package: packageScope});
if (!match) {
throw new XDSError(`No showcase found for "${name}" in package "${packageScope}"`);
}
diff --git a/packages/cli/src/api/template.mjs b/packages/cli/src/api/template.mjs
index 19dda5046e..ac695d8e24 100644
--- a/packages/cli/src/api/template.mjs
+++ b/packages/cli/src/api/template.mjs
@@ -160,10 +160,24 @@ export async function findRelatedBlocks(componentName, cwd) {
);
}
-export async function findShowcase(componentName, cwd) {
+/**
+ * @param {string} componentName
+ * @param {string} [cwd]
+ * @param {{ package?: string }} [options] - When set, only search blocks from this package.
+ * Core blocks have no `package` field; external blocks have `package` set to the npm name.
+ */
+export async function findShowcase(componentName, cwd, options) {
const blocks = await discoverAllBlocks(cwd);
const lc = componentName.toLowerCase();
- const showcases = blocks.filter(b => b.isShowcase);
+ const packageFilter = options?.package;
+
+ // When scoped to a package, only consider blocks from that package.
+ // Core blocks have no `package` field — filter them out when a package is specified.
+ const showcases = blocks.filter(b => {
+ if (!b.isShowcase) return false;
+ if (packageFilter) return b.package === packageFilter;
+ return true;
+ });
const toResult = (b) => ({
name: b.name,