promptForRegistryComponents() — ui Function Reference
Architecture documentation for the promptForRegistryComponents() function in add.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD f06982e8_5ef0_e553_ffbe_a4189b216d87["promptForRegistryComponents()"] bcd87158_201e_8041_38a6_f566a96d459f["add.ts"] f06982e8_5ef0_e553_ffbe_a4189b216d87 -->|defined in| bcd87158_201e_8041_38a6_f566a96d459f 08918f28_2fda_4709_8ae2_ccf20fead04e["add()"] 08918f28_2fda_4709_8ae2_ccf20fead04e -->|calls| f06982e8_5ef0_e553_ffbe_a4189b216d87 style f06982e8_5ef0_e553_ffbe_a4189b216d87 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shadcn/src/commands/add.ts lines 266–322
async function promptForRegistryComponents(
options: z.infer<typeof addOptionsSchema>
) {
const registryIndex = await getShadcnRegistryIndex()
if (!registryIndex) {
logger.break()
handleError(new Error("Failed to fetch registry index."))
return []
}
if (options.all) {
return registryIndex
.map((entry) => entry.name)
.filter(
(component) => !DEPRECATED_COMPONENTS.some((c) => c.name === component)
)
}
if (options.components?.length) {
return options.components
}
const { components } = await prompts({
type: "multiselect",
name: "components",
message: "Which components would you like to add?",
hint: "Space to select. A to toggle all. Enter to submit.",
instructions: false,
choices: registryIndex
.filter(
(entry) =>
entry.type === "registry:ui" &&
!DEPRECATED_COMPONENTS.some(
(component) => component.name === entry.name
)
)
.map((entry) => ({
title: entry.name,
value: entry.name,
selected: options.all ? true : options.components?.includes(entry.name),
})),
})
if (!components?.length) {
logger.warn("No components selected. Exiting.")
logger.info("")
process.exit(1)
}
const result = z.array(z.string()).safeParse(components)
if (!result.success) {
logger.error("")
handleError(new Error("Something went wrong. Please try again."))
return []
}
return result.data
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does promptForRegistryComponents() do?
promptForRegistryComponents() is a function in the ui codebase, defined in packages/shadcn/src/commands/add.ts.
Where is promptForRegistryComponents() defined?
promptForRegistryComponents() is defined in packages/shadcn/src/commands/add.ts at line 266.
What calls promptForRegistryComponents()?
promptForRegistryComponents() is called by 1 function(s): add.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free