An open source design system that's fully customizable and agent ready
TypeScript
fix(cli): list only component directories for swizzle (#10185)
Cindy Zhang2fde70956bf6
diff --git a/.changeset/cli-swizzle-list-components-only.md b/.changeset/cli-swizzle-list-components-only.mdnew file mode 100644index 0000000000..2ef67e5bff--- /dev/null+++ b/.changeset/cli-swizzle-list-components-only.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[fix] `astryx swizzle --list` no longer lists Core's shared folders (`animator`, `gestures`, `i18n`, `internal`, `keyboard`, `motion`, `privateAttributes`, `__tests__`) as components. A copy of `gestures` imports `@astryxdesign/core/motion`, which the core package does not export.++@thecodebasedotdiff --git a/packages/cli/foundation/fs/paths.mjs b/packages/cli/foundation/fs/paths.mjsindex 47f3fdc8fe..1f91118ff8 100644--- a/packages/cli/foundation/fs/paths.mjs+++ b/packages/cli/foundation/fs/paths.mjs@@ -854,7 +854,8 @@ export function discoverExternalPackages(startDir = process.cwd()) {/*** List available component directories in packages/core/src.- * Returns directory names that contain Astryx*.tsx files.+ * Component directories are capitalized (`Button`, `Dialog`); lowercase+ * directories hold shared infrastructure and are never listed.* @param {string} coreDir*/export function listComponents(coreDir) {@@ -865,9 +866,7 @@ export function listComponents(coreDir) {return entries.filter(e => {if (!e.isDirectory()) return false;- // Skip non-component dirs- if (['hooks', 'theme', 'utils'].includes(e.name)) return false;- return true;+ return /^[A-Z]/.test(e.name);}).map(e => e.name).sort();diff --git a/packages/cli/foundation/fs/paths.test.mjs b/packages/cli/foundation/fs/paths.test.mjsindex 93e5658645..7e1b41b417 100644--- a/packages/cli/foundation/fs/paths.test.mjs+++ b/packages/cli/foundation/fs/paths.test.mjs@@ -681,9 +681,23 @@ describe('discoverExternalPackages', () => {});describe('listComponents', () => {- it('returns sorted component directory names, skipping hooks/theme/utils', () => {+ it('returns sorted component directory names, skipping infrastructure dirs', () => {const srcDir = path.join(tmpDir, 'src');- for (const dir of ['Button', 'Avatar', 'hooks', 'theme', 'utils', 'Zebra']) {+ // Infrastructure directories (`hooks`, `theme`, `utils`, `i18n`, `motion`,+ // `gestures`, `__tests__`) must never be offered to `swizzle`: a copy of+ // them cannot compile in a consumer project.+ for (const dir of [+ 'Button',+ 'Avatar',+ '__tests__',+ 'gestures',+ 'hooks',+ 'i18n',+ 'motion',+ 'theme',+ 'utils',+ 'Zebra',+ ]) {fs.mkdirSync(path.join(srcDir, dir), {recursive: true});}