-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.production
116 lines (85 loc) · 5.54 KB
/
Makefile.production
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
-include Makefile.passwords
RELEASE=$(shell git describe --long | sed 's@\([0-9.]\{1,\}\).*@\1@')
VERSION=$(shell git describe --long)
KIDSGO_HASH=$(shell md5sum dist/kidsgo.min.js | awk '{print $$1}')
KIDSGO_VENDOR_HASH=$(shell md5sum dist/kidsgo-vendor.min.js | awk '{print $$1}')
KIDSGO_VERSION_HASH=$(VERSION)-$(KIDSGO_HASH)
stats:
npm run webpack -- --mode production --optimization-minimize --devtool=source-map --output-filename 'kidsgo.min.js' --json > webpack-stats.json
cat webpack-stats.json
todo:
cd src; grep -r 'TODO: Implement' views components lib | grep -v gen.py | sort | grep --color -E '^[^:]*:'
cd src; grep -r 'TODO: Implement' views components lib | grep -v gen.py | wc -l
todo-all:
cd src; grep -r TODO views components lib | grep --color -E '^[^:]*:'
cd src; grep -r TODO views components lib | wc -l
#LANGUAGE_VERSION=`md5sum i18n/locale/*.js | sort | md5sum | awk '{print $$1}'`
LANGUAGE_VERSION=""
SUPPORTED_LANGUAGES=`python -c 'import json; print(json.dumps(json.loads(open("i18n/languages.json", "r").read())))'`
GOBAN_VERSION=`python -c 'import json; print(json.loads(open("package.json", "r").read())["devDependencies"]["goban"][1:])'`
BASE_INDEX_HEADERS=-H "Content-Type: text/plain" \
-H "X-KIDSGO-Index-Release: $(RELEASE)" \
-H "X-KIDSGO-Index-Version: $(VERSION)" \
-H "X-KIDSGO-Supported-Languages: $(SUPPORTED_LANGUAGES)" \
-H "X-KIDSGO-Goban-Js: https://cdn.online-go.com/goban/$(GOBAN_VERSION)/goban.min.js" \
-H "X-KIDSGO-Language-Version: $(LANGUAGE_VERSION)" \
DEV_INDEX_HEADERS=$(BASE_INDEX_HEADERS) -H "X-KIDSGO-Index-Auth: $(DEV_INDEX_AUTH)"
BETA_INDEX_HEADERS=$(BASE_INDEX_HEADERS) -H "X-KIDSGO-Index-Auth: $(BETA_INDEX_AUTH)"
PROD_INDEX_HEADERS=$(BASE_INDEX_HEADERS) -H "X-KIDSGO-Index-Auth: $(PROD_INDEX_AUTH)"
dev-put: push-cdn
KIDSGO_VERSION_HASH=$(KIDSGO_VERSION_HASH) KIDSGO_VENDOR_HASH=$(KIDSGO_VENDOR_HASH) npm run minify-index --silent | curl -X PUT $(DEV_INDEX_HEADERS) -d @- http://kidsgo.codebits.org:1080/_index
dev-del:
curl -X DELETE $(DEV_INDEX_HEADERS) http://kidsgo.codebits.org:1080/_index
beta-put: push-cdn audit-translations
KIDSGO_VERSION_HASH=$(KIDSGO_VERSION_HASH) KIDSGO_VENDOR_HASH=$(KIDSGO_VENDOR_HASH) npm run minify-index --silent | curl -X PUT $(BETA_INDEX_HEADERS) -d @- https://beta.kidsgoserver.com/_index
beta-maintenance:
cat src/maintenance.html | curl -X PUT $(BETA_INDEX_HEADERS) -d @- https://beta.kidsgoserver.com/_index
live-put: push-cdn audit-translations
KIDSGO_VERSION_HASH=$(KIDSGO_VERSION_HASH) KIDSGO_VENDOR_HASH=$(KIDSGO_VENDOR_HASH) npm run minify-index --silent | curl -X PUT $(PROD_INDEX_HEADERS) -d @- https://kidsgoserver.com/_index
live-maintenance:
cat src/maintenance.html | curl -X PUT $(PROD_INDEX_HEADERS) -d @- https://kidsgoserver.com/_index
confirm-go-live:
@read -p "Go live? " yesno; \
test $$yesno == 'yes';
push: push-cdn
push-cdn: prepare-cdn-files
gsutil -m rsync -r deployment-staging-area/$(RELEASE) gs://kidsgo-site-files/$(RELEASE)/
#gsutil -m setmeta -h "Content-Type:audio/webm" 'gs://kidsgo-site-files/$(RELEASE)/sound/*.webm'
sync-translations:
#cd i18n/locale/; ssh [email protected] "bash -c 'cd kidsgoserver.com/i18n/locale; tar jcf - *'" | tar jxf -
audit-translations:
#cd i18n; node audit-translations.js
prepare-cdn-files: purge-cdn-files sync-translations dist/kidsgo.min.js dist/kidsgo-vendor.min.js dist/kidsgo.$(VERSION).css
mkdir -p deployment-staging-area/$(RELEASE)/
mkdir -p deployment-staging-area/$(RELEASE)/locale
cat dist/kidsgo.min.js | sed 's/kidsgo.min.js.map/kidsgo.$(KIDSGO_VERSION_HASH).js.map/' > deployment-staging-area/$(RELEASE)/kidsgo.$(KIDSGO_VERSION_HASH).js
cat dist/kidsgo-vendor.min.js | sed 's/kidsgo-vendor.min.js.map/kidsgo-vendor.$(KIDSGO_VENDOR_HASH).js.map/' > deployment-staging-area/$(RELEASE)/kidsgo-vendor.$(KIDSGO_VENDOR_HASH).js
cp -p dist/kidsgo.min.js.map deployment-staging-area/$(RELEASE)/kidsgo.$(KIDSGO_VERSION_HASH).js.map
cp -p dist/kidsgo-vendor.min.js.map deployment-staging-area/$(RELEASE)/kidsgo-vendor.$(KIDSGO_VENDOR_HASH).js.map
cp -p dist/kidsgo.$(VERSION).css deployment-staging-area/$(RELEASE)/
cp -p dist/kidsgo.$(VERSION).css.map deployment-staging-area/$(RELEASE)/
cp -Rp assets/img deployment-staging-area/$(RELEASE)/
cp -Rp assets/avatars deployment-staging-area/$(RELEASE)/
cp -Rp assets/backgrounds deployment-staging-area/$(RELEASE)/
cp -Rp assets/sound deployment-staging-area/$(RELEASE)/
cp -Rp assets/pages deployment-staging-area/$(RELEASE)/
cp -Rp assets/misc deployment-staging-area/$(RELEASE)/
cp -Rp assets/buttons deployment-staging-area/$(RELEASE)/
cp -Rp assets/stones deployment-staging-area/$(RELEASE)/
ls i18n/locale/*.js | sed 's@i18n/locale/\([^\.]\+\).js@\1@' | xargs -n1 -I {} cp i18n/locale/{}.js deployment-staging-area/$(RELEASE)/locale/{}.$(LANGUAGE_VERSION).js
# cleanup
find deployment-staging-area/ | grep \\.swp$$ | xargs rm -f
find deployment-staging-area/ | grep "~" | xargs rm -f
find deployment-staging-area/ | grep /backup/ | xargs rm -f
find deployment-staging-area/ | grep \\.bak$$ | xargs rm -f
find deployment-staging-area/ | grep \\.xcf$$ | xargs rm -f
find deployment-staging-area/ | grep \\.dat$$ | xargs rm -f
purge-cdn-files:
rm -Rf deployment-staging-area
dist/kidsgo.min.js: dist/kidsgo.js
npm run webpack -- --mode=production --optimization-minimize --devtool=source-map
dist/kidsgo-vendor.min.js: dist/kidsgo-vendor.js
npm run webpack -- --mode=production --optimization-minimize --devtool=source-map
dist/kidsgo.$(VERSION).css:
npm run gulp min_styl
.PHONY: dev stats todo update install default min server dist push-cdn sync-translations