-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
125 lines (87 loc) · 3.01 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
export DIR=ipcmanview_data
export VITE_HOST=127.0.0.1
export WEB_PATH=internal/web
-include .env
TOOL_AIR=github.com/cosmtrek/air@v1.51.0
TOOL_TASK=github.com/go-task/task/v3/cmd/task@v3.35.1
TOOL_GOOSE=github.com/pressly/goose/v3/cmd/goose@v3.18.0
TOOL_SQLC=github.com/sqlc-dev/sqlc/cmd/sqlc@v1.25.0
TOOL_TWIRP=github.com/twitchtv/twirp/protoc-gen-twirp@v8.1.3
TOOL_PROTOC_GEN_GO=google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0
TOOL_OAPI_CODEGEN=github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@v2.1.0
PROTOC_VERSION=25.1
PROTOC_ZIP=protoc-$(PROTOC_VERSION)-linux-x86_64.zip
_:
mkdir -p $(WEB_PATH)/dist $(DIR) && touch $(WEB_PATH)/dist/index.html
clean:
rm -rf $(DIR)
migrate:
goose -dir internal/sqlite/migrations sqlite3 $(DIR)/sqlite.db up
generate:
go generate ./...
run:
go run ./cmd/ipcmanview serve
debug:
go run ./cmd/ipcmanview debug
preview: generate run
migration:
atlas migrate diff $(name) --env local
hash:
atlas migrate hash --env local
# ---------- Dev
# Start backend
dev:
air
# Start frontend
dev-web:
cd $(WEB_PATH) && pnpm install && pnpm run dev
# Proxy request to frontend and backend
dev-proxy:
go run ./scripts/dev-proxy
# ---------- Gen
# Generate code
gen: gen-sqlc gen-proto gen-mediamtx gen-pubsub gen-hub gen-typescriptify
gen-sqlc:
sqlc generate
gen-proto:
cd rpc && protoc --go_out=. --twirp_out=. rpc.proto
cd $(WEB_PATH) && mkdir -p ./src/twirp && pnpm exec protoc --ts_out=./src/twirp --ts_opt=generate_dependencies --proto_path=$(shell readlink -f rpc) --ts_opt long_type_string rpc.proto
gen-mediamtx:
oapi-codegen -package mediamtx ./internal/mediamtx/swagger.json > ./internal/mediamtx/mediamtx.gen.go
gen-pubsub:
sh ./scripts/generate-pubsub-events.sh ./internal/bus/models.go
gen-hub:
go run ./scripts/generate-hub ./internal/bus/models.go
gen-typescriptify:
go run ./scripts/typescriptify $(WEB_PATH)/src/lib/models.gen.ts
# ---------- Tooling
# Install tooling
tooling: tooling-air tooling-task tooling-goose tooling-sqlc tooling-twirp tooling-protoc-gen-go tooling-protoc-gen-ts tooling-oapi-codegen
tooling-build: tooling-task tooling-sqlc tooling-twirp tooling-protoc-gen-go tooling-protoc-gen-ts tooling-oapi-codegen
tooling-air:
go install $(TOOL_AIR)
tooling-task:
go install $(TOOL_TASK)
tooling-goose:
go install $(TOOL_GOOSE)
tooling-sqlc:
go install $(TOOL_SQLC)
tooling-twirp:
go install $(TOOL_TWIRP)
tooling-protoc-gen-go:
go install $(TOOL_PROTOC_GEN_GO)
tooling-protoc-gen-ts:
cd $(WEB_PATH) && pnpm install
tooling-oapi-codegen:
go install $(TOOL_OAPI_CODEGEN)
# ---------- Install
install-protoc:
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/$(PROTOC_ZIP)
sudo unzip -o $(PROTOC_ZIP) -d /usr/local bin/protoc
sudo unzip -o $(PROTOC_ZIP) -d /usr/local 'include/*'
rm $(PROTOC_ZIP)
install-atlas:
# TODO: pin atlas version
curl -OL https://release.ariga.io/atlas/atlas-community-linux-amd64-latest
chmod +x atlas-community-linux-amd64-latest
mv atlas-community-linux-amd64-latest ~/.local/bin/atlas