fix: refactor

This commit is contained in:
shadcn
2026-02-23 09:58:55 +04:00
parent 751c520865
commit 339de90b8a
5 changed files with 29 additions and 12 deletions

View File

@@ -214,7 +214,7 @@ function printInfo(data: ReturnType<typeof collectInfo>) {
// Registries.
if (Object.keys(data.config.registries).length > 0) {
logger.break()
logger.log(highlighter.info("Registries"))
logger.log("registries:")
printEntries(data.config.registries)
}
} else {

View File

@@ -134,7 +134,8 @@ export const init = new Command()
if (options.defaults) {
options.template = options.template || "next"
// Base resolution happens below — just mark presetBase as undefined.
options.base = options.base || "base"
options.reinstall = options.reinstall ?? false
}
if (options.template && !(options.template in templates)) {
@@ -373,13 +374,19 @@ export const init = new Command()
: "")
if (!resolvedBase) {
const base = await promptForBase()
resolvedBase = base
options.base = base
if (components.length > 0) {
// When initializing from a registry item, default to radix.
// The registry:base config will override this.
resolvedBase = "radix"
} else {
const base = await promptForBase()
resolvedBase = base
options.base = base
}
}
// Build the --defaults URL now that base is resolved.
if (options.defaults && components.length === 0) {
if (options.defaults && !components.some(isUrl)) {
const initUrl = resolveInitUrl(
{
...DEFAULT_PRESETS.nova,

View File

@@ -55,7 +55,7 @@ export const DEFAULT_PRESETS = {
},
lyra: {
title: "Lyra",
description: "Tabler / JetBrains Mono",
description: "Hugeicons / JetBrains Mono",
style: "lyra",
baseColor: "neutral",
theme: "neutral",

View File

@@ -549,7 +549,9 @@ describe("shadcn init - next-monorepo", () => {
"-t",
"next-monorepo",
"--preset",
"radix-nova",
"nova",
"--base",
"radix",
],
{ timeout: 300000, debug: true }
)

View File

@@ -1042,8 +1042,6 @@ describe("registries", () => {
"--yes",
])
expect(output.stderr).toContain("Updating CSS variables in app/globals.css")
const globalCssContent = await fs.readFile(
path.join(fixturePath, "app/globals.css"),
"utf-8"
@@ -1204,7 +1202,12 @@ describe("registries:init", () => {
"@one": "http://localhost:4444/r/{name}",
})
await npxShadcn(fixturePath, ["init", "--force", "@one/style"])
await npxShadcn(fixturePath, [
"init",
"--force",
"--no-reinstall",
"@one/style",
])
const componentsJson = await fs.readJson(
path.join(fixturePath, "components.json")
@@ -1272,7 +1275,12 @@ describe("registries:init", () => {
process.env.BEARER_TOKEN = "EXAMPLE_BEARER_TOKEN"
await npxShadcn(fixturePath, ["init", "--force", "@two/style"])
await npxShadcn(fixturePath, [
"init",
"--force",
"--no-reinstall",
"@two/style",
])
const componentsJson = await fs.readJson(
path.join(fixturePath, "components.json")