move env from constants to SvgInline, cleanup
This commit is contained in:
@@ -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<string, string | undefined> = {
|
||||
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);
|
||||
|
||||
|
||||
@@ -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"];
|
||||
|
||||
@@ -28,12 +28,9 @@ const parsePATsFromEnv = (env) => {
|
||||
* @returns {Record<string, string | undefined>} `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<string, string | undefined>} 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) || [];
|
||||
|
||||
Reference in New Issue
Block a user