Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Centralize web build env access

Manav Rathi3f84000f2051
diff --git a/web/apps/ensu/src/services/app-update.ts b/web/apps/ensu/src/services/app-update.ts
index 8b304f7453..30f017f1c8 100644
--- a/web/apps/ensu/src/services/app-update.ts
+++ b/web/apps/ensu/src/services/app-update.ts
@@ -1,5 +1,6 @@
import { isTauriRuntime } from "@/services/tauri-runtime";
import type { MiniDialogAttributes } from "ente-base/components/MiniDialog";
+import { buildEnvIsProductionBuild } from "ente-base/env";
import log from "ente-base/log";
const oneDay = 24 * 60 * 60 * 1000;
@@ -123,11 +124,7 @@ export const handleManualAppUpdateCheck = async (
};
export const setupAutoAppUpdates = (showMiniDialog: ShowMiniDialog) => {
- if (
- !isTauriRuntime() ||
- process.env.NODE_ENV !== "production" ||
- intervalId
- ) {
+ if (!isTauriRuntime() || !buildEnvIsProductionBuild || intervalId) {
return () => {};
}
diff --git a/web/apps/locker/src/components/LockerSocialFooter.tsx b/web/apps/locker/src/components/LockerSocialFooter.tsx
index 87b76e8d91..d036289271 100644
--- a/web/apps/locker/src/components/LockerSocialFooter.tsx
+++ b/web/apps/locker/src/components/LockerSocialFooter.tsx
@@ -3,6 +3,7 @@ import RedditIcon from "@mui/icons-material/Reddit";
import XIcon from "@mui/icons-material/X";
import YouTubeIcon from "@mui/icons-material/YouTube";
import { IconButton, Stack, Typography } from "@mui/material";
+import { buildEnvGitSHA } from "ente-base/env";
import { t } from "i18next";
import React from "react";
@@ -48,7 +49,7 @@ const socialLinks = [
] as const;
const buildLabel = () => {
- const sha = process.env.gitSHA;
+ const sha = buildEnvGitSHA;
return sha ? `${t("build")} ${sha.slice(0, 7)}` : undefined;
};
diff --git a/web/packages/base/app.ts b/web/packages/base/app.ts
index 76352eb7be..257cdc706e 100644
--- a/web/packages/base/app.ts
+++ b/web/packages/base/app.ts
@@ -1,4 +1,8 @@
-import { buildAppName, buildDesktopAppVersion, buildIsDesktop } from "./env";
+import {
+ buildEnvAppName,
+ buildEnvDesktopAppVersion,
+ buildEnvIsDesktop,
+} from "./env";
export const appNames = [
"accounts",
@@ -36,7 +40,7 @@ export type AppName = (typeof appNames)[number];
* such may be incorrect (e.g. when a new app gets added). So apps should
* dynamically validate and log it once somewhere during init.
*/
-export const appName: AppName = buildAppName as AppName;
+export const appName: AppName = buildEnvAppName as AppName;
/**
* True if we're running in our desktop app.
@@ -51,14 +55,14 @@ export const appName: AppName = buildAppName as AppName;
* positives, it'd need a runtime check of the form
* `navigator.userAgent.includes("Electron")`.
*/
-export const isDesktop = buildIsDesktop;
+export const isDesktop = buildEnvIsDesktop;
/**
* Version of the desktop app.
*
* This is only defined when {@link isDesktop} is true.
*/
-export const desktopAppVersion = buildDesktopAppVersion;
+export const desktopAppVersion = buildEnvDesktopAppVersion;
/**
* Static (English) title for the app.
diff --git a/web/packages/base/env.ts b/web/packages/base/env.ts
index 5ad22bcdb0..ec377acf70 100644
--- a/web/packages/base/env.ts
+++ b/web/packages/base/env.ts
@@ -24,12 +24,13 @@ declare const process: {
* all other commands.
*/
export const isDevBuild = process.env.NODE_ENV == "development";
+export const buildEnvIsProductionBuild = process.env.NODE_ENV == "production";
-export const customAPIEndpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
-export const buildAppName = process.env.appName;
-export const buildIsDesktop = process.env.isDesktop == "1";
-export const buildDesktopAppVersion = process.env.desktopAppVersion;
-export const buildGitSHA = process.env.gitSHA;
+export const buildEnvCustomAPIEndpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
+export const buildEnvAppName = process.env.appName;
+export const buildEnvIsDesktop = process.env.isDesktop == "1";
+export const buildEnvDesktopAppVersion = process.env.desktopAppVersion;
+export const buildEnvGitSHA = process.env.gitSHA;
/**
* `true` if we're running in the default global context (aka the main thread)
diff --git a/web/packages/base/log-web.ts b/web/packages/base/log-web.ts
index 124e04ba9e..fde750fd9c 100644
--- a/web/packages/base/log-web.ts
+++ b/web/packages/base/log-web.ts
@@ -1,4 +1,4 @@
-import { buildGitSHA, isDevBuild } from "ente-base/env";
+import { buildEnvGitSHA, isDevBuild } from "ente-base/env";
import log from "ente-base/log";
import { appName, appNames } from "./app";
@@ -18,7 +18,7 @@ export const logStartupBanner = (userID?: number) => {
);
}
- const sha = buildGitSHA;
+ const sha = buildEnvGitSHA;
const buildID = isDevBuild ? "dev " : sha ? `git ${sha} ` : "";
log.info(`Starting ente-${appName}-web ${buildID}uid ${userID ?? 0}`);
};
diff --git a/web/packages/base/origins.ts b/web/packages/base/origins.ts
index 827c97d4d9..1caae8f133 100644
--- a/web/packages/base/origins.ts
+++ b/web/packages/base/origins.ts
@@ -1,5 +1,5 @@
import { getKVS } from "ente-base/kv";
-import { customAPIEndpoint } from "./env";
+import { buildEnvCustomAPIEndpoint } from "./env";
/**
* Return the origin (scheme, host, port triple) that should be used for making
@@ -56,13 +56,13 @@ export const apiURL = async (
* Otherwise return undefined.
*/
export const customAPIOrigin = async () =>
- (await getKVS("apiOrigin")) ?? customAPIEndpoint ?? undefined;
+ (await getKVS("apiOrigin")) ?? buildEnvCustomAPIEndpoint ?? undefined;
/**
* A static build time constant that is `true` if the API origin has been
* customized through the environment.
*/
-export const isCustomAPIOrigin = !!customAPIEndpoint;
+export const isCustomAPIOrigin = !!buildEnvCustomAPIEndpoint;
/**
* A convenience wrapper over {@link customAPIOrigin} that returns the only the