-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
176 lines (133 loc) · 4.72 KB
/
Makefile
File metadata and controls
176 lines (133 loc) · 4.72 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Layer 2: Load environment variables
# Default to dev if not specified. Can be overridden via: make <target> APP_ENV=preprod
APP_ENV ?= dev
-include .env
-include .env.$(APP_ENV)
export
# Derived variables
DBSTRING := "postgresql://$(DB_USER):$(DB_PASS)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)"
GOOSE_MIGRATION_DIR := "./internal/db/migration"
SUPABASE_DIR := "./deployments/docker/_supabase"
.PHONY: client-dev client-web-dev client-android-dev client-ios-dev client-preprod client-web-preprod \
client-android-preprod client-ios-preprod client-prod client-web-prod client-android-prod client-ios-prod \
client-relay client-relay-watch client-lint client-lint-fix clien run test test-dev test-preprod test-prod \
gen-graph gen-graph-server gen-graph-client gen-sql mig-up mig-down mig-create supabase-compose dev preprod \
prod run-prod
# --- Client Development Targets ---
# Runs dev server for all platforms
client-dev:
pnpm dev
client-web-dev:
pnpm --filter @meissa/web dev
#client-android-dev:
# pnpm --filter @meissa/andoird dev
#client-ios-dev:
# pnpm --filter @meissa/ios dev
# --- Client Preprod (Build) Targets ---
client-preprod:
pnpm build:preprod
client-web-preprod:
pnpm --filter @meissa/web build:preprod
#client-android-preprod:
# pnpm --filter @meissa/android build:preprod
#client-ios-preprod:
# pnpm --filter @meissa/ios build:preprod
# --- Client Prod (Build) Targets ---
# Builds all client platforms
client-prod:
pnpm install --frozen-lockfile && pnpm build:prod
client-web-prod:
pnpm --filter @meissa/web build:prod
#client-android-prod:
# pnpm --filter @meissa/android build:prod
#client-ios-prod:
# pnpm --filter @meissa/ios build:prod
# --- Client Relay Target ---
client-relay:
pnpm relay
client-relay-watch:
pnpm relay-watch
# --- Linting and Formatting ---
client-lint:
pnpm lint
client-lint-fix:
pnpm lint:fix
# --- Server Generating Targets ---
gen-sql:
@echo "Generating SQL code..."
go tool sqlc generate -f ./configs/sqlc.yaml
gen-graph:
@echo "Generating GraphQL code..."
@$(MAKE) gen-graph-server
@$(MAKE) gen-graph-client
gen-graph-server:
@echo "Generating GraphQL server code..."
go tool gqlgen generate --config ./configs/gqlgen.yml
gen-graph-client:
@echo "Generating GraphQL client code..."
go tool gqlgenc generate --configdir configs
# Calls the run target with APP_ENV=dev
dev:
@$(MAKE) run APP_ENV=dev
# Calls the run target with APP_ENV=preprod
preprod:
@$(MAKE) run APP_ENV=preprod
# Calls the run target with APP_ENV=prod
prod:
@echo "Building the server for production ($(APP_ENV))"
go build -o build/meissa -v ./cmd
run-prod:
@echo "run-prod is disabled temporarily. It is not working."
# @$(MAKE) prod APP_ENV=prod && APP_ENV=prod ./build/meissa serve
# make run APP_ENV=<env> (defaults to dev if just run `make run`)
run:
@echo "Running the server ($(APP_ENV))"
go run ./cmd/ serve
# make test APP_ENV=<env> (defaults to dev if just run `make test`)
test:
@echo "Running tests ($(APP_ENV))"
go test -v ./...
test-dev:
@$(MAKE) test APP_ENV=dev
test-preprod:
@$(MAKE) test APP_ENV=preprod
test-prod:
@$(MAKE) test APP_ENV=prod
# make mig-up APP_ENV=<env> (defaults to dev if just run `make mig-up`)
mig-up:
@echo "DB migration up ($(APP_ENV))"
@GOOSE_DRIVER=$(DB_DRIVER) GOOSE_DBSTRING=$(DBSTRING) go tool goose --dir $(GOOSE_MIGRATION_DIR) up
# make mig-down APP_ENV=<env> (defaults to dev if just run `make mig-down`)
mig-down:
@echo "DB migration down ($(APP_ENV))"
@GOOSE_DRIVER=$(DB_DRIVER) GOOSE_DBSTRING=$(DBSTRING) go tool goose --dir $(GOOSE_MIGRATION_DIR) down
# make mig-create name=<migration_file_name>
mig-create:
@if [ -z "$(name)" ]; then echo "Error: 'name' is required. Usage: make mig-create name=migration_name"; exit 1; fi
@echo "Creating migration file..."
go tool goose -dir $(GOOSE_MIGRATION_DIR) create $(name) sql
# Usage: make supabase-compose [up|start|stop|down]
supabase-compose:
@case "$(filter-out $@,$(MAKECMDGOALS))" in \
up) \
echo "Compose up Supabase Docker services..." ; \
cd $(SUPABASE_DIR) && docker compose --env-file .env up -d ;; \
start) \
echo "Starting Supabase Docker services..." ; \
cd $(SUPABASE_DIR) && docker compose --env-file .env start ;; \
stop) \
echo "Stopping Supabase Docker services..." ; \
cd $(SUPABASE_DIR) && docker compose --env-file .env stop ;; \
down) \
echo "Stopping and removing Supabase Docker services..." ; \
cd $(SUPABASE_DIR) && docker compose --env-file .env down -v --rmi all --remove-orphans ;; \
*) \
echo "Usage: make supabase-compose [up|start|stop|down]" ; \
exit 1 ;; \
esac
# Necessary to allow passing subcommands as targets
up start stop down:
@:
#go tool goose -dir ./internal/db/migration postgres create add_some_column sql
debug:
@echo "DEBUG: $(GOOSE_DBSTRING)"