#!/bin/bash -x
if (( $# != 2 )); then
    echo "Improper usage of this script. Please invoke with arguments <OLD_VERSION> <NEW_VERSION> "
    exit 1
fi

os=`uname`

function _sed {
    if [[ "$os" =~ "Linux" ]]; then
        sed -i -e "$1" ${@:2}
    else
        sed -i '' -e "$1" ${@:2}
    fi
}

oldVersion=$1
newVersion=$2

_sed 's/'$oldVersion'/'$newVersion'/g' \
package.json \
NOTICE-JS

echo "prepare git patch"

countFoundOldVersions=$(git grep -F ${oldVersion} * | grep -v ReleaseNotes | wc -l)
if (($countFoundOldVersions > 0)); then
    echo "WARNING: a grep over your workspace emphasised that the oldVersion is still present in some of your resources. Please check manually!"
    git grep -F ${oldVersion} * | grep -v ReleaseNotes
else
    git add -A && git commit -m "[Release] set version to $newVersion"
fi

Add helper script to easily update project version
[tools] Add helper script to easily update project version

Change-Id: I60a2cfed238a14adcc135f995d6c7d171f6be91d
Reviewed-on: https://src.bmw-carit.de/gerrit/68419
External-IP-Free: Atanas Gegov <132b2ca0f92fc3d0bac6b8420311fd3a05a633a5@bmw-carit.de>
Reviewed-by: Guido Ostkamp <f36066ac811a58c12d7a8da5ce324c31d8ddf32b@de.bertrandt.com>
OSS-Check: Guido Ostkamp <f36066ac811a58c12d7a8da5ce324c31d8ddf32b@de.bertrandt.com>
Tested-by: zuul <1505422b2465e9a84f6fdfaa161078890c593f06@bmw-carit.de>
