From b40c4b7915b41050a89e037101e75bd1d1a4cb03 Mon Sep 17 00:00:00 2001 From: martin-mfg <2026226+martin-mfg@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:39:17 +0200 Subject: [PATCH] move env from constants to SvgInline, cleanup --- apps/frontend/src/components/Card/SvgInline.tsx | 9 +++++---- apps/frontend/src/constants.ts | 7 ------- packages/core/src/common/config.js | 4 ---- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/apps/frontend/src/components/Card/SvgInline.tsx b/apps/frontend/src/components/Card/SvgInline.tsx index e4a8ee64..5fd0c9b6 100644 --- a/apps/frontend/src/components/Card/SvgInline.tsx +++ b/apps/frontend/src/components/Card/SvgInline.tsx @@ -14,8 +14,6 @@ import { useUserToken, } from "../../redux/selectors/userSelectors.js"; -import "../../constants.js"; // set process.env before the core package uses it - interface SvgInlineProps { url: string; stage: number; @@ -48,9 +46,12 @@ export function SvgInline(props: SvgInlineProps): JSX.Element { let isCurrent = true; const loadSvg = async () => { - window.process.env.PAT_1 = userToken as string; + const config: Record = { + FETCH_MULTI_PAGE_STARS: "10", + PAT_1: userToken as string, // even if it's null, core's retryer.js sees there is 1 PAT and sets `RETRIES` accordingly + }; // eslint-disable-next-line @typescript-eslint/no-unsafe-call - loadConfigFromEnv(window.process.env); + loadConfigFromEnv(config); setLoaded(false); diff --git a/apps/frontend/src/constants.ts b/apps/frontend/src/constants.ts index e3328ed2..f3baf303 100644 --- a/apps/frontend/src/constants.ts +++ b/apps/frontend/src/constants.ts @@ -17,10 +17,3 @@ export const DEMO_USER = "anuraghazra" as string; export const DEMO_REPO = "anuraghazra/github-readme-stats" as string; export const DEMO_GIST = "bbfce31e0217a3689c8d961a356cb10d" as string; export const DEMO_WAKATIME_USER = "alan" as string; - -window.process = { - env: { - FETCH_MULTI_PAGE_STARS: "10", - PAT_1: "placeholderPAT", // so the backend's retryer.js sees there is 1 PAT and sets `RETRIES` accordingly - }, -} as (typeof window)["process"]; diff --git a/packages/core/src/common/config.js b/packages/core/src/common/config.js index 7b1a50db..32456ce8 100644 --- a/packages/core/src/common/config.js +++ b/packages/core/src/common/config.js @@ -28,12 +28,9 @@ const parsePATsFromEnv = (env) => { * @returns {Record} `process.env` if available, otherwise `{}`. */ const getDefaultEnv = () => { - console.log((typeof process !== "undefined") + " | " + process?.env); if (typeof process !== "undefined" && process?.env) { - console.log("if branch, returning " + JSON.stringify(process.env)); return process.env; } - console.log("else branch"); return {}; }; @@ -63,7 +60,6 @@ let currentConfig; * @param {Record} env Environment variables used to build the runtime config. */ export const loadConfigFromEnv = (env = getDefaultEnv()) => { - console.log("env: " + JSON.stringify(env)); const whitelist = parseCsv(env.WHITELIST); const gistWhitelist = parseCsv(env.GIST_WHITELIST); const excludeRepositories = parseCsv(env.EXCLUDE_REPO) || [];