forked from OpenVidu/openvidu-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-tutorials.sh
executable file
·160 lines (139 loc) · 6.88 KB
/
update-tutorials.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
set -eo pipefail
if [[ -z "$FROM_VERSION" || -z "$TO_VERSION" ]]; then
echo
echo "Examples of use: "
echo " export FROM_VERSION=2.12.0; export TO_VERSION=2.13.0; ${0}"
echo " export FROM_VERSION=2.12.0; export TO_VERSION=2.13.0; export FROM_VERSION_SDK=2.12.0; export TO_VERSION_SDK=2.13.0; ${0}"
echo
exit 1
fi
if [[ -z "$FROM_VERSION_SDK" || -z "$TO_VERSION_SDK" ]]; then
echo
echo "No FROM_VERSION_SDK and TO_VERSION_SDK properties provided. Server SDKs depdendencies won't be updated."
echo "To update also server SDKs dependencies, run the script like this:"
echo " export FROM_VERSION=2.12.0; export TO_VERSION=2.13.0; export FROM_VERSION_SDK=2.12.0; export TO_VERSION_SDK=2.13.0; ${0}"
echo
read -p "Do you still want to continue? [Y/N]" -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then :
else
echo "Aborted"
exit 1
fi
fi
echo "## Updating openvidu-tutorials"
echo "## From $FROM_VERSION to $TO_VERSION"
if [[ ! -z "$FROM_VERSION_SDK" || ! -z "$TO_VERSION_SDK" ]]; then
echo "## From SDK $FROM_VERSION_SDK to SDK $TO_VERSION_SDK"
fi
echo
NPM_TUTORIALS="openvidu-insecure-angular
openvidu-insecure-react
openvidu-library-react
openvidu-ionic
openvidu-js-node
openvidu-mvc-node
openvidu-recording-node
openvidu-react-native
openvidu-electron
openvidu-insecure-vue
openvidu-call/openvidu-call-front
openvidu-call/openvidu-call-back"
MAVEN_TUTORIALS="openvidu-js-java
openvidu-mvc-java
openvidu-recording-java
openvidu-ipcameras"
# Delete all package-lock.json and node_modules
find -type f -name 'package-lock.json' -exec rm {} \;
find -type d -name 'node_modules' -prune -exec rm -rf {} \;
# Updating openvidu-browser dependencies in package.json files [openvidu-insecure-angular, openvidu-insecure-react, openvidu-ionic, openvidu-insecure-vue]
find . -type f -name 'package.json' -exec sed -i "s/\"openvidu-browser\": \"$FROM_VERSION\"/\"openvidu-browser\": \"$TO_VERSION\"/" {} \;
# Updating openvidu-react dependencies in package.json files [openvidu-library-react]
find . -type f -name 'package.json' -exec sed -i "s/\"openvidu-react\": \"$FROM_VERSION\"/\"openvidu-react\": \"$TO_VERSION\"/" {} \;
# Updating openvidu-angular dependencies in package.json files [openvidu-call, openvidu-components/*]
find . -type f -name 'package.json' -exec sed -i "s/\"openvidu-angular\": \"$FROM_VERSION\"/\"openvidu-angular\": \"$TO_VERSION\"/" {} \;
# Updating openvidu-react-native-adapter dependencies in package.json files [openvidu-react-native]
find . -type f -name 'package.json' -exec sed -i "s/file:openvidu-react-native-adapter-$FROM_VERSION.tgz/file:openvidu-react-native-adapter-$TO_VERSION.tgz/" {} \;
# If server SDKs must be udpated
if [[ -n "$FROM_VERSION_SDK" && -n "$TO_VERSION_SDK" ]]; then
# Updating openvidu-node-client dependencies in package.json files [openvidu-js-node, openvidu-mvc-node, openvidu-recording-node]
find . -type f -name 'package.json' -exec sed -i "s/\"openvidu-node-client\": \"$FROM_VERSION_SDK\"/\"openvidu-node-client\": \"$TO_VERSION_SDK\"/" {} \;
# Updating openvidu-java-client dependencies in pom.xml files
for tutorial in ${MAVEN_TUTORIALS}
do
cd $tutorial
mvn --batch-mode versions:use-dep-version -Dincludes=io.openvidu:openvidu-java-client -DdepVersion=$TO_VERSION_SDK -DforceVersion=true
cd ..
done
fi
# Update every <script src="openvidu-browser-VERSION.js"></script> import in every *.html or *.ejs file (14 files changed)
for file in *.html *.ejs; do
echo
echo "###############################"
echo "Updating openvidu-browser <script> tag in $file"
echo "###############################"
echo
find . -type f -name $file -exec sed -i "s/<script src=\"openvidu-browser-$FROM_VERSION.js\"><\/script>/<script src=\"openvidu-browser-$TO_VERSION.js\"><\/script>/" {} \;
done
# Update every openvidu-browser-VERSION.js file (15 FILES CHANGED)
wget https://github.com/OpenVidu/openvidu/releases/download/v$TO_VERSION/openvidu-browser-$TO_VERSION.js
readarray MY_ARRAY < <(find -name "openvidu-browser-$FROM_VERSION.js" -printf "%h\n" | sort -u)
for directory in ${MY_ARRAY[@]}
do
echo
echo "###############################"
echo "Replacing $directory/openvidu-browser-$FROM_VERSION.js with openvidu-browser-$TO_VERSION.js"
echo "###############################"
echo
rm $directory/openvidu-browser-$FROM_VERSION.js
cp openvidu-browser-$TO_VERSION.js $directory/openvidu-browser-$TO_VERSION.js
done
rm openvidu-browser-$TO_VERSION.js
# Run "npm install" in every NPM project
for tutorial in ${NPM_TUTORIALS}
do
echo
echo "###############################"
echo "Compiling NPM project $tutorial"
echo "###############################"
echo
cd $tutorial
npm --no-git-tag-version --allow-same-version version $TO_VERSION
npm install || true
cd ..
done
# Run "mvn clean compile package" in every Maven project
for tutorial in ${MAVEN_TUTORIALS}
do
echo
echo "###############################"
echo "Compiling Maven project $tutorial"
echo "###############################"
echo
cd $tutorial
mvn versions:set -DnewVersion=$TO_VERSION
mvn clean compile package || true
cd ..
done
# Update openvidu-webcomponent tutorial files: static web component files and import inside index.html
echo
echo "###############################"
echo "Updating openvidu-webcomponent tutorial"
echo "###############################"
wget https://github.com/OpenVidu/openvidu/releases/download/v$TO_VERSION/openvidu-webcomponent-$TO_VERSION.zip
mkdir openvidu-webcomponent-$TO_VERSION
mv openvidu-webcomponent-$TO_VERSION.zip openvidu-webcomponent-$TO_VERSION/openvidu-webcomponent-$TO_VERSION.zip
unzip openvidu-webcomponent-$TO_VERSION/openvidu-webcomponent-$TO_VERSION.zip -d openvidu-webcomponent-$TO_VERSION/.
rm openvidu-webcomponent/web/openvidu-webcomponent-$FROM_VERSION.js
rm openvidu-webcomponent/web/openvidu-webcomponent-$FROM_VERSION.css
mv openvidu-webcomponent-$TO_VERSION/openvidu-webcomponent-$TO_VERSION.js openvidu-webcomponent/web/.
mv openvidu-webcomponent-$TO_VERSION/openvidu-webcomponent-$TO_VERSION.css openvidu-webcomponent/web/.
rm -rf openvidu-webcomponent-$TO_VERSION
sed -i "s/<script src=\"openvidu-webcomponent-$FROM_VERSION.js\"><\/script>/<script src=\"openvidu-webcomponent-$TO_VERSION.js\"><\/script>/" openvidu-webcomponent/web/index.html
sed -i "s/<link rel=\"stylesheet\" href=\"openvidu-webcomponent-$FROM_VERSION.css\">/<link rel=\"stylesheet\" href=\"openvidu-webcomponent-$TO_VERSION.css\">/" openvidu-webcomponent/web/index.html
echo
echo "###################################"
echo "SUCCESS UPDATING OPENVIDU-TUTORIALS"
echo "###################################"
echo