-
Notifications
You must be signed in to change notification settings - Fork 92
/
setversion.sh
executable file
·99 lines (79 loc) · 2.52 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/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. 8.0.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
gsed -i "s/\"version\":.*\"[^\"]*\"/\"version\": \"${version}\"/g" ${file}
}
update_mock_sdk_info ()
{
local file=$1
local version=$2
gsed -i "s/new\ SDKInfo(\"[^\"]*\"/new SDKInfo(\"${version}\"/g" ${file}
}
update_sdk_info_test_suite ()
{
local file=$1
local version=$2
gsed -i "s/sdkInfo\.sdkVersion\.indexOf(\"[^\"]*\")/sdkInfo.sdkVersion.indexOf(\"${version}\")/g" ${file}
}
update_salesforce_mobile_sdk_version ()
{
local file=$1
local version=$2
gsed -i "s/var\ SALESFORCE_MOBILE_SDK_VERSION = \"[^\"]*\"/var SALESFORCE_MOBILE_SDK_VERSION = \"${version}\"/g" ${file}
}
update_cordova_plugins_version ()
{
local file=$1
local version=$2
gsed -i "s/\"com.salesforce\": \"[^\"]*\"/\"com.salesforce\": \"${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 bower.json ***"
update_package_json "./tools/bower.json" "${OPT_VERSION}"
echo "*** Updating package.json in tools ***"
update_package_json "./tools/package.json" "${OPT_VERSION}"
echo "*** Updating package-lock.json ***"
update_package_json "./tools/package-lock.json" "${OPT_VERSION}"
echo "*** Updating MockSDKInfo test ***"
update_mock_sdk_info "./test/MockSDKInfo.js" "${OPT_VERSION}"
echo "*** Updating SFSDKInfoTestSuite.js ***"
update_sdk_info_test_suite "./test/SFSDKInfoTestSuite.js" "${OPT_VERSION}"
echo "*** Updating SALESFORCE_MOBILE_SDK_VERSION ***"
update_salesforce_mobile_sdk_version "./test/SFTestRunnerPlugin.js" "${OPT_VERSION}"
update_salesforce_mobile_sdk_version "./libs/cordova.force.js" "${OPT_VERSION}"
echo "*** Updating cordova_plugins.js ***"
update_cordova_plugins_version "./gen/cordova_plugins.js" "${OPT_VERSION}"
echo "*** Updating generated plugin files ***"
./tools/update.sh