Stop using @electron/remote to obtain app.getPath() (#4078)

* Stop using remote to obtain app.getPath()

- Initialize entire map in bootstrap()

- Updated unit tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Resolve PR comments

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix test

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix build

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Ensure that init can only be called once and catch errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Replace basically all uses of app.getPath() with AppPaths.get()

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix unit tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-10-27 21:07:41 -04:00
1 parent 65b6908bf1
commit f297407156
45 files changed
+521 -200

No files matched your search

+2 -2
View File
@@ -23,12 +23,12 @@
// convert file path cluster icons to their base64 encoded versions
import path from "path";
import { app } from "electron";
import fse from "fs-extra";
import { loadConfigFromFileSync } from "../../common/kube-helpers";
import { MigrationDeclaration, migrationLog } from "../helpers";
import type { ClusterModel } from "../../common/cluster-types";
import { getCustomKubeConfigPath, storedKubeConfigFolder } from "../../common/utils";
import { AppPaths } from "../../common/app-paths";
interface Pre360ClusterModel extends ClusterModel {
kubeConfig: string;
@@ -37,7 +37,7 @@ interface Pre360ClusterModel extends ClusterModel {
export default {
version: "3.6.0-beta.1",
run(store) {
const userDataPath = app.getPath("userData");
const userDataPath = AppPaths.get("userData");
const storedClusters: Pre360ClusterModel[] = store.get("clusters") ?? [];
const migratedClusters: ClusterModel[] = [];
@@ -20,10 +20,10 @@
*/
import path from "path";
import { app } from "electron";
import fse from "fs-extra";
import type { ClusterModel } from "../../common/cluster-types";
import type { MigrationDeclaration } from "../helpers";
import { AppPaths } from "../../common/app-paths";
interface Pre500WorkspaceStoreModel {
workspaces: {
@@ -35,7 +35,7 @@ interface Pre500WorkspaceStoreModel {
export default {
version: "5.0.0-beta.10",
run(store) {
const userDataPath = app.getPath("userData");
const userDataPath = AppPaths.get("userData");
try {
const workspaceData: Pre500WorkspaceStoreModel = fse.readJsonSync(path.join(userDataPath, "lens-workspace-store.json"));
@@ -23,8 +23,8 @@ import type { ClusterModel, ClusterPreferences, ClusterPrometheusPreferences } f
import { MigrationDeclaration, migrationLog } from "../helpers";
import { generateNewIdFor } from "../utils";
import path from "path";
import { app } from "electron";
import { moveSync, removeSync } from "fs-extra";
import { AppPaths } from "../../common/app-paths";
function mergePrometheusPreferences(left: ClusterPrometheusPreferences, right: ClusterPrometheusPreferences): ClusterPrometheusPreferences {
if (left.prometheus && left.prometheusProvider) {
@@ -106,7 +106,7 @@ function moveStorageFolder({ folder, newId, oldId }: { folder: string, newId: st
export default {
version: "5.0.0-beta.13",
run(store) {
const folder = path.resolve(app.getPath("userData"), "lens-local-storage");
const folder = path.resolve(AppPaths.get("userData"), "lens-local-storage");
const oldClusters: ClusterModel[] = store.get("clusters") ?? [];
const clusters = new Map<string, ClusterModel>();