-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (38 loc) · 1.19 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
SRC = $(shell find . -type f -name '*.go' -not -path "./database/*")
REGEN_DIRS = $(shell find . -name '*.go' | xargs grep -l //go:generate | xargs dirname | sort | uniq)
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
.PHONY: regen
regen: $(patsubst %, %/.go-generate, $(REGEN_DIRS)) ## Regenerate all code.
.PHONY: migrate
migrate: ## Create all databases and apply migrations
$(MAKE) -C server/db migrate
.PHONY:
dev-boost:
reflex -d fancy -c reflex-boost.conf
.PHONY:
dev-export:
reflex -d fancy -c reflex-export.conf
.PHONY:
dev-sponsor:
reflex -d fancy -c reflex-sponsor.conf
.PHONY:
reset:
rm -rf tmp/dbs/*.sql
.PHONY: regen
regen: $(patsubst %, %/.go-generate, $(REGEN_DIRS)) ## Regenerate all code.
$(MAKE) -C database regen
.PHONY: lint
lint: ## Lint the code.
golangci-lint run
.PHONY:
fmt: ## Format all code.
@gofmt -l -w $(SRC)
# Generate rules for each directory that has files with go:generate directives.
define GO_GENERATE_RULE
$1/.go-generate: $1/*.go
go generate -x $1
touch $1/.go-generate
endef
$(foreach dir,$(REGEN_DIRS),$(eval $(call GO_GENERATE_RULE,$(dir))))