1
1
import { promises as fs } from "fs"
2
2
import path from "path"
3
3
import { preFlightInit } from "@/src/preflights/preflight-init"
4
- import { getRegistryBaseColors , getRegistryStyles } from "@/src/registry/api"
4
+ import {
5
+ BASE_COLORS ,
6
+ getRegistryBaseColors ,
7
+ getRegistryStyles ,
8
+ } from "@/src/registry/api"
5
9
import { addComponents } from "@/src/utils/add-components"
6
10
import { TEMPLATES , createProject } from "@/src/utils/create-project"
7
11
import * as ERRORS from "@/src/utils/errors"
@@ -53,6 +57,23 @@ export const initOptionsSchema = z.object({
53
57
message : "Invalid template. Please use 'next' or 'next-monorepo'." ,
54
58
}
55
59
) ,
60
+ baseColor : z
61
+ . string ( )
62
+ . optional ( )
63
+ . refine (
64
+ ( val ) => {
65
+ if ( val ) {
66
+ return BASE_COLORS . find ( ( color ) => color . name === val )
67
+ }
68
+
69
+ return true
70
+ } ,
71
+ {
72
+ message : `Invalid base color. Please use '${ BASE_COLORS . map (
73
+ ( color ) => color . name
74
+ ) . join ( "', '" ) } '`,
75
+ }
76
+ ) ,
56
77
} )
57
78
58
79
export const init = new Command ( )
@@ -64,8 +85,12 @@ export const init = new Command()
64
85
)
65
86
. option (
66
87
"-t, --template <template>" ,
67
- "the template to use. (next, next-monorepo)" ,
68
- ""
88
+ "the template to use. (next, next-monorepo)"
89
+ )
90
+ . option (
91
+ "-b, --base-color <base-color>" ,
92
+ "the base color to use. (neutral, gray, zinc, stone, slate)" ,
93
+ undefined
69
94
)
70
95
. option ( "-y, --yes" , "skip confirmation prompt." , true )
71
96
. option ( "-d, --defaults," , "use default configuration." , false )
@@ -311,7 +336,7 @@ async function promptForMinimalConfig(
311
336
opts : z . infer < typeof initOptionsSchema >
312
337
) {
313
338
let style = defaultConfig . style
314
- let baseColor = defaultConfig . tailwind . baseColor
339
+ let baseColor = opts . baseColor
315
340
let cssVariables = defaultConfig . tailwind . cssVariables
316
341
317
342
if ( ! opts . defaults ) {
@@ -334,7 +359,7 @@ async function promptForMinimalConfig(
334
359
initial : 0 ,
335
360
} ,
336
361
{
337
- type : "select" ,
362
+ type : opts . baseColor ? null : "select" ,
338
363
name : "tailwindBaseColor" ,
339
364
message : `Which color would you like to use as the ${ highlighter . info (
340
365
"base color"
@@ -347,7 +372,7 @@ async function promptForMinimalConfig(
347
372
] )
348
373
349
374
style = options . style ?? "new-york"
350
- baseColor = options . tailwindBaseColor
375
+ baseColor = options . tailwindBaseColor ?? baseColor
351
376
cssVariables = opts . cssVariables
352
377
}
353
378
0 commit comments