diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 008183693..8a02c4bde 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -75,7 +75,7 @@ services: # │ 🟦 │ APPLICATION CONTAINER(s) │ # ╰──────────────────────────────────────────────────────────────────────────────────╯ - scores: + web-prod: image: name4d/betarena:scores-latest # ╭───── # │ WARNING: diff --git a/.scripts/docker.env.inject.sh b/.scripts/docker.env.inject.sh index d45f656fd..815701612 100644 --- a/.scripts/docker.env.inject.sh +++ b/.scripts/docker.env.inject.sh @@ -16,50 +16,73 @@ # ╰──────────────────────────────────────────────────────────────────────────────────╯ # set -o allexport -# source ./.env +# source ./env/.env.docker.scores # set +o allexport # [🐞] -echo "[docker.env.inject.sh] ENV:" $(env) +echo "[docker.env.inject.sh] ────────────────────────────────────────────────────────────────" +# [🐞] +# echo "[docker.env.inject.sh] ENV:" $(env) +# [🐞] +echo "[docker.env.inject.sh] ENVIROMENT INJECTION 🟨 // START" # ╭───── # │ NOTE: # │ |: Loop through all the environment variables that start with 'VITE_X_[..]' # ╰───── +counter=0 for i in $(env | grep VITE_X_) do + # ╭───── + # │ NOTE: + # │ |: Extract the 'key' and 'value' from the environment variable + # ╰───── key=$(echo $i | cut -d '=' -f 1) value=$(echo $i | cut -d '=' -f 2-) # [🐞] - echo "[docker.env.inject.sh] ASSIGN:" $key=$value + echo "[docker.env.inject.sh] ASSIGN NEW VALUE:" $key = $value + # ╭───── + # │ NOTE: + # │ |: Replace the 'VITE_X_' with 'VITE_' in the global environment variables + # ╰───── key_original=${key/_X_/_} - export $key_original=$value - unset $key # ╭───── # │ NOTE: - # │ |: This will replace all the occurences of the '$key' in: - # │ |: [1] All Files (disabled) + # │ |: Replace ALL occurences of the '$key' in: + # │ |: [1] (disabled) All Files # │ |: [2] All Files with '.js' and '.css' extension + # ┣───── + # │ NOTE: + # │ |: [1] 'gsed' is used instead of 'sed' to support MacOS # ╰───── + value_adjusted=${value/&/\\&} # find /usr/share/nginx/html \ # -type f \ # -exec sed -i "s|${key}|${value}|g" '{}' + # - find /app/build \ + find build \ -type f \ -exec sed \ - -i "s|${key}|${value}|g" '{}' + + -i "s|${key}|${value_adjusted}|g" '{}' + # + + counter=$((counter+1)) done # [🐞] -find /app/build -type f -exec grep -i "VITE_X" {} + | wc -l +echo "[docker.env.inject.sh] ────────────────────────────────────────────────────────────────" +# [🐞] +echo "[docker.env.inject.sh] 'VITE_X_' values remaining" $(find build -type f -exec grep -i "VITE_X" {} + | wc -l) +# [🐞] +echo "[docker.env.inject.sh] 'VITE_X_' values replaced" $counter +# [🐞] +echo "[docker.env.inject.sh] ENVIROMENT INJECTION 🟨 // END" # [🐞] -echo "[docker.env.inject.sh] ENV:" $(env) +# echo "[docker.env.inject.sh] ENV:" $(env) # [🐞] echo "[docker.env.inject.sh] DONE 🟩" \ No newline at end of file diff --git a/Makefile b/Makefile index bbc648dd0..3e639f906 100644 --- a/Makefile +++ b/Makefile @@ -602,7 +602,7 @@ docker-spin-start-production: BUILDKIT_PROGRESS=plain \ docker compose \ -f .docker/docker-compose.yml \ - --env-file .env.docker \ + --env-file env/.env.docker.compose \ up \ --build \ -d \ @@ -629,7 +629,7 @@ docker-spin-start-ngnix: BUILDKIT_PROGRESS=plain \ docker compose \ -f .docker/docker-compose.yml \ - --env-file .env.docker \ + --env-file env/.env.docker.compose \ up \ --build \ -d \ diff --git a/src/lib/components/misc/admin/Admin-Dev-ControlPanel.svelte b/src/lib/components/misc/admin/Admin-Dev-ControlPanel.svelte index 80a2d19f4..a33ba5e02 100644 --- a/src/lib/components/misc/admin/Admin-Dev-ControlPanel.svelte +++ b/src/lib/components/misc/admin/Admin-Dev-ControlPanel.svelte @@ -78,11 +78,6 @@ */ // eslint-disable-next-line no-unused-vars , VIEWPORT_TABLET_INIT: [ number, boolean ] = [ 1160, true ] - /** - * @description - * 📣 target environment being used. - */ // eslint-disable-next-line no-unused-vars - , targetAppEnv: string = import.meta.env.VITE_ENV_TARGET ; // #endregion ➤ 📌 VARIABLES diff --git a/src/lib/components/misc/admin/Admin-Dev-ControlPanelToggleButton.svelte b/src/lib/components/misc/admin/Admin-Dev-ControlPanelToggleButton.svelte index 6f99c579d..b3e63920f 100644 --- a/src/lib/components/misc/admin/Admin-Dev-ControlPanelToggleButton.svelte +++ b/src/lib/components/misc/admin/Admin-Dev-ControlPanelToggleButton.svelte @@ -76,11 +76,6 @@ * @augments EventDispatcher */ , dispatch: EventDispatcher = createEventDispatcher() - /** - * @description - * 📣 target environment being used. - */ // eslint-disable-next-line no-unused-vars - , targetAppEnv: string = import.meta.env.VITE_ENV_TARGET ; let diff --git a/src/lib/constants/instance.ts b/src/lib/constants/instance.ts index a1dd1c2e8..0ec1a69e3 100644 --- a/src/lib/constants/instance.ts +++ b/src/lib/constants/instance.ts @@ -1,36 +1,44 @@ // ╭──────────────────────────────────────────────────────────────────────────────────╮ -// │ 📌 High Order Module Overview │ +// │ 📌 High Order Overview │ // ┣──────────────────────────────────────────────────────────────────────────────────┫ -// │ ➤ Internal Code Format │:│ V.8.0 │ -// │ ➤ Status │:│ 🔒 LOCKED │ -// │ ➤ Author(s) │:│ @migbash │ +// │ ➤ Code Format // V.8.0 │ +// │ ➤ Status // 🔒 LOCKED │ +// │ ➤ Author(s) // @migbash │ +// │ ➤ Maintainer(s) // @migbash │ +// │ ➤ Created on // │ // ┣──────────────────────────────────────────────────────────────────────────────────┫ // │ 📝 Description │ // ┣──────────────────────────────────────────────────────────────────────────────────┫ -// │ Betarena (Module) ││ Instance Variables Definitions │ +// │ BETARENA (Module) +// │ |: // ╰──────────────────────────────────────────────────────────────────────────────────╯ -// #region ➤ 📦 Package Imports - -import { dev } from "$app/environment"; - -// #endregion ➤ 📦 Package Imports - -// [🐞] -// console.log('📦 [scores-lib] :: process.env.VITE_PROD_LOGS', process.env.VITE_PROD_LOGS); +/* eslint-disable prefer-const */ export const /** + * @author + * @migbash + * @summary + * 🟦 HELPER * @description - * - 📝 `LOGS_SHOW_OVERRIDE` flag. `(default=false)` - * - IMPORTANT Turns off all 'debugging' console logs for 'scores'. - * - 📝 overrides (ADMIN) to show logs even in PROD. - * - 📝 Prevents logs display on `deployments`. + * 📝 Dynamic Instance Logic of Enviornment Variables + * @return { boolean | undefined } + * 📤 Retrieve Target instance/configuration value */ - LOGS_SHOW_OVERRIDE = - import.meta.env.VITE_PROD_LOGS == undefined - ? dev - : import.meta.env.VITE_PROD_LOGS == 'false' - ? false - : true + getInstance + = ( + strTargetInstance: 'logging' | undefined + ) => + { + if (strTargetInstance === 'logging') + // import.meta.env.VITE_PROD_LOGS == undefined + // ? dev + // : import.meta.env.VITE_PROD_LOGS == 'false' + // ? false + // : true + return import.meta.env.VITE_PROD_LOGS === 'true'; + ; + return; + } ; diff --git a/src/lib/types/vite.d.ts b/src/lib/types/vite.d.ts index ac05a0ee8..8bd232961 100644 --- a/src/lib/types/vite.d.ts +++ b/src/lib/types/vite.d.ts @@ -2,129 +2,166 @@ interface ImportMetaEnv { + // ╭──────────────────────────────────────────────────────────────────────────────────╮ + // │ 💠 │ MISCELLENOUS │ + // ╰──────────────────────────────────────────────────────────────────────────────────╯ /** * @description - * 📝 Logs Master / Admin override + * 📝 CONFIGURATION + * Console Logs Toggle */ - readonly VITE_PROD_LOGS?: string | undefined; - + readonly VITE_PROD_LOGS?: 'false' | 'true' | undefined; + // ╭──────────────────────────────────────────────────────────────────────────────────╮ + // │ 🔳 │ HASURA │ + // ╰──────────────────────────────────────────────────────────────────────────────────╯ /** * @description - * 📝 Hasura GraphQL `url` + * 📝 SECRET + * Hasura GraphQL `url` */ readonly VITE_HASURA_DB_URL?: string | undefined; /** * @description - * 📝 Hasura WebSocket `url` + * 📝 SECRET + * Hasura WebSocket `url` */ readonly VITE_HASURA_DB_WSS?: string | undefined; /** * @description - * 📝 Hasura Database Access Token + * 📝 SECRET + * Hasura Database Access Token */ readonly VITE_HASURA_DB_TOKEN?: string | undefined; - + // ╭──────────────────────────────────────────────────────────────────────────────────╮ + // │ 🟨 │ FIREBASE │ + // ╰──────────────────────────────────────────────────────────────────────────────────╯ /** * @description - * 📝 Firebase API Key for access to `Firebase Services` + * 📝 SECRET + * Firebase API Key for access to `Firebase Services` */ readonly VITE_FIREBASE_DB_API_KEY?: string | undefined; /** * @description - * 📝 Firebase Authentication Domain + * 📝 SECRET + * Firebase Authentication Domain */ readonly VITE_FIREBASE_DB_AUTH_DOMAIN?: string | undefined; /** * @description - * 📝 Firebase Project Name + * 📝 SECRET + * Firebase Project Name */ readonly VITE_FIREBASE_DB_PROJECT_ID?: string | undefined; /** * @description - * 📝 Firebase Project `url` + * 📝 SECRET + * Firebase Project `url` */ readonly VITE_FIREBASE_DB_DATABASE_URL?: string | undefined; /** * @description - * 📝 Firebase Storage Bucket + * 📝 SECRET + * Firebase Storage Bucket */ readonly VITE_FIREBASE_DB_STORAGE_BUCKET?: string | undefined; /** * @description - * 📝 Firebase Functions Host / Origin + * 📝 SECRET + * Firebase Functions Host / Origin */ readonly VITE_FIREBASE_FUNCTIONS_ORIGIN?: string | undefined; /** * @description - * 📝 Firebase Functions URL [1] + * 📝 SECRET + * Firebase Functions URL [1] */ readonly VITE_DISCORD_OAUTH_URL?: string | undefined; /** * @description - * 📝 Firebase Functions URL [1] + * 📝 SECRET + * Firebase Functions URL [1] */ readonly VITE_FIREBASE_FUNCTIONS_F_0?: string | undefined; /** * @description - * 📝 Firebase Functions URL [2] + * 📝 SECRET + * Firebase Functions URL [2] */ readonly VITE_FIREBASE_FUNCTIONS_F_1?: string | undefined; - + // ╭──────────────────────────────────────────────────────────────────────────────────╮ + // │ 🟥 │ REDIS │ + // ╰──────────────────────────────────────────────────────────────────────────────────╯ /** * @description - * 📝 Redis Database Host + * 📝 SECRET + * Redis Database Host */ readonly VITE_REDIS_HOST?: string | undefined; /** * @description - * 📝 Redis Database Port Access + * 📝 SECRET + * Redis Database Port Access */ readonly VITE_REDIS_PORT?: string | undefined; /** * @description - * 📝 Redis Database Password + * 📝 SECRET + * Redis Database Password */ readonly VITE_REDIS_PASS?: string | undefined; /** * @description - * 📝 Redis Database Number for Scores Data + * 📝 SECRET + * Redis Database Number for Scores Data */ readonly VITE_REDIS_CACHE_DB?: string | undefined; /** * @description - * 📝 Redis Database Number for BullJs + * 📝 SECRET + * Redis Database Number for BullJs */ readonly VITE_REDIS_BULL_DB?: string | undefined; - + // ╭──────────────────────────────────────────────────────────────────────────────────╮ + // │ 🟪 │ SENTRY │ + // ╰──────────────────────────────────────────────────────────────────────────────────╯ /** * @description - * 📝 Sentry `url`. + * 📝 CONFIGURATION + * Sentry `url`. */ readonly VITE_SENTRY_URL?: string | undefined; /** * @description - * 📝 Environment for Sentry (duplicate) + * 📝 CONFIGURATION + * Environment for Sentry (duplicate) */ readonly VITE_SENTRY_ENVIRONMENT?: 'production' | 'development' | 'local'; /** * @description - * 📝 Environment for Sentry + * 📝 CONFIGURATION + * Environment for Sentry */ readonly SENTRY_ENVIRONMENT?: 'production' | 'development' | 'local'; /** * @description - * 📝 Authentication Token for Sentry Actions + * 📝 CONFIGURATION + * Authentication Token for Sentry Actions */ readonly SENTRY_AUTH_TOKEN?: string; /** * @description - * 📝 action of `Sourcemap Upload` for Sentry + * 📝 CONFIGURATION + * action of `Sourcemap Upload` for Sentry */ readonly VITE_SENTRY_UPLOAD_SOURCEMAPS?: string; - + // ╭──────────────────────────────────────────────────────────────────────────────────╮ + // │ 🔳 │ WALLETCONNECT │ + // ╰──────────────────────────────────────────────────────────────────────────────────╯ /** * @description - * 📝 `walletconnect` project env + * 📝 SECRET + * WalletConnect project env */ readonly VITE_WALLETCONNECT_ID?: string } diff --git a/src/lib/utils/debug.ts b/src/lib/utils/debug.ts index 7165ad68c..fb2887730 100644 --- a/src/lib/utils/debug.ts +++ b/src/lib/utils/debug.ts @@ -19,7 +19,7 @@ import * as Sentry from '@sentry/browser'; import { json } from '@sveltejs/kit'; import chalk from 'chalk'; -import { LOGS_SHOW_OVERRIDE } from '$lib/constants/instance.js'; +import { getInstance } from '$lib/constants/instance.js'; // #endregion ➤ 📦 Package Imports @@ -53,13 +53,7 @@ export const const // [🐞] - logPrefix = '🖥️ [scores] ::', - /** - * @description - * - 📣 overrides all individual toggles for show/hide ALL logs. - * - 📣 used for local development override of `logs`. - */ - MASTER_DEBUG_TOGGLE: boolean = true + logPrefix = '🖥️ [scores] ::' ; export const @@ -237,29 +231,7 @@ export function dlog style = 'background: #FF6133; color: black; border-radius: 1.5px; padding: 2.5px 2.5px;'; ; - show = MASTER_DEBUG_TOGGLE && show; - - const - if_M_0: boolean - = (LOGS_SHOW_OVERRIDE && show && style == undefined) - // ╭───── - // │ IMPORTANT - // │ > Force 'authentication' to show in production. - // ╰───── - || (targetLog == AU_W_TAG[0] && AU_W_TAG[1] && style == undefined), - if_M_1: boolean - = (LOGS_SHOW_OVERRIDE && typeof(msg) == 'string' && show && style != undefined) - // ╭───── - // │ IMPORTANT - // │ > Force 'authentication' to show in production. - // ╰───── - || (targetLog == AU_W_TAG[0] && AU_W_TAG[1] && typeof(msg) == 'string' && show && style != undefined) - ; - - if (if_M_0) - console.debug(chalk.hex('#00FFFF')(`🖥️ [scores] :: ${msg}`)); - ; - if (if_M_1) + if (getInstance('logging')) console.debug(chalk.hex('#00FFFF')(`🖥️ [scores] :: ${msg}`)); ; @@ -300,7 +272,7 @@ export function dlogv2 // │ CHECK |:| for showing logs. // ╰───── const if_M_0: boolean - = (LOGS_SHOW_OVERRIDE && show) + = (getInstance('logging') && show) || (groupName.includes(AU_W_TAG[0])) ; if (!if_M_0) return;