mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Use new @k8slens/run-many package in core
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
1dc177f21c
commit
a1f651c287
16
package-lock.json
generated
16
package-lock.json
generated
@ -4685,16 +4685,6 @@
|
||||
"react-dom": "^17 || ^18"
|
||||
}
|
||||
},
|
||||
"node_modules/@ogre-tools/injectable-utils": {
|
||||
"version": "15.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@ogre-tools/injectable-utils/-/injectable-utils-15.1.2.tgz",
|
||||
"integrity": "sha512-2MjkmA2HRFQ6Czz8BWtujosFDgPO6OXnzkbWYvDFYT7W8zLJHmeXzt4mWjw90+vIfwAPOQWOlBP6T4yau9tSug==",
|
||||
"peerDependencies": {
|
||||
"@ogre-tools/fp": "*",
|
||||
"@ogre-tools/injectable": "*",
|
||||
"lodash": "^4.17.21"
|
||||
}
|
||||
},
|
||||
"node_modules/@ogre-tools/test-utils": {
|
||||
"version": "15.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@ogre-tools/test-utils/-/test-utils-15.1.2.tgz",
|
||||
@ -32353,7 +32343,6 @@
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
|
||||
"@ogre-tools/injectable-react": "^15.1.2",
|
||||
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||
"@sentry/electron": "^3.0.8",
|
||||
"@sentry/integrations": "^6.19.3",
|
||||
"@side/jest-runtime": "^1.1.0",
|
||||
@ -32553,6 +32542,7 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/application-for-electron-main": "^6.5.0-alpha.0",
|
||||
"@k8slens/run-many": "^1.0.0",
|
||||
"@k8slens/test-utils": "^1.0.0",
|
||||
"@k8slens/utilities": "^1.0.0",
|
||||
"@types/byline": "^4.2.33",
|
||||
@ -34401,7 +34391,6 @@
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
|
||||
"@ogre-tools/injectable-react": "^15.1.2",
|
||||
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||
"mobx": "^6.8.0",
|
||||
"rimraf": "^4.1.2"
|
||||
},
|
||||
@ -34914,7 +34903,6 @@
|
||||
"@ogre-tools/fp": "^15.1.1",
|
||||
"@ogre-tools/injectable": "^15.1.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.1",
|
||||
"@ogre-tools/injectable-utils": "^15.1.1",
|
||||
"lodash": "^4.17.15"
|
||||
}
|
||||
},
|
||||
@ -34930,7 +34918,6 @@
|
||||
"@ogre-tools/fp": "^15.1.2",
|
||||
"@ogre-tools/injectable": "^15.1.2",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||
"lodash": "^4.17.15"
|
||||
}
|
||||
},
|
||||
@ -34947,7 +34934,6 @@
|
||||
"@k8slens/feature-core": "^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"
|
||||
}
|
||||
},
|
||||
|
||||
@ -135,7 +135,6 @@
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
|
||||
"@ogre-tools/injectable-react": "^15.1.2",
|
||||
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||
"@sentry/electron": "^3.0.8",
|
||||
"@sentry/integrations": "^6.19.3",
|
||||
"@side/jest-runtime": "^1.1.0",
|
||||
@ -332,6 +331,7 @@
|
||||
"peerDependencies": {
|
||||
"@k8slens/application": "^6.5.0-alpha.0",
|
||||
"@k8slens/application-for-electron-main": "^6.5.0-alpha.0",
|
||||
"@k8slens/run-many": "^1.0.0",
|
||||
"@k8slens/test-utils": "^1.0.0",
|
||||
"@k8slens/utilities": "^1.0.0",
|
||||
"@types/byline": "^4.2.33",
|
||||
|
||||
@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||
import { afterWindowIsOpenedInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
||||
import electronAppInjectable from "../electron-app.injectable";
|
||||
import { runManyFor } from "../../../common/runnable/run-many-for";
|
||||
import { runManyFor } from "@k8slens/run-many";
|
||||
|
||||
const setupRunnablesAfterWindowIsOpenedInjectable = getInjectable({
|
||||
id: "setup-runnables-after-window-is-opened",
|
||||
|
||||
@ -8,7 +8,7 @@ import { beforeQuitOfFrontEndInjectionToken, beforeQuitOfBackEndInjectionToken }
|
||||
import electronAppInjectable from "../electron-app.injectable";
|
||||
import isIntegrationTestingInjectable from "../../../common/vars/is-integration-testing.injectable";
|
||||
import autoUpdaterInjectable from "../features/auto-updater.injectable";
|
||||
import { runManySyncFor } from "../../../common/runnable/run-many-sync-for";
|
||||
import { runManySyncFor } from "@k8slens/run-many";
|
||||
|
||||
const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({
|
||||
id: "setup-closing-of-application",
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Runnable, RunnableSync } from "../../../common/runnable/types";
|
||||
import type { Runnable, RunnableSync } from "@k8slens/run-many";
|
||||
|
||||
export const beforeQuitOfFrontEndInjectionToken = getInjectionToken<RunnableSync>({
|
||||
id: "before-quit-of-front-end",
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getMessageChannelListenerInjectable } from "../../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import { rootFrameHasRenderedChannel } from "../../../../common/root-frame/root-frame-rendered-channel";
|
||||
import { runManyFor } from "../../../../common/runnable/run-many-for";
|
||||
import { runManyFor } from "@k8slens/run-many";
|
||||
import { afterRootFrameIsReadyInjectionToken } from "../../runnable-tokens/phases";
|
||||
|
||||
const rootFrameRenderedChannelListenerInjectable = getMessageChannelListenerInjectable({
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Runnable } from "../../common/runnable/types";
|
||||
import type { Runnable } from "@k8slens/run-many";
|
||||
|
||||
// NOTE: these are run before any other token, mostly to set up things that all other runnables need
|
||||
export const beforeFrameStartsFirstInjectionToken = getInjectionToken<Runnable>({
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { runManyFor } from "../../common/runnable/run-many-for";
|
||||
import { runManyFor } from "@k8slens/run-many";
|
||||
import * as tokens from "../before-frame-starts/tokens";
|
||||
import currentlyInClusterFrameInjectable from "../routes/currently-in-cluster-frame.injectable";
|
||||
import {
|
||||
|
||||
@ -206,7 +206,6 @@
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
|
||||
"@ogre-tools/injectable-react": "^15.1.2",
|
||||
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||
"mobx": "^6.8.0",
|
||||
"rimraf": "^4.1.2"
|
||||
},
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
export { applicationFeature } from "./src/feature";
|
||||
|
||||
export { onLoadOfApplicationInjectionToken } from "./src/start-application/timeslots/on-load-of-application-injection-token";
|
||||
export { beforeApplicationIsLoadingInjectionToken } from "./src/start-application/timeslots/before-application-is-loading-injection-token";
|
||||
export { afterApplicationIsLoadedInjectionToken } from "./src/start-application/timeslots/after-application-is-loaded-injection-token";
|
||||
export * from "./src/start-application/time-slots";
|
||||
|
||||
export type { StartApplication } from "./src/start-application/start-application.injectable";
|
||||
export { startApplicationInjectionToken } from "./src/start-application/start-application.injectable";
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
"@ogre-tools/fp": "^15.1.2",
|
||||
"@ogre-tools/injectable": "^15.1.2",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||
"lodash": "^4.17.15"
|
||||
},
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
|
||||
import { runManyFor } from "@ogre-tools/injectable-utils";
|
||||
import { beforeApplicationIsLoadingInjectionToken } from "./timeslots/before-application-is-loading-injection-token";
|
||||
import { onLoadOfApplicationInjectionToken } from "./timeslots/on-load-of-application-injection-token";
|
||||
import { afterApplicationIsLoadedInjectionToken } from "./timeslots/after-application-is-loaded-injection-token";
|
||||
import { runManyFor } from "@k8slens/run-many";
|
||||
import * as timeSlots from "./time-slots";
|
||||
|
||||
export type StartApplication = () => Promise<void>;
|
||||
|
||||
@ -16,22 +14,13 @@ const startApplicationInjectable = getInjectable({
|
||||
|
||||
instantiate: (di): StartApplication => {
|
||||
const runManyAsync = runManyFor(di)
|
||||
|
||||
const beforeApplicationIsLoading = runManyAsync(
|
||||
beforeApplicationIsLoadingInjectionToken
|
||||
);
|
||||
|
||||
const onLoadOfApplication = runManyAsync(onLoadOfApplicationInjectionToken);
|
||||
|
||||
const afterApplicationIsLoaded = runManyAsync(
|
||||
afterApplicationIsLoadedInjectionToken
|
||||
);
|
||||
const beforeApplicationIsLoading = runManyAsync(timeSlots.beforeApplicationIsLoadingInjectionToken);
|
||||
const onLoadOfApplication = runManyAsync(timeSlots.onLoadOfApplicationInjectionToken);
|
||||
const afterApplicationIsLoaded = runManyAsync(timeSlots.afterApplicationIsLoadedInjectionToken);
|
||||
|
||||
return async () => {
|
||||
await beforeApplicationIsLoading();
|
||||
|
||||
await onLoadOfApplication();
|
||||
|
||||
await afterApplicationIsLoaded();
|
||||
};
|
||||
},
|
||||
|
||||
@ -6,10 +6,8 @@ import {
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import { applicationFeature } from "../feature";
|
||||
import { startApplicationInjectionToken } from "./start-application.injectable";
|
||||
import { beforeApplicationIsLoadingInjectionToken } from "./timeslots/before-application-is-loading-injection-token";
|
||||
import * as timeSlots from "./time-slots";
|
||||
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
||||
import { onLoadOfApplicationInjectionToken } from "./timeslots/on-load-of-application-injection-token";
|
||||
import { afterApplicationIsLoadedInjectionToken } from "./timeslots/after-application-is-loaded-injection-token";
|
||||
|
||||
describe("starting-of-application", () => {
|
||||
let di: DiContainer;
|
||||
@ -30,19 +28,19 @@ describe("starting-of-application", () => {
|
||||
const beforeApplicationIsLoadingInjectable = getInjectable({
|
||||
id: "before-application-is-loading",
|
||||
instantiate: () => ({ run: beforeApplicationIsLoadingMock }),
|
||||
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||
injectionToken: timeSlots.beforeApplicationIsLoadingInjectionToken,
|
||||
});
|
||||
|
||||
const onLoadOfApplicationInjectable = getInjectable({
|
||||
id: "on-load-of-application",
|
||||
instantiate: () => ({ run: onLoadOfApplicationMock }),
|
||||
injectionToken: onLoadOfApplicationInjectionToken,
|
||||
injectionToken: timeSlots.onLoadOfApplicationInjectionToken,
|
||||
});
|
||||
|
||||
const afterApplicationIsLoadedInjectable = getInjectable({
|
||||
id: "after-application-is-loaded",
|
||||
instantiate: () => ({ run: afterApplicationIsLoadedMock }),
|
||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||
injectionToken: timeSlots.afterApplicationIsLoadedInjectionToken,
|
||||
});
|
||||
|
||||
di.register(
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Runnable } from "@k8slens/run-many";
|
||||
|
||||
export const beforeApplicationIsLoadingInjectionToken = getInjectionToken<Runnable>({
|
||||
id: "before-application-is-loading-injection-token",
|
||||
});
|
||||
|
||||
export const onLoadOfApplicationInjectionToken = getInjectionToken<Runnable>({
|
||||
id: "on-load-of-application",
|
||||
});
|
||||
|
||||
export const afterApplicationIsLoadedInjectionToken = getInjectionToken<Runnable>({
|
||||
id: "after-application-is-loaded-injection-token",
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Runnable } from "@ogre-tools/injectable-utils";
|
||||
|
||||
export const afterApplicationIsLoadedInjectionToken =
|
||||
getInjectionToken<Runnable>({
|
||||
id: "after-application-is-loaded-injection-token",
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Runnable } from "@ogre-tools/injectable-utils";
|
||||
|
||||
export const beforeApplicationIsLoadingInjectionToken =
|
||||
getInjectionToken<Runnable>({
|
||||
id: "before-application-is-loading-injection-token",
|
||||
});
|
||||
@ -1,6 +0,0 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Runnable } from "@ogre-tools/injectable-utils";
|
||||
|
||||
export const onLoadOfApplicationInjectionToken = getInjectionToken<Runnable>({
|
||||
id: "on-load-of-application",
|
||||
});
|
||||
@ -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"
|
||||
},
|
||||
|
||||
|
||||
@ -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,
|
||||
}),
|
||||
|
||||
|
||||
@ -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",
|
||||
});
|
||||
@ -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",
|
||||
});
|
||||
@ -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",
|
||||
});
|
||||
@ -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";
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -1,2 +1,4 @@
|
||||
export * from "./src/run-many-for";
|
||||
export * from "./src/run-many-sync-for";
|
||||
|
||||
export type { Runnable, RunnableSync, Run, RunSync } from "./src/types";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user