Skip to content

Commit

Permalink
refactor: init CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
selemondev committed Nov 11, 2024
1 parent 384c87a commit f54b42a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -39,6 +39,9 @@ const PROJECT_DEPENDENCIES = {
'tailwind-merge',
'radix-vue',
],
nuxt: [
'shadcn-nuxt',
],
}

const initOptionsSchema = z.object({
Expand Down Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion packages/module/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f54b42a

Please sign in to comment.