mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
chore(nuxi): use consola for consistency (#686)
This commit is contained in:
parent
cc2279bd8a
commit
abfaaa97eb
@ -32,6 +32,7 @@
|
|||||||
"clear": "^0.1.0",
|
"clear": "^0.1.0",
|
||||||
"clipboardy": "^2.3.0",
|
"clipboardy": "^2.3.0",
|
||||||
"colorette": "^2.0.14",
|
"colorette": "^2.0.14",
|
||||||
|
"consola": "^2.15.3",
|
||||||
"debounce-promise": "^3.1.2",
|
"debounce-promise": "^3.1.2",
|
||||||
"deep-object-diff": "^1.1.0",
|
"deep-object-diff": "^1.1.0",
|
||||||
"degit": "^2.8.4",
|
"degit": "^2.8.4",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
|
import consola from 'consola'
|
||||||
import { importModule } from '../utils/cjs'
|
import { importModule } from '../utils/cjs'
|
||||||
import { error } from '../utils/log'
|
|
||||||
|
|
||||||
import { defineNuxtCommand } from './index'
|
import { defineNuxtCommand } from './index'
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export default defineNuxtCommand({
|
|||||||
const nuxt = await loadNuxt({ rootDir })
|
const nuxt = await loadNuxt({ rootDir })
|
||||||
|
|
||||||
nuxt.hook('error', (err) => {
|
nuxt.hook('error', (err) => {
|
||||||
error('Nuxt Build Error:', err)
|
consola.error('Nuxt Build Error:', err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ import { resolve, relative } from 'pathe'
|
|||||||
import chokidar from 'chokidar'
|
import chokidar from 'chokidar'
|
||||||
import debounce from 'debounce-promise'
|
import debounce from 'debounce-promise'
|
||||||
import type { Nuxt } from '@nuxt/kit'
|
import type { Nuxt } from '@nuxt/kit'
|
||||||
|
import consola from 'consola'
|
||||||
import { createServer, createLoadingHandler } from '../utils/server'
|
import { createServer, createLoadingHandler } from '../utils/server'
|
||||||
import { showBanner } from '../utils/banner'
|
import { showBanner } from '../utils/banner'
|
||||||
import { importModule } from '../utils/cjs'
|
import { importModule } from '../utils/cjs'
|
||||||
import { error } from '../utils/log'
|
|
||||||
import { defineNuxtCommand } from './index'
|
import { defineNuxtCommand } from './index'
|
||||||
|
|
||||||
export default defineNuxtCommand({
|
export default defineNuxtCommand({
|
||||||
@ -47,7 +47,7 @@ export default defineNuxtCommand({
|
|||||||
listener.showURL()
|
listener.showURL()
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error(`Cannot ${isRestart ? 'restart' : 'start'} nuxt: `, err)
|
consola.error(`Cannot ${isRestart ? 'restart' : 'start'} nuxt: `, err)
|
||||||
server.setApp(createLoadingHandler(
|
server.setApp(createLoadingHandler(
|
||||||
'Error while loading nuxt. Please check console and fix errors.'
|
'Error while loading nuxt. Please check console and fix errors.'
|
||||||
))
|
))
|
||||||
|
@ -2,7 +2,7 @@ import { existsSync, readdirSync } from 'fs'
|
|||||||
import createDegit from 'degit'
|
import createDegit from 'degit'
|
||||||
import { relative, resolve } from 'pathe'
|
import { relative, resolve } from 'pathe'
|
||||||
import superb from 'superb'
|
import superb from 'superb'
|
||||||
import { warn, info, error } from '../utils/log'
|
import consola from 'consola'
|
||||||
import { defineNuxtCommand } from './index'
|
import { defineNuxtCommand } from './index'
|
||||||
|
|
||||||
const rpath = p => relative(process.cwd(), p)
|
const rpath = p => relative(process.cwd(), p)
|
||||||
@ -26,12 +26,12 @@ export default defineNuxtCommand({
|
|||||||
const dstDir = resolve(process.cwd(), args._[0] || 'nuxt-app')
|
const dstDir = resolve(process.cwd(), args._[0] || 'nuxt-app')
|
||||||
const degit = createDegit(src, { cache: false /* TODO: buggy */, verbose: (args.verbose || args.v) })
|
const degit = createDegit(src, { cache: false /* TODO: buggy */, verbose: (args.verbose || args.v) })
|
||||||
if (existsSync(dstDir) && readdirSync(dstDir).length) {
|
if (existsSync(dstDir) && readdirSync(dstDir).length) {
|
||||||
error(`Directory ${dstDir} is not empty. Please pick another name or remove it first. Aborting.`)
|
consola.error(`Directory ${dstDir} is not empty. Please pick another name or remove it first. Aborting.`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
const formatArgs = msg => msg.replace('options.', '--')
|
const formatArgs = msg => msg.replace('options.', '--')
|
||||||
degit.on('warn', event => warn(formatArgs(event.message)))
|
degit.on('warn', event => consola.warn(formatArgs(event.message)))
|
||||||
degit.on('info', event => info(formatArgs(event.message)))
|
degit.on('info', event => consola.info(formatArgs(event.message)))
|
||||||
await degit.clone(dstDir)
|
await degit.clone(dstDir)
|
||||||
|
|
||||||
// Show neet steps
|
// Show neet steps
|
||||||
|
@ -2,8 +2,8 @@ import { promises as fsp } from 'fs'
|
|||||||
import { relative, resolve } from 'pathe'
|
import { relative, resolve } from 'pathe'
|
||||||
import { cyan } from 'colorette'
|
import { cyan } from 'colorette'
|
||||||
import { TSReference } from '@nuxt/kit'
|
import { TSReference } from '@nuxt/kit'
|
||||||
|
import consola from 'consola'
|
||||||
import { importModule, getModulePaths, getNearestPackage } from '../utils/cjs'
|
import { importModule, getModulePaths, getNearestPackage } from '../utils/cjs'
|
||||||
import { success } from '../utils/log'
|
|
||||||
import { defineNuxtCommand } from './index'
|
import { defineNuxtCommand } from './index'
|
||||||
|
|
||||||
export default defineNuxtCommand({
|
export default defineNuxtCommand({
|
||||||
@ -53,7 +53,7 @@ export default defineNuxtCommand({
|
|||||||
|
|
||||||
await fsp.writeFile(declarationPath, declaration)
|
await fsp.writeFile(declarationPath, declaration)
|
||||||
|
|
||||||
success('Generated', cyan(relative(process.cwd(), declarationPath)))
|
consola.success('Generated', cyan(relative(process.cwd(), declarationPath)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import mri from 'mri'
|
import mri from 'mri'
|
||||||
import { red, cyan } from 'colorette'
|
import { red, cyan } from 'colorette'
|
||||||
|
import consola from 'consola'
|
||||||
import { commands, Command, NuxtCommand } from './commands'
|
import { commands, Command, NuxtCommand } from './commands'
|
||||||
import { showHelp } from './utils/help'
|
import { showHelp } from './utils/help'
|
||||||
import { showBanner } from './utils/banner'
|
import { showBanner } from './utils/banner'
|
||||||
import { error } from './utils/log'
|
|
||||||
|
|
||||||
async function _main () {
|
async function _main () {
|
||||||
const _argv = process.argv.slice(2)
|
const _argv = process.argv.slice(2)
|
||||||
@ -41,12 +41,15 @@ async function _main () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onFatalError (err: unknown) {
|
function onFatalError (err: unknown) {
|
||||||
error(err)
|
consola.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('unhandledRejection', err => error('[unhandledRejection]', err))
|
// Wrap all console logs with consola for better DX
|
||||||
process.on('uncaughtException', err => error('[uncaughtException]', err))
|
consola.wrapConsole()
|
||||||
|
|
||||||
|
process.on('unhandledRejection', err => consola.error('[unhandledRejection]', err))
|
||||||
|
process.on('uncaughtException', err => consola.error('[uncaughtException]', err))
|
||||||
|
|
||||||
export function main () {
|
export function main () {
|
||||||
_main().catch(onFatalError)
|
_main().catch(onFatalError)
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
import { green, red, yellow, cyan } from 'colorette'
|
|
||||||
|
|
||||||
export const error = (...args: any[]) => console.error(red('[error]'), ...args)
|
|
||||||
export const warn = (...args: any[]) => console.warn(yellow('[warn]'), ...args)
|
|
||||||
export const info = (...args: any[]) => console.info(cyan('[info]'), ...args)
|
|
||||||
export const success = (...args: any[]) => console.log(green('[success]'), ...args)
|
|
@ -13677,6 +13677,7 @@ fsevents@~2.3.2:
|
|||||||
clear: ^0.1.0
|
clear: ^0.1.0
|
||||||
clipboardy: ^2.3.0
|
clipboardy: ^2.3.0
|
||||||
colorette: ^2.0.14
|
colorette: ^2.0.14
|
||||||
|
consola: ^2.15.3
|
||||||
debounce-promise: ^3.1.2
|
debounce-promise: ^3.1.2
|
||||||
deep-object-diff: ^1.1.0
|
deep-object-diff: ^1.1.0
|
||||||
degit: ^2.8.4
|
degit: ^2.8.4
|
||||||
|
Loading…
Reference in New Issue
Block a user