diff --git a/.yarnrc b/.yarnrc index c1a72798f7..3d59b91c7e 100644 --- a/.yarnrc +++ b/.yarnrc @@ -1,3 +1,3 @@ disturl "https://atom.io/download/electron" -target "11.4.3" +target "12.0.10" runtime "electron" diff --git a/integration/__tests__/app.tests.ts b/integration/__tests__/app.tests.ts index b15c5d423b..9a6b091ce6 100644 --- a/integration/__tests__/app.tests.ts +++ b/integration/__tests__/app.tests.ts @@ -36,11 +36,13 @@ jest.setTimeout(60000); describe("Lens integration tests", () => { let app: Application; + const click = async (selector: string) => { + return (await app.client.$(selector)).click(); + }; + describe("app start", () => { utils.beforeAllWrapped(async () => { app = await utils.appStart(); - - console.log("app", app); }); utils.afterAllWrapped(async () => { @@ -49,53 +51,22 @@ describe("Lens integration tests", () => { } }); -<<<<<<< HEAD - it('shows "whats new"', async () => { - await utils.clickWhatsNew(app); - }); - - // it('shows "add cluster"', async () => { - // await app.electron.ipcRenderer.send("test-menu-item-click", "File", "Add Cluster"); - // await app.client.waitUntilTextExists("h2", "Add Clusters from Kubeconfig"); - // }); -======= - it('shows "add cluster"', async () => { - await app.electron.ipcRenderer.send("test-menu-item-click", "File", "Add Cluster"); - await app.client.waitUntilTextExists("h2", "Add Clusters from Kubeconfig"); - }); ->>>>>>> master - describe("preferences page", () => { - // it('shows "preferences"', async () => { - // const appName: string = process.platform === "darwin" ? "OpenLens" : "File"; + it('shows "preferences"', async () => { + const appName: string = process.platform === "darwin" ? "OpenLens" : "File"; -<<<<<<< HEAD - // await app.mainProcess.send("test-menu-item-click", appName, "Preferences"); - // await app.client.waitUntilTextExists("[data-testid=application-header]", "APPLICATION"); - // }); - - it("shows all tabs and their contents", async () => { - await app.client.elementClick("[data-testid=application-tab]"); - await app.client.elementClick("[data-testid=proxy-tab]"); - await app.client.waitUntilTextExists("[data-testid=proxy-header]", "PROXY"); - await app.client.elementClick("[data-testid=kube-tab]"); - await app.client.waitUntilTextExists("[data-testid=kubernetes-header]", "KUBERNETES"); - await app.client.elementClick("[data-testid=telemetry-tab]"); - await app.client.waitUntilTextExists("[data-testid=telemetry-header]", "TELEMETRY"); -======= - await app.electron.ipcRenderer.send("test-menu-item-click", appName, "Preferences"); + await (app.electron as any).ipcRenderer.send("test-menu-item-click", appName, "Preferences"); await app.client.waitUntilTextExists("[data-testid=application-header]", "Application"); }); it("shows all tabs and their contents", async () => { - await app.client.click("[data-testid=application-tab]"); - await app.client.click("[data-testid=proxy-tab]"); + await click("[data-testid=application-tab]"); + await click("[data-testid=proxy-tab]"); await app.client.waitUntilTextExists("[data-testid=proxy-header]", "Proxy"); - await app.client.click("[data-testid=kube-tab]"); + await click("[data-testid=kube-tab]"); await app.client.waitUntilTextExists("[data-testid=kubernetes-header]", "Kubernetes"); - await app.client.click("[data-testid=telemetry-tab]"); + await click("[data-testid=telemetry-tab]"); await app.client.waitUntilTextExists("[data-testid=telemetry-header]", "Telemetry"); ->>>>>>> master }); it("ensures helm repos", async () => { @@ -105,9 +76,9 @@ describe("Lens integration tests", () => { fail("Lens failed to add any repositories"); } - await app.client.elementClick("[data-testid=kube-tab]"); + await click("[data-testid=kube-tab]"); await app.client.waitUntilTextExists("div.repos .repoName", repos[0].name); // wait for the helm-cli to fetch the repo(s) - await app.client.elementClick("#HelmRepoSelect"); // click the repo select to activate the drop-down + await click("#HelmRepoSelect"); // click the repo select to activate the drop-down await app.client.waitUntilTextExists("div.Select__option", ""); // wait for at least one option to appear (any text) }); }); diff --git a/integration/__tests__/cluster-pages.tests.ts b/integration/__tests__/cluster-pages.tests.ts index 9ed7bb8824..4d6b03f2a6 100644 --- a/integration/__tests__/cluster-pages.tests.ts +++ b/integration/__tests__/cluster-pages.tests.ts @@ -42,13 +42,24 @@ describe("Lens cluster pages", () => { let app: Application; const ready = minikubeReady(TEST_NAMESPACE); + const click = async (selector: string) => { + return (await app.client.$(selector)).click(); + }; + + const waitUntilTextExists = (selector: string, text: string) => { + return app.client.waitUntilTextExists(selector, text); + }; + + const waitForDisplayed = async (selector: string) => { + return (await app.client.$(selector)).waitForDisplayed(); + }; + utils.describeIf(ready)("test common pages", () => { let clusterAdded = false; const addCluster = async () => { - await app.client.waitUntilTextExists("div", "Catalog"); await waitForMinikubeDashboard(app); - await app.client.elementClick('a[href="/nodes"]'); - await app.client.waitUntilTextExists("div.TableCell", "Ready"); + await click('a[href="/nodes"]'); + await waitUntilTextExists("div.TableCell", "Ready"); }; describe("cluster add", () => { @@ -345,30 +356,30 @@ describe("Lens cluster pages", () => { if (drawer !== "") { it(`shows ${drawer} drawer`, async () => { expect(clusterAdded).toBe(true); - await app.client.elementClick(selectors.expandSubMenu); - await app.client.waitUntilTextExists(selectors.subMenuLink(pages[0].href), pages[0].name); + await click(selectors.expandSubMenu); + await waitUntilTextExists(selectors.subMenuLink(pages[0].href), pages[0].name); }); pages.forEach(({ name, href, expectedSelector, expectedText }) => { it(`shows ${drawer}->${name} page`, async () => { expect(clusterAdded).toBe(true); - await app.client.elementClick(selectors.subMenuLink(href)); - await app.client.waitUntilTextExists(expectedSelector, expectedText); + await click(selectors.subMenuLink(href)); + await waitUntilTextExists(expectedSelector, expectedText); }); }); it(`hides ${drawer} drawer`, async () => { expect(clusterAdded).toBe(true); - await app.client.elementClick(selectors.expandSubMenu); - await expect(app.client.waitUntilTextExists(selectors.subMenuLink(pages[0].href), pages[0].name, 100)).rejects.toThrow(); + await click(selectors.expandSubMenu); + await expect(waitUntilTextExists(selectors.subMenuLink(pages[0].href), pages[0].name)).rejects.toThrow(); }); } else { const { href, name, expectedText, expectedSelector } = pages[0]; it(`shows page ${name}`, async () => { expect(clusterAdded).toBe(true); - await app.client.elementClick(`a[href^="/${href}"]`); - await app.client.waitUntilTextExists(expectedSelector, expectedText); + await click(`a[href^="/${href}"]`); + await waitUntilTextExists(expectedSelector, expectedText); }); } }); @@ -386,30 +397,29 @@ describe("Lens cluster pages", () => { it(`shows a log for a pod`, async () => { expect(clusterAdded).toBe(true); // Go to Pods page - await app.client.elementClick(getSidebarSelectors("workloads").expandSubMenu); - await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods"); - await app.client.elementClick('a[href^="/pods"]'); - await app.client.elementClick(".NamespaceSelect"); + await click(getSidebarSelectors("workloads").expandSubMenu); + await waitUntilTextExists('a[href^="/pods"]', "Pods"); + await click('a[href^="/pods"]'); + await click(".NamespaceSelect"); await app.client.keys("kube-system"); await app.client.keys("Enter");// "\uE007" - await app.client.waitUntilTextExists("div.TableCell", "kube-apiserver"); + await waitUntilTextExists("div.TableCell", "kube-apiserver"); // Open logs tab in dock - await app.client.elementClick(".list .TableRow:first-child"); - await (await app.client.$(".Drawer")).waitForDisplayed(); - await (await app.client.$(`ul.KubeObjectMenu li.MenuItem i[title="Logs"]`)).waitForDisplayed(); - await app.client.elementClick("ul.KubeObjectMenu li.MenuItem i[title='Logs']"); + await click(".list .TableRow:first-child"); + await waitForDisplayed(".Drawer"); + await waitForDisplayed(`ul.KubeObjectMenu li.MenuItem i[title="Logs"]`); + await click("ul.KubeObjectMenu li.MenuItem i[title='Logs']"); // Check if controls are available - await (await app.client.$(".LogList .VirtualList")).waitForDisplayed(); - await (await app.client.$(".LogResourceSelector")).waitForDisplayed(); - //await app.client.waitForVisible(".LogSearch .SearchInput"); - await (await app.client.$(".LogSearch .SearchInput input")).waitForDisplayed(); + await waitForDisplayed(".LogList .VirtualList"); + await waitForDisplayed(".LogResourceSelector"); + await waitForDisplayed(".LogSearch .SearchInput input"); // Search for semicolon await app.client.keys(":"); - await (await app.client.$(".LogList .list span.active")).waitForDisplayed(); + await waitForDisplayed(".LogList .list span.active"); // Click through controls - await app.client.elementClick(".LogControls .show-timestamps"); - await app.client.elementClick(".LogControls .show-previous"); + await click(".LogControls .show-timestamps"); + await click(".LogControls .show-previous"); }); }); @@ -424,35 +434,35 @@ describe("Lens cluster pages", () => { it("shows default namespace", async () => { expect(clusterAdded).toBe(true); - await app.client.elementClick('a[href="/namespaces"]'); - await app.client.waitUntilTextExists("div.TableCell", "default"); - await app.client.waitUntilTextExists("div.TableCell", "kube-system"); + await click('a[href="/namespaces"]'); + await waitUntilTextExists("div.TableCell", "default"); + await waitUntilTextExists("div.TableCell", "kube-system"); }); it(`creates ${TEST_NAMESPACE} namespace`, async () => { expect(clusterAdded).toBe(true); - await app.client.elementClick('a[href="/namespaces"]'); - await app.client.waitUntilTextExists("div.TableCell", "default"); - await app.client.waitUntilTextExists("div.TableCell", "kube-system"); - await app.client.elementClick("button.add-button"); - await app.client.waitUntilTextExists("div.AddNamespaceDialog", "Create Namespace"); + await click('a[href="/namespaces"]'); + await waitUntilTextExists("div.TableCell", "default"); + await waitUntilTextExists("div.TableCell", "kube-system"); + await click("button.add-button"); + await waitUntilTextExists("div.AddNamespaceDialog", "Create Namespace"); await app.client.keys(`${TEST_NAMESPACE}\n`); await (await app.client.$(`.name=${TEST_NAMESPACE}`)).waitForExist(); }); it(`creates a pod in ${TEST_NAMESPACE} namespace`, async () => { expect(clusterAdded).toBe(true); - await app.client.elementClick(getSidebarSelectors("workloads").expandSubMenu); - await app.client.waitUntilTextExists('a[href^="/pods"]', "Pods"); - await app.client.elementClick('a[href^="/pods"]'); + await click(getSidebarSelectors("workloads").expandSubMenu); + await waitUntilTextExists('a[href^="/pods"]', "Pods"); + await click('a[href^="/pods"]'); - await app.client.elementClick(".NamespaceSelect"); + await click(".NamespaceSelect"); await app.client.keys(TEST_NAMESPACE); await app.client.keys("Enter");// "\uE007" - await app.client.elementClick(".Icon.new-dock-tab"); - await app.client.waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource"); - await app.client.elementClick("li.MenuItem.create-resource-tab"); - await (await app.client.$(".CreateResource div.ace_content")).waitForDisplayed(); + await click(".Icon.new-dock-tab"); + await waitUntilTextExists("li.MenuItem.create-resource-tab", "Create resource"); + await click("li.MenuItem.create-resource-tab"); + await waitForDisplayed(".CreateResource div.ace_content"); // Write pod manifest to editor await app.client.keys("apiVersion: v1\n"); await app.client.keys("kind: Pod\n"); @@ -465,12 +475,12 @@ describe("Lens cluster pages", () => { await app.client.keys(" image: nginx:alpine\n"); // Create deployment await (await app.client.$("button.Button=Create & Close")).waitForEnabled(); - await app.client.elementClick("button.Button=Create & Close"); + await click("button.Button=Create & Close"); // Wait until first bits of pod appears on dashboard await (await app.client.$(".name=nginx-create-pod-test")).waitForExist(); // Open pod details - await app.client.elementClick(".name=nginx-create-pod-test"); - await app.client.waitUntilTextExists("div.drawer-title-text", "Pod: nginx-create-pod-test"); + await click(".name=nginx-create-pod-test"); + await waitUntilTextExists("div.drawer-title-text", "Pod: nginx-create-pod-test"); }); }); }); diff --git a/integration/__tests__/command-palette.tests.ts b/integration/__tests__/command-palette.tests.ts index 03ef6e23ae..63930d8f0e 100644 --- a/integration/__tests__/command-palette.tests.ts +++ b/integration/__tests__/command-palette.tests.ts @@ -39,7 +39,7 @@ describe("Lens command palette", () => { }); it("opens command dialog from menu", async () => { - await app.electron.ipcRenderer.send("test-menu-item-click", "View", "Command Palette..."); + (app.electron as any).ipcRenderer.send("test-menu-item-click", "View", "Command Palette..."); await app.client.waitUntilTextExists(".Select__option", "Preferences: Open"); await app.client.keys("Escape"); }); diff --git a/integration/helpers/minikube.ts b/integration/helpers/minikube.ts index fb96c27aef..ab0e29ab28 100644 --- a/integration/helpers/minikube.ts +++ b/integration/helpers/minikube.ts @@ -59,13 +59,11 @@ export function minikubeReady(testNamespace: string): boolean { } export async function waitForMinikubeDashboard(app: Application) { - await app.client.waitUntilTextExists("div.TableCell", "minikube"); - await (await app.client.$(".Input.SearchInput input")).waitForExist(); + await (await app.client.$(".Input.SearchInput input")).waitForDisplayed(); await (await app.client.$(".Input.SearchInput input")).setValue("minikube"); - await app.client.waitUntilTextExists("div.TableCell", "minikube"); - await app.client.elementClick("div.TableRow"); + await (await app.client.$("div.TableRow")).click(); await app.client.waitUntilTextExists("div.drawer-title-text", "KubernetesCluster: minikube"); - await app.client.elementClick("div.EntityIcon div.HotbarIcon div div.MuiAvatar-root"); + await (await app.client.$("div.EntityIcon div.HotbarIcon div div.MuiAvatar-root")).click(); await app.client.waitUntilTextExists("pre.kube-auth-out", "Authentication proxy started"); await (await app.client.$(`iframe[name="minikube"]`)).waitForDisplayed(); await (await app.client.$("iframe[name=minikube]")).waitForExist(); diff --git a/integration/helpers/utils.ts b/integration/helpers/utils.ts index ae3a516c62..ca02502aab 100644 --- a/integration/helpers/utils.ts +++ b/integration/helpers/utils.ts @@ -84,38 +84,21 @@ export async function appStart() { } }); - console.log("APP", app); - - const startedApp = await app.start(); + await app.start(); // Wait for splash screen to be closed - while (await startedApp.client.getWindowCount() > 1); - await startedApp.client.windowByIndex(0); - await startedApp.client.waitUntilWindowLoaded(); + while (await app.client.getWindowCount() > 1); + await new Promise((resolve) => setTimeout(resolve, 1_000)); + await app.client.windowByIndex(0); + await app.client.waitUntilWindowLoaded(); await showCatalog(app); - return startedApp; -} - -export async function clickWhatsNew(app: Application) { - await app.client.waitUntilTextExists("h1", "What's new?"); - await app.client.elementClick("button.primary"); - await app.client.waitUntilTextExists("div", "Catalog"); -} - -export async function clickWelcomeNotification(app: Application) { - const itemsText = await app.client.getElementText("div.info-panel"); - - if (itemsText === "0 items") { - // welcome notification should be present, dismiss it - await app.client.waitUntilTextExists("div.message", "Welcome!"); - await app.client.elementClick(".notification i.Icon.close"); - } + return app; } export async function showCatalog(app: Application) { await app.client.waitUntilTextExists("[data-test-id=catalog-link]", "Catalog"); - await app.client.elementClick("[data-test-id=catalog-link]"); + await (await app.client.$("[data-test-id=catalog-link]")).click(); } type AsyncPidGetter = () => Promise; diff --git a/package.json b/package.json index 732ee878c1..1d96894bb9 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "bundledHelmVersion": "3.5.4" }, "engines": { - "node": ">=12 <13" + "node": ">=14 <15" }, "jest": { "collectCoverage": false, @@ -179,6 +179,7 @@ } }, "dependencies": { + "@electron/remote": "^1.1.0", "@hapi/call": "^8.0.1", "@hapi/subtext": "^7.0.3", "@kubernetes/client-node": "^0.14.3", @@ -314,7 +315,7 @@ "css-loader": "^3.5.3", "deepdash": "^5.3.5", "dompurify": "^2.0.11", - "electron": "^11.4.3", + "electron": "^12.0.10", "electron-builder": "^22.10.5", "electron-notarize": "^0.3.0", "eslint": "^7.7.0", @@ -355,7 +356,7 @@ "react-window": "^1.8.5", "sass-loader": "^8.0.2", "sharp": "^0.26.1", - "spectron": "^13.0.0", + "spectron": "^14.0.0", "style-loader": "^2.0.0", "tailwindcss": "^2.1.2", "ts-jest": "26.3.0", diff --git a/src/common/base-store.ts b/src/common/base-store.ts index 893a09b965..d15c8d508c 100644 --- a/src/common/base-store.ts +++ b/src/common/base-store.ts @@ -22,13 +22,15 @@ import path from "path"; import Config from "conf"; import type { Options as ConfOptions } from "conf/dist/source/types"; -import { app, ipcMain, IpcMainEvent, ipcRenderer, IpcRendererEvent, remote } from "electron"; +import { app, ipcMain, IpcMainEvent, ipcRenderer, IpcRendererEvent } from "electron"; import { IReactionOptions, makeObservable, observable, reaction, runInAction, when } from "mobx"; import { getAppVersion, Singleton, toJS, Disposer } from "./utils"; import logger from "../main/logger"; import { broadcastMessage, subscribeToBroadcast, unsubscribeFromBroadcast } from "./ipc"; import isEqual from "lodash/isEqual"; +const remote = ipcMain ? null : require("@electron/remote"); + export interface BaseStoreParams extends ConfOptions { autoLoad?: boolean; syncEnabled?: boolean; diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index 60968efd06..967f39bf58 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -20,7 +20,7 @@ */ import path from "path"; -import { app, ipcMain, ipcRenderer, remote, webFrame } from "electron"; +import { app, ipcMain, ipcRenderer, webFrame } from "electron"; import { unlink } from "fs-extra"; import { action, comparer, computed, makeObservable, observable, reaction } from "mobx"; import { BaseStore } from "./base-store"; @@ -32,6 +32,8 @@ import { appEventBus } from "./event-bus"; import { handleRequest, requestMain, subscribeToBroadcast, unsubscribeAllFromBroadcast } from "./ipc"; import { disposer, noop, toJS } from "./utils"; +const remote = ipcMain ? null : require("@electron/remote"); + export interface ClusterIconUpload { clusterId: string; name: string; diff --git a/src/common/user-store.ts b/src/common/user-store.ts index f7ab221bb8..771a35fdf7 100644 --- a/src/common/user-store.ts +++ b/src/common/user-store.ts @@ -20,7 +20,7 @@ */ import type { ThemeId } from "../renderer/theme.store"; -import { app, remote } from "electron"; +import { app, ipcMain } from "electron"; import semver from "semver"; import { action, computed, observable, reaction, makeObservable } from "mobx"; import moment from "moment-timezone"; @@ -33,6 +33,8 @@ import os from "os"; import { fileNameMigration } from "../migrations/user-store"; import { ObservableToggleSet, toJS } from "../renderer/utils"; +const remote = ipcMain ? null : require("@electron/remote"); + export interface UserStoreModel { lastSeenAppVersion: string; preferences: UserPreferencesModel; diff --git a/src/extensions/extension-loader.ts b/src/extensions/extension-loader.ts index da2669550f..fc8ba332b1 100644 --- a/src/extensions/extension-loader.ts +++ b/src/extensions/extension-loader.ts @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { app, ipcRenderer, remote } from "electron"; +import { app, ipcMain, ipcRenderer } from "electron"; import { EventEmitter } from "events"; import { isEqual } from "lodash"; import { action, computed, makeObservable, observable, reaction, when } from "mobx"; @@ -35,6 +35,8 @@ import type { LensMainExtension } from "./lens-main-extension"; import type { LensRendererExtension } from "./lens-renderer-extension"; import * as registries from "./registries"; +const remote = ipcMain ? null : require("@electron/remote"); + export function extensionPackagesRoot() { return path.join((app || remote.app).getPath("userData")); } diff --git a/src/main/extension-filesystem.ts b/src/main/extension-filesystem.ts index 402619bdc9..2a8c2cd07e 100644 --- a/src/main/extension-filesystem.ts +++ b/src/main/extension-filesystem.ts @@ -21,7 +21,7 @@ import { randomBytes } from "crypto"; import { SHA256 } from "crypto-js"; -import { app, remote } from "electron"; +import { app, ipcMain } from "electron"; import fse from "fs-extra"; import { action, makeObservable, observable } from "mobx"; import path from "path"; @@ -29,6 +29,8 @@ import { BaseStore } from "../common/base-store"; import type { LensExtensionId } from "../extensions/lens-extension"; import { toJS } from "../common/utils"; +const remote = ipcMain ? null : require("@electron/remote"); + interface FSProvisionModel { extensions: Record; // extension names to paths } diff --git a/src/main/index.ts b/src/main/index.ts index 3abbfecd17..768d48f82a 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -22,6 +22,7 @@ // Main process import "../common/system-ca"; +import { initialize as initializeRemote } from "@electron/remote/dist/src/main"; import * as Mobx from "mobx"; import * as LensExtensionsCommonApi from "../extensions/common-api"; import * as LensExtensionsMainApi from "../extensions/main-api"; @@ -79,6 +80,7 @@ if (process.env.LENS_DISABLE_GPU) { app.disableHardwareAcceleration(); } +initializeRemote(); configurePackages(); mangleProxyEnv(); diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index 1a00d2919d..e13923948a 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { app, remote } from "electron"; +import { app, ipcMain } from "electron"; import path from "path"; import fs from "fs"; import { promiseExec } from "./promise-exec"; @@ -32,6 +32,7 @@ import { customRequest } from "../common/request"; import { getBundledKubectlVersion } from "../common/utils/app-version"; import { isDevelopment, isWindows, isTestEnv } from "../common/vars"; +const remote = ipcMain ? null : require("@electron/remote"); const bundledVersion = getBundledKubectlVersion(); const kubectlMap: Map = new Map([ ["1.7", "1.8.15"], diff --git a/src/main/window-manager.ts b/src/main/window-manager.ts index 25b9e4ca88..c1204c94bb 100644 --- a/src/main/window-manager.ts +++ b/src/main/window-manager.ts @@ -85,6 +85,7 @@ export class WindowManager extends Singleton { nodeIntegration: true, nodeIntegrationInSubFrames: true, enableRemoteModule: true, + contextIsolation: false }, }); this.windowState.manage(this.mainWindow); @@ -219,7 +220,9 @@ export class WindowManager extends Singleton { resizable: false, show: false, webPreferences: { - nodeIntegration: true + nodeIntegration: true, + enableRemoteModule: true, + contextIsolation: false } }); await this.splashWindow.loadURL("static://splash.html"); diff --git a/src/migrations/cluster-store/3.6.0-beta.1.ts b/src/migrations/cluster-store/3.6.0-beta.1.ts index 5339d5232b..bc8740c982 100644 --- a/src/migrations/cluster-store/3.6.0-beta.1.ts +++ b/src/migrations/cluster-store/3.6.0-beta.1.ts @@ -23,12 +23,14 @@ // convert file path cluster icons to their base64 encoded versions import path from "path"; -import { app, remote } from "electron"; +import { app, ipcMain } from "electron"; import { migration } from "../migration-wrapper"; import fse from "fs-extra"; import { ClusterModel, ClusterStore } from "../../common/cluster-store"; import { loadConfigFromFileSync } from "../../common/kube-helpers"; +const remote = ipcMain ? null : require("@electron/remote"); + export default migration({ version: "3.6.0-beta.1", run(store, printLog) { diff --git a/src/migrations/user-store/file-name-migration.ts b/src/migrations/user-store/file-name-migration.ts index e0c848d3a8..d4a1592b9b 100644 --- a/src/migrations/user-store/file-name-migration.ts +++ b/src/migrations/user-store/file-name-migration.ts @@ -20,9 +20,11 @@ */ import fse from "fs-extra"; -import { app, remote } from "electron"; +import { app, ipcMain } from "electron"; import path from "path"; +const remote = ipcMain ? null : require("@electron/remote"); + export async function fileNameMigration() { const userDataPath = (app || remote.app).getPath("userData"); const configJsonPath = path.join(userDataPath, "config.json"); diff --git a/src/renderer/utils/createStorage.ts b/src/renderer/utils/createStorage.ts index f432cc850e..b40d3756c5 100755 --- a/src/renderer/utils/createStorage.ts +++ b/src/renderer/utils/createStorage.ts @@ -22,13 +22,14 @@ // Keeps window.localStorage state in external JSON-files. // Because app creates random port between restarts => storage session wiped out each time. import path from "path"; -import { app, remote } from "electron"; +import { app, ipcMain } from "electron"; import { comparer, observable, reaction, toJS, when } from "mobx"; import fse from "fs-extra"; import { StorageHelper } from "./storageHelper"; import { ClusterStore, getHostedClusterId } from "../../common/cluster-store"; import logger from "../../main/logger"; +const remote = ipcMain ? null : require("@electron/remote"); const storage = observable({ initialized: false, loaded: false, diff --git a/yarn.lock b/yarn.lock index bcbb916fde..8a812a5482 100644 --- a/yarn.lock +++ b/yarn.lock @@ -314,7 +314,7 @@ ajv "^6.12.0" ajv-keywords "^3.4.1" -"@electron/get@^1.0.1", "@electron/get@^1.12.2": +"@electron/get@^1.0.1": version "1.12.2" resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.12.2.tgz#6442066afb99be08cefb9a281e4b4692b33764f3" integrity sha512-vAuHUbfvBQpYTJ5wB7uVIDq5c/Ry0fiTBMs7lnEYAo/qXXppIVcWdfBr57u6eRnKdVso7KSiH6p/LbQAG6Izrg== @@ -330,6 +330,27 @@ global-agent "^2.0.2" global-tunnel-ng "^2.7.1" +"@electron/get@^1.12.4": + version "1.12.4" + resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.12.4.tgz#a5971113fc1bf8fa12a8789dc20152a7359f06ab" + integrity sha512-6nr9DbJPUR9Xujw6zD3y+rS95TyItEVM0NVjt1EehY2vUWfIgPiIPVHxCvaTS0xr2B+DRxovYVKbuOWqC35kjg== + dependencies: + debug "^4.1.1" + env-paths "^2.2.0" + fs-extra "^8.1.0" + got "^9.6.0" + progress "^2.0.3" + semver "^6.2.0" + sumchecker "^3.0.1" + optionalDependencies: + global-agent "^2.0.2" + global-tunnel-ng "^2.7.1" + +"@electron/remote@^1.0.4", "@electron/remote@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-1.1.0.tgz#167d119c7c03c7778b556fdc4f1f38a44b23f1c2" + integrity sha512-yr8gZTkIgJYKbFqExI4QZqMSjn1kL/us9Dl46+TH1EZdhgRtsJ6HDfdsIxu0QEc6Hv+DMAXs69rgquH+8FDk4w== + "@electron/universal@1.0.4": version "1.0.4" resolved "https://registry.yarnpkg.com/@electron/universal/-/universal-1.0.4.tgz#231ac246c39d45b80e159bd21c3f9027dcaa10f5" @@ -1520,6 +1541,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.24.tgz#c57511e3a19c4b5e9692bb2995c40a3a52167944" integrity sha512-5SCfvCxV74kzR3uWgTYiGxrd69TbT1I6+cMx1A5kEly/IVveJBimtAMlXiEyVFn5DvUFewQWxOOiJhlxeQwxgA== +"@types/node@^14.6.2": + version "14.17.3" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.3.tgz#6d327abaa4be34a74e421ed6409a0ae2f47f4c3d" + integrity sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -5187,12 +5213,12 @@ electron-builder@^22.10.5: update-notifier "^5.1.0" yargs "^16.2.0" -electron-chromedriver@^11.0.0: - version "11.0.0" - resolved "https://registry.yarnpkg.com/electron-chromedriver/-/electron-chromedriver-11.0.0.tgz#49b034ed0ad12c12e3522862c7bb46875a0d85e1" - integrity sha512-ayMJPBbB4puU0SqYbcD9XvF3/7GWIhqKE1n5lG2/GQPRnrZkNoPIilsrS0rQcD50Xhl69KowatDqLhUznZWtbA== +electron-chromedriver@^12.0.0: + version "12.0.0" + resolved "https://registry.yarnpkg.com/electron-chromedriver/-/electron-chromedriver-12.0.0.tgz#55bdc451b938b384642d613a05eadacb1fe476ee" + integrity sha512-zOs98o9+20Er8Q44z06h90VldwrJaoRCieW3Q8WkdDjA3cMRU5mlmm1kGDhPLMeYNuhq6e39aGMVH/IBFD97HQ== dependencies: - "@electron/get" "^1.12.2" + "@electron/get" "^1.12.4" extract-zip "^2.0.0" electron-devtools-installer@^3.1.1: @@ -5257,13 +5283,13 @@ electron@*: "@types/node" "^12.0.12" extract-zip "^1.0.3" -electron@^11.4.3: - version "11.4.3" - resolved "https://registry.yarnpkg.com/electron/-/electron-11.4.3.tgz#74319635417c24fd19e31cfce5a39c8792e4014b" - integrity sha512-RhCWJqiYK5oIRGOheilhg/nngCgk0fPgaf00KvbxorlvFZAz8OeMT5ShCpVsMSoyYhk4XEnn4orRly5ltaFYJg== +electron@^12.0.10: + version "12.0.10" + resolved "https://registry.yarnpkg.com/electron/-/electron-12.0.10.tgz#d0879ff005a200d5b08dbfb3e5bbea744d38c71a" + integrity sha512-qaNvFG4AgeuT3PkSljQ9MlY7hz87wIwJ5cmSZ1453IVsUd0BV7pcaLViSpR1bRSqxetDDWxCLtCp0N9RXeDZww== dependencies: "@electron/get" "^1.0.1" - "@types/node" "^12.0.12" + "@types/node" "^14.6.2" extract-zip "^1.0.3" elliptic@^6.0.0, elliptic@^6.5.2: @@ -13360,14 +13386,15 @@ spdy@^4.0.2: select-hose "^2.0.0" spdy-transport "^3.0.0" -spectron@^13.0.0: - version "13.0.0" - resolved "https://registry.yarnpkg.com/spectron/-/spectron-13.0.0.tgz#16bdfcf9a2b26cb5ee6c3e29b4f08101e339aa4d" - integrity sha512-7RPa6Fp8gqL4V0DubobnqIRFHIijkpjg6MFHcJlxoerWyvLJd+cQvOh756XpB1Z/U3DyA9jPcS+HE2PvYRP5+A== +spectron@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/spectron/-/spectron-14.0.0.tgz#c8160e38c30dcda39734f3e8e809162dc0805d14" + integrity sha512-88GM7D1eLiTxjByjtY7lxU7CJcQ92kX1x0WfnADaIXqqYRLbI1KlIWxXz1Xm5UxuMJh5N847K0NONG49mvZtuw== dependencies: + "@electron/remote" "^1.0.4" dev-null "^0.1.1" - electron-chromedriver "^11.0.0" - request "^2.88.2" + electron-chromedriver "^12.0.0" + got "^11.8.0" split "^1.0.1" webdriverio "^6.9.1"