Skip to content

Commit 793805e

Browse files
committed
fix(ui): remove broken ui pages from dashboard, fixes #48
1 parent 346701f commit 793805e

File tree

1 file changed

+2
-137
lines changed

1 file changed

+2
-137
lines changed

ui.js

Lines changed: 2 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,6 @@
1-
const path = require('path')
2-
const fs = require('fs-extra')
31
const prompts = require('./uiOptions')
42

53
module.exports = api => {
6-
const { setSharedData, removeSharedData } = api.namespace(
7-
'webpack-dashboard-'
8-
)
9-
10-
let firstRun = true
11-
let hadFailed = false
12-
let modernMode = false
13-
14-
// For webpack dashboard
15-
function resetSharedData (key) {
16-
setSharedData(`${key}-status`, null)
17-
setSharedData(`${key}-progress`, 0)
18-
setSharedData(`${key}-operations`, null)
19-
setSharedData(`${key}-stats`, null)
20-
setSharedData(`${key}-sizes`, null)
21-
setSharedData(`${key}-problems`, null)
22-
}
23-
24-
// For webpack dashboard
25-
async function onWebpackMessage ({ data: message }) {
26-
if (message.webpackDashboardData) {
27-
const type = message.webpackDashboardData.type
28-
for (const data of message.webpackDashboardData.value) {
29-
if (data.type === 'stats') {
30-
// Stats are read from a file
31-
const statsFile = path.resolve(
32-
process.cwd(),
33-
`./node_modules/.stats-${type}.json`
34-
)
35-
const value = await fs.readJson(statsFile)
36-
setSharedData(`${type}-${data.type}`, value)
37-
await fs.remove(statsFile)
38-
} else if (
39-
type.indexOf('build') !== -1 &&
40-
modernMode &&
41-
data.type === 'progress'
42-
) {
43-
// Progress is shared between 'build' and 'build-modern'
44-
// 'build' first and then 'build-modern'
45-
const value = type === 'build' ? data.value / 2 : (data.value + 1) / 2
46-
// We display the same progress bar for both
47-
for (const t of ['build', 'build-modern']) {
48-
setSharedData(`${t}-${data.type}`, value)
49-
}
50-
} else {
51-
setSharedData(`${type}-${data.type}`, data.value)
52-
53-
// Notifications
54-
if (type === 'serve' && data.type === 'status') {
55-
if (data.value === 'Failed') {
56-
api.notify({
57-
title: 'Build failed',
58-
message: 'The build has errors.',
59-
icon: 'error'
60-
})
61-
hadFailed = true
62-
} else if (data.value === 'Success') {
63-
if (hadFailed) {
64-
api.notify({
65-
title: 'Build fixed',
66-
message: 'The build succeeded.',
67-
icon: 'done'
68-
})
69-
hadFailed = false
70-
} else if (firstRun) {
71-
api.notify({
72-
title: 'App ready',
73-
message: 'The build succeeded.',
74-
icon: 'done'
75-
})
76-
firstRun = false
77-
}
78-
}
79-
}
80-
}
81-
}
82-
}
83-
}
84-
854
api.describeTask({
865
match: /vue-cli-service electron:build/,
876
description: 'Build your app for production with electron-builder',
@@ -115,65 +34,11 @@ module.exports = api => {
11534
answers.archs.forEach(a => {
11635
args.push(`--${a}`)
11736
})
118-
// Webpack dashboard
119-
setSharedData('modern-mode', (modernMode = !!answers.modern))
120-
// Tell renderer build to send status to dashboard
121-
args.push('--dashboard')
122-
// Data
123-
resetSharedData('build')
124-
resetSharedData('build-modern')
125-
},
126-
onRun: () => {
127-
api.ipcOn(onWebpackMessage)
128-
},
129-
onExit: () => {
130-
api.ipcOff(onWebpackMessage)
131-
},
132-
views: [
133-
{
134-
id: 'vue-webpack-dashboard',
135-
label: 'vue-webpack.dashboard.title',
136-
icon: 'dashboard',
137-
component: 'vue-webpack-dashboard'
138-
},
139-
{
140-
id: 'vue-webpack-analyzer',
141-
label: 'vue-webpack.analyzer.title',
142-
icon: 'donut_large',
143-
component: 'vue-webpack-analyzer'
144-
}
145-
],
146-
defaultView: 'vue-webpack-dashboard'
37+
}
14738
})
14839
api.describeTask({
14940
match: /vue-cli-service electron:serve/,
15041
description: 'Serve your app, launch electron',
151-
link: 'https://nklayman.github.io/vue-cli-plugin-electron-builder/',
152-
onBeforeRun: ({ answers, args }) => {
153-
// Tell dev server to send status to dashboard
154-
args.push('--dashboard')
155-
156-
// Data
157-
resetSharedData('serve')
158-
removeSharedData('serve-url')
159-
firstRun = true
160-
hadFailed = false
161-
},
162-
onRun: () => {
163-
api.ipcOn(onWebpackMessage)
164-
},
165-
onExit: () => {
166-
api.ipcOff(onWebpackMessage)
167-
removeSharedData('serve-url')
168-
},
169-
views: [
170-
{
171-
id: 'vue-webpack-dashboard',
172-
label: 'vue-webpack.dashboard.title',
173-
icon: 'dashboard',
174-
component: 'vue-webpack-dashboard'
175-
}
176-
],
177-
defaultView: 'vue-webpack-dashboard'
42+
link: 'https://nklayman.github.io/vue-cli-plugin-electron-builder/'
17843
})
17944
}

0 commit comments

Comments
 (0)