feat(cli): add placeholder generate command (#738)

This commit is contained in:
pooya parsa 2021-10-12 10:52:28 +02:00 committed by GitHub
parent d1e0af928e
commit 096b0e3305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,26 @@
import { resolve } from 'pathe'
import { isNuxt3 } from '@nuxt/kit'
import { importModule } from '../utils/cjs'
import { defineNuxtCommand } from './index'
export default defineNuxtCommand({
meta: {
name: 'generate',
usage: 'npx nuxi generate [rootDir]',
description: ''
},
async invoke (args) {
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const rootDir = resolve(args._[0] || '.')
const { loadNuxt } = await importModule('@nuxt/kit', rootDir) as typeof import('@nuxt/kit')
const nuxt = await loadNuxt({ rootDir })
if (isNuxt3(nuxt)) {
throw new Error('`nuxt generate` is not supported in Nuxt 3. Please follow this RFC: https://git.io/JKfvx')
} else {
throw new Error('Please use `nuxt generate` for Nuxt 2 instead of `nuxi generate`')
}
}
})

View File

@ -5,6 +5,7 @@ const _rDefault = r => r.default || r
export const commands = { export const commands = {
dev: () => import('./dev').then(_rDefault), dev: () => import('./dev').then(_rDefault),
build: () => import('./build').then(_rDefault), build: () => import('./build').then(_rDefault),
generate: () => import('./generate').then(_rDefault),
prepare: () => import('./prepare').then(_rDefault), prepare: () => import('./prepare').then(_rDefault),
usage: () => import('./usage').then(_rDefault), usage: () => import('./usage').then(_rDefault),
info: () => import('./info').then(_rDefault), info: () => import('./info').then(_rDefault),