feat: update to consola 2 (#4247)

* add ~> addReporter

* remove badge

* withScope ~> withTag

* update to consola 2

* update build tests
This commit is contained in:
Pooya Parsa 2018-11-01 07:20:07 +03:30 committed by Sébastien Chopin
parent e502d95090
commit 1dd32d0d21
23 changed files with 45 additions and 59 deletions

View File

@ -56,7 +56,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
"consola": "^1.4.4"
"consola": "^2.0.0-1"
},
"engines": {
"node": ">=6.0.0",

View File

@ -47,7 +47,7 @@
"@nuxt/cli": "^2.2.0",
"@nuxt/common": "^2.2.0",
"@nuxt/core": "^2.2.0",
"consola": "^1.4.4"
"consola": "^2.0.0-1"
},
"engines": {
"node": ">=8.0.0",

View File

@ -52,7 +52,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
"consola": "^1.4.4"
"consola": "^2.0.0-1"
},
"engines": {
"node": ">=8.0.0",

View File

@ -31,7 +31,7 @@
"babel-jest": "^23.6.0",
"babel-plugin-dynamic-import-node": "^2.2.0",
"codecov": "^3.1.0",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"eslint": "^5.8.0",

View File

@ -12,7 +12,7 @@
"@nuxt/vue-app": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"chokidar": "^2.0.4",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"fs-extra": "^7.0.0",
"glob": "^7.1.3",
"hash-sum": "^1.0.2",

View File

@ -61,10 +61,7 @@ export default class Builder {
if (this.options.build.analyze) {
this.nuxt.hook('build:done', () => {
consola.warn({
message: 'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.',
badge: true
})
consola.warn('Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.')
})
}
@ -125,8 +122,7 @@ export default class Builder {
} else if (pluginFiles.length > 1) {
consola.warn({
message: `Found ${pluginFiles.length} plugins that match the configuration, suggest to specify extension:`,
additional: ` ${pluginFiles.join('\n ')}`,
badge: true
additional: pluginFiles.join('\n')
})
}
@ -152,11 +148,7 @@ export default class Builder {
}
this._buildStatus = STATUS.BUILDING
consola.info({
message: 'Building project',
badge: true,
clear: !this.options.dev
})
consola.info('Building project')
// Wait for nuxt ready
await this.nuxt.ready()
@ -175,12 +167,7 @@ export default class Builder {
)
} else {
this._defaultPage = true
consola.warn({
message: `No \`${this.options.dir.pages}\` directory found in ${dir}.`,
additional: 'Using the default built-in page.\n',
additionalStyle: 'yellowBright',
badge: true
})
consola.warn(`No \`${this.options.dir.pages}\` directory found in ${dir}. Using the default built-in page.`)
}
}
}

View File

@ -13,7 +13,7 @@
},
"dependencies": {
"@nuxt/config": "^2.2.0",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"esm": "^3.0.84",
"minimist": "^1.2.0",
"wrap-ansi": "^4.0.0"

View File

@ -21,7 +21,7 @@ export default function setup({ dev }) {
// Exit process on fatal errors
/* istanbul ignore next */
consola.add({
consola.addReporter({
log(logObj) {
if (logObj.type === 'fatal') {
process.stderr.write('Nuxt Fatal Error :(\n')

View File

@ -4,7 +4,7 @@ export { NuxtCommand } from '../../src'
jest.mock('consola')
consola.add = jest.fn()
consola.addReporter = jest.fn()
export {
consola

View File

@ -9,7 +9,7 @@
"main": "dist/common.js",
"dependencies": {
"@nuxt/config": "^2.2.0",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"lodash": "^4.17.11"
},
"publishConfig": {

View File

@ -9,7 +9,7 @@
"main": "dist/config.js",
"dependencies": {
"@nuxt/common": "^2.2.0",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"lodash": "^4.17.11",
"std-env": "^2.0.2"
},

View File

@ -14,7 +14,7 @@
"@nuxt/vue-renderer": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"@nuxtjs/opencollective": "^0.1.0",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"debug": "^4.1.0",
"esm": "^3.0.84",
"fs-extra": "^7.0.0",

View File

@ -10,7 +10,7 @@
"dependencies": {
"@nuxt/common": "^2.2.0",
"chalk": "^2.4.1",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"fs-extra": "^7.0.0",
"html-minifier": "^3.5.21"
},

View File

@ -31,11 +31,7 @@ export default class Generator {
const routes = await this.initRoutes()
consola.info({
message: 'Generating pages',
badge: true,
clear: true
})
consola.info('Generating pages')
const errors = await this.generateRoutes(routes)

View File

@ -14,7 +14,7 @@
"chalk": "^2.4.1",
"compression": "^1.7.3",
"connect": "^3.6.6",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"etag": "^1.8.1",
"fresh": "^0.5.2",
"fs-extra": "^7.0.0",

View File

@ -179,11 +179,7 @@ export default class Server {
showReady(clear = true) {
if (this.readyMessage) {
consola.ready({
message: this.readyMessage,
badge: true,
clear
})
consola.success(this.readyMessage)
}
}

View File

@ -11,7 +11,7 @@
"@nuxt/common": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"browserslist-useragent": "^2.0.1",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"fs-extra": "^7.0.0",
"lru-cache": "^4.1.3",
"vue": "^2.5.17",

View File

@ -17,7 +17,7 @@
"cache-loader": "^1.2.2",
"caniuse-lite": "^1.0.30000900",
"chalk": "^2.4.1",
"consola": "^1.4.4",
"consola": "^2.0.0-1",
"css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"file-loader": "^2.0.0",

View File

@ -37,7 +37,7 @@ export default class Package extends EventEmitter {
this.readPkg()
// Init logger
this.logger = consola.withScope(this.pkg.name)
this.logger = consola.withTag(this.pkg.name)
// Try to load config
this.loadConfig()

View File

@ -15,7 +15,7 @@ describe('cli build', () => {
test('nuxt build -> error config', async () => {
await expect(execify(`node -r esm ${nuxtBin} build ${rootDir} -c config.js`)).rejects.toMatchObject({
stdout: expect.stringContaining('Could not load config file: config.js')
stderr: expect.stringContaining('Could not load config file: config.js')
})
})
})

View File

@ -5,13 +5,6 @@ describe('missing-pages-dir', () => {
buildFixture('missing-pages-dir', (builder) => {
const options = builder.nuxt.options
expect(consola.warn).toHaveBeenCalledTimes(1)
expect(consola.warn.mock.calls).toMatchObject([
[{
message: `No \`${options.dir.pages}\` directory found in ${options.srcDir}.`,
additional: 'Using the default built-in page.\n',
additionalStyle: 'yellowBright',
badge: true
}]
])
expect(consola.warn).toHaveBeenCalledWith(`No \`${options.dir.pages}\` directory found in ${options.srcDir}. Using the default built-in page.`)
})
})

View File

@ -19,13 +19,11 @@ describe('with-config', () => {
expect(consola.warn.mock.calls).toMatchObject([
[{
message: 'Found 2 plugins that match the configuration, suggest to specify extension:',
additional: expect.stringContaining('plugins/test.json'),
badge: true
additional: expect.stringContaining('plugins/test.json')
}],
[{
message: 'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.',
badge: true
}]
[
'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.'
]
])
expect(customCompressionMiddlewareFunctionName).toBe('damn')
}, hooks)

View File

@ -3010,7 +3010,7 @@ connect@^3.6.6:
parseurl "~1.3.2"
utils-merge "1.0.1"
consola@^1.4.3, consola@^1.4.4:
consola@^1.4.3:
version "1.4.4"
resolved "https://registry.npmjs.org/consola/-/consola-1.4.4.tgz#cf5eda375c0e99df8970cc8f5e98be023da24ce0"
integrity sha512-6ZCi6LpbwGml3g8C8iXIuSf9yZAWoRAXodcHxBWRVvy42uKe4z7AG4JB4v46LEmgtPXv2rIqR6wVD+sxixDD/A==
@ -3020,6 +3020,17 @@ consola@^1.4.3, consola@^1.4.4:
lodash "^4.17.5"
std-env "^1.1.0"
consola@^2.0.0-1:
version "2.0.0-1"
resolved "https://registry.npmjs.org/consola/-/consola-2.0.0-1.tgz#4883f5c19ae07b63226f27311c4e54a42e18714a"
integrity sha512-X4sDWc37AbZFXVHT55I0SWKilv1qClu3fPDzakcnEKUENJZXrHaJwpSUDDXOrp0KBsdUBx6ji6DpuSZm6/QUVQ==
dependencies:
chalk "^2.4.1"
dayjs "^1.7.7"
figures "^2.0.0"
std-env "^2.0.2"
string-width "^2.1.1"
console-browserify@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10"
@ -3595,6 +3606,11 @@ dateformat@^3.0.0:
resolved "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==
dayjs@^1.7.7:
version "1.7.7"
resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.7.7.tgz#8df20f78ac2476e3f5348ef49f8f22ebc3016370"
integrity sha512-Qlkiu0NNDpYwhk0syK4ImvAl/5YnsEMkvC2O123INviGeOA3Q8s5VyVkZzmN5SC7Wv9bb1+rfwO+uSqtHB4UWw==
de-indent@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"