Last active
April 4, 2024 23:33
-
-
Save AhmedAbouelkher/e59cc74c59fd257848aab8d4dc272b51 to your computer and use it in GitHub Desktop.
Revisions
-
AhmedAbouelkher revised this gist
Apr 4, 2024 . 1 changed file with 31 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,50 @@ #!/bin/sh # list all system env variables starting with flutter_ and put them in an array variable values=$(env | grep ^flutter_) # check if values is empty if [ -z "$values" ]; then echo "No environment variables found starting with flutter_" exit 0 fi strippedValues="" # loop through all values and strip the flutter_ prefix for value in $values do # strip the prefix key=$(echo $value | sed 's/^flutter_//') strippedValues="$strippedValues $key" done envString="" # loop through all values and print them for envVariable in $strippedValues do # split key and value by = (for only the first = in the string) key=$(echo $envVariable | cut -d'=' -f1) value=$(echo $envVariable | cut -d'=' -f2-) # check if value is empty if [ -z "$value" ] then echo "No value found for $key" exit 0 fi # if key starts with _secret, then it is a secret and should be decoded from base64 # example _secret_kAPIKey if echo "$key" | grep -q '^secret_'; then value=$(echo $value | base64 --decode) # remove the _secret_ from the key key=$(echo $key | sed 's/secret_//') fi # add the value to the envString line="const String $key = '$value';\n" envString="$envString$line" done # write the envString to the env.dart file echo "$envString" > $(pwd)/lib/env.dart -
AhmedAbouelkher revised this gist
Dec 6, 2023 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,19 +2,21 @@ # list all system env variables starting with flutter_ and put them in a array variable values=$(env | grep ^flutter_) # check if values is empty if [ -z "$values" ] then echo "No environment variables found starting with flutter_" exit 0 fi strippedValues=() # loop through all values and strip the flutter_ prefix for value in $values do # strip the prefix key=$(echo $value | sed 's/^flutter_//') strippedValues+=($key) done envString="" # loop through all values and print them for envVariable in ${strippedValues[@]} do @@ -24,6 +26,5 @@ do # add the value to the envString envString+="const $key = \"${value}\";\n" done # write the envString to the env.dart file echo $envString > lib/env.dart -
AhmedAbouelkher created this gist
Dec 6, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/bin/sh # list all system env variables starting with flutter_ and put them in a array variable values=$(env | grep ^flutter_) strippedValues=() # loop through all values and strip the flutter_ prefix for value in $values do # strip the prefix key=$(echo $value | sed 's/^flutter_//') strippedValues+=($key) done envString="" # loop through all values and print them for envVariable in ${strippedValues[@]} do # split the key and value key=$(echo $envVariable | cut -d '=' -f 1) value=$(echo $envVariable | cut -d '=' -f 2) # add the value to the envString envString+="const $key = \"${value}\";\n" done # write the envString to the env.dart file echo $envString > lib/env.dart