diff --git a/.changeset/fluffy-years-knock.md b/.changeset/fluffy-years-knock.md new file mode 100644 index 0000000000..fc167c719e --- /dev/null +++ b/.changeset/fluffy-years-knock.md @@ -0,0 +1,5 @@ +--- +"shadcn": minor +--- + +add --base-color flag diff --git a/packages/shadcn/src/commands/init.ts b/packages/shadcn/src/commands/init.ts index cbbaff855d..4d7e85140a 100644 --- a/packages/shadcn/src/commands/init.ts +++ b/packages/shadcn/src/commands/init.ts @@ -1,7 +1,11 @@ import { promises as fs } from "fs" import path from "path" import { preFlightInit } from "@/src/preflights/preflight-init" -import { getRegistryBaseColors, getRegistryStyles } from "@/src/registry/api" +import { + BASE_COLORS, + getRegistryBaseColors, + getRegistryStyles, +} from "@/src/registry/api" import { addComponents } from "@/src/utils/add-components" import { TEMPLATES, createProject } from "@/src/utils/create-project" import * as ERRORS from "@/src/utils/errors" @@ -53,6 +57,23 @@ export const initOptionsSchema = z.object({ message: "Invalid template. Please use 'next' or 'next-monorepo'.", } ), + baseColor: z + .string() + .optional() + .refine( + (val) => { + if (val) { + return BASE_COLORS.find((color) => color.name === val) + } + + return true + }, + { + message: `Invalid base color. Please use '${BASE_COLORS.map( + (color) => color.name + ).join("', '")}'`, + } + ), }) export const init = new Command() @@ -64,8 +85,12 @@ export const init = new Command() ) .option( "-t, --template