kyle-c
12/14/2018 - 9:16 AM

CI/CD for GoogleService-Info.plist

#!/bin/bash

this_dir=$(dirname $0);
cfgFile="$this_dir/../app/constants/EnvConfig.js";



vert='\033[1;32m';
rouge='\033[1;31m';
clear='\033[0m';

target=""

envNames=("a" "b" "intDev" "intProd")

while getopts "hle:v:" option
do
    case $option in
        h)
            echo "Configurateur d'environnement cible"
            echo ""
            echo "Liste des options :"
            echo "  -h          : Affiche l'aide"
            echo "  -l          : Liste les enironnements disponibles"
            echo "  -e xxx      : Configure l'application pour l'environnement xxx"
            echo "  -d ON/OFF   : Activate / Deactivate debug mode"
            exit 0
            ;;
        l)
            echo "Environnements : "
            for index in ${!envNames[*]}
            do
                printf "%s\t: %s\n" ${envNames[$index]} ${envURLs[$index]}
            done
            exit 0
            ;;
        e)
            echo "Set environement : $OPTARG"
            target=$OPTARG
            ;;
        v)
            echo "Version : $OPTARG"
            ;;
        \?)
            echo "$OPTARG : option invalide, -h pour la liste des options disponibles"
            exit 1
            ;;
    esac
done

idx=-1
if [ "${target}" != "" ]
  then
    for i in "${!envNames[@]}"; do
       if [ "${envNames[$i]}" = "${target}" ]
        then
            idx=${i};
            envPlistFile="GoogleService-Info_${envNames[$i]}.plist";
            cp -R ${envPlistFile} GoogleService-Info.plist 
        fi
    done

  else
    printf "${rouge} !!  Aucun environement configuré! Essayer avec la commande config.sh -e dev${clear}\n";
fi

exit 0