318 lines
10 KiB
Makefile
318 lines
10 KiB
Makefile
# Makefile for Medication Reminder App
|
|
# Acts as a wrapper for package.json scripts with organized targets
|
|
|
|
.PHONY: help install clean build dev test lint deploy undeploy docker gitea k8s
|
|
|
|
# Default target
|
|
.DEFAULT_GOAL := help
|
|
|
|
# Colors for output
|
|
BLUE := \033[34m
|
|
GREEN := \033[32m
|
|
YELLOW := \033[33m
|
|
RED := \033[31m
|
|
RESET := \033[0m
|
|
|
|
##@ General
|
|
|
|
help: ## Display this help message
|
|
@printf "$(BLUE)Medication Reminder App - Available Commands$(RESET)\n"
|
|
@printf "\n"
|
|
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " $(GREEN)%-20s$(RESET) %s\n", $$1, $$2 } /^##@/ { printf "\n$(YELLOW)%s$(RESET)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
install: ## Install dependencies
|
|
@printf "$(BLUE)Installing dependencies...$(RESET)\n"
|
|
@bun install
|
|
|
|
clean: ## Clean build artifacts and dependencies
|
|
@printf "$(BLUE)Cleaning up...$(RESET)\n"
|
|
@rm -rf node_modules dist build .cache
|
|
|
|
##@ Development
|
|
|
|
dev: ## Start development server
|
|
@printf "$(BLUE)Starting development server...$(RESET)\n"
|
|
@bun run dev
|
|
|
|
build: ## Build the application
|
|
@printf "$(BLUE)Building application...$(RESET)\n"
|
|
@bun run build
|
|
|
|
preview: ## Preview the built application
|
|
@printf "$(BLUE)Starting preview server...$(RESET)\n"
|
|
@bun run preview
|
|
|
|
##@ Testing
|
|
|
|
test: ## Run unit tests
|
|
@printf "$(BLUE)Running unit tests...$(RESET)\n"
|
|
@bun run test
|
|
|
|
test-watch: ## Run unit tests in watch mode
|
|
@printf "$(BLUE)Running tests in watch mode...$(RESET)\n"
|
|
@bun run test:watch
|
|
|
|
test-coverage: ## Run tests with coverage
|
|
@printf "$(BLUE)Running tests with coverage...$(RESET)\n"
|
|
@bun run test:coverage
|
|
|
|
test-integration: ## Run integration tests
|
|
@printf "$(BLUE)Running integration tests...$(RESET)\n"
|
|
@bun run test:integration
|
|
|
|
test-e2e: ## Run end-to-end tests
|
|
@printf "$(BLUE)Running e2e tests...$(RESET)\n"
|
|
@bun run test:e2e
|
|
|
|
test-e2e-ui: ## Run e2e tests with UI
|
|
@printf "$(BLUE)Running e2e tests with UI...$(RESET)\n"
|
|
@bun run test:e2e:ui
|
|
|
|
test-e2e-debug: ## Debug e2e tests
|
|
@printf "$(BLUE)Debugging e2e tests...$(RESET)\n"
|
|
@bun run test:e2e:debug
|
|
|
|
test-e2e-report: ## Show e2e test report
|
|
@printf "$(BLUE)Showing e2e test report...$(RESET)\n"
|
|
@bun run test:e2e:report
|
|
|
|
test-backend: ## Run backend tests (unit + integration)
|
|
@printf "$(BLUE)Running backend tests...$(RESET)\n"
|
|
@bun run test && bun run test:integration
|
|
|
|
test-all: ## Run all tests (unit + integration + e2e)
|
|
@printf "$(BLUE)Running all tests...$(RESET)\n"
|
|
@bun run test:all
|
|
|
|
##@ Code Quality
|
|
|
|
lint: ## Run all linting checks
|
|
@printf "$(BLUE)Running linting checks...$(RESET)\n"
|
|
@bun run lint
|
|
|
|
lint-fix: ## Fix linting issues
|
|
@printf "$(BLUE)Fixing linting issues...$(RESET)\n"
|
|
@bun run lint:fix
|
|
|
|
lint-markdown: ## Lint markdown files
|
|
@printf "$(BLUE)Linting markdown files...$(RESET)\n"
|
|
@bun run lint:markdown
|
|
|
|
lint-markdown-fix: ## Fix markdown linting issues
|
|
@printf "$(BLUE)Fixing markdown linting issues...$(RESET)\n"
|
|
@bun run lint:markdown:fix
|
|
|
|
lint-docker: ## Lint Dockerfile
|
|
@printf "$(BLUE)Linting Dockerfile...$(RESET)\n"
|
|
@bun run lint:docker
|
|
|
|
check-secrets: ## Check for secrets in code
|
|
@printf "$(BLUE)Checking for secrets...$(RESET)\n"
|
|
@bun run check:secrets
|
|
|
|
check-editorconfig: ## Check EditorConfig compliance
|
|
@printf "$(BLUE)Checking EditorConfig compliance...$(RESET)\n"
|
|
@bun run check:editorconfig
|
|
|
|
fix-editorconfig: ## Fix EditorConfig issues
|
|
@printf "$(BLUE)Fixing EditorConfig issues...$(RESET)\n"
|
|
@bun run fix:editorconfig
|
|
|
|
pre-commit: ## Run pre-commit checks
|
|
@printf "$(BLUE)Running pre-commit checks...$(RESET)\n"
|
|
@bun run pre-commit
|
|
|
|
##@ Setup & Deployment
|
|
|
|
setup: ## Setup the project
|
|
@printf "$(BLUE)Setting up project...$(RESET)\n"
|
|
@bun run setup
|
|
|
|
deploy: ## Deploy the application
|
|
@printf "$(BLUE)Deploying application...$(RESET)\n"
|
|
@bun run deploy
|
|
|
|
undeploy: ## Undeploy the application (both k8s and docker)
|
|
@printf "$(BLUE)Undeploying application...$(RESET)\n"
|
|
@$(MAKE) undeploy-k8s
|
|
@$(MAKE) undeploy-docker
|
|
|
|
undeploy-k8s: ## Undeploy from Kubernetes only
|
|
@printf "$(BLUE)Undeploying from Kubernetes...$(RESET)\n"
|
|
@if kubectl get deployment -l app=rxminder 2>/dev/null | grep -q rxminder; then \
|
|
$(MAKE) k8s-undeploy; \
|
|
else \
|
|
printf "$(YELLOW)No Kubernetes deployments found for rxminder$(RESET)\n"; \
|
|
fi
|
|
|
|
undeploy-docker: ## Stop and remove Docker Compose services
|
|
@printf "$(BLUE)Undeploying Docker containers...$(RESET)\n"
|
|
@if docker-compose -f docker/docker-compose.yaml ps --services 2>/dev/null | grep -q .; then \
|
|
$(MAKE) docker-down; \
|
|
else \
|
|
printf "$(YELLOW)No Docker Compose services found running$(RESET)\n"; \
|
|
fi
|
|
|
|
undeploy-docker-full: ## Stop, remove containers and delete volumes
|
|
@printf "$(BLUE)Full Docker undeploy (includes volumes)...$(RESET)\n"
|
|
@if docker-compose -f docker/docker-compose.yaml ps --services 2>/dev/null | grep -q .; then \
|
|
$(MAKE) docker-down-volumes; \
|
|
else \
|
|
printf "$(YELLOW)No Docker Compose services found running$(RESET)\n"; \
|
|
fi
|
|
|
|
validate-env: ## Validate environment configuration
|
|
@printf "$(BLUE)Validating environment...$(RESET)\n"
|
|
@bun run validate:env
|
|
|
|
validate-deployment: ## Validate deployment
|
|
@printf "$(BLUE)Validating deployment...$(RESET)\n"
|
|
@bun run validate:deployment
|
|
|
|
seed-production: ## Seed production database
|
|
@printf "$(BLUE)Seeding production database...$(RESET)\n"
|
|
@bun run seed:production
|
|
|
|
##@ Kubernetes
|
|
|
|
k8s-deploy: ## Deploy to Kubernetes
|
|
@printf "$(BLUE)Deploying to Kubernetes...$(RESET)\n"
|
|
@bun run deploy:k8s
|
|
|
|
k8s-undeploy: ## Remove from Kubernetes
|
|
@printf "$(BLUE)Removing from Kubernetes...$(RESET)\n"
|
|
@bun run undeploy:k8s
|
|
|
|
k8s-deploy-dry: ## Dry run Kubernetes deployment
|
|
@printf "$(BLUE)Dry run Kubernetes deployment...$(RESET)\n"
|
|
@bun run deploy:k8s --dry-run
|
|
|
|
k8s-undeploy-dry: ## Dry run Kubernetes removal
|
|
@printf "$(BLUE)Dry run Kubernetes removal...$(RESET)\n"
|
|
@bun run undeploy:k8s --dry-run
|
|
|
|
k8s-status: ## Show Kubernetes deployment status
|
|
@printf "$(BLUE)Showing Kubernetes status...$(RESET)\n"
|
|
@bun run deploy:k8s --status
|
|
|
|
##@ Docker
|
|
|
|
docker-setup: ## Setup Docker buildx
|
|
@printf "$(BLUE)Setting up Docker buildx...$(RESET)\n"
|
|
@bun run docker:setup
|
|
|
|
docker-build: ## Build multi-platform Docker images
|
|
@printf "$(BLUE)Building multi-platform Docker images...$(RESET)\n"
|
|
@bun run docker:build
|
|
|
|
docker-build-local: ## Build local Docker image
|
|
@printf "$(BLUE)Building local Docker image...$(RESET)\n"
|
|
@bun run docker:build-local
|
|
|
|
docker-bake: ## Build with Docker Bake
|
|
@printf "$(BLUE)Building with Docker Bake...$(RESET)\n"
|
|
@bun run docker:bake
|
|
|
|
docker-inspect: ## Inspect Docker buildx
|
|
@printf "$(BLUE)Inspecting Docker buildx...$(RESET)\n"
|
|
@bun run docker:inspect
|
|
|
|
docker-cleanup: ## Cleanup Docker buildx
|
|
@printf "$(BLUE)Cleaning up Docker buildx...$(RESET)\n"
|
|
@bun run docker:cleanup
|
|
|
|
docker-stop: ## Stop Docker Compose services
|
|
@printf "$(BLUE)Stopping Docker Compose services...$(RESET)\n"
|
|
@if docker-compose -f docker/docker-compose.yaml ps --services 2>/dev/null | grep -q .; then \
|
|
docker-compose -f docker/docker-compose.yaml stop; \
|
|
printf "$(GREEN)Docker Compose services stopped$(RESET)\n"; \
|
|
else \
|
|
printf "$(YELLOW)No Docker Compose services found running$(RESET)\n"; \
|
|
fi
|
|
|
|
docker-down: ## Stop and remove Docker Compose containers
|
|
@printf "$(BLUE)Stopping and removing Docker Compose containers...$(RESET)\n"
|
|
@if docker-compose -f docker/docker-compose.yaml ps --services 2>/dev/null | grep -q .; then \
|
|
docker-compose -f docker/docker-compose.yaml down; \
|
|
printf "$(GREEN)Docker Compose containers stopped and removed$(RESET)\n"; \
|
|
else \
|
|
printf "$(YELLOW)No Docker Compose services found running$(RESET)\n"; \
|
|
fi
|
|
|
|
docker-down-volumes: ## Stop, remove containers and delete volumes
|
|
@printf "$(BLUE)Stopping containers and removing volumes...$(RESET)\n"
|
|
@if docker-compose -f docker/docker-compose.yaml ps --services 2>/dev/null | grep -q .; then \
|
|
docker-compose -f docker/docker-compose.yaml down --volumes --remove-orphans; \
|
|
printf "$(GREEN)Docker Compose containers and volumes removed$(RESET)\n"; \
|
|
else \
|
|
printf "$(YELLOW)No Docker Compose services found running$(RESET)\n"; \
|
|
fi
|
|
|
|
docker-stop-all: ## Stop and remove ALL Docker containers (use with caution)
|
|
@printf "$(BLUE)Stopping all Docker containers...$(RESET)\n"
|
|
@docker stop $$(docker ps -aq) 2>/dev/null || true
|
|
@docker rm $$(docker ps -aq) 2>/dev/null || true
|
|
|
|
docker-prune: ## Remove unused Docker images and volumes
|
|
@printf "$(BLUE)Cleaning up Docker images and volumes...$(RESET)\n"
|
|
@docker image prune -f --filter "until=24h" 2>/dev/null || true
|
|
@docker volume prune -f 2>/dev/null || true
|
|
@docker system prune -f 2>/dev/null || true
|
|
|
|
##@ Gitea
|
|
|
|
gitea-setup: ## Setup Gitea integration
|
|
@printf "$(BLUE)Setting up Gitea integration...$(RESET)\n"
|
|
@bun run gitea:setup
|
|
|
|
gitea-build: ## Build multi-platform images for Gitea
|
|
@printf "$(BLUE)Building multi-platform images for Gitea...$(RESET)\n"
|
|
@bun run gitea:build
|
|
|
|
gitea-build-local: ## Build local image for Gitea
|
|
@printf "$(BLUE)Building local image for Gitea...$(RESET)\n"
|
|
@bun run gitea:build-local
|
|
|
|
gitea-build-staging: ## Build staging image for Gitea
|
|
@printf "$(BLUE)Building staging image for Gitea...$(RESET)\n"
|
|
@bun run gitea:build-staging
|
|
|
|
gitea-build-prod: ## Build production image for Gitea
|
|
@printf "$(BLUE)Building production image for Gitea...$(RESET)\n"
|
|
@bun run gitea:build-prod
|
|
|
|
gitea-test: ## Test Gitea integration
|
|
@printf "$(BLUE)Testing Gitea integration...$(RESET)\n"
|
|
@bun run gitea:test
|
|
|
|
gitea-deploy: ## Deploy to Gitea
|
|
@printf "$(BLUE)Deploying to Gitea...$(RESET)\n"
|
|
@bun run gitea:deploy
|
|
|
|
gitea-status: ## Show Gitea deployment status
|
|
@printf "$(BLUE)Showing Gitea status...$(RESET)\n"
|
|
@bun run gitea:status
|
|
|
|
gitea-cleanup: ## Cleanup Gitea resources
|
|
@printf "$(BLUE)Cleaning up Gitea resources...$(RESET)\n"
|
|
@bun run gitea:cleanup
|
|
|
|
##@ Quick Commands
|
|
|
|
start: dev ## Alias for dev (start development server)
|
|
|
|
build-and-test: build test ## Build and run tests
|
|
@printf "$(GREEN)Build and test completed!$(RESET)\n"
|
|
|
|
full-check-backend: lint test-backend ## Run backend code quality check (unit + integration tests only)
|
|
@printf "$(GREEN)Backend check completed!$(RESET)\n"
|
|
|
|
full-check: lint test-all ## Run full code quality check (includes unit + integration + E2E tests)
|
|
@printf "$(GREEN)Full check completed!$(RESET)\n"
|
|
|
|
quick-deploy: build k8s-deploy ## Quick build and deploy to Kubernetes
|
|
@printf "$(GREEN)Quick deployment completed!$(RESET)\n"
|
|
|
|
reset: clean install ## Reset project (clean and reinstall)
|
|
@printf "$(GREEN)Project reset completed!$(RESET)\n"
|