-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
285 lines (249 loc) · 10.3 KB
/
Makefile
File metadata and controls
285 lines (249 loc) · 10.3 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# Makefile for Snowdream Tech AI IDE Template
# Purpose: Unified entry point for cross-platform project orchestration and developer governance.
# Design:
# - POSIX-compliant shell delegation with Windows-specific Batch abstractions.
# - Standardized lifecycle targets: init -> setup -> install -> verify -> audit.
# - "World Class" AI documentation style (English-only technical metadata).
# =============================================================================
# Global Options
# =============================================================================
# Verbosity level: 0 (quiet), 1 (normal), 2 (verbose)
# Supports: make setup VERBOSE=2 or make setup V=2
V ?= 1
VERBOSE ?= $(V)
export VERBOSE
# Pass flags to sub-scripts
SCRIPT_ARGS :=
ifeq ($(shell [ $(VERBOSE) -ge 2 ] && echo 1),1)
SCRIPT_ARGS += --verbose
endif
ifeq ($(shell [ $(VERBOSE) -eq 0 ] && echo 1),1)
SCRIPT_ARGS += --quiet
endif
# =============================================================================
# OS Detection
# =============================================================================
ifeq ($(OS),Windows_NT)
# Detect if we are running in a POSIX-like environment (Git Bash, WSL, etc.)
# We check if 'sh' works and returns expected output.
IS_POSIX := $(shell sh -c 'echo 1' 2>/dev/null)
ifeq ($(IS_POSIX),1)
OS_NAME := POSIX_WINDOWS
ARCH_NAME := $(shell uname -m)
SHELL_NAME := $(shell basename $$SHELL)
# Colors for POSIX
BLUE := $(shell printf '\033[0;34m')
GREEN := $(shell printf '\033[0;32m')
YELLOW := $(shell printf '\033[1;33m')
RED := $(shell printf '\033[0;31m')
NC := $(shell printf '\033[0m')
else
OS_NAME := Windows
ARCH_NAME := $(PROCESSOR_ARCHITECTURE)
SHELL_NAME := powershell.exe
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -Command
# Colors for native Windows (PowerShell handles this, but for make echo)
BLUE :=
GREEN :=
YELLOW :=
RED :=
NC :=
endif
else
OS_NAME := $(shell uname -s)
ARCH_NAME := $(shell uname -m)
SHELL_NAME := $(shell basename $$SHELL)
# Colors for POSIX
BLUE := $(shell printf '\033[0;34m')
GREEN := $(shell printf '\033[0;32m')
YELLOW := $(shell printf '\033[1;33m')
RED := $(shell printf '\033[0;31m')
NC := $(shell printf '\033[0m')
endif
# SSoT Project Metadata
PROJECT_VERSION := $(shell cat VERSION 2>/dev/null || echo "unknown")
GIT_BRANCH := $(shell git branch --show-current 2>/dev/null || echo "not a git repo")
# =============================================================================
# Targets
# =============================================================================
.PHONY: all help init setup install lint format test build clean commit verify release env update audit health bench docs archive-changelog check-env sync-docs precommit license-add license-check gen-dependabot sync-labels sync-harden-runner sync-lock update-tools
# Default target: display help
all: help
help: ## Show this help message
@printf "$(BLUE)Snowdream Tech AI IDE Template$(NC) ($(GREEN)v$(PROJECT_VERSION)$(NC))\n"
@printf "%-16s $(GREEN)$(OS_NAME)$(NC) ($(ARCH_NAME))\n" "Detected OS:"
@printf "%-16s $(GREEN)$(SHELL_NAME)$(NC)\n" "Current Shell:"
@printf "%-16s $(GREEN)$(GIT_BRANCH)$(NC)\n\n" "Git Branch:"
@printf "$(YELLOW)Usage:$(NC)\n"
@printf " make $(GREEN)<target>$(NC) [ARGS=\"...\"] [V=1|2] [VARIABLE=value]\n\n"
@printf "$(YELLOW)Main Lifecycle Targets:$(NC)\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-18s$(NC) %s\n", $$1, $$2}'
# Lifecycle Targets
init: ## Hydrate project from template (rename placeholders)
ifeq ($(OS_NAME),Windows)
@scripts/init-project.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/init-project.sh $(SCRIPT_ARGS) $(ARGS)
endif
setup: ## Install system-level development tools
ifeq ($(OS_NAME),Windows)
@scripts/setup.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/setup.sh $(SCRIPT_ARGS) $(ARGS)
endif
install: setup ## Install project-level dependencies (pip, npm)
ifeq ($(OS_NAME),Windows)
@scripts/install.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/install.sh $(SCRIPT_ARGS) $(ARGS)
endif
lint: ## Run standardized linter (pre-commit)
ifeq ($(OS_NAME),Windows)
@scripts/lint.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/lint.sh $(SCRIPT_ARGS) $(ARGS)
endif
precommit: lint ## Alias for lint (Run pre-commit hooks)
format: ## Auto-format code (ruff, prettier, shfmt, etc.)
ifeq ($(OS_NAME),Windows)
@scripts/format.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/format.sh $(SCRIPT_ARGS) $(ARGS)
endif
test: ## Run unified test suite
ifeq ($(OS_NAME),Windows)
@scripts/test.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/test.sh $(SCRIPT_ARGS) $(ARGS)
endif
build: ## Build project artifacts
ifeq ($(OS_NAME),Windows)
@scripts/build.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/build.sh $(SCRIPT_ARGS) $(ARGS)
endif
commit: ## Start the interactive Commitizen CLI
ifeq ($(OS_NAME),Windows)
@scripts/commit.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/commit.sh $(SCRIPT_ARGS) $(ARGS)
endif
.NOTPARALLEL: verify
verify: ## Run full local verification (env, lint, test, audit)
ifeq ($(OS_NAME),Windows)
@scripts/verify.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/verify.sh $(SCRIPT_ARGS) $(ARGS)
endif
release: ## Standardized release manager (versioning & tagging)
ifeq ($(OS_NAME),Windows)
@scripts/release.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/release.sh $(SCRIPT_ARGS) $(ARGS)
endif
env: ## Environment configuration manager (.env)
ifeq ($(OS_NAME),Windows)
@scripts/env.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/env.sh $(SCRIPT_ARGS) $(ARGS)
endif
update-tools: ## Upgrade Mise-managed tool versions (Tier 1 & 2)
ifeq ($(OS_NAME),Windows)
@scripts/update-tools.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/update-tools.sh $(SCRIPT_ARGS) $(ARGS)
endif
update: ## Update all tools, dependencies, and hooks (Inc. Mise tool versions)
ifeq ($(OS_NAME),Windows)
@scripts/update.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/update.sh $(SCRIPT_ARGS) $(ARGS)
endif
audit: ## Run security audit and vulnerability scans
ifeq ($(OS_NAME),Windows)
@scripts/audit.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/audit.sh $(SCRIPT_ARGS) $(ARGS)
endif
health: ## Generate unified project health dashboard
ifeq ($(OS_NAME),Windows)
@scripts/health.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/health.sh $(SCRIPT_ARGS) $(ARGS)
endif
bench: ## Run performance benchmarks
ifeq ($(OS_NAME),Windows)
@scripts/bench.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/bench.sh $(SCRIPT_ARGS) $(ARGS)
endif
sync-docs: ## Synchronize documentation between versions
ifeq ($(OS_NAME),Windows)
@scripts/sync-docs.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/sync-docs.sh $(SCRIPT_ARGS) $(ARGS)
endif
license-add: ## Add license headers to core source files (Safe Mode)
@mise x -- addlicense -v -f .github/license-header.txt \
$$(find src pkg internal cmd app lib include scripts tests \
\( -path "*/vendor/*" -o -path "*/node_modules/*" -o -path "*/dist/*" -o -path "*/build/*" \) -prune -o \
-type f \( -name "*.go" -o -name "*.sh" -o -name "*.py" -o -name "*.js" -o -name "*.mjs" -o -name "*.ts" -o -name "*.tsx" -o -name "*.jsx" -o -name "*.vue" -o -name "*.svelte" -o -name "*.astro" -o -name "*.java" -o -name "*.kt" -o -name "*.swift" -o -name "*.m" -o -name "*.mm" -o -name "*.c" -o -name "*.cpp" -o -name "*.cc" -o -name "*.h" -o -name "*.hpp" -o -name "*.rs" -o -name "*.rb" -o -name "*.php" -o -name "*.cs" -o -name "*.fs" -o -name "*.dart" -o -name "*.rego" -o -name "*.proto" -o -name "*.tf" -o -name "*.tfvars" -o -name "*.kcl" -o -name "*.pkl" -o -name "*.cue" \) -print 2>/dev/null)
license-check: ## Check for missing license headers
@mise x -- addlicense -check -v -f .github/license-header.txt \
$$(find src pkg internal cmd app lib include scripts tests \
\( -path "*/vendor/*" -o -path "*/node_modules/*" -o -path "*/dist/*" -o -path "*/build/*" \) -prune -o \
-type f \( -name "*.go" -o -name "*.sh" -o -name "*.py" -o -name "*.js" -o -name "*.mjs" -o -name "*.ts" -o -name "*.tsx" -o -name "*.jsx" -o -name "*.vue" -o -name "*.svelte" -o -name "*.astro" -o -name "*.java" -o -name "*.kt" -o -name "*.swift" -o -name "*.m" -o -name "*.mm" -o -name "*.c" -o -name "*.cpp" -o -name "*.cc" -o -name "*.h" -o -name "*.hpp" -o -name "*.rs" -o -name "*.rb" -o -name "*.php" -o -name "*.cs" -o -name "*.fs" -o -name "*.dart" -o -name "*.rego" -o -name "*.proto" -o -name "*.tf" -o -name "*.tfvars" -o -name "*.kcl" -o -name "*.pkl" -o -name "*.cue" \) -print 2>/dev/null)
docs: ## Documentation site manager (dev/build/preview)
ifeq ($(OS_NAME),Windows)
@scripts/docs.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/docs.sh $(SCRIPT_ARGS) $(ARGS)
endif
gen-dependabot: ## Auto-generate dependabot.yml from detected ecosystems
ifeq ($(OS_NAME),Windows)
@scripts/gen-dependabot.bat $(SCRIPT_ARGS) $(ARGS)
else
@mise x -- sh scripts/gen-dependabot.sh $(SCRIPT_ARGS) $(ARGS)
endif
sync-labels: ## Synchronize and brand repository labels
ifeq ($(OS_NAME),Windows)
@mise x -- scripts/sync-labels.bat $(SCRIPT_ARGS) $(ARGS)
else
@mise x -- sh scripts/sync-labels.sh $(SCRIPT_ARGS) $(ARGS)
endif
sync-harden-runner: ## Synchronize Harden Runner endpoints to all workflow files
ifeq ($(OS_NAME),Windows)
@scripts/sync-harden-runner.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/sync-harden-runner.sh $(SCRIPT_ARGS) $(ARGS)
endif
sync-lock: ## Synchronize and verify the mise.lock file across all platforms
ifeq ($(OS_NAME),Windows)
@scripts/sync-lock.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/sync-lock.sh $(SCRIPT_ARGS) $(ARGS)
endif
archive-changelog: ## Archive major-version changelog entries
ifeq ($(OS_NAME),Windows)
@scripts/archive-changelog.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/archive-changelog.sh $(SCRIPT_ARGS) $(ARGS)
endif
check-env: ## Onboarding environment health check
ifeq ($(OS_NAME),Windows)
@scripts/check-env.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/check-env.sh $(SCRIPT_ARGS) $(ARGS)
endif
clean: ## Remove temporary and generated files
ifeq ($(OS_NAME),Windows)
@scripts/cleanup.bat $(SCRIPT_ARGS) $(ARGS)
else
@sh scripts/cleanup.sh $(SCRIPT_ARGS) $(ARGS)
endif
fix: ## Automatically fix common issues (line endings, typos)
@printf "$(BLUE)Applying automated fixes...$(NC)\n"
@find scripts -name "*.bat" -o -name "*.ps1" | xargs perl -pi -e 's/\r\n/\n/g; s/\n/\r\n/g'
@git add --renormalize .
@printf "$(GREEN)Fixes applied!$(NC)\n"