|
| 1 | +.DEFAULT_GOAL := help |
| 2 | + |
| 3 | +# Edge-function workspaces (TypeScript source; built + published to GitHub Packages by CI) |
| 4 | +LAMBDA_DIR := lib/lambda-at-edge |
| 5 | +CF_DIR := lib/cloudfront-functions |
| 6 | + |
| 7 | +##@ General |
| 8 | + |
| 9 | +.PHONY: help |
| 10 | +help: ## Display this help |
| 11 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
| 12 | + |
| 13 | +##@ Dependencies |
| 14 | + |
| 15 | +.PHONY: install |
| 16 | +install: ## Install all dependencies (Lambda@Edge + CloudFront Functions) |
| 17 | + @echo "Installing Lambda@Edge dependencies..." |
| 18 | + cd $(LAMBDA_DIR) && yarn install |
| 19 | + @echo "Installing CloudFront Functions dependencies..." |
| 20 | + cd $(CF_DIR) && yarn install |
| 21 | + @echo "✓ Dependencies installation complete" |
| 22 | + |
| 23 | +##@ Tests |
| 24 | + |
| 25 | +.PHONY: test |
| 26 | +test: ## Run all tests (Lambda@Edge + CloudFront Functions) |
| 27 | + @echo "Running Lambda@Edge tests..." |
| 28 | + cd $(LAMBDA_DIR) && yarn test |
| 29 | + @echo "Running CloudFront Function tests..." |
| 30 | + cd $(CF_DIR) && yarn test |
| 31 | + @echo "✓ Tests complete" |
| 32 | + |
| 33 | +.PHONY: test-lambda |
| 34 | +test-lambda: ## Run all Lambda@Edge tests |
| 35 | + cd $(LAMBDA_DIR) && yarn test |
| 36 | + |
| 37 | +.PHONY: test-cloudfront |
| 38 | +test-cloudfront: ## Run all CloudFront Function tests |
| 39 | + cd $(CF_DIR) && yarn test |
| 40 | + |
| 41 | +.PHONY: test-filter-function |
| 42 | +test-filter-function: ## Run tests for filter-function (Lambda@Edge) |
| 43 | + cd $(LAMBDA_DIR) && yarn workspace @krishanthisera/filter-function test |
| 44 | + |
| 45 | +.PHONY: test-geo-redirect |
| 46 | +test-geo-redirect: ## Run tests for geo-redirect (Lambda@Edge) |
| 47 | + cd $(LAMBDA_DIR) && yarn workspace @krishanthisera/geo-redirect test |
| 48 | + |
| 49 | +.PHONY: test-prerender-proxy |
| 50 | +test-prerender-proxy: ## Run tests for prerender-proxy (Lambda@Edge) |
| 51 | + cd $(LAMBDA_DIR) && yarn workspace @krishanthisera/prerender-proxy test |
| 52 | + |
| 53 | +.PHONY: test-response-handler |
| 54 | +test-response-handler: ## Run tests for response-handler (Lambda@Edge) |
| 55 | + cd $(LAMBDA_DIR) && yarn workspace @krishanthisera/response-handler test |
| 56 | + |
| 57 | +.PHONY: test-uri-rewrite |
| 58 | +test-uri-rewrite: ## Run tests for uri-rewrite (CloudFront Function) |
| 59 | + cd $(CF_DIR) && yarn workspace @krishanthisera/uri-rewrite test |
| 60 | + |
| 61 | +##@ Build |
| 62 | + |
| 63 | +.PHONY: build |
| 64 | +build: ## Build all functions (Lambda@Edge + CloudFront Functions) |
| 65 | + @echo "Building Lambda@Edge functions..." |
| 66 | + cd $(LAMBDA_DIR) && yarn build |
| 67 | + @echo "Building CloudFront Functions..." |
| 68 | + cd $(CF_DIR) && yarn build |
| 69 | + @echo "✓ Build complete" |
| 70 | + |
| 71 | +.PHONY: build-lambda |
| 72 | +build-lambda: ## Build all Lambda@Edge functions |
| 73 | + cd $(LAMBDA_DIR) && yarn build |
| 74 | + |
| 75 | +.PHONY: build-cloudfront |
| 76 | +build-cloudfront: ## Build all CloudFront Functions |
| 77 | + cd $(CF_DIR) && yarn build |
| 78 | + |
| 79 | +.PHONY: build-filter-function |
| 80 | +build-filter-function: ## Build filter-function (Lambda@Edge) |
| 81 | + cd $(LAMBDA_DIR) && yarn workspace @krishanthisera/filter-function build |
| 82 | + |
| 83 | +.PHONY: build-geo-redirect |
| 84 | +build-geo-redirect: ## Build geo-redirect (Lambda@Edge) |
| 85 | + cd $(LAMBDA_DIR) && yarn workspace @krishanthisera/geo-redirect build |
| 86 | + |
| 87 | +.PHONY: build-prerender-proxy |
| 88 | +build-prerender-proxy: ## Build prerender-proxy (Lambda@Edge) |
| 89 | + cd $(LAMBDA_DIR) && yarn workspace @krishanthisera/prerender-proxy build |
| 90 | + |
| 91 | +.PHONY: build-response-handler |
| 92 | +build-response-handler: ## Build response-handler (Lambda@Edge) |
| 93 | + cd $(LAMBDA_DIR) && yarn workspace @krishanthisera/response-handler build |
| 94 | + |
| 95 | +.PHONY: build-uri-rewrite |
| 96 | +build-uri-rewrite: ## Build uri-rewrite (CloudFront Function) |
| 97 | + cd $(CF_DIR) && yarn workspace @krishanthisera/uri-rewrite build |
| 98 | + |
| 99 | +##@ Lint |
| 100 | + |
| 101 | +.PHONY: lint |
| 102 | +lint: ## Run linters (Lambda@Edge) |
| 103 | + cd $(LAMBDA_DIR) && yarn lint:check |
| 104 | + |
| 105 | +.PHONY: lint-fix |
| 106 | +lint-fix: ## Run linters and fix issues (Lambda@Edge) |
| 107 | + cd $(LAMBDA_DIR) && yarn lint:fix |
| 108 | + |
| 109 | +##@ Format |
| 110 | + |
| 111 | +.PHONY: format |
| 112 | +format: ## Check code formatting (Lambda@Edge) |
| 113 | + cd $(LAMBDA_DIR) && yarn format:check |
| 114 | + |
| 115 | +.PHONY: format-fix |
| 116 | +format-fix: ## Fix code formatting (Lambda@Edge) |
| 117 | + cd $(LAMBDA_DIR) && yarn format:fix |
| 118 | + |
| 119 | +##@ Release |
| 120 | + |
| 121 | +# Function code is published to the GitHub Packages npm registry (@krishanthisera/*) |
| 122 | +# by the release-* GitHub Actions workflows on push to main, driven by |
| 123 | +# Conventional Commits. These targets only preview what would be released. |
| 124 | + |
| 125 | +.PHONY: release-dry-run-lambda |
| 126 | +release-dry-run-lambda: ## Dry-run semantic-release for every Lambda@Edge package (needs GITHUB_TOKEN) |
| 127 | + @for pkg in filter-function prerender-proxy geo-redirect response-handler; do \ |
| 128 | + echo "== $$pkg =="; \ |
| 129 | + cd $(LAMBDA_DIR)/packages/$$pkg && npx --no-install semantic-release --dry-run --no-ci; cd - >/dev/null; \ |
| 130 | + done |
| 131 | + |
| 132 | +.PHONY: release-dry-run-cloudfront |
| 133 | +release-dry-run-cloudfront: ## Dry-run semantic-release for uri-rewrite (needs GITHUB_TOKEN) |
| 134 | + cd $(CF_DIR)/packages/uri-rewrite && npx --no-install semantic-release --dry-run --no-ci |
| 135 | + |
| 136 | +##@ Terraform |
| 137 | + |
| 138 | +.PHONY: tf-init |
| 139 | +tf-init: ## Initialize Terraform |
| 140 | + terraform init |
| 141 | + |
| 142 | +.PHONY: tf-plan |
| 143 | +tf-plan: ## Run Terraform plan |
| 144 | + terraform plan |
| 145 | + |
| 146 | +.PHONY: tf-apply |
| 147 | +tf-apply: ## Apply Terraform changes |
| 148 | + terraform apply |
| 149 | + |
| 150 | +.PHONY: tf-docs |
| 151 | +tf-docs: ## Regenerate Terraform documentation (requires terraform-docs) |
| 152 | + terraform-docs markdown table --output-file README.md --output-mode inject . |
| 153 | + terraform-docs markdown table --output-file modules/edge-functions/README.md --output-mode inject modules/edge-functions |
| 154 | + |
| 155 | +##@ Development |
| 156 | + |
| 157 | +.PHONY: dev |
| 158 | +dev: install build test ## Full development setup (install, build, test) |
| 159 | + @echo "✓ Development environment ready" |
| 160 | + |
| 161 | +.PHONY: watch-lambda |
| 162 | +watch-lambda: ## Watch Lambda@Edge tests |
| 163 | + cd $(LAMBDA_DIR) && yarn test --watch |
| 164 | + |
| 165 | +.PHONY: watch-cloudfront |
| 166 | +watch-cloudfront: ## Watch CloudFront Function tests |
| 167 | + cd $(CF_DIR) && yarn workspace @krishanthisera/uri-rewrite test:watch |
| 168 | + |
| 169 | +##@ Deployment |
| 170 | + |
| 171 | +.PHONY: pre-deploy |
| 172 | +pre-deploy: build test ## Build and test before deployment |
| 173 | + @echo "✓ Pre-deployment checks passed" |
| 174 | + |
| 175 | +.PHONY: deploy |
| 176 | +deploy: pre-deploy tf-apply ## Full deployment (build, test, apply) |
| 177 | + @echo "✓ Deployment complete" |
| 178 | + |
| 179 | +##@ Clean |
| 180 | + |
| 181 | +.PHONY: clean |
| 182 | +clean: ## Clean build artifacts |
| 183 | + @echo "Cleaning Lambda@Edge build artifacts..." |
| 184 | + cd $(LAMBDA_DIR) && rm -rf packages/*/build function_archives .turbo packages/*/.turbo |
| 185 | + @echo "Cleaning CloudFront Functions build artifacts..." |
| 186 | + cd $(CF_DIR) && rm -rf packages/*/build .turbo packages/*/.turbo |
| 187 | + @echo "✓ Build artifacts cleaned" |
| 188 | + |
| 189 | +.PHONY: clean-all |
| 190 | +clean-all: clean ## Clean everything including node_modules |
| 191 | + @echo "Removing node_modules..." |
| 192 | + rm -rf $(LAMBDA_DIR)/node_modules $(LAMBDA_DIR)/packages/*/node_modules |
| 193 | + rm -rf $(CF_DIR)/node_modules $(CF_DIR)/packages/*/node_modules |
| 194 | + @echo "✓ Everything cleaned" |
0 commit comments