Skip to content

Commit a697022

Browse files
committed
feat(generator): use electron-devtools-installer, fixes #776
1 parent 3aa27dc commit a697022

File tree

7 files changed

+27
-10
lines changed

7 files changed

+27
-10
lines changed

Diff for: docs/guide/commonIssues.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Often this issue is caused when Vue Devtools fails to install. This may happen i
2828
```javascript
2929
if (isDevelopment && !process.env.IS_TEST) {
3030
// Install Vue Devtools
31-
await installVueDevtools()
31+
await installExtension(VUEJS_DEVTOOLS)
3232
}
3333
```
3434

Diff for: docs/guide/recipes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ app.on('ready', async () => {
237237
if (isDevelopment && !process.env.IS_TEST) {
238238
// Install Vue Devtools
239239
try {
240-
await installVueDevtools()
240+
await installExtensions(VUEJS_DEVTOOLS)
241241
} catch (e) {
242242
console.error('Vue Devtools failed to install:', e.toString())
243243
}

Diff for: generator/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ module.exports = (api, options = {}) => {
105105
}
106106
addScript('postinstall', 'electron-builder install-app-deps')
107107
addScript('postuninstall', 'electron-builder install-app-deps')
108-
const devDependencies = {}
108+
const devDependencies = {
109+
'electron-devtools-installer': '^3.1.0'
110+
}
109111
if (electronVersion) {
110112
// Use provided electron version
111113
devDependencies.electron = electronVersion

Diff for: generator/templates/base/src/background.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict'
22

33
import { app, protocol, BrowserWindow } from 'electron'
4-
import {
5-
createProtocol,
6-
<% if (devtoolsExtensionsBroken) { %>/* installVueDevtools */<% } else { %>installVueDevtools<% } %>
7-
} from 'vue-cli-plugin-electron-builder/lib'
4+
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
5+
<% if (devtoolsExtensionsBroken) { %>// <% } %>import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
86
const isDevelopment = process.env.NODE_ENV !== 'production'
97

108
// Keep a global reference of the window object, if you don't, the window will
@@ -73,12 +71,12 @@ app.on('ready', async () => {
7371
// In addition, if you upgrade to Electron ^8.2.5 or ^9.0.0 then devtools should work fine
7472

7573
// try {
76-
// await installVueDevtools()
74+
// await installExtension(VUEJS_DEVTOOLS)
7775
// } catch (e) {
7876
// console.error('Vue Devtools failed to install:', e.toString())
7977
// }
8078
<% } else { %>try {
81-
await installVueDevtools()
79+
await installExtension(VUEJS_DEVTOOLS)
8280
} catch (e) {
8381
console.error('Vue Devtools failed to install:', e.toString())
8482
}<% } %>

Diff for: lib/installVueDevtools/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ if (fs.existsSync(getIDMapPath())) {
2020
}
2121

2222
const install = (forceDownload = false) => {
23+
console.log(
24+
'installVueDevtools() is deprecated, and will be removed in a future release.'
25+
)
26+
console.log('Please use electron-devtools-installer instead.')
27+
console.log(
28+
'See https://github.com/nklayman/vue-cli-plugin-electron-builder/releases/tag/v2.0.0-rc.4 for details.'
29+
)
2330
// return new Promise(resolve => {
2431
const chromeStoreID = 'nhdogjmejiglipccpnnnanhbledajbpd'
2532
const extensionName = IDMap[chromeStoreID]
@@ -31,7 +38,7 @@ const install = (forceDownload = false) => {
3138
return Promise.resolve(IDMap[chromeStoreID])
3239
}
3340
return downloadChromeExtension(chromeStoreID, forceDownload).then(
34-
extensionFolder => {
41+
(extensionFolder) => {
3542
// Use forceDownload, but already installed
3643
if (extensionInstalled) {
3744
BrowserWindow.removeDevToolsExtension(extensionName)

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"chai": "^4.2.0",
6262
"chai-as-promised": "^7.1.1",
6363
"electron": "^9.0.3",
64+
"electron-devtools-installer": "^3.1.0",
6465
"eslint": "^7.2.0",
6566
"eslint-config-standard": "^14.0.0",
6667
"eslint-plugin-import": "^2.21.2",

Diff for: yarn.lock

+9
Original file line numberDiff line numberDiff line change
@@ -6521,6 +6521,15 @@ electron-chromedriver@^9.0.0:
65216521
"@electron/get" "^1.12.2"
65226522
extract-zip "^2.0.0"
65236523

6524+
electron-devtools-installer@^3.1.0:
6525+
version "3.1.0"
6526+
resolved "https://registry.yarnpkg.com/electron-devtools-installer/-/electron-devtools-installer-3.1.0.tgz#c7800d36ab8438b51d2e03345860f817ecb5797f"
6527+
integrity sha512-qZd1Aoya8YOK6QauNX92V5qyKGtb4lbs238bP+qtMBkXts24xJ/1PtOVBPvdg5w3Ts9L5o6I9sDErKuzHeJFDA==
6528+
dependencies:
6529+
rimraf "^3.0.2"
6530+
semver "^7.2.1"
6531+
unzip-crx "^0.2.0"
6532+
65246533
65256534
version "22.7.0"
65266535
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-22.7.0.tgz#d92ba7c4007c9ac1dd070593e48028184fb2dc19"

0 commit comments

Comments
 (0)