#!/usr/bin/env node /** * 拉取 beautifului.dev 的 shadcn registry 源到 docs/ui-ref/beautifului/。 * 组件清单来自站点 01-21 节;slug 与锚点基本一致(个别做了别名兜底)。 * 用法:node scripts/fetch-beautifului-registry.mjs */ import { mkdirSync, writeFileSync } from 'node:fs' import { join } from 'node:path' const SLUGS = [ 'loading-state', 'thinking', 'thinking-state', 'streaming-text', 'approval-card', 'tool-chips', 'task-rows', 'chat', 'chat-composer', 'prompt-bar', 'recommendation-card', 'context-cards', 'diff-table', 'records-table', 'filter-table', 'sidebar-nav', 'search', 'flowchart', 'insight-cards', 'code-block', 'fine-tune-card', 'selection-actions', 'agent-screen', 'foundation', 'button', 'glide-menu', 'entity-chip', 'value-pill', 'shimmer', 'stream-text' ] const OUT = join(process.cwd(), 'docs', 'ui-ref', 'beautifului') mkdirSync(OUT, { recursive: true }) for (const slug of SLUGS) { const url = `https://www.beautifului.dev/r/${slug}.json` try { const res = await fetch(url) if (!res.ok) { console.log(`[miss ] ${slug} (${res.status})`) continue } const json = await res.json() writeFileSync(join(OUT, `${slug}.json`), JSON.stringify(json, null, 2), 'utf8') const files = (json.files ?? []).map((f) => f.path).join(', ') console.log(`[ok ] ${slug} files: ${files || '(none)'}`) } catch (err) { console.log(`[error] ${slug}: ${err.message}`) } }