#!/usr/bin/env bash

set -e

version=$1

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
green="\x1B[0;32m" # '\e[1;32m' is too bright for white bg.
blue="\x1B[1;34m"
endColor="\x1B[0m"

function echoblue() {
    echo -e "${blue}$1${endColor}"
}

pushd "$DIR"

pushd ../server/bo_client
echoblue("Setting bo_client version")
npm run set-version -- "$version"
popd

pushd ../server/src
echoblue("Setting back version")
sed -i "" -e "s/\([:space:]*\'version\'[[:space:]]*\=\>[[:space:]]*\'\)[\.0-9]*\(\'.*\)/\1${version}\2/" config/version.php
popd

pushd ../cms
echoblue("Setting cms version")
npm run set-version -- "$version"
popd

pushd ../cms/app-client
echoblue("Setting bo_client version")
npm run set-version -- "$version"
popd

echoblue("Version has been changed, please commit and push if necessary.")


popd
