Skip to content

Commit 5d3a988

Browse files
committed
Make sure SRI only includes version number
1 parent 7e8fd95 commit 5d3a988

File tree

21 files changed

+77
-37
lines changed

21 files changed

+77
-37
lines changed

deploy.sh

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,31 @@ RED=`tput setaf 1`
66
GREEN=`tput setaf 2`
77
RESET=`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

1212
if ! [[ $PWD = */scripts ]] || ! [[ -f "./dist/latest/custom/latest.js" ]]; then
1313
echo -e "==> ${RED}Not in scripts directory, killing script${RESET}"
1414
exit 1
1515
fi
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
2034
echo
2135
if [[ $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}"
4465
else
4566
echo '==> Cancelled by you'
46-
fi
47-
48-
67+
fi

dist/latest/cloudflare.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2021-04-20; e8aa) */
1+
/* Simple Analytics - Privacy friendly analytics (docs.simpleanalytics.com/script; 2021-04-20; e8aa; v2) */
22
/* eslint-env browser */
33

44
(function (window, overwriteOptions, baseUrl, apiUrlPrefix, version, saGlobal) {

dist/latest/custom/app.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/latest/custom/e.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)