// 下载 beautifului.dev registry:索引 + 候选组件 JSON,保存到 scripts/beautifului/ import { mkdir, writeFile } from 'node:fs/promises' const outDir = new URL('./beautifului/', import.meta.url) await mkdir(outDir, { recursive: true }) async function grab(slug) { const r = await fetch(`https://www.beautifului.dev/r/${slug}.json`) if (!r.ok) { console.log(slug, '=> HTTP', r.status) return null } const text = await r.text() await writeFile(new URL(`${slug}.json`, outDir), text) return JSON.parse(text) } // 1) registry 索引 const idx = await grab('registry') if (idx) { const items = Array.isArray(idx) ? idx : idx.items || [] console.log('=== registry index ===') for (const it of items) console.log('-', it.name, '|', it.title || '', '|', it.type || '') } // 2) 候选组件(含传递依赖) const wanted = [ 'foundation', 'loading-state', 'streaming-text', 'tool-chips', 'approval-card', 'button', 'glide-menu', 'task-rows', 'prompt-bar', 'selection-actions', 'shimmer', 'stream-text' ] console.log('=== components ===') for (const s of wanted) { const j = await grab(s) if (!j) continue const files = (j.files || []).map((f) => f.path).join(', ') console.log(`${s}: deps=${JSON.stringify(j.dependencies || [])} files=[${files}]`) }