@@ -3,11 +3,11 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
33import { createInterface } from 'node:readline/promises'
44import { stdin as input , stdout as output } from 'node:process'
55import { resolve } from 'pathe'
6- import { consola } from 'consola'
76import { createMain , defineCommand } from 'citty'
87
98import ensureNuxtProject from './utils/ensure-nuxt-project'
109import { version , name , description } from '../package.json'
10+ import { logger } from './utils/logger'
1111
1212export const main = createMain ( {
1313 meta : {
@@ -52,7 +52,7 @@ export const main = createMain({
5252 const pkg = pkgRaw as { scripts ?: Record < string , string > }
5353 const hasProcessorDev = Boolean ( pkg && pkg . scripts && pkg . scripts [ 'processor:dev' ] )
5454 if ( ! hasProcessorDev ) {
55- consola . warn ( 'No "processor:dev" script found in package.json.' )
55+ logger . warn ( 'No "processor:dev" script found in package.json.' )
5656 const rl = createInterface ( { input, output } )
5757 const answer = await rl . question ( 'Add script to package.json? (y/N) ' )
5858 rl . close ( )
@@ -67,16 +67,16 @@ export const main = createMain({
6767 }
6868 try {
6969 writeFileSync ( pkgPath , JSON . stringify ( updated , null , 2 ) + '\n' , 'utf8' )
70- consola . success ( 'Added "processor:dev" script to package.json' )
70+ logger . success ( 'Added "processor:dev" script to package.json' )
7171 }
7272 catch {
73- consola . error ( 'Failed to write to package.json' )
73+ logger . error ( 'Failed to write to package.json' )
7474 }
7575 }
7676 }
7777 }
78- catch {
79- // ignore JSON parse errors
78+ catch ( error ) {
79+ logger . error ( 'Failed to parse' , error )
8080 }
8181 }
8282 }
@@ -91,7 +91,7 @@ export const main = createMain({
9191 const pkg = pkgRaw as { scripts ?: Record < string , string > }
9292 hasProcessorDev = Boolean ( pkg && pkg . scripts && pkg . scripts [ 'processor:dev' ] )
9393 if ( ! hasProcessorDev ) {
94- consola . warn ( 'No "processor:dev" script found in package.json.' )
94+ logger . warn ( 'No "processor:dev" script found in package.json.' )
9595
9696 const rl = createInterface ( { input, output } )
9797 const answer = await rl . question ( 'Add script to package.json? (y/N) ' )
@@ -102,27 +102,27 @@ export const main = createMain({
102102 const updated = {
103103 ...pkg ,
104104 scripts : {
105- ...( pkg . scripts || { } ) ,
105+ ...( pkg . scripts ?? { } ) ,
106106 'processor:dev' : 'nuxt-processor dev' ,
107107 } ,
108108 }
109109 try {
110110 writeFileSync ( pkgPath , JSON . stringify ( updated , null , 2 ) + '\n' , 'utf8' )
111- consola . success ( 'Added "processor:dev" script to package.json' )
111+ logger . success ( 'Added "processor:dev" script to package.json' )
112112 }
113113 catch {
114- consola . error ( 'Failed to write to package.json' )
114+ logger . error ( 'Failed to write to package.json' )
115115 }
116116 }
117117 }
118118 }
119- catch {
120- // ignore JSON parse errors, still show guidance
119+ catch ( error ) {
120+ logger . error ( 'Failed to parse' , error )
121121 }
122122 }
123- consola . error ( 'No entry file found at .nuxt/dev/workers/index.mjs' )
124- consola . info ( 'Please start your Nuxt dev server (e.g. `npm run dev`).' )
125- consola . info ( 'After it starts, run `npx nuxt-processor dev` again to start the processor.' )
123+ logger . error ( 'No entry file found at .nuxt/dev/workers/index.mjs' )
124+ logger . info ( 'Please start your Nuxt dev server (e.g. `npm run dev`).' )
125+ logger . info ( 'After it starts, run `npx nuxt-processor dev` again to start the processor.' )
126126 process . exit ( 1 )
127127 }
128128
@@ -140,7 +140,7 @@ export const main = createMain({
140140 ...( args . workers ? [ `--workers=${ args . workers } ` ] : [ ] ) ,
141141 ]
142142
143- consola . info ( `Running watcher for processor` )
143+ logger . info ( `Running watcher for processor` )
144144 const child = spawn ( nodeBin , nodeArgs , {
145145 stdio : 'inherit' ,
146146 cwd : projectRoot ,
0 commit comments