fix(dev): remove installed extension before installing new
Signed-off-by: Grigorii K. Shartsev <[email protected]>
This commit is contained in:
1 parent
0fba4cb9db
commit
46f7857a69
4 files changed
+14
-24
No files matched your search
@@ -6,7 +6,7 @@
|
||||
import { createWriteStream } from 'node:fs'
|
||||
import { pipeline } from 'node:stream/promises'
|
||||
|
||||
import { VUE_DEVTOOLS_EXTENSION_ID } from './vue-devtools-extension-id.mjs'
|
||||
const VUE_DEVTOOLS_EXTENSION_ID = 'nhdogjmejiglipccpnnnanhbledajbpd'
|
||||
|
||||
// TODO: while this is fine to have not exact version here, it's better to get the current version of built-in Chromium in the current version of Electron
|
||||
const CHROMIUM_VERSION = '122.0.6261.39'
|
||||
@@ -15,6 +15,7 @@ const getChromiumExtensionUrl = (extensionId) => `https://clients2.google.com/se
|
||||
|
||||
/**
|
||||
* Download Chrome extension by extension ID
|
||||
*
|
||||
* @param {string} extensionId - Chrome extension ID
|
||||
* @param {module:fs.PathLike} outputPath - Path to save the extension
|
||||
*/
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
// See: https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd
|
||||
export const VUE_DEVTOOLS_EXTENSION_ID = 'nhdogjmejiglipccpnnnanhbledajbpd'
|
||||
+12
-14
@@ -7,7 +7,6 @@ const { app, session } = require('electron')
|
||||
const fs = require('node:fs/promises')
|
||||
const { resolve } = require('node:path')
|
||||
const unzip = require('unzip-crx-3')
|
||||
const { VUE_DEVTOOLS_EXTENSION_ID } = require('../scripts/vue-devtools-extension-id.mjs')
|
||||
|
||||
const vueDevtoolsPath = resolve(__dirname, require('../resources/vue-devtools.crx'))
|
||||
/**
|
||||
@@ -34,23 +33,22 @@ async function isDirectoryExists(path) {
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async function installVueDevtools() {
|
||||
if (session.defaultSession.extensions.getExtension(VUE_DEVTOOLS_EXTENSION_ID)) {
|
||||
console.log('Vue Devtools extension has already been installed')
|
||||
return
|
||||
}
|
||||
|
||||
const extensionDir = resolve(app.getPath('userData'), 'extensions', 'vuejs-devtools')
|
||||
|
||||
// TODO: add version check to enable vue-devtools updating
|
||||
const isExtensionUnpacked = await isDirectoryExists(extensionDir)
|
||||
if (!isExtensionUnpacked) {
|
||||
try {
|
||||
// Check if there is uncleaned unpacked extensions from the previous installation
|
||||
if (await isDirectoryExists(extensionDir)) {
|
||||
await fs.rm(extensionDir, { recursive: true })
|
||||
}
|
||||
|
||||
await fs.mkdir(extensionDir)
|
||||
await unzip(vueDevtoolsPath, extensionDir)
|
||||
console.log('Vue Devtools extension is unpacked')
|
||||
await session.defaultSession.extensions.loadExtension(extensionDir)
|
||||
|
||||
console.log('Vue Devtools extension is installed')
|
||||
} catch (error) {
|
||||
console.error('Could not install Vue Devtools', error)
|
||||
}
|
||||
|
||||
await session.defaultSession.extensions.loadExtension(extensionDir)
|
||||
|
||||
console.log('Vue Devtools extension is installed')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -154,8 +154,6 @@ app.whenReady().then(async () => {
|
||||
const openInBackground = ARGUMENTS.openInBackground || app.getLoginItemSettings().wasOpenedAtLogin
|
||||
|
||||
try {
|
||||
// Note: legacy Vue devtools warns with "ExtensionLoadWarning: Manifest version 2 is deprecated, and support will be removed in 2024."
|
||||
// This is fine and works. New Vue devtools does not support Vue 2.
|
||||
await installVueDevtools()
|
||||
} catch (error) {
|
||||
console.log('Unable to install Vue Devtools')
|
||||
|
||||
Reference in new issue
Block a user