-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
179 lines (140 loc) · 5.74 KB
/
Copy pathMakefile
File metadata and controls
179 lines (140 loc) · 5.74 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
177
178
179
# ─────────────────────────────────────────────
# xops — boot.xops Makefile
# Universal bootstrap for the deployment platform
# ─────────────────────────────────────────────
SHELL := /bin/bash
.DEFAULT_GOAL := help
# Colors
BOLD := \033[1m
GREEN := \033[32m
CYAN := \033[36m
RESET := \033[0m
##@ 🚀 Bootstrap
.PHONY: bootstrap
bootstrap: check-deps env infra-up install db-migrate worm-codegen ## Full first-run setup (run this once)
@echo -e "\n$(GREEN)$(BOLD)✅ xops is ready!$(RESET)"
@echo -e " Run $(CYAN)make dev$(RESET) to start all services."
@echo -e " Run $(CYAN)make open$(RESET) to open the app in your browser.\n"
.PHONY: check-deps
check-deps: ## Check required dependencies
@echo -e "$(BOLD)Checking dependencies...$(RESET)"
@command -v node >/dev/null 2>&1 || { echo "❌ node is required. https://nodejs.org"; exit 1; }
@node -e "const v=process.versions.node.split('.')[0]; if(v<20){process.exit(1)}" || { echo "❌ node >= 20 required"; exit 1; }
@command -v pnpm >/dev/null 2>&1 || { echo "📦 Installing pnpm..."; npm install -g pnpm@9; }
@command -v docker >/dev/null 2>&1 || { echo "❌ Docker is required. https://docs.docker.com/get-docker/"; exit 1; }
@docker compose version >/dev/null 2>&1 || { echo "❌ Docker Compose v2 is required."; exit 1; }
@echo -e "$(GREEN)✔ All dependencies found$(RESET)"
.PHONY: env
env: ## Copy .env.example → .env (skip if already exists)
@if [ ! -f .env ]; then \
cp .env.example .env; \
echo -e "$(GREEN)✔ Created .env from .env.example$(RESET)"; \
echo -e " $(CYAN)Edit .env to set your secrets before continuing.$(RESET)"; \
else \
echo "✔ .env already exists — skipping"; \
fi
.PHONY: install
install: ## Install all pnpm dependencies (set GITHUB_TOKEN for GPR-only @decoperations packages)
@echo -e "$(BOLD)Installing dependencies...$(RESET)"
pnpm install
@echo -e "$(GREEN)✔ Dependencies installed$(RESET)"
.PHONY: worm-codegen
worm-codegen: ## Regenerate TypeScript stubs from .worm/schema.json
pnpm --filter @xops/web run worm:codegen
@echo -e "$(GREEN)✔ s3worm types regenerated$(RESET)"
##@ 🐳 Infrastructure
.PHONY: infra-up
infra-up: ## Start Docker services (Postgres, Redis, MinIO)
@echo -e "$(BOLD)Starting infrastructure...$(RESET)"
docker compose -f infrastructure/docker/docker-compose.yml up -d
@echo -e "$(GREEN)✔ Infrastructure running$(RESET)"
@echo -e " Postgres → localhost:5432"
@echo -e " Redis → localhost:6379"
@echo -e " MinIO → localhost:9000 (console: localhost:9001)"
.PHONY: infra-down
infra-down: ## Stop Docker services
docker compose -f infrastructure/docker/docker-compose.yml down
.PHONY: infra-reset
infra-reset: ## Wipe and restart Docker services (⚠️ destroys data)
docker compose -f infrastructure/docker/docker-compose.yml down -v
$(MAKE) infra-up
.PHONY: infra-logs
infra-logs: ## Tail infrastructure logs
docker compose -f infrastructure/docker/docker-compose.yml logs -f
##@ 🗄️ Database
.PHONY: db-migrate
db-migrate: ## Run database migrations
@echo -e "$(BOLD)Running migrations...$(RESET)"
pnpm --filter @xops/db run db:migrate
@echo -e "$(GREEN)✔ Migrations applied$(RESET)"
.PHONY: db-push
db-push: ## Push schema directly (dev only)
pnpm --filter @xops/db run db:push
.PHONY: db-studio
db-studio: ## Open Drizzle Studio
pnpm --filter @xops/db run db:studio
.PHONY: db-seed
db-seed: ## Seed database with dev data
pnpm --filter @xops/db run db:seed
##@ 🔧 Development
.PHONY: dev
dev: ## Start all apps in dev mode
pnpm run dev
.PHONY: dev-web
dev-web: ## Start web app only
pnpm --filter @xops/web run dev
.PHONY: dev-builder
dev-builder: ## Start builder service only
pnpm --filter @xops/builder run dev
.PHONY: dev-docs
dev-docs: ## Start docs site only
pnpm --filter @xops/docs run dev
##@ 🏗️ Build
.PHONY: build
build: ## Build all packages and apps
pnpm run build
.PHONY: build-web
build-web: ## Build web app only
pnpm --filter @xops/web run build
.PHONY: typecheck
typecheck: ## Run TypeScript type checks across all packages
pnpm run typecheck
.PHONY: lint
lint: ## Run ESLint across all packages
pnpm run lint
.PHONY: test
test: ## Run tests across all packages
pnpm run test
##@ 🔨 CLI
.PHONY: cli-build
cli-build: ## Build the xops CLI
pnpm --filter @xops/cli run build
.PHONY: cli-link
cli-link: ## Link CLI globally for local development
pnpm --filter @xops/cli run build
pnpm --filter @xops/cli link --global
@echo -e "$(GREEN)✔ 'xops' command linked globally$(RESET)"
.PHONY: cli-unlink
cli-unlink: ## Unlink global CLI
pnpm unlink --global @xops/cli
##@ 🧹 Maintenance
.PHONY: clean
clean: ## Remove build artifacts and node_modules
pnpm run clean
find . -name "node_modules" -type d -prune -exec rm -rf {} + 2>/dev/null; true
find . -name ".turbo" -type d -prune -exec rm -rf {} + 2>/dev/null; true
find . -name "dist" -type d -prune -exec rm -rf {} + 2>/dev/null; true
find . -name ".next" -type d -prune -exec rm -rf {} + 2>/dev/null; true
@echo -e "$(GREEN)✔ Clean$(RESET)"
.PHONY: format
format: ## Format all files with Prettier
pnpm run format
.PHONY: open
open: ## Open the web app in browser
@open http://localhost:3000 2>/dev/null || xdg-open http://localhost:3000 2>/dev/null || echo "Open http://localhost:3000"
##@ ℹ️ Help
.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\n$(BOLD)xops$(RESET) — boot.xops deployment platform\n\nUsage: make $(CYAN)<target>$(RESET)\n"} \
/^[a-zA-Z_0-9-]+:.*?##/ { printf " $(CYAN)%-20s$(RESET) %s\n", $$1, $$2 } \
/^##@/ { printf "\n$(BOLD)%s$(RESET)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)