Skip to content

Instantly share code, notes, and snippets.

@evanjmg
Created May 21, 2019 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanjmg/75ea011c8312405c9eb983977bb335a9 to your computer and use it in GitHub Desktop.
Save evanjmg/75ea011c8312405c9eb983977bb335a9 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
GREEN='\033[0;32m'
YELLOW='\033[0;93m'
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m'
capitalize_words() {
typeset string string_out
string=$1
string_out=''
read -r -a words <<< "$string"
for word in "${words[@]}"; do
[[ -n "$string_out" ]] && string_out+=" "
first_letter=${word:0:1}
rest=${word:1}
string_out+="$(printf '%s\n' "$first_letter" | tr '[:lower:]' '[:upper:]')"
string_out+="$rest"
done
echo "$string_out"
}
export APP_NAME=$1
export CAPITALIZED_APP_NAME=$(capitalize_words "$APP_NAME")
if [ -z "$ENV" ]
then
ENVIRONMENT_NAME=$2
elif [ "$FIRST_ARG" = "install" ]
then
ENVIRONMENT_NAME="staging"
else
ENVIRONMENT_NAME=$ENV
fi
export BUILD_ENV="$APP_NAME.$ENVIRONMENT_NAME"
export ENVFILE=".env.$APP_NAME.$ENVIRONMENT_NAME"
export CAPITALIZED_ENVIRONMENT_NAME=$(capitalize_words "$ENVIRONMENT_NAME")
export IOS_SCHEME="${CAPITALIZED_APP_NAME}${CAPITALIZED_ENVIRONMENT_NAME}"
echo $ENVFILE > /tmp/envfile
printf "========================================\n"
printf "%-20s | $GREEN%-30s$NC\n" "App Name" "$CAPITALIZED_APP_NAME"
printf "%-20s | $GREEN%-30s$NC\n" "Build Env" "$BUILD_ENV"
printf "%-20s | $GREEN%-30s$NC\n" "Environment" "$CAPITALIZED_ENVIRONMENT_NAME"
printf "%-20s | $GREEN%-30s$NC\n" "Environment File" "$ENVFILE"
printf "========================================\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment