(pagePath: string)
| 465 | } |
| 466 | |
| 467 | const buildBlockItem = async (pagePath: string) => { |
| 468 | const code = await read(pagePath) |
| 469 | const slug = blockSlugFromPage(pagePath) |
| 470 | const privates = await collectBlocks(pagePath, code) |
| 471 | const privSet = new Set<string>([pagePath, ...privates]) |
| 472 | const urlDeps = await registryDepsForBlock(pagePath, code) |
| 473 | const specs = importSpecifiers(code) |
| 474 | const deps = topLevelPackages(specs) |
| 475 | const metaPath = path.join(path.dirname(pagePath), 'meta.json') |
| 476 | let title: string | undefined |
| 477 | let description: string | undefined |
| 478 | if (await exists(metaPath)) { |
| 479 | const metaRaw = await read(metaPath).catch(() => '{}') |
| 480 | try { |
| 481 | const meta = JSON.parse(metaRaw) |
| 482 | title = meta.title || slug |
| 483 | description = meta.description || slug |
| 484 | } catch { |
| 485 | title = slug |
| 486 | description = slug |
| 487 | } |
| 488 | } else { |
| 489 | title = slug |
| 490 | description = slug |
| 491 | } |
| 492 | const staged: { abs: string; type: FileOut['type']; target?: string }[] = [] |
| 493 | const pageStaged = stagedPathFor(slug, pagePath) |
| 494 | const pageTransformed = await rewritePrivatesToRegistry(pagePath, code, privSet, slug) |
| 495 | await write(pageStaged, pageTransformed) |
| 496 | staged.push({ |
| 497 | abs: pageStaged, |
| 498 | type: 'registry:page', |
| 499 | target: `${PAGE_TARGET_ROOT}/${slug}/page.tsx`, |
| 500 | }) |
| 501 | for (const p of privates) { |
| 502 | const transformed = await rewritePrivatesToRegistry(p, await read(p), privSet, slug) |
| 503 | const dest = stagedPathFor(slug, p) |
| 504 | await write(dest, transformed) |
| 505 | staged.push({ abs: dest, type: 'registry:component' }) |
| 506 | } |
| 507 | const files: FileOut[] = [] |
| 508 | for (const f of staged) { |
| 509 | if (f.type === 'registry:page') { |
| 510 | files.push(await fileEntryPage(f.abs, f.target!, undefined)) |
| 511 | } else { |
| 512 | files.push(await fileEntryOther(f.abs, f.type, undefined, f.target)) |
| 513 | } |
| 514 | } |
| 515 | const raw = { |
| 516 | $schema: 'https://ui.shadcn.com/schema/registry-item.json', |
| 517 | extends: 'none', |
| 518 | name: slug.split('/').join('-'), |
| 519 | type: 'registry:block', |
| 520 | title, |
| 521 | description, |
| 522 | dependencies: deps.length ? deps : undefined, |
| 523 | registryDependencies: urlDeps.length ? urlDeps : undefined, |
| 524 | files, |
no test coverage detected