-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (64 loc) Β· 2.85 KB
/
Copy pathMakefile
File metadata and controls
81 lines (64 loc) Β· 2.85 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
.PHONY: all build clean fmt test verify vet run run-rest run-hot run-dev build-smart-studio build-prod run-migrate
all: verify
fmt:
test -z "$$(gofmt -l .)"
test: build-ui
go test ./... -race -coverprofile=coverage.out
vet: build-ui
go vet ./...
build-ui:
cd ui && npm install && npm run build
# build-smart-studio builds the SMART Studio React app (../smart-studio) and copies its dist into
# ./smart-studio/dist so it can be served same-origin from this server in production,
# eliminating CORS. Mirrors build-ui. Optional: only needed for prod deploys;
# the dev workflow uses Vite at :3000 + the CORS middleware.
build-smart-studio:
cd ../smart-studio && npm install && npm run build
mkdir -p smart-studio/dist
cp -r ../smart-studio/dist/. smart-studio/dist/
build: build-ui
go build ./...
# build-prod produces ONE self-contained binary that serves the SMART Studio React
# frontend AND the metaai-go REST API on the same origin (no CORS in prod).
# Pipeline: build SMART Studio β copy into embed dir β embed into the Go binary.
# Output: ./bin/metaai-rest (static assets baked in).
build-prod: build-smart-studio
mkdir -p bin
go build -o bin/metaai-rest ./cmd/metaai-rest
@echo ""
@echo "β Built bin/metaai-rest (SMART Studio SPA + REST API, single binary)"
@echo " Run with: META_AI_REST_TOKEN=... ./bin/metaai-rest"
# run-migrate rebuilds SMART Studio's dist into the embed dir without recompiling Go,
# useful after a frontend-only change while iterating on a running prod binary.
# (Re-run build-prod to bake the new assets into a fresh binary.)
run-migrate: build-smart-studio
@echo "β SMART Studio dist refreshed at smart-studio/dist (run 'make build-prod' to embed into binary)"
# run boots the OpenAI/Anthropic-compatible API proxy server.
run:
go run ./cmd/metaai-server
# run-rest boots the REST API server (/chat, /image, /video, ...).
run-rest:
go run ./cmd/metaai-rest
# run-hot starts the REST API with air hot-reload: every .go or .env change
# rebuilds + restarts the server automatically (like Vite HMR but for Go).
# Requires `go install github.com/air-verse/air@latest`.
run-hot:
$$(go env GOPATH)/bin/air
# run-dev starts BOTH the hot-reloaded Go API AND the SMART Studio Vite dev server,
# so a single command gives you the full dev loop with auto-reload on both
# sides. Ctrl-C kills both.
run-dev:
@echo "Starting Go API (air hot-reload on :8000) + SMART Studio Vite (HMR on :3000)..."
@trap 'kill 0' INT; \
( $$(go env GOPATH)/bin/air ) & api_pid=$$!; \
( cd ../smart-studio && npm run dev ) & vite_pid=$$!; \
wait
# run-token boots the proxy with a bearer token clients must present.
run-token:
go run ./cmd/metaai-server -token "$$META_AI_PROXY_TOKEN"
verify: fmt test vet build
clean:
go clean ./...
rm -f coverage.out coverage.html
rm -rf ui/dist bin
rm -f smart-studio/dist/index.html smart-studio/dist/assets -r 2>/dev/null || true