generated from alexstojda/go-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
86 lines (63 loc) · 2 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
FRONTEND_DIR = './web/app'
setup: setup-frontend setup-backend
setup-frontend:
@cd $(FRONTEND_DIR) && yarn
setup-backend: mod
mod:
@go mod download
env: env-local keys
env-local:
@cp .env .env.local
clean:
@rm -rf $(FRONTEND_DIR)/build
generate: generate-backend generate-frontend
generate-frontend:
@docker compose up --remove-orphans --build -d openapi-client
@rm -rf web/app/src/api/generated && true
@docker compose cp openapi-client:/out web/app/src/api/generated
@docker compose stop openapi-client
generate-backend:
@docker compose up --remove-orphans --build -d openapi-server
@rm -rf internal/app/generated && true
@docker compose cp openapi-server:/out internal/app/generated
@docker compose stop openapi-server
build: build-backend build-frontend
build-backend:
@mkdir -p ./build
@go build -v -o ./build/pinman main.go
build-frontend:
@cd $(FRONTEND_DIR) && yarn build
run: clean generate build-frontend
@SPA_PATH=./web/app/build go run main.go
run-backend:
@go run main.go
run-database:
@docker compose up -d postgres
run-frontend:
@cd $(FRONTEND_DIR) && REACT_APP_API_HOST=http://localhost:8080 yarn start
test: test-backend test-frontend
test-setup:
@go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo
@go install -mod=mod github.com/vektra/mockery/[email protected]
@mockery
test-frontend:
@cd $(FRONTEND_DIR) && yarn test
@rm -rf ./reports/ts && true
@mkdir -p ./reports/ts
@mv -f $(FRONTEND_DIR)/coverage $(FRONTEND_DIR)/reports ./reports/ts/
test-backend: test-setup
@ginkgo ./...
keys:
@echo "Generating key-pair for jwt tokens..."
@ssh-keygen -f `pwd`/token -t rsa -N '' -q
@sed -i "s/TOKEN_PRIVATE_KEY.*/TOKEN_PRIVATE_KEY=`cat ./token | base64 | tr -d '\n'`/" "./.env.local"
@sed -i "s/TOKEN_PUBLIC_KEY.*/TOKEN_PUBLIC_KEY=`cat ./token.pub | base64 | tr -d '\n'`/" "./.env.local"
@rm -r ./token ./token.pub
test-backend-cov: test-setup
@ginkgo --cover \
--race \
--json-report=report.json \
--output-dir=reports/go \
--skip-package generated \
--skip-file mock \
./...