From 35e1212c65c6c8666b6f5b8b169eaeacc96688b4 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 11:16:55 -0700 Subject: [PATCH 1/4] make gcp environment variable available to electron main process --- scripts/build-desktop.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/build-desktop.sh b/scripts/build-desktop.sh index 025559dc4671..9b9889ccc802 100755 --- a/scripts/build-desktop.sh +++ b/scripts/build-desktop.sh @@ -13,6 +13,10 @@ else ENV_FILE=".env" fi +if [[ -n $GCP_GEOLOCATION_API_KEY ]]; then + echo "$GCP_GEOLOCATION_API_KEY=" >> ENV_FILE +fi + SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") source "$SCRIPTS_DIR/shellUtils.sh"; From acbdb2af0db11ca756c8d10645e17698bd91cb0c Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 11:48:04 -0700 Subject: [PATCH 2/4] replace or add key --- scripts/build-desktop.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/build-desktop.sh b/scripts/build-desktop.sh index 9b9889ccc802..89af2334ac20 100755 --- a/scripts/build-desktop.sh +++ b/scripts/build-desktop.sh @@ -14,7 +14,13 @@ else fi if [[ -n $GCP_GEOLOCATION_API_KEY ]]; then - echo "$GCP_GEOLOCATION_API_KEY=" >> ENV_FILE + if grep -q "^GCP_GEOLOCATION_API_KEY=" "$ENV_FILE"; then + # Replace the value for the existing key + sed -i "s|^GCP_GEOLOCATION_API_KEY=.*$|GCP_GEOLOCATION_API_KEY=$GCP_GEOLOCATION_API_KEY|g" "$ENV_FILE" + else + # Add the key-value pair to the config file + echo "GCP_GEOLOCATION_API_KEY=$GCP_GEOLOCATION_API_KEY" >> "$ENV_FILE" + fi fi SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") From 8540705d1fe1dce4b890bc65edd2fa7e36c3c58a Mon Sep 17 00:00:00 2001 From: Rory Abraham <47436092+roryabraham@users.noreply.github.com> Date: Mon, 25 Mar 2024 12:06:53 -0700 Subject: [PATCH 3/4] Update scripts/build-desktop.sh Co-authored-by: Rafe Colton --- scripts/build-desktop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-desktop.sh b/scripts/build-desktop.sh index 89af2334ac20..7ce1a53b12e2 100755 --- a/scripts/build-desktop.sh +++ b/scripts/build-desktop.sh @@ -13,7 +13,7 @@ else ENV_FILE=".env" fi -if [[ -n $GCP_GEOLOCATION_API_KEY ]]; then +if [[ -n "$GCP_GEOLOCATION_API_KEY" ]]; then if grep -q "^GCP_GEOLOCATION_API_KEY=" "$ENV_FILE"; then # Replace the value for the existing key sed -i "s|^GCP_GEOLOCATION_API_KEY=.*$|GCP_GEOLOCATION_API_KEY=$GCP_GEOLOCATION_API_KEY|g" "$ENV_FILE" From 9712e22e8cdfd8e166bc4852f84eddb1ddd25eb8 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 12:13:18 -0700 Subject: [PATCH 4/4] Use grep -E, remove unnecessary semicolon --- scripts/build-desktop.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build-desktop.sh b/scripts/build-desktop.sh index 7ce1a53b12e2..efbca35a498c 100755 --- a/scripts/build-desktop.sh +++ b/scripts/build-desktop.sh @@ -14,7 +14,7 @@ else fi if [[ -n "$GCP_GEOLOCATION_API_KEY" ]]; then - if grep -q "^GCP_GEOLOCATION_API_KEY=" "$ENV_FILE"; then + if grep -qE "^GCP_GEOLOCATION_API_KEY=" "$ENV_FILE"; then # Replace the value for the existing key sed -i "s|^GCP_GEOLOCATION_API_KEY=.*$|GCP_GEOLOCATION_API_KEY=$GCP_GEOLOCATION_API_KEY|g" "$ENV_FILE" else @@ -24,7 +24,7 @@ if [[ -n "$GCP_GEOLOCATION_API_KEY" ]]; then fi SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") -source "$SCRIPTS_DIR/shellUtils.sh"; +source "$SCRIPTS_DIR/shellUtils.sh" title "Bundling Desktop js Bundle Using Webpack" info " • ELECTRON_ENV: $ELECTRON_ENV"