Files
supabase/apps/ui-library/scripts/build-registry.mts
Ivan Vasilov 33127bb6ab feat: Library (#34294)
* Copy the design-system app into a new one for ui-library.

* Remove unneeded content.

* Add supabase config.

* Cleanup the css.

* Add bunch of packages.

* Cleanup the registry.

* Regenerate the registry.

* Add needed components for documenting components.

* Add the pages for the components.

* Fix the RegistryBlock.

* Various fixes.

* Add a turbo definition for ui-library.

* Rename Remix to React Router.

* Reorder the pages for all frameworks.

* Remove the bottom pager.

* Fix the pages and command menu.

* Various fixes.

* Minor fixes.

* Add ai editor rules.

* Various fixes.

* Add local supabase env vars.

* Try to fix a package error.

* Bunch of various fixes.

* Fix lint errors.
2025-03-20 22:11:07 +01:00

49 lines
1.4 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, '..', '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.ts
// Do not edit this file directly.
import * as React from "react"
export const Index: Record<string, any> = {
"default": {
${registry.items.map((item) => {
const componentFile = item.files.find((file) => file.path.endsWith('.tsx'))
return `
"${item.name}": {
name: "${item.name}",
type: "${item.type}",
registryDependencies: [${item.registryDependencies.map((dep) => `"${dep}"`).join(',')}],
${componentFile ? `component: React.lazy(() => import("@/${componentFile.path}")),` : ''}
source: "",
files: [${item.files?.map((file) => `"${file.path}"`).join(',')}],
category: "undefined",
subcategory: "undefined",
chunks: []
}
`
})}
},
}
`
fs.writeFileSync(`__registry__/index.tsx`, registryIndex)