diff --git a/package.json b/package.json index a4d9b321bf..17679b371b 100644 --- a/package.json +++ b/package.json @@ -218,11 +218,12 @@ "@hapi/subtext": "^7.0.4", "@kubernetes/client-node": "^0.17.1", "@material-ui/styles": "^4.11.5", - "@ogre-tools/fp": "^12.0.1", - "@ogre-tools/injectable": "^12.0.1", - "@ogre-tools/injectable-extension-for-auto-registration": "^12.0.1", - "@ogre-tools/injectable-extension-for-mobx": "^12.0.1", - "@ogre-tools/injectable-react": "^12.0.1", + "@ogre-tools/fp": "^14.0.3", + "@ogre-tools/injectable": "^14.0.3", + "@ogre-tools/injectable-extension-for-auto-registration": "^14.0.3", + "@ogre-tools/injectable-extension-for-mobx": "^14.0.3", + "@ogre-tools/injectable-react": "^14.0.3", + "@ogre-tools/mobx-utils": "^14.0.3", "@sentry/electron": "^3.0.8", "@sentry/integrations": "^6.19.3", "@side/jest-runtime": "^1.0.1", @@ -291,7 +292,13 @@ "winston-console-format": "^1.0.8", "winston-transport-browserconsole": "^1.0.5", "ws": "^8.11.0", - "xterm-link-provider": "^1.3.1" + "xterm-link-provider": "^1.3.1", + "@lensapp/cluster": "^0.1.5", + "@lensapp/feature-core": "^0.1.6", + "@lensapp/fs": "^0.2.0", + "@lensapp/logging": "^0.1.5", + "@lensapp/shell": "^0.1.6", + "@lensapp/utils": "^0.2.4" }, "devDependencies": { "@async-fn/jest": "1.6.4", diff --git a/src/common/fs/delete-file.injectable.ts b/src/common/fs/delete-file.injectable.ts index 57aba5b379..f98639a854 100644 --- a/src/common/fs/delete-file.injectable.ts +++ b/src/common/fs/delete-file.injectable.ts @@ -8,7 +8,7 @@ import fsInjectable from "./fs.injectable"; export type DeleteFile = (filePath: string) => Promise; const deleteFileInjectable = getInjectable({ - id: "delete-file", + id: "delete-file-1", instantiate: (di): DeleteFile => di.inject(fsInjectable).unlink, }); diff --git a/src/common/fs/fs.injectable.ts b/src/common/fs/fs.injectable.ts index ab385e5871..4661e63995 100644 --- a/src/common/fs/fs.injectable.ts +++ b/src/common/fs/fs.injectable.ts @@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable"; import fse from "fs-extra"; const fsInjectable = getInjectable({ - id: "fs", + id: "fs-1", instantiate: () => fse, causesSideEffects: true, }); diff --git a/src/common/fs/path-exists.injectable.ts b/src/common/fs/path-exists.injectable.ts index aee6cac52b..824e550379 100644 --- a/src/common/fs/path-exists.injectable.ts +++ b/src/common/fs/path-exists.injectable.ts @@ -8,7 +8,7 @@ import fsInjectable from "./fs.injectable"; export type PathExists = (path: string) => Promise; const pathExistsInjectable = getInjectable({ - id: "path-exists", + id: "path-exists-1", instantiate: (di): PathExists => di.inject(fsInjectable).pathExists, }); diff --git a/src/common/fs/read-file.injectable.ts b/src/common/fs/read-file.injectable.ts index 0dc539e1b1..926cf70da6 100644 --- a/src/common/fs/read-file.injectable.ts +++ b/src/common/fs/read-file.injectable.ts @@ -8,7 +8,7 @@ import fsInjectable from "./fs.injectable"; export type ReadFile = (filePath: string) => Promise; const readFileInjectable = getInjectable({ - id: "read-file", + id: "read-file-1", instantiate: (di): ReadFile => { const { readFile } = di.inject(fsInjectable); diff --git a/src/common/fs/read-json-file.injectable.ts b/src/common/fs/read-json-file.injectable.ts index d270368cf9..038f49bbd7 100644 --- a/src/common/fs/read-json-file.injectable.ts +++ b/src/common/fs/read-json-file.injectable.ts @@ -9,7 +9,7 @@ import fsInjectable from "./fs.injectable"; export type ReadJson = (filePath: string) => Promise; const readJsonFileInjectable = getInjectable({ - id: "read-json-file", + id: "read-json-file-1", instantiate: (di): ReadJson => di.inject(fsInjectable).readJson, }); diff --git a/src/common/fs/read-yaml-file.injectable.ts b/src/common/fs/read-yaml-file.injectable.ts index a34a69d388..5e1ac8c9b4 100644 --- a/src/common/fs/read-yaml-file.injectable.ts +++ b/src/common/fs/read-yaml-file.injectable.ts @@ -9,7 +9,7 @@ import yaml from "js-yaml"; export type ReadYamlFile = (filePath: string) => Promise; const readYamlFileInjectable = getInjectable({ - id: "read-yaml-file", + id: "read-yaml-file-1", instantiate: (di): ReadYamlFile => { const readFile = di.inject(readFileInjectable); diff --git a/src/common/fs/write-file.injectable.ts b/src/common/fs/write-file.injectable.ts index faa5285ca1..631f20a065 100644 --- a/src/common/fs/write-file.injectable.ts +++ b/src/common/fs/write-file.injectable.ts @@ -10,7 +10,7 @@ import fsInjectable from "./fs.injectable"; export type WriteFile = (filePath: string, content: string | Buffer, opts?: WriteFileOptions) => Promise; const writeFileInjectable = getInjectable({ - id: "write-file", + id: "write-file-1", instantiate: (di): WriteFile => { const { writeFile, ensureDir } = di.inject(fsInjectable); diff --git a/src/common/fs/write-json-file.injectable.ts b/src/common/fs/write-json-file.injectable.ts index a7079d7f84..a2bb71416a 100644 --- a/src/common/fs/write-json-file.injectable.ts +++ b/src/common/fs/write-json-file.injectable.ts @@ -10,7 +10,7 @@ import fsInjectable from "./fs.injectable"; export type WriteJson = (filePath: string, contents: JsonValue) => Promise; const writeJsonFileInjectable = getInjectable({ - id: "write-json-file", + id: "write-json-file-1", instantiate: (di): WriteJson => { const { writeJson, ensureDir } = di.inject(fsInjectable); diff --git a/src/common/path/get-dirname.injectable.ts b/src/common/path/get-dirname.injectable.ts index 93b4496767..de2f9c21f9 100644 --- a/src/common/path/get-dirname.injectable.ts +++ b/src/common/path/get-dirname.injectable.ts @@ -8,7 +8,7 @@ import path from "path"; export type GetDirnameOfPath = (path: string) => string; const getDirnameOfPathInjectable = getInjectable({ - id: "get-dirname-of-path", + id: "get-dirname-of-path-1", instantiate: (): GetDirnameOfPath => path.dirname, causesSideEffects: true, }); diff --git a/src/common/utils/channel/channel.test.ts b/src/common/utils/channel/channel.test.ts index 9a361b6770..291081b618 100644 --- a/src/common/utils/channel/channel.test.ts +++ b/src/common/utils/channel/channel.test.ts @@ -208,7 +208,7 @@ describe("channel", () => { handler: () => () => "some-other-value", }); - testChannelListenerInMain2Injectable.id += "2"; + // testChannelListenerInMain2Injectable.id += "2"; applicationBuilder.beforeApplicationStart((mainDi) => { runInAction(() => { diff --git a/src/main/catalog/catalog-entities-from-features/catalog-entities.injectable.ts b/src/main/catalog/catalog-entities-from-features/catalog-entities.injectable.ts index 8d100374ed..b26aa1fe0e 100644 --- a/src/main/catalog/catalog-entities-from-features/catalog-entities.injectable.ts +++ b/src/main/catalog/catalog-entities-from-features/catalog-entities.injectable.ts @@ -4,17 +4,17 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import type { ClusterDto } from "./clusters.injectable"; -import clustersInjectable from "./clusters.injectable"; import catalogEntityForClusterInjectable from "./catalog-entity-for-cluster.injectable"; +import type { Cluster } from "@lensapp/cluster"; +import { clustersInjectionToken } from "@lensapp/cluster"; const catalogEntitiesInjectable = getInjectable({ id: "catalog-entities", instantiate: (di) => { - const clusters = di.inject(clustersInjectable); + const clusters = di.inject(clustersInjectionToken); - const getCatalogEntity = (cluster: ClusterDto) => + const getCatalogEntity = (cluster: Cluster) => di.inject(catalogEntityForClusterInjectable, cluster); return computed(() => clusters.get().map(getCatalogEntity)); diff --git a/src/main/catalog/catalog-entities-from-features/catalog-entity-for-cluster.injectable.ts b/src/main/catalog/catalog-entities-from-features/catalog-entity-for-cluster.injectable.ts index 3a43ccf339..525d49560d 100644 --- a/src/main/catalog/catalog-entities-from-features/catalog-entity-for-cluster.injectable.ts +++ b/src/main/catalog/catalog-entities-from-features/catalog-entity-for-cluster.injectable.ts @@ -2,14 +2,17 @@ * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ +import type { Cluster } from "@lensapp/cluster"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; -import { KubernetesCluster, LensKubernetesClusterStatus } from "../../../common/catalog-entities"; -import type { ClusterDto } from "./clusters.injectable"; +import { + KubernetesCluster, + LensKubernetesClusterStatus, +} from "../../../common/catalog-entities"; const catalogEntityForClusterInjectable = getInjectable({ id: "catalog-entity-for-cluster", - instantiate: (di, cluster: ClusterDto) => + instantiate: (di, cluster: Cluster) => new KubernetesCluster({ metadata: { uid: cluster.id, @@ -31,7 +34,7 @@ const catalogEntityForClusterInjectable = getInjectable({ }), lifecycle: lifecycleEnum.keyedSingleton({ - getInstanceKey: (di, cluster: ClusterDto) => cluster.id, + getInstanceKey: (di, cluster: Cluster) => cluster.id, }), }); diff --git a/src/main/catalog/catalog-entities-from-features/clusters.injectable.ts b/src/main/catalog/catalog-entities-from-features/clusters.injectable.ts deleted file mode 100644 index a197b20f93..0000000000 --- a/src/main/catalog/catalog-entities-from-features/clusters.injectable.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import { getInjectable } from "@ogre-tools/injectable"; -import { computedInjectManyInjectable } from "@ogre-tools/injectable-extension-for-mobx"; -import { computed } from "mobx"; -import { clusterInjectionToken } from "@lensapp/catalog"; - -const clustersInjectable = getInjectable({ - id: "clusters", - - instantiate: (di) => { - const computedInjectMany = di.inject(computedInjectManyInjectable); - const clusters = computedInjectMany(clusterInjectionToken); - - return computed(() => clusters.get()); - }, -}); - -export default clustersInjectable; diff --git a/src/main/catalog/entity-registry.injectable.ts b/src/main/catalog/entity-registry.injectable.ts index 003ed3d62e..6a461a4bee 100644 --- a/src/main/catalog/entity-registry.injectable.ts +++ b/src/main/catalog/entity-registry.injectable.ts @@ -5,12 +5,15 @@ import { getInjectable } from "@ogre-tools/injectable"; import hasCategoryForEntityInjectable from "../../common/catalog/has-category-for-entity.injectable"; import { CatalogEntityRegistry } from "./entity-registry"; +import catalogEntitiesInjectable + from "./catalog-entities-from-features/catalog-entities.injectable"; const catalogEntityRegistryInjectable = getInjectable({ id: "catalog-entity-registry", instantiate: (di) => new CatalogEntityRegistry({ hasCategoryForEntity: di.inject(hasCategoryForEntityInjectable), + decoupledCatalogEntities: di.inject(catalogEntitiesInjectable), }), }); diff --git a/src/main/getDi.ts b/src/main/getDi.ts index 17d9cc36b7..7b1a9883c8 100644 --- a/src/main/getDi.ts +++ b/src/main/getDi.ts @@ -18,7 +18,10 @@ export const getDi = () => { autoRegister({ di, - requireContexts: [ + + targetModule: module, + + getRequireContexts: () => [ require.context("./", true, /\.injectable\.(ts|tsx)$/), require.context("../extensions", true, /\.injectable\.(ts|tsx)$/), require.context("../common", true, /\.injectable\.(ts|tsx)$/), diff --git a/src/main/register-features.ts b/src/main/register-features.ts index 74dda3a8b1..5c114a83f7 100644 --- a/src/main/register-features.ts +++ b/src/main/register-features.ts @@ -3,8 +3,18 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ +import { registerFeature } from "@lensapp/feature-core"; +import clusterFeature from "@lensapp/cluster"; +import fsFeature from "@lensapp/fs"; +import loggingFeature from "@lensapp/logging"; +import shellFeature from "@lensapp/shell"; import type { DiContainer } from "@ogre-tools/injectable"; import { action } from "mobx"; -export default action((di: DiContainer) => {}); +export default action((di: DiContainer) => { + registerFeature(di, clusterFeature); + registerFeature(di, fsFeature); + registerFeature(di, loggingFeature); + registerFeature(di, shellFeature); +}); diff --git a/src/renderer/getDi.tsx b/src/renderer/getDi.tsx index 348c5e369b..3906d35abc 100644 --- a/src/renderer/getDi.tsx +++ b/src/renderer/getDi.tsx @@ -19,7 +19,10 @@ export const getDi = () => { autoRegister({ di, - requireContexts: [ + + targetModule: module, + + getRequireContexts: () => [ require.context("./", true, /\.injectable\.(ts|tsx)$/), require.context("../common", true, /\.injectable\.(ts|tsx)$/), require.context("../extensions", true, /\.injectable\.(ts|tsx)$/), diff --git a/src/renderer/register-features.ts b/src/renderer/register-features.ts index 2261de4d4f..74dda3a8b1 100644 --- a/src/renderer/register-features.ts +++ b/src/renderer/register-features.ts @@ -3,7 +3,8 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ +import type { DiContainer } from "@ogre-tools/injectable"; import { action } from "mobx"; -export default action(() => {}); +export default action((di: DiContainer) => {}); diff --git a/yarn.lock b/yarn.lock index c2fccc0195..4a883c34b2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1101,6 +1101,36 @@ resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b" integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A== +"@lensapp/cluster@^0.1.5": + version "0.1.5" + resolved "http://localhost:53093/@lensapp%2fcluster/-/cluster-0.1.5.tgz#81b7a6cb1a32bf0ef5a388cee53bac40077adf51" + integrity sha512-PDM8NBgvugQTOqQEk2/9XRW98Yup9+eqhbAv9mrMetfDnYnadS2UJQXU9uOTo8bZDjgSNCJFyijqWH8KJBXQcw== + +"@lensapp/feature-core@^0.1.6": + version "0.1.6" + resolved "http://localhost:53093/@lensapp%2ffeature-core/-/feature-core-0.1.6.tgz#7f59954c7108c2357a3fccd675707702f0e1e28b" + integrity sha512-c7Iq9E/M0V9uTrJvwHXUWaWJs2ndNML3zzT51+hyTV5oBbKFYlS+82b9jiETVPTGy52r5ttJwLEKfvfVIzadag== + +"@lensapp/fs@^0.2.0": + version "0.2.0" + resolved "http://localhost:53093/@lensapp%2ffs/-/fs-0.2.0.tgz#b22f669d4dd6a20a9365cf7d75262801c6baefba" + integrity sha512-ToQc89BkYDF7Ca4yUl24frYYYfJ3BFRiVpmlvmIpLQvoGe1FbHesq3JcaAmuMMOv2DmxvNdJ/yN/5BBEwkOnPQ== + +"@lensapp/logging@^0.1.5": + version "0.1.5" + resolved "http://localhost:53093/@lensapp%2flogging/-/logging-0.1.5.tgz#51f24447252745f394a0f1230b7473ee3cb13d39" + integrity sha512-CIKEVaYMdwkYbPkJpaNwlgwq76t9XKJqAuSg7UDqzUEd4abnXu/vsojfeNWIRVc5ZlXsegZYBKKQQ4dlivb3/Q== + +"@lensapp/shell@^0.1.6": + version "0.1.6" + resolved "http://localhost:53093/@lensapp%2fshell/-/shell-0.1.6.tgz#574ae450c8e75c16d12a79e1ffcf0ef5733ad7e8" + integrity sha512-BrIvBrrOpAdaGLisI8kjet4ez9eq/b6dkOD5jV1ep+z1wIWjsJv8BDC1obIUQ1jb2V5N1ACofwt3SdlNyNVYMQ== + +"@lensapp/utils@^0.2.4": + version "0.2.4" + resolved "http://localhost:53093/@lensapp%2futils/-/utils-0.2.4.tgz#aab4ad66d0c0d467080b29ed4216a6b81ca27d67" + integrity sha512-vfYiLC98vFhbJD4kDMILebOapqOXaM35mR72MHkBdbP8nYeDej62fC6YW6sAO41G5mJpLELvVQy8Xix9XHxwQQ== + "@malept/cross-spawn-promise@^1.1.0": version "1.1.1" resolved "https://registry.yarnpkg.com/@malept/cross-spawn-promise/-/cross-spawn-promise-1.1.1.tgz#504af200af6b98e198bce768bc1730c6936ae01d" @@ -1409,30 +1439,35 @@ read-package-json-fast "^2.0.3" which "^2.0.2" -"@ogre-tools/fp@^12.0.1": - version "12.0.1" - resolved "https://registry.yarnpkg.com/@ogre-tools/fp/-/fp-12.0.1.tgz#1f932c8c4cc04075f92ab5ca564db158ac1514d4" - integrity sha512-BzMhkI4wPnuI+hXJDbtHUXQn/uBjJLx3W0oDaIFV+lLpkneUU0oW9D5uZFHNOouzCgf67/tnmUC6Ohevbr7/VA== +"@ogre-tools/fp@^14.0.3": + version "14.0.3" + resolved "https://registry.yarnpkg.com/@ogre-tools/fp/-/fp-14.0.3.tgz#e8e1279b6f40685d0f4b1699dfd6e5c81e9f305b" + integrity sha512-6FwUnuw5n4/ICtXTcUadgNJlLJv+iCfUD4UE+8yrVyyXg+LXX3K2GdSxI9sivoA/3xIEoUyPkXcSOAEUIDXWsA== -"@ogre-tools/injectable-extension-for-auto-registration@^12.0.1": - version "12.0.1" - resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-extension-for-auto-registration/-/injectable-extension-for-auto-registration-12.0.1.tgz#878f73b5408b12193664f4920289905eacb4c1cc" - integrity sha512-itKcxEJ/J8SKGD/Wwj0UYOA+/nqwnrwanhikY6qhlibj8guujX77Iip7vMBzJFc2nIrRaQRcpNV2eXe+tjQUdg== +"@ogre-tools/injectable-extension-for-auto-registration@^14.0.3": + version "14.0.3" + resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-extension-for-auto-registration/-/injectable-extension-for-auto-registration-14.0.3.tgz#492c43e01b7d1efcdcb10bd0c844ef636f8b5788" + integrity sha512-2wXDIxO//DOBw+N68JLumrK/3zaryYfS70AFkKCf/FI17qsgkfd2OrMh2TEdXhnGwoPiIelRRGaLYWiFcxl8nw== -"@ogre-tools/injectable-extension-for-mobx@^12.0.1": - version "12.0.1" - resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-extension-for-mobx/-/injectable-extension-for-mobx-12.0.1.tgz#1e9de8caba076d7cebda4177a5ab763594b08b28" - integrity sha512-M1penOpZfO3/rJMb6WN4IL86p9Lx9tOMCipiNkAyitNLGWfeDPG279JlCs9E3Uw8R9nkFPiw8Je2SLnwnM9o+A== +"@ogre-tools/injectable-extension-for-mobx@^14.0.3": + version "14.0.3" + resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-extension-for-mobx/-/injectable-extension-for-mobx-14.0.3.tgz#11f5becc6d5e15e75bbbac31e994501e0f683536" + integrity sha512-VOFXxC4ZH3+WfK5sizjT0SEmnmK48bai6VkKKj1BsHkywpLFaYLQrA4yr6DvvxtWuP8q/Zr7u8rb+JkW68cdyQ== -"@ogre-tools/injectable-react@^12.0.1": - version "12.0.1" - resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-react/-/injectable-react-12.0.1.tgz#07a43f25bd78db37cb2c00bc0c06e0a69394f519" - integrity sha512-LAOh/EHKqk/pQcBRZUAz0VcJwgBeIPxHwlV/Apw0aEBBoMuYLsLZh47rES8sMYMV6N5x7oVfkjMscujY0DCgaQ== +"@ogre-tools/injectable-react@^14.0.3": + version "14.0.3" + resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-react/-/injectable-react-14.0.3.tgz#005679b9b727ee9249cc327272fe933329eda5d9" + integrity sha512-y0c8gb8uO9AUWKILXItE0ZqqMmJcXDh3+2j+fXJT5SDcnV7TIVgYuwXd+mh78i0SaoL74/YiX+HNujne/wnIUA== -"@ogre-tools/injectable@^12.0.1": - version "12.0.1" - resolved "https://registry.yarnpkg.com/@ogre-tools/injectable/-/injectable-12.0.1.tgz#53f9981f7f165da4277857b8338cc4097d357ad2" - integrity sha512-uOx8STN2wSc9hknDSTGqViyR89Vwg7rGacwrVNchgyo48/QJsmZZz6cd1Aw3nT4vr7ekjTc2lh0Rz6zGIv47hg== +"@ogre-tools/injectable@^14.0.3": + version "14.0.3" + resolved "https://registry.yarnpkg.com/@ogre-tools/injectable/-/injectable-14.0.3.tgz#3d2b188fce6d87e8195093d555b34d788a436c5e" + integrity sha512-qytN1CWITWW7qa6a4gWSTgAo1MV2M1nDSh+SX0xDE7w5lvDpKj6cT3zxNbGX4J1s++SdiCsAK7HHuX3IaeBaow== + +"@ogre-tools/mobx-utils@^14.0.3": + version "14.0.3" + resolved "https://registry.yarnpkg.com/@ogre-tools/mobx-utils/-/mobx-utils-14.0.3.tgz#8a83f13c00df18d4bab4489029b3e0b519eb0634" + integrity sha512-7Mwqap03vfgHfxLTy2hRRoMi2uepuUOb+zbGqg6kSK7Mdpwu4UXkMEOgQnEQFsiTPhxvbUBdUPS8Uc6HFlP9NA== "@pmmmwh/react-refresh-webpack-plugin@^0.5.8": version "0.5.8"