1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Deprecate vars in favor of injectables

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-04-27 10:52:24 +03:00
parent f1e0fd081d
commit 5c31203e50
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
5 changed files with 28 additions and 8 deletions

View File

@ -9,21 +9,43 @@ import { SemVer } from "semver";
import packageInfo from "../../package.json"; import packageInfo from "../../package.json";
import { lazyInitialized } from "./utils/lazy-initialized"; import { lazyInitialized } from "./utils/lazy-initialized";
/**
* @deprecated Switch to using isMacInjectable
*/
export const isMac = process.platform === "darwin"; export const isMac = process.platform === "darwin";
/**
* @deprecated Switch to using isWindowsInjectable
*/
export const isWindows = process.platform === "win32"; export const isWindows = process.platform === "win32";
/**
* @deprecated Switch to using isLinuxInjectable
*/
export const isLinux = process.platform === "linux"; export const isLinux = process.platform === "linux";
export const isDebugging = ["true", "1", "yes", "y", "on"].includes((process.env.DEBUG ?? "").toLowerCase()); export const isDebugging = ["true", "1", "yes", "y", "on"].includes((process.env.DEBUG ?? "").toLowerCase());
export const isSnap = !!process.env.SNAP; export const isSnap = !!process.env.SNAP;
export const isProduction = process.env.NODE_ENV === "production"; export const isProduction = process.env.NODE_ENV === "production";
export const isTestEnv = !!process.env.JEST_WORKER_ID; export const isTestEnv = !!process.env.JEST_WORKER_ID;
/**
* @deprecated Switch to using isDevelopmentInjectable
*/
export const isDevelopment = !isTestEnv && !isProduction; export const isDevelopment = !isTestEnv && !isProduction;
export const isPublishConfigured = Object.keys(packageInfo.build).includes("publish"); export const isPublishConfigured = Object.keys(packageInfo.build).includes("publish");
export const integrationTestingArg = "--integration-testing"; export const integrationTestingArg = "--integration-testing";
export const isIntegrationTesting = process.argv.includes(integrationTestingArg); export const isIntegrationTesting = process.argv.includes(integrationTestingArg);
export const productName = packageInfo.productName; export const productName = packageInfo.productName;
/**
* @deprecated Switch to using appNameInjectable
*/
export const appName = `${packageInfo.productName}${isDevelopment ? "Dev" : ""}`; export const appName = `${packageInfo.productName}${isDevelopment ? "Dev" : ""}`;
export const publicPath = "/build/" as string; export const publicPath = "/build/" as string;
export const defaultTheme = "lens-dark" as string; export const defaultTheme = "lens-dark" as string;
export const defaultFontSize = 12; export const defaultFontSize = 12;

View File

@ -3,11 +3,12 @@
* 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 { isDevelopment } from "../vars"; import { isProduction, isTestEnv } from "../vars";
const isDevelopmentInjectable = getInjectable({ const isDevelopmentInjectable = getInjectable({
id: "is-development", id: "is-development",
instantiate: () => isDevelopment, instantiate: () => !isTestEnv && !isProduction,
causesSideEffects: true,
}); });
export default isDevelopmentInjectable; export default isDevelopmentInjectable;

View File

@ -3,11 +3,10 @@
* 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 { isLinux } from "../vars";
const isLinuxInjectable = getInjectable({ const isLinuxInjectable = getInjectable({
id: "is-linux", id: "is-linux",
instantiate: () => isLinux, instantiate: () => process.platform === "linux",
causesSideEffects: true, causesSideEffects: true,
}); });

View File

@ -3,11 +3,10 @@
* 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 { isMac } from "../vars";
const isMacInjectable = getInjectable({ const isMacInjectable = getInjectable({
id: "is-mac", id: "is-mac",
instantiate: () => isMac, instantiate: () => process.platform === "darwin",
causesSideEffects: true, causesSideEffects: true,
}); });

View File

@ -3,11 +3,10 @@
* 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 { isWindows } from "../vars";
const isWindowsInjectable = getInjectable({ const isWindowsInjectable = getInjectable({
id: "is-windows", id: "is-windows",
instantiate: () => isWindows, instantiate: () => process.platform === "win32",
causesSideEffects: true, causesSideEffects: true,
}); });