mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'master' into remove-duplicate-runnable-ids-rebased
# Conflicts: # package-lock.json # packages/core/package.json # packages/core/src/features/application-menu/main/start-application-menu.injectable.ts # packages/core/src/features/application-update/child-features/periodical-checking-of-updates/main/start-checking-for-updates.injectable.ts # packages/core/src/features/application-update/main/emit-current-version-to-analytics.injectable.ts # packages/core/src/features/application-update/main/watch-if-update-should-happen-on-quit/start-watching-if-update-should-happen-on-quit.injectable.ts # packages/core/src/features/cluster/state-sync/main/setup-sync.injectable.ts # packages/core/src/features/cluster/store/main/init.injectable.ts # packages/core/src/features/file-system-provisioner/main/init-store.injectable.ts # packages/core/src/features/hotbar/store/main/init.injectable.ts # packages/core/src/features/shell-sync/main/setup-shell.injectable.ts # packages/core/src/features/theme/system-type/main/setup-update-emitter.injectable.ts # packages/core/src/main/cluster/initialize-manager.injectable.ts # packages/core/src/main/electron-app/runnables/enforce-single-application-instance.injectable.ts # packages/core/src/main/electron-app/runnables/setup-application-name.injectable.ts # packages/core/src/main/electron-app/runnables/setup-deep-linking.injectable.ts # packages/core/src/main/electron-app/runnables/setup-developer-tools-in-development-environment.injectable.ts # packages/core/src/main/electron-app/runnables/setup-device-shutdown.injectable.ts # packages/core/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.injectable.ts # packages/core/src/main/electron-app/runnables/setup-main-window-visibility-after-activation.injectable.ts # packages/core/src/main/electron-app/runnables/setup-runnables-after-window-is-opened.injectable.ts # packages/core/src/main/electron-app/runnables/setup-runnables-before-closing-of-application.injectable.ts # packages/core/src/main/library.ts # packages/core/src/main/start-main-application/runnable-tokens/phases.ts # packages/core/src/main/start-main-application/runnables/emit-service-start-to-event-bus.injectable.ts # packages/core/src/main/start-main-application/runnables/initialize-extensions.injectable.ts # packages/core/src/main/start-main-application/runnables/kube-config-sync/add-source.injectable.ts # packages/core/src/main/start-main-application/runnables/kube-config-sync/start-kube-config-sync.injectable.ts # packages/core/src/main/start-main-application/runnables/sentry/setup.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-hardware-acceleration.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-hostnames.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-immer.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-lens-proxy-certificate.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-mobx.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-proxy-env.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-syncing-of-weblinks.injectable.ts # packages/core/src/main/start-main-application/runnables/setup-system-ca.injectable.ts # packages/core/src/main/start-main-application/runnables/show-initial-window.injectable.ts # packages/core/src/main/start-main-application/runnables/show-loading.injectable.ts # packages/core/src/main/start-main-application/start-main-application.injectable.ts # packages/core/src/main/stores/init-user-store.injectable.ts # packages/core/src/main/theme/sync-theme-from-os/start-syncing-theme-from-operating-system.injectable.ts # packages/core/src/main/tray/electron-tray/start-tray.injectable.ts # packages/core/src/main/tray/menu-icon/start-reactivity.injectable.ts # packages/core/src/main/tray/reactive-tray-menu-items/start-reactive-tray-menu-items.injectable.ts # packages/core/src/main/user-store/sync-open-at-login-with-os.injectable.ts # packages/core/src/main/utils/channel/channel-listeners/start-listening-on-channels.injectable.ts # packages/core/src/main/vars/build-version/init.injectable.ts # packages/core/src/main/vars/default-update-channel/init.injectable.ts # packages/core/src/main/vars/release-channel/init.injectable.ts # packages/core/src/main/vars/semantic-build-version/init.injectable.ts # packages/core/src/renderer/components/test-utils/get-application-builder.tsx # packages/core/src/renderer/getDiForUnitTesting.tsx # packages/open-lens/package.json
This commit is contained in:
commit
c6861b6f6e
@ -11,9 +11,12 @@ All releases will be made by creating a PR which bumps the version field in the
|
|||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
1. If you are making a minor or major release (or prereleases for one) make sure you are on the `master` branch.
|
1. If you are making a minor or major release (or prereleases of one) make sure you are on the `master` branch.
|
||||||
1. If you are making a patch release (or a prerelease for one) make sure you are on the `release/v<MAJOR>.<MINOR>` branch.
|
1. If you are making a patch release (or a prerelease for one) make sure you are on the `release/v<MAJOR>.<MINOR>` branch.
|
||||||
1. Run `npm run create-release-pr <release-type>`. If you are making a subsequent prerelease release, provide the `--check-commits` flag.
|
1. Run `npm run create-release-pr`.
|
||||||
1. If you are checking the commits, type `y<ENTER>` to pick a commit, and `n<ENTER>` to skip it. You will want to skip the commits that were part of previous prerelease releases.
|
1. Pick the PRs that you want to include in this release using the keys listed.
|
||||||
1. Once the PR is created, approved, and then merged the `Release Open Lens` workflow will create a tag and release for you.
|
1. Once the PR is created, approved, and then merged the `Release Open Lens` workflow will create a tag and release for you.
|
||||||
1. If you are making a major or minor release, create a `release/v<MAJOR>.<MINOR>` branch and push it to `origin` so that future patch releases can be made from it.
|
1. If you are making a major or minor release, create a `release/v<MAJOR>.<MINOR>` branch and push it to `origin` so that future patch releases can be made from it.
|
||||||
|
1. If you released a major or minor version, create a new patch milestone and move all bug issues to that milestone and all enhancement issues to the next minor milestone.
|
||||||
|
1. If you released a patch version, create a new patch milestone for the next patch version and move all the issues and PRs (open or closed) that weren't included in the current release to that milestone.
|
||||||
|
1. Close the milestone related to the release that was just made (if not a prerelease release).
|
||||||
|
|||||||
@ -32,6 +32,6 @@
|
|||||||
"adr": "^1.4.3",
|
"adr": "^1.4.3",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"lerna": "^6.5.1",
|
"lerna": "^6.5.1",
|
||||||
"rimraf": "^4.1.3"
|
"rimraf": "^4.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@swc/cli": "^0.1.61",
|
"@swc/cli": "^0.1.61",
|
||||||
"@swc/core": "^1.3.35",
|
"@swc/core": "^1.3.37",
|
||||||
"@types/node": "^16.18.11",
|
"@types/node": "^16.18.11",
|
||||||
"@types/semver": "^7.3.13",
|
"@types/semver": "^7.3.13",
|
||||||
"rimraf": "^4.1.2"
|
"rimraf": "^4.1.2"
|
||||||
|
|||||||
@ -130,11 +130,12 @@
|
|||||||
"@k8slens/node-fetch": "^6.5.0-alpha.0",
|
"@k8slens/node-fetch": "^6.5.0-alpha.0",
|
||||||
"@kubernetes/client-node": "^0.18.1",
|
"@kubernetes/client-node": "^0.18.1",
|
||||||
"@material-ui/styles": "^4.11.5",
|
"@material-ui/styles": "^4.11.5",
|
||||||
"@ogre-tools/fp": "^15.1.1",
|
"@ogre-tools/fp": "^15.1.2",
|
||||||
"@ogre-tools/injectable": "^15.1.1",
|
"@ogre-tools/injectable": "^15.1.2",
|
||||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.1",
|
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||||
"@ogre-tools/injectable-extension-for-mobx": "^15.1.1",
|
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
|
||||||
"@ogre-tools/injectable-react": "^15.1.1",
|
"@ogre-tools/injectable-react": "^15.1.2",
|
||||||
|
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||||
"@sentry/electron": "^3.0.8",
|
"@sentry/electron": "^3.0.8",
|
||||||
"@sentry/integrations": "^6.19.3",
|
"@sentry/integrations": "^6.19.3",
|
||||||
"@side/jest-runtime": "^1.1.0",
|
"@side/jest-runtime": "^1.1.0",
|
||||||
@ -202,7 +203,7 @@
|
|||||||
"@material-ui/lab": "^4.0.0-alpha.60",
|
"@material-ui/lab": "^4.0.0-alpha.60",
|
||||||
"@sentry/types": "^6.19.7",
|
"@sentry/types": "^6.19.7",
|
||||||
"@swc/cli": "^0.1.61",
|
"@swc/cli": "^0.1.61",
|
||||||
"@swc/core": "^1.3.35",
|
"@swc/core": "^1.3.37",
|
||||||
"@swc/jest": "^0.2.24",
|
"@swc/jest": "^0.2.24",
|
||||||
"@testing-library/dom": "^7.31.2",
|
"@testing-library/dom": "^7.31.2",
|
||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
@ -330,6 +331,7 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@k8slens/application": "^6.5.0-alpha.0",
|
"@k8slens/application": "^6.5.0-alpha.0",
|
||||||
|
"@k8slens/application-for-electron-main": "^6.5.0-alpha.0",
|
||||||
"@k8slens/run-many": "^1.0.0",
|
"@k8slens/run-many": "^1.0.0",
|
||||||
"@k8slens/test-utils": "^1.0.0",
|
"@k8slens/test-utils": "^1.0.0",
|
||||||
"@k8slens/utilities": "^1.0.0",
|
"@k8slens/utilities": "^1.0.0",
|
||||||
|
|||||||
@ -700,6 +700,11 @@ export class Cluster implements ClusterModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shouldShowResource(resource: KubeApiResourceDescriptor): boolean {
|
shouldShowResource(resource: KubeApiResourceDescriptor): boolean {
|
||||||
|
if (this.allowedResources.size === 0) {
|
||||||
|
// better to show than hide everything
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return this.allowedResources.has(formatKubeApiResource(resource));
|
return this.allowedResources.has(formatKubeApiResource(resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type { DiContainerForInjection } from "@ogre-tools/injectable";
|
|
||||||
|
|
||||||
export interface ApplicationConfig {
|
|
||||||
mode: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Application {
|
|
||||||
start: () => Promise<void>;
|
|
||||||
readonly di: DiContainerForInjection;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CreateApplication = (config: ApplicationConfig) => Application;
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import nodeEnvInjectionToken from "./node-env-injection-token";
|
import { nodeEnvInjectionToken } from "./node-env-injection-token";
|
||||||
|
|
||||||
const isProductionInjectable = getInjectable({
|
const isProductionInjectable = getInjectable({
|
||||||
id: "is-production",
|
id: "is-production",
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
|
|
||||||
const nodeEnvInjectionToken = getInjectionToken<string | undefined>({
|
export const nodeEnvInjectionToken = getInjectionToken<string | undefined>({
|
||||||
id: "node-env-injection-token",
|
id: "node-env-injection-token",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import nodeEnvInjectionToken from "./node-env-injection-token";
|
import { nodeEnvInjectionToken } from "./node-env-injection-token";
|
||||||
|
|
||||||
const nodeEnvFakeInjectable = getInjectable({
|
const nodeEnvFakeInjectable = getInjectable({
|
||||||
id: "node-env-fake",
|
id: "node-env-fake",
|
||||||
|
|||||||
@ -4,18 +4,20 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import applicationMenuReactivityInjectable from "./application-menu-reactivity.injectable";
|
import applicationMenuReactivityInjectable from "./application-menu-reactivity.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const startApplicationMenuInjectable = getInjectable({
|
const startApplicationMenuInjectable = getInjectable({
|
||||||
id: "start-application-menu",
|
id: "start-application-menu",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const applicationMenu = di.inject(applicationMenuReactivityInjectable);
|
const applicationMenu = di.inject(applicationMenuReactivityInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
applicationMenu.start();
|
applicationMenu.start();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,21 +5,23 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import periodicalCheckForUpdatesInjectable from "./periodical-check-for-updates.injectable";
|
import periodicalCheckForUpdatesInjectable from "./periodical-check-for-updates.injectable";
|
||||||
import updatingIsEnabledInjectable from "../../../main/updating-is-enabled/updating-is-enabled.injectable";
|
import updatingIsEnabledInjectable from "../../../main/updating-is-enabled/updating-is-enabled.injectable";
|
||||||
import { afterApplicationIsLoadedInjectionToken } from "../../../../../main/start-main-application/runnable-tokens/phases";
|
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const startCheckingForUpdatesInjectable = getInjectable({
|
const startCheckingForUpdatesInjectable = getInjectable({
|
||||||
id: "start-checking-for-updates",
|
id: "start-checking-for-updates",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable);
|
const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable);
|
||||||
const updatingIsEnabled = di.inject(updatingIsEnabledInjectable);
|
const updatingIsEnabled = di.inject(updatingIsEnabledInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
if (updatingIsEnabled && !periodicalCheckForUpdates.started) {
|
if (updatingIsEnabled && !periodicalCheckForUpdates.started) {
|
||||||
periodicalCheckForUpdates.start();
|
periodicalCheckForUpdates.start();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { afterApplicationIsLoadedInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases";
|
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
|
||||||
import emitAppEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
|
import emitAppEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
|
||||||
import { getCurrentDateTime } from "../../../common/utils/date/get-current-date-time";
|
import { getCurrentDateTime } from "../../../common/utils/date/get-current-date-time";
|
||||||
import buildVersionInjectable from "../../../main/vars/build-version/build-version.injectable";
|
import buildVersionInjectable from "../../../main/vars/build-version/build-version.injectable";
|
||||||
@ -11,11 +11,12 @@ import buildVersionInjectable from "../../../main/vars/build-version/build-versi
|
|||||||
const emitCurrentVersionToAnalyticsInjectable = getInjectable({
|
const emitCurrentVersionToAnalyticsInjectable = getInjectable({
|
||||||
id: "emit-current-version-to-analytics",
|
id: "emit-current-version-to-analytics",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const emitAppEvent = di.inject(emitAppEventInjectable);
|
const emitAppEvent = di.inject(emitAppEventInjectable);
|
||||||
const buildVersion = di.inject(buildVersionInjectable);
|
const buildVersion = di.inject(buildVersionInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
emitAppEvent({
|
emitAppEvent({
|
||||||
name: "app",
|
name: "app",
|
||||||
action: "current-version",
|
action: "current-version",
|
||||||
@ -26,7 +27,8 @@ const emitCurrentVersionToAnalyticsInjectable = getInjectable({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,19 +3,21 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import watchIfUpdateShouldHappenOnQuitInjectable from "./watch-if-update-should-happen-on-quit.injectable";
|
import watchIfUpdateShouldHappenOnQuitInjectable from "./watch-if-update-should-happen-on-quit.injectable";
|
||||||
|
|
||||||
const startWatchingIfUpdateShouldHappenOnQuitInjectable = getInjectable({
|
const startWatchingIfUpdateShouldHappenOnQuitInjectable = getInjectable({
|
||||||
id: "start-watching-if-update-should-happen-on-quit",
|
id: "start-watching-if-update-should-happen-on-quit",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable);
|
const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
watchIfUpdateShouldHappenOnQuit.start();
|
watchIfUpdateShouldHappenOnQuit.start();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { isEqual } from "lodash";
|
|||||||
import { autorun } from "mobx";
|
import { autorun } from "mobx";
|
||||||
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable";
|
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable";
|
||||||
import type { ClusterId, ClusterState } from "../../../../common/cluster-types";
|
import type { ClusterId, ClusterState } from "../../../../common/cluster-types";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import initClusterStoreInjectable from "../../store/main/init.injectable";
|
import initClusterStoreInjectable from "../../store/main/init.injectable";
|
||||||
import emitClusterStateUpdateInjectable from "./emit-update.injectable";
|
import emitClusterStateUpdateInjectable from "./emit-update.injectable";
|
||||||
|
|
||||||
|
|||||||
@ -4,19 +4,21 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable";
|
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import initUserStoreInjectable from "../../../../main/stores/init-user-store.injectable";
|
import initUserStoreInjectable from "../../../../main/stores/init-user-store.injectable";
|
||||||
|
|
||||||
const initClusterStoreInjectable = getInjectable({
|
const initClusterStoreInjectable = getInjectable({
|
||||||
id: "init-cluster-store",
|
id: "init-cluster-store",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const clusterStore = di.inject(clusterStoreInjectable);
|
const clusterStore = di.inject(clusterStoreInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
clusterStore.load();
|
clusterStore.load();
|
||||||
},
|
},
|
||||||
runAfter: initUserStoreInjectable,
|
runAfter: initUserStoreInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import fileSystemProvisionerStoreInjectable from "../../../extensions/extension-loader/file-system-provisioner-store/file-system-provisioner-store.injectable";
|
import fileSystemProvisionerStoreInjectable from "../../../extensions/extension-loader/file-system-provisioner-store/file-system-provisioner-store.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const initFileSystemProvisionerStoreInjectable = getInjectable({
|
const initFileSystemProvisionerStoreInjectable = getInjectable({
|
||||||
id: "init-file-system-provisioner-store",
|
id: "init-file-system-provisioner-store",
|
||||||
|
|||||||
@ -4,19 +4,21 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import hotbarStoreInjectable from "../../../../common/hotbars/store.injectable";
|
import hotbarStoreInjectable from "../../../../common/hotbars/store.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import setupSyncingOfGeneralCatalogEntitiesInjectable from "../../../../main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable";
|
import setupSyncingOfGeneralCatalogEntitiesInjectable from "../../../../main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable";
|
||||||
|
|
||||||
const initHotbarStoreInjectable = getInjectable({
|
const initHotbarStoreInjectable = getInjectable({
|
||||||
id: "init-hotbar-store",
|
id: "init-hotbar-store",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const hotbarStore = di.inject(hotbarStoreInjectable);
|
const hotbarStore = di.inject(hotbarStoreInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
hotbarStore.load();
|
hotbarStore.load();
|
||||||
},
|
},
|
||||||
runAfter: setupSyncingOfGeneralCatalogEntitiesInjectable,
|
runAfter: setupSyncingOfGeneralCatalogEntitiesInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import loggerInjectable from "../../../common/logger.injectable";
|
import loggerInjectable from "../../../common/logger.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import isSnapPackageInjectable from "../../../common/vars/is-snap-package.injectable";
|
import isSnapPackageInjectable from "../../../common/vars/is-snap-package.injectable";
|
||||||
import electronAppInjectable from "../../../main/electron-app/electron-app.injectable";
|
import electronAppInjectable from "../../../main/electron-app/electron-app.injectable";
|
||||||
import computeShellEnvironmentInjectable from "./compute-shell-environment.injectable";
|
import computeShellEnvironmentInjectable from "./compute-shell-environment.injectable";
|
||||||
@ -15,8 +15,7 @@ import { unionPATHs } from "@k8slens/utilities";
|
|||||||
const setupShellInjectable = getInjectable({
|
const setupShellInjectable = getInjectable({
|
||||||
id: "setup-shell",
|
id: "setup-shell",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const isSnapPackage = di.inject(isSnapPackageInjectable);
|
const isSnapPackage = di.inject(isSnapPackageInjectable);
|
||||||
const electronApp = di.inject(electronAppInjectable);
|
const electronApp = di.inject(electronAppInjectable);
|
||||||
@ -24,6 +23,8 @@ const setupShellInjectable = getInjectable({
|
|||||||
const computeShellEnvironment = di.inject(computeShellEnvironmentInjectable);
|
const computeShellEnvironment = di.inject(computeShellEnvironmentInjectable);
|
||||||
const emitShellSyncFailed = di.inject(emitShellSyncFailedInjectable);
|
const emitShellSyncFailed = di.inject(emitShellSyncFailedInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async (): Promise<void> => {
|
||||||
logger.info("🐚 Syncing shell environment");
|
logger.info("🐚 Syncing shell environment");
|
||||||
|
|
||||||
const result = await computeShellEnvironment(resolvedUserShellSetting.get());
|
const result = await computeShellEnvironment(resolvedUserShellSetting.get());
|
||||||
@ -64,7 +65,8 @@ const setupShellInjectable = getInjectable({
|
|||||||
logger.info(`[SHELL-SYNC]: Synced shell env`);
|
logger.info(`[SHELL-SYNC]: Synced shell env`);
|
||||||
logger.debug(`[SHELL-SYNC]: updated env`, process.env);
|
logger.debug(`[SHELL-SYNC]: updated env`, process.env);
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,17 +4,18 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import operatingSystemThemeInjectable from "../../../../main/theme/operating-system-theme.injectable";
|
import operatingSystemThemeInjectable from "../../../../main/theme/operating-system-theme.injectable";
|
||||||
import emitSystemThemeTypeUpdateInjectable from "./emit-update.injectable";
|
import emitSystemThemeTypeUpdateInjectable from "./emit-update.injectable";
|
||||||
|
|
||||||
const setupSystemThemeTypeUpdaterEmitterInjectable = getInjectable({
|
const setupSystemThemeTypeUpdaterEmitterInjectable = getInjectable({
|
||||||
id: "setup-system-theme-type-updater-emitter",
|
id: "setup-system-theme-type-updater-emitter",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const operatingSystemTheme = di.inject(operatingSystemThemeInjectable);
|
const operatingSystemTheme = di.inject(operatingSystemThemeInjectable);
|
||||||
const emitSystemThemeTypeUpdate = di.inject(emitSystemThemeTypeUpdateInjectable);
|
const emitSystemThemeTypeUpdate = di.inject(emitSystemThemeTypeUpdateInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
reaction(
|
reaction(
|
||||||
() => operatingSystemTheme.get(),
|
() => operatingSystemTheme.get(),
|
||||||
emitSystemThemeTypeUpdate,
|
emitSystemThemeTypeUpdate,
|
||||||
@ -23,7 +24,8 @@ const setupSystemThemeTypeUpdaterEmitterInjectable = getInjectable({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { fromPairs, map } from "lodash/fp";
|
|||||||
import { pipeline } from "@ogre-tools/fp";
|
import { pipeline } from "@ogre-tools/fp";
|
||||||
import joinPathsInjectable from "../../common/path/join-paths.injectable";
|
import joinPathsInjectable from "../../common/path/join-paths.injectable";
|
||||||
import appNameInjectable from "../../common/vars/app-name.injectable";
|
import appNameInjectable from "../../common/vars/app-name.injectable";
|
||||||
import { appPathsRunnablePhaseInjectionToken } from "../start-main-application/runnable-tokens/phases";
|
import { beforeAnythingInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
|
|
||||||
const setupAppPathsInjectable = getInjectable({
|
const setupAppPathsInjectable = getInjectable({
|
||||||
id: "setup-app-paths",
|
id: "setup-app-paths",
|
||||||
@ -48,7 +48,7 @@ const setupAppPathsInjectable = getInjectable({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
injectionToken: appPathsRunnablePhaseInjectionToken,
|
injectionToken: beforeAnythingInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default setupAppPathsInjectable;
|
export default setupAppPathsInjectable;
|
||||||
|
|||||||
@ -3,18 +3,20 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import clusterManagerInjectable from "./manager.injectable";
|
import clusterManagerInjectable from "./manager.injectable";
|
||||||
|
|
||||||
const initializeClusterManagerInjectable = getInjectable({
|
const initializeClusterManagerInjectable = getInjectable({
|
||||||
id: "initialize-cluster-manager",
|
id: "initialize-cluster-manager",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const clusterManager = di.inject(clusterManagerInjectable);
|
const clusterManager = di.inject(clusterManagerInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
clusterManager.init();
|
clusterManager.init();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,32 +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 { runInAction } from "mobx";
|
|
||||||
import type { CreateApplication } from "../common/create-app";
|
|
||||||
import nodeEnvInjectionToken from "../common/vars/node-env-injection-token";
|
|
||||||
import { getDi } from "./getDi";
|
|
||||||
import { registerInjectables } from "./register-injectables";
|
|
||||||
import startMainApplicationInjectable from "./start-main-application/start-main-application.injectable";
|
|
||||||
|
|
||||||
export const createApplication: CreateApplication = (config) => {
|
|
||||||
const { mode } = config;
|
|
||||||
const di = getDi();
|
|
||||||
|
|
||||||
runInAction(() => {
|
|
||||||
di.register(getInjectable({
|
|
||||||
id: "node-env",
|
|
||||||
instantiate: () => mode,
|
|
||||||
injectionToken: nodeEnvInjectionToken,
|
|
||||||
}));
|
|
||||||
|
|
||||||
registerInjectables(di);
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
start: di.inject(startMainApplicationInjectable),
|
|
||||||
di,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,14 +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 electronAppInjectable from "../electron-app.injectable";
|
|
||||||
|
|
||||||
const waitForElectronToBeReadyInjectable = getInjectable({
|
|
||||||
id: "wait-for-electron-to-be-ready",
|
|
||||||
|
|
||||||
instantiate: (di) => () => di.inject(electronAppInjectable).whenReady(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default waitForElectronToBeReadyInjectable;
|
|
||||||
@ -3,25 +3,27 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
import requestSingleInstanceLockInjectable from "../features/request-single-instance-lock.injectable";
|
import requestSingleInstanceLockInjectable from "../features/request-single-instance-lock.injectable";
|
||||||
import exitAppInjectable from "../features/exit-app.injectable";
|
import exitAppInjectable from "../features/exit-app.injectable";
|
||||||
|
|
||||||
const enforceSingleApplicationInstanceInjectable = getInjectable({
|
const enforceSingleApplicationInstanceInjectable = getInjectable({
|
||||||
id: "enforce-single-application-instance",
|
id: "enforce-single-application-instance",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const requestSingleInstanceLock = di.inject(requestSingleInstanceLockInjectable);
|
const requestSingleInstanceLock = di.inject(requestSingleInstanceLockInjectable);
|
||||||
const exitApp = di.inject(exitAppInjectable);
|
const exitApp = di.inject(exitAppInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
if (!requestSingleInstanceLock()) {
|
if (!requestSingleInstanceLock()) {
|
||||||
exitApp();
|
exitApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,22 +4,22 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import appNameInjectable from "../../../common/vars/app-name.injectable";
|
import appNameInjectable from "../../../common/vars/app-name.injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
import electronAppInjectable from "../electron-app.injectable";
|
import electronAppInjectable from "../electron-app.injectable";
|
||||||
|
|
||||||
const setupApplicationNameInjectable = getInjectable({
|
const setupApplicationNameInjectable = getInjectable({
|
||||||
id: "setup-application-name",
|
id: "setup-application-name",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const app = di.inject(electronAppInjectable);
|
const app = di.inject(electronAppInjectable);
|
||||||
const appName = di.inject(appNameInjectable);
|
const appName = di.inject(appNameInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
app.setName(appName);
|
app.setName(appName);
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,21 +7,26 @@ import electronAppInjectable from "../electron-app.injectable";
|
|||||||
import openDeepLinkInjectable from "../../protocol-handler/lens-protocol-router-main/open-deep-link-for-url/open-deep-link.injectable";
|
import openDeepLinkInjectable from "../../protocol-handler/lens-protocol-router-main/open-deep-link-for-url/open-deep-link.injectable";
|
||||||
import loggerInjectable from "../../../common/logger.injectable";
|
import loggerInjectable from "../../../common/logger.injectable";
|
||||||
import commandLineArgumentsInjectable from "../../utils/command-line-arguments.injectable";
|
import commandLineArgumentsInjectable from "../../utils/command-line-arguments.injectable";
|
||||||
import { startsWith, toLower } from "lodash/fp";
|
import { pipeline } from "@ogre-tools/fp";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { find, startsWith, toLower, map } from "lodash/fp";
|
||||||
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import showApplicationWindowInjectable from "../../start-main-application/lens-window/show-application-window.injectable";
|
import showApplicationWindowInjectable from "../../start-main-application/lens-window/show-application-window.injectable";
|
||||||
|
|
||||||
const setupDeepLinkingInjectable = getInjectable({
|
const setupDeepLinkingInjectable = getInjectable({
|
||||||
id: "setup-deep-linking",
|
id: "setup-deep-linking",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const app = di.inject(electronAppInjectable);
|
const app = di.inject(electronAppInjectable);
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const openDeepLinkForUrl = di.inject(openDeepLinkInjectable);
|
const openDeepLinkForUrl = di.inject(openDeepLinkInjectable);
|
||||||
const showApplicationWindow = di.inject(showApplicationWindowInjectable);
|
const showApplicationWindow = di.inject(showApplicationWindowInjectable);
|
||||||
const firstInstanceCommandLineArguments = di.inject(commandLineArgumentsInjectable);
|
|
||||||
|
|
||||||
|
const firstInstanceCommandLineArguments = di.inject(
|
||||||
|
commandLineArgumentsInjectable,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async () => {
|
||||||
logger.info(`📟 Setting protocol client for lens://`);
|
logger.info(`📟 Setting protocol client for lens://`);
|
||||||
|
|
||||||
if (app.setAsDefaultProtocolClient("lens")) {
|
if (app.setAsDefaultProtocolClient("lens")) {
|
||||||
@ -44,6 +49,7 @@ const setupDeepLinkingInjectable = getInjectable({
|
|||||||
|
|
||||||
app.on(
|
app.on(
|
||||||
"second-instance",
|
"second-instance",
|
||||||
|
|
||||||
async (_, secondInstanceCommandLineArguments) => {
|
async (_, secondInstanceCommandLineArguments) => {
|
||||||
const url = getDeepLinkUrl(secondInstanceCommandLineArguments);
|
const url = getDeepLinkUrl(secondInstanceCommandLineArguments);
|
||||||
|
|
||||||
@ -55,15 +61,13 @@ const setupDeepLinkingInjectable = getInjectable({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default setupDeepLinkingInjectable;
|
export default setupDeepLinkingInjectable;
|
||||||
|
|
||||||
const getDeepLinkUrl = (commandLineArguments: string[]) => (
|
const getDeepLinkUrl = (commandLineArguments: string[]) =>
|
||||||
commandLineArguments
|
pipeline(commandLineArguments, map(toLower), find(startsWith("lens://")));
|
||||||
.map(toLower)
|
|
||||||
.find(startsWith("lens://"))
|
|
||||||
);
|
|
||||||
|
|||||||
@ -3,18 +3,19 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import nodeEnvInjectionToken from "../../../common/vars/node-env-injection-token";
|
import { nodeEnvInjectionToken } from "../../../common/vars/node-env-injection-token";
|
||||||
import loggerInjectable from "../../../common/logger.injectable";
|
import loggerInjectable from "../../../common/logger.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const setupDeveloperToolsInDevelopmentEnvironmentInjectable = getInjectable({
|
const setupDeveloperToolsInDevelopmentEnvironmentInjectable = getInjectable({
|
||||||
id: "setup-developer-tools-in-development-environment",
|
id: "setup-developer-tools-in-development-environment",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const nodeEnv = di.inject(nodeEnvInjectionToken);
|
const nodeEnv = di.inject(nodeEnvInjectionToken);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
if (nodeEnv !== "development") {
|
if (nodeEnv !== "development") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -36,7 +37,8 @@ const setupDeveloperToolsInDevelopmentEnvironmentInjectable = getInjectable({
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,19 +5,21 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import powerMonitorInjectable from "../features/power-monitor.injectable";
|
import powerMonitorInjectable from "../features/power-monitor.injectable";
|
||||||
import exitAppInjectable from "../features/exit-app.injectable";
|
import exitAppInjectable from "../features/exit-app.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const setupDeviceShutdownInjectable = getInjectable({
|
const setupDeviceShutdownInjectable = getInjectable({
|
||||||
id: "setup-device-shutdown",
|
id: "setup-device-shutdown",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const powerMonitor = di.inject(powerMonitorInjectable);
|
const powerMonitor = di.inject(powerMonitorInjectable);
|
||||||
const exitApp = di.inject(exitAppInjectable);
|
const exitApp = di.inject(exitAppInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
powerMonitor.on("shutdown", exitApp);
|
powerMonitor.on("shutdown", exitApp);
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
|
|||||||
import { setupIpcMainHandlers } from "./setup-ipc-main-handlers";
|
import { setupIpcMainHandlers } from "./setup-ipc-main-handlers";
|
||||||
import loggerInjectable from "../../../../common/logger.injectable";
|
import loggerInjectable from "../../../../common/logger.injectable";
|
||||||
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable";
|
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import applicationMenuItemCompositeInjectable from "../../../../features/application-menu/main/application-menu-item-composite.injectable";
|
import applicationMenuItemCompositeInjectable from "../../../../features/application-menu/main/application-menu-item-composite.injectable";
|
||||||
import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.injectable";
|
import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.injectable";
|
||||||
import getClusterByIdInjectable from "../../../../common/cluster-store/get-by-id.injectable";
|
import getClusterByIdInjectable from "../../../../common/cluster-store/get-by-id.injectable";
|
||||||
@ -15,8 +15,7 @@ import pushCatalogToRendererInjectable from "../../../catalog-sync-to-renderer/p
|
|||||||
const setupIpcMainHandlersInjectable = getInjectable({
|
const setupIpcMainHandlersInjectable = getInjectable({
|
||||||
id: "setup-ipc-main-handlers",
|
id: "setup-ipc-main-handlers",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const applicationMenuItemComposite = di.inject(applicationMenuItemCompositeInjectable);
|
const applicationMenuItemComposite = di.inject(applicationMenuItemCompositeInjectable);
|
||||||
const pushCatalogToRenderer = di.inject(pushCatalogToRendererInjectable);
|
const pushCatalogToRenderer = di.inject(pushCatalogToRendererInjectable);
|
||||||
@ -24,6 +23,8 @@ const setupIpcMainHandlersInjectable = getInjectable({
|
|||||||
const emitAppEvent = di.inject(emitAppEventInjectable);
|
const emitAppEvent = di.inject(emitAppEventInjectable);
|
||||||
const getClusterById = di.inject(getClusterByIdInjectable);
|
const getClusterById = di.inject(getClusterByIdInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
logger.debug("[APP-MAIN] initializing ipc main handlers");
|
logger.debug("[APP-MAIN] initializing ipc main handlers");
|
||||||
|
|
||||||
setupIpcMainHandlers({
|
setupIpcMainHandlers({
|
||||||
@ -34,7 +35,8 @@ const setupIpcMainHandlersInjectable = getInjectable({
|
|||||||
getClusterById,
|
getClusterById,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
|
|||||||
@ -5,18 +5,19 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import electronAppInjectable from "../electron-app.injectable";
|
import electronAppInjectable from "../electron-app.injectable";
|
||||||
import loggerInjectable from "../../../common/logger.injectable";
|
import loggerInjectable from "../../../common/logger.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import showApplicationWindowInjectable from "../../start-main-application/lens-window/show-application-window.injectable";
|
import showApplicationWindowInjectable from "../../start-main-application/lens-window/show-application-window.injectable";
|
||||||
|
|
||||||
const setupMainWindowVisibilityAfterActivationInjectable = getInjectable({
|
const setupMainWindowVisibilityAfterActivationInjectable = getInjectable({
|
||||||
id: "setup-main-window-visibility-after-activation",
|
id: "setup-main-window-visibility-after-activation",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const app = di.inject(electronAppInjectable);
|
const app = di.inject(electronAppInjectable);
|
||||||
const showApplicationWindow = di.inject(showApplicationWindowInjectable);
|
const showApplicationWindow = di.inject(showApplicationWindowInjectable);
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
app.on("activate", (_, windowIsVisible) => {
|
app.on("activate", (_, windowIsVisible) => {
|
||||||
logger.info("APP:ACTIVATE", { hasVisibleWindows: windowIsVisible });
|
logger.info("APP:ACTIVATE", { hasVisibleWindows: windowIsVisible });
|
||||||
|
|
||||||
@ -25,7 +26,8 @@ const setupMainWindowVisibilityAfterActivationInjectable = getInjectable({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,25 +3,26 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken, afterWindowIsOpenedInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
|
import { afterWindowIsOpenedInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
||||||
import electronAppInjectable from "../electron-app.injectable";
|
import electronAppInjectable from "../electron-app.injectable";
|
||||||
import { runManyFor } from "@k8slens/run-many";
|
import { runManyFor } from "@k8slens/run-many";
|
||||||
|
|
||||||
const setupRunnablesAfterWindowIsOpenedInjectable = getInjectable({
|
const setupRunnablesAfterWindowIsOpenedInjectable = getInjectable({
|
||||||
id: "setup-runnables-after-window-is-opened",
|
id: "setup-runnables-after-window-is-opened",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const afterWindowIsOpened = runManyFor(di)(afterWindowIsOpenedInjectionToken);
|
const afterWindowIsOpened = runManyFor(di)(afterWindowIsOpenedInjectionToken);
|
||||||
const app = di.inject(electronAppInjectable);
|
const app = di.inject(electronAppInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
app.on("browser-window-created", () => {
|
app.on("browser-window-created", () => {
|
||||||
afterWindowIsOpened();
|
afterWindowIsOpened();
|
||||||
});
|
});
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken, beforeQuitOfFrontEndInjectionToken, beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
|
import { beforeQuitOfFrontEndInjectionToken, beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
||||||
import electronAppInjectable from "../electron-app.injectable";
|
import electronAppInjectable from "../electron-app.injectable";
|
||||||
import isIntegrationTestingInjectable from "../../../common/vars/is-integration-testing.injectable";
|
import isIntegrationTestingInjectable from "../../../common/vars/is-integration-testing.injectable";
|
||||||
import autoUpdaterInjectable from "../features/auto-updater.injectable";
|
import autoUpdaterInjectable from "../features/auto-updater.injectable";
|
||||||
@ -12,14 +13,16 @@ import { runManySyncFor } from "@k8slens/run-many";
|
|||||||
const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({
|
const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({
|
||||||
id: "setup-closing-of-application",
|
id: "setup-closing-of-application",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const runManySync = runManySyncFor(di);
|
const runManySync = runManySyncFor(di);
|
||||||
const runRunnablesBeforeQuitOfFrontEnd = runManySync(beforeQuitOfFrontEndInjectionToken);
|
const runRunnablesBeforeQuitOfFrontEnd = runManySync(beforeQuitOfFrontEndInjectionToken);
|
||||||
const runRunnablesBeforeQuitOfBackEnd = runManySync(beforeQuitOfBackEndInjectionToken);
|
const runRunnablesBeforeQuitOfBackEnd = runManySync(beforeQuitOfBackEndInjectionToken);
|
||||||
const app = di.inject(electronAppInjectable);
|
const app = di.inject(electronAppInjectable);
|
||||||
const isIntegrationTesting = di.inject(isIntegrationTestingInjectable);
|
const isIntegrationTesting = di.inject(isIntegrationTestingInjectable);
|
||||||
const autoUpdater = di.inject(autoUpdaterInjectable);
|
const autoUpdater = di.inject(autoUpdaterInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
let isAutoUpdating = false;
|
let isAutoUpdating = false;
|
||||||
|
|
||||||
autoUpdater.on("before-quit-for-update", () => {
|
autoUpdater.on("before-quit-for-update", () => {
|
||||||
@ -38,10 +41,9 @@ const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { createContainer } from "@ogre-tools/injectable";
|
|
||||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
|
||||||
import { setLegacyGlobalDiForExtensionApi } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
|
||||||
|
|
||||||
export const getDi = () => {
|
|
||||||
const environment = "main";
|
|
||||||
const di = createContainer(environment);
|
|
||||||
|
|
||||||
registerMobX(di);
|
|
||||||
setLegacyGlobalDiForExtensionApi(di, environment);
|
|
||||||
|
|
||||||
return di;
|
|
||||||
};
|
|
||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import { chunk } from "lodash/fp";
|
import { chunk } from "lodash/fp";
|
||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import { isInjectable } from "@ogre-tools/injectable";
|
import { createContainer, isInjectable } from "@ogre-tools/injectable";
|
||||||
import spawnInjectable from "./child-process/spawn.injectable";
|
import spawnInjectable from "./child-process/spawn.injectable";
|
||||||
import initializeExtensionsInjectable from "./start-main-application/runnables/initialize-extensions.injectable";
|
import initializeExtensionsInjectable from "./start-main-application/runnables/initialize-extensions.injectable";
|
||||||
import setupIpcMainHandlersInjectable from "./electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.injectable";
|
import setupIpcMainHandlersInjectable from "./electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.injectable";
|
||||||
@ -28,14 +28,20 @@ import electronInjectable from "./utils/resolve-system-proxy/electron.injectable
|
|||||||
import initializeClusterManagerInjectable from "./cluster/initialize-manager.injectable";
|
import initializeClusterManagerInjectable from "./cluster/initialize-manager.injectable";
|
||||||
import type { GlobalOverride } from "@k8slens/test-utils";
|
import type { GlobalOverride } from "@k8slens/test-utils";
|
||||||
import { getOverrideFsWithFakes } from "../test-utils/override-fs-with-fakes";
|
import { getOverrideFsWithFakes } from "../test-utils/override-fs-with-fakes";
|
||||||
import { getDi } from "./getDi";
|
import {
|
||||||
|
setLegacyGlobalDiForExtensionApi,
|
||||||
|
} from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
|
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||||
|
|
||||||
export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) {
|
export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) {
|
||||||
const {
|
const {
|
||||||
doGeneralOverrides = false,
|
doGeneralOverrides = false,
|
||||||
} = opts;
|
} = opts;
|
||||||
|
|
||||||
const di = getDi();
|
const di = createContainer("main");
|
||||||
|
|
||||||
|
registerMobX(di);
|
||||||
|
setLegacyGlobalDiForExtensionApi(di, "main");
|
||||||
|
|
||||||
di.preventSideEffects();
|
di.preventSideEffects();
|
||||||
|
|
||||||
|
|||||||
@ -4,14 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// @experimental
|
// @experimental
|
||||||
export {
|
export type {
|
||||||
afterApplicationIsLoadedInjectionToken,
|
Environments,
|
||||||
beforeApplicationIsLoadingInjectionToken,
|
} from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
beforeElectronIsReadyInjectionToken,
|
|
||||||
onLoadOfApplicationInjectionToken,
|
export { registerLensCore } from "./register-lens-core";
|
||||||
} from "./start-main-application/runnable-tokens/phases";
|
export { nodeEnvInjectionToken } from "../common/vars/node-env-injection-token";
|
||||||
export { createApplication } from "./create-app";
|
|
||||||
export type { CreateApplication, Application, ApplicationConfig } from "../common/create-app";
|
|
||||||
export * as Mobx from "mobx";
|
export * as Mobx from "mobx";
|
||||||
export * as mainExtensionApi from "../extensions/main-api";
|
export * as mainExtensionApi from "../extensions/main-api";
|
||||||
export * as commonExtensionApi from "../extensions/common-api";
|
export * as commonExtensionApi from "../extensions/common-api";
|
||||||
|
|||||||
@ -2,20 +2,26 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
|
import type {
|
||||||
|
Environments } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
|
import {
|
||||||
|
setLegacyGlobalDiForExtensionApi,
|
||||||
|
} from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
|
|
||||||
|
export function registerLensCore(di: DiContainer, environment: Environments) {
|
||||||
|
setLegacyGlobalDiForExtensionApi(di, environment);
|
||||||
|
|
||||||
export function registerInjectables(di: DiContainer) {
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
autoRegister({
|
autoRegister({
|
||||||
di,
|
di,
|
||||||
targetModule: module,
|
targetModule: module,
|
||||||
getRequireContexts: () => [
|
getRequireContexts: () => [
|
||||||
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||||
require.context("../common", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
|
||||||
require.context("../extensions", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
require.context("../extensions", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||||
|
require.context("../common", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||||
require.context("../features", true, CONTEXT_MATCHER_FOR_FEATURES),
|
require.context("../features", true, CONTEXT_MATCHER_FOR_FEATURES),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -1,59 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
|
||||||
import type { Runnable, RunnableSync } from "@k8slens/run-many";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* These tokens are here so that the importing of their respective dependencies
|
|
||||||
* can be delayed until all of them are ready
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This runnable token should only have the app paths init so that it can be run by itself
|
|
||||||
*/
|
|
||||||
export const appPathsRunnablePhaseInjectionToken = getInjectionToken<RunnableSync>({
|
|
||||||
id: "app-paths-runnable-phase",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const showLoadingRunnablePhaseInjectionToken = getInjectionToken<Runnable>({
|
|
||||||
id: "show-loading-runnable-phase",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const showInitialWindowRunnablePhaseInjectionToken = getInjectionToken<Runnable>({
|
|
||||||
id: "show-initial-window-runnable-phase",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const onLoadOfApplicationInjectionToken = getInjectionToken<Runnable>({
|
|
||||||
id: "on-load-of-application",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const beforeQuitOfFrontEndInjectionToken = getInjectionToken<RunnableSync>({
|
|
||||||
id: "before-quit-of-front-end",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const beforeQuitOfBackEndInjectionToken = getInjectionToken<RunnableSync>({
|
|
||||||
id: "before-quit-of-back-end",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const beforeElectronIsReadyInjectionToken = getInjectionToken<RunnableSync>({
|
|
||||||
id: "before-electron-is-ready",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const beforeApplicationIsLoadingInjectionToken = getInjectionToken<Runnable>({
|
|
||||||
id: "before-application-is-loading",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const afterWindowIsOpenedInjectionToken = getInjectionToken<Runnable>({
|
|
||||||
id: "after-window-is-opened",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const afterRootFrameIsReadyInjectionToken = getInjectionToken<Runnable>({
|
|
||||||
id: "after-root-frame-is-ready",
|
|
||||||
});
|
|
||||||
|
|
||||||
export const afterApplicationIsLoadedInjectionToken = getInjectionToken<Runnable>({
|
|
||||||
id: "after-application-is-loaded",
|
|
||||||
});
|
|
||||||
@ -4,18 +4,20 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import emitAppEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
|
import emitAppEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
|
||||||
import { afterApplicationIsLoadedInjectionToken } from "../runnable-tokens/phases";
|
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const emitServiceStartToEventBusInjectable = getInjectable({
|
const emitServiceStartToEventBusInjectable = getInjectable({
|
||||||
id: "emit-service-start-to-event-bus",
|
id: "emit-service-start-to-event-bus",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const emitAppEvent = di.inject(emitAppEventInjectable);
|
const emitAppEvent = di.inject(emitAppEventInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
emitAppEvent({ name: "service", action: "start" });
|
emitAppEvent({ name: "service", action: "start" });
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,18 +9,19 @@ import loggerInjectable from "../../../common/logger.injectable";
|
|||||||
import extensionDiscoveryInjectable from "../../../extensions/extension-discovery/extension-discovery.injectable";
|
import extensionDiscoveryInjectable from "../../../extensions/extension-discovery/extension-discovery.injectable";
|
||||||
import extensionLoaderInjectable from "../../../extensions/extension-loader/extension-loader.injectable";
|
import extensionLoaderInjectable from "../../../extensions/extension-loader/extension-loader.injectable";
|
||||||
import showErrorPopupInjectable from "../../electron-app/features/show-error-popup.injectable";
|
import showErrorPopupInjectable from "../../electron-app/features/show-error-popup.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const initializeExtensionsInjectable = getInjectable({
|
const initializeExtensionsInjectable = getInjectable({
|
||||||
id: "initialize-extensions",
|
id: "initialize-extensions",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const extensionDiscovery = di.inject(extensionDiscoveryInjectable);
|
const extensionDiscovery = di.inject(extensionDiscoveryInjectable);
|
||||||
const extensionLoader = di.inject(extensionLoaderInjectable);
|
const extensionLoader = di.inject(extensionLoaderInjectable);
|
||||||
const showErrorPopup = di.inject(showErrorPopupInjectable);
|
const showErrorPopup = di.inject(showErrorPopupInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async () => {
|
||||||
logger.info("🧩 Initializing extensions");
|
logger.info("🧩 Initializing extensions");
|
||||||
|
|
||||||
await extensionDiscovery.init();
|
await extensionDiscovery.init();
|
||||||
@ -46,14 +47,17 @@ const initializeExtensionsInjectable = getInjectable({
|
|||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
showErrorPopup(
|
showErrorPopup(
|
||||||
"Lens Error",
|
"Lens Error",
|
||||||
`Could not load extensions${error?.message ? `: ${error.message}` : ""}`,
|
`Could not load extensions${
|
||||||
|
error?.message ? `: ${error.message}` : ""
|
||||||
|
}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
console.trace();
|
console.trace();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
|
|
||||||
|
|||||||
@ -5,18 +5,20 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable";
|
import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable";
|
||||||
import catalogEntityRegistryInjectable from "../../../catalog/entity-registry.injectable";
|
import catalogEntityRegistryInjectable from "../../../catalog/entity-registry.injectable";
|
||||||
import { afterApplicationIsLoadedInjectionToken } from "../../runnable-tokens/phases";
|
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const addKubeconfigSyncAsEntitySourceInjectable = getInjectable({
|
const addKubeconfigSyncAsEntitySourceInjectable = getInjectable({
|
||||||
id: "add-kubeconfig-sync-as-entity-source",
|
id: "add-kubeconfig-sync-as-entity-source",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
|
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
|
||||||
const entityRegistry = di.inject(catalogEntityRegistryInjectable);
|
const entityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
entityRegistry.addComputedSource("kubeconfig-sync", kubeConfigSyncManager.source);
|
entityRegistry.addComputedSource("kubeconfig-sync", kubeConfigSyncManager.source);
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { afterApplicationIsLoadedInjectionToken } from "../../runnable-tokens/phases";
|
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
|
||||||
import directoryForKubeConfigsInjectable from "../../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
|
import directoryForKubeConfigsInjectable from "../../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
|
||||||
import ensureDirInjectable from "../../../../common/fs/ensure-dir.injectable";
|
import ensureDirInjectable from "../../../../common/fs/ensure-dir.injectable";
|
||||||
import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable";
|
import kubeconfigSyncManagerInjectable from "../../../catalog-sources/kubeconfig-sync/manager.injectable";
|
||||||
@ -12,18 +12,20 @@ import addKubeconfigSyncAsEntitySourceInjectable from "./add-source.injectable";
|
|||||||
const startKubeConfigSyncInjectable = getInjectable({
|
const startKubeConfigSyncInjectable = getInjectable({
|
||||||
id: "start-kubeconfig-sync",
|
id: "start-kubeconfig-sync",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const directoryForKubeConfigs = di.inject(directoryForKubeConfigsInjectable);
|
const directoryForKubeConfigs = di.inject(directoryForKubeConfigsInjectable);
|
||||||
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
|
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
|
||||||
const ensureDir = di.inject(ensureDirInjectable);
|
const ensureDir = di.inject(ensureDirInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async () => {
|
||||||
await ensureDir(directoryForKubeConfigs);
|
await ensureDir(directoryForKubeConfigs);
|
||||||
|
|
||||||
kubeConfigSyncManager.startSync();
|
kubeConfigSyncManager.startSync();
|
||||||
},
|
},
|
||||||
runAfter: addKubeconfigSyncAsEntitySourceInjectable,
|
runAfter: addKubeconfigSyncAsEntitySourceInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,22 +3,22 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../../runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
import initializeSentryReportingWithInjectable from "../../../../common/error-reporting/initialize-sentry-reporting.injectable";
|
import initializeSentryReportingWithInjectable from "../../../../common/error-reporting/initialize-sentry-reporting.injectable";
|
||||||
import initializeSentryOnMainInjectable from "./initialize-on-main.injectable";
|
import initializeSentryOnMainInjectable from "./initialize-on-main.injectable";
|
||||||
|
|
||||||
const setupSentryInjectable = getInjectable({
|
const setupSentryInjectable = getInjectable({
|
||||||
id: "setup-sentry",
|
id: "setup-sentry",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const initializeSentryReportingWith = di.inject(initializeSentryReportingWithInjectable);
|
const initializeSentryReportingWith = di.inject(initializeSentryReportingWithInjectable);
|
||||||
const initializeSentryOnMain = di.inject(initializeSentryOnMainInjectable);
|
const initializeSentryOnMain = di.inject(initializeSentryOnMainInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
initializeSentryReportingWith(initializeSentryOnMain);
|
initializeSentryReportingWith(initializeSentryOnMain);
|
||||||
|
}
|
||||||
return undefined;
|
};
|
||||||
},
|
},
|
||||||
}),
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -5,23 +5,23 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import disableHardwareAccelerationInjectable from "../../electron-app/features/disable-hardware-acceleration.injectable";
|
import disableHardwareAccelerationInjectable from "../../electron-app/features/disable-hardware-acceleration.injectable";
|
||||||
import hardwareAccelerationShouldBeDisabledInjectable from "../../vars/hardware-acceleration-should-be-disabled.injectable";
|
import hardwareAccelerationShouldBeDisabledInjectable from "../../vars/hardware-acceleration-should-be-disabled.injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
|
|
||||||
const setupHardwareAccelerationInjectable = getInjectable({
|
const setupHardwareAccelerationInjectable = getInjectable({
|
||||||
id: "setup-hardware-acceleration",
|
id: "setup-hardware-acceleration",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const hardwareAccelerationShouldBeDisabled = di.inject(hardwareAccelerationShouldBeDisabledInjectable);
|
const hardwareAccelerationShouldBeDisabled = di.inject(hardwareAccelerationShouldBeDisabledInjectable);
|
||||||
const disableHardwareAcceleration = di.inject(disableHardwareAccelerationInjectable);
|
const disableHardwareAcceleration = di.inject(disableHardwareAccelerationInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
if (hardwareAccelerationShouldBeDisabled) {
|
if (hardwareAccelerationShouldBeDisabled) {
|
||||||
disableHardwareAcceleration();
|
disableHardwareAcceleration();
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,24 +4,24 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import electronAppInjectable from "../../electron-app/electron-app.injectable";
|
import electronAppInjectable from "../../electron-app/electron-app.injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
|
|
||||||
const setupHostnamesInjectable = getInjectable({
|
const setupHostnamesInjectable = getInjectable({
|
||||||
id: "setup-hostnames",
|
id: "setup-hostnames",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const app = di.inject(electronAppInjectable);
|
const app = di.inject(electronAppInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
app.commandLine.appendSwitch("host-rules", [
|
app.commandLine.appendSwitch("host-rules", [
|
||||||
"MAP localhost 127.0.0.1",
|
"MAP localhost 127.0.0.1",
|
||||||
"MAP lens.app 127.0.0.1",
|
"MAP lens.app 127.0.0.1",
|
||||||
"MAP *.lens.app 127.0.0.1",
|
"MAP *.lens.app 127.0.0.1",
|
||||||
].join());
|
].join());
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { setAutoFreeze, enableMapSet } from "immer";
|
import { setAutoFreeze, enableMapSet } from "immer";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
|
|
||||||
const setupImmerInjectable = getInjectable({
|
const setupImmerInjectable = getInjectable({
|
||||||
id: "setup-immer",
|
id: "setup-immer",
|
||||||
@ -15,8 +15,6 @@ const setupImmerInjectable = getInjectable({
|
|||||||
// Required in `utils/storage-helper.ts`
|
// Required in `utils/storage-helper.ts`
|
||||||
setAutoFreeze(false); // allow to merge mobx observables
|
setAutoFreeze(false); // allow to merge mobx observables
|
||||||
enableMapSet(); // allow to merge maps and sets
|
enableMapSet(); // allow to merge maps and sets
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
@ -5,15 +5,16 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { generate } from "selfsigned";
|
import { generate } from "selfsigned";
|
||||||
import lensProxyCertificateInjectable from "../../../common/certificate/lens-proxy-certificate.injectable";
|
import lensProxyCertificateInjectable from "../../../common/certificate/lens-proxy-certificate.injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
|
|
||||||
const setupLensProxyCertificateInjectable = getInjectable({
|
const setupLensProxyCertificateInjectable = getInjectable({
|
||||||
id: "setup-lens-proxy-certificate",
|
id: "setup-lens-proxy-certificate",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const lensProxyCertificate = di.inject(lensProxyCertificateInjectable);
|
const lensProxyCertificate = di.inject(lensProxyCertificateInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
const cert = generate([
|
const cert = generate([
|
||||||
{ name: "commonName", value: "Lens Certificate Authority" },
|
{ name: "commonName", value: "Lens Certificate Authority" },
|
||||||
{ name: "organizationName", value: "Lens" },
|
{ name: "organizationName", value: "Lens" },
|
||||||
@ -39,10 +40,9 @@ const setupLensProxyCertificateInjectable = getInjectable({
|
|||||||
});
|
});
|
||||||
|
|
||||||
lensProxyCertificate.set(cert);
|
lensProxyCertificate.set(cert);
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import loggerInjectable from "../../../common/logger.injectable";
|
|||||||
import lensProxyPortInjectable from "../../lens-proxy/lens-proxy-port.injectable";
|
import lensProxyPortInjectable from "../../lens-proxy/lens-proxy-port.injectable";
|
||||||
import isWindowsInjectable from "../../../common/vars/is-windows.injectable";
|
import isWindowsInjectable from "../../../common/vars/is-windows.injectable";
|
||||||
import showErrorPopupInjectable from "../../electron-app/features/show-error-popup.injectable";
|
import showErrorPopupInjectable from "../../electron-app/features/show-error-popup.injectable";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import buildVersionInjectable from "../../vars/build-version/build-version.injectable";
|
import buildVersionInjectable from "../../vars/build-version/build-version.injectable";
|
||||||
import initializeBuildVersionInjectable from "../../vars/build-version/init.injectable";
|
import initializeBuildVersionInjectable from "../../vars/build-version/init.injectable";
|
||||||
import lensProxyCertificateInjectable from "../../../common/certificate/lens-proxy-certificate.injectable";
|
import lensProxyCertificateInjectable from "../../../common/certificate/lens-proxy-certificate.injectable";
|
||||||
@ -19,8 +19,7 @@ import { Agent } from "https";
|
|||||||
const setupLensProxyInjectable = getInjectable({
|
const setupLensProxyInjectable = getInjectable({
|
||||||
id: "setup-lens-proxy",
|
id: "setup-lens-proxy",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const lensProxy = di.inject(lensProxyInjectable);
|
const lensProxy = di.inject(lensProxyInjectable);
|
||||||
const exitApp = di.inject(exitAppInjectable);
|
const exitApp = di.inject(exitAppInjectable);
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
@ -31,6 +30,8 @@ const setupLensProxyInjectable = getInjectable({
|
|||||||
const lensProxyCertificate = di.inject(lensProxyCertificateInjectable);
|
const lensProxyCertificate = di.inject(lensProxyCertificateInjectable);
|
||||||
const fetch = di.inject(fetchInjectable);
|
const fetch = di.inject(fetchInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async () => {
|
||||||
try {
|
try {
|
||||||
logger.info("🔌 Starting LensProxy");
|
logger.info("🔌 Starting LensProxy");
|
||||||
await lensProxy.listen(); // lensProxy.port available
|
await lensProxy.listen(); // lensProxy.port available
|
||||||
@ -77,7 +78,8 @@ const setupLensProxyInjectable = getInjectable({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
runAfter: initializeBuildVersionInjectable,
|
runAfter: initializeBuildVersionInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import * as Mobx from "mobx";
|
import * as Mobx from "mobx";
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
|
|
||||||
const setupMobxInjectable = getInjectable({
|
const setupMobxInjectable = getInjectable({
|
||||||
id: "setup-mobx",
|
id: "setup-mobx",
|
||||||
|
|||||||
@ -3,18 +3,21 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/phases";
|
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||||
import getCommandLineSwitchInjectable from "../../electron-app/features/get-command-line-switch.injectable";
|
import getCommandLineSwitchInjectable from "../../electron-app/features/get-command-line-switch.injectable";
|
||||||
|
|
||||||
const setupProxyEnvInjectable = getInjectable({
|
const setupProxyEnvInjectable = getInjectable({
|
||||||
id: "setup-proxy-env",
|
id: "setup-proxy-env",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const getCommandLineSwitch = di.inject(getCommandLineSwitchInjectable);
|
const getCommandLineSwitch = di.inject(getCommandLineSwitchInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
const switchValue = getCommandLineSwitch("proxy-server");
|
const switchValue = getCommandLineSwitch("proxy-server");
|
||||||
|
|
||||||
let httpsProxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || "";
|
let httpsProxy =
|
||||||
|
process.env.HTTPS_PROXY || process.env.HTTP_PROXY || "";
|
||||||
|
|
||||||
delete process.env.HTTPS_PROXY;
|
delete process.env.HTTPS_PROXY;
|
||||||
delete process.env.HTTP_PROXY;
|
delete process.env.HTTP_PROXY;
|
||||||
@ -30,10 +33,9 @@ const setupProxyEnvInjectable = getInjectable({
|
|||||||
if (getCommandLineSwitch("proxy-server") !== "") {
|
if (getCommandLineSwitch("proxy-server") !== "") {
|
||||||
process.env.HTTPS_PROXY = getCommandLineSwitch("proxy-server");
|
process.env.HTTPS_PROXY = getCommandLineSwitch("proxy-server");
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,18 +4,20 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import syncGeneralCatalogEntitiesInjectable from "../../catalog-sources/sync-general-catalog-entities.injectable";
|
import syncGeneralCatalogEntitiesInjectable from "../../catalog-sources/sync-general-catalog-entities.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const setupSyncingOfGeneralCatalogEntitiesInjectable = getInjectable({
|
const setupSyncingOfGeneralCatalogEntitiesInjectable = getInjectable({
|
||||||
id: "setup-syncing-of-general-catalog-entities",
|
id: "setup-syncing-of-general-catalog-entities",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const syncGeneralCatalogEntities = di.inject(syncGeneralCatalogEntitiesInjectable);
|
const syncGeneralCatalogEntities = di.inject(syncGeneralCatalogEntitiesInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
syncGeneralCatalogEntities();
|
syncGeneralCatalogEntities();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,19 +3,21 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import syncWeblinksInjectable from "../../catalog-sources/sync-weblinks.injectable";
|
import syncWeblinksInjectable from "../../catalog-sources/sync-weblinks.injectable";
|
||||||
|
|
||||||
const setupSyncingOfWeblinksInjectable = getInjectable({
|
const setupSyncingOfWeblinksInjectable = getInjectable({
|
||||||
id: "setup-syncing-of-weblinks",
|
id: "setup-syncing-of-weblinks",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const syncWeblinks = di.inject(syncWeblinksInjectable);
|
const syncWeblinks = di.inject(syncWeblinksInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
syncWeblinks();
|
syncWeblinks();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,18 +3,22 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import injectSystemCAsInjectable from "../../../features/certificate-authorities/common/inject-system-cas.injectable";
|
import injectSystemCAsInjectable from "../../../features/certificate-authorities/common/inject-system-cas.injectable";
|
||||||
|
|
||||||
const setupSystemCaInjectable = getInjectable({
|
const setupSystemCaInjectable = getInjectable({
|
||||||
id: "setup-system-ca",
|
id: "setup-system-ca",
|
||||||
instantiate: (di) => ({
|
|
||||||
run: async () => {
|
instantiate: (di) => {
|
||||||
const injectSystemCAs = di.inject(injectSystemCAsInjectable);
|
const injectSystemCAs = di.inject(injectSystemCAsInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async () => {
|
||||||
await injectSystemCAs();
|
await injectSystemCAs();
|
||||||
},
|
},
|
||||||
}),
|
}
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import openDeepLinkInjectable from "../../protocol-handler/lens-protocol-router-
|
|||||||
import commandLineArgumentsInjectable from "../../utils/command-line-arguments.injectable";
|
import commandLineArgumentsInjectable from "../../utils/command-line-arguments.injectable";
|
||||||
import createFirstApplicationWindowInjectable from "../lens-window/application-window/create-first-application-window.injectable";
|
import createFirstApplicationWindowInjectable from "../lens-window/application-window/create-first-application-window.injectable";
|
||||||
import splashWindowInjectable from "../lens-window/splash-window/splash-window.injectable";
|
import splashWindowInjectable from "../lens-window/splash-window/splash-window.injectable";
|
||||||
import { showInitialWindowRunnablePhaseInjectionToken } from "../runnable-tokens/phases";
|
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const getDeepLinkUrl = (commandLineArguments: string[]) => (
|
const getDeepLinkUrl = (commandLineArguments: string[]) => (
|
||||||
commandLineArguments
|
commandLineArguments
|
||||||
@ -18,8 +18,7 @@ const getDeepLinkUrl = (commandLineArguments: string[]) => (
|
|||||||
|
|
||||||
const showInitialWindowInjectable = getInjectable({
|
const showInitialWindowInjectable = getInjectable({
|
||||||
id: "show-initial-window",
|
id: "show-initial-window",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const shouldStartHidden = di.inject(shouldStartHiddenInjectable);
|
const shouldStartHidden = di.inject(shouldStartHiddenInjectable);
|
||||||
const shouldStartWindow = !shouldStartHidden;
|
const shouldStartWindow = !shouldStartHidden;
|
||||||
const createFirstApplicationWindow = di.inject(createFirstApplicationWindowInjectable);
|
const createFirstApplicationWindow = di.inject(createFirstApplicationWindowInjectable);
|
||||||
@ -27,6 +26,8 @@ const showInitialWindowInjectable = getInjectable({
|
|||||||
const openDeepLink = di.inject(openDeepLinkInjectable);
|
const openDeepLink = di.inject(openDeepLinkInjectable);
|
||||||
const commandLineArguments = di.inject(commandLineArgumentsInjectable);
|
const commandLineArguments = di.inject(commandLineArgumentsInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async () => {
|
||||||
if (shouldStartWindow) {
|
if (shouldStartWindow) {
|
||||||
const deepLinkUrl = getDeepLinkUrl(commandLineArguments);
|
const deepLinkUrl = getDeepLinkUrl(commandLineArguments);
|
||||||
|
|
||||||
@ -41,8 +42,9 @@ const showInitialWindowInjectable = getInjectable({
|
|||||||
splashWindow.close();
|
splashWindow.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
injectionToken: showInitialWindowRunnablePhaseInjectionToken,
|
},
|
||||||
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default showInitialWindowInjectable;
|
export default showInitialWindowInjectable;
|
||||||
|
|||||||
@ -5,23 +5,24 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import shouldStartHiddenInjectable from "../../electron-app/features/should-start-hidden.injectable";
|
import shouldStartHiddenInjectable from "../../electron-app/features/should-start-hidden.injectable";
|
||||||
import splashWindowInjectable from "../lens-window/splash-window/splash-window.injectable";
|
import splashWindowInjectable from "../lens-window/splash-window/splash-window.injectable";
|
||||||
import { showLoadingRunnablePhaseInjectionToken } from "../runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const showLoadingInjectable = getInjectable({
|
const showLoadingInjectable = getInjectable({
|
||||||
id: "show-loading",
|
id: "show-loading",
|
||||||
|
instantiate: (di) => {
|
||||||
instantiate: (di) => ({
|
|
||||||
run: async () => {
|
|
||||||
const shouldStartHidden = di.inject(shouldStartHiddenInjectable);
|
const shouldStartHidden = di.inject(shouldStartHiddenInjectable);
|
||||||
const shouldShowLoadingWindow = !shouldStartHidden;
|
const shouldShowLoadingWindow = !shouldStartHidden;
|
||||||
const splashWindow = di.inject(splashWindowInjectable);
|
const splashWindow = di.inject(splashWindowInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async () => {
|
||||||
if (shouldShowLoadingWindow) {
|
if (shouldShowLoadingWindow) {
|
||||||
await splashWindow.start();
|
await splashWindow.start();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
injectionToken: showLoadingRunnablePhaseInjectionToken,
|
},
|
||||||
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default showLoadingInjectable;
|
export default showLoadingInjectable;
|
||||||
|
|||||||
@ -1,45 +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 { runManyFor, runManySyncFor } from "@k8slens/run-many";
|
|
||||||
import * as phases from "./runnable-tokens/phases";
|
|
||||||
import waitForElectronToBeReadyInjectable from "../electron-app/features/wait-for-electron-to-be-ready.injectable";
|
|
||||||
|
|
||||||
const startMainApplicationInjectable = getInjectable({
|
|
||||||
id: "start-main-application",
|
|
||||||
|
|
||||||
instantiate: (di) => {
|
|
||||||
const runMany = runManyFor(di);
|
|
||||||
const runManySync = runManySyncFor(di);
|
|
||||||
const waitForElectronToBeReady = di.inject(waitForElectronToBeReadyInjectable);
|
|
||||||
|
|
||||||
const appPathsRunnablePhase = runManySync(phases.appPathsRunnablePhaseInjectionToken);
|
|
||||||
const beforeElectronIsReady = runManySync(phases.beforeElectronIsReadyInjectionToken);
|
|
||||||
const beforeApplicationIsLoading = runMany(phases.beforeApplicationIsLoadingInjectionToken);
|
|
||||||
const showLoadingRunnablePhase = runMany(phases.showLoadingRunnablePhaseInjectionToken);
|
|
||||||
const onLoadOfApplication = runMany(phases.onLoadOfApplicationInjectionToken);
|
|
||||||
const showInitialWindowRunnablePhase = runMany(phases.showInitialWindowRunnablePhaseInjectionToken);
|
|
||||||
const afterApplicationIsLoaded = runMany(phases.afterApplicationIsLoadedInjectionToken);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
// Stuff happening before application is ready needs to be synchronous because of
|
|
||||||
// https://github.com/electron/electron/issues/21370
|
|
||||||
appPathsRunnablePhase();
|
|
||||||
beforeElectronIsReady();
|
|
||||||
|
|
||||||
return (async () => {
|
|
||||||
await waitForElectronToBeReady();
|
|
||||||
await beforeApplicationIsLoading();
|
|
||||||
await showLoadingRunnablePhase();
|
|
||||||
await onLoadOfApplication();
|
|
||||||
await showInitialWindowRunnablePhase();
|
|
||||||
await afterApplicationIsLoaded();
|
|
||||||
})();
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default startMainApplicationInjectable;
|
|
||||||
@ -5,21 +5,23 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import userStoreFileNameMigrationInjectable from "../../common/user-store/file-name-migration.injectable";
|
import userStoreFileNameMigrationInjectable from "../../common/user-store/file-name-migration.injectable";
|
||||||
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../start-main-application/runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import initDefaultUpdateChannelInjectable from "../vars/default-update-channel/init.injectable";
|
import initDefaultUpdateChannelInjectable from "../vars/default-update-channel/init.injectable";
|
||||||
|
|
||||||
const initUserStoreInjectable = getInjectable({
|
const initUserStoreInjectable = getInjectable({
|
||||||
id: "init-user-store",
|
id: "init-user-store",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const userStore = di.inject(userStoreInjectable);
|
const userStore = di.inject(userStoreInjectable);
|
||||||
const userStoreFileNameMigration = di.inject(userStoreFileNameMigrationInjectable);
|
const userStoreFileNameMigration = di.inject(userStoreFileNameMigrationInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: async () => {
|
||||||
await userStoreFileNameMigration();
|
await userStoreFileNameMigration();
|
||||||
userStore.load();
|
userStore.load();
|
||||||
},
|
},
|
||||||
runAfter: initDefaultUpdateChannelInjectable,
|
runAfter: initDefaultUpdateChannelInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,18 +4,20 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import syncThemeFromOperatingSystemInjectable from "../../electron-app/features/sync-theme-from-operating-system.injectable";
|
import syncThemeFromOperatingSystemInjectable from "../../electron-app/features/sync-theme-from-operating-system.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const startSyncingThemeFromOperatingSystemInjectable = getInjectable({
|
const startSyncingThemeFromOperatingSystemInjectable = getInjectable({
|
||||||
id: "start-syncing-theme-from-operating-system",
|
id: "start-syncing-theme-from-operating-system",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const syncTheme = di.inject(syncThemeFromOperatingSystemInjectable);
|
const syncTheme = di.inject(syncThemeFromOperatingSystemInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
syncTheme.start();
|
syncTheme.start();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,19 +3,21 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import electronTrayInjectable from "./electron-tray.injectable";
|
import electronTrayInjectable from "./electron-tray.injectable";
|
||||||
|
|
||||||
const startTrayInjectable = getInjectable({
|
const startTrayInjectable = getInjectable({
|
||||||
id: "start-tray",
|
id: "start-tray",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const electronTray = di.inject(electronTrayInjectable);
|
const electronTray = di.inject(electronTrayInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
electronTray.start();
|
electronTray.start();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,22 +3,25 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import startTrayInjectable from "../electron-tray/start-tray.injectable";
|
import startTrayInjectable from "../electron-tray/start-tray.injectable";
|
||||||
import reactiveTrayMenuIconInjectable from "./reactive.injectable";
|
import reactiveTrayMenuIconInjectable from "./reactive.injectable";
|
||||||
|
|
||||||
const startReactiveTrayMenuIconInjectable = getInjectable({
|
const startReactiveTrayMenuIconInjectable = getInjectable({
|
||||||
id: "start-reactive-tray-menu-icon",
|
id: "start-reactive-tray-menu-icon",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable);
|
const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: "start-reactive-tray-menu-icon",
|
||||||
|
run: () => {
|
||||||
reactiveTrayMenuIcon.start();
|
reactiveTrayMenuIcon.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
runAfter: startTrayInjectable,
|
runAfter: startTrayInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,20 +4,23 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import reactiveTrayMenuItemsInjectable from "./reactive-tray-menu-items.injectable";
|
import reactiveTrayMenuItemsInjectable from "./reactive-tray-menu-items.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import startTrayInjectable from "../electron-tray/start-tray.injectable";
|
import startTrayInjectable from "../electron-tray/start-tray.injectable";
|
||||||
|
|
||||||
const startReactiveTrayMenuItemsInjectable = getInjectable({
|
const startReactiveTrayMenuItemsInjectable = getInjectable({
|
||||||
id: "start-reactive-tray-menu-items",
|
id: "start-reactive-tray-menu-items",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const reactiveTrayMenuItems = di.inject(reactiveTrayMenuItemsInjectable);
|
const reactiveTrayMenuItems = di.inject(reactiveTrayMenuItemsInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
reactiveTrayMenuItems.start();
|
reactiveTrayMenuItems.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
runAfter: startTrayInjectable,
|
runAfter: startTrayInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,15 +6,16 @@ import { getInjectable } from "@ogre-tools/injectable";
|
|||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
||||||
import setLoginItemSettingsInjectable from "../electron-app/features/set-login-item-settings.injectable";
|
import setLoginItemSettingsInjectable from "../electron-app/features/set-login-item-settings.injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
|
||||||
const setupSyncOpenAtLoginWithOsInjectable = getInjectable({
|
const setupSyncOpenAtLoginWithOsInjectable = getInjectable({
|
||||||
id: "setup-sync-open-at-login-with-os",
|
id: "setup-sync-open-at-login-with-os",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const setLoginItemSettings = di.inject(setLoginItemSettingsInjectable);
|
const setLoginItemSettings = di.inject(setLoginItemSettingsInjectable);
|
||||||
const userStore = di.inject(userStoreInjectable);
|
const userStore = di.inject(userStoreInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
reaction(() => userStore.openAtLogin, openAtLogin => {
|
reaction(() => userStore.openAtLogin, openAtLogin => {
|
||||||
setLoginItemSettings({
|
setLoginItemSettings({
|
||||||
openAtLogin,
|
openAtLogin,
|
||||||
@ -25,7 +26,8 @@ const setupSyncOpenAtLoginWithOsInjectable = getInjectable({
|
|||||||
fireImmediately: true,
|
fireImmediately: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -3,22 +3,24 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { onLoadOfApplicationInjectionToken } from "../../../start-main-application/runnable-tokens/phases";
|
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||||
import listeningOnMessageChannelsInjectable from "../../../../common/utils/channel/listening-on-message-channels.injectable";
|
import listeningOnMessageChannelsInjectable from "../../../../common/utils/channel/listening-on-message-channels.injectable";
|
||||||
import listeningOnRequestChannelsInjectable from "./listening-on-request-channels.injectable";
|
import listeningOnRequestChannelsInjectable from "./listening-on-request-channels.injectable";
|
||||||
|
|
||||||
const startListeningOnChannelsInjectable = getInjectable({
|
const startListeningOnChannelsInjectable = getInjectable({
|
||||||
id: "start-listening-on-channels-main",
|
id: "start-listening-on-channels-main",
|
||||||
|
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: () => {
|
|
||||||
const listeningOnMessageChannels = di.inject(listeningOnMessageChannelsInjectable);
|
const listeningOnMessageChannels = di.inject(listeningOnMessageChannelsInjectable);
|
||||||
const listeningOnRequestChannels = di.inject(listeningOnRequestChannelsInjectable);
|
const listeningOnRequestChannels = di.inject(listeningOnRequestChannelsInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
run: () => {
|
||||||
listeningOnMessageChannels.start();
|
listeningOnMessageChannels.start();
|
||||||
listeningOnRequestChannels.start();
|
listeningOnRequestChannels.start();
|
||||||
},
|
},
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
|
||||||
injectionToken: onLoadOfApplicationInjectionToken,
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,18 +3,18 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import buildVersionInjectable from "./build-version.injectable";
|
import buildVersionInjectable from "./build-version.injectable";
|
||||||
|
|
||||||
const initializeBuildVersionInjectable = getInjectable({
|
const initializeBuildVersionInjectable = getInjectable({
|
||||||
id: "initialize-build-version",
|
id: "initialize-build-version",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const buildVersion = di.inject(buildVersionInjectable);
|
const buildVersion = di.inject(buildVersionInjectable);
|
||||||
|
|
||||||
await buildVersion.init();
|
return {
|
||||||
|
run: () => buildVersion.init(),
|
||||||
|
};
|
||||||
},
|
},
|
||||||
}),
|
|
||||||
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -3,20 +3,20 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import initReleaseChannelInjectable from "../release-channel/init.injectable";
|
import initReleaseChannelInjectable from "../release-channel/init.injectable";
|
||||||
import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable";
|
import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable";
|
||||||
|
|
||||||
const initDefaultUpdateChannelInjectable = getInjectable({
|
const initDefaultUpdateChannelInjectable = getInjectable({
|
||||||
id: "init-default-update-channel",
|
id: "init-default-update-channel",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const defaultUpdateChannel = di.inject(defaultUpdateChannelInjectable);
|
const defaultUpdateChannel = di.inject(defaultUpdateChannelInjectable);
|
||||||
|
|
||||||
await defaultUpdateChannel.init();
|
return {
|
||||||
},
|
run: async () => await defaultUpdateChannel.init(),
|
||||||
runAfter: initReleaseChannelInjectable,
|
runAfter: initReleaseChannelInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,19 +4,19 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import releaseChannelInjectable from "../../../common/vars/release-channel.injectable";
|
import releaseChannelInjectable from "../../../common/vars/release-channel.injectable";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import initSemanticBuildVersionInjectable from "../semantic-build-version/init.injectable";
|
import initSemanticBuildVersionInjectable from "../semantic-build-version/init.injectable";
|
||||||
|
|
||||||
const initReleaseChannelInjectable = getInjectable({
|
const initReleaseChannelInjectable = getInjectable({
|
||||||
id: "init-release-channel",
|
id: "init-release-channel",
|
||||||
instantiate: (di) => ({
|
instantiate: (di) => {
|
||||||
run: async () => {
|
|
||||||
const releaseChannel = di.inject(releaseChannelInjectable);
|
const releaseChannel = di.inject(releaseChannelInjectable);
|
||||||
|
|
||||||
await releaseChannel.init();
|
return {
|
||||||
},
|
run: async () => await releaseChannel.init(),
|
||||||
runAfter: initSemanticBuildVersionInjectable,
|
runAfter: initSemanticBuildVersionInjectable,
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,18 +4,16 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import buildSemanticVersionInjectable from "../../../common/vars/build-semantic-version.injectable";
|
import buildSemanticVersionInjectable from "../../../common/vars/build-semantic-version.injectable";
|
||||||
import { beforeApplicationIsLoadingInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||||
import initializeBuildVersionInjectable from "../build-version/init.injectable";
|
import initializeBuildVersionInjectable from "../build-version/init.injectable";
|
||||||
|
|
||||||
const initSemanticBuildVersionInjectable = getInjectable({
|
const initSemanticBuildVersionInjectable = getInjectable({
|
||||||
id: "init-semantic-build-version",
|
id: "init-semantic-build-version",
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
return {
|
|
||||||
run: async () => {
|
|
||||||
const buildSemanticVersion = di.inject(buildSemanticVersionInjectable);
|
const buildSemanticVersion = di.inject(buildSemanticVersionInjectable);
|
||||||
|
|
||||||
await buildSemanticVersion.init();
|
return {
|
||||||
},
|
run: () => buildSemanticVersion.init(),
|
||||||
runAfter: initializeBuildVersionInjectable,
|
runAfter: initializeBuildVersionInjectable,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getGlobalOverride } from "../common/test-utils/get-global-override";
|
||||||
|
import bootstrapInjectable from "./bootstrap.injectable";
|
||||||
|
|
||||||
|
export default getGlobalOverride(bootstrapInjectable, () => ({
|
||||||
|
run: () => {},
|
||||||
|
}));
|
||||||
28
packages/core/src/renderer/bootstrap.injectable.ts
Normal file
28
packages/core/src/renderer/bootstrap.injectable.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* 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 {
|
||||||
|
afterApplicationIsLoadedInjectionToken,
|
||||||
|
} from "@k8slens/application";
|
||||||
|
import { bootstrap } from "./bootstrap";
|
||||||
|
import startFrameInjectable from "./start-frame/start-frame.injectable";
|
||||||
|
|
||||||
|
const bootstrapInjectable = getInjectable({
|
||||||
|
id: "bootstrap",
|
||||||
|
|
||||||
|
instantiate: (di) => ({
|
||||||
|
run: async () => {
|
||||||
|
await bootstrap(di);
|
||||||
|
},
|
||||||
|
|
||||||
|
runAfter: di.inject(startFrameInjectable),
|
||||||
|
}),
|
||||||
|
|
||||||
|
causesSideEffects: true,
|
||||||
|
|
||||||
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default bootstrapInjectable;
|
||||||
@ -9,7 +9,9 @@ import React from "react";
|
|||||||
import { render, unmountComponentAtNode } from "react-dom";
|
import { render, unmountComponentAtNode } from "react-dom";
|
||||||
import { DefaultProps } from "./mui-base-theme";
|
import { DefaultProps } from "./mui-base-theme";
|
||||||
import { DiContextProvider } from "@ogre-tools/injectable-react";
|
import { DiContextProvider } from "@ogre-tools/injectable-react";
|
||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type {
|
||||||
|
DiContainerForInjection,
|
||||||
|
} from "@ogre-tools/injectable";
|
||||||
import extensionLoaderInjectable from "../extensions/extension-loader/extension-loader.injectable";
|
import extensionLoaderInjectable from "../extensions/extension-loader/extension-loader.injectable";
|
||||||
import extensionDiscoveryInjectable from "../extensions/extension-discovery/extension-discovery.injectable";
|
import extensionDiscoveryInjectable from "../extensions/extension-discovery/extension-discovery.injectable";
|
||||||
import extensionInstallationStateStoreInjectable from "../extensions/extension-installation-state-store/extension-installation-state-store.injectable";
|
import extensionInstallationStateStoreInjectable from "../extensions/extension-installation-state-store/extension-installation-state-store.injectable";
|
||||||
@ -18,13 +20,8 @@ import initClusterFrameInjectable from "./frames/cluster-frame/init-cluster-fram
|
|||||||
import { Router } from "react-router";
|
import { Router } from "react-router";
|
||||||
import historyInjectable from "./navigation/history.injectable";
|
import historyInjectable from "./navigation/history.injectable";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import startFrameInjectable from "./start-frame/start-frame.injectable";
|
|
||||||
|
|
||||||
export async function bootstrap(di: DiContainer) {
|
|
||||||
const startFrame = di.inject(startFrameInjectable);
|
|
||||||
|
|
||||||
await startFrame();
|
|
||||||
|
|
||||||
|
export async function bootstrap(di: DiContainerForInjection) {
|
||||||
const rootElem = document.getElementById("app");
|
const rootElem = document.getElementById("app");
|
||||||
|
|
||||||
assert(rootElem, "#app MUST exist");
|
assert(rootElem, "#app MUST exist");
|
||||||
|
|||||||
@ -23,8 +23,6 @@ import type { NavigateToHelmCharts } from "../../../common/front-end-routing/rou
|
|||||||
import navigateToHelmChartsInjectable from "../../../common/front-end-routing/routes/cluster/helm/charts/navigate-to-helm-charts.injectable";
|
import navigateToHelmChartsInjectable from "../../../common/front-end-routing/routes/cluster/helm/charts/navigate-to-helm-charts.injectable";
|
||||||
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
|
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
|
||||||
import type { Cluster } from "../../../common/cluster/cluster";
|
import type { Cluster } from "../../../common/cluster/cluster";
|
||||||
import startMainApplicationInjectable from "../../../main/start-main-application/start-main-application.injectable";
|
|
||||||
import startFrameInjectable from "../../start-frame/start-frame.injectable";
|
|
||||||
import type { NamespaceStore } from "../+namespaces/store";
|
import type { NamespaceStore } from "../+namespaces/store";
|
||||||
import historyInjectable from "../../navigation/history.injectable";
|
import historyInjectable from "../../navigation/history.injectable";
|
||||||
import type { MinimalTrayMenuItem } from "../../../main/tray/electron-tray/electron-tray.injectable";
|
import type { MinimalTrayMenuItem } from "../../../main/tray/electron-tray/electron-tray.injectable";
|
||||||
@ -69,6 +67,16 @@ import fsInjectable from "../../../common/fs/fs.injectable";
|
|||||||
import joinPathsInjectable from "../../../common/path/join-paths.injectable";
|
import joinPathsInjectable from "../../../common/path/join-paths.injectable";
|
||||||
import homeDirectoryPathInjectable from "../../../common/os/home-directory-path.injectable";
|
import homeDirectoryPathInjectable from "../../../common/os/home-directory-path.injectable";
|
||||||
import { testUsingFakeTime } from "@k8slens/test-utils";
|
import { testUsingFakeTime } from "@k8slens/test-utils";
|
||||||
|
import { registerFeature } from "@k8slens/feature-core";
|
||||||
|
import {
|
||||||
|
applicationFeatureForElectronMain,
|
||||||
|
testUtils as applicationForElectronTestUtils,
|
||||||
|
} from "@k8slens/application-for-electron-main";
|
||||||
|
import {
|
||||||
|
applicationFeature,
|
||||||
|
startApplicationInjectionToken,
|
||||||
|
} from "@k8slens/application";
|
||||||
|
|
||||||
|
|
||||||
type Callback = (di: DiContainer) => void | Promise<void>;
|
type Callback = (di: DiContainer) => void | Promise<void>;
|
||||||
|
|
||||||
@ -165,9 +173,17 @@ export const getApplicationBuilder = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
|
registerFeature(
|
||||||
|
mainDi,
|
||||||
|
applicationFeature,
|
||||||
|
applicationFeatureForElectronMain,
|
||||||
|
);
|
||||||
|
|
||||||
mainDi.register(mainExtensionsStateInjectable);
|
mainDi.register(mainExtensionsStateInjectable);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
applicationForElectronTestUtils.overrideSideEffectsWithFakes(mainDi);
|
||||||
|
|
||||||
testUsingFakeTime();
|
testUsingFakeTime();
|
||||||
|
|
||||||
const { overrideForWindow, sendToWindow } = overrideChannels(mainDi);
|
const { overrideForWindow, sendToWindow } = overrideChannels(mainDi);
|
||||||
@ -226,6 +242,11 @@ export const getApplicationBuilder = () => {
|
|||||||
overrideFsWithFakes(windowDi);
|
overrideFsWithFakes(windowDi);
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
|
registerFeature(
|
||||||
|
windowDi,
|
||||||
|
applicationFeature,
|
||||||
|
);
|
||||||
|
|
||||||
windowDi.register(rendererExtensionsStateInjectable);
|
windowDi.register(rendererExtensionsStateInjectable);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -253,9 +274,9 @@ export const getApplicationBuilder = () => {
|
|||||||
await callback(windowDi);
|
await callback(windowDi);
|
||||||
}
|
}
|
||||||
|
|
||||||
const startFrame = windowDi.inject(startFrameInjectable);
|
const startApplication = windowDi.inject(startApplicationInjectionToken);
|
||||||
|
|
||||||
await startFrame();
|
await startApplication();
|
||||||
|
|
||||||
for (const callback of afterWindowStartCallbacks) {
|
for (const callback of afterWindowStartCallbacks) {
|
||||||
await callback(windowDi);
|
await callback(windowDi);
|
||||||
@ -289,9 +310,9 @@ export const getApplicationBuilder = () => {
|
|||||||
const namespaces = observable.set<string>();
|
const namespaces = observable.set<string>();
|
||||||
const namespaceItems = observable.array<Namespace>();
|
const namespaceItems = observable.array<Namespace>();
|
||||||
const selectedNamespaces = observable.set<string>();
|
const selectedNamespaces = observable.set<string>();
|
||||||
const startMainApplication = mainDi.inject(startMainApplicationInjectable);
|
const startApplication = mainDi.inject(startApplicationInjectionToken);
|
||||||
|
|
||||||
const startApplication = async ({ shouldStartHidden }: { shouldStartHidden: boolean }) => {
|
const startApp = async ({ shouldStartHidden }: { shouldStartHidden: boolean }) => {
|
||||||
mainDi.inject(lensProxyPortInjectable).set(42);
|
mainDi.inject(lensProxyPortInjectable).set(42);
|
||||||
|
|
||||||
for (const callback of beforeApplicationStartCallbacks) {
|
for (const callback of beforeApplicationStartCallbacks) {
|
||||||
@ -299,7 +320,7 @@ export const getApplicationBuilder = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainDi.override(shouldStartHiddenInjectable, () => shouldStartHidden);
|
mainDi.override(shouldStartHiddenInjectable, () => shouldStartHidden);
|
||||||
await startMainApplication();
|
await startApplication();
|
||||||
|
|
||||||
for (const callback of afterApplicationStartCallbacks) {
|
for (const callback of afterApplicationStartCallbacks) {
|
||||||
await callback(mainDi);
|
await callback(mainDi);
|
||||||
@ -671,11 +692,11 @@ export const getApplicationBuilder = () => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
startHidden: async () => {
|
startHidden: async () => {
|
||||||
await startApplication({ shouldStartHidden: true });
|
await startApp({ shouldStartHidden: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
async render() {
|
async render() {
|
||||||
await startApplication({ shouldStartHidden: false });
|
await startApp({ shouldStartHidden: false });
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
.applicationWindow
|
.applicationWindow
|
||||||
|
|||||||
@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import "./components/app.scss";
|
|
||||||
|
|
||||||
import { bootstrap } from "./bootstrap";
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import nodeEnvInjectionToken from "../common/vars/node-env-injection-token";
|
|
||||||
import { runInAction } from "mobx";
|
|
||||||
import { registerInjectables } from "./register-injectables";
|
|
||||||
import type { CreateApplication } from "../common/create-app";
|
|
||||||
import { getDi } from "./getDi";
|
|
||||||
|
|
||||||
export const createApplication: CreateApplication = (config) => {
|
|
||||||
const { mode } = config;
|
|
||||||
const di = getDi();
|
|
||||||
|
|
||||||
runInAction(() => {
|
|
||||||
di.register(getInjectable({
|
|
||||||
id: "node-env",
|
|
||||||
instantiate: () => mode,
|
|
||||||
injectionToken: nodeEnvInjectionToken,
|
|
||||||
}));
|
|
||||||
|
|
||||||
registerInjectables(di);
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
start: () => bootstrap(di),
|
|
||||||
di,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { createContainer } from "@ogre-tools/injectable";
|
|
||||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
|
||||||
import { registerInjectableReact } from "@ogre-tools/injectable-react";
|
|
||||||
import { setLegacyGlobalDiForExtensionApi } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
|
||||||
|
|
||||||
export const getDi = () => {
|
|
||||||
const environment = "renderer";
|
|
||||||
const di = createContainer(environment);
|
|
||||||
|
|
||||||
registerMobX(di);
|
|
||||||
registerInjectableReact(di);
|
|
||||||
setLegacyGlobalDiForExtensionApi(di, environment);
|
|
||||||
|
|
||||||
return di;
|
|
||||||
};
|
|
||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { noop, chunk } from "lodash/fp";
|
import { noop, chunk } from "lodash/fp";
|
||||||
import { isInjectable } from "@ogre-tools/injectable";
|
import { createContainer, isInjectable } from "@ogre-tools/injectable";
|
||||||
import requestFromChannelInjectable from "./utils/channel/request-from-channel.injectable";
|
import requestFromChannelInjectable from "./utils/channel/request-from-channel.injectable";
|
||||||
import { getOverrideFsWithFakes } from "../test-utils/override-fs-with-fakes";
|
import { getOverrideFsWithFakes } from "../test-utils/override-fs-with-fakes";
|
||||||
import terminalSpawningPoolInjectable from "./components/dock/terminal/terminal-spawning-pool.injectable";
|
import terminalSpawningPoolInjectable from "./components/dock/terminal/terminal-spawning-pool.injectable";
|
||||||
@ -15,14 +15,26 @@ import startTopbarStateSyncInjectable from "./components/layout/top-bar/start-st
|
|||||||
import watchHistoryStateInjectable from "./remote-helpers/watch-history-state.injectable";
|
import watchHistoryStateInjectable from "./remote-helpers/watch-history-state.injectable";
|
||||||
import legacyOnChannelListenInjectable from "./ipc/legacy-channel-listen.injectable";
|
import legacyOnChannelListenInjectable from "./ipc/legacy-channel-listen.injectable";
|
||||||
import type { GlobalOverride } from "@k8slens/test-utils";
|
import type { GlobalOverride } from "@k8slens/test-utils";
|
||||||
import { getDi } from "./getDi";
|
|
||||||
|
import {
|
||||||
|
setLegacyGlobalDiForExtensionApi,
|
||||||
|
} from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
|
import {
|
||||||
|
registerMobX,
|
||||||
|
} from "@ogre-tools/injectable-extension-for-mobx";
|
||||||
|
import { registerInjectableReact } from "@ogre-tools/injectable-react";
|
||||||
|
|
||||||
export const getDiForUnitTesting = (
|
export const getDiForUnitTesting = (
|
||||||
opts: { doGeneralOverrides?: boolean } = {},
|
opts: { doGeneralOverrides?: boolean } = {},
|
||||||
) => {
|
) => {
|
||||||
const { doGeneralOverrides = false } = opts;
|
const { doGeneralOverrides = false } = opts;
|
||||||
|
|
||||||
const di = getDi();
|
const environment = "renderer";
|
||||||
|
const di = createContainer(environment);
|
||||||
|
|
||||||
|
registerMobX(di);
|
||||||
|
registerInjectableReact(di);
|
||||||
|
setLegacyGlobalDiForExtensionApi(di, environment);
|
||||||
|
|
||||||
di.preventSideEffects();
|
di.preventSideEffects();
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,12 @@ import React from "react";
|
|||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
|
|
||||||
// @experimental
|
// @experimental
|
||||||
|
export type {
|
||||||
|
Environments,
|
||||||
|
} from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
|
|
||||||
|
export { nodeEnvInjectionToken } from "../common/vars/node-env-injection-token";
|
||||||
|
export { registerLensCore } from "./register-lens-core";
|
||||||
export { React, ReactDOM };
|
export { React, ReactDOM };
|
||||||
export * as Mobx from "mobx";
|
export * as Mobx from "mobx";
|
||||||
export * as MobxReact from "mobx-react";
|
export * as MobxReact from "mobx-react";
|
||||||
@ -14,5 +20,3 @@ export * as ReactRouter from "react-router";
|
|||||||
export * as ReactRouterDom from "react-router-dom";
|
export * as ReactRouterDom from "react-router-dom";
|
||||||
export * as rendererExtensionApi from "../extensions/renderer-api";
|
export * as rendererExtensionApi from "../extensions/renderer-api";
|
||||||
export * as commonExtensionApi from "../extensions/common-api";
|
export * as commonExtensionApi from "../extensions/common-api";
|
||||||
export { createApplication } from "./create-app";
|
|
||||||
export type { CreateApplication, Application, ApplicationConfig } from "../common/create-app";
|
|
||||||
|
|||||||
@ -2,19 +2,28 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
|
import type {
|
||||||
|
Environments,
|
||||||
|
} from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
|
import {
|
||||||
|
setLegacyGlobalDiForExtensionApi,
|
||||||
|
} from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
|
|
||||||
|
export function registerLensCore(di: DiContainer, environment: Environments) {
|
||||||
|
setLegacyGlobalDiForExtensionApi(di, environment);
|
||||||
|
|
||||||
export function registerInjectables(di: DiContainer) {
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
autoRegister({
|
autoRegister({
|
||||||
di,
|
di,
|
||||||
targetModule: module,
|
targetModule: module,
|
||||||
getRequireContexts: () => [
|
getRequireContexts: () => [
|
||||||
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||||
require.context("../extensions", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
|
||||||
require.context("../common", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
require.context("../common", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||||
|
require.context("../extensions", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||||
require.context("../features", true, CONTEXT_MATCHER_FOR_FEATURES),
|
require.context("../features", true, CONTEXT_MATCHER_FOR_FEATURES),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -6,11 +6,13 @@ import { getInjectable } from "@ogre-tools/injectable";
|
|||||||
import { runManyFor } from "@k8slens/run-many";
|
import { runManyFor } from "@k8slens/run-many";
|
||||||
import * as tokens from "../before-frame-starts/tokens";
|
import * as tokens from "../before-frame-starts/tokens";
|
||||||
import currentlyInClusterFrameInjectable from "../routes/currently-in-cluster-frame.injectable";
|
import currentlyInClusterFrameInjectable from "../routes/currently-in-cluster-frame.injectable";
|
||||||
|
import {
|
||||||
|
afterApplicationIsLoadedInjectionToken,
|
||||||
|
} from "@k8slens/application";
|
||||||
|
|
||||||
const startFrameInjectable = getInjectable({
|
const startFrameInjectable = getInjectable({
|
||||||
id: "start-frame",
|
id: "start-frame",
|
||||||
|
|
||||||
// TODO: Consolidate contents of bootstrap.tsx here
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const runMany = runManyFor(di);
|
const runMany = runManyFor(di);
|
||||||
const beforeFrameStartsFirst = runMany(tokens.beforeFrameStartsFirstInjectionToken);
|
const beforeFrameStartsFirst = runMany(tokens.beforeFrameStartsFirstInjectionToken);
|
||||||
@ -21,7 +23,8 @@ const startFrameInjectable = getInjectable({
|
|||||||
const beforeClusterFrameStartsSecond = runMany(tokens.beforeClusterFrameStartsSecondInjectionToken);
|
const beforeClusterFrameStartsSecond = runMany(tokens.beforeClusterFrameStartsSecondInjectionToken);
|
||||||
const currentlyInClusterFrame = di.inject(currentlyInClusterFrameInjectable);
|
const currentlyInClusterFrame = di.inject(currentlyInClusterFrameInjectable);
|
||||||
|
|
||||||
return async () => {
|
return {
|
||||||
|
run: async () => {
|
||||||
await beforeFrameStartsFirst();
|
await beforeFrameStartsFirst();
|
||||||
|
|
||||||
if (currentlyInClusterFrame) {
|
if (currentlyInClusterFrame) {
|
||||||
@ -37,8 +40,11 @@ const startFrameInjectable = getInjectable({
|
|||||||
} else {
|
} else {
|
||||||
await beforeMainFrameStartsSecond();
|
await beforeMainFrameStartsSecond();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default startFrameInjectable;
|
export default startFrameInjectable;
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@swc/cli": "^0.1.61",
|
"@swc/cli": "^0.1.61",
|
||||||
"@swc/core": "^1.3.35",
|
"@swc/core": "^1.3.37",
|
||||||
"@types/cli-progress": "^3.11.0",
|
"@types/cli-progress": "^3.11.0",
|
||||||
"@types/gunzip-maybe": "^1.4.0",
|
"@types/gunzip-maybe": "^1.4.0",
|
||||||
"@types/node": "^16.18.11",
|
"@types/node": "^16.18.11",
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
"style-loader": "^3.3.1",
|
"style-loader": "^3.3.1",
|
||||||
"ts-loader": "^9.4.2",
|
"ts-loader": "^9.4.2",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
|
"typed-emitter": "^2.1.0",
|
||||||
"typedoc": "0.23.25",
|
"typedoc": "0.23.25",
|
||||||
"typedoc-plugin-markdown": "^3.13.6",
|
"typedoc-plugin-markdown": "^3.13.6",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@swc/cli": "^0.1.61",
|
"@swc/cli": "^0.1.61",
|
||||||
"@swc/core": "^1.3.35",
|
"@swc/core": "^1.3.37",
|
||||||
"@types/jsdom": "^20.0.1",
|
"@types/jsdom": "^20.0.1",
|
||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.11.18",
|
||||||
"@types/sharp": "^0.31.1",
|
"@types/sharp": "^0.31.1",
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://github.com/lensapp/lens",
|
"homepage": "https://github.com/lensapp/lens",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@swc/core": "^1.3.20",
|
"@swc/core": "^1.3.37",
|
||||||
"@swc/jest": "^0.2.23",
|
"@swc/jest": "^0.2.23",
|
||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
|
|||||||
@ -196,17 +196,20 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@k8slens/application": "^6.5.0-alpha.0",
|
"@k8slens/application": "^6.5.0-alpha.0",
|
||||||
|
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||||
|
"@k8slens/application-for-electron-main": "^6.5.0-alpha.0",
|
||||||
"@k8slens/core": "^6.5.0-alpha.0",
|
"@k8slens/core": "^6.5.0-alpha.0",
|
||||||
"@k8slens/ensure-binaries": "^6.5.0-alpha.0",
|
"@k8slens/ensure-binaries": "^6.5.0-alpha.0",
|
||||||
"@k8slens/generate-tray-icons": "^6.5.0-alpha.0",
|
"@k8slens/generate-tray-icons": "^6.5.0-alpha.0",
|
||||||
"@k8slens/run-many": "^1.0.0",
|
"@k8slens/run-many": "^1.0.0",
|
||||||
"@k8slens/test-utils": "^1.0.0",
|
"@k8slens/test-utils": "^1.0.0",
|
||||||
"@k8slens/utilities": "^1.0.0",
|
"@k8slens/utilities": "^1.0.0",
|
||||||
"@ogre-tools/fp": "^15.1.1",
|
"@ogre-tools/fp": "^15.1.2",
|
||||||
"@ogre-tools/injectable": "^15.1.1",
|
"@ogre-tools/injectable": "^15.1.2",
|
||||||
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.1",
|
"@ogre-tools/injectable-extension-for-auto-registration": "^15.1.2",
|
||||||
"@ogre-tools/injectable-extension-for-mobx": "^15.1.1",
|
"@ogre-tools/injectable-extension-for-mobx": "^15.1.2",
|
||||||
"@ogre-tools/injectable-react": "^15.1.1",
|
"@ogre-tools/injectable-react": "^15.1.2",
|
||||||
|
"@ogre-tools/injectable-utils": "^15.1.2",
|
||||||
"mobx": "^6.8.0",
|
"mobx": "^6.8.0",
|
||||||
"rimraf": "^4.1.2"
|
"rimraf": "^4.1.2"
|
||||||
},
|
},
|
||||||
@ -215,7 +218,7 @@
|
|||||||
"@k8slens/node-fetch": "^6.5.0-alpha.0",
|
"@k8slens/node-fetch": "^6.5.0-alpha.0",
|
||||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
||||||
"@swc/cli": "^0.1.61",
|
"@swc/cli": "^0.1.61",
|
||||||
"@swc/core": "^1.3.35",
|
"@swc/core": "^1.3.37",
|
||||||
"@swc/jest": "^0.2.24",
|
"@swc/jest": "^0.2.24",
|
||||||
"@types/byline": "^4.2.33",
|
"@types/byline": "^4.2.33",
|
||||||
"@types/chart.js": "^2.9.36",
|
"@types/chart.js": "^2.9.36",
|
||||||
|
|||||||
@ -1,15 +1,30 @@
|
|||||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
import { createApplication, mainExtensionApi as Main, commonExtensionApi as Common } from "@k8slens/core/main";
|
import {
|
||||||
|
mainExtensionApi as Main,
|
||||||
|
commonExtensionApi as Common,
|
||||||
|
registerLensCore,
|
||||||
|
} from "@k8slens/core/main";
|
||||||
|
import { createContainer } from "@ogre-tools/injectable";
|
||||||
|
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||||
|
import { registerFeature } from "@k8slens/feature-core";
|
||||||
|
import { applicationFeature, startApplicationInjectionToken } from '@k8slens/application'
|
||||||
|
import { applicationFeatureForElectronMain } from '@k8slens/application-for-electron-main'
|
||||||
|
|
||||||
const app = createApplication({
|
const environment = "main";
|
||||||
mode: process.env.NODE_ENV || "development"
|
|
||||||
});
|
const di = createContainer(environment);
|
||||||
|
|
||||||
|
registerMobX(di);
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
|
registerLensCore(di, environment);
|
||||||
|
|
||||||
|
registerFeature(di, applicationFeature, applicationFeatureForElectronMain);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
autoRegister({
|
autoRegister({
|
||||||
di: app.di,
|
di,
|
||||||
targetModule: module,
|
targetModule: module,
|
||||||
getRequireContexts: () => [
|
getRequireContexts: () => [
|
||||||
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||||
@ -22,7 +37,9 @@ runInAction(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.start().catch((error) => {
|
const startApplication = di.inject(startApplicationInjectionToken);
|
||||||
|
|
||||||
|
startApplication().catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
})
|
})
|
||||||
|
|||||||
8
packages/open-lens/src/main/node-env.injectable.ts
Normal file
8
packages/open-lens/src/main/node-env.injectable.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import { nodeEnvInjectionToken } from "@k8slens/core/main";
|
||||||
|
|
||||||
|
export const nodeEnvInjectable = getInjectable({
|
||||||
|
id: "node-env",
|
||||||
|
instantiate: () => process.env.NODE_ENV || "development",
|
||||||
|
injectionToken: nodeEnvInjectionToken,
|
||||||
|
});
|
||||||
@ -1,15 +1,32 @@
|
|||||||
import "@k8slens/core/styles";
|
import "@k8slens/core/styles";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
import { createApplication, rendererExtensionApi as Renderer, commonExtensionApi as Common } from "@k8slens/core/renderer";
|
import {
|
||||||
|
rendererExtensionApi as Renderer,
|
||||||
|
commonExtensionApi as Common,
|
||||||
|
registerLensCore,
|
||||||
|
} from "@k8slens/core/renderer";
|
||||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||||
|
import { registerFeature } from "@k8slens/feature-core";
|
||||||
|
import {
|
||||||
|
applicationFeature,
|
||||||
|
startApplicationInjectionToken
|
||||||
|
} from "@k8slens/application";
|
||||||
|
import { createContainer } from "@ogre-tools/injectable";
|
||||||
|
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||||
|
import { registerInjectableReact } from "@ogre-tools/injectable-react";
|
||||||
|
|
||||||
const app = createApplication({
|
const environment = "main";
|
||||||
mode: process.env.NODE_ENV || "development"
|
|
||||||
});
|
const di = createContainer(environment);
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
|
registerMobX(di);
|
||||||
|
registerInjectableReact(di);
|
||||||
|
registerLensCore(di, environment);
|
||||||
|
registerFeature(di, applicationFeature);
|
||||||
|
|
||||||
autoRegister({
|
autoRegister({
|
||||||
di: app.di,
|
di,
|
||||||
targetModule: module,
|
targetModule: module,
|
||||||
getRequireContexts: () => [
|
getRequireContexts: () => [
|
||||||
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
|
||||||
@ -18,7 +35,9 @@ runInAction(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.start();
|
const startApplication = di.inject(startApplicationInjectionToken);
|
||||||
|
|
||||||
|
startApplication();
|
||||||
|
|
||||||
export {
|
export {
|
||||||
React,
|
React,
|
||||||
|
|||||||
8
packages/open-lens/src/renderer/node-env.injectable.ts
Normal file
8
packages/open-lens/src/renderer/node-env.injectable.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import { nodeEnvInjectionToken } from "@k8slens/core/renderer";
|
||||||
|
|
||||||
|
export const nodeEnvInjectable = getInjectable({
|
||||||
|
id: "node-env",
|
||||||
|
instantiate: () => process.env.NODE_ENV || "development",
|
||||||
|
injectionToken: nodeEnvInjectionToken,
|
||||||
|
});
|
||||||
@ -14,7 +14,7 @@
|
|||||||
import CopyPlugin from "copy-webpack-plugin";
|
import CopyPlugin from "copy-webpack-plugin";
|
||||||
import type { WebpackPluginInstance } from "webpack";
|
import type { WebpackPluginInstance } from "webpack";
|
||||||
import { DefinePlugin } from "webpack";
|
import { DefinePlugin } from "webpack";
|
||||||
import { assetsFolderName, isDevelopment, rendererDir, buildDir, htmlTemplate, publicPath, sassCommonVars } from "./vars";
|
import { assetsFolderName, isDevelopment, rendererDir, buildDir, htmlTemplate, publicPath } from "./vars";
|
||||||
import { platform } from "process";
|
import { platform } from "process";
|
||||||
|
|
||||||
const renderer: webpack.Configuration = {
|
const renderer: webpack.Configuration = {
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@swc/cli": "^0.1.61",
|
"@swc/cli": "^0.1.61",
|
||||||
"@swc/core": "^1.3.35",
|
"@swc/core": "^1.3.37",
|
||||||
"@types/inquirer": "^9.0.3",
|
"@types/inquirer": "^9.0.3",
|
||||||
"@types/node": "^16.18.11",
|
"@types/node": "^16.18.11",
|
||||||
"@types/semver": "^7.3.13",
|
"@types/semver": "^7.3.13",
|
||||||
|
|||||||
@ -145,6 +145,14 @@ function formatSemverForMilestone(version: SemVer): string {
|
|||||||
return `${version.major}.${version.minor}.${version.patch}`;
|
return `${version.major}.${version.minor}.${version.patch}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatVersionForPickingPrs(version: SemVer): string {
|
||||||
|
if (version.prerelease.length > 0) {
|
||||||
|
return `${version.major}.${version.minor}.${version.patch}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${version.major}.${version.minor}.${version.patch+1}`;
|
||||||
|
}
|
||||||
|
|
||||||
async function createReleaseBranchAndCommit(prBase: string, version: SemVer, prBody: string): Promise<void> {
|
async function createReleaseBranchAndCommit(prBase: string, version: SemVer, prBody: string): Promise<void> {
|
||||||
const prBranch = `release/v${version.format()}`;
|
const prBranch = `release/v${version.format()}`;
|
||||||
|
|
||||||
@ -182,9 +190,10 @@ function sortExtendedGithubPrData(left: ExtendedGithubPrData, right: ExtendedGit
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRelevantPRs(milestone: string, previousReleasedVersion: string): Promise<ExtendedGithubPrData[]> {
|
async function getRelevantPRs(previousReleasedVersion: string): Promise<ExtendedGithubPrData[]> {
|
||||||
console.log("retrieving previous 200 PRs...");
|
console.log("retrieving previous 200 PRs...");
|
||||||
|
|
||||||
|
const milestone = formatVersionForPickingPrs(await getCurrentVersionOfSubPackage("core"));
|
||||||
const getMergedPrsArgs = [
|
const getMergedPrsArgs = [
|
||||||
"gh",
|
"gh",
|
||||||
"pr",
|
"pr",
|
||||||
@ -326,8 +335,7 @@ async function createRelease(): Promise<void> {
|
|||||||
await bumpPackageVersions();
|
await bumpPackageVersions();
|
||||||
}
|
}
|
||||||
|
|
||||||
const prMilestone = formatSemverForMilestone(await getCurrentVersionOfSubPackage("core"));
|
const relevantPrs = await getRelevantPRs(previousReleasedVersion);
|
||||||
const relevantPrs = await getRelevantPRs(prMilestone, previousReleasedVersion);
|
|
||||||
const selectedPrs = await pickRelevantPrs(relevantPrs, isMasterBranch);
|
const selectedPrs = await pickRelevantPrs(relevantPrs, isMasterBranch);
|
||||||
const prBody = formatChangelog(previousReleasedVersion, selectedPrs);
|
const prBody = formatChangelog(previousReleasedVersion, selectedPrs);
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@swc/cli": "^0.1.61",
|
"@swc/cli": "^0.1.61",
|
||||||
"@swc/core": "^1.3.35",
|
"@swc/core": "^1.3.37",
|
||||||
"@types/command-line-args": "^5.2.0",
|
"@types/command-line-args": "^5.2.0",
|
||||||
"@types/node": "^16.18.11",
|
"@types/node": "^16.18.11",
|
||||||
"@types/semver": "^7.3.13",
|
"@types/semver": "^7.3.13",
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
# @k8slens/application
|
|
||||||
|
|
||||||
This package contains stuff related to creating Lens-applications.
|
|
||||||
|
|
||||||
In the beginning it will contain just the injection tokens used to configure the application.
|
|
||||||
|
|
||||||
## Install
|
|
||||||
```bash
|
|
||||||
$ npm install @k8slens/application
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
As of now, this package doesn't do anything alone. It just provides you way to register implementation for contract.
|
|
||||||
|
|
||||||
Future ambition is that all stuff related to how applications are built will be relocated here.
|
|
||||||
|
|
||||||
39
packages/technical-features/application/agnostic/README.md
Normal file
39
packages/technical-features/application/agnostic/README.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# @k8slens/application
|
||||||
|
|
||||||
|
This package contains stuff related to creating Lens-applications.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install @k8slens/application-for-electron-main
|
||||||
|
```
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { applicationFeature, startApplicationInjectionToken } from "@k8slens/application";
|
||||||
|
import { registerFeature } from "@k8slens/feature-core";
|
||||||
|
import { createContainer } from "@ogre-tools/injectable";
|
||||||
|
|
||||||
|
const di = createContainer("some-container");
|
||||||
|
|
||||||
|
registerFeature(di, applicationFeature);
|
||||||
|
|
||||||
|
const startApplication = di.inject(startApplicationInjectionToken);
|
||||||
|
|
||||||
|
startApplication();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
#### Start application
|
||||||
|
`startApplicationInjectionToken`
|
||||||
|
|
||||||
|
Starts the application and calls timeslots in specified order. Check for timeslots for more info.
|
||||||
|
|
||||||
|
## Extendability
|
||||||
|
|
||||||
|
#### Timeslots
|
||||||
|
|
||||||
|
1. `beforeApplicationIsLoadingInjectionToken`
|
||||||
|
2. `onLoadOfApplicationInjectionToken`
|
||||||
|
3. `afterApplicationIsLoadedInjectionToken`
|
||||||
11
packages/technical-features/application/agnostic/index.ts
Normal file
11
packages/technical-features/application/agnostic/index.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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 type { StartApplication } from "./src/start-application/start-application.injectable";
|
||||||
|
export { startApplicationInjectionToken } from "./src/start-application/start-application.injectable";
|
||||||
|
|
||||||
|
export { applicationInformationToken } from "./src/application-information-token";
|
||||||
|
export type { ApplicationInformation } from "./src/application-information-token";
|
||||||
@ -1,2 +1,2 @@
|
|||||||
module.exports =
|
module.exports =
|
||||||
require("@k8slens/jest").monorepoPackageConfig(__dirname).configForReact;
|
require("@k8slens/jest").monorepoPackageConfig(__dirname).configForNode;
|
||||||
@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/lensapp/monorepo.git"
|
"url": "git+https://github.com/lensapp/lens.git"
|
||||||
},
|
},
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@ -29,8 +29,15 @@
|
|||||||
"test": "jest --coverage --runInBand"
|
"test": "jest --coverage --runInBand"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@ogre-tools/fp": "^15.1.1",
|
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||||
"@ogre-tools/injectable": "^15.1.1",
|
"@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"
|
"lodash": "^4.17.15"
|
||||||
|
},
|
||||||
|
|
||||||
|
"devDependencies": {
|
||||||
|
"@async-fn/jest": "^1.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
import { getFeature } from "@k8slens/feature-core";
|
||||||
|
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||||
|
|
||||||
|
export const applicationFeature = getFeature({
|
||||||
|
id: "application",
|
||||||
|
|
||||||
|
register: (di) => {
|
||||||
|
autoRegister({
|
||||||
|
di,
|
||||||
|
targetModule: module,
|
||||||
|
|
||||||
|
getRequireContexts: () => [
|
||||||
|
require.context("./", true, /\.injectable\.(ts|tsx)$/),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
|
export type StartApplication = () => Promise<void>;
|
||||||
|
|
||||||
|
export const startApplicationInjectionToken =
|
||||||
|
getInjectionToken<StartApplication>({
|
||||||
|
id: "start-application-injection-token",
|
||||||
|
});
|
||||||
|
|
||||||
|
const startApplicationInjectable = getInjectable({
|
||||||
|
id: "start-application",
|
||||||
|
|
||||||
|
instantiate: (di): StartApplication => {
|
||||||
|
const runManyAsync = runManyFor(di)
|
||||||
|
|
||||||
|
const beforeApplicationIsLoading = runManyAsync(
|
||||||
|
beforeApplicationIsLoadingInjectionToken
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadOfApplication = runManyAsync(onLoadOfApplicationInjectionToken);
|
||||||
|
|
||||||
|
const afterApplicationIsLoaded = runManyAsync(
|
||||||
|
afterApplicationIsLoadedInjectionToken
|
||||||
|
);
|
||||||
|
|
||||||
|
return async () => {
|
||||||
|
await beforeApplicationIsLoading();
|
||||||
|
|
||||||
|
await onLoadOfApplication();
|
||||||
|
|
||||||
|
await afterApplicationIsLoaded();
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
injectionToken: startApplicationInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default startApplicationInjectable;
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
import {
|
||||||
|
createContainer,
|
||||||
|
DiContainer,
|
||||||
|
getInjectable,
|
||||||
|
} from "@ogre-tools/injectable";
|
||||||
|
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 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;
|
||||||
|
|
||||||
|
let beforeApplicationIsLoadingMock: AsyncFnMock<() => Promise<void>>;
|
||||||
|
let onLoadOfApplicationMock: AsyncFnMock<() => Promise<void>>;
|
||||||
|
let afterApplicationIsLoadedMock: AsyncFnMock<() => Promise<void>>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
di = createContainer("irrelevant");
|
||||||
|
|
||||||
|
registerFeature(di, applicationFeature);
|
||||||
|
|
||||||
|
beforeApplicationIsLoadingMock = asyncFn();
|
||||||
|
onLoadOfApplicationMock = asyncFn();
|
||||||
|
afterApplicationIsLoadedMock = asyncFn();
|
||||||
|
|
||||||
|
const beforeApplicationIsLoadingInjectable = getInjectable({
|
||||||
|
id: "before-application-is-loading",
|
||||||
|
instantiate: () => ({ run: beforeApplicationIsLoadingMock }),
|
||||||
|
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
const onLoadOfApplicationInjectable = getInjectable({
|
||||||
|
id: "on-load-of-application",
|
||||||
|
instantiate: () => ({ run: onLoadOfApplicationMock }),
|
||||||
|
injectionToken: onLoadOfApplicationInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
const afterApplicationIsLoadedInjectable = getInjectable({
|
||||||
|
id: "after-application-is-loaded",
|
||||||
|
instantiate: () => ({ run: afterApplicationIsLoadedMock }),
|
||||||
|
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
di.register(
|
||||||
|
beforeApplicationIsLoadingInjectable,
|
||||||
|
onLoadOfApplicationInjectable,
|
||||||
|
afterApplicationIsLoadedInjectable
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when application is started", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
const startApplication = di.inject(startApplicationInjectionToken);
|
||||||
|
|
||||||
|
startApplication();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("calls runnables registered in before application is loading", () => {
|
||||||
|
expect(beforeApplicationIsLoadingMock).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when runnables in before application is loading resolve", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await beforeApplicationIsLoadingMock.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("calls runnables registered in on load of application", () => {
|
||||||
|
expect(onLoadOfApplicationMock).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("when runnables in before application is loading resolve, calls runnables registered in after load of application", async () => {
|
||||||
|
await onLoadOfApplicationMock.resolve();
|
||||||
|
|
||||||
|
expect(afterApplicationIsLoadedMock).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
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",
|
||||||
|
});
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
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",
|
||||||
|
});
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user