mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Convert runMany and runManySync to use injectManyWithMeta + move to seperate package (#7244)
* Convert runMany and runManySync to use injectManyWithMeta Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup type errors due to new Runnable requirements Signed-off-by: Sebastian Malton <sebastian@malton.name> * Add documentation for verifyRunnablesAreDAG Signed-off-by: Sebastian Malton <sebastian@malton.name> * Simplify convertToWithIdWith Signed-off-by: Sebastian Malton <sebastian@malton.name> * Move all utility functions to separate package Signed-off-by: Sebastian Malton <sebastian@malton.name> * Move testing utilities to separate package Signed-off-by: Sebastian Malton <sebastian@malton.name> * Move run-many and run-many-sync to separate package Signed-off-by: Sebastian Malton <sebastian@malton.name> * Replace all internal uses of utilities with new packages Signed-off-by: Sebastian Malton <sebastian@malton.name> * Use new @k8slens/run-many package in core Signed-off-by: Sebastian Malton <sebastian@malton.name> * Add dep to open-lens Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup type errors Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup uses of @k8slens/test-utils Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup getGlobalOverride Signed-off-by: Sebastian Malton <sebastian@malton.name> * Move tests to new package too Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix type errors Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup uses of AsyncResult and autoBind Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup remaining import issues Signed-off-by: Sebastian Malton <sebastian@malton.name> * Finial fixups to fix build Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix lint Signed-off-by: Sebastian Malton <sebastian@malton.name> * Revert moving "testUsingFakeTime" to separate package - This fixes tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix integration tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix unit test failing due to spelling fix Signed-off-by: Sebastian Malton <sebastian@malton.name> --------- Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
ad9bafe2a5
commit
2789bcebcb
754 files changed
+2715
-2752
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { overrideSideEffectsWithFakes } from "./src/override-side-effects-with-fakes";
|
||||
|
||||
export { beforeElectronIsReadyInjectionToken } from "./src/start-application/timeslots/before-electron-is-ready-injection-token";
|
||||
export { beforeAnythingInjectionToken } from "./src/start-application/timeslots/before-anything-injection-token";
|
||||
export * from "./src/start-application/time-slots";
|
||||
|
||||
export { applicationFeatureForElectronMain } from "./src/feature";
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@ogre-tools/injectable": "^15.1.2",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||
"electron": "^19.1.9"
|
||||
},
|
||||
|
||||
|
||||
+9
-19
@@ -6,32 +6,22 @@ import {
|
||||
} from "@ogre-tools/injectable";
|
||||
import { startApplicationInjectionToken } from "@k8slens/application";
|
||||
import whenAppIsReadyInjectable from "./when-app-is-ready.injectable";
|
||||
import { beforeAnythingInjectionToken } from "./timeslots/before-anything-injection-token";
|
||||
import { beforeElectronIsReadyInjectionToken } from "./timeslots/before-electron-is-ready-injection-token";
|
||||
import { runManySyncFor } from "@ogre-tools/injectable-utils";
|
||||
import { beforeAnythingInjectionToken, beforeElectronIsReadyInjectionToken } from "./time-slots";
|
||||
import { runManySyncFor } from "@k8slens/run-many";
|
||||
|
||||
type ToBeDecorated = (di: DiContainer, ...args: unknown[]) => (...args: unknown[]) => unknown;
|
||||
|
||||
const startElectronApplicationInjectable = getInjectable({
|
||||
id: "start-electron-application",
|
||||
|
||||
instantiate: () => ({
|
||||
decorate:
|
||||
(toBeDecorated: unknown) =>
|
||||
decorate: (toBeDecorated: unknown) => (
|
||||
(di: DiContainer, ...args: unknown[]) => {
|
||||
const whenAppIsReady = di.inject(whenAppIsReadyInjectable);
|
||||
const runManySync = runManySyncFor(di);
|
||||
const beforeAnything = runManySync(beforeAnythingInjectionToken);
|
||||
const beforeElectronIsReady = runManySync(
|
||||
beforeElectronIsReadyInjectionToken
|
||||
);
|
||||
|
||||
const typedToBeDecorated = toBeDecorated as (
|
||||
di: DiContainer,
|
||||
...args: unknown[]
|
||||
) => unknown;
|
||||
|
||||
const startApplication = typedToBeDecorated(di, ...args) as (
|
||||
...args: unknown[]
|
||||
) => unknown;
|
||||
const beforeElectronIsReady = runManySync(beforeElectronIsReadyInjectionToken);
|
||||
const startApplication = (toBeDecorated as ToBeDecorated)(di, ...args);
|
||||
|
||||
return (...startApplicationArgs: unknown[]) => {
|
||||
beforeAnything();
|
||||
@@ -43,8 +33,8 @@ const startElectronApplicationInjectable = getInjectable({
|
||||
return startApplication(...startApplicationArgs);
|
||||
})()
|
||||
};
|
||||
},
|
||||
|
||||
}
|
||||
),
|
||||
target: startApplicationInjectionToken,
|
||||
}),
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { RunnableSync } from "@k8slens/run-many";
|
||||
|
||||
export const beforeAnythingInjectionToken = getInjectionToken<RunnableSync>({
|
||||
id: "before-anything",
|
||||
});
|
||||
|
||||
export const beforeElectronIsReadyInjectionToken = getInjectionToken<RunnableSync>({
|
||||
id: "before-electron-is-ready-injection-token",
|
||||
});
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Runnable } from "@ogre-tools/injectable-utils";
|
||||
|
||||
export const beforeAnythingInjectionToken = getInjectionToken<Runnable>({
|
||||
id: "before-anything",
|
||||
});
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Runnable } from "@ogre-tools/injectable-utils";
|
||||
|
||||
export const beforeElectronIsReadyInjectionToken = getInjectionToken<Runnable>({
|
||||
id: "before-electron-is-ready-injection-token",
|
||||
});
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import { createContainer, DiContainer } from "@ogre-tools/injectable";
|
||||
import { applicationFeatureForElectronMain } from "../../feature";
|
||||
import { applicationFeatureForElectronMain } from "../feature";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import whenAppIsReadyInjectable from "../when-app-is-ready.injectable";
|
||||
import whenAppIsReadyInjectable from "./when-app-is-ready.injectable";
|
||||
import { getPromiseStatus } from "@ogre-tools/test-utils";
|
||||
import electronAppInjectable from "../../electron/electron-app.injectable";
|
||||
import electronAppInjectable from "../electron/electron-app.injectable";
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
import asyncFn from "@async-fn/jest";
|
||||
|
||||
+1
-2
@@ -11,8 +11,7 @@ import {
|
||||
} from "@k8slens/application";
|
||||
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
||||
import whenAppIsReadyInjectable from "./start-application/when-app-is-ready.injectable";
|
||||
import { beforeAnythingInjectionToken } from "./start-application/timeslots/before-anything-injection-token";
|
||||
import { beforeElectronIsReadyInjectionToken } from "./start-application/timeslots/before-electron-is-ready-injection-token";
|
||||
import { beforeAnythingInjectionToken, beforeElectronIsReadyInjectionToken } from "./start-application/time-slots";
|
||||
|
||||
describe("starting-of-electron-main-application", () => {
|
||||
let di: DiContainer;
|
||||
|
||||
Reference in new issue
Block a user