migrate.ts — ui Source File
Architecture documentation for migrate.ts, a typescript file in the ui codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR da749efe_50ce_753c_dc60_9072204cbe6f["migrate.ts"] d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"] da749efe_50ce_753c_dc60_9072204cbe6f --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5 54054371_e049_7449_0721_48af95e84160["migrate-icons"] da749efe_50ce_753c_dc60_9072204cbe6f --> 54054371_e049_7449_0721_48af95e84160 87669051_5853_e1f2_1a08_19cf370b0a99["migrate-radix"] da749efe_50ce_753c_dc60_9072204cbe6f --> 87669051_5853_e1f2_1a08_19cf370b0a99 5eaab848_ebd5_85a2_145a_0322b024a192["migrate-rtl"] da749efe_50ce_753c_dc60_9072204cbe6f --> 5eaab848_ebd5_85a2_145a_0322b024a192 559c244f_6fd5_efc1_d466_9db51c31d329["preflight-migrate"] da749efe_50ce_753c_dc60_9072204cbe6f --> 559c244f_6fd5_efc1_d466_9db51c31d329 2dce5b77_ae3e_67df_2221_13714429e261["errors"] da749efe_50ce_753c_dc60_9072204cbe6f --> 2dce5b77_ae3e_67df_2221_13714429e261 6be7d8a9_c93c_8743_3ef7_968efff25479["handle-error"] da749efe_50ce_753c_dc60_9072204cbe6f --> 6be7d8a9_c93c_8743_3ef7_968efff25479 1df8bbed_5110_29f0_12f0_996fc7a1eda1["logger"] da749efe_50ce_753c_dc60_9072204cbe6f --> 1df8bbed_5110_29f0_12f0_996fc7a1eda1 7d629454_eee6_73fe_2526_919af8d00ef9["commander"] da749efe_50ce_753c_dc60_9072204cbe6f --> 7d629454_eee6_73fe_2526_919af8d00ef9 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] da749efe_50ce_753c_dc60_9072204cbe6f --> 6802ce19_522d_e5fb_e458_8826d9f6952e style da749efe_50ce_753c_dc60_9072204cbe6f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import path from "path"
import { migrateIcons } from "@/src/migrations/migrate-icons"
import { migrateRadix } from "@/src/migrations/migrate-radix"
import { migrateRtl } from "@/src/migrations/migrate-rtl"
import { preFlightMigrate } from "@/src/preflights/preflight-migrate"
import * as ERRORS from "@/src/utils/errors"
import { handleError } from "@/src/utils/handle-error"
import { logger } from "@/src/utils/logger"
import { Command } from "commander"
import { z } from "zod"
export const migrations = [
{
name: "icons",
description: "migrate your ui components to a different icon library.",
},
{
name: "radix",
description: "migrate to radix-ui.",
},
{
name: "rtl",
description: "migrate your components to support RTL (right-to-left).",
},
] as const
export const migrateOptionsSchema = z.object({
cwd: z.string(),
list: z.boolean(),
yes: z.boolean(),
migration: z
.string()
.refine(
(value) =>
value && migrations.some((migration) => migration.name === value),
{
message:
"You must specify a valid migration. Run `shadcn migrate --list` to see available migrations.",
}
)
.optional(),
path: z.string().optional(),
})
export const migrate = new Command()
.name("migrate")
.description("run a migration.")
.argument("[migration]", "the migration to run.")
.argument("[path]", "optional path or glob pattern to migrate.")
.option(
"-c, --cwd <cwd>",
"the working directory. defaults to the current directory.",
process.cwd()
)
.option("-l, --list", "list all migrations.", false)
.option("-y, --yes", "skip confirmation prompt.", false)
.action(async (migration, migratePath, opts) => {
try {
const options = migrateOptionsSchema.parse({
cwd: path.resolve(opts.cwd),
migration,
path: migratePath,
list: opts.list,
yes: opts.yes,
})
if (options.list || !options.migration) {
logger.info("Available migrations:")
for (const migration of migrations) {
logger.info(`- ${migration.name}: ${migration.description}`)
}
return
}
if (!options.migration) {
throw new Error(
"You must specify a migration. Run `shadcn migrate --list` to see available migrations."
)
}
let { errors, config } = await preFlightMigrate(options)
if (
errors[ERRORS.MISSING_DIR_OR_EMPTY_PROJECT] ||
errors[ERRORS.MISSING_CONFIG]
) {
throw new Error(
"No `components.json` file found. Ensure you are at the root of your project."
)
}
if (!config) {
throw new Error(
"Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file."
)
}
if (options.migration === "icons") {
await migrateIcons(config)
}
if (options.migration === "radix") {
await migrateRadix(config, { yes: options.yes, path: options.path })
}
if (options.migration === "rtl") {
await migrateRtl(config, { yes: options.yes, path: options.path })
}
} catch (error) {
logger.break()
handleError(error)
}
})
Domain
Subdomains
Functions
Dependencies
- commander
- errors
- handle-error
- logger
- migrate-icons
- migrate-radix
- migrate-rtl
- path
- preflight-migrate
- zod
Source
Frequently Asked Questions
What does migrate.ts do?
migrate.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, TemplateSync subdomain.
What functions are defined in migrate.ts?
migrate.ts defines 1 function(s): migrate.
What does migrate.ts depend on?
migrate.ts imports 10 module(s): commander, errors, handle-error, logger, migrate-icons, migrate-radix, migrate-rtl, path, and 2 more.
Where is migrate.ts in the architecture?
migrate.ts is located at packages/shadcn/src/commands/migrate.ts (domain: FrameworkTooling, subdomain: TemplateSync, directory: packages/shadcn/src/commands).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free