mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
feat(nuxi): display nuxt and nitro versions for dev and build commands (#7118)
This commit is contained in:
parent
6fbbf8c5bc
commit
2d30a1db8b
@ -4,6 +4,7 @@ import { writeTypes } from '../utils/prepare'
|
||||
import { loadKit } from '../utils/kit'
|
||||
import { clearDir } from '../utils/fs'
|
||||
import { overrideEnv } from '../utils/env'
|
||||
import { showVersions } from '../utils/banner'
|
||||
import { defineNuxtCommand } from './index'
|
||||
|
||||
export default defineNuxtCommand({
|
||||
@ -16,6 +17,7 @@ export default defineNuxtCommand({
|
||||
overrideEnv('production')
|
||||
|
||||
const rootDir = resolve(args._[0] || '.')
|
||||
showVersions(rootDir)
|
||||
|
||||
const { loadNuxt, buildNuxt } = await loadKit(rootDir)
|
||||
|
||||
|
@ -7,7 +7,7 @@ import type { Nuxt } from '@nuxt/schema'
|
||||
import consola from 'consola'
|
||||
import { withTrailingSlash } from 'ufo'
|
||||
import { setupDotenv } from 'c12'
|
||||
import { showBanner } from '../utils/banner'
|
||||
import { showBanner, showVersions } from '../utils/banner'
|
||||
import { writeTypes } from '../utils/prepare'
|
||||
import { loadKit } from '../utils/kit'
|
||||
import { importModule } from '../utils/cjs'
|
||||
@ -38,6 +38,8 @@ export default defineNuxtCommand({
|
||||
}
|
||||
|
||||
const rootDir = resolve(args._[0] || '.')
|
||||
showVersions(rootDir)
|
||||
|
||||
await setupDotenv({ cwd: rootDir })
|
||||
|
||||
const listener = await listen(serverHandler, {
|
||||
|
@ -63,6 +63,7 @@ export default defineNuxtCommand({
|
||||
OperatingSystem: os.type(),
|
||||
NodeVersion: process.version,
|
||||
NuxtVersion: nuxtVersion,
|
||||
NitroVersion: getDepVersion('nitropack'),
|
||||
PackageManager: packageManager,
|
||||
Builder: builder,
|
||||
UserConfig: Object.keys(nuxtConfig).map(key => '`' + key + '`').join(', '),
|
||||
|
@ -1,8 +1,26 @@
|
||||
import { createRequire } from 'node:module'
|
||||
import clear from 'clear'
|
||||
import { green } from 'colorette'
|
||||
import { bold, gray, green } from 'colorette'
|
||||
import { version } from '../../package.json'
|
||||
|
||||
export function showBanner (_clear?: boolean) {
|
||||
if (_clear) { clear() }
|
||||
console.log(green(`Nuxt CLI v${version}`))
|
||||
console.log(gray(`Nuxi ${(bold(version))}`))
|
||||
}
|
||||
|
||||
export function showVersions (cwd: string) {
|
||||
const _require = createRequire(cwd)
|
||||
const getPkgVersion = (pkg: string) => {
|
||||
try {
|
||||
const { version } = _require(`${pkg}/package.json`)
|
||||
return version || ''
|
||||
} catch { /* not found */ }
|
||||
return ''
|
||||
}
|
||||
const nuxtVersion = getPkgVersion('nuxt') || getPkgVersion('nuxt-edge')
|
||||
const nitroVersion = getPkgVersion('nitropack')
|
||||
console.log(gray(
|
||||
green(`Nuxt ${bold(nuxtVersion)}`) +
|
||||
(nitroVersion ? ` with Nitro ${(bold(nitroVersion))}` : '')
|
||||
))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user