-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (55 loc) · 2.28 KB
/
Makefile
File metadata and controls
71 lines (55 loc) · 2.28 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
SHELL := /bin/sh
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || \
echo v0)
.PHONY: help all fmt vet test build ui run-dev run-test web-dev build-proto
help: ## Display this help screen
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
all: fmt vet test ui build ## Run all checks, build UI, and build backend
fmt: ## Run go fmt
go fmt ./...
vet: ## Run go vet
go vet ./...
test: ## Run go test
go test ./...
ui: ## Build the frontend (React)
cd web && npm install && npm run build
rm -rf internal/ui/dist
mkdir -p internal/ui/dist
cp -r web/dist/* internal/ui/dist/
build: ## Build the backend binary
@go build \
-tags release \
-ldflags '-X github.com/ygelfand/power-dash/internal/cli.PowerDashVersion=$(VERSION)' \
-o bin/power-dash cmd/power-dash/main.go
run-dev: build ## Run backend with hot-reloading frontend
@mkdir -p tmp/data
@echo "Starting power-dash dev environment..."
@echo "Backend: http://localhost:8080"
@echo "Frontend: http://localhost:8000"
@trap 'kill 0' EXIT; \
(cd web && npm run dev) & \
./bin/power-dash run --config fixtures/power-dash.yaml --log-level info --listen :8080
run-dev-nc: build ## Run backend with hot-reloading frontend without collector
@mkdir -p tmp/data
@echo "Starting power-dash dev environment..."
@echo "Backend: http://localhost:8080"
@echo "Frontend: http://localhost:8000"
@trap 'kill 0' EXIT; \
(cd web && npm run dev) & \
./bin/power-dash run --no-collector --config fixtures/power-dash.yaml --log-level info --listen :8080
run-test: ui build ## Run backend with embedded frontend (production simulation)
@mkdir -p tmp/data
@echo "Starting power-dash in embedded (test) mode on port 8080..."
@./bin/power-dash run --config fixtures/power-dash.yaml -log-level info --listen :8080
web-dev: ## Run just the frontend dev server
cd web && npm run dev
web-lint: ## Run frontend linter
cd web && npm run lint
web-build: ## Build the frontend
cd web && npm install && npm run build
web-check: web-lint web-build ## Run frontend lint and build
build-proto: ## Build the protobuf files
protoc --go_out=. api/proto/*.proto