@@ -6,17 +6,31 @@ RED=`tput setaf 1`
66GREEN=` tput setaf 2`
77RESET=` tput sgr0`
88
9- scripts_path =' ./dist/latest/custom'
10- remote_path =
' [email protected] :/var/www/default' 9+ SCRIPTS_LATEST_PATH =' ./dist/latest/custom'
10+ REMOTE_PATH =
' [email protected] :/var/www/default' 1111
1212if ! [[ $PWD = * /scripts ]] || ! [[ -f " ./dist/latest/custom/latest.js" ]]; then
1313 echo -e " ==> ${RED} Not in scripts directory, killing script${RESET} "
1414 exit 1
1515fi
1616
17- echo ' ==> You are about to deploy to production'
17+ if [[ ` git status --porcelain` ]]; then
18+ echo -e " ==> ${RED} There are changes in your repo, commit and test them first${RESET} "
19+ exit 1
20+ fi
21+
22+ read -p " ==> Specify the latest SRI version: " VERSION
23+
24+ LATEST_FILE=" ./dist/v$VERSION /latest.js"
25+ SRI_FILE=" ./dist/v$VERSION /custom/latest.js"
26+
27+ if [ ! -f " $LATEST_FILE " ] || [ ! -f " $SRI_FILE " ]; then
28+ echo " ==> Files with version v$VERSION do not exist."
29+ exit 1
30+ fi
1831
19- read -p " ==> Are you sure? (y/N)" -n 1 -r
32+ echo " ==> You are about to deploy to production"
33+ read -p " ==> Are you sure (y/N)? " -r
2034echo
2135if [[ $REPLY =~ ^[Yy]$ ]]; then
2236 echo ' ==> Minifying one more time'
@@ -28,21 +42,26 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
2842 exit 1
2943 fi
3044
31- echo ' ==> Deploying to production'
32- rsync --rsync-path=" sudo rsync" " $scripts_path /e.js" " $remote_path /events.js"
33- rsync --rsync-path=" sudo rsync" " $scripts_path /e.js.map" " $remote_path /events.js.map"
34- rsync --rsync-path=" sudo rsync" " $scripts_path /latest.js" " $remote_path /latest.js"
35- rsync --rsync-path=" sudo rsync" " $scripts_path /latest.js.map" " $remote_path /latest.js.map"
36- rsync --rsync-path=" sudo rsync" " $scripts_path /light.js" " $remote_path /light.js"
37- rsync --rsync-path=" sudo rsync" " $scripts_path /light.js.map" " $remote_path /light.js.map"
38- rsync --rsync-path=" sudo rsync" " $scripts_path /proxy.js" " $remote_path /proxy.js"
39- rsync --rsync-path=" sudo rsync" " $scripts_path /proxy.js.map" " $remote_path /proxy.js.map"
40- rsync --rsync-path=" sudo rsync" " $scripts_path /../embed.js" " $remote_path /embed.js"
41- rsync --rsync-path=" sudo rsync" " $scripts_path /../embed.js.map" " $remote_path /embed.js.map"
45+ echo " ==> Deploying non SRI v$VERSION files to production"
46+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /e.js" " $REMOTE_PATH /events.js"
47+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /e.js.map" " $REMOTE_PATH /events.js.map"
48+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /latest.js" " $REMOTE_PATH /latest.js"
49+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /latest.js.map" " $REMOTE_PATH /latest.js.map"
50+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /light.js" " $REMOTE_PATH /light.js"
51+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /light.js.map" " $REMOTE_PATH /light.js.map"
52+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /proxy.js" " $REMOTE_PATH /proxy.js"
53+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /proxy.js.map" " $REMOTE_PATH /proxy.js.map"
54+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /../embed.js" " $REMOTE_PATH /embed.js"
55+ rsync --rsync-path=" sudo rsync" " $SCRIPTS_LATEST_PATH /../embed.js.map" " $REMOTE_PATH /embed.js.map"
56+
57+ echo " ==> Creating v$VERSION folder on server"
58+ ssh
[email protected] mkdir -p
" /var/www/default/v$VERSION " 59+
60+ echo " ==> Copying SRI v$VERSION file to server"
61+ rsync --quiet --rsync-path=" sudo rsync" " ./dist/v$VERSION /custom/v$VERSION .js" " $REMOTE_PATH /v$VERSION /app.js"
62+ rsync --quiet --rsync-path=" sudo rsync" " ./dist/v$VERSION /custom/v$VERSION .js.map" " $REMOTE_PATH /v$VERSION /app.js.map"
4263
4364 echo -e " ==> ${GREEN} Woop woop! Deployed!${RESET} "
4465else
4566 echo ' ==> Cancelled by you'
46- fi
47-
48-
67+ fi
0 commit comments