修复npm安全漏洞警告,优化编译时cli的显示状态
parent
241859232b
commit
2b1076f09e
|
@ -3,7 +3,7 @@ process.env.NODE_ENV = 'production'
|
||||||
const chalk = require('chalk')
|
const chalk = require('chalk')
|
||||||
const del = require('del')
|
const del = require('del')
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
const Multispinner = require('multispinner')
|
const Spinnies = require('spinnies')
|
||||||
|
|
||||||
const mainConfig = require('./main/webpack.config.prod')
|
const mainConfig = require('./main/webpack.config.prod')
|
||||||
const rendererConfig = require('./renderer/webpack.config.prod')
|
const rendererConfig = require('./renderer/webpack.config.prod')
|
||||||
|
@ -15,40 +15,44 @@ const okayLog = chalk.bgGreen.white(' OKAY ') + ' '
|
||||||
function build() {
|
function build() {
|
||||||
del.sync(['dist/electron', 'build'])
|
del.sync(['dist/electron', 'build'])
|
||||||
|
|
||||||
const tasks = ['main', 'renderer']
|
const spinners = new Spinnies({ color: 'blue' })
|
||||||
const m = new Multispinner(tasks, {
|
spinners.add('main', { text: 'main building' })
|
||||||
preText: 'building',
|
spinners.add('renderer', { text: 'renderer building' })
|
||||||
postText: 'process',
|
|
||||||
})
|
|
||||||
|
|
||||||
let results = ''
|
let results = ''
|
||||||
|
|
||||||
m.on('success', () => {
|
// m.on('success', () => {
|
||||||
|
// process.stdout.write('\x1B[2J\x1B[0f')
|
||||||
|
// console.log(`\n\n${results}`)
|
||||||
|
// console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)
|
||||||
|
// process.exit()
|
||||||
|
// })
|
||||||
|
function handleSuccess() {
|
||||||
process.stdout.write('\x1B[2J\x1B[0f')
|
process.stdout.write('\x1B[2J\x1B[0f')
|
||||||
console.log(`\n\n${results}`)
|
console.log(`\n\n${results}`)
|
||||||
console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)
|
console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)
|
||||||
process.exit()
|
process.exit()
|
||||||
})
|
}
|
||||||
|
|
||||||
pack(mainConfig).then(result => {
|
Promise.all([
|
||||||
results += result + '\n\n'
|
pack(mainConfig).then(result => {
|
||||||
m.success('main')
|
results += result + '\n\n'
|
||||||
}).catch(err => {
|
spinners.succeed('main', { text: 'main build success!' })
|
||||||
m.error('main')
|
}).catch(err => {
|
||||||
console.log(`\n ${errorLog}failed to build main process`)
|
spinners.fail('main', { text: 'main build fail :(' })
|
||||||
console.error(`\n${err}\n`)
|
console.log(`\n ${errorLog}failed to build main process`)
|
||||||
process.exit(1)
|
console.error(`\n${err}\n`)
|
||||||
})
|
process.exit(1)
|
||||||
|
}),
|
||||||
pack(rendererConfig).then(result => {
|
pack(rendererConfig).then(result => {
|
||||||
results += result + '\n\n'
|
results += result + '\n\n'
|
||||||
m.success('renderer')
|
spinners.succeed('renderer', { text: 'renderer build success!' })
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
m.error('renderer')
|
spinners.fail('renderer', { text: 'renderer build fail :(' })
|
||||||
console.log(`\n ${errorLog}failed to build renderer process`)
|
console.log(`\n ${errorLog}failed to build renderer process`)
|
||||||
console.error(`\n${err}\n`)
|
console.error(`\n${err}\n`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
}),
|
||||||
|
]).then(handleSuccess)
|
||||||
}
|
}
|
||||||
|
|
||||||
function pack(config) {
|
function pack(config) {
|
||||||
|
|
|
@ -13,8 +13,6 @@ const webpackHotMiddleware = require('webpack-hot-middleware')
|
||||||
const mainConfig = require('./main/webpack.config.dev')
|
const mainConfig = require('./main/webpack.config.dev')
|
||||||
const rendererConfig = require('./renderer/webpack.config.dev')
|
const rendererConfig = require('./renderer/webpack.config.dev')
|
||||||
|
|
||||||
const { logStats } = require('./utils')
|
|
||||||
|
|
||||||
let electronProcess = null
|
let electronProcess = null
|
||||||
let manualRestart = false
|
let manualRestart = false
|
||||||
let hotMiddleware
|
let hotMiddleware
|
||||||
|
@ -74,7 +72,6 @@ function startMain() {
|
||||||
const compiler = webpack(mainConfig)
|
const compiler = webpack(mainConfig)
|
||||||
|
|
||||||
compiler.hooks.watchRun.tapAsync('watch-run', (compilation, done) => {
|
compiler.hooks.watchRun.tapAsync('watch-run', (compilation, done) => {
|
||||||
logStats('Main', chalk.white.bold('compiling...'))
|
|
||||||
hotMiddleware.publish({ action: 'compiling' })
|
hotMiddleware.publish({ action: 'compiling' })
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -138,34 +135,24 @@ function electronLog(data, color) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function greeting() {
|
|
||||||
/* const cols = process.stdout.columns
|
|
||||||
let text = ''
|
|
||||||
|
|
||||||
if (cols > 104) text = 'electron-vue'
|
|
||||||
else if (cols > 76) text = 'electron-|vue'
|
|
||||||
else text = false
|
|
||||||
|
|
||||||
if (text) {
|
|
||||||
say(text, {
|
|
||||||
colors: ['yellow'],
|
|
||||||
font: 'simple3d',
|
|
||||||
space: false,
|
|
||||||
})
|
|
||||||
} else console.log(chalk.yellow.bold('\n electron-vue')) */
|
|
||||||
console.log(chalk.blue('getting ready...') + '\n')
|
|
||||||
}
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
greeting()
|
const Spinnies = require('spinnies')
|
||||||
|
const spinners = new Spinnies({ color: 'blue' })
|
||||||
|
spinners.add('main', { text: 'main compiling' })
|
||||||
|
spinners.add('renderer', { text: 'renderer compiling' })
|
||||||
|
function handleSuccess(name) {
|
||||||
|
spinners.succeed(name, { text: name + ' compile success!' })
|
||||||
|
}
|
||||||
|
function handleFail(name) {
|
||||||
|
spinners.fail(name, { text: name + ' compile fail!' })
|
||||||
|
}
|
||||||
|
|
||||||
Promise.all([startRenderer(), startMain()])
|
Promise.all([
|
||||||
.then(() => {
|
startRenderer().then(() => handleSuccess('renderer')).catch(() => handleFail('renderer')),
|
||||||
startElectron()
|
startMain().then(() => handleSuccess('main')).catch(() => handleFail('main')),
|
||||||
})
|
]).then(startElectron).catch(err => {
|
||||||
.catch(err => {
|
console.error(err)
|
||||||
console.error(err)
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
|
@ -146,13 +146,13 @@
|
||||||
"@babel/polyfill": "^7.8.7",
|
"@babel/polyfill": "^7.8.7",
|
||||||
"@babel/preset-env": "^7.9.0",
|
"@babel/preset-env": "^7.9.0",
|
||||||
"autoprefixer": "^9.7.5",
|
"autoprefixer": "^9.7.5",
|
||||||
"babel-eslint": "^10.0.3",
|
"babel-eslint": "^10.1.0",
|
||||||
"babel-loader": "^8.1.0",
|
"babel-loader": "^8.1.0",
|
||||||
"babel-minify-webpack-plugin": "^0.3.1",
|
"babel-minify-webpack-plugin": "^0.3.1",
|
||||||
"babel-preset-minify": "^0.5.1",
|
"babel-preset-minify": "^0.5.1",
|
||||||
"browserslist": "^4.11.1",
|
"browserslist": "^4.11.1",
|
||||||
"cfonts": "^2.8.1",
|
"cfonts": "^2.8.1",
|
||||||
"chalk": "^3.0.0",
|
"chalk": "^4.0.0",
|
||||||
"changelog-parser": "^2.8.0",
|
"changelog-parser": "^2.8.0",
|
||||||
"copy-webpack-plugin": "^5.1.1",
|
"copy-webpack-plugin": "^5.1.1",
|
||||||
"core-js": "^3.6.4",
|
"core-js": "^3.6.4",
|
||||||
|
@ -164,11 +164,11 @@
|
||||||
"electron-builder": "^22.4.1",
|
"electron-builder": "^22.4.1",
|
||||||
"electron-debug": "^3.0.1",
|
"electron-debug": "^3.0.1",
|
||||||
"electron-devtools-installer": "^2.2.4",
|
"electron-devtools-installer": "^2.2.4",
|
||||||
"electron-to-chromium": "^1.3.391",
|
"electron-to-chromium": "^1.3.397",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-config-standard": "^14.1.1",
|
"eslint-config-standard": "^14.1.1",
|
||||||
"eslint-formatter-friendly": "^7.0.0",
|
"eslint-formatter-friendly": "^7.0.0",
|
||||||
"eslint-loader": "^3.0.3",
|
"eslint-loader": "^4.0.0",
|
||||||
"eslint-plugin-html": "^6.0.0",
|
"eslint-plugin-html": "^6.0.0",
|
||||||
"eslint-plugin-import": "^2.20.2",
|
"eslint-plugin-import": "^2.20.2",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
@ -176,12 +176,11 @@
|
||||||
"eslint-plugin-standard": "^4.0.1",
|
"eslint-plugin-standard": "^4.0.1",
|
||||||
"file-loader": "^6.0.0",
|
"file-loader": "^6.0.0",
|
||||||
"friendly-errors-webpack-plugin": "^1.7.0",
|
"friendly-errors-webpack-plugin": "^1.7.0",
|
||||||
"html-webpack-plugin": "^4.0.3",
|
"html-webpack-plugin": "^4.0.4",
|
||||||
"less": "^3.11.1",
|
"less": "^3.11.1",
|
||||||
"less-loader": "^5.0.0",
|
"less-loader": "^5.0.0",
|
||||||
"markdown-it": "^10.0.0",
|
"markdown-it": "^10.0.0",
|
||||||
"mini-css-extract-plugin": "^0.9.0",
|
"mini-css-extract-plugin": "^0.9.0",
|
||||||
"multispinner": "^0.2.1",
|
|
||||||
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
"postcss-pxtorem": "^5.1.1",
|
"postcss-pxtorem": "^5.1.1",
|
||||||
|
@ -190,6 +189,7 @@
|
||||||
"pug-plain-loader": "^1.0.0",
|
"pug-plain-loader": "^1.0.0",
|
||||||
"raw-loader": "^4.0.0",
|
"raw-loader": "^4.0.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
|
"spinnies": "^0.5.1",
|
||||||
"stylus": "^0.54.7",
|
"stylus": "^0.54.7",
|
||||||
"stylus-loader": "^3.0.2",
|
"stylus-loader": "^3.0.2",
|
||||||
"terser-webpack-plugin": "^2.3.5",
|
"terser-webpack-plugin": "^2.3.5",
|
||||||
|
@ -211,8 +211,8 @@
|
||||||
"electron-updater": "^4.2.5",
|
"electron-updater": "^4.2.5",
|
||||||
"image-size": "^0.8.3",
|
"image-size": "^0.8.3",
|
||||||
"js-htmlencode": "^0.3.0",
|
"js-htmlencode": "^0.3.0",
|
||||||
"lrc-file-parser": "^1.0.2",
|
"lrc-file-parser": "^1.0.3",
|
||||||
"needle": "^2.3.3",
|
"needle": "^2.4.1",
|
||||||
"node-id3": "^0.1.16",
|
"node-id3": "^0.1.16",
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
|
|
Loading…
Reference in New Issue