-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (121 loc) · 4.94 KB
/
Makefile
File metadata and controls
153 lines (121 loc) · 4.94 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
# SPDX-License-Identifier: Apache-2.0
# ---------------------------------------------------------------------------
# Makefile — ComplyTime website developer workflow
#
# Quick reference:
# make help — list all targets
# make sync-dry — dry-run content sync (reads GitHub, writes nothing)
# make sync — apply content sync to disk
# make dev — start Hugo dev server (after syncing content)
# make check — vet + fmt-check + race tests
# ---------------------------------------------------------------------------
# Overridable variables
ORG ?= complytime
CONFIG ?= sync-config.yaml
LOCK ?= .content-lock.json
OUTPUT ?= .
WORKERS ?= 5
TIMEOUT ?= 3m
REPO ?=
SYNC_BIN := cmd/sync-content/sync-content
SYNC_PKG := ./cmd/sync-content/...
# Common flags passed to every sync invocation
SYNC_FLAGS := --org $(ORG) --config $(CONFIG) --output $(OUTPUT) --workers $(WORKERS) --timeout $(TIMEOUT)
ifdef REPO
SYNC_FLAGS += --repo $(REPO)
endif
.DEFAULT_GOAL := help
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
.PHONY: help
help: ## Show this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} \
/^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
# ---------------------------------------------------------------------------
# Go — build, test, lint
# ---------------------------------------------------------------------------
.PHONY: build
build: ## Compile the sync-content binary
go build -o $(SYNC_BIN) ./cmd/sync-content
.PHONY: test
test: ## Run all Go unit tests
go test $(SYNC_PKG)
.PHONY: test-race
test-race: ## Run Go tests with the race detector
go test -race $(SYNC_PKG)
.PHONY: vet
vet: ## Run go vet
go vet $(SYNC_PKG)
.PHONY: fmt
fmt: ## Format Go source files with gofmt
gofmt -w cmd/sync-content/
.PHONY: fmt-check
fmt-check: ## Check Go formatting (non-destructive)
@out=$$(gofmt -l cmd/sync-content/); \
if [ -n "$$out" ]; then \
echo "The following files need formatting:"; \
echo "$$out"; \
exit 1; \
fi
.PHONY: check
check: vet fmt-check test-race ## Run vet + fmt-check + race tests (CI equivalent)
# ---------------------------------------------------------------------------
# Content sync — uses GITHUB_TOKEN from the environment
# ---------------------------------------------------------------------------
.PHONY: sync-dry
sync-dry: build ## Dry-run content sync — reads GitHub, writes nothing to disk
./$(SYNC_BIN) $(SYNC_FLAGS)
.PHONY: sync
sync: build ## Apply content sync to disk (--write)
./$(SYNC_BIN) $(SYNC_FLAGS) --write
.PHONY: sync-locked
sync-locked: build ## Apply content sync at approved SHAs from .content-lock.json
./$(SYNC_BIN) $(SYNC_FLAGS) --lock $(LOCK) --write
.PHONY: sync-update-lock
sync-update-lock: build ## Refresh .content-lock.json with current upstream SHAs (no content write)
./$(SYNC_BIN) $(SYNC_FLAGS) --lock $(LOCK) --update-lock
.PHONY: sync-single-dry
sync-single-dry: ## Dry-run sync for one repo (REPO=complytime/complyctl)
@if [ -z "$(REPO)" ]; then echo "Usage: make sync-single-dry REPO=complytime/<name>"; exit 1; fi
$(MAKE) sync-dry REPO=$(REPO)
.PHONY: sync-single
sync-single: ## Apply sync for one repo (REPO=complytime/complyctl)
@if [ -z "$(REPO)" ]; then echo "Usage: make sync-single REPO=complytime/<name>"; exit 1; fi
$(MAKE) sync REPO=$(REPO)
# ---------------------------------------------------------------------------
# Hugo / Node — site build and dev server
# ---------------------------------------------------------------------------
.PHONY: node-install
node-install: ## Install Node dependencies (npm install)
npm install
.PHONY: dev
dev: ## Start the Hugo dev server (runs: npm run dev)
npm run dev
.PHONY: site-build
site-build: ## Build the Hugo site (runs: hugo --minify --gc)
npm run build
.PHONY: preview
preview: sync site-build ## Full preview: sync content then build the site
# ---------------------------------------------------------------------------
# Housekeeping
# ---------------------------------------------------------------------------
.PHONY: clean
clean: ## Remove the compiled sync-content binary
rm -f $(SYNC_BIN)
.PHONY: clean-build
clean-build: ## Remove Hugo output + resource cache, then rebuild (CI match)
rm -rf public/ resources/
npm run build
.PHONY: clean-nuclear
clean-nuclear: ## Full wipe (Hugo output, Hugo cache, node_modules) + fresh npm ci + rebuild
rm -rf public/ resources/ /tmp/hugo_cache/ node_modules/
npm ci
npm run build
.PHONY: reset-sync
reset-sync: ## Clear all generated sync content + full rebuild (use when sync logic or upstream changes)
rm -f .sync-manifest.json data/projects.json
rm -rf content/docs/projects/*/
rm -rf public/ resources/
go run ./cmd/sync-content $(SYNC_FLAGS) --lock $(LOCK) --write
npm run build