snippetmakefileTippending
Makefile as project task runner
Viewed 0 times
Makefiletask-runnerbuildautomationphonyself-documenting
Problem
Projects need a standard way to run common tasks (build, test, deploy, lint) that works everywhere without installing extra tools.
Solution
Use Makefile as a universal task runner:
.PHONY: help dev build test lint clean deploy
.DEFAULT_GOAL := help
# Self-documenting help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.?## .$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
dev: ## Start development server
npm run dev
build: ## Build for production
npm run build
test: ## Run all tests
npm test
test-watch: ## Run tests in watch mode
npm test -- --watch
lint: ## Run linter
npm run lint
clean: ## Remove build artifacts
rm -rf dist node_modules/.cache
deploy: build test ## Deploy (builds and tests first)
./scripts/deploy.sh
db-migrate: ## Run database migrations
npx prisma migrate deploy
db-seed: ## Seed the database
npx prisma db seed
# Variables
ENV ?= development
start: ## Start with ENV variable (default: development)
ENV=$(ENV) node dist/index.js
.PHONY: help dev build test lint clean deploy
.DEFAULT_GOAL := help
# Self-documenting help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.?## .$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
dev: ## Start development server
npm run dev
build: ## Build for production
npm run build
test: ## Run all tests
npm test
test-watch: ## Run tests in watch mode
npm test -- --watch
lint: ## Run linter
npm run lint
clean: ## Remove build artifacts
rm -rf dist node_modules/.cache
deploy: build test ## Deploy (builds and tests first)
./scripts/deploy.sh
db-migrate: ## Run database migrations
npx prisma migrate deploy
db-seed: ## Seed the database
npx prisma db seed
# Variables
ENV ?= development
start: ## Start with ENV variable (default: development)
ENV=$(ENV) node dist/index.js
Why
Make is pre-installed on macOS and Linux. A Makefile serves as living documentation of project tasks that anyone can run.
Revisions (0)
No revisions yet.