#!/bin/bash # # Script to build the application and creating a version number depending on build # ---------------------------------- # COLORS # ---------------------------------- NOCOLOR='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' CYAN='\033[0;36m' YELLOW='\033[1;33m' BRANCH=$(git rev-parse --abbrev-ref HEAD) while [ $# -gt 0 ]; do if [[ $1 == *"--"* ]]; then param="${1/--/}" declare $param="$2" # echo $1 $2 // Optional to see the parameter:value result fi shift done config=${config:-prod} version=${version:-$config} # ---------------------------------- # UPDATING VERSION # ---------------------------------- echo -e "${CYAN}Setting version to ${version} inside the environments file${NOCOLOR}" if [ $config = "api" ]; then sed "s/version:.*',/version: '${version}',/" apps/mina-sidor-fa/src/environments/environment.ts > temp.txt && mv temp.txt apps/mina-sidor-fa/src/environments/environment.ts else sed "s/version:.*',/version: '${version}',/" apps/mina-sidor-fa/src/environments/environment.$config.ts > temp.txt && mv temp.txt apps/mina-sidor-fa/src/environments/environment.$config.ts fi echo -e "${GREEN}Version set to ${version}${NOCOLOR}" # ---------------------------------- # BUILD APPLICATION # ---------------------------------- echo -e "${CYAN}Running npm run ng build mina-sidor-fa -- --configuration ${config}${NOCOLOR}" if [ $config = "api" ]; then npm run ng build mina-sidor-fa else npm run ng build mina-sidor-fa -- --configuration $config fi echo -e "${GREEN}Application built: ${version}${NOCOLOR}" exit