@@ -2,7 +2,6 @@ import { existsSync, promises as fs } from "fs"
2
2
import path from "path"
3
3
import {
4
4
DEFAULT_COMPONENTS ,
5
- DEFAULT_TAILWIND_BASE_COLOR ,
6
5
DEFAULT_TAILWIND_CONFIG ,
7
6
DEFAULT_TAILWIND_CSS ,
8
7
DEFAULT_UTILS ,
@@ -23,6 +22,7 @@ import * as templates from "@/src/utils/templates"
23
22
import chalk from "chalk"
24
23
import { Command } from "commander"
25
24
import { execa } from "execa"
25
+ import template from "lodash.template"
26
26
import ora from "ora"
27
27
import prompts from "prompts"
28
28
import * as z from "zod"
@@ -86,6 +86,16 @@ export async function promptForConfig(
86
86
const baseColors = await getRegistryBaseColors ( )
87
87
88
88
const options = await prompts ( [
89
+ {
90
+ type : "toggle" ,
91
+ name : "typescript" ,
92
+ message : `Would you like to use ${ highlight (
93
+ "TypeScript"
94
+ ) } (recommended)?`,
95
+ initial : defaultConfig ?. tsx ?? true ,
96
+ active : "yes" ,
97
+ inactive : "no" ,
98
+ } ,
89
99
{
90
100
type : "select" ,
91
101
name : "style" ,
@@ -115,7 +125,9 @@ export async function promptForConfig(
115
125
{
116
126
type : "toggle" ,
117
127
name : "tailwindCssVariables" ,
118
- message : `Do you want to use ${ highlight ( "CSS variables" ) } for colors?` ,
128
+ message : `Would you like to use ${ highlight (
129
+ "CSS variables"
130
+ ) } for colors?`,
119
131
initial : defaultConfig ?. tailwind . cssVariables ?? true ,
120
132
active : "yes" ,
121
133
inactive : "no" ,
@@ -158,6 +170,7 @@ export async function promptForConfig(
158
170
cssVariables : options . tailwindCssVariables ,
159
171
} ,
160
172
rsc : options . rsc ,
173
+ tsx : options . typescript ,
161
174
aliases : {
162
175
utils : options . utils ,
163
176
components : options . components ,
@@ -213,12 +226,14 @@ export async function runInit(cwd: string, config: Config) {
213
226
}
214
227
}
215
228
229
+ const extension = config . tsx ? "ts" : "js"
230
+
216
231
// Write tailwind config.
217
232
await fs . writeFile (
218
233
config . resolvedPaths . tailwindConfig ,
219
234
config . tailwind . cssVariables
220
- ? templates . TAILWIND_CONFIG_WITH_VARIABLES
221
- : templates . TAILWIND_CONFIG ,
235
+ ? template ( templates . TAILWIND_CONFIG_WITH_VARIABLES ) ( { extension } )
236
+ : template ( templates . TAILWIND_CONFIG ) ( { extension } ) ,
222
237
"utf8"
223
238
)
224
239
@@ -236,8 +251,8 @@ export async function runInit(cwd: string, config: Config) {
236
251
237
252
// Write cn file.
238
253
await fs . writeFile (
239
- `${ config . resolvedPaths . utils } .ts ` ,
240
- templates . UTILS ,
254
+ `${ config . resolvedPaths . utils } .${ extension } ` ,
255
+ extension === "ts" ? templates . UTILS : templates . UTILS_JS ,
241
256
"utf8"
242
257
)
243
258
0 commit comments