Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/workflow-update/draft/4 #2303

Merged
merged 6 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ services:
# │ 🟦 │ APPLICATION CONTAINER(s) │
# ╰──────────────────────────────────────────────────────────────────────────────────╯

scores:
web-prod:
image: name4d/betarena:scores-latest
# ╭─────
# │ WARNING:
Expand Down
45 changes: 34 additions & 11 deletions .scripts/docker.env.inject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 🟩"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down
5 changes: 0 additions & 5 deletions src/lib/components/misc/admin/Admin-Dev-ControlPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
* @augments EventDispatcher
*/
, dispatch: EventDispatcher<any> = createEventDispatcher()
/**
* @description
* 📣 target environment being used.
*/ // eslint-disable-next-line no-unused-vars
, targetAppEnv: string = import.meta.env.VITE_ENV_TARGET
;

let
Expand Down
54 changes: 31 additions & 23 deletions src/lib/constants/instance.ts
Original file line number Diff line number Diff line change
@@ -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 // <date-created> │
// ┣──────────────────────────────────────────────────────────────────────────────────┫
// │ 📝 Description │
// ┣──────────────────────────────────────────────────────────────────────────────────┫
// │ Betarena (Module) ││ Instance Variables Definitions │
// │ BETARENA (Module)
// │ |: <insert-module-summary-here>
// ╰──────────────────────────────────────────────────────────────────────────────────╯

// #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;
}
;
Loading
Loading