.PHONY: help build build-release test test-nextest lint lint-fix fmt fmt-check check ci clean install-deps install install-custom release-pr-bw release-bw setup-bitwarden
.DEFAULT_GOAL := help
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
NC := \033[0m
BINARY := amg
help:
@echo "$(BLUE)Available targets:$(NC)"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
install-deps:
@echo "$(BLUE)Installing development dependencies...$(NC)"
@cargo install cargo-edit cargo-nextest --quiet 2>/dev/null || true
@echo "$(GREEN)✓ Dependencies installed$(NC)"
build:
@echo "$(BLUE)Building project...$(NC)"
@cargo build
@echo "$(GREEN)✓ Build complete$(NC)"
build-release:
@echo "$(BLUE)Building project (release)...$(NC)"
@cargo build --release
@echo "$(GREEN)✓ Release build complete$(NC)"
test:
@echo "$(BLUE)Running tests...$(NC)"
@cargo test --all-targets
@echo "$(GREEN)✓ Tests passed$(NC)"
test-nextest:
@echo "$(BLUE)Running tests with nextest...$(NC)"
@cargo nextest run --all-targets
@echo "$(GREEN)✓ Tests passed$(NC)"
lint:
@echo "$(BLUE)Running clippy...$(NC)"
@cargo clippy --all-targets --all-features -- -D warnings
@echo "$(GREEN)✓ Linting passed$(NC)"
lint-fix:
@echo "$(BLUE)Running clippy --fix...$(NC)"
@cargo clippy --fix --all-targets --all-features --allow-dirty --allow-staged
@echo "$(GREEN)✓ Linting fixes applied$(NC)"
fmt:
@echo "$(BLUE)Formatting code...$(NC)"
@cargo fmt
@echo "$(GREEN)✓ Code formatted$(NC)"
fmt-check:
@echo "$(BLUE)Checking code formatting...$(NC)"
@cargo fmt --all -- --check || (echo "$(RED)Formatting check failed! Run 'make fmt' to fix.$(NC)" && exit 1)
@echo "$(GREEN)✓ Formatting check passed$(NC)"
check: fmt-check
@echo "$(BLUE)Running cargo check...$(NC)"
@cargo check --all-targets
@echo "$(GREEN)✓ Check passed$(NC)"
ci:
@echo "$(BLUE)Running CI pipeline...$(NC)"
@$(MAKE) fmt-check
@$(MAKE) lint
@$(MAKE) check
@$(MAKE) test-nextest
@echo "$(GREEN)✓ All CI checks passed$(NC)"
all: fmt-check lint check test-nextest build-release
@echo "$(GREEN)✓ All checks passed and release build complete$(NC)"
clean:
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
@cargo clean
@echo "$(GREEN)✓ Clean complete$(NC)"
update:
@echo "$(BLUE)Updating dependencies...$(NC)"
@cargo upgrade --incompatible
@echo "$(GREEN)✓ Dependencies updated$(NC)"
install:
@echo "$(BLUE)Installing $(BINARY) to $$HOME/.cargo/bin...$(NC)"
@cargo install --path .
@echo "$(GREEN)✓ $(BINARY) installed successfully$(NC)"
@echo "$(YELLOW)Note: Ensure $$HOME/.cargo/bin is in your PATH$(NC)"
install-custom: ## Install the binary to a custom directory (usage: make install-custom ROOT=/path/to/root)
@if [ -z "$(ROOT)" ]; then \
echo "$(RED)Error: ROOT variable must be set. Example: make install-custom ROOT=$$HOME/.local$(NC)"; \
exit 1; \
fi
@echo "$(BLUE)Installing $(BINARY) to $(ROOT)/bin...$(NC)"
@cargo install --path . --root $(ROOT)
@echo "$(GREEN)✓ $(BINARY) installed successfully to $(ROOT)/bin$(NC)"
@echo "$(YELLOW)Note: Ensure $(ROOT)/bin is in your PATH$(NC)"
setup-bitwarden:
@echo "$(BLUE)Setting up Bitwarden CLI...$(NC)"
@./scripts/setup-bitwarden.sh
@echo "$(GREEN)✓ Bitwarden setup complete$(NC)"
release-pr-bw:
@./scripts/release-with-bitwarden.sh release-pr
release-bw:
@./scripts/release-with-bitwarden.sh release