-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
112 lines (82 loc) · 2.64 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
##### Update Targets
.PHONY: update
update: update-go update-frontend
.PHONY: update-go
update-go:
go mod download
.PHONY: update-frontend
update-frontend:
cd frontend && npm install
##### Clean Targets
.PHONY: clean-all
clean-all: clean-backend
.PHONY: clean-backend
clean-backend:
docker-compose down -v
##### Test Targets
.PHONY: test-all
test-all: test-backend test-frontend
.PHONY: test-backend
test-backend:
cd backend && go vet ./... && go test ./...
.PHONY: test-frontend
test-frontend:
cd frontend && npm run test
##### Linting/Tidy/Format Targets
.PHONY: tidy-all
tidy-all: format-backend lint-frontend
.PHONY: format-backend
format-backend:
gofmt -w backend
.PHONY: lint-frontend
lint-frontend:
cd frontend && npm run lint
# tidy-go removes unused/outdated go modules. This frequently causes conflicts so it is not included in tidy-all
.PHONY: tidy-go
tidy-go:
go mod tidy
##### Run Targets
# run-backend starts up a fresh instance of the backend -- typically what you want when working on new features
.PHONY: run-backend
run-backend: clean-backend rerun-backend
# rerun-Backend restarts a stopped instance of the backend -- useful if you want to preserve database data between runs
.PHONY: rerun-backend
rerun-backend:
docker-compose up --build
.PHONY: run-prod
run-prod:
docker-compose -f docker-compose-prod.yml down
docker-compose -f docker-compose-prod.yml up --build
##### Helpers
# view-backend enters the docker container running the backend
.PHONY: view-backend
view-backend:
docker exec -it ashirt-server_backend_1 /bin/sh
# view-frontend enters the docker container running the frontend
.PHONY: view-frontend
view-frontend:
docker exec -it ashirt-server_frontend_1 /bin/sh
# view-db enters the docker container running the database
.PHONY: view-db
view-db:
docker exec -it ashirt-server_db_1 /bin/bash
# new-migration generates a new "migration" (database alteration) when a schema/data change is necessary.
.PHONY: new-migration
new-migration:
bin/create-migration.sh
# migrate-up runs all pending migrations
.PHONY: migrate-up
migrate-up:
bin/migrate-up
# prep is shorthand for formatting and testing. Useful when prepping for a new Pull Request.
.PHONY: prep
prep: tidy-all test-all
# gentypes is a mechanism manually to re-create the dtos.ts file needed by the frontend. Typically this
# will not need to be called directly. Instead, webpack will generate this for you.
.PHONY: gentypes
gentypes:
mkdir -p frontend/src/services/data_sources/dtos
go run backend/dtos/gentypes/generate_typescript_types.go > frontend/src/services/data_sources/dtos/dtos.ts
.PHONY: build-test
build-test:
go build -o /dev/null backend/bin/dev/dev.go