feat: support root option

This commit is contained in:
Dunqing 2023-09-15 15:27:21 +08:00
parent 09feb74ebe
commit a528711b99
3 changed files with 9 additions and 0 deletions

View File

@ -116,6 +116,12 @@ export async function promptForConfig(
{ title: 'Nuxt', value: 'nuxt' },
],
},
{
type: 'text',
name: 'root',
message: `Where is your ${highlight('source code')} folder located`,
initial: (prev, values) => defaultConfig?.root ?? values.framework === 'nuxt' ? '.' : 'src',
},
{
type: 'select',
name: 'style',
@ -174,6 +180,7 @@ export async function promptForConfig(
const config = rawConfigSchema.parse({
// $schema: 'https://ui.shadcn.com/schema.json',
root: options.root,
style: options.style,
typescript: options.typescript,
framework: options.framework,

View File

@ -23,6 +23,7 @@ const explorer = cosmiconfig('components', {
export const rawConfigSchema = z
.object({
$schema: z.string().optional(),
root: z.string(),
style: z.string(),
typescript: z.boolean().default(false),
tailwind: z.object({

View File

@ -129,6 +129,7 @@ export function getItemTargetPath(
return null
return path.join(
config.typescript ? '' : config.root,
config.resolvedPaths[parent as keyof typeof config.resolvedPaths],
type,
)