This commit is contained in:
shadcn
2026-04-06 23:32:48 +04:00
parent e3d2b14911
commit 7cb3b13a33

View File

@@ -1,5 +1,5 @@
import path from "path"
import { confirmBaseSwitch, runInit } from "@/src/commands/init"
import { runInit } from "@/src/commands/init"
import { preFlightApply } from "@/src/preflights/preflight-apply"
import { decodePreset, isPresetCode } from "@/src/preset/preset"
import {
@@ -323,3 +323,38 @@ function getInitCommand(preset?: string) {
return `shadcn init --preset ${quoteShellArg(preset)}`
}
async function confirmBaseSwitch(
existingStyle: string,
resolvedBase: "radix" | "base"
) {
const oldBase = existingStyle.startsWith("base-") ? "base" : "radix"
if (resolvedBase === oldBase) return resolvedBase
logger.warn(
` You are switching from ${highlighter.info(
oldBase
)} to ${highlighter.info(resolvedBase)}.`
)
logger.warn(
` Components outside the ${highlighter.info(
"ui"
)} directory that depend on ${highlighter.info(
oldBase
)} primitives may need manual updates.`
)
logger.break()
const { proceed } = await prompts({
type: "confirm",
name: "proceed",
message: "Would you like to continue?",
initial: true,
})
if (!proceed) {
process.exit(1)
}
return resolvedBase
}