refactor: init CLI

This commit is contained in:
selemondev 2024-11-11 12:00:57 +03:00
parent 384c87a91c
commit f54b42af0a
2 changed files with 20 additions and 6 deletions

View File

@ -4,7 +4,7 @@ import { Command } from 'commander'
import { consola } from 'consola'
import { colors } from 'consola/utils'
import { template } from 'lodash-es'
import { addDependency } from 'nypm'
import { addDependency, addDevDependency } from 'nypm'
import ora from 'ora'
import path from 'pathe'
import prompts from 'prompts'
@ -39,6 +39,9 @@ const PROJECT_DEPENDENCIES = {
'tailwind-merge',
'radix-vue',
],
nuxt: [
'shadcn-nuxt',
],
}
const initOptionsSchema = z.object({
@ -309,10 +312,21 @@ export async function runInit(cwd: string, config: Config) {
const iconsDep = config.style === 'new-york' ? ['@radix-icons/vue'] : ['lucide-vue-next']
const deps = PROJECT_DEPENDENCIES.base.concat(iconsDep).filter(Boolean)
await addDependency(deps, {
cwd,
silent: true,
})
await Promise.allSettled(
[
config.framework === 'nuxt' && await addDevDependency(
[...PROJECT_DEPENDENCIES.nuxt, ...deps],
{
cwd,
silent: true,
},
),
await addDependency(deps, {
cwd,
silent: true,
}),
],
)
dependenciesSpinner?.succeed()
}

View File

@ -63,7 +63,7 @@ export default defineNuxtModule<ModuleOptions>({
await installModule('@nuxtjs/tailwindcss')
// Installs the `@nuxtjs/color-mode` module.
await installModule('@nuxtjs/color-mode')
await installModule('@nuxtjs/color-mode', { classSuffix: '' })
// Manually scan `componentsDir` for components and register them for auto imports
try {