mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
feat: minimal logger for CI/Test environments
This commit is contained in:
parent
db1ee4bc31
commit
13d17d241e
@ -39,8 +39,9 @@ export default class Builder {
|
|||||||
this.webpackHotMiddleware = null
|
this.webpackHotMiddleware = null
|
||||||
this.filesWatcher = null
|
this.filesWatcher = null
|
||||||
this.customFilesWatcher = null
|
this.customFilesWatcher = null
|
||||||
this.spinner = createSpinner()
|
this.spinner = createSpinner({
|
||||||
this.spinner.enabled = !this.options.test
|
minimal: this.options.test || this.options.ci
|
||||||
|
})
|
||||||
|
|
||||||
// Mute stats on dev
|
// Mute stats on dev
|
||||||
this.webpackStats = this.options.dev ? false : this.options.build.stats
|
this.webpackStats = this.options.dev ? false : this.options.build.stats
|
||||||
|
@ -20,8 +20,9 @@ export default class Generator {
|
|||||||
isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath
|
isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath
|
||||||
)
|
)
|
||||||
|
|
||||||
this.spinner = createSpinner()
|
this.spinner = createSpinner({
|
||||||
this.spinner.enabled = !this.options.test
|
minimal: this.options.test || this.options.ci
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async generate({ build = true, init = true } = {}) {
|
async generate({ build = true, init = true } = {}) {
|
||||||
|
@ -132,6 +132,7 @@ export default function webpackBaseConfig({ name, isServer }) {
|
|||||||
if (this.options.build.profile) {
|
if (this.options.build.profile) {
|
||||||
config.plugins.push(new webpack.ProgressPlugin({ profile: true }))
|
config.plugins.push(new webpack.ProgressPlugin({ profile: true }))
|
||||||
} else {
|
} else {
|
||||||
|
if (!(this.options.test || this.options.ci)) {
|
||||||
config.plugins.push(new ProgressPlugin({
|
config.plugins.push(new ProgressPlugin({
|
||||||
spinner: this.spinner,
|
spinner: this.spinner,
|
||||||
name: isServer ? 'server' : 'client',
|
name: isServer ? 'server' : 'client',
|
||||||
@ -139,6 +140,7 @@ export default function webpackBaseConfig({ name, isServer }) {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add timefix-plugin before others plugins
|
// Add timefix-plugin before others plugins
|
||||||
if (this.options.dev) {
|
if (this.options.dev) {
|
||||||
|
@ -1,20 +1,31 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import isCI from 'is-ci'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mode: 'universal',
|
// Information about running environment
|
||||||
dev: process.env.NODE_ENV !== 'production',
|
dev: process.env.NODE_ENV !== 'production',
|
||||||
debug: undefined, // Will be equal to dev if not provided
|
debug: undefined, // Will be equal to dev if not provided
|
||||||
test: process.env.NODE_ENV === 'test',
|
test: process.env.NODE_ENV === 'test',
|
||||||
|
ci: Boolean(isCI),
|
||||||
|
|
||||||
|
// Mode
|
||||||
|
mode: 'universal',
|
||||||
|
|
||||||
|
// Dirs
|
||||||
buildDir: '.nuxt',
|
buildDir: '.nuxt',
|
||||||
cacheDir: '.cache',
|
cacheDir: '.cache',
|
||||||
nuxtDir: path.resolve(__dirname, '../..'),
|
nuxtDir: path.resolve(__dirname, '../..'),
|
||||||
nuxtAppDir: path.resolve(__dirname, '../app'),
|
nuxtAppDir: path.resolve(__dirname, '../app'),
|
||||||
modulesDir: ['node_modules'], // ~> relative to options.rootDir
|
modulesDir: ['node_modules'], // ~> relative to options.rootDir
|
||||||
|
|
||||||
|
// Ignore
|
||||||
ignorePrefix: '-',
|
ignorePrefix: '-',
|
||||||
ignore: [
|
ignore: [
|
||||||
'**/*.test.*'
|
'**/*.test.*'
|
||||||
],
|
],
|
||||||
|
|
||||||
extensions: [],
|
extensions: [],
|
||||||
|
|
||||||
build: {
|
build: {
|
||||||
analyze: false,
|
analyze: false,
|
||||||
profile: process.argv.includes('--profile'),
|
profile: process.argv.includes('--profile'),
|
||||||
|
@ -26,7 +26,9 @@ export const fatalError = function () {
|
|||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createSpinner = function () {
|
export const createSpinner = function ({ minimal = false }) {
|
||||||
|
// Use ORA by default
|
||||||
|
if (!minimal) {
|
||||||
return new ORA({
|
return new ORA({
|
||||||
color: 'green',
|
color: 'green',
|
||||||
spinner: 'clock',
|
spinner: 'clock',
|
||||||
@ -34,6 +36,23 @@ export const createSpinner = function () {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creare a minimal fallback for test and CI environments
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
const logger = (tag) => (...args) => console.log(
|
||||||
|
`[${(new Date().toISOString)()}]`,
|
||||||
|
_.padEnd(`[${tag}]`, 10),
|
||||||
|
...args
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
start: logger('START'),
|
||||||
|
failed: logger('FAIL'),
|
||||||
|
succeed: logger('SUCCESS'),
|
||||||
|
info: logger('INFO')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const encodeHtml = function encodeHtml(str) {
|
export const encodeHtml = function encodeHtml(str) {
|
||||||
return str.replace(/</g, '<').replace(/>/g, '>')
|
return str.replace(/</g, '<').replace(/>/g, '>')
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
"html-minifier": "^3.5.12",
|
"html-minifier": "^3.5.12",
|
||||||
"html-webpack-inline-source-plugin": "^0.0.10",
|
"html-webpack-inline-source-plugin": "^0.0.10",
|
||||||
"html-webpack-plugin": "^3.0.7",
|
"html-webpack-plugin": "^3.0.7",
|
||||||
|
"is-ci": "^1.1.0",
|
||||||
"launch-editor-middleware": "^2.2.1",
|
"launch-editor-middleware": "^2.2.1",
|
||||||
"lodash": "^4.17.5",
|
"lodash": "^4.17.5",
|
||||||
"lru-cache": "^4.1.2",
|
"lru-cache": "^4.1.2",
|
||||||
|
@ -3522,7 +3522,7 @@ is-callable@^1.1.1, is-callable@^1.1.3:
|
|||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
|
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
|
||||||
|
|
||||||
is-ci@^1.0.10:
|
is-ci@^1.0.10, is-ci@^1.1.0:
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.1.0.tgz#247e4162e7860cebbdaf30b774d6b0ac7dcfe7a5"
|
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.1.0.tgz#247e4162e7860cebbdaf30b774d6b0ac7dcfe7a5"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Loading…
Reference in New Issue
Block a user