refactor: 815 shadcn-nuxt dependencies and CLI init

Closes: 815
This commit is contained in:
selemondev 2024-10-20 12:53:19 +03:00
parent f9615d3657
commit 04b647217c
7 changed files with 855 additions and 781 deletions

View File

@ -30,6 +30,9 @@
"taze": "taze major -frI --ignore-paths ./packages/cli/test/** --exclude typescript,/@iconify/",
"taze:minor": "taze minor -fwri --ignore-paths ./packages/cli/test/** --exclude /@iconify/"
},
"dependencies": {
"shadcn-nuxt": "^0.10.4"
},
"devDependencies": {
"@antfu/eslint-config": "^3.6.2",
"@commitlint/cli": "^19.5.0",

View File

@ -4,11 +4,10 @@ import { Command } from 'commander'
import { consola } from 'consola'
import { colors } from 'consola/utils'
import { template } from 'lodash-es'
import { addDependency, addDevDependency } from 'nypm'
import { addDependency } from 'nypm'
import ora from 'ora'
import path from 'pathe'
import prompts from 'prompts'
import { gte } from 'semver'
import { z } from 'zod'
import {
type Config,
@ -40,9 +39,6 @@ const PROJECT_DEPENDENCIES = {
'tailwind-merge',
'radix-vue',
],
nuxt: [
'@nuxtjs/tailwindcss',
],
}
const initOptionsSchema = z.object({
@ -310,23 +306,18 @@ export async function runInit(cwd: string, config: Config) {
// Install dependencies.
const dependenciesSpinner = ora('Installing dependencies...')?.start()
// Starting from `shadcn-nuxt` version 0.10.4, Base dependencies are handled by the module so no need to re-add them by the CLI
const baseDeps = gte(shadcnNuxt?.version || '0.0.0', '0.10.4') ? [] : PROJECT_DEPENDENCIES.base
const iconsDep = config.style === 'new-york' ? ['@radix-icons/vue'] : ['lucide-vue-next']
const deps = baseDeps.concat(iconsDep).filter(Boolean)
// Starting from `shadcn-nuxt` version 0.10.4, Base dependencies are handled by the module so no need to re-add them by the CLI.
// Unfortunately, the dependencies are not available when using the latest `shadcn-nuxt` module. Hence why we need to rely on the CLI to install the required deps for both Nuxt 3 and Vue 3.
// Install the required deps.
const iconsDep = config.style === 'new-york' ? ['@radix-icons/vue'] : ['lucide-vue-next']
const deps = PROJECT_DEPENDENCIES.base.concat(iconsDep).filter(Boolean)
await Promise.allSettled(
[
config.framework === 'nuxt' && await addDevDependency(PROJECT_DEPENDENCIES.nuxt, {
cwd,
silent: true,
}),
await addDependency(deps, {
cwd,
silent: true,
}),
],
)
})
dependenciesSpinner?.succeed()
}

View File

@ -1,7 +1,7 @@
{
"name": "shadcn-nuxt",
"type": "module",
"version": "0.11.0",
"version": "0.10.4",
"description": "Add shadcn-vue module to Nuxt",
"publishConfig": {
"access": "public"

View File

@ -1,5 +1,5 @@
export default defineNuxtConfig({
modules: ['@nuxtjs/tailwindcss', 'shadcn-nuxt'],
modules: ['shadcn-nuxt'],
shadcn: {
prefix: 'Ui',
},

View File

@ -10,11 +10,10 @@
"dependencies": {
"@nuxtjs/tailwindcss": "^6.10.1",
"embla-carousel-vue": "8.0.0-rc19",
"lucide-vue-next": "^0.276.0"
"lucide-vue-next": "^0.276.0",
"shadcn-nuxt": "^0.10.4"
},
"devDependencies": {
"@nuxtjs/tailwindcss": "^6.12.0",
"nuxt": "latest",
"shadcn-nuxt": "file:.."
"nuxt": "latest"
}
}

View File

@ -59,6 +59,10 @@ export default defineNuxtModule<ModuleOptions>({
})
})
// Install the `@nuxtjs/tailwindcss` module.
await installModule('@nuxtjs/tailwindcss')
// Installs the `@nuxtjs/color-mode` module.
await installModule('@nuxtjs/color-mode', {

File diff suppressed because it is too large Load Diff