-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
154 lines (115 loc) · 4.91 KB
/
Copy pathMakefile
File metadata and controls
154 lines (115 loc) · 4.91 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
# OME Web Console Makefile
# Run 'make help' to see available commands
.PHONY: help dev dev-frontend dev-backend build build-frontend build-backend \
run-backend start-frontend install install-frontend install-backend \
clean lint test test-backend test-frontend
# Colors for terminal output
CYAN := \033[36m
GREEN := \033[32m
YELLOW := \033[33m
RESET := \033[0m
# Directories
FRONTEND_DIR := frontend
BACKEND_DIR := backend
BACKEND_BIN := $(BACKEND_DIR)/bin/api
# Default target
.DEFAULT_GOAL := help
##@ Development
dev: ## Start both frontend and backend in development mode
@echo "$(CYAN)Starting OME Web Console...$(RESET)"
@$(MAKE) -j2 dev-frontend dev-backend
dev-frontend: ## Start frontend development server (port 3000)
@echo "$(GREEN)Starting frontend on http://localhost:3000$(RESET)"
@cd $(FRONTEND_DIR) && npm run dev
dev-backend: ## Start backend development server (port 8080)
@echo "$(GREEN)Starting backend on http://localhost:8080$(RESET)"
@cd $(BACKEND_DIR) && go run ./cmd/api
##@ Building
build: build-backend build-frontend ## Build both frontend and backend
build-frontend: ## Build frontend for production
@echo "$(CYAN)Building frontend...$(RESET)"
@cd $(FRONTEND_DIR) && npm run build
@echo "$(GREEN)Frontend build complete$(RESET)"
build-backend: ## Build backend binary
@echo "$(CYAN)Building backend...$(RESET)"
@cd $(BACKEND_DIR) && go build -o bin/api ./cmd/api
@echo "$(GREEN)Backend binary: $(BACKEND_BIN)$(RESET)"
##@ Running
run-backend: $(BACKEND_BIN) ## Run the backend binary
@echo "$(GREEN)Running backend on http://localhost:$${PORT:-8080}$(RESET)"
@cd $(BACKEND_DIR) && ./bin/api
start-frontend: ## Start frontend production server
@echo "$(GREEN)Starting frontend production server...$(RESET)"
@cd $(FRONTEND_DIR) && npm run start
##@ Dependencies
install: install-backend install-frontend ## Install all dependencies
install-frontend: ## Install frontend dependencies
@echo "$(CYAN)Installing frontend dependencies...$(RESET)"
@cd $(FRONTEND_DIR) && npm install
@echo "$(GREEN)Frontend dependencies installed$(RESET)"
install-backend: ## Download Go modules
@echo "$(CYAN)Downloading Go modules...$(RESET)"
@cd $(BACKEND_DIR) && go mod download
@echo "$(GREEN)Go modules downloaded$(RESET)"
##@ Quality
lint: lint-frontend lint-backend ## Run all linters
lint-frontend: ## Run frontend linter (ESLint)
@echo "$(CYAN)Linting frontend...$(RESET)"
@cd $(FRONTEND_DIR) && npm run lint
lint-backend: ## Run backend linter
@echo "$(CYAN)Linting backend...$(RESET)"
@cd $(BACKEND_DIR) && go vet ./...
format: format-frontend format-backend ## Format all code
format-frontend: ## Format frontend code (Prettier)
@echo "$(CYAN)Formatting frontend...$(RESET)"
@cd $(FRONTEND_DIR) && npm run format
@echo "$(GREEN)Frontend formatted$(RESET)"
format-backend: ## Format backend code (gofmt)
@echo "$(CYAN)Formatting backend...$(RESET)"
@cd $(BACKEND_DIR) && go fmt ./...
@echo "$(GREEN)Backend formatted$(RESET)"
format-check: ## Check formatting without making changes
@echo "$(CYAN)Checking frontend formatting...$(RESET)"
@cd $(FRONTEND_DIR) && npm run format:check
typecheck: ## Run TypeScript type checking
@echo "$(CYAN)Type checking frontend...$(RESET)"
@cd $(FRONTEND_DIR) && npm run typecheck
test: test-backend test-frontend ## Run all tests
test-backend: ## Run backend tests
@echo "$(CYAN)Running backend tests...$(RESET)"
@cd $(BACKEND_DIR) && go test -v ./...
test-frontend: ## Run frontend tests (typecheck)
@echo "$(CYAN)Running frontend tests...$(RESET)"
@cd $(FRONTEND_DIR) && npm run test
##@ Utilities
clean: ## Clean build artifacts
@echo "$(YELLOW)Cleaning build artifacts...$(RESET)"
@rm -rf $(BACKEND_DIR)/bin
@rm -rf $(FRONTEND_DIR)/.next
@rm -rf $(FRONTEND_DIR)/out
@echo "$(GREEN)Clean complete$(RESET)"
check-backend: ## Check if backend is running
@curl -s http://localhost:8080/health > /dev/null 2>&1 && \
echo "$(GREEN)Backend is running$(RESET)" || \
echo "$(YELLOW)Backend is not running$(RESET)"
check-frontend: ## Check if frontend is running
@curl -s http://localhost:3000 > /dev/null 2>&1 && \
echo "$(GREEN)Frontend is running$(RESET)" || \
echo "$(YELLOW)Frontend is not running$(RESET)"
status: check-backend check-frontend ## Check status of both services
##@ Help
help: ## Show this help message
@echo "$(CYAN)OME Web Console$(RESET)"
@echo ""
@echo "Usage: make [target]"
@echo ""
@awk 'BEGIN {FS = ":.*##"; printf ""} /^[a-zA-Z_-]+:.*?##/ { printf " $(CYAN)%-18s$(RESET) %s\n", $$1, $$2 } /^##@/ { printf "\n$(GREEN)%s$(RESET)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@echo ""
@echo "$(YELLOW)Examples:$(RESET)"
@echo " make dev # Start development servers"
@echo " make build # Build for production"
@echo " make install # Install dependencies"
@echo " PORT=9090 make run-backend # Run backend on custom port"
# Ensure backend binary exists before running
$(BACKEND_BIN):
@$(MAKE) build-backend