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