1
- import { readFileSync } from 'node:fs '
1
+ import type { NuxtOptions } from '@nuxt/schema '
2
2
3
+ import { readFileSync } from 'node:fs'
3
4
import { colors } from 'consola/utils'
4
5
import { resolveModulePath } from 'exsolve'
5
6
6
- import { loadKit , tryResolveNuxt } from './kit'
7
+ import { tryResolveNuxt } from './kit'
7
8
import { logger } from './logger'
8
9
9
- export async function showVersions ( cwd : string ) {
10
+ export function showVersionsFromConfig ( cwd : string , config : NuxtOptions ) {
10
11
const { bold, gray, green } = colors
11
- const nuxtDir = tryResolveNuxt ( cwd )
12
-
13
- const kit = await loadKit ( cwd )
14
- const config = await kit . loadNuxtConfig ( { cwd } )
15
12
16
13
function getBuilder ( ) : { name : string , version : string } {
17
- switch ( config . builder ) {
14
+ switch ( config ! . builder ) {
18
15
case '@nuxt/rspack-builder' :
19
16
return { name : 'Rspack' , version : getPkgVersion ( '@rspack/core' ) }
20
17
case '@nuxt/webpack-builder' :
@@ -29,7 +26,7 @@ export async function showVersions(cwd: string) {
29
26
}
30
27
31
28
function getPkgJSON ( pkg : string ) {
32
- for ( const url of [ cwd , nuxtDir ] ) {
29
+ for ( const url of [ cwd , tryResolveNuxt ( cwd ) ] ) {
33
30
if ( ! url ) {
34
31
continue
35
32
}
@@ -60,3 +57,9 @@ export async function showVersions(cwd: string) {
60
57
+ gray ( ')' ) ,
61
58
)
62
59
}
60
+
61
+ export async function showVersions ( cwd : string , kit : typeof import ( '@nuxt/kit' ) ) {
62
+ const config = await kit . loadNuxtConfig ( { cwd } )
63
+
64
+ return showVersionsFromConfig ( cwd , config )
65
+ }
0 commit comments