refactor(cli): don't reinstall deps when shadcn-nuxt is available
This commit is contained in:
parent
486a06874b
commit
3b7aca7ac7
|
|
@ -9,6 +9,8 @@ import { z } from 'zod'
|
||||||
import { addDependency, addDevDependency } from 'nypm'
|
import { addDependency, addDevDependency } from 'nypm'
|
||||||
import { consola } from 'consola'
|
import { consola } from 'consola'
|
||||||
import { colors } from 'consola/utils'
|
import { colors } from 'consola/utils'
|
||||||
|
import { gte } from 'semver'
|
||||||
|
import { getProjectInfo } from '../utils/get-project-info'
|
||||||
import * as templates from '../utils/templates'
|
import * as templates from '../utils/templates'
|
||||||
import {
|
import {
|
||||||
getRegistryBaseColor,
|
getRegistryBaseColor,
|
||||||
|
|
@ -239,6 +241,15 @@ export async function promptForConfig(
|
||||||
export async function runInit(cwd: string, config: Config) {
|
export async function runInit(cwd: string, config: Config) {
|
||||||
const spinner = ora('Initializing project...')?.start()
|
const spinner = ora('Initializing project...')?.start()
|
||||||
|
|
||||||
|
// Check in in a Nuxt project.
|
||||||
|
const { isNuxt, shadcnNuxt } = await getProjectInfo()
|
||||||
|
if (isNuxt) {
|
||||||
|
consola.log('')
|
||||||
|
shadcnNuxt
|
||||||
|
? consola.info(`Detected a Nuxt project with 'shadcn-nuxt' v${shadcnNuxt.version}...`)
|
||||||
|
: consola.warn(`Detected a Nuxt project without 'shadcn-nuxt' module. It's recommended to install it.`)
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure all resolved paths directories exist.
|
// Ensure all resolved paths directories exist.
|
||||||
for (const [key, resolvedPath] of Object.entries(config.resolvedPaths)) {
|
for (const [key, resolvedPath] of Object.entries(config.resolvedPaths)) {
|
||||||
// Determine if the path is a file or directory.
|
// Determine if the path is a file or directory.
|
||||||
|
|
@ -299,9 +310,9 @@ export async function runInit(cwd: string, config: Config) {
|
||||||
// Install dependencies.
|
// Install dependencies.
|
||||||
const dependenciesSpinner = ora('Installing dependencies...')?.start()
|
const dependenciesSpinner = ora('Installing dependencies...')?.start()
|
||||||
|
|
||||||
const deps = PROJECT_DEPENDENCIES.base.concat(
|
const baseDeps = gte(shadcnNuxt?.version || '', '0.10.4') ? [] : PROJECT_DEPENDENCIES.base
|
||||||
config.style === 'new-york' ? ['@radix-icons/vue'] : ['lucide-vue-next'],
|
const iconsDep = config.style === 'new-york' ? ['@radix-icons/vue'] : ['lucide-vue-next']
|
||||||
).filter(Boolean)
|
const deps = baseDeps.concat(iconsDep).filter(Boolean)
|
||||||
|
|
||||||
await Promise.allSettled(
|
await Promise.allSettled(
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user