forked from forcedotcom/SalesforceMobileSDK-CordovaPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setversion.sh
executable file
·59 lines (46 loc) · 1.13 KB
/
setversion.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
!#!/bin/bash
#set -x
OPT_VERSION=""
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
usage ()
{
echo "Use this script to set Mobile SDK version number in source files"
echo "Usage: $0 -v <version>"
echo " where: version is the version e.g. 7.1.0"
}
parse_opts ()
{
while getopts v:d: command_line_opt
do
case ${command_line_opt} in
v) OPT_VERSION=${OPTARG};;
esac
done
if [ "${OPT_VERSION}" == "" ]
then
echo -e "${RED}You must specify a value for the version.${NC}"
usage
exit 1
fi
}
# Helper functions
update_package_json ()
{
local file=$1
local version=$2
sed -i "s/\"version\":.*\"[^\"]*\"/\"version\": \"${version}\"/g" ${file}
}
update_plugin_xml ()
{
local file=$1
local version=$2
sed -i "s/version.*=.*\"[^\"]*\">/version=\"${version}\">/g" ${file}
}
parse_opts "$@"
echo -e "${YELLOW}*** SETTING VERSION TO ${OPT_VERSION} ***${NC}"
echo "*** Updating package.json ***"
update_package_json "./package.json" "${OPT_VERSION}"
echo "*** Updating plugin.xml ***"
update_plugin_xml "./plugin.xml" "${OPT_VERSION}"