diff --git a/package.json b/package.json index 016cb3464c..3bbf863063 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,9 @@ "lint:fix": "lerna run lint:fix --stream", "mkdocs:serve-local": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -it -p 8000:8000 -v ${PWD}:/docs mkdocs-serve-local:latest", "mkdocs:verify": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -v ${PWD}:/docs mkdocs-serve-local:latest build --strict", - "test:unit": "lerna run --stream test:unit", + "test:unit": "lerna run --stream test:unit --no-bail", "test:unit:watch": "jest --watch", - "test:integration": "lerna run --stream test:integration", + "test:integration": "lerna run --stream test:integration --no-bail", "bump-version": "lerna version --no-git-tag-version --no-push", "precreate-release-pr": "cd packages/release-tool && npm run build", "create-release-pr": "node packages/release-tool/dist/index.js" diff --git a/packages/core/src/extensions/common-api/app.ts b/packages/core/src/extensions/common-api/app.ts index 9e0c84f4e0..a7b33c35cc 100644 --- a/packages/core/src/extensions/common-api/app.ts +++ b/packages/core/src/extensions/common-api/app.ts @@ -14,6 +14,7 @@ import { buildVersionInjectionToken } from "../../common/vars/build-semantic-ver import { asLegacyGlobalForExtensionApi } from "../as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api"; import enabledExtensionsInjectable from "../../features/extensions/enabled/common/enabled-extensions.injectable"; import userPreferencesStateInjectable from "../../features/user-preferences/common/state.injectable"; +import { lensBuildEnvironmentInjectionToken } from "@k8slens/application"; const userStore = asLegacyGlobalForExtensionApi(userPreferencesStateInjectable); const enabledExtensions = asLegacyGlobalForExtensionApi(enabledExtensionsInjectable); @@ -53,6 +54,11 @@ export const App = { return di.inject(isLinuxInjectable); }, + get lensBuildEnvironment() { + const di = getLegacyGlobalDiForExtensionApi(); + + return di.inject(lensBuildEnvironmentInjectionToken); + }, /** * @deprecated This value is now `""` and is left here for backwards compatibility. */ diff --git a/packages/open-lens/src/common/build-environment.injectable.ts b/packages/open-lens/src/common/build-environment.injectable.ts new file mode 100644 index 0000000000..790b4e3fcb --- /dev/null +++ b/packages/open-lens/src/common/build-environment.injectable.ts @@ -0,0 +1,14 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { lensBuildEnvironmentInjectionToken } from "@k8slens/application"; +import { getInjectable } from "@ogre-tools/injectable"; + +const lensBuildEnvironmentInjectable = getInjectable({ + id: "lens-build-environment", + instantiate: () => "unknown", + injectionToken: lensBuildEnvironmentInjectionToken, +}); + +export default lensBuildEnvironmentInjectable; diff --git a/packages/technical-features/application/agnostic/index.ts b/packages/technical-features/application/agnostic/index.ts index 2e5595a816..fd8c0b4800 100644 --- a/packages/technical-features/application/agnostic/index.ts +++ b/packages/technical-features/application/agnostic/index.ts @@ -7,3 +7,5 @@ export { startApplicationInjectionToken } from "./src/start-application/start-ap export { applicationInformationToken } from "./src/application-information-token.no-coverage"; export type { ApplicationInformation } from "./src/application-information-token.no-coverage"; + +export { lensBuildEnvironmentInjectionToken } from "./src/environment-token"; diff --git a/packages/technical-features/application/agnostic/src/environment-token.test.ts b/packages/technical-features/application/agnostic/src/environment-token.test.ts new file mode 100644 index 0000000000..bece4e0ac7 --- /dev/null +++ b/packages/technical-features/application/agnostic/src/environment-token.test.ts @@ -0,0 +1,22 @@ +import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injectable"; +import { lensBuildEnvironmentInjectionToken } from "./environment-token"; + +describe("environment-token coverage tests", () => { + let di: DiContainer; + + beforeEach(() => { + di = createContainer("irrelevant"); + }); + + it("should be able to specify a build environment", () => { + di.register( + getInjectable({ + id: "some-id", + instantiate: () => "some-value", + injectionToken: lensBuildEnvironmentInjectionToken, + }), + ); + + expect(di.inject(lensBuildEnvironmentInjectionToken)).toBe("some-value"); + }); +}); diff --git a/packages/technical-features/application/agnostic/src/environment-token.ts b/packages/technical-features/application/agnostic/src/environment-token.ts new file mode 100644 index 0000000000..111c45d526 --- /dev/null +++ b/packages/technical-features/application/agnostic/src/environment-token.ts @@ -0,0 +1,9 @@ +/** + * 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"; + +export const lensBuildEnvironmentInjectionToken = getInjectionToken({ + id: "lens-build-environment-token", +});