diff --git a/apps/www/src/content/docs/installation/astro.md b/apps/www/src/content/docs/installation/astro.md index b57f5475..470de011 100644 --- a/apps/www/src/content/docs/installation/astro.md +++ b/apps/www/src/content/docs/installation/astro.md @@ -104,7 +104,7 @@ Would you like to use TypeScript (recommended)? no / yes Which framework are you using? Astro Which style would you like to use? › Default Which color would you like to use as base color? › Slate -Where is your typescript configuration file? › ./tsconfig.json +Where is your tsconfig.json located? › ./tsconfig.json Where is your global CSS file? › src/styles/globals.css Do you want to use CSS variables for colors? › no / yes Where is your tailwind.config located? › tailwind.config.mjs diff --git a/apps/www/src/content/docs/installation/laravel.md b/apps/www/src/content/docs/installation/laravel.md index 1a2e47dc..a86bc62f 100644 --- a/apps/www/src/content/docs/installation/laravel.md +++ b/apps/www/src/content/docs/installation/laravel.md @@ -30,7 +30,7 @@ Would you like to use TypeScript (recommended)? no / yes Which framework are you using? Vite / Nuxt / Laravel Which style would you like to use? › Default Which color would you like to use as base color? › Slate -Where is your typescript configuration file? › ./tsconfig.json +Where is your tsconfig.json located? › ./tsconfig.json Where is your global CSS file? › resources/css/app.css Do you want to use CSS variables for colors? › no / yes Where is your tailwind.config.js located? › tailwind.config.js diff --git a/apps/www/src/content/docs/installation/nuxt.md b/apps/www/src/content/docs/installation/nuxt.md index 302a9f8c..13c1b018 100644 --- a/apps/www/src/content/docs/installation/nuxt.md +++ b/apps/www/src/content/docs/installation/nuxt.md @@ -184,7 +184,7 @@ Would you like to use TypeScript (recommended)? no / yes Which framework are you using? Vite / Nuxt / Laravel Which style would you like to use? › Default Which color would you like to use as base color? › Slate -Where is your typescript configuration file? › ./tsconfig.json +Where is your tsconfig.json located? › ./tsconfig.json Where is your global CSS file? › › src/index.css Do you want to use CSS variables for colors? › no / yes Where is your tailwind.config.js located? › tailwind.config.js diff --git a/apps/www/src/content/docs/installation/vite.md b/apps/www/src/content/docs/installation/vite.md index cb98211d..5f99b6c6 100644 --- a/apps/www/src/content/docs/installation/vite.md +++ b/apps/www/src/content/docs/installation/vite.md @@ -159,7 +159,7 @@ Would you like to use TypeScript (recommended)? no / yes Which framework are you using? Vite / Nuxt / Laravel Which style would you like to use? › Default Which color would you like to use as base color? › Slate -Where is your typescript configuration file? › ./tsconfig.json +Where is your tsconfig.json located? › ./tsconfig.json Where is your global CSS file? › › src/index.css Do you want to use CSS variables for colors? › no / yes Where is your tailwind.config.js located? › tailwind.config.js diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 05e24c48..4bac72c4 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -135,6 +135,16 @@ export async function promptForConfig( value: color.name, })), }, + { + type: 'text', + name: 'tsConfigPath', + message: (prev, values) => `Where is your ${highlight(values.typescript ? 'tsconfig.json' : 'jsconfig.json')} file?`, + initial: (prev, values) => { + const prefix = values.framework === 'nuxt' ? '.nuxt/' : './' + const path = values.typescript ? 'tsconfig.json' : 'jsconfig.json' + return prefix + path + }, + }, { type: 'text', name: 'tailwindCss', @@ -189,6 +199,7 @@ export async function promptForConfig( $schema: 'https://shadcn-vue.com/schema.json', style: options.style, typescript: options.typescript, + tsConfigPath: options.tsConfigPath, framework: options.framework, tailwind: { config: options.tailwindConfig, diff --git a/packages/cli/src/utils/get-config.ts b/packages/cli/src/utils/get-config.ts index a664e22e..cfd9a65c 100644 --- a/packages/cli/src/utils/get-config.ts +++ b/packages/cli/src/utils/get-config.ts @@ -25,6 +25,7 @@ export const rawConfigSchema = z $schema: z.string().optional(), style: z.string(), typescript: z.boolean().default(true), + tsConfigPath: z.string().default(DEFAULT_TYPESCRIPT_CONFIG), tailwind: z.object({ config: z.string(), css: z.string(), @@ -33,7 +34,6 @@ export const rawConfigSchema = z prefix: z.string().optional(), }), framework: z.string().default('Vite'), - tsConfigPath: z.string().default('./tsconfig.json'), aliases: z.object({ components: z.string(), utils: z.string(), @@ -85,10 +85,9 @@ export async function resolveConfigPaths(cwd: string, config: RawConfig) { } } else { - tsConfigPath = path.resolve(cwd, './jsconfig.json') + tsConfigPath = config.tsConfigPath.includes('tsconfig.json') ? path.resolve(cwd, './jsconfig.json') : path.resolve(cwd, config.tsConfigPath) tsConfig = loadConfig(tsConfigPath) } - if (tsConfig.resultType === 'failed') { throw new Error( `Failed to load ${tsConfigPath}. ${tsConfig.message ?? ''}`.trim(),