view() — ui Function Reference
Architecture documentation for the view() function in view.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD cbd2b552_c9f4_95c2_948a_6d60d111b687["view()"] 3f70379c_fbf1_9ff8_2596_7f5153a582bb["view.ts"] cbd2b552_c9f4_95c2_948a_6d60d111b687 -->|defined in| 3f70379c_fbf1_9ff8_2596_7f5153a582bb style cbd2b552_c9f4_95c2_948a_6d60d111b687 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shadcn/src/commands/view.ts lines 28–78
.action(async (items: string[], opts) => {
try {
const options = viewOptionsSchema.parse({
cwd: path.resolve(opts.cwd),
})
await loadEnvFiles(options.cwd)
// Start with a shadow config to support partial components.json.
let shadowConfig = configWithDefaults({})
// Check if there's a components.json file (partial or complete).
const componentsJsonPath = path.resolve(options.cwd, "components.json")
if (fsExtra.existsSync(componentsJsonPath)) {
const existingConfig = await fsExtra.readJson(componentsJsonPath)
const partialConfig = rawConfigSchema.partial().parse(existingConfig)
shadowConfig = configWithDefaults(partialConfig)
}
// Try to get the full config, but fall back to shadow config if it fails.
let config = shadowConfig
try {
const fullConfig = await getConfig(options.cwd)
if (fullConfig) {
config = configWithDefaults(fullConfig)
}
} catch {
// Use shadow config if getConfig fails (partial components.json).
}
const { config: updatedConfig, newRegistries } =
await ensureRegistriesInConfig(items, config, {
silent: true,
writeFile: false,
})
if (newRegistries.length > 0) {
config.registries = updatedConfig.registries
}
// Validate registries early for better error messages.
validateRegistryConfigForItems(items, config)
const payload = await getRegistryItems(items, { config })
console.log(JSON.stringify(payload, null, 2))
process.exit(0)
} catch (error) {
handleError(error)
} finally {
clearRegistryContext()
}
})
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does view() do?
view() is a function in the ui codebase, defined in packages/shadcn/src/commands/view.ts.
Where is view() defined?
view() is defined in packages/shadcn/src/commands/view.ts at line 28.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free