An open source design system that's fully customizable and agent ready
TypeScript
feat(shadcn): enable hidden production registry (#6260)
Joey8a2a626312c2
diff --git a/.github/scripts/shadcn-registry-ci.test.mjs b/.github/scripts/shadcn-registry-ci.test.mjsindex b8292f361e..aa28e3d3ab 100644--- a/.github/scripts/shadcn-registry-ci.test.mjs+++ b/.github/scripts/shadcn-registry-ci.test.mjs@@ -37,7 +37,7 @@ describe('ShadCN registry CI contract', () => {expect(job.needs).toEqual(['check-scope']);expect(job.if).toContain('always()');expect(job['runs-on']).toBe('4-core-ubuntu');- expect(job['timeout-minutes']).toBe(20);+ expect(job['timeout-minutes']).toBe(30);expect(step('Require successful scope classification').run).toContain('refusing to skip required work',);@@ -66,8 +66,8 @@ describe('ShadCN registry CI contract', () => {}});- it('proves production exclusion before generating the canary catalog', () => {- const production = step('Verify production excludes compatibility output');+ it('proves hidden production output without enabling public discovery', () => {+ const production = step('Verify hidden production registry contract');expect(production.run).toBe('node internal/shadcn-registry/verify-production-gate.mjs',);@@ -75,10 +75,34 @@ describe('ShadCN registry CI contract', () => {const generateData = read('apps/docsite/scripts/generate-data.mjs');expect(generateData).toContain('generateShadcnRegistryForTarget({');expect(generateData).not.toMatch(/\bgenerateShadcnRegistry\(\{/);+ expect(generateData).toContain(+ "dependencyTag: DOCSITE_TARGET === 'canary' ? 'canary' : null",+ );+ expect(generateData).toContain(+ "DOCSITE_TARGET === 'canary' ? shadcnCounts.itemPaths : undefined",+ );+ expect(generateData).toContain("allowSubset: DOCSITE_TARGET === 'latest'");const preview = step('Generate and validate the complete preview registry');expect(preview.env.DOCSITE_TARGET).toBe('canary');expect(preview.run).toContain('generate-data.mjs');+ const hidden = step('Generate the hidden production registry');+ expect(hidden.env.DOCSITE_TARGET).toBe('latest');+ expect(hidden.run).toContain('generate-data.mjs');+ const discovery = step('Verify hidden production discovery surfaces');+ expect(discovery.env.ASTRYX_VERIFY_HIDDEN_PRODUCTION).toBe('1');+ expect(discovery.env.NEXT_PUBLIC_DOCS_TARGET).toBe('latest');+ expect(discovery.run).toBe(+ 'pnpm -F @astryxdesign/docsite exec vitest run src/__tests__/hidden-shadcn-production.test.ts',+ );+ expect(job.steps.indexOf(discovery)).toBeGreaterThan(+ job.steps.indexOf(hidden),+ );+ expect(job.steps.indexOf(discovery)).toBeLessThan(+ job.steps.indexOf(+ step('Install and build every hidden production registry item'),+ ),+ );});it('keeps the soak rollout out of public CLI discovery', () => {@@ -98,10 +122,19 @@ describe('ShadCN registry CI contract', () => {expect(step('Build registry package exports').run).toBe('pnpm build');});- it('uses the complete clean-consumer verifier and an exact ShadCN pin', () => {- expect(step('Install and build every registry item').run).toBe(+ it('uses the complete clean-consumer verifier in preview and production', () => {+ expect(step('Install and build every preview registry item').run).toBe('node internal/shadcn-registry/verify-full-catalog.mjs',);+ const productionInstall = step(+ 'Install and build every hidden production registry item',+ );+ expect(productionInstall.run).toBe(+ 'node internal/shadcn-registry/verify-full-catalog.mjs',+ );+ expect(productionInstall.env.ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES).toBe(+ '1',+ );const manifest = JSON.parse(read('apps/docsite/package.json'));expect(manifest.devDependencies.shadcn).toMatch(/^\d+\.\d+\.\d+$/);@@ -119,6 +152,8 @@ describe('ShadCN registry CI contract', () => {'precompiled declaration type-check exited','parseRegistryReceipt','verifyPrecompiledTypeDeclarations(project, catalog.items)',+ 'ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES',+ 'is not an exact release','compileSources(project, sources)',]) {expect(verifier).toContain(invariant);diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 2e3d1162e7..9641cd2aff 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -302,7 +302,7 @@ jobs:needs: [check-scope]if: ${{ always() && !cancelled() }}runs-on: 4-core-ubuntu- timeout-minutes: 20+ timeout-minutes: 30permissions:contents: readsteps:@@ -326,7 +326,7 @@ jobs:if: needs.check-scope.outputs.spec_only != 'true'run: pnpm build- - name: Verify production excludes compatibility output+ - name: Verify hidden production registry contractif: needs.check-scope.outputs.spec_only != 'true'run: node internal/shadcn-registry/verify-production-gate.mjs@@ -336,8 +336,27 @@ jobs:DOCSITE_TARGET: canaryrun: node apps/docsite/scripts/generate-data.mjs- - name: Install and build every registry item+ - name: Install and build every preview registry item+ if: needs.check-scope.outputs.spec_only != 'true'+ run: node internal/shadcn-registry/verify-full-catalog.mjs++ - name: Generate the hidden production registry+ if: needs.check-scope.outputs.spec_only != 'true'+ env:+ DOCSITE_TARGET: latest+ run: node apps/docsite/scripts/generate-data.mjs++ - name: Verify hidden production discovery surfaces+ if: needs.check-scope.outputs.spec_only != 'true'+ env:+ ASTRYX_VERIFY_HIDDEN_PRODUCTION: '1'+ NEXT_PUBLIC_DOCS_TARGET: latest+ run: pnpm -F @astryxdesign/docsite exec vitest run src/__tests__/hidden-shadcn-production.test.ts++ - name: Install and build every hidden production registry itemif: needs.check-scope.outputs.spec_only != 'true'+ env:+ ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES: '1'run: node internal/shadcn-registry/verify-full-catalog.mjs# Historical required check name. The two Vitest lanes and the publicdiff --git a/apps/docsite/scripts/generate-data.mjs b/apps/docsite/scripts/generate-data.mjsindex 926b015b3c..870ea0ab11 100644--- a/apps/docsite/scripts/generate-data.mjs+++ b/apps/docsite/scripts/generate-data.mjs@@ -2206,7 +2206,7 @@ export const blogDarkImages: string[] = ${JSON.stringify(darkImages, null, 2)};return {blogPostCount: posts.length, blogTypeCount: types.length};}-function checkShadcnRouteLock(contracts) {+function checkShadcnRouteLock(contracts, {allowSubset = false} = {}) {const lockPath = path.join(REPO_ROOT,'internal',@@ -2217,6 +2217,11 @@ function checkShadcnRouteLock(contracts) {const serialized = `${JSON.stringify(lock, null, 2)}\n`;if (process.env.UPDATE_SHADCN_ROUTE_LOCK === '1') {+ if (allowSubset) {+ throw new Error(+ 'Refusing to replace the complete ShadCN route lock from a production subset.',+ );+ }fs.writeFileSync(lockPath, serialized, 'utf8');console.log(` updated ${path.relative(REPO_ROOT, lockPath)}`);return;@@ -2228,6 +2233,21 @@ function checkShadcnRouteLock(contracts) {);}const current = fs.readFileSync(lockPath, 'utf8');+ if (allowSubset) {+ const locked = new Map(+ JSON.parse(current).items.map(contract => [contract.name, contract]),+ );+ for (const contract of contracts) {+ if (+ JSON.stringify(locked.get(contract.name)) !== JSON.stringify(contract)+ ) {+ throw new Error(+ `Production ShadCN route ${contract.path} is absent from or differs from the reviewed route lock.`,+ );+ }+ }+ return;+ }if (current !== serialized) {throw new Error(`Generated ShadCN names or routes changed. Preserve old paths with doc.registry.aliases, or intentionally refresh the reviewed lock with UPDATE_SHADCN_ROUTE_LOCK=1 node apps/docsite/scripts/generate-data.mjs.`,@@ -2257,25 +2277,21 @@ async function main() {blocks,templates,cliRoot: CLI_ROOT,- dependencyTag: 'canary',+ dependencyTag: DOCSITE_TARGET === 'canary' ? 'canary' : null,externalDependencySpecs: registryExternalDependencySpecs(),});- if (shadcnCounts) {- checkShadcnRouteLock(shadcnCounts.contracts);- }+ checkShadcnRouteLock(shadcnCounts.contracts, {+ allowSubset: DOCSITE_TARGET === 'latest',+ });// `/r` stays unclaimed for a future Astryx-native registry.fs.rmSync(path.join(DOCSITE_ROOT, 'public', 'r'), {recursive: true,force: true,});- const showcaseCopied = generateShowcaseRegistry(- blocks,- shadcnCounts?.itemPaths,- );- const examplesCopied = generateExampleRegistry(- blocks,- shadcnCounts?.itemPaths,- );+ const shadcnUiItemPaths =+ DOCSITE_TARGET === 'canary' ? shadcnCounts.itemPaths : undefined;+ const showcaseCopied = generateShowcaseRegistry(blocks, shadcnUiItemPaths);+ const examplesCopied = generateExampleRegistry(blocks, shadcnUiItemPaths);const registryOrigin = resolveShadcnRegistryOrigin(process.env);const registryIsPreview =DOCSITE_TARGET === 'canary' &&@@ -2298,19 +2314,15 @@ export const shadcnRegistryIsPreview = ${registryIsPreview};console.log(` ${docsCount} doc topics`);console.log(` ${blogPostCount} blog posts`);console.log(` ${themeCount} themes`);- if (shadcnCounts) {- console.log(- ` ${shadcnCounts.total} ShadCN registry items ` +- `(${shadcnCounts.components} components, ${shadcnCounts.hooks} hooks, ` +- `${shadcnCounts.showcases} showcases, ${shadcnCounts.examples} examples, ` +- `${shadcnCounts.blocks} standalone blocks, ${shadcnCounts.pages} pages; ` +- `${shadcnCounts.skippedUnpublishedComponents} unpublished components, ` +- `${shadcnCounts.skippedUnpublishedBlocks} blocks, and ` +- `${shadcnCounts.skippedUnpublishedPages} pages skipped)`,- );- } else {- console.log(' ShadCN registry disabled for the production target');- }+ console.log(+ ` ${shadcnCounts.total} ShadCN registry items ` ++ `(${shadcnCounts.components} components, ${shadcnCounts.hooks} hooks, ` ++ `${shadcnCounts.showcases} showcases, ${shadcnCounts.examples} examples, ` ++ `${shadcnCounts.blocks} standalone blocks, ${shadcnCounts.pages} pages; ` ++ `${shadcnCounts.skippedUnpublishedComponents} unpublished components, ` ++ `${shadcnCounts.skippedUnpublishedBlocks} blocks, and ` ++ `${shadcnCounts.skippedUnpublishedPages} pages skipped)`,+ );console.log('Done.');}diff --git a/apps/docsite/scripts/generate-shadcn-registry.mjs b/apps/docsite/scripts/generate-shadcn-registry.mjsindex ec69261e1d..c91e91c13b 100644--- a/apps/docsite/scripts/generate-shadcn-registry.mjs+++ b/apps/docsite/scripts/generate-shadcn-registry.mjs@@ -657,9 +657,9 @@ function writeJson(filePath, value) {}export function generateShadcnRegistryForTarget({target, outDir, ...options}) {- if (target !== 'canary') {+ if (target !== 'canary' && target !== 'latest') {fs.rmSync(outDir, {recursive: true, force: true});- return null;+ throw new Error(`Unsupported ShadCN registry target: ${String(target)}`);}return generateShadcnRegistry({outDir, ...options});}diff --git a/apps/docsite/src/__tests__/hidden-shadcn-production.test.ts b/apps/docsite/src/__tests__/hidden-shadcn-production.test.tsnew file mode 100644index 0000000000..0b6ba0c4bf--- /dev/null+++ b/apps/docsite/src/__tests__/hidden-shadcn-production.test.ts@@ -0,0 +1,290 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file Hidden production ShadCN discovery contract.+ *+ * Runs after latest-target data generation. The registry JSON must exist for+ * know-the-URL soak testing while every ordinary discovery surface stays clean.+ */++import fs from 'node:fs';+import path from 'node:path';+import {describe, expect, it, vi} from 'vitest';++vi.mock('next/cache', () => ({cacheLife: () => {}}));+const VERIFY_HIDDEN_PRODUCTION =+ process.env.ASTRYX_VERIFY_HIDDEN_PRODUCTION === '1';+if (VERIFY_HIDDEN_PRODUCTION) {+ process.env.NEXT_PUBLIC_DOCS_TARGET = 'latest';+}++const root = path.resolve(import.meta.dirname, '../..');+const [+ {default: robots},+ {default: sitemap},+ {GET: getLlmsTxt},+ {GET: getRss},+ {POST: postMcp},+ {CURRENT_TARGET},+ {components},+ {blocks},+ {templates},+ {docTopics},+ {blogPosts},+ {packages},+ {showcaseRegistry},+ {exampleRegistry},+ {shadcnRegistryIsPreview, shadcnRegistryOrigin},+ {flattenComponentSidebarEntries},+ {buildSearchPaletteItems},+] = await Promise.all([+ import('../app/robots'),+ import('../app/sitemap'),+ import('../app/llms.txt/route'),+ import('../app/rss.xml/route'),+ import('../app/mcp/route'),+ import('../lib/docsVersions'),+ import('../generated/componentRegistry'),+ import('../generated/blockRegistry'),+ import('../generated/templateRegistry'),+ import('../generated/docsRegistry'),+ import('../generated/blogRegistry'),+ import('../generated/packageRegistry'),+ import('../generated/showcaseRegistry'),+ import('../generated/exampleRegistry'),+ import('../generated/shadcnRegistry'),+ import('../components/componentSidebarData'),+ import('../components/searchPaletteData'),+]);++const FORBIDDEN_DISCOVERY_PATTERNS = [+ {+ label: 'registry URL',+ pattern: /\/shadcn(?:\/|["'`])/i,+ },+ {label: 'compatibility topic', pattern: /shadcn-compatibility/i},+ {label: 'launch post', pattern: /meet-astryx-from-shadcn/i},+ {+ label: 'registry install command',+ pattern: /\b(?:npx|pnpm dlx|yarn dlx|bunx)\s+shadcn(?:@|\s)/i,+ },+];++function expectNoRegistryDiscovery(value: unknown, surface: string): void {+ const serialized = JSON.stringify(value).replaceAll('\\"', '"');+ for (const {label, pattern} of FORBIDDEN_DISCOVERY_PATTERNS) {+ expect(serialized, `${surface} contains ${label}`).not.toMatch(pattern);+ }+}++function expectNoShadcnPromotion(value: unknown, surface: string): void {+ expectNoRegistryDiscovery(value, surface);+ expect(+ JSON.stringify(value),+ `${surface} contains generic ShadCN promotion`,+ ).not.toMatch(/shadcn/i);+}++interface McpResponse {+ error?: unknown;+ result?: {+ content?: Array<{type?: string; text?: string}>;+ };+}++function mcpPayload(response: McpResponse): unknown {+ expect(response.error).toBeUndefined();+ const textItems = (response.result?.content ?? []).filter(+ item => item.type === 'text' && typeof item.text === 'string',+ );+ expect(textItems).toHaveLength(1);+ return JSON.parse(textItems[0].text!);+}++function registryItemPaths(value: unknown, seen = new Set<object>()): string[] {+ if (value == null || typeof value !== 'object') {+ return [];+ }+ if (seen.has(value)) {+ return [];+ }+ seen.add(value);++ const paths: string[] = [];+ for (const [key, child] of Object.entries(value)) {+ if (key === 'registryItemPath' && typeof child === 'string') {+ paths.push(child);+ }+ paths.push(...registryItemPaths(child, seen));+ }+ return paths;+}++async function callMcpTool(+ name: string,+ args: Record<string, unknown>,+): Promise<McpResponse> {+ const response = await postMcp(+ new Request('https://astryx.atmeta.com/mcp', {+ method: 'POST',+ headers: {+ accept: 'application/json, text/event-stream',+ 'content-type': 'application/json',+ },+ body: JSON.stringify({+ jsonrpc: '2.0',+ id: 1,+ method: 'tools/call',+ params: {name, arguments: args},+ }),+ }),+ );+ const text = await response.text();+ expect(response.status, text).toBe(200);++ if (response.headers.get('content-type')?.includes('text/event-stream')) {+ return text+ .split('\n')+ .filter(line => line.startsWith('data: '))+ .map(line => JSON.parse(line.slice('data: '.length)))+ .at(-1) as McpResponse;+ }+ return JSON.parse(text) as McpResponse;+}++const describeHiddenProduction = VERIFY_HIDDEN_PRODUCTION+ ? describe+ : describe.skip;++describeHiddenProduction('hidden production ShadCN discovery', () => {+ it('rejects generic promotion while allowing migration-only references', () => {+ expect(() =>+ expectNoShadcnPromotion(+ {title: 'Install Astryx with ShadCN'},+ 'mutation probe',+ ),+ ).toThrow();+ expect(() =>+ expectNoRegistryDiscovery(+ {description: 'Migrate a Tailwind/shadcn app to Astryx.'},+ 'migration probe',+ ),+ ).not.toThrow();+ });++ it('serves the stable registry only to clients that know its URL', () => {+ expect(CURRENT_TARGET).toBe('latest');+ expect(shadcnRegistryIsPreview).toBe(false);+ expect(shadcnRegistryOrigin).toBe('https://astryx.atmeta.com/shadcn');++ const registry = JSON.parse(+ fs.readFileSync(path.join(root, 'public/shadcn/registry.json'), 'utf8'),+ );+ expect(registry.items.length).toBeGreaterThan(0);+ expect(robots().rules).toEqual({+ userAgent: '*',+ allow: '/',+ disallow: ['/playground/preview', '/shadcn/'],+ });+ });++ it('keeps generated docs, blog, navigation, and search indexes clean', () => {+ const sidebar = flattenComponentSidebarEntries().map(entry => ({+ href: entry.href,+ label: entry.displayName,+ }));+ const search = buildSearchPaletteItems({+ components,+ packages,+ docTopics,+ templates,+ }).map(item => ({+ id: item.id,+ label: item.label,+ group: item.auxiliaryData.group,+ keywords: item.auxiliaryData.keywords,+ }));++ expectNoShadcnPromotion(+ docTopics.map(topic => ({topic: topic.topic, title: topic.title})),+ 'docs navigation',+ );+ expectNoShadcnPromotion(+ blogPosts.map(post => ({slug: post.slug, title: post.title})),+ 'blog indexes',+ );+ expectNoShadcnPromotion(sidebar, 'component navigation');+ expectNoShadcnPromotion(search, 'global search');+ });++ it('keeps sitemap, RSS, and llms.txt clean', async () => {+ const sitemapEntries = await sitemap();+ const rss = await (await getRss()).text();+ const llmsTxt = await (await getLlmsTxt()).text();++ expectNoShadcnPromotion(sitemapEntries, 'sitemap');+ expectNoShadcnPromotion(rss, 'RSS');+ expectNoShadcnPromotion(llmsTxt, 'llms.txt');+ });++ it('exercises the real MCP tools without exposing registry promotion', async () => {+ const search = mcpPayload(+ await callMcpTool('search', {+ query: 'shadcn registry install',+ limit: 50,+ }),+ );+ expect(Array.isArray(search)).toBe(true);+ for (const result of search as Array<Record<string, unknown>>) {+ if (/shadcn/i.test(JSON.stringify(result))) {+ expect(result).toMatchObject({type: 'doc', topic: 'migration'});+ expectNoRegistryDiscovery(result, 'allowed MCP migration result');+ } else {+ expectNoShadcnPromotion(result, 'real MCP search result');+ }+ }++ for (const name of ['Button', 'settings']) {+ const result = mcpPayload(await callMcpTool('get', {name}));+ expectNoShadcnPromotion(result, `real MCP get(${name}) response`);+ }++ const migration = mcpPayload(await callMcpTool('get', {name: 'migration'}));+ expect(JSON.stringify(migration)).toMatch(/shadcn/i);+ expectNoRegistryDiscovery(migration, 'allowed MCP migration guide');++ expectNoShadcnPromotion(+ {components, blocks, templates},+ 'complete MCP component and template registries',+ );+ const migrationTopic = docTopics.find(topic => topic.topic === 'migration');+ expect(migrationTopic).toBeDefined();+ expectNoRegistryDiscovery(migrationTopic, 'allowed migration topic');+ expectNoShadcnPromotion(+ docTopics.filter(topic => topic.topic !== 'migration'),+ 'all other MCP doc topics',+ );+ });++ it('omits install paths from component, block, example, and template UI data', () => {+ const componentUi = fs.readFileSync(+ path.join(+ root,+ 'src/components/component-detail/ComponentDetailClient.tsx',+ ),+ 'utf8',+ );+ const templateUi = fs.readFileSync(+ path.join(root, 'src/components/TemplatePreviewDialog.tsx'),+ 'utf8',+ );++ expect(componentUi).toContain(+ "CURRENT_TARGET === 'canary' && pkg && pkgVersion",+ );+ expect(templateUi).toContain("CURRENT_TARGET === 'canary' && (");+ expect(+ registryItemPaths({blocks, templates, showcaseRegistry, exampleRegistry}),+ ).toEqual([]);+ });+});diff --git a/apps/docsite/src/__tests__/robots.test.ts b/apps/docsite/src/__tests__/robots.test.tsnew file mode 100644index 0000000000..7187b104b5--- /dev/null+++ b/apps/docsite/src/__tests__/robots.test.ts@@ -0,0 +1,14 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, expect, it} from 'vitest';+import robots from '../app/robots';++describe('docsite robots policy', () => {+ it('keeps the hidden registry out of crawler discovery', () => {+ expect(robots().rules).toEqual({+ userAgent: '*',+ allow: '/',+ disallow: ['/playground/preview', '/shadcn/'],+ });+ });+});diff --git a/apps/docsite/src/app/robots.ts b/apps/docsite/src/app/robots.tsindex ce4b54fa49..c6c12c8836 100644--- a/apps/docsite/src/app/robots.ts+++ b/apps/docsite/src/app/robots.ts@@ -5,7 +5,9 @@** Next.js serves this at /robots.txt. It allows full crawling and advertises* the dynamic sitemap so search engines can discover every page the docsite- * generates. Uses the same SITE_URL origin as the sitemap and metadata.+ * generates. The raw compatibility registry remains intentionally unlinked and+ * disallowed from crawlers during soak testing. Uses the same SITE_URL origin+ * as the sitemap and metadata.** @output MetadataRoute.Robots consumed by Next.js to emit /robots.txt*/@@ -18,8 +20,8 @@ export default function robots(): MetadataRoute.Robots {rules: {userAgent: '*',allow: '/',- // The playground preview frame is a render target, not indexable content.- disallow: '/playground/preview',+ // The preview frame and hidden registry are machine surfaces, not pages.+ disallow: ['/playground/preview', '/shadcn/'],},sitemap: new URL('/sitemap.xml', SITE_URL).toString(),};diff --git a/internal/shadcn-registry/generate-shadcn-registry.test.mjs b/internal/shadcn-registry/generate-shadcn-registry.test.mjsindex 8fbc5aa50f..1052e36ab5 100644--- a/internal/shadcn-registry/generate-shadcn-registry.test.mjs+++ b/internal/shadcn-registry/generate-shadcn-registry.test.mjs@@ -315,16 +315,47 @@ describe('buildShadcnRegistry', () => {}});- it('removes stale compatibility output for non-canary targets', () => {+ it('generates exact-version compatibility output for production', () => {const root = mkdtempSync(path.join(tmpdir(), 'astryx-shadcn-production-'));const outDir = path.join(root, 'shadcn');try {mkdirSync(outDir, {recursive: true});writeFileSync(path.join(outDir, 'stale.json'), '{}\n');+ const result = generateShadcnRegistryForTarget({+ target: 'latest',+ outDir,+ ...fixture(),+ });+ expect(result.total).toBe(3);+ expect(existsSync(path.join(outDir, 'stale.json'))).toBe(false);+ const component = JSON.parse(+ readFileSync(path.join(outDir, 'components', 'button.json'), 'utf8'),+ );+ expect(component.dependencies).toEqual([+ '@astryxdesign/[email protected]',+ '@stylexjs/[email protected]',+ ]);expect(- generateShadcnRegistryForTarget({target: 'latest', outDir}),- ).toBeNull();+ component.dependencies.some(dependency =>+ dependency.includes('@canary'),+ ),+ ).toBe(false);+ } finally {+ rmSync(root, {recursive: true, force: true});+ }+ });++ it('fails closed for an unknown registry target', () => {+ const root = mkdtempSync(path.join(tmpdir(), 'astryx-shadcn-unknown-'));+ const outDir = path.join(root, 'shadcn');+ try {+ mkdirSync(outDir, {recursive: true});+ writeFileSync(path.join(outDir, 'stale.json'), '{}\n');++ expect(() =>+ generateShadcnRegistryForTarget({target: 'unknown', outDir}),+ ).toThrow(/Unsupported ShadCN registry target/);expect(existsSync(outDir)).toBe(false);} finally {rmSync(root, {recursive: true, force: true});diff --git a/internal/shadcn-registry/verify-full-catalog.mjs b/internal/shadcn-registry/verify-full-catalog.mjsindex a37d7c46a1..9c458202a6 100644--- a/internal/shadcn-registry/verify-full-catalog.mjs+++ b/internal/shadcn-registry/verify-full-catalog.mjs@@ -6,8 +6,9 @@* @description Installs every generated Astryx registry item through the pinned* ShadCN client in TypeScript and JavaScript modes, verifies exact written* bytes and dependencies, then compiles every installed source file against- * the current Astryx package exports.- * @input A generated canary registry under apps/docsite/public/shadcn.+ * current local exports or the exact published packages named by production.+ * @input A generated preview or hidden production registry under+ * apps/docsite/public/shadcn.* @output A clean-consumer proof for every canonical item and alias route.* @position Required CI contract for the public ShadCN compatibility surface.*/@@ -48,6 +49,8 @@ const docsiteRequire = createRequire(const SHADCN_BIN = docsiteRequire.resolve('shadcn');const TYPESCRIPT_BIN = docsiteRequire.resolve('typescript/bin/tsc');const KEEP_TEMP = process.env.ASTRYX_KEEP_SHADCN_MATRIX === '1';+const USE_PUBLISHED_PACKAGES =+ process.env.ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES === '1';const MAX_COMMAND_OUTPUT = 16 * 1024 * 1024;const COPIED_KINDS = new Set(['showcase', 'example', 'block', 'page']);@@ -394,6 +397,15 @@ function writeConsumer(project, items, packageDirs, {tsx}) {const name = packageName(spec);dependencyNames.add(name);if (!name.startsWith('@astryxdesign/')) return spec;+ if (USE_PUBLISHED_PACKAGES) {+ const version = spec.slice(name.length + 1);+ if (!/^\d+\.\d+\.\d+$/.test(version)) {+ fail(+ `${item.name} production dependency ${spec} is not an exact release`,+ );+ }+ return spec;+ }const directory = packageDirs.get(name);if (directory == null) {fail(`${item.name} depends on unresolved workspace package ${name}`);@@ -592,7 +604,7 @@ async function compileSources(project, sources) {async function main() {const startedAt = Date.now();const catalog = loadCatalog();- const packageDirs = localPackageDirs();+ const packageDirs = USE_PUBLISHED_PACKAGES ? null : localPackageDirs();const results = [];for (const tsx of [true, false]) {diff --git a/internal/shadcn-registry/verify-production-gate.mjs b/internal/shadcn-registry/verify-production-gate.mjsindex 1bfdc522cd..b4b7b92e1e 100644--- a/internal/shadcn-registry/verify-production-gate.mjs+++ b/internal/shadcn-registry/verify-production-gate.mjs@@ -3,11 +3,11 @@/*** @file verify-production-gate.mjs- * @description Proves a non-canary docsite target removes stale ShadCN output- * without downloading the currently published package catalog.+ * @description Proves the production target emits an unlinked ShadCN registry+ * with exact released dependencies, replacing stale output deterministically.* @input The target-aware registry generator used by generate-data.mjs.- * @output A network-free assertion that production cannot expose `/shadcn`.- * @position Required CI guard for the staged compatibility launch.+ * @output A network-free assertion for the hidden production registry contract.+ * @position Required CI guard for the staged compatibility soak.*/import assert from 'node:assert/strict';@@ -27,11 +27,46 @@ try {const result = generateShadcnRegistryForTarget({target: 'latest',outDir,+ packages: [+ {name: '@astryxdesign/cli', version: '0.6.0'},+ {name: '@astryxdesign/core', version: '0.5.2'},+ ],+ allComponents: {+ '@astryxdesign/core': [+ {+ name: 'Button',+ displayName: 'Button',+ description: 'Runs an action.',+ importPath: '@astryxdesign/core/Button',+ hidden: false,+ params: null,+ },+ ],+ },+ blocks: [],+ templates: [],+ externalDependencySpecs: {+ '@stylexjs/stylex': '@stylexjs/[email protected]',+ },});- assert.equal(result, null);- assert.equal(fs.existsSync(outDir), false);- console.log('Verified production excludes ShadCN compatibility output.');+ assert.equal(result.total, 1);+ assert.equal(fs.existsSync(path.join(outDir, 'stale.json')), false);+ assert.equal(fs.existsSync(path.join(outDir, 'registry.json')), true);+ const item = JSON.parse(+ fs.readFileSync(path.join(outDir, 'components', 'button.json'), 'utf8'),+ );+ assert.deepEqual(item.dependencies, [+ '@astryxdesign/[email protected]',+ '@stylexjs/[email protected]',+ ]);+ assert.equal(+ item.dependencies.some(dependency => dependency.includes('@canary')),+ false,+ );+ console.log(+ 'Verified production emits hidden ShadCN routes with exact release dependencies.',+ );} finally {fs.rmSync(root, {recursive: true, force: true});}