* Build the current registry. * Export the blocks as JSON and import them into registry.json. * Move the registry.json into public/r. * Fix a prettier error. * Clean up extra files in vue blocks. * Bump shadcn. * Readd shadcn to vue blocks. * Fix the shadcn types. * Remove extra package exclusions.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
// typecheck
|
|
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
import { registry } from '../registry/index'
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
const registryPath = path.join(__dirname, '..', 'public', 'r', 'registry.json')
|
|
|
|
const cleanedRegistry = {
|
|
$schema: 'https://ui.shadcn.com/schema/registry.json',
|
|
...registry,
|
|
items: registry.items.filter((item) => item.type !== 'registry:example'),
|
|
}
|
|
|
|
fs.writeFileSync(registryPath, JSON.stringify(cleanedRegistry, null, 2))
|
|
|
|
// Create a registry index file for use by ComponentPreview in the app.
|
|
const registryIndex = `
|
|
// @ts-nocheck
|
|
// This file is autogenerated by scripts/build-registry.mts
|
|
// Do not edit this file directly.
|
|
import * as React from "react"
|
|
|
|
export const Index = {
|
|
"default": {
|
|
${registry.items
|
|
.filter((item) => item.type === 'registry:example')
|
|
.map((item) => {
|
|
const componentFile = item.files.find((file) => file.path.endsWith('.tsx'))
|
|
|
|
return `
|
|
"${item.name}": {
|
|
component: ${componentFile ? `React.lazy(() => import("@/${componentFile.path}"))` : 'null'},
|
|
}
|
|
`
|
|
})}
|
|
},
|
|
} as const
|
|
`
|
|
fs.writeFileSync(`__registry__/index.tsx`, registryIndex)
|