-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (86 loc) · 2.91 KB
/
Makefile
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
NAMESPACE?=git.cipherboy.com/WillowPatchGames/wpg
GO?=go
GOROOT?=
NPM?=npm
PYTHON?=python3
DIST?=build.tar
all: build
test: check
dist: distui tarball
check: vet gosec staticcheck crypt utils games database business
check-api: check api-tests
deps:
GOROOT="$(GOROOT)" $(GO) get -u $(NAMESPACE)/...
cd assets/static && $(NPM) install
./scripts/words.sh
deps-update: deps
GOROOT="$(GOROOT)" $(GO) mod tidy
cd assets/static && $(NPM) audit fix --force
sass-update: deps-update
cd assets/static && $(NPM) rebuild node-sass
fuzz:
GOROOT="$(GOROOT)" $(GO) get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
cd pkg/password && go-fuzz-build && go-fuzz
format:
GOROOT="$(GOROOT)" $(GO) fmt $(NAMESPACE)/...
vet:
GOROOT="$(GOROOT)" $(GO) vet $(NAMESPACE)/...
gosec:
test -e ~/go/bin/gosec || ( echo "Must install gosec: https://github.com/securego/gosec" && exit 1 )
$(HOME)/go/bin/gosec ./...
staticcheck:
test -e ~/go/bin/staticcheck || ( echo "Must install staticcheck: https://staticcheck.io/docs/" && exit 1 )
$(HOME)/go/bin/staticcheck $(NAMESPACE)/...
crypt: pkg/password/*.go
GOROOT="$(GOROOT)" $(GO) test $(NAMESPACE)/pkg/password
utils: internal/utils/*.go
GOROOT="$(GOROOT)" $(GO) test $(NAMESPACE)/internal/utils
games: pkg/games/*.go
GOROOT="$(GOROOT)" $(GO) test $(NAMESPACE)/pkg/games
database: internal/database/*.go
GOROOT="$(GOROOT)" $(GO) test $(NAMESPACE)/internal/database
business: internal/business/*.go
GOROOT="$(GOROOT)" $(GO) test $(NAMESPACE)/internal/business
api-tests:
bash ./scripts/api-tests.sh $(PYTHON)
install: install_database
uninstall: remove_database
build: cmds
cmds: wpgapi
wpgapi: cmd/wpgapi/main.go pkg/*/*.go internal/*/*.go
GOROOT="$(GOROOT)" $(GO) build $(NAMESPACE)/cmd/wpgapi
clean:
rm -f wpgapi
clean-api: clean
rm -rf wpg.sqlite3
distclean: clean-api
rm -rf assets/static/node_modules assets/static/package-lock.json
submod:
git submodule init && git submodule update
webui:
cd assets/static && REACT_EDITOR=none BROWSER=none $(NPM) start
backend: all
./scripts/start-backend.sh
images:
cd assets/static/src/images && git pull
distui:
cd assets/static && REACT_EDITOR=none BROWSER=none $(NPM) run build
cp assets/static/public/csw15.txt assets/static/build/csw15.txt
bash ./scripts/build-gzip.sh
tarball: build
rm -f $(DIST) $(DIST).xz
tar -cf $(DIST) wpgapi assets/wordlist.txt
tar -rf $(DIST) -C assets/static build
tar -rf $(DIST) -C scripts units
tar -rf $(DIST) configs
xz $(DIST)
beta-deploy: all dist
mv $(DIST).xz ../ansible/files/$(DIST).xz
cd ../nginx-configs && tar -cJf ../ansible/files/nginx.tar.xz *
cd ../ansible && bash ./backup.sh beta
cd ../ansible && ansible-playbook -i hosts beta.yml
prod-deploy: all dist
mv $(DIST).xz ../ansible/files/$(DIST).xz
cd ../nginx-configs && tar -cJf ../ansible/files/nginx.tar.xz *
cd ../ansible && bash ./backup.sh prod
cd ../ansible && ansible-playbook -i hosts prod.yml