# Makefile for Medication Reminder App # Consolidated version with grouped targets and reduced redundancy .PHONY: help install clean dev build test lint docker 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 reset: clean install ## Reset project (clean and reinstall) @printf "$(GREEN)Project reset completed!$(RESET)\n" ##@ Development dev: ## Start development server @printf "$(BLUE)Starting development server...$(RESET)\n" @bun run dev build: ## Build the application for development @printf "$(BLUE)Building application for development...$(RESET)\n" @NODE_ENV=development bun run build build-prod: ## Build the application for production @printf "$(BLUE)Building application for production...$(RESET)\n" @bun run build preview: ## Preview the built application @printf "$(BLUE)Starting preview server...$(RESET)\n" @bun run preview setup: ## Setup the project @printf "$(BLUE)Setting up project...$(RESET)\n" @bun run setup ##@ Testing & Quality 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 interactive UI @printf "$(BLUE)Running e2e tests with UI...$(RESET)\n" @bun run test:e2e:ui test-auth-debug: ## Run authentication debug tests @printf "$(BLUE)Running authentication debug tests...$(RESET)\n" @bunx playwright test --config=tests/e2e/playwright.auth.config.ts test-auth-debug-ui: ## Run authentication debug tests with UI @printf "$(BLUE)Running authentication debug tests with UI...$(RESET)\n" @bunx playwright test --config=tests/e2e/playwright.auth.config.ts --ui test-all: ## Run all tests (unit + integration + e2e) @printf "$(BLUE)Running all tests...$(RESET)\n" @bun run test:all lint: ## Run linting and fix issues @printf "$(BLUE)Running linting checks...$(RESET)\n" @bun run lint @bun run lint:fix 2>/dev/null || true pre-commit: ## Run pre-commit checks @printf "$(BLUE)Running pre-commit checks...$(RESET)\n" @bun run pre-commit check: lint test-all ## Run complete quality check (lint + all tests) @printf "$(GREEN)Quality check completed!$(RESET)\n" ##@ Docker docker-build: ## Build Docker images (local and multi-platform) @printf "$(BLUE)Building Docker images...$(RESET)\n" @bun run docker:build-local @bun run docker:build 2>/dev/null || true docker-build-local: ## Build Docker image for local platform only @printf "$(BLUE)Building local Docker image...$(RESET)\n" @./scripts/buildx-helper.sh build-local docker-build-multi: ## Build multi-platform Docker images @printf "$(BLUE)Building multi-platform Docker images...$(RESET)\n" @./scripts/buildx-helper.sh build-multi docker-build-multi-dev: ## Build multi-platform Docker images for development @printf "$(BLUE)Building multi-platform Docker images for development...$(RESET)\n" @./scripts/buildx-helper.sh build-multi-dev docker-build-push: ## Build and push multi-platform Docker images @printf "$(BLUE)Building and pushing multi-platform Docker images...$(RESET)\n" @./scripts/buildx-helper.sh build-push docker-push: ## Push existing Docker images to registry @printf "$(BLUE)Pushing Docker images to registry...$(RESET)\n" @./scripts/buildx-helper.sh push docker-setup: ## Setup Docker buildx builder instance @printf "$(BLUE)Setting up Docker buildx builder...$(RESET)\n" @./scripts/buildx-helper.sh setup docker-inspect: ## Inspect Docker buildx builder @printf "$(BLUE)Inspecting Docker buildx builder...$(RESET)\n" @./scripts/buildx-helper.sh inspect docker-bake: ## Build using docker-bake.hcl @printf "$(BLUE)Building using docker-bake.hcl...$(RESET)\n" @./scripts/buildx-helper.sh bake docker-list: ## List available Docker buildx builders @printf "$(BLUE)Listing Docker buildx builders...$(RESET)\n" @./scripts/buildx-helper.sh list docker-down: ## Stop and remove Docker containers @printf "$(BLUE)Stopping Docker 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 containers stopped$(RESET)\n"; \ else \ printf "$(YELLOW)No containers running$(RESET)\n"; \ fi docker-clean: docker-down ## Stop containers and clean up volumes/images @printf "$(BLUE)Cleaning Docker resources...$(RESET)\n" @docker-compose -f docker/docker-compose.yaml down --volumes --remove-orphans 2>/dev/null || true @docker image prune -f --filter "until=24h" 2>/dev/null || true @docker volume prune -f 2>/dev/null || true docker-cleanup: ## Remove buildx builder and cleanup @printf "$(BLUE)Cleaning up Docker buildx resources...$(RESET)\n" @./scripts/buildx-helper.sh cleanup ##@ Kubernetes Deployment deploy-dev: ## Deploy to development environment @printf "$(BLUE)Deploying to development...$(RESET)\n" @kubectl apply -k k8s-kustomize/overlays/dev deploy-prod: ## Deploy to production environment @printf "$(BLUE)Deploying to production...$(RESET)\n" @kubectl apply -k k8s-kustomize/overlays/prod undeploy-dev: ## Remove development deployment @printf "$(BLUE)Removing development deployment...$(RESET)\n" @kubectl delete -k k8s-kustomize/overlays/dev --ignore-not-found=true undeploy-prod: ## Remove production deployment @printf "$(BLUE)Removing production deployment...$(RESET)\n" @kubectl delete -k k8s-kustomize/overlays/prod --ignore-not-found=true status-dev: ## Show development deployment status @printf "$(BLUE)Development status...$(RESET)\n" @kubectl get all -n rxminder-dev -l app=rxminder 2>/dev/null || printf "$(YELLOW)No development deployment found$(RESET)\n" status-prod: ## Show production deployment status @printf "$(BLUE)Production status...$(RESET)\n" @kubectl get all -n rxminder-prod -l app=rxminder 2>/dev/null || printf "$(YELLOW)No production deployment found$(RESET)\n" diff-dev: ## Show changes for development deployment @printf "$(BLUE)Development diff...$(RESET)\n" @kubectl diff -k k8s-kustomize/overlays/dev 2>/dev/null || true diff-prod: ## Show changes for production deployment @printf "$(BLUE)Production diff...$(RESET)\n" @kubectl diff -k k8s-kustomize/overlays/prod 2>/dev/null || true validate-k8s: ## Validate Kubernetes configurations @printf "$(BLUE)Validating Kubernetes configs...$(RESET)\n" @kubectl kustomize k8s-kustomize/overlays/dev | kubectl apply --dry-run=client --validate=true -f - >/dev/null @kubectl kustomize k8s-kustomize/overlays/prod | kubectl apply --dry-run=client --validate=true -f - >/dev/null @printf "$(GREEN)Kubernetes validation passed!$(RESET)\n" ##@ Configuration generate-config: ## Generate configuration for all environments using unified config @printf "$(BLUE)Generating unified configurations...$(RESET)\n" @bun scripts/generate-unified-config.ts --all @printf "$(GREEN)Unified configurations generated!$(RESET)\n" generate-config-dev: ## Generate configuration for development environment @printf "$(BLUE)Generating development configuration...$(RESET)\n" @bun scripts/generate-unified-config.ts development @printf "$(GREEN)Development configuration generated!$(RESET)\n" generate-config-staging: ## Generate configuration for staging environment @printf "$(BLUE)Generating staging configuration...$(RESET)\n" @bun scripts/generate-unified-config.ts staging @printf "$(GREEN)Staging configuration generated!$(RESET)\n" generate-config-prod: ## Generate configuration for production environment @printf "$(BLUE)Generating production configuration...$(RESET)\n" @bun scripts/generate-unified-config.ts production @printf "$(GREEN)Production configuration generated!$(RESET)\n" validate-config: ## Validate unified configuration @printf "$(BLUE)Validating unified configuration...$(RESET)\n" @bun scripts/generate-unified-config.ts --dry-run @printf "$(GREEN)Configuration validation completed!$(RESET)\n" config-debug: ## Show current unified configuration (debug mode) @printf "$(BLUE)Current unified configuration:$(RESET)\n" @bun -e "import { logConfig } from './config/unified.config.ts'; logConfig();" ##@ Workflows start: dev ## Alias for dev (start development server) build-test: build test ## Build and run unit tests @printf "$(GREEN)Build and test completed!$(RESET)\n" deploy-dev-quick: build deploy-dev ## Build and deploy to development @printf "$(GREEN)Quick development deployment completed!$(RESET)\n" deploy-prod-quick: ## Build and deploy to production with generated secrets @printf "$(BLUE)Generating secure production secrets and deploying...$(RESET)\n" @JWT_SECRET=$$(openssl rand -base64 32) SESSION_SECRET=$$(openssl rand -base64 32) $(MAKE) build-prod @$(MAKE) deploy-prod @printf "$(GREEN)Production deployment completed with generated secrets!$(RESET)\n" deploy-prod-configured: build-prod deploy-prod ## Build and deploy to production (requires pre-configured secrets) @printf "$(GREEN)Production deployment completed with configured secrets!$(RESET)\n" deploy-demo: build ## Build and deploy demo version with development settings @printf "$(BLUE)Deploying demo version for testing...$(RESET)\n" @NODE_ENV=development docker-compose -f docker/docker-compose.yaml up -d --build 2>/dev/null || printf "$(YELLOW)Docker deployment failed, trying development K8s...$(RESET)\n" @printf "$(GREEN)Demo deployment completed! Access at http://localhost:8080$(RESET)\n" deploy-local: build ## Build and deploy locally using Docker @printf "$(BLUE)Starting local deployment with Docker...$(RESET)\n" @docker-compose -f docker/docker-compose.yaml down 2>/dev/null || true @NODE_ENV=development docker-compose -f docker/docker-compose.yaml up -d --build @printf "$(GREEN)Local deployment completed! Access at http://localhost:8080$(RESET)\n" @printf "$(BLUE)To stop: make docker-down$(RESET)\n" undeploy-all: undeploy-dev undeploy-prod docker-clean ## Remove all deployments and clean Docker @printf "$(GREEN)Complete cleanup completed!$(RESET)\n" stop-local: docker-down ## Stop local Docker deployment @printf "$(GREEN)Local deployment stopped!$(RESET)\n" ci-check: check validate-k8s ## Complete CI/CD validation pipeline @printf "$(GREEN)CI/CD checks passed!$(RESET)\n"