preFlightMigrate() — ui Function Reference
Architecture documentation for the preFlightMigrate() function in preflight-migrate.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD e4850f05_d6af_5384_528c_fa2826a5d2cb["preFlightMigrate()"] c2dfe6a6_6b7d_0de1_1047_b79a859d6140["preflight-migrate.ts"] e4850f05_d6af_5384_528c_fa2826a5d2cb -->|defined in| c2dfe6a6_6b7d_0de1_1047_b79a859d6140 style e4850f05_d6af_5384_528c_fa2826a5d2cb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shadcn/src/preflights/preflight-migrate.ts lines 11–64
export async function preFlightMigrate(
options: z.infer<typeof migrateOptionsSchema>
) {
const errors: Record<string, boolean> = {}
// Ensure target directory exists.
// Check for empty project. We assume if no package.json exists, the project is empty.
if (
!fs.existsSync(options.cwd) ||
!fs.existsSync(path.resolve(options.cwd, "package.json"))
) {
errors[ERRORS.MISSING_DIR_OR_EMPTY_PROJECT] = true
return {
errors,
config: null,
}
}
// Check for existing components.json file.
if (!fs.existsSync(path.resolve(options.cwd, "components.json"))) {
errors[ERRORS.MISSING_CONFIG] = true
return {
errors,
config: null,
}
}
try {
const config = await getConfig(options.cwd)
return {
errors,
config: config!,
}
} catch (error) {
logger.break()
logger.error(
`An invalid ${highlighter.info(
"components.json"
)} file was found at ${highlighter.info(
options.cwd
)}.\nBefore you can run a migration, you must create a valid ${highlighter.info(
"components.json"
)} file by running the ${highlighter.info("init")} command.`
)
logger.error(
`Learn more at ${highlighter.info(
"https://ui.shadcn.com/docs/components-json"
)}.`
)
logger.break()
process.exit(1)
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does preFlightMigrate() do?
preFlightMigrate() is a function in the ui codebase, defined in packages/shadcn/src/preflights/preflight-migrate.ts.
Where is preFlightMigrate() defined?
preFlightMigrate() is defined in packages/shadcn/src/preflights/preflight-migrate.ts at line 11.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free