.PHONY: help setup run \
test test/domain test/application test/infrastructure \
lint format format/fix check clean \
audit audit/fix \
generate/entity generate/use-case generate/bootstrap \
web/install web/dev web/test web/lint web/sync
CARGO := cargo
BUN := bun
GREEN := \033[1;32m
YELLOW := \033[1;33m
CYAN := \033[1;36m
RED := \033[1;31m
NC := \033[0m
help:
@echo ""
@echo "${CYAN}Available targets:${NC}"
@echo ""
@grep -E '^[a-zA-Z/_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " ${YELLOW}%-32s${NC} %s\n", $$1, $$2}'
@echo ""
setup:
@echo "${CYAN}Setting up development environment...${NC}"
$(CARGO) install cargo-nextest --locked
$(CARGO) install cargo-audit --locked
run:
@echo "${GREEN}Starting API server...${NC}"
$(CARGO) run -p presentation
test:
@echo "${YELLOW}Running all tests...${NC}"
$(CARGO) nextest run --workspace
@if [ -d web ]; then $(MAKE) web/test; fi
test/domain:
@echo "${YELLOW}Running domain tests...${NC}"
$(CARGO) nextest run -p business -E 'test(domain)'
test/application:
@echo "${YELLOW}Running application layer tests...${NC}"
$(CARGO) nextest run -p business -E 'test(application)'
test/infrastructure:
@echo "${YELLOW}Running infrastructure tests...${NC}"
$(CARGO) nextest run -p infrastructure
lint:
@echo "${CYAN}Linting code...${NC}"
$(CARGO) clippy --workspace -- -D warnings
@if [ -d web ]; then $(MAKE) web/lint; fi
format:
@echo "${CYAN}Checking code formatting...${NC}"
$(CARGO) fmt --all -- --check
format/fix:
@echo "${CYAN}Fixing code formatting...${NC}"
$(CARGO) fmt --all
check:
@echo "${CYAN}Checking code...${NC}"
$(CARGO) check --workspace
clean:
@echo "${RED}Cleaning build artifacts...${NC}"
$(CARGO) clean
audit:
@echo "${CYAN}Running security audit...${NC}"
$(CARGO) audit
audit/fix:
@echo "${CYAN}Previewing security fixes (dry-run)...${NC}"
$(CARGO) audit fix --dry-run
generate/entity: ## Scaffold a new DDD entity — make generate/entity NAME=Product
@if [ -z "$$NAME" ]; then \
echo "${RED}Error: provide entity name — make generate/entity NAME=Product${NC}"; \
exit 1; \
fi
@echo "${GREEN}Scaffolding entity '$$NAME'...${NC}"
puerto generate scaffold $$NAME
generate/use-case: ## Add a use case to an entity — make generate/use-case ENTITY=Product ACTION=delete_product
@if [ -z "$$ENTITY" ] || [ -z "$$ACTION" ]; then \
echo "${RED}Error: provide entity and action — make generate/use-case ENTITY=Product ACTION=delete_product${NC}"; \
exit 1; \
fi
@echo "${GREEN}Adding use case '$$ACTION' to '$$ENTITY'...${NC}"
puerto generate use-case $$ENTITY $$ACTION
generate/bootstrap:
@echo "${GREEN}Regenerating bootstrap.rs...${NC}"
puerto generate bootstrap
web/install:
@echo "${CYAN}Installing frontend dependencies...${NC}"
cd web && $(BUN) install
web/dev:
@echo "${GREEN}Starting frontend dev server...${NC}"
cd web && $(BUN) run dev
web/test:
@echo "${YELLOW}Running frontend tests...${NC}"
cd web && $(BUN) test
web/lint:
@echo "${CYAN}Linting frontend...${NC}"
cd web && $(BUN) run typecheck && $(BUN) run lint && $(BUN) run lint:arch
web/sync:
@echo "${CYAN}Exporting docs/api/openapi.json...${NC}"
UPDATE_OPENAPI=1 $(CARGO) test -p presentation openapi
@echo "${CYAN}Generating web/src/infrastructure/http/schema.d.ts...${NC}"
cd web && $(BUN) run openapi:types
@echo "${CYAN}Formatting web/ (Biome, no lint fixes)...${NC}"
cd web && $(BUN) run format