buildRegistry() — ui Function Reference
Architecture documentation for the buildRegistry() function in build.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 81f7cdd0_5b9c_3c3f_b34d_f82fdfc939e9["buildRegistry()"] 63e091f6_3c2a_b275_9d68_1537ab7744bf["build.ts"] 81f7cdd0_5b9c_3c3f_b34d_f82fdfc939e9 -->|defined in| 63e091f6_3c2a_b275_9d68_1537ab7744bf a0b7587c_d7d1_15ce_fb36_b2d35ff36427["build()"] a0b7587c_d7d1_15ce_fb36_b2d35ff36427 -->|calls| 81f7cdd0_5b9c_3c3f_b34d_f82fdfc939e9 fad061f2_6610_9959_e2da_f7274dc36de4["resolveRegistryItems()"] 81f7cdd0_5b9c_3c3f_b34d_f82fdfc939e9 -->|calls| fad061f2_6610_9959_e2da_f7274dc36de4 style 81f7cdd0_5b9c_3c3f_b34d_f82fdfc939e9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shadcn/src/commands/registry/build.ts lines 46–182
async function buildRegistry(opts: z.infer<typeof buildOptionsSchema>) {
try {
const options = buildOptionsSchema.parse(opts)
const [{ errors, resolvePaths, config }, projectInfo] = await Promise.all([
preFlightRegistryBuild(options),
getProjectInfo(options.cwd),
])
if (errors[ERRORS.MISSING_CONFIG] || !config || !projectInfo) {
logger.error(
`A ${highlighter.info(
"components.json"
)} file is required to build the registry. Run ${highlighter.info(
"shadcn init"
)} to create one.`
)
logger.break()
process.exit(1)
}
if (errors[ERRORS.BUILD_MISSING_REGISTRY_FILE] || !resolvePaths) {
logger.error(
`We could not find a registry file at ${highlighter.info(
path.resolve(options.cwd, options.registryFile)
)}.`
)
logger.break()
process.exit(1)
}
const content = await fs.readFile(resolvePaths.registryFile, "utf-8")
const result = registrySchema.safeParse(JSON.parse(content))
if (!result.success) {
logger.error(
`Invalid registry file found at ${highlighter.info(
resolvePaths.registryFile
)}.`
)
logger.break()
process.exit(1)
}
const buildSpinner = spinner("Building registry...")
// Recursively resolve the registry items.
const resolvedRegistry = await resolveRegistryItems(
result.data,
config,
projectInfo
)
// Loop through the registry items and remove duplicates files i.e same path.
for (const registryItem of resolvedRegistry.items) {
// Deduplicate files
registryItem.files = registryItem.files?.filter(
(file, index, self) =>
index === self.findIndex((t) => t.path === file.path)
)
// Deduplicate dependencies
if (registryItem.dependencies) {
registryItem.dependencies = registryItem.dependencies.filter(
(dep, index, self) => index === self.findIndex((d) => d === dep)
)
}
}
for (const registryItem of resolvedRegistry.items) {
if (!registryItem.files) {
continue
}
buildSpinner.start(`Building ${registryItem.name}...`)
// Add the schema to the registry item.
registryItem["$schema"] =
"https://ui.shadcn.com/schema/registry-item.json"
for (const file of registryItem.files) {
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does buildRegistry() do?
buildRegistry() is a function in the ui codebase, defined in packages/shadcn/src/commands/registry/build.ts.
Where is buildRegistry() defined?
buildRegistry() is defined in packages/shadcn/src/commands/registry/build.ts at line 46.
What does buildRegistry() call?
buildRegistry() calls 1 function(s): resolveRegistryItems.
What calls buildRegistry()?
buildRegistry() is called by 1 function(s): build.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free