From af63fefdc323585553f072c010b9620a4d035165 Mon Sep 17 00:00:00 2001 From: Digikwal <79085106+digikwal@users.noreply.github.com> Date: Thu, 26 Jun 2025 22:00:08 +0200 Subject: [PATCH] chore: add Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes the following targets: - `make lint` → Run pre-commit hook for trailing whitespace - `make format` → Apply Prettier formatting across the repo - `make push` → Add, commit (with prompt), and push changes - `make amend` → Amend the last commit without editing message - `make help` → Show usage guide Also includes optional extras like hook installation and reset utilities. --- Makefile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..4a7cabe6 --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +# Default help formatter +.DEFAULT_GOAL := help + +# Colors +GREEN := \033[0;32m +RESET := \033[0m + +# Help generator (targets with ##) +help: ## Show this help message + @echo "" + @echo "$(GREEN)Available make commands:$(RESET)" + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + | sort \ + | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' + @echo "" + +# 1. Pre-commit check: trailing whitespace only +lint: ## Run pre-commit check for trailing whitespace + pre-commit run trailing-whitespace --all-files + +# 2. Format all files with prettier +format: ## Run Prettier on the whole repo + npx prettier --write . + +# 3a-c. Stage, commit & push +push: ## Add all files, commit (ask for message), and push + @git add . + @read -p "Enter commit message: " msg; \ + git commit -m "$$msg" + @git push + +# 4. Amend last commit (no edit) +amend: ## Amend last commit without editing the message + git commit --amend --no-edit + +# Add-ons you might like: + +check-hooks: ## Run all configured pre-commit hooks + pre-commit run --all-files + +install-hooks: ## Install pre-commit hooks in .git/hooks + pre-commit install + +reset-soft: ## Undo last commit but keep changes staged + git reset --soft HEAD~1 + +clean: ## Remove temporary Python/node/docker files + rm -rf __pycache__ node_modules *.pyc *.log .pytest_cache .mypy_cache