|
| 1 | +# ------------------------------------------ |
| 2 | +# Practicalli: Makefile |
| 3 | +# |
| 4 | +# Consistent set of targets to support local book development |
| 5 | +# ------------------------------------------ |
| 6 | + |
| 7 | +# .PHONY: ensures target used rather than matching file name |
| 8 | +# https://makefiletutorial.com/#phony |
| 9 | +.PHONY: all clean docs lint pre-commit-check test |
| 10 | + |
| 11 | +# ------- Makefile Variables --------- # |
| 12 | +# run help if no target specified |
| 13 | +.DEFAULT_GOAL := help |
| 14 | + |
| 15 | +# Column the target description is printed from |
| 16 | +HELP-DESCRIPTION-SPACING := 24 |
| 17 | + |
| 18 | +# Tool Commands |
| 19 | +MEGALINTER_RUNNER := npx mega-linter-runner --flavor documentation --env "'MEGALINTER_CONFIG=.github/config/megalinter.yaml'" --remove-container |
| 20 | +MKDOCS_SERVER := mkdocs serve --dev-addr localhost:7777 |
| 21 | + |
| 22 | +# Makefile file and directory name wildcard |
| 23 | +EDN-FILES := $(wildcard *.edn) |
| 24 | +# ------------------------------------ # |
| 25 | + |
| 26 | +# ------ Quality Checks ------------ # |
| 27 | +pre-commit-check: lint |
| 28 | + |
| 29 | +lint: ## Run MegaLinter with custom configuration (node.js required) |
| 30 | + $(info --------- MegaLinter Runner ---------) |
| 31 | + $(MEGALINTER_RUNNER) |
| 32 | + |
| 33 | +lint-fix: ## Run MegaLinter with custom configuration (node.js required) |
| 34 | + $(info --------- MegaLinter Runner ---------) |
| 35 | + $(MEGALINTER_RUNNER) --fix |
| 36 | + |
| 37 | +lint-clean: ## Clean MegaLinter report information |
| 38 | + $(info --------- MegaLinter Clean Reports ---------) |
| 39 | + - rm -rf ./megalinter-reports |
| 40 | +# ------------------------------------ # |
| 41 | + |
| 42 | +# --- Documentation Generation ------ # |
| 43 | +docs: ## Build and run mkdocs in local server |
| 44 | + $(info --------- Mkdocs Local Server ---------) |
| 45 | + $(MKDOCS_SERVER) |
| 46 | + |
| 47 | +docs-changed: ## Build only changed files and run mkdocs in local server |
| 48 | + $(info --------- Mkdocs Local Server ---------) |
| 49 | + $(MKDOCS_SERVER) --dirtyreload |
| 50 | + |
| 51 | +docs-build: ## Build mkdocs |
| 52 | + $(info --------- Mkdocs Local Server ---------) |
| 53 | + mkdocs build |
| 54 | +# ------------------------------------ # |
| 55 | + |
| 56 | +# ------------ Help ------------------ # |
| 57 | +# Source: https://nedbatchelder.com/blog/201804/makefile_help_target.html |
| 58 | + |
| 59 | +help: ## Describe available tasks in Makefile |
| 60 | + @grep '^[a-zA-Z]' $(MAKEFILE_LIST) | \ |
| 61 | + sort | \ |
| 62 | + awk -F ':.*?## ' 'NF==2 {printf "\033[36m %-$(HELP-DESCRIPTION-SPACING)s\033[0m %s\n", $$1, $$2}' |
| 63 | +# ------------------------------------ # |
0 commit comments