mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restructure to monorepo (#6907)
* wip: restructure to monorepo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor create-release-pr to a package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * github workflow fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix typo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * add webpack-env types to core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix github workflows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor/fix integration tests Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * lint fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * yarn run dev Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * eslint settings for vscode Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * move templates to right package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * open-lens build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * integration test fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix nx task dependencies Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * use bash shell for unit tests in test workflow Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix test:unit for windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix build:app on windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove ELECTRON_BUILDER_EXTRA_ARGS Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * sync src/ from master Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove Makefile from core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
0066ca4ea2
commit
2657df2293
3321 files changed
+28699
-11447
No files matched your search
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 isDevelopmentInjectable from "./is-development.injectable";
|
||||
import productNameInjectable from "./product-name.injectable";
|
||||
|
||||
const appNameInjectable = getInjectable({
|
||||
id: "app-name",
|
||||
|
||||
instantiate: (di) => {
|
||||
const isDevelopment = di.inject(isDevelopmentInjectable);
|
||||
const productName = di.inject(productNameInjectable);
|
||||
|
||||
return `${productName}${isDevelopment ? "Dev" : ""}`;
|
||||
},
|
||||
});
|
||||
|
||||
export default appNameInjectable;
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 applicationCopyrightInjectable = getInjectable({
|
||||
id: "application-copyright",
|
||||
instantiate: (di) => di.inject(applicationInformationToken).copyright,
|
||||
});
|
||||
|
||||
export default applicationCopyrightInjectable;
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 applicationDescriptionInjectable = getInjectable({
|
||||
id: "application-description",
|
||||
instantiate: (di) => di.inject(applicationInformationToken).description,
|
||||
});
|
||||
|
||||
export default applicationDescriptionInjectable;
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 packageJson from "../../../package.json";
|
||||
import applicationInformationToken from "../../common/vars/application-information-token";
|
||||
|
||||
const applicationInformationInjectable = getInjectable({
|
||||
id: "application-information",
|
||||
injectionToken: applicationInformationToken,
|
||||
instantiate: () => {
|
||||
const { version, config, productName, build, copyright, description, name } = packageJson;
|
||||
|
||||
return { version, config, productName, build, copyright, description, name };
|
||||
},
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default applicationInformationInjectable;
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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 packageJson from "../../../package.json";
|
||||
|
||||
export type ApplicationInformation = Pick<typeof packageJson, "version" | "config" | "productName" | "copyright" | "description" | "name"> & {
|
||||
build: Partial<typeof packageJson["build"]> & { publish?: unknown[] };
|
||||
};
|
||||
|
||||
const applicationInformationToken = getInjectionToken<ApplicationInformation>({
|
||||
id: "application-information-token",
|
||||
});
|
||||
|
||||
export default applicationInformationToken;
|
||||
+24
@@ -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 "../test-utils/get-global-override";
|
||||
import applicationInformationInjectable from "./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",
|
||||
}));
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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 bundledResourcesDirectoryInjectable from "./bundled-resources-dir.injectable";
|
||||
import normalizedPlatformArchitectureInjectable from "./normalized-platform-architecture.injectable";
|
||||
import joinPathsInjectable from "../path/join-paths.injectable";
|
||||
|
||||
const baseBundledBinariesDirectoryInjectable = getInjectable({
|
||||
id: "base-bundled-binaries-directory",
|
||||
instantiate: (di) => {
|
||||
const bundledResourcesDirectory = di.inject(bundledResourcesDirectoryInjectable);
|
||||
const normalizedPlatformArchitecture = di.inject(normalizedPlatformArchitectureInjectable);
|
||||
const joinPaths = di.inject(joinPathsInjectable);
|
||||
|
||||
return joinPaths(
|
||||
bundledResourcesDirectory,
|
||||
normalizedPlatformArchitecture,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
export default baseBundledBinariesDirectoryInjectable;
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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 { SemVer } from "semver";
|
||||
import type { InitializableState } from "../initializable-state/create";
|
||||
import { createInitializableState } from "../initializable-state/create";
|
||||
import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token";
|
||||
|
||||
export const buildVersionInjectionToken = getInjectionToken<InitializableState<string>>({
|
||||
id: "build-version-token",
|
||||
});
|
||||
|
||||
export const buildVersionChannel: RequestChannel<void, string> = {
|
||||
id: "build-version",
|
||||
};
|
||||
|
||||
const buildSemanticVersionInjectable = createInitializableState({
|
||||
id: "build-semantic-version",
|
||||
init: (di) => {
|
||||
const buildVersion = di.inject(buildVersionInjectionToken);
|
||||
|
||||
return new SemVer(buildVersion.get());
|
||||
},
|
||||
});
|
||||
|
||||
export default buildSemanticVersionInjectable;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 bundledKubectlVersionInjectable = getInjectable({
|
||||
id: "bundled-kubectl-version",
|
||||
instantiate: (di) => di.inject(applicationInformationToken).config.bundledKubectlVersion,
|
||||
});
|
||||
|
||||
export default bundledKubectlVersionInjectable;
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 isProductionInjectable from "./is-production.injectable";
|
||||
import normalizedPlatformInjectable from "./normalized-platform.injectable";
|
||||
import lensResourcesDirInjectable from "./lens-resources-dir.injectable";
|
||||
import joinPathsInjectable from "../path/join-paths.injectable";
|
||||
|
||||
const bundledResourcesDirectoryInjectable = getInjectable({
|
||||
id: "bundled-resources-directory",
|
||||
instantiate: (di) => {
|
||||
const isProduction = di.inject(isProductionInjectable);
|
||||
const normalizedPlatform = di.inject(normalizedPlatformInjectable);
|
||||
const joinPaths = di.inject(joinPathsInjectable);
|
||||
const lensResourcesDir = di.inject(lensResourcesDirInjectable);
|
||||
|
||||
return isProduction
|
||||
? lensResourcesDir
|
||||
: joinPaths(lensResourcesDir, "binaries", "client", normalizedPlatform);
|
||||
},
|
||||
});
|
||||
|
||||
export default bundledResourcesDirectoryInjectable;
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 contentSecurityPolicyInjectable = getInjectable({
|
||||
id: "content-security-policy",
|
||||
instantiate: (di) => di.inject(applicationInformationToken).config.contentSecurityPolicy,
|
||||
});
|
||||
|
||||
export default contentSecurityPolicyInjectable;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import extensionApiVersionInjectable from "./extension-api-version.injectable";
|
||||
|
||||
export default getGlobalOverride(extensionApiVersionInjectable, () => "6.0.0");
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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 { SemVer } from "semver";
|
||||
import packageJson from "../../../package.json";
|
||||
|
||||
const extensionApiVersionInjectable = getInjectable({
|
||||
id: "extension-api-version",
|
||||
instantiate: () => {
|
||||
const { major, minor, patch } = new SemVer(packageJson.version);
|
||||
|
||||
return `${major}.${minor}.${patch}`;
|
||||
},
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default extensionApiVersionInjectable;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import isDebuggingInjectable from "./is-debugging.injectable";
|
||||
|
||||
export default getGlobalOverride(isDebuggingInjectable, () => false);
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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";
|
||||
|
||||
const isDebuggingInjectable = getInjectable({
|
||||
id: "is-debugging",
|
||||
instantiate: () => ["true", "1", "yes", "y", "on"].includes((process.env.DEBUG ?? "").toLowerCase()),
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default isDebuggingInjectable;
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 isProductionInjectable from "./is-production.injectable";
|
||||
|
||||
const isDevelopmentInjectable = getInjectable({
|
||||
id: "is-development",
|
||||
instantiate: (di) => !di.inject(isProductionInjectable),
|
||||
});
|
||||
|
||||
export default isDevelopmentInjectable;
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 commandLineArgumentsInjectable from "../../main/utils/command-line-arguments.injectable";
|
||||
|
||||
const isIntegrationTestingInjectable = getInjectable({
|
||||
id: "is-integration-testing",
|
||||
|
||||
instantiate: (di) => {
|
||||
const commandLineArguments = di.inject(commandLineArgumentsInjectable);
|
||||
|
||||
return commandLineArguments.includes("--integration-testing");
|
||||
},
|
||||
});
|
||||
|
||||
export default isIntegrationTestingInjectable;
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 platformInjectable from "./platform.injectable";
|
||||
|
||||
const isLinuxInjectable = getInjectable({
|
||||
id: "is-linux",
|
||||
|
||||
instantiate: (di) => {
|
||||
const platform = di.inject(platformInjectable);
|
||||
|
||||
return platform === "linux";
|
||||
},
|
||||
});
|
||||
|
||||
export default isLinuxInjectable;
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 platformInjectable from "./platform.injectable";
|
||||
|
||||
const isMacInjectable = getInjectable({
|
||||
id: "is-mac",
|
||||
|
||||
instantiate: (di) => {
|
||||
const platform = di.inject(platformInjectable);
|
||||
|
||||
return platform === "darwin";
|
||||
},
|
||||
});
|
||||
|
||||
export default isMacInjectable;
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 nodeEnvInjectionToken from "./node-env-injection-token";
|
||||
|
||||
const isProductionInjectable = getInjectable({
|
||||
id: "is-production",
|
||||
|
||||
instantiate: (di) => {
|
||||
const nodeEnv = di.inject(nodeEnvInjectionToken);
|
||||
|
||||
return nodeEnv === "production";
|
||||
},
|
||||
});
|
||||
|
||||
export default isProductionInjectable;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import isSnapPackageInjectable from "./is-snap-package.injectable";
|
||||
|
||||
export default getGlobalOverride(isSnapPackageInjectable, () => false);
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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";
|
||||
|
||||
const isSnapPackageInjectable = getInjectable({
|
||||
id: "is-snap",
|
||||
instantiate: () => Boolean(process.env.SNAP),
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default isSnapPackageInjectable;
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 platformInjectable from "./platform.injectable";
|
||||
|
||||
const isWindowsInjectable = getInjectable({
|
||||
id: "is-windows",
|
||||
|
||||
instantiate: (di) => {
|
||||
const platform = di.inject(platformInjectable);
|
||||
|
||||
return platform === "win32";
|
||||
},
|
||||
});
|
||||
|
||||
export default isWindowsInjectable;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import lensResourcesDirInjectable from "./lens-resources-dir.injectable";
|
||||
|
||||
export default getGlobalOverride(lensResourcesDirInjectable, () => "/irrelavent-dir-for-lens-resources");
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 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 isProductionInjectable from "./is-production.injectable";
|
||||
|
||||
const lensResourcesDirInjectable = getInjectable({
|
||||
id: "lens-resources-dir",
|
||||
|
||||
instantiate: (di) => {
|
||||
const isProduction = di.inject(isProductionInjectable);
|
||||
|
||||
return isProduction
|
||||
? process.resourcesPath
|
||||
: process.cwd();
|
||||
},
|
||||
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default lensResourcesDirInjectable;
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* 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";
|
||||
|
||||
const nodeEnvInjectionToken = getInjectionToken<string | undefined>({
|
||||
id: "node-env-injection-token",
|
||||
});
|
||||
|
||||
export default nodeEnvInjectionToken;
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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 processArchInjectable from "./process-arch.injectable";
|
||||
|
||||
const normalizedPlatformArchitectureInjectable = getInjectable({
|
||||
id: "normalized-platform-architecture",
|
||||
instantiate: (di) => {
|
||||
const platformArch = di.inject(processArchInjectable);
|
||||
|
||||
switch (platformArch) {
|
||||
case "arm64":
|
||||
return "arm64";
|
||||
case "x64":
|
||||
case "amd64":
|
||||
return "x64";
|
||||
case "386":
|
||||
case "x32":
|
||||
case "ia32":
|
||||
return "ia32";
|
||||
default:
|
||||
throw new Error(`arch=${platformArch} is unsupported`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default normalizedPlatformArchitectureInjectable;
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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 platformInjectable from "./platform.injectable";
|
||||
|
||||
export type NormalizedPlatform = "darwin" | "linux" | "windows";
|
||||
|
||||
const normalizedPlatformInjectable = getInjectable({
|
||||
id: "normalized-platform",
|
||||
|
||||
instantiate: (di): NormalizedPlatform => {
|
||||
const platform = di.inject(platformInjectable);
|
||||
|
||||
switch (platform) {
|
||||
case "darwin":
|
||||
return "darwin";
|
||||
case "linux":
|
||||
return "linux";
|
||||
case "win32":
|
||||
return "windows";
|
||||
default:
|
||||
throw new Error(`platform=${platform} is unsupported`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default normalizedPlatformInjectable;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import platformInjectable from "./platform.injectable";
|
||||
|
||||
export default getGlobalOverride(platformInjectable, () => "darwin");
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 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";
|
||||
|
||||
export const allPlatforms = ["win32", "darwin", "linux"] as const;
|
||||
|
||||
const platformInjectable = getInjectable({
|
||||
id: "platform",
|
||||
instantiate: () => process.platform as typeof allPlatforms[number],
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default platformInjectable;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import processArchInjectable from "./process-arch.injectable";
|
||||
|
||||
export default getGlobalOverride(processArchInjectable, () => "x64");
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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";
|
||||
|
||||
const processArchInjectable = getInjectable({
|
||||
id: "process-arch",
|
||||
instantiate: () => process.arch,
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default processArchInjectable;
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 productNameInjectable = getInjectable({
|
||||
id: "product-name",
|
||||
instantiate: (di) => di.inject(applicationInformationToken).productName,
|
||||
});
|
||||
|
||||
export default productNameInjectable;
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { createInitializableState } from "../initializable-state/create";
|
||||
import buildSemanticVersionInjectable from "./build-semantic-version.injectable";
|
||||
import type { ReleaseChannel } from "../../features/application-update/common/update-channels";
|
||||
|
||||
const releaseChannelInjectable = createInitializableState({
|
||||
id: "release-channel",
|
||||
init: (di): ReleaseChannel => {
|
||||
const buildSemanticVersion = di.inject(buildSemanticVersionInjectable);
|
||||
const currentReleaseChannel = buildSemanticVersion.get().prerelease[0];
|
||||
|
||||
switch (currentReleaseChannel) {
|
||||
case "latest":
|
||||
case "beta":
|
||||
case "alpha":
|
||||
return currentReleaseChannel;
|
||||
default:
|
||||
return "latest";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default releaseChannelInjectable;
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 sentryDataSourceNameInjectable = getInjectable({
|
||||
id: "sentry-data-source-name",
|
||||
instantiate: (di) => di.inject(applicationInformationToken).config.sentryDsn,
|
||||
});
|
||||
|
||||
export default sentryDataSourceNameInjectable;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import staticFilesDirectoryInjectable from "./static-files-directory.injectable";
|
||||
|
||||
export default getGlobalOverride(staticFilesDirectoryInjectable, () => "/some-static-directory");
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 appPathsInjectable from "../app-paths/app-paths.injectable";
|
||||
import joinPathsInjectable from "../path/join-paths.injectable";
|
||||
|
||||
const staticFilesDirectoryInjectable = getInjectable({
|
||||
id: "static-files-directory",
|
||||
|
||||
instantiate: (di) => {
|
||||
const joinPaths = di.inject(joinPathsInjectable);
|
||||
const currentAppDir = di.inject(appPathsInjectable).currentApp;
|
||||
|
||||
return joinPaths(currentAppDir, "static");
|
||||
},
|
||||
});
|
||||
|
||||
export default staticFilesDirectoryInjectable;
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 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 storeMigrationVersionInjectable = getInjectable({
|
||||
id: "store-migration-version",
|
||||
instantiate: (di) => di.inject(applicationInformationToken).version,
|
||||
});
|
||||
|
||||
export default storeMigrationVersionInjectable;
|
||||
Reference in new issue
Block a user