-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
82 lines (64 loc) · 2.27 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
npm=pnpm
help:
@echo "Available commands:"
@echo "Development mode"
@echo " dev - Start development servers for frontend and backend"
@echo " devBackend - Start the backend development server"
@echo " devFrontend - Start the frontend development server"
@echo "Dependence"
@echo " dep - Install dependencies for frontend and backend"
@echo " depBackend - Install backend dependencies"
@echo " depFrontend - Install frontend dependencies"
@echo "Build"
@echo " build - Build both frontend and backend"
@echo " buildFrontend - Build frontend"
@echo " buildBackend - Build backend"
@echo " buildDist - Build dist from docker"
@echo "Misc"
@echo " doctor - Check tools"
@echo " clean - Clean generated files"
@echo " format - Format code"
# @$(call check,"executable","the target that will not work, no comma is allowed")
define check
@command -v $(1) > /dev/null 2>&1 && echo "detected $(1)" || echo "$(1) is NOT installed, the '$(2)' target will not work"
endef
doctor:
@$(call check,tmux,dev)
@$(call check,nodemon,devBackend)
@$(call check,go,depBackend and buildBackend)
@$(call check,pnpm,depFrontend and devFrontend and buildFrontend)
@$(call check,docker,buildDist)
@$(call check,prettier,format)
@$(call check,bash,buildFrontend)
dev:
tmux split-window -h make devFrontend
make devBackend
dep: depBackend depFrontend
depBackend:
cd ./backend/ && go mod download
mkdir -p ./backend/static/
touch ./backend/static/.gitkeep
depFrontend:
cd ./frontend/ && $(npm) install
devBackend:
cd ./backend/ && nodemon -e go --watch './**/*.go' --signal SIGTERM --exec 'TOKEN=token go run -tags dev . --db data.db'
devFrontend:
cd ./frontend/ && $(npm) run dev
build: buildFrontend buildBackend
buildDist:
docker build --output out .
buildFrontend:
cd ./frontend/ && sh build.sh
buildBackend:
rm -rf ./backend/static/
cp -r ./frontend/out/ ./backend/static/
cd ./backend/ && bash build.sh
format:
cd frontend && prettier --write src
cd backend && gofmt -w .
clean:
rm -rf ./main
rm -rf ./backend/static/
rm -rf ./frontend/out/ ./frontend/node_modules/ ./frontend/.next/
mkdir ./backend/static/
.PHONY: devBackend devFrontend build buildBackend buildFrontend clean dep depFrontend depBackend