|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | + |
| 3 | +# --------------------------------------------------------------------------- |
| 4 | +# Makefile — ComplyTime website developer workflow |
| 5 | +# |
| 6 | +# Quick reference: |
| 7 | +# make help — list all targets |
| 8 | +# make sync-dry — dry-run content sync (reads GitHub, writes nothing) |
| 9 | +# make sync — apply content sync to disk |
| 10 | +# make dev — start Hugo dev server (after syncing content) |
| 11 | +# make check — vet + fmt-check + race tests |
| 12 | +# --------------------------------------------------------------------------- |
| 13 | + |
| 14 | +# Overridable variables |
| 15 | +ORG ?= complytime |
| 16 | +CONFIG ?= sync-config.yaml |
| 17 | +LOCK ?= .content-lock.json |
| 18 | +OUTPUT ?= . |
| 19 | +WORKERS ?= 5 |
| 20 | +TIMEOUT ?= 3m |
| 21 | +REPO ?= |
| 22 | + |
| 23 | +SYNC_BIN := cmd/sync-content/sync-content |
| 24 | +SYNC_PKG := ./cmd/sync-content/... |
| 25 | + |
| 26 | +# Common flags passed to every sync invocation |
| 27 | +SYNC_FLAGS := --org $(ORG) --config $(CONFIG) --output $(OUTPUT) --workers $(WORKERS) --timeout $(TIMEOUT) |
| 28 | +ifdef REPO |
| 29 | +SYNC_FLAGS += --repo $(REPO) |
| 30 | +endif |
| 31 | + |
| 32 | +.DEFAULT_GOAL := help |
| 33 | + |
| 34 | +# --------------------------------------------------------------------------- |
| 35 | +# Help |
| 36 | +# --------------------------------------------------------------------------- |
| 37 | + |
| 38 | +.PHONY: help |
| 39 | +help: ## Show this help message |
| 40 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} \ |
| 41 | + /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) |
| 42 | + |
| 43 | +# --------------------------------------------------------------------------- |
| 44 | +# Go — build, test, lint |
| 45 | +# --------------------------------------------------------------------------- |
| 46 | + |
| 47 | +.PHONY: build |
| 48 | +build: ## Compile the sync-content binary |
| 49 | + go build -o $(SYNC_BIN) ./cmd/sync-content |
| 50 | + |
| 51 | +.PHONY: test |
| 52 | +test: ## Run all Go unit tests |
| 53 | + go test $(SYNC_PKG) |
| 54 | + |
| 55 | +.PHONY: test-race |
| 56 | +test-race: ## Run Go tests with the race detector |
| 57 | + go test -race $(SYNC_PKG) |
| 58 | + |
| 59 | +.PHONY: vet |
| 60 | +vet: ## Run go vet |
| 61 | + go vet $(SYNC_PKG) |
| 62 | + |
| 63 | +.PHONY: fmt |
| 64 | +fmt: ## Format Go source files with gofmt |
| 65 | + gofmt -w cmd/sync-content/ |
| 66 | + |
| 67 | +.PHONY: fmt-check |
| 68 | +fmt-check: ## Check Go formatting (non-destructive) |
| 69 | + @out=$$(gofmt -l cmd/sync-content/); \ |
| 70 | + if [ -n "$$out" ]; then \ |
| 71 | + echo "The following files need formatting:"; \ |
| 72 | + echo "$$out"; \ |
| 73 | + exit 1; \ |
| 74 | + fi |
| 75 | + |
| 76 | +.PHONY: check |
| 77 | +check: vet fmt-check test-race ## Run vet + fmt-check + race tests (CI equivalent) |
| 78 | + |
| 79 | +# --------------------------------------------------------------------------- |
| 80 | +# Content sync — uses GITHUB_TOKEN from the environment |
| 81 | +# --------------------------------------------------------------------------- |
| 82 | + |
| 83 | +.PHONY: sync-dry |
| 84 | +sync-dry: build ## Dry-run content sync — reads GitHub, writes nothing to disk |
| 85 | + ./$(SYNC_BIN) $(SYNC_FLAGS) |
| 86 | + |
| 87 | +.PHONY: sync |
| 88 | +sync: build ## Apply content sync to disk (--write) |
| 89 | + ./$(SYNC_BIN) $(SYNC_FLAGS) --write |
| 90 | + |
| 91 | +.PHONY: sync-locked |
| 92 | +sync-locked: build ## Apply content sync at approved SHAs from .content-lock.json |
| 93 | + ./$(SYNC_BIN) $(SYNC_FLAGS) --lock $(LOCK) --write |
| 94 | + |
| 95 | +.PHONY: sync-update-lock |
| 96 | +sync-update-lock: build ## Refresh .content-lock.json with current upstream SHAs (no content write) |
| 97 | + ./$(SYNC_BIN) $(SYNC_FLAGS) --lock $(LOCK) --update-lock |
| 98 | + |
| 99 | +.PHONY: sync-single-dry |
| 100 | +sync-single-dry: ## Dry-run sync for one repo (REPO=complytime/complyctl) |
| 101 | + @if [ -z "$(REPO)" ]; then echo "Usage: make sync-single-dry REPO=complytime/<name>"; exit 1; fi |
| 102 | + $(MAKE) sync-dry REPO=$(REPO) |
| 103 | + |
| 104 | +.PHONY: sync-single |
| 105 | +sync-single: ## Apply sync for one repo (REPO=complytime/complyctl) |
| 106 | + @if [ -z "$(REPO)" ]; then echo "Usage: make sync-single REPO=complytime/<name>"; exit 1; fi |
| 107 | + $(MAKE) sync REPO=$(REPO) |
| 108 | + |
| 109 | +# --------------------------------------------------------------------------- |
| 110 | +# Hugo / Node — site build and dev server |
| 111 | +# --------------------------------------------------------------------------- |
| 112 | + |
| 113 | +.PHONY: node-install |
| 114 | +node-install: ## Install Node dependencies (npm install) |
| 115 | + npm install |
| 116 | + |
| 117 | +.PHONY: dev |
| 118 | +dev: ## Start the Hugo dev server (runs: npm run dev) |
| 119 | + npm run dev |
| 120 | + |
| 121 | +.PHONY: site-build |
| 122 | +site-build: ## Build the Hugo site (runs: hugo --minify --gc) |
| 123 | + npm run build |
| 124 | + |
| 125 | +.PHONY: preview |
| 126 | +preview: sync site-build ## Full preview: sync content then build the site |
| 127 | + |
| 128 | +# --------------------------------------------------------------------------- |
| 129 | +# Housekeeping |
| 130 | +# --------------------------------------------------------------------------- |
| 131 | + |
| 132 | +.PHONY: clean |
| 133 | +clean: ## Remove the compiled sync-content binary |
| 134 | + rm -f $(SYNC_BIN) |
| 135 | + |
| 136 | +.PHONY: clean-build |
| 137 | +clean-build: ## Remove Hugo output + resource cache, then rebuild (CI match) |
| 138 | + rm -rf public/ resources/ |
| 139 | + npm run build |
| 140 | + |
| 141 | +.PHONY: clean-nuclear |
| 142 | +clean-nuclear: ## Full wipe (Hugo output, Hugo cache, node_modules) + fresh npm ci + rebuild |
| 143 | + rm -rf public/ resources/ /tmp/hugo_cache/ node_modules/ |
| 144 | + npm ci |
| 145 | + npm run build |
| 146 | + |
| 147 | +.PHONY: reset-sync |
| 148 | +reset-sync: ## Clear all generated sync content + full rebuild (use when sync logic or upstream changes) |
| 149 | + rm -f .sync-manifest.json data/projects.json |
| 150 | + rm -rf content/docs/projects/*/ |
| 151 | + rm -rf public/ resources/ |
| 152 | + go run ./cmd/sync-content $(SYNC_FLAGS) --lock $(LOCK) --write |
| 153 | + npm run build |
0 commit comments