Skip to content

Commit 0f1f030

Browse files
authored
Switch to using messaging and startable stoppable from NPM package (lensapp#7368)
* Add custom jest resolver to fix requiring "uuid" module Signed-off-by: Janne Savolainen <[email protected]> * Update dependencies Signed-off-by: Janne Savolainen <[email protected]> * Introduce test utils for rendering and running with thrown mobx reactions Signed-off-by: Janne Savolainen <[email protected]> * Extract startable-stoppable to NPM package Signed-off-by: Janne Savolainen <[email protected]> * Extract messaging to NPM package Co-authored-by: Mikko Aspiala <[email protected]> Signed-off-by: Janne Savolainen <[email protected]> * Switch to using startable-stoppable from NPM package Signed-off-by: Janne Savolainen <[email protected]> * Switch to using messaging from the Feature Signed-off-by: Janne Savolainen <[email protected]> * Remove old implementation of messaging Signed-off-by: Janne Savolainen <[email protected]> * Make setupping app paths happen earlier in renderer Signed-off-by: Janne Savolainen <[email protected]> * Fix typo Signed-off-by: Janne Savolainen <[email protected]> * Add kludge to make testing-library work properly from test-utils package Signed-off-by: Janne Savolainen <[email protected]> * Fix code style Signed-off-by: Janne Savolainen <[email protected]> * Add lint:fix -root script Signed-off-by: Janne Savolainen <[email protected]> * Fix unrelated failing unit tests Signed-off-by: Janne Savolainen <[email protected]> * Turn of no-floating-promises from typescript linting for being broken Signed-off-by: Janne Savolainen <[email protected]> * Make linting not happen for dist -directories Signed-off-by: Janne Savolainen <[email protected]> * Make linting failures appear as failure Signed-off-by: Janne Savolainen <[email protected]> * Stop running prettier twice It already gets ran as eslint-plugin. Signed-off-by: Janne Savolainen <[email protected]> * Make CI run unit tests for all packages by consolidating name of NPM script Co-authored-by: Mikko Aspiala <[email protected]> Signed-off-by: Janne Savolainen <[email protected]> * Add missing unit tests for coverage Co-authored-by: Mikko Aspiala <[email protected]> Signed-off-by: Janne Savolainen <[email protected]> * Skip coverage for test utils Co-authored-by: Mikko Aspiala <[email protected]> Signed-off-by: Janne Savolainen <[email protected]> * Remove check for coverage in packages which are not ready for it Signed-off-by: Janne Savolainen <[email protected]> * Stop collecting coverage from index.ts files them being indirections to the implementation Co-authored-by: Mikko Aspiala <[email protected]> Signed-off-by: Janne Savolainen <[email protected]> * Implement sending message to channel in main Signed-off-by: Janne Savolainen <[email protected]> * Add missing feature dependencies Signed-off-by: Janne Savolainen <[email protected]> * Add dummy implementations for requesting in main from renderer Signed-off-by: Janne Savolainen <[email protected]> * Re-enable communicating from main to cluster frames Signed-off-by: Janne Savolainen <[email protected]> * Ignore trivial files from coverage Signed-off-by: Janne Savolainen <[email protected]> * Update package-lock Signed-off-by: Janne Savolainen <[email protected]> * Extract message-bridge to separate NPM package to prevent dev dependencies being in the production bundle Signed-off-by: Janne Savolainen <[email protected]> * Extract computed channel to own NPM package for clear dependencies Signed-off-by: Janne Savolainen <[email protected]> * Consolidate electron related stuff to a directory Signed-off-by: Janne Savolainen <[email protected]> * Add missing publish configurations Signed-off-by: Janne Savolainen <[email protected]> * Ignore test implementation from coverage being not interesting Signed-off-by: Janne Savolainen <[email protected]> --------- Signed-off-by: Janne Savolainen <[email protected]>
1 parent df49ff9 commit 0f1f030

File tree

261 files changed

+4447
-1795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+4447
-1795
lines changed

package-lock.json

+763-437
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"clean:node_modules": "lerna clean -y && rimraf node_modules",
2020
"dev": "lerna run dev --stream --skip-nx-cache",
2121
"lint": "lerna run lint --stream",
22+
"lint:fix": "lerna run lint:fix --stream",
2223
"mkdocs:serve-local": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -it -p 8000:8000 -v ${PWD}:/docs mkdocs-serve-local:latest",
2324
"mkdocs:verify": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -v ${PWD}:/docs mkdocs-serve-local:latest build --strict",
2425
"test:unit": "lerna run --stream test:unit",

packages/core/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
},
190190
"devDependencies": {
191191
"@async-fn/jest": "1.6.4",
192+
"@k8slens/messaging-fake-bridge": "^1.0.0-alpha.1",
192193
"@material-ui/core": "^4.12.3",
193194
"@material-ui/icons": "^4.11.2",
194195
"@material-ui/lab": "^4.0.0-alpha.60",
@@ -322,7 +323,11 @@
322323
"@k8slens/application": "^6.5.0-alpha.0",
323324
"@k8slens/application-for-electron-main": "^6.5.0-alpha.0",
324325
"@k8slens/legacy-extensions": "^1.0.0-alpha.0",
326+
"@k8slens/messaging": "^1.0.0-alpha.1",
327+
"@k8slens/messaging-for-main": "^1.0.0-alpha.1",
328+
"@k8slens/messaging-for-renderer": "^1.0.0-alpha.1",
325329
"@k8slens/run-many": "^1.0.0-alpha.1",
330+
"@k8slens/startable-stoppable": "^1.0.0-alpha.1",
326331
"@k8slens/test-utils": "^1.0.0-alpha.1",
327332
"@k8slens/utilities": "^1.0.0-alpha.1",
328333
"@types/byline": "^4.2.33",

packages/core/src/common/app-paths/app-paths-channel.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
* Licensed under MIT License. See LICENSE in root directory for more information.
44
*/
55
import type { AppPaths } from "./app-path-injection-token";
6-
import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token";
6+
import { getRequestChannel } from "@k8slens/messaging";
77

8-
export type AppPathsChannel = RequestChannel<void, AppPaths>;
9-
10-
export const appPathsChannel: AppPathsChannel = {
11-
id: "app-paths",
12-
};
8+
export const appPathsChannel = getRequestChannel<void, AppPaths>("app-paths");
139

packages/core/src/common/base-store/base-store.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type { GetConfigurationFileModel } from "../get-configuration-file-model/
1515
import type { Logger } from "../logger";
1616
import type { PersistStateToConfig } from "./save-to-file";
1717
import type { GetBasenameOfPath } from "../path/get-basename.injectable";
18-
import type { EnlistMessageChannelListener } from "../utils/channel/enlist-message-channel-listener-injection-token";
18+
import type { EnlistMessageChannelListener } from "@k8slens/messaging";
1919
import { toJS } from "../utils";
2020

2121
export interface BaseStoreParams<T> extends Omit<ConfOptions<T>, "migrations"> {
@@ -108,6 +108,7 @@ export abstract class BaseStore<T extends object> {
108108
this.params.syncOptions,
109109
),
110110
this.dependencies.enlistMessageChannelListener({
111+
id: this.displayName,
111112
channel: {
112113
id: `${this.dependencies.ipcChannelPrefixes.local}:${config.path}`,
113114
},

packages/core/src/common/certificate/lens-proxy-certificate-channel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
*/
55

66
import type { SelfSignedCert } from "selfsigned";
7-
import { getRequestChannel } from "../utils/channel/get-request-channel";
7+
import { getRequestChannel } from "@k8slens/messaging";
88

99
export const lensProxyCertificateChannel = getRequestChannel<void, SelfSignedCert>("request-lens-proxy-certificate");

packages/core/src/common/cluster-store/cluster-store.injectable.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { baseStoreIpcChannelPrefixesInjectionToken } from "../base-store/channel
1616
import { shouldBaseStoreDisableSyncInIpcListenerInjectionToken } from "../base-store/disable-sync";
1717
import { persistStateToConfigInjectionToken } from "../base-store/save-to-file";
1818
import getBasenameOfPathInjectable from "../path/get-basename.injectable";
19-
import { enlistMessageChannelListenerInjectionToken } from "../utils/channel/enlist-message-channel-listener-injection-token";
19+
import { enlistMessageChannelListenerInjectionToken } from "@k8slens/messaging";
2020

2121
const clusterStoreInjectable = getInjectable({
2222
id: "cluster-store",

packages/core/src/common/cluster/current-cluster-channel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import type { ClusterId } from "../cluster-types";
7-
import type { MessageChannel } from "../utils/channel/message-channel-listener-injection-token";
7+
import type { MessageChannel } from "@k8slens/messaging";
88

99
export const currentClusterMessageChannel: MessageChannel<ClusterId> = {
1010
id: "current-visible-cluster",

packages/core/src/common/cluster/visibility-channel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import type { ClusterId } from "../cluster-types";
7-
import type { MessageChannel } from "../utils/channel/message-channel-listener-injection-token";
7+
import type { MessageChannel } from "@k8slens/messaging";
88

99
export const clusterVisibilityChannel: MessageChannel<ClusterId | null> = {
1010
id: "cluster-visibility",

packages/core/src/common/front-end-routing/app-navigation-channel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under MIT License. See LICENSE in root directory for more information.
44
*/
55
import { IpcRendererNavigationEvents } from "../ipc/navigation-events";
6-
import type { MessageChannel } from "../utils/channel/message-channel-listener-injection-token";
6+
import type { MessageChannel } from "@k8slens/messaging";
77

88
export type AppNavigationChannel = MessageChannel<string>;
99

packages/core/src/common/front-end-routing/cluster-frame-navigation-channel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under MIT License. See LICENSE in root directory for more information.
44
*/
55
import { IpcRendererNavigationEvents } from "../ipc/navigation-events";
6-
import type { MessageChannel } from "../utils/channel/message-channel-listener-injection-token";
6+
import type { MessageChannel } from "@k8slens/messaging";
77

88
export type ClusterFrameNavigationChannel = MessageChannel<string>;
99

packages/core/src/common/helm/add-helm-repository-channel.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
* Licensed under MIT License. See LICENSE in root directory for more information.
44
*/
55
import type { HelmRepo } from "./helm-repo";
6-
import type { AsyncResult } from "@k8slens/utilities";
7-
import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token";
6+
import type { Result } from "@k8slens/utilities";
7+
import { getRequestChannel } from "@k8slens/messaging";
88

9-
export type AddHelmRepositoryChannel = RequestChannel<HelmRepo, AsyncResult<void, string>>;
10-
11-
export const addHelmRepositoryChannel: AddHelmRepositoryChannel = {
12-
id: "add-helm-repository-channel",
13-
};
9+
export const addHelmRepositoryChannel = getRequestChannel<
10+
HelmRepo,
11+
Result<void, string>
12+
>("add-helm-repository-channel");

packages/core/src/common/helm/get-active-helm-repositories-channel.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
*/
55
import type { HelmRepo } from "./helm-repo";
66
import type { AsyncResult } from "@k8slens/utilities";
7-
import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token";
7+
import { getRequestChannel } from "@k8slens/messaging";
88

9-
export type GetActiveHelmRepositoriesChannel = RequestChannel<void, AsyncResult<HelmRepo[]>>;
10-
11-
export const getActiveHelmRepositoriesChannel: GetActiveHelmRepositoriesChannel = {
12-
id: "get-helm-active-list-repositories",
13-
};
9+
export const getActiveHelmRepositoriesChannel = getRequestChannel<
10+
void,
11+
AsyncResult<HelmRepo[]>
12+
>("get-helm-active-list-repositories");

packages/core/src/common/helm/remove-helm-repository-channel.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
* Licensed under MIT License. See LICENSE in root directory for more information.
44
*/
55
import type { AsyncResult } from "@k8slens/utilities";
6-
import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token";
6+
import { getRequestChannel } from "@k8slens/messaging";
77
import type { HelmRepo } from "./helm-repo";
88

9-
export type RemoveHelmRepositoryChannel = RequestChannel<HelmRepo, AsyncResult<void, string>>;
10-
11-
export const removeHelmRepositoryChannel: RemoveHelmRepositoryChannel = {
12-
id: "remove-helm-repository-channel",
13-
};
9+
export const removeHelmRepositoryChannel = getRequestChannel<
10+
HelmRepo,
11+
AsyncResult<void, string>
12+
>("remove-helm-repository-channel");

packages/core/src/common/hotbars/store.injectable.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { hotbarStoreMigrationInjectionToken } from "./migrations-token";
1414
import getBasenameOfPathInjectable from "../path/get-basename.injectable";
1515
import { baseStoreIpcChannelPrefixesInjectionToken } from "../base-store/channel-prefix";
1616
import { persistStateToConfigInjectionToken } from "../base-store/save-to-file";
17-
import { enlistMessageChannelListenerInjectionToken } from "../utils/channel/enlist-message-channel-listener-injection-token";
17+
import { enlistMessageChannelListenerInjectionToken } from "@k8slens/messaging";
1818
import { shouldBaseStoreDisableSyncInIpcListenerInjectionToken } from "../base-store/disable-sync";
1919

2020
const hotbarStoreInjectable = getInjectable({

packages/core/src/common/kube-helpers/channels.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@
44
*/
55

66
import { getInjectionToken } from "@ogre-tools/injectable";
7-
import type { Asyncify } from "type-fest";
8-
import type { RequestChannelHandler } from "../../main/utils/channel/channel-listeners/listener-tokens";
97
import type { ClusterId } from "../cluster-types";
10-
import type { AsyncResult } from "@k8slens/utilities";
11-
import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token";
8+
import type { AsyncResult, Result } from "@k8slens/utilities";
9+
import { getRequestChannel } from "@k8slens/messaging";
1210

1311
export interface KubectlApplyAllArgs {
1412
clusterId: ClusterId;
1513
resources: string[];
1614
extraArgs: string[];
1715
}
1816

19-
export const kubectlApplyAllChannel: RequestChannel<KubectlApplyAllArgs, AsyncResult<string, string>> = {
20-
id: "kubectl-apply-all",
21-
};
17+
export const kubectlApplyAllChannel = getRequestChannel<
18+
KubectlApplyAllArgs,
19+
Result<string, string>
20+
>("kubectl-apply-all");
2221

23-
export type KubectlApplyAll = Asyncify<RequestChannelHandler<typeof kubectlApplyAllChannel>>;
22+
export type KubectlApplyAll = (req: KubectlApplyAllArgs) => AsyncResult<string, string>;
2423

2524
export const kubectlApplyAllInjectionToken = getInjectionToken<KubectlApplyAll>({
2625
id: "kubectl-apply-all",
@@ -32,11 +31,12 @@ export interface KubectlDeleteAllArgs {
3231
extraArgs: string[];
3332
}
3433

35-
export const kubectlDeleteAllChannel: RequestChannel<KubectlDeleteAllArgs, AsyncResult<string, string>> = {
36-
id: "kubectl-delete-all",
37-
};
34+
export const kubectlDeleteAllChannel = getRequestChannel<
35+
KubectlDeleteAllArgs,
36+
Result<string, string>
37+
>("kubectl-delete-all");
3838

39-
export type KubectlDeleteAll = Asyncify<RequestChannelHandler<typeof kubectlDeleteAllChannel>>;
39+
export type KubectlDeleteAll = (req: KubectlDeleteAllArgs) => AsyncResult<string, string>;
4040

4141
export const kubectlDeleteAllInjectionToken = getInjectionToken<KubectlDeleteAll>({
4242
id: "kubectl-delete-all",

packages/core/src/common/root-frame/root-frame-rendered-channel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) OpenLens Authors. All rights reserved.
33
* Licensed under MIT License. See LICENSE in root directory for more information.
44
*/
5-
import type { MessageChannel } from "../utils/channel/message-channel-listener-injection-token";
5+
import type { MessageChannel } from "@k8slens/messaging";
66

77
export type RootFrameHasRenderedChannel = MessageChannel<void>;
88

packages/core/src/common/user-store/user-store.injectable.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { baseStoreIpcChannelPrefixesInjectionToken } from "../base-store/channel
1616
import { shouldBaseStoreDisableSyncInIpcListenerInjectionToken } from "../base-store/disable-sync";
1717
import { persistStateToConfigInjectionToken } from "../base-store/save-to-file";
1818
import getBasenameOfPathInjectable from "../path/get-basename.injectable";
19-
import { enlistMessageChannelListenerInjectionToken } from "../utils/channel/enlist-message-channel-listener-injection-token";
19+
import { enlistMessageChannelListenerInjectionToken } from "@k8slens/messaging";
2020
import userStorePreferenceDescriptorsInjectable from "./preference-descriptors.injectable";
2121

2222
const userStoreInjectable = getInjectable({

0 commit comments

Comments
 (0)