mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
refactor application-information
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
051cc59401
commit
261b7d763b
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import packageJson from "../../../package.json";
|
import packageJson from "../../../package.json";
|
||||||
import applicationInformationToken from "./application-information-token";
|
import applicationInformationToken from "../../common/vars/application-information-token";
|
||||||
|
|
||||||
const applicationInformationInjectable = getInjectable({
|
const applicationInformationInjectable = getInjectable({
|
||||||
id: "application-information",
|
id: "application-information",
|
||||||
|
|||||||
@ -6,9 +6,8 @@
|
|||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
import type packageJson from "../../../package.json";
|
import type packageJson from "../../../package.json";
|
||||||
|
|
||||||
export type ApplicationInformation = Pick<typeof packageJson, "version" | "productName" | "copyright" | "description" | "name"> & {
|
export type ApplicationInformation = Pick<typeof packageJson, "version" | "config" | "productName" | "copyright" | "description" | "name"> & {
|
||||||
build: Partial<typeof packageJson["build"]> & { publish?: unknown[] };
|
build: Partial<typeof packageJson["build"]> & { publish?: unknown[] };
|
||||||
config: typeof packageJson["config"] & { extensions?: string[] };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const applicationInformationToken = getInjectionToken<ApplicationInformation>({
|
const applicationInformationToken = getInjectionToken<ApplicationInformation>({
|
||||||
|
|||||||
@ -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 applicationInformationToken from "./application-information-token";
|
|
||||||
|
|
||||||
const applicationInformationForTestingInjectable = getInjectable({
|
|
||||||
id: "application-information-for-testing",
|
|
||||||
injectionToken: applicationInformationToken,
|
|
||||||
instantiate: () => ({
|
|
||||||
name: "some-product-name",
|
|
||||||
productName: "some-product-name",
|
|
||||||
version: "6.0.0",
|
|
||||||
build: {},
|
|
||||||
config: {
|
|
||||||
k8sProxyVersion: "0.2.1",
|
|
||||||
bundledKubectlVersion: "1.23.3",
|
|
||||||
bundledHelmVersion: "3.7.2",
|
|
||||||
sentryDsn: "",
|
|
||||||
contentSecurityPolicy: "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:",
|
|
||||||
welcomeRoute: "/welcome",
|
|
||||||
extensions: [],
|
|
||||||
},
|
|
||||||
copyright: "some-copyright-information",
|
|
||||||
description: "some-descriptive-text",
|
|
||||||
}),
|
|
||||||
causesSideEffects: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default applicationInformationForTestingInjectable;
|
|
||||||
@ -71,7 +71,7 @@ import kubectlDownloadingNormalizedArchInjectable from "./kubectl/normalized-arc
|
|||||||
import initializeClusterManagerInjectable from "./cluster/initialize-manager.injectable";
|
import initializeClusterManagerInjectable from "./cluster/initialize-manager.injectable";
|
||||||
import addKubeconfigSyncAsEntitySourceInjectable from "./start-main-application/runnables/kube-config-sync/add-source.injectable";
|
import addKubeconfigSyncAsEntitySourceInjectable from "./start-main-application/runnables/kube-config-sync/add-source.injectable";
|
||||||
import type { GlobalOverride } from "../common/test-utils/get-global-override";
|
import type { GlobalOverride } from "../common/test-utils/get-global-override";
|
||||||
import applicationInformationForTestingInjectable from "../common/vars/application-information.injectable-for-testing";
|
import applicationInformationInjectable from "../common/vars/application-information-injectable";
|
||||||
|
|
||||||
export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) {
|
export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) {
|
||||||
const {
|
const {
|
||||||
@ -94,7 +94,7 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
|
|||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
registerMobX(di);
|
registerMobX(di);
|
||||||
di.register(applicationInformationForTestingInjectable);
|
di.register(applicationInformationInjectable);
|
||||||
|
|
||||||
chunk(100)(injectables).forEach(chunkInjectables => {
|
chunk(100)(injectables).forEach(chunkInjectables => {
|
||||||
di.register(...chunkInjectables);
|
di.register(...chunkInjectables);
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* 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 applicationInformationInjectable from "../../common/vars/application-information-injectable";
|
||||||
|
|
||||||
|
export default getGlobalOverride(applicationInformationInjectable, () => ({
|
||||||
|
name: "some-product-name",
|
||||||
|
productName: "some-product-name",
|
||||||
|
version: "6.0.0",
|
||||||
|
build: {} as any,
|
||||||
|
config: {
|
||||||
|
k8sProxyVersion: "0.2.1",
|
||||||
|
bundledKubectlVersion: "1.23.3",
|
||||||
|
bundledHelmVersion: "3.7.2",
|
||||||
|
sentryDsn: "",
|
||||||
|
contentSecurityPolicy: "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:",
|
||||||
|
welcomeRoute: "/welcome",
|
||||||
|
},
|
||||||
|
copyright: "some-copyright-information",
|
||||||
|
description: "some-descriptive-text",
|
||||||
|
}));
|
||||||
@ -41,7 +41,7 @@ import legacyOnChannelListenInjectable from "./ipc/legacy-channel-listen.injecta
|
|||||||
import storageSaveDelayInjectable from "./utils/create-storage/storage-save-delay.injectable";
|
import storageSaveDelayInjectable from "./utils/create-storage/storage-save-delay.injectable";
|
||||||
import environmentVariablesInjectable from "../common/utils/environment-variables.injectable";
|
import environmentVariablesInjectable from "../common/utils/environment-variables.injectable";
|
||||||
import type { GlobalOverride } from "../common/test-utils/get-global-override";
|
import type { GlobalOverride } from "../common/test-utils/get-global-override";
|
||||||
import applicationInformationForTestingInjectable from "../common/vars/application-information.injectable-for-testing";
|
import applicationInformationInjectable from "../common/vars/application-information-injectable";
|
||||||
|
|
||||||
export const getDiForUnitTesting = (
|
export const getDiForUnitTesting = (
|
||||||
opts: { doGeneralOverrides?: boolean } = {},
|
opts: { doGeneralOverrides?: boolean } = {},
|
||||||
@ -64,8 +64,7 @@ export const getDiForUnitTesting = (
|
|||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
registerMobX(di);
|
registerMobX(di);
|
||||||
|
di.register(applicationInformationInjectable);
|
||||||
di.register(applicationInformationForTestingInjectable);
|
|
||||||
|
|
||||||
chunk(100)(injectables).forEach((chunkInjectables) => {
|
chunk(100)(injectables).forEach((chunkInjectables) => {
|
||||||
di.register(...chunkInjectables);
|
di.register(...chunkInjectables);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user