Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
sadeghbarati 2024-05-26 08:43:58 +03:30
commit 9fa948ea81
13 changed files with 1396 additions and 1449 deletions

16
.github/actions/setup/action.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Setup
description: Installs Node, Enables Corepack and caches pnpm.
runs:
using: composite
steps:
- name: Enable corepack
run: corepack enable
shell: bash
- name: Setup node & pnpm
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm

View File

@ -48,32 +48,10 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Run a build step here - name: Setup (Install Node & pnpm)
- name: Setup Node.js environment uses: ./.github/actions/setup
uses: actions/setup-node@v2
with:
node-version: 18
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 9.1.2
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies - name: Install dependencies
run: pnpm i --frozen-lockfile run: pnpm i --frozen-lockfile

View File

@ -14,14 +14,13 @@ jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-node@v3 - name: Setup (Install Node & pnpm)
with: uses: ./.github/actions/setup
node-version: 18.x
- run: npx changelogithub - run: pnpm dlx changelogithub
env: env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

View File

@ -19,31 +19,10 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Setup Node.js environment - name: Setup (Install Node & pnpm)
uses: actions/setup-node@v2 uses: ./.github/actions/setup
with:
node-version: 18
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 9.0.5
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies - name: Install dependencies
run: pnpm i --frozen-lockfile run: pnpm i --frozen-lockfile

View File

@ -66,8 +66,10 @@
"ofetch": "^1.3.4", "ofetch": "^1.3.4",
"ora": "^8.0.1", "ora": "^8.0.1",
"pathe": "^1.1.2", "pathe": "^1.1.2",
"pkg-types": "^1.1.0",
"prompts": "^2.4.2", "prompts": "^2.4.2",
"radix-vue": "^1.7.3", "radix-vue": "^1.7.3",
"semver": "^7.6.0",
"ts-morph": "^22.0.0", "ts-morph": "^22.0.0",
"tsconfig-paths": "^4.2.0", "tsconfig-paths": "^4.2.0",
"zod": "^3.23.3" "zod": "^3.23.3"

View File

@ -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,10 @@ 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( // 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
config.style === 'new-york' ? ['@radix-icons/vue'] : ['lucide-vue-next'], const baseDeps = gte(shadcnNuxt?.version || '0.0.0', '0.10.4') ? [] : PROJECT_DEPENDENCIES.base
).filter(Boolean) const iconsDep = config.style === 'new-york' ? ['@radix-icons/vue'] : ['lucide-vue-next']
const deps = baseDeps.concat(iconsDep).filter(Boolean)
await Promise.allSettled( await Promise.allSettled(
[ [

View File

@ -1,11 +1,14 @@
import { existsSync } from 'node:fs' import { existsSync } from 'node:fs'
import path from 'pathe' import path from 'pathe'
import fs from 'fs-extra' import fs from 'fs-extra'
import { readPackageJSON } from 'pkg-types'
import type { PackageJson } from 'pkg-types'
export async function getProjectInfo() { export async function getProjectInfo() {
const info = { const info = {
tsconfig: null, tsconfig: null,
isNuxt: false, isNuxt: false,
shadcnNuxt: undefined,
isVueVite: false, isVueVite: false,
srcDir: false, srcDir: false,
componentsUiDir: false, componentsUiDir: false,
@ -15,9 +18,13 @@ export async function getProjectInfo() {
try { try {
const tsconfig = await getTsConfig() const tsconfig = await getTsConfig()
const isNuxt = existsSync(path.resolve('./nuxt.config.js')) || existsSync(path.resolve('./nuxt.config.ts'))
const shadcnNuxt = isNuxt ? await getShadcnNuxtInfo() : undefined
return { return {
tsconfig, tsconfig,
isNuxt: existsSync(path.resolve('./nuxt.config.js')) || existsSync(path.resolve('./nuxt.config.ts')), isNuxt,
shadcnNuxt,
isVueVite: existsSync(path.resolve('./vite.config.js')) || existsSync(path.resolve('./vite.config.ts')), isVueVite: existsSync(path.resolve('./vite.config.js')) || existsSync(path.resolve('./vite.config.ts')),
srcDir: existsSync(path.resolve('./src')), srcDir: existsSync(path.resolve('./src')),
srcComponentsUiDir: existsSync(path.resolve('./src/components/ui')), srcComponentsUiDir: existsSync(path.resolve('./src/components/ui')),
@ -29,6 +36,18 @@ export async function getProjectInfo() {
} }
} }
async function getShadcnNuxtInfo() {
let nuxtModule: PackageJson | undefined
try {
nuxtModule = await readPackageJSON('shadcn-nuxt')
}
catch (error) {
nuxtModule = undefined
}
return nuxtModule
}
export async function getTsConfig() { export async function getTsConfig() {
try { try {
const tsconfigPath = path.join('tsconfig.json') const tsconfigPath = path.join('tsconfig.json')

View File

@ -36,7 +36,10 @@
}, },
"dependencies": { "dependencies": {
"@nuxt/kit": "^3.11.2", "@nuxt/kit": "^3.11.2",
"@oxc-parser/wasm": "^0.1.0" "@oxc-parser/wasm": "^0.1.0",
"class-variance-authority": "^0.7.0",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7"
}, },
"devDependencies": { "devDependencies": {
"@nuxt/eslint-config": "^0.3.10", "@nuxt/eslint-config": "^0.3.10",

View File

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

View File

@ -8,17 +8,13 @@
"generate": "nuxi generate" "generate": "nuxi generate"
}, },
"dependencies": { "dependencies": {
"class-variance-authority": "^0.7.0", "@nuxtjs/tailwindcss": "^6.10.1",
"clsx": "^2.1.1",
"embla-carousel": "8.0.0-rc19",
"embla-carousel-vue": "8.0.0-rc19", "embla-carousel-vue": "8.0.0-rc19",
"lucide-vue-next": "^0.276.0", "lucide-vue-next": "^0.276.0"
"radix-vue": "^1.7.2",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7"
}, },
"devDependencies": { "devDependencies": {
"@nuxtjs/tailwindcss": "^6.12.0", "@nuxtjs/tailwindcss": "^6.12.0",
"nuxt": "latest" "nuxt": "latest",
"shadcn-nuxt": "file:.."
} }
} }

View File

@ -8,7 +8,7 @@ import { UTILS } from '../../cli/src/utils/templates'
// Module options TypeScript interface definition // Module options TypeScript interface definition
export interface ModuleOptions { export interface ModuleOptions {
/** /**
* Prefix for all the imported component * Prefix for all the imported component.
*/ */
prefix?: string prefix?: string
/** /**

File diff suppressed because it is too large Load Diff