-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
142 lines (112 loc) · 3.16 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
SHELL := /bin/bash
include .env
export
export APP_NAME := $(basename $(notdir $(shell pwd)))
.PHONY: help
help: ## display this help screen
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: aqua
aqua: ## install aqua ref. https://aquaproj.github.io/
@brew install aquaproj/aqua/aqua
.PHONY: tool
tool: ## install tool
@aqua install
.PHONY: build
build: ## go build
@go build -v ./... && go clean
.PHONY: fmt
fmt: ## go format
@go fmt ./...
.PHONY: lint
lint: ## go lint ref. https://golangci-lint.run/
@golangci-lint run ./... --fix
.PHONY: mod
mod: ## go mod tidy & go mod vendor
@go mod tidy
@go mod vendor
.PHONY: update
update: ## go modules update
@go get -u -t ./...
@go mod tidy
@go mod vendor
.PHONY: gen
gen: ## Generate code.
@go generate ./...
@go mod tidy
@go mod vendor
.PHONY: load
load: ## api server reload
@touch cmd/api/main.go
.PHONY: test
test: ## unit test
@$(call _test,${c})
define _test
if [ -z "$1" ]; then \
go test ./internal/... ; \
else \
go test ./internal/... -count=1 ; \
fi
endef
.PHONY: integration
integration: ## run integration test. If you want to invalidate the cache, please specify an argument like `make integration c=c`.
@$(call _integration,${c})
define _integration
if [ -z "$1" ]; then \
go test ./test/integration/... ; \
else \
go test ./test/integration/... -count=1 ; \
fi
endef
.PHONY: e2e
e2e: ## run e2e test. If you want to invalidate the cache, please specify an argument like `make e2e c=c`.
@$(call _e2e,${c})
define _e2e
if [ -z "$1" ]; then \
go test ./test/e2e/... ; \
else \
go test ./test/e2e/... -count=1 ; \
fi
endef
.PHONY: up
up: ## docker compose up with air hot reload
@docker compose --project-name ${APP_NAME} --file ./.docker/compose.yaml up -d
.PHONY: web
web: ## run web server
@(cd web && bun run dev)
.PHONY: down
down: ## docker compose down
@docker compose --project-name ${APP_NAME} down --volumes
.PHONY: balus
balus: ## destroy everything about docker. (containers, images, volumes, networks.)
@docker compose --project-name ${APP_NAME} down --rmi all --volumes
.PHONY: ymlfmt
ymlfmt: ## format yaml file
@yamlfmt
.PHONY: ymlint
ymlint: ## lint yaml file
@yamlfmt -lint
.PHONY: psql
psql:
@docker exec -it ${APP_NAME}-postgres psql -U postgres
.PHONY: migrate
migrate: ## migrate atlas schema
@atlas schema apply -u ${DATABASE_URL} --to file://schema/schema.hcl --auto-approve
.PHONY: prismastudio
prismastudio: ## execute prisma studio
@(cd schema && bun run prisma studio)
.PHONY: prismapush
prismapush: ## migrate prisma schema
@(cd schema && bun run prisma db push)
.PHONY: prismapull
prismapull: ## import prisma schema
@(cd schema && bun run prisma db pull)
.PHONY: atlasinspect
atlasinspect: ## import atlas schema
@atlas schema inspect -u ${DATABASE_URL} > schema/schema.hcl
.PHONY: schemafmt
schemafmt:
@atlas schema fmt schema/schema.hcl
@(cd schema && bun run prisma format)
.PHONY: doc
doc: ## generate document
@bunx @redocly/cli build-docs api/openapi.yaml --output ./doc/api/index.html