UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
fix: registry example dependency drift checks (#917)
Yeom-JinHo63139e6f2617
diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.ymlindex fad1437a..d90c2100 100644--- a/.github/workflows/code-check.yml+++ b/.github/workflows/code-check.yml@@ -115,6 +115,42 @@ jobs:- run: pnpm typecheck+ registry-deps:+ runs-on: ubuntu-latest+ name: pnpm registry-deps:check+ steps:+ - uses: actions/checkout@v6+ with:+ fetch-depth: 0++ - name: Install Node.js+ uses: actions/setup-node@v3+ with:+ node-version: 22++ - uses: pnpm/action-setup@v4+ name: Install pnpm+ id: pnpm-install+ with:+ version: 9.15.0+ run_install: false++ - name: Get pnpm store directory+ id: pnpm-cache+ run: |+ echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT+ - uses: actions/cache@v3+ name: Setup pnpm cache+ with:+ path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}+ restore-keys: |+ ${{ runner.os }}-pnpm-store-+ - name: Install dependencies+ run: pnpm install++ - run: pnpm registry-deps:check+registry-drift:runs-on: ubuntu-latestname: registry artifact drift checkdiff --git a/apps/www/package.json b/apps/www/package.jsonindex 23825bda..bb7e8bbb 100644--- a/apps/www/package.json+++ b/apps/www/package.json@@ -7,6 +7,8 @@"preinstall": "npx only-allow pnpm","postinstall": "fumadocs-mdx","dev": "next dev",+ "registry-deps:check": "npx tsx ./scripts/sync-example-registry-dependencies.mts --check",+ "registry-deps:fix": "npx tsx ./scripts/sync-example-registry-dependencies.mts --fix","prebuild": "pnpm build:registry","build": "next build","build:registry": "npx tsx ./scripts/build-registry.mts && prettier --log-level silent --write \"registry/**/*.{ts,tsx,mdx}\" --cache",@@ -17,7 +19,7 @@"lint:fix": "eslint --fix .","format:fix": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache","format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache",- "check": "pnpm lint && pnpm typecheck && pnpm format:check"+ "check": "pnpm lint && pnpm typecheck && pnpm format:check && pnpm registry-deps:check"},"dependencies": {"@hookform/resolvers": "^5.2.2",diff --git a/apps/www/public/llms-full.txt b/apps/www/public/llms-full.txtindex f1e7ee98..40a9f966 100644--- a/apps/www/public/llms-full.txt+++ b/apps/www/public/llms-full.txt@@ -351,6 +351,129 @@ export const AnimatedBeam: React.FC<AnimatedBeamProps> = ({}+===== EXAMPLE: bento-demo =====+Title: Bento Demo++--- file: example/bento-demo.tsx ---+import { CalendarIcon, FileTextIcon } from "@radix-ui/react-icons"+import { BellIcon, Share2Icon } from "lucide-react"++import { cn } from "@/lib/utils"+import { Calendar } from "@/components/ui/calendar"+import AnimatedBeamMultipleOutputDemo from "@/registry/example/animated-beam-multiple-outputs"+import AnimatedListDemo from "@/registry/example/animated-list-demo"+import { BentoCard, BentoGrid } from "@/registry/magicui/bento-grid"+import { Marquee } from "@/registry/magicui/marquee"++const files = [+ {+ name: "bitcoin.pdf",+ body: "Bitcoin is a cryptocurrency invented in 2008 by an unknown person or group of people using the name Satoshi Nakamoto.",+ },+ {+ name: "finances.xlsx",+ body: "A spreadsheet or worksheet is a file made of rows and columns that help sort data, arrange data easily, and calculate numerical data.",+ },+ {+ name: "logo.svg",+ body: "Scalable Vector Graphics is an Extensible Markup Language-based vector image format for two-dimensional graphics with support for interactivity and animation.",+ },+ {+ name: "keys.gpg",+ body: "GPG keys are used to encrypt and decrypt email, files, directories, and whole disk partitions and to authenticate messages.",+ },+ {+ name: "seed.txt",+ body: "A seed phrase, seed recovery phrase or backup seed phrase is a list of words which store all the information needed to recover Bitcoin funds on-chain.",+ },+]++const features = [+ {+ Icon: FileTextIcon,+ name: "Save your files",+ description: "We automatically save your files as you type.",+ href: "#",+ cta: "Learn more",+ className: "col-span-3 lg:col-span-1",+ background: (+ <Marquee+ pauseOnHover+ className="absolute top-10 [mask-image:linear-gradient(to_top,transparent_40%,#000_100%)] [--duration:20s]"+ >+ {files.map((f, idx) => (+ <figure+ key={idx}+ className={cn(+ "relative w-32 cursor-pointer overflow-hidden rounded-xl border p-4",+ "border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05]",+ "dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]",+ "transform-gpu blur-[1px] transition-all duration-300 ease-out hover:blur-none"+ )}+ >+ <div className="flex flex-row items-center gap-2">+ <div className="flex flex-col">+ <figcaption className="text-sm font-medium dark:text-white">+ {f.name}+ </figcaption>+ </div>+ </div>+ <blockquote className="mt-2 text-xs">{f.body}</blockquote>+ </figure>+ ))}+ </Marquee>+ ),+ },+ {+ Icon: BellIcon,+ name: "Notifications",+ description: "Get notified when something happens.",+ href: "#",+ cta: "Learn more",+ className: "col-span-3 lg:col-span-2",+ background: (+ <AnimatedListDemo className="absolute top-4 right-2 h-[300px] w-full scale-75 border-none [mask-image:linear-gradient(to_top,transparent_10%,#000_100%)] transition-all duration-300 ease-out group-hover:scale-90" />+ ),+ },+ {+ Icon: Share2Icon,+ name: "Integrations",+ description: "Supports 100+ integrations and counting.",+ href: "#",+ cta: "Learn more",+ className: "col-span-3 lg:col-span-2",+ background: (+ <AnimatedBeamMultipleOutputDemo className="absolute top-4 right-2 h-[300px] border-none [mask-image:linear-gradient(to_top,transparent_10%,#000_100%)] transition-all duration-300 ease-out group-hover:scale-105" />+ ),+ },+ {+ Icon: CalendarIcon,+ name: "Calendar",+ description: "Use the calendar to filter your files by date.",+ className: "col-span-3 lg:col-span-1",+ href: "#",+ cta: "Learn more",+ background: (+ <Calendar+ mode="single"+ selected={new Date(2022, 4, 11, 0, 0, 0)}+ className="absolute top-10 right-0 origin-top scale-75 rounded-md border [mask-image:linear-gradient(to_top,transparent_40%,#000_100%)] transition-all duration-300 ease-out group-hover:scale-90"+ />+ ),+ },+]++export default function BentoDemo() {+ return (+ <BentoGrid>+ {features.map((feature, idx) => (+ <BentoCard key={idx} {...feature} />+ ))}+ </BentoGrid>+ )+}++===== EXAMPLE: animated-beam-demo =====Title: Animated Beam Demo@@ -2624,6 +2747,129 @@ export const AnimatedList = React.memo(AnimatedList.displayName = "AnimatedList"+===== EXAMPLE: bento-demo =====+Title: Bento Demo++--- file: example/bento-demo.tsx ---+import { CalendarIcon, FileTextIcon } from "@radix-ui/react-icons"+import { BellIcon, Share2Icon } from "lucide-react"++import { cn } from "@/lib/utils"+import { Calendar } from "@/components/ui/calendar"+import AnimatedBeamMultipleOutputDemo from "@/registry/example/animated-beam-multiple-outputs"+import AnimatedListDemo from "@/registry/example/animated-list-demo"+import { BentoCard, BentoGrid } from "@/registry/magicui/bento-grid"+import { Marquee } from "@/registry/magicui/marquee"++const files = [+ {+ name: "bitcoin.pdf",+ body: "Bitcoin is a cryptocurrency invented in 2008 by an unknown person or group of people using the name Satoshi Nakamoto.",+ },+ {+ name: "finances.xlsx",+ body: "A spreadsheet or worksheet is a file made of rows and columns that help sort data, arrange data easily, and calculate numerical data.",+ },+ {+ name: "logo.svg",+ body: "Scalable Vector Graphics is an Extensible Markup Language-based vector image format for two-dimensional graphics with support for interactivity and animation.",+ },+ {+ name: "keys.gpg",+ body: "GPG keys are used to encrypt and decrypt email, files, directories, and whole disk partitions and to authenticate messages.",+ },+ {+ name: "seed.txt",+ body: "A seed phrase, seed recovery phrase or backup seed phrase is a list of words which store all the information needed to recover Bitcoin funds on-chain.",+ },+]++const features = [+ {+ Icon: FileTextIcon,+ name: "Save your files",+ description: "We automatically save your files as you type.",+ href: "#",+ cta: "Learn more",+ className: "col-span-3 lg:col-span-1",+ background: (+ <Marquee+ pauseOnHover+ className="absolute top-10 [mask-image:linear-gradient(to_top,transparent_40%,#000_100%)] [--duration:20s]"+ >+ {files.map((f, idx) => (+ <figure+ key={idx}+ className={cn(+ "relative w-32 cursor-pointer overflow-hidden rounded-xl border p-4",+ "border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05]",+ "dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]",+ "transform-gpu blur-[1px] transition-all duration-300 ease-out hover:blur-none"+ )}+ >+ <div className="flex flex-row items-center gap-2">+ <div className="flex flex-col">+ <figcaption className="text-sm font-medium dark:text-white">+ {f.name}+ </figcaption>+ </div>+ </div>+ <blockquote className="mt-2 text-xs">{f.body}</blockquote>+ </figure>+ ))}+ </Marquee>+ ),+ },+ {+ Icon: BellIcon,+ name: "Notifications",+ description: "Get notified when something happens.",+ href: "#",+ cta: "Learn more",+ className: "col-span-3 lg:col-span-2",+ background: (+ <AnimatedListDemo className="absolute top-4 right-2 h-[300px] w-full scale-75 border-none [mask-image:linear-gradient(to_top,transparent_10%,#000_100%)] transition-all duration-300 ease-out group-hover:scale-90" />+ ),+ },+ {+ Icon: Share2Icon,+ name: "Integrations",+ description: "Supports 100+ integrations and counting.",+ href: "#",+ cta: "Learn more",+ className: "col-span-3 lg:col-span-2",+ background: (+ <AnimatedBeamMultipleOutputDemo className="absolute top-4 right-2 h-[300px] border-none [mask-image:linear-gradient(to_top,transparent_10%,#000_100%)] transition-all duration-300 ease-out group-hover:scale-105" />+ ),+ },+ {+ Icon: CalendarIcon,+ name: "Calendar",+ description: "Use the calendar to filter your files by date.",+ className: "col-span-3 lg:col-span-1",+ href: "#",+ cta: "Learn more",+ background: (+ <Calendar+ mode="single"+ selected={new Date(2022, 4, 11, 0, 0, 0)}+ className="absolute top-10 right-0 origin-top scale-75 rounded-md border [mask-image:linear-gradient(to_top,transparent_40%,#000_100%)] transition-all duration-300 ease-out group-hover:scale-90"+ />+ ),+ },+]++export default function BentoDemo() {+ return (+ <BentoGrid>+ {features.map((feature, idx) => (+ <BentoCard key={idx} {...feature} />+ ))}+ </BentoGrid>+ )+}++===== EXAMPLE: animated-list-demo =====Title: Animated List Demo@@ -3929,6 +4175,43 @@ export const ClientTweetCard = ({}+===== EXAMPLE: tweet-card-demo =====+Title: Tweet Card Demo++--- file: example/tweet-card-demo.tsx ---+import { ClientTweetCard } from "@/registry/magicui/client-tweet-card"++/**+ * <TweetCard /> (Server Side Only)+ * <ClientTweetCard /> (Client Side Only)+ */+export default function TweetDemo() {+ return <ClientTweetCard id="1668408059125702661" />+}+++===== EXAMPLE: tweet-card-images =====+Title: Tweet Card Images++--- file: example/tweet-card-images.tsx ---+import { ClientTweetCard } from "@/registry/magicui/client-tweet-card"++export default function TweetImages() {+ return <ClientTweetCard id="1678577280489234432" className="shadow-2xl" />+}+++===== EXAMPLE: tweet-card-meta-preview =====+Title: Tweet Card Meta Preview++--- file: example/tweet-card-meta-preview.tsx ---+import { ClientTweetCard } from "@/registry/magicui/client-tweet-card"++export default function TweetMetaPreview() {+ return <ClientTweetCard id="1675849118445436929" className="shadow-2xl" />+}++===== COMPONENT: code-comparison =====Title: Code Comparisondiff --git a/apps/www/public/r/bento-demo.json b/apps/www/public/r/bento-demo.jsonindex 3104e8ec..9614167e 100644--- a/apps/www/public/r/bento-demo.json+++ b/apps/www/public/r/bento-demo.json@@ -12,8 +12,10 @@"calendar","@magicui/marquee","@magicui/bento-grid",- "@magicui/animated-list-demo",- "@magicui/animated-beam-multiple-outputs"+ "@magicui/animated-beam",+ "@magicui/animated-list",+ "@magicui/animated-beam-multiple-outputs",+ "@magicui/animated-list-demo"],"files": [{diff --git a/apps/www/public/r/registry.json b/apps/www/public/r/registry.jsonindex 9a498d52..1a7c6ec9 100644--- a/apps/www/public/r/registry.json+++ b/apps/www/public/r/registry.json@@ -1814,6 +1814,7 @@"title": "Tweet Card Demo","description": "Example showing a tweet card with author info.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1829,6 +1830,7 @@"title": "Tweet Card Images","description": "Example showing a tweet card with images.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1844,6 +1846,7 @@"title": "Tweet Card Meta Preview","description": "Example showing a tweet card with meta preview.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1881,8 +1884,10 @@"calendar","@magicui/marquee","@magicui/bento-grid",- "@magicui/animated-list-demo",- "@magicui/animated-beam-multiple-outputs"+ "@magicui/animated-beam",+ "@magicui/animated-list",+ "@magicui/animated-beam-multiple-outputs",+ "@magicui/animated-list-demo"],"files": [{diff --git a/apps/www/public/r/tweet-card-demo.json b/apps/www/public/r/tweet-card-demo.jsonindex 69077321..097273a1 100644--- a/apps/www/public/r/tweet-card-demo.json+++ b/apps/www/public/r/tweet-card-demo.json@@ -5,6 +5,7 @@"title": "Tweet Card Demo","description": "Example showing a tweet card with author info.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [diff --git a/apps/www/public/r/tweet-card-images.json b/apps/www/public/r/tweet-card-images.jsonindex 0d11ed24..f011c997 100644--- a/apps/www/public/r/tweet-card-images.json+++ b/apps/www/public/r/tweet-card-images.json@@ -5,6 +5,7 @@"title": "Tweet Card Images","description": "Example showing a tweet card with images.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [diff --git a/apps/www/public/r/tweet-card-meta-preview.json b/apps/www/public/r/tweet-card-meta-preview.jsonindex aa91cb91..f3331ee4 100644--- a/apps/www/public/r/tweet-card-meta-preview.json+++ b/apps/www/public/r/tweet-card-meta-preview.json@@ -5,6 +5,7 @@"title": "Tweet Card Meta Preview","description": "Example showing a tweet card with meta preview.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [diff --git a/apps/www/public/registry.json b/apps/www/public/registry.jsonindex 9a498d52..1a7c6ec9 100644--- a/apps/www/public/registry.json+++ b/apps/www/public/registry.json@@ -1814,6 +1814,7 @@"title": "Tweet Card Demo","description": "Example showing a tweet card with author info.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1829,6 +1830,7 @@"title": "Tweet Card Images","description": "Example showing a tweet card with images.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1844,6 +1846,7 @@"title": "Tweet Card Meta Preview","description": "Example showing a tweet card with meta preview.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1881,8 +1884,10 @@"calendar","@magicui/marquee","@magicui/bento-grid",- "@magicui/animated-list-demo",- "@magicui/animated-beam-multiple-outputs"+ "@magicui/animated-beam",+ "@magicui/animated-list",+ "@magicui/animated-beam-multiple-outputs",+ "@magicui/animated-list-demo"],"files": [{diff --git a/apps/www/registry.json b/apps/www/registry.jsonindex 9a498d52..1a7c6ec9 100644--- a/apps/www/registry.json+++ b/apps/www/registry.json@@ -1814,6 +1814,7 @@"title": "Tweet Card Demo","description": "Example showing a tweet card with author info.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1829,6 +1830,7 @@"title": "Tweet Card Images","description": "Example showing a tweet card with images.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1844,6 +1846,7 @@"title": "Tweet Card Meta Preview","description": "Example showing a tweet card with meta preview.","registryDependencies": [+ "@magicui/client-tweet-card","@magicui/tweet-card"],"files": [@@ -1881,8 +1884,10 @@"calendar","@magicui/marquee","@magicui/bento-grid",- "@magicui/animated-list-demo",- "@magicui/animated-beam-multiple-outputs"+ "@magicui/animated-beam",+ "@magicui/animated-list",+ "@magicui/animated-beam-multiple-outputs",+ "@magicui/animated-list-demo"],"files": [{diff --git a/apps/www/registry/__index__.tsx b/apps/www/registry/__index__.tsxindex ad873423..236425b6 100644--- a/apps/www/registry/__index__.tsx+++ b/apps/www/registry/__index__.tsx@@ -1804,7 +1804,7 @@ export const Index: Record<string, any> = {name: "tweet-card-demo",description: "Example showing a tweet card with author info.",type: "registry:example",- registryDependencies: ["@magicui/tweet-card"],+ registryDependencies: ["@magicui/client-tweet-card","@magicui/tweet-card"],files: [{path: "registry/example/tweet-card-demo.tsx",type: "registry:example",@@ -1821,7 +1821,7 @@ export const Index: Record<string, any> = {name: "tweet-card-images",description: "Example showing a tweet card with images.",type: "registry:example",- registryDependencies: ["@magicui/tweet-card"],+ registryDependencies: ["@magicui/client-tweet-card","@magicui/tweet-card"],files: [{path: "registry/example/tweet-card-images.tsx",type: "registry:example",@@ -1838,7 +1838,7 @@ export const Index: Record<string, any> = {name: "tweet-card-meta-preview",description: "Example showing a tweet card with meta preview.",type: "registry:example",- registryDependencies: ["@magicui/tweet-card"],+ registryDependencies: ["@magicui/client-tweet-card","@magicui/tweet-card"],files: [{path: "registry/example/tweet-card-meta-preview.tsx",type: "registry:example",@@ -1872,7 +1872,7 @@ export const Index: Record<string, any> = {name: "bento-demo",description: "Example showing a bento grid layout for showcasing features.",type: "registry:example",- registryDependencies: ["button","calendar","@magicui/marquee","@magicui/bento-grid","@magicui/animated-list-demo","@magicui/animated-beam-multiple-outputs"],+ registryDependencies: ["button","calendar","@magicui/marquee","@magicui/bento-grid","@magicui/animated-beam","@magicui/animated-list","@magicui/animated-beam-multiple-outputs","@magicui/animated-list-demo"],files: [{path: "registry/example/bento-demo.tsx",type: "registry:example",diff --git a/apps/www/registry/registry-examples.ts b/apps/www/registry/registry-examples.tsindex e99cb254..9ea1736e 100644--- a/apps/www/registry/registry-examples.ts+++ b/apps/www/registry/registry-examples.ts@@ -484,7 +484,7 @@ export const examples: Registry["items"] = [type: "registry:example",title: "Tweet Card Demo",description: "Example showing a tweet card with author info.",- registryDependencies: ["@magicui/tweet-card"],+ registryDependencies: ["@magicui/client-tweet-card", "@magicui/tweet-card"],files: [{path: "example/tweet-card-demo.tsx",@@ -497,7 +497,7 @@ export const examples: Registry["items"] = [type: "registry:example",title: "Tweet Card Images",description: "Example showing a tweet card with images.",- registryDependencies: ["@magicui/tweet-card"],+ registryDependencies: ["@magicui/client-tweet-card", "@magicui/tweet-card"],files: [{path: "example/tweet-card-images.tsx",@@ -510,7 +510,7 @@ export const examples: Registry["items"] = [type: "registry:example",title: "Tweet Card Meta Preview",description: "Example showing a tweet card with meta preview.",- registryDependencies: ["@magicui/tweet-card"],+ registryDependencies: ["@magicui/client-tweet-card", "@magicui/tweet-card"],files: [{path: "example/tweet-card-meta-preview.tsx",@@ -541,8 +541,10 @@ export const examples: Registry["items"] = ["calendar","@magicui/marquee","@magicui/bento-grid",- "@magicui/animated-list-demo",+ "@magicui/animated-beam",+ "@magicui/animated-list","@magicui/animated-beam-multiple-outputs",+ "@magicui/animated-list-demo",],dependencies: ["@radix-ui/react-icons"],files: [diff --git a/apps/www/scripts/build-registry.mts b/apps/www/scripts/build-registry.mtsindex e9241a85..4ecdcbf9 100644--- a/apps/www/scripts/build-registry.mts+++ b/apps/www/scripts/build-registry.mts@@ -5,9 +5,17 @@ import { rimraf } from "rimraf"import { Registry } from "shadcn/schema"import { siteConfig } from "../config/site"-import { registry } from "../registry/index"+import {+ assertNoMissingExampleFiles,+ syncExampleRegistryDependencies,+} from "./sync-example-registry-dependencies.mts"++async function loadRegistry(): Promise<Registry> {+ const { registry } = await import("../registry/index.ts")+ return registry+}-async function buildRegistryIndex() {+async function buildRegistryIndex(registry: Registry) {let index = `/* eslint-disable @typescript-eslint/ban-ts-comment *//* eslint-disable @typescript-eslint/no-explicit-any */// @ts-nocheck@@ -64,7 +72,7 @@ export const Index: Record<string, any> = {`await fs.writeFile(path.join(process.cwd(), "registry/__index__.tsx"), index)}-async function buildRegistryJsonFile() {+async function buildRegistryJsonFile(registry: Registry) {// 1. Fix the path for registry items.const fixedRegistry = {...registry,@@ -136,7 +144,7 @@ async function readRegistryFilesContents(item: RegistryItem): Promise<string> {return contents.filter(Boolean).join("\n")}-function getComponentExamples() {+function getComponentExamples(registry: Registry) {const examplesByComponent = new Map<string, string[]>()registry.items@@ -156,7 +164,7 @@ function getComponentExamples() {return examplesByComponent}-async function generateLlmsContent() {+async function generateLlmsContent(registry: Registry) {const components = registry.items.filter((item) => item.type === "registry:ui").sort((a, b) => a.name.localeCompare(b.name))@@ -206,6 +214,7 @@ async function generateLlmsContent() {}async function generateLlmsFullContent(+ registry: Registry,examplesByComponent: Map<string, string[]>) {const components = registry.items@@ -249,12 +258,12 @@ async function generateLlmsFullContent(return componentContents.join("\n\n\n")}-async function buildLlmsFiles() {- const examplesByComponent = getComponentExamples()+async function buildLlmsFiles(registry: Registry) {+ const examplesByComponent = getComponentExamples(registry)const [minContent, fullContent] = await Promise.all([- generateLlmsContent(),- generateLlmsFullContent(examplesByComponent),+ generateLlmsContent(registry),+ generateLlmsFullContent(registry, examplesByComponent),])const publicDir = path.join(process.cwd(), "public")@@ -281,16 +290,23 @@ async function buildRegistry() {}try {+ console.log("🔎 Syncing registry example dependencies...")+ const syncIssues = await syncExampleRegistryDependencies({ mode: "fix" })+ assertNoMissingExampleFiles(syncIssues)+ console.log("✅ Registry example dependencies synced")++ const registry = await loadRegistry()+console.log("��️ Building registry/__index__.tsx...")- await buildRegistryIndex()+ await buildRegistryIndex(registry)console.log("✅ Registry index built successfully")console.log("💅 Building registry.json...")- await buildRegistryJsonFile()+ await buildRegistryJsonFile(registry)console.log("✅ Registry JSON file built successfully")console.log("🧠 Building llms files...")- await buildLlmsFiles()+ await buildLlmsFiles(registry)console.log("✅ llms-min.txt and llms.txt built successfully")console.log("🏗️ Building registry...")diff --git a/apps/www/scripts/sync-example-registry-dependencies.mts b/apps/www/scripts/sync-example-registry-dependencies.mtsnew file mode 100644index 00000000..951d0ebe--- /dev/null+++ b/apps/www/scripts/sync-example-registry-dependencies.mts@@ -0,0 +1,689 @@+import { promises as fs } from "node:fs"+import path from "node:path"+import process from "node:process"+import { fileURLToPath } from "node:url"++import { CodeBlockWriter, Node, Project, SyntaxKind } from "ts-morph"++const MAGICUI_IMPORT_PREFIX = "@/registry/magicui/"+const MAGICUI_PACKAGE_PREFIX = "@magicui/"+const EXAMPLE_IMPORT_PREFIX = "@/registry/example/"+const REGISTRY_IMPORT_PREFIX = "@/registry/"++const scriptPath = fileURLToPath(import.meta.url)+const appRoot = path.resolve(path.dirname(scriptPath), "..")+const registryRoot = path.join(appRoot, "registry")+const registryExamplesPath = path.join(registryRoot, "registry-examples.ts")+const registryUiPath = path.join(registryRoot, "registry-ui.ts")++type SyncMode = "check" | "fix"++type SyncOptions = {+ mode: SyncMode+}++type ExampleIssue = {+ exampleName: string+ exampleFiles: string[]+ extraDependencies: string[]+ missingDependencies: string[]+ missingFiles: string[]+}++// Detect direct CLI execution so this module can also be imported by builds.+function isMainModule() {+ return process.argv[1]+ ? path.resolve(process.argv[1]) === scriptPath+ : false+}++// Read plain string values from string literals and template literals.+function getStringLiteralValue(node: Node | undefined) {+ if (!node) {+ return null+ }++ if (+ Node.isStringLiteral(node) ||+ Node.isNoSubstitutionTemplateLiteral(node)+ ) {+ return node.getLiteralText()+ }++ return null+}++// Resolve a named object property when it exists as a simple assignment.+function getObjectPropertyAssignment(+ node: Node,+ propertyName: string+): Node | undefined {+ if (!Node.isObjectLiteralExpression(node)) {+ return undefined+ }++ const property = node.getProperty(propertyName)+ if (!property || !Node.isPropertyAssignment(property)) {+ return undefined+ }++ return property+}++// Extract string items from array properties like registryDependencies.+function getStringArrayValues(node: Node | undefined) {+ if (!node || !Node.isPropertyAssignment(node)) {+ return []+ }++ const initializer = node.getInitializer()+ if (!initializer || !Node.isArrayLiteralExpression(initializer)) {+ return []+ }++ return initializer+ .getElements()+ .flatMap((element) => {+ const value = getStringLiteralValue(element)+ return value ? [value] : []+ })+}++// Collect referenced .tsx files from an example's files array.+function getExampleFilePaths(node: Node) {+ const filesProperty = getObjectPropertyAssignment(node, "files")+ if (!filesProperty || !Node.isPropertyAssignment(filesProperty)) {+ return []+ }++ const initializer = filesProperty.getInitializer()+ if (!initializer || !Node.isArrayLiteralExpression(initializer)) {+ return []+ }++ return initializer+ .getElements()+ .flatMap((element) => {+ const stringPath = getStringLiteralValue(element)+ if (stringPath) {+ return [stringPath]+ }++ if (!Node.isObjectLiteralExpression(element)) {+ return []+ }++ const pathProperty = getObjectPropertyAssignment(element, "path")+ if (!pathProperty || !Node.isPropertyAssignment(pathProperty)) {+ return []+ }++ const filePath = getStringLiteralValue(pathProperty.getInitializer())+ return filePath ? [filePath] : []+ })+ .filter((filePath) => filePath.endsWith(".tsx"))+}++// Read the registry item name for reporting.+function getRegistryItemName(node: Node) {+ const nameProperty = getObjectPropertyAssignment(node, "name")+ if (!nameProperty || !Node.isPropertyAssignment(nameProperty)) {+ return "unknown"+ }++ return getStringLiteralValue(nameProperty.getInitializer()) ?? "unknown"+}++// Read the registry item type so only examples are processed.+function getRegistryItemType(node: Node) {+ const typeProperty = getObjectPropertyAssignment(node, "type")+ if (!typeProperty || !Node.isPropertyAssignment(typeProperty)) {+ return null+ }++ return getStringLiteralValue(typeProperty.getInitializer())+}++// Read a registry array declaration like examples/ui so items can be inspected.+function getRegistryItemsDeclaration(sourceFile: Node, declarationName: string) {+ if (!Node.isSourceFile(sourceFile)) {+ return null+ }++ const declaration = sourceFile.getVariableDeclaration(declarationName)+ const initializer = declaration?.getInitializer()+ if (!initializer || !Node.isArrayLiteralExpression(initializer)) {+ return null+ }++ return initializer+}++// Preserve insertion order while removing duplicates.+function dedupe(values: string[]) {+ const seen = new Set<string>()++ return values.filter((value) => {+ if (seen.has(value)) {+ return false+ }++ seen.add(value)+ return true+ })+}++// Convert local registry imports into namespaced registry dependency ids.+function getRegistryDependencyName(moduleSpecifier: string) {+ const prefix = [MAGICUI_IMPORT_PREFIX, EXAMPLE_IMPORT_PREFIX].find((value) =>+ moduleSpecifier.startsWith(value)+ )++ if (!prefix) {+ return null+ }++ const itemName = moduleSpecifier.slice(prefix.length)+ if (!itemName) {+ return null+ }++ return `${MAGICUI_PACKAGE_PREFIX}${itemName}`+}++// Map registry source files back to their published registry dependency ids.+function getRegistryDependencyNameFromFilePath(filePath: string) {+ const registryItemRoots = [+ path.join(registryRoot, "magicui"),+ path.join(registryRoot, "example"),+ ]++ const matchingRoot = registryItemRoots.find((rootPath) => {+ const relativePath = path.relative(rootPath, filePath)+ return !relativePath.startsWith("..") && !path.isAbsolute(relativePath)+ })++ if (!matchingRoot) {+ return null+ }++ const relativePath = path.relative(matchingRoot, filePath)++ if (+ !/\.(ts|tsx)$/.test(relativePath)+ ) {+ return null+ }++ const packageName = relativePath+ .replace(/\.(ts|tsx)$/, "")+ .split(path.sep)+ .join("/")++ return `${MAGICUI_PACKAGE_PREFIX}${packageName}`+}++// Limit exact matching to magicui package entries and leave other deps alone.+function isMagicUiPackage(dependency: string) {+ return dependency.startsWith(MAGICUI_PACKAGE_PREFIX)+}++// Infer the primary UI package from example naming conventions like confetti-fireworks.+function inferRegistryDependenciesFromExampleName(+ exampleName: string,+ registryUiNames: string[]+) {+ const matchingUiNames = registryUiNames+ .filter((uiName) => {+ return exampleName === uiName || exampleName.startsWith(`${uiName}-`)+ })+ .sort((left, right) => right.length - left.length || left.localeCompare(right))++ const longestMatch = matchingUiNames.at(0)+ if (!longestMatch) {+ return []+ }++ return [`${MAGICUI_PACKAGE_PREFIX}${longestMatch}`]+}++// Collect static and dynamic module specifiers from a source file.+function collectModuleSpecifiersFromSourceFile(sourceFile: Node) {+ const importSpecifiers = sourceFile+ .getDescendantsOfKind(SyntaxKind.ImportDeclaration)+ .map((importDeclaration) => importDeclaration.getModuleSpecifierValue())++ const dynamicImportSpecifiers = sourceFile+ .getDescendantsOfKind(SyntaxKind.CallExpression)+ .flatMap((callExpression) => {+ if (callExpression.getExpression().getKind() !== SyntaxKind.ImportKeyword) {+ return []+ }++ return [getStringLiteralValue(callExpression.getArguments().at(0))]+ })+ .filter((specifier): specifier is string => specifier !== null)++ return dedupe([...importSpecifiers, ...dynamicImportSpecifiers])+}++// Check whether an import points at another source file under apps/www/registry.+function getRegistryImportBasePath(+ fromFilePath: string,+ moduleSpecifier: string+) {+ if (moduleSpecifier.startsWith(REGISTRY_IMPORT_PREFIX)) {+ return path.join(registryRoot, moduleSpecifier.slice(REGISTRY_IMPORT_PREFIX.length))+ }++ if (!moduleSpecifier.startsWith(".")) {+ return null+ }++ const resolvedPath = path.resolve(path.dirname(fromFilePath), moduleSpecifier)+ const relativePath = path.relative(registryRoot, resolvedPath)++ if (relativePath.startsWith("..") || path.isAbsolute(relativePath)) {+ return null+ }++ return resolvedPath+}++// Resolve registry-local imports without needing a full tsconfig module resolver.+async function resolveRegistryImportPath(+ fromFilePath: string,+ moduleSpecifier: string+) {+ const basePath = getRegistryImportBasePath(fromFilePath, moduleSpecifier)+ if (!basePath) {+ return null+ }++ const candidates = /\.[mc]?[jt]sx?$/.test(basePath)+ ? [basePath]+ : [+ `${basePath}.tsx`,+ `${basePath}.ts`,+ path.join(basePath, "index.tsx"),+ path.join(basePath, "index.ts"),+ ]++ for (const candidate of candidates) {+ try {+ await fs.access(candidate)+ return candidate+ } catch {+ continue+ }+ }++ return {+ missingImport: moduleSpecifier,+ sourceFile: path.relative(registryRoot, fromFilePath),+ }+}++// Walk the local registry import graph and collect all reachable @magicui/* packages.+async function collectRegistryDependenciesFromFile(+ project: Project,+ filePath: string,+ dependencies: Set<string>,+ missingFiles: string[],+ excludedDependencies: Set<string>,+ visitedFiles = new Set<string>()+) {+ const absolutePath = path.resolve(filePath)+ if (visitedFiles.has(absolutePath)) {+ return+ }++ visitedFiles.add(absolutePath)++ const sourceFile =+ project.getSourceFile(absolutePath) ??+ project.addSourceFileAtPathIfExists(absolutePath)++ if (!sourceFile) {+ missingFiles.push(path.relative(registryRoot, absolutePath))+ return+ }++ const fileDependency = getRegistryDependencyNameFromFilePath(absolutePath)+ if (fileDependency && !excludedDependencies.has(fileDependency)) {+ dependencies.add(fileDependency)+ }++ for (const moduleSpecifier of collectModuleSpecifiersFromSourceFile(sourceFile)) {+ const directDependency = getRegistryDependencyName(moduleSpecifier)+ if (directDependency && !excludedDependencies.has(directDependency)) {+ dependencies.add(directDependency)+ }++ const resolvedImport = await resolveRegistryImportPath(+ absolutePath,+ moduleSpecifier+ )++ if (!resolvedImport) {+ continue+ }++ if (typeof resolvedImport !== "string") {+ missingFiles.push(+ `${resolvedImport.sourceFile} -> ${resolvedImport.missingImport}`+ )+ continue+ }++ await collectRegistryDependenciesFromFile(+ project,+ resolvedImport,+ dependencies,+ missingFiles,+ excludedDependencies,+ visitedFiles+ )+ }+}++// Aggregate magicui dependencies across all files referenced by one example.+async function collectExampleRegistryDependencies(+ project: Project,+ filePaths: string[]+) {+ const missingFiles: string[] = []+ const dependencies = new Set<string>()+ const visitedFiles = new Set<string>()+ const excludedDependencies = new Set(+ filePaths+ .filter((filePath) => filePath.startsWith("example/"))+ .map((filePath) => {+ return getRegistryDependencyNameFromFilePath(path.join(registryRoot, filePath))+ })+ .filter((dependency): dependency is string => dependency !== null)+ )++ for (const filePath of filePaths) {+ const absolutePath = path.join(registryRoot, filePath)++ try {+ await fs.access(absolutePath)+ } catch {+ missingFiles.push(filePath)+ continue+ }++ await collectRegistryDependenciesFromFile(+ project,+ absolutePath,+ dependencies,+ missingFiles,+ excludedDependencies,+ visitedFiles+ )+ }++ return {+ dependencies: Array.from(dependencies).sort((left, right) =>+ left.localeCompare(right)+ ),+ missingFiles,+ }+}++// Upsert registryDependencies while keeping the property near files.+function setRegistryDependencies(node: Node, dependencies: string[]) {+ if (!Node.isObjectLiteralExpression(node)) {+ return+ }++ const normalizedDependencies = dedupe(dependencies)+ const existingProperty = getObjectPropertyAssignment(+ node,+ "registryDependencies"+ )+ const filesPropertyIndex = node+ .getProperties()+ .findIndex((property) => {+ return Node.isPropertyAssignment(property) && property.getName() === "files"+ })++ const initializer = (writer: CodeBlockWriter) => {+ writer.write("[")++ if (normalizedDependencies.length === 0) {+ writer.write("]")+ return+ }++ writer.newLine()+ writer.indent(() => {+ for (const dependency of normalizedDependencies) {+ writer.writeLine(`${JSON.stringify(dependency)},`)+ }+ })+ writer.write("]")+ }++ if (existingProperty && Node.isPropertyAssignment(existingProperty)) {+ existingProperty.setInitializer(initializer)+ return+ }++ const insertIndex =+ filesPropertyIndex >= 0 ? filesPropertyIndex : node.getProperties().length++ node.insertPropertyAssignment(insertIndex, {+ name: "registryDependencies",+ initializer,+ })+}++// Format one mismatch entry for CLI output.+function formatIssue(issue: ExampleIssue) {+ const fileList =+ issue.exampleFiles.length > 0 ? issue.exampleFiles.join(", ") : "no files"+ const extraDependencies =+ issue.extraDependencies.length > 0+ ? issue.extraDependencies.join(", ")+ : "none"+ const missingDependencies =+ issue.missingDependencies.length > 0+ ? issue.missingDependencies.join(", ")+ : "none"+ const missingFiles =+ issue.missingFiles.length > 0 ? issue.missingFiles.join(", ") : "none"++ return [+ `- ${issue.exampleName}`,+ ` files: ${fileList}`,+ ` extra registryDependencies: ${extraDependencies}`,+ ` missing registryDependencies: ${missingDependencies}`,+ ` missing files: ${missingFiles}`,+ ].join("\n")+}++// Treat missing files or missing dependencies as failures that need action.+function hasBlockingIssue(issue: ExampleIssue) {+ return issue.missingDependencies.length > 0 || issue.missingFiles.length > 0+}++// Treat extra dependencies as non-blocking warnings to avoid destructive churn.+function hasWarningIssue(issue: ExampleIssue) {+ return issue.extraDependencies.length > 0 && !hasBlockingIssue(issue)+}++// Raise a hard failure when an example points at files that cannot be read.+export function assertNoMissingExampleFiles(issues: ExampleIssue[]) {+ const missingFileIssues = issues.filter((issue) => issue.missingFiles.length > 0)+ if (missingFileIssues.length === 0) {+ return+ }++ const issueSummary = missingFileIssues.map(formatIssue).join("\n")+ throw new Error(+ [+ "registry example dependency sync failed because some example files are missing:",+ issueSummary,+ ].join("\n")+ )+}++// Compare imported magicui components with declared registryDependencies.+export async function syncExampleRegistryDependencies({+ mode,+}: SyncOptions): Promise<ExampleIssue[]> {+ const project = new Project({+ skipAddingFilesFromTsConfig: true,+ })+ const registryExamplesSourceFile =+ project.addSourceFileAtPath(registryExamplesPath)+ const registryUiSourceFile = project.addSourceFileAtPath(registryUiPath)++ const initializer = getRegistryItemsDeclaration(+ registryExamplesSourceFile,+ "examples"+ )+ const uiInitializer = getRegistryItemsDeclaration(registryUiSourceFile, "ui")++ if (!initializer) {+ throw new Error("Could not find the examples array in registry-examples.ts.")+ }++ if (!uiInitializer) {+ throw new Error("Could not find the ui array in registry-ui.ts.")+ }++ const registryUiNames = uiInitializer+ .getElements()+ .flatMap((item) => {+ if (!Node.isObjectLiteralExpression(item)) {+ return []+ }++ if (getRegistryItemType(item) !== "registry:ui") {+ return []+ }++ return [getRegistryItemName(item)]+ })+ .sort((left, right) => right.length - left.length || left.localeCompare(right))++ const issues: ExampleIssue[] = []++ for (const item of initializer.getElements()) {+ if (!Node.isObjectLiteralExpression(item)) {+ continue+ }++ if (getRegistryItemType(item) !== "registry:example") {+ continue+ }++ const exampleName = getRegistryItemName(item)+ const exampleFiles = getExampleFilePaths(item)+ const currentDependencies = getStringArrayValues(+ getObjectPropertyAssignment(item, "registryDependencies")+ )+ const { dependencies: importedDependencies, missingFiles } =+ await collectExampleRegistryDependencies(project, exampleFiles)+ const inferredDependencies = inferRegistryDependenciesFromExampleName(+ exampleName,+ registryUiNames+ )+ const expectedDependencies = dedupe([+ ...importedDependencies,+ ...inferredDependencies,+ ]).sort((left, right) => left.localeCompare(right))++ const normalizedCurrentDependencies = dedupe(currentDependencies)+ const currentMagicUiDependencies = normalizedCurrentDependencies.filter(+ isMagicUiPackage+ )+ const extraDependencies = currentMagicUiDependencies.filter((dependency) => {+ return !expectedDependencies.includes(dependency)+ })+ const missingDependencies = expectedDependencies.filter((dependency) => {+ return !currentMagicUiDependencies.includes(dependency)+ })+ const nextDependencies = [...normalizedCurrentDependencies, ...missingDependencies]+ const dependenciesChanged =+ nextDependencies.length !== currentDependencies.length ||+ nextDependencies.some(+ (dependency, index) => dependency !== currentDependencies[index]+ )++ if (dependenciesChanged || missingFiles.length > 0) {+ issues.push({+ exampleName,+ exampleFiles,+ extraDependencies,+ missingDependencies,+ missingFiles,+ })+ }++ if (mode === "fix" && dependenciesChanged) {+ setRegistryDependencies(item, nextDependencies)+ }+ }++ if (mode === "fix" && registryExamplesSourceFile.isSaved() === false) {+ await registryExamplesSourceFile.save()+ }++ return issues+}++// Expose a small check/fix CLI for local runs and package scripts.+async function main() {+ const mode = process.argv.includes("--check") ? "check" : "fix"+ const issues = await syncExampleRegistryDependencies({ mode })+ const blockingIssues = issues.filter(hasBlockingIssue)+ const warningIssues = issues.filter(hasWarningIssue)++ if (issues.length === 0) {+ console.log("registry example dependencies are in sync")+ return+ }++ const blockingIssueSummary = blockingIssues.map(formatIssue).join("\n")+ const warningIssueSummary = warningIssues.map(formatIssue).join("\n")++ if (mode === "check") {+ if (blockingIssues.length > 0) {+ console.error("registry example dependency mismatches found:")+ console.error(blockingIssueSummary)+ process.exit(1)+ }++ console.warn("registry example dependencies have non-blocking warnings:")+ console.warn(warningIssueSummary)+ return+ }++ try {+ assertNoMissingExampleFiles(issues)+ } catch (error) {+ console.error("registry example dependency sync completed with missing files:")+ console.error(error instanceof Error ? error.message : error)+ process.exit(1)+ }++ if (blockingIssues.length > 0) {+ console.log("updated registry example dependencies:")+ console.log(blockingIssueSummary)+ } else {+ console.log("registry example dependencies are in sync")+ }++ if (warningIssues.length > 0) {+ console.warn("registry example dependencies have non-blocking warnings:")+ console.warn(warningIssueSummary)+ }+}++if (isMainModule()) {+ await main()+}diff --git a/package.json b/package.jsonindex 9e8d1409..2ea60156 100644--- a/package.json+++ b/package.json@@ -15,9 +15,10 @@"format:fix": "turbo run format:fix","format:fix:silent": "turbo run format:fix -- --log-level silent","format:check": "turbo run format:check",+ "registry-deps:check": "pnpm --filter=www registry-deps:check","build:docs": "turbo run build:docs --filter=www","build:registry": "pnpm --filter=www build:registry && pnpm --filter=www lint:fix && pnpm format:fix:silent",- "check": "pnpm lint && pnpm typecheck && pnpm format:check"+ "check": "pnpm lint && pnpm typecheck && pnpm format:check && pnpm registry-deps:check"},"devDependencies": {"@commitlint/cli": "^19.8.1",