# NxMesh Development Justfile # Common commands for development workflow # Default recipe - shows available commands default: @just --list # ============================================================================= # Setup Commands # ============================================================================= # Initial setup - run once after devcontainer creation setup: @echo "๐Ÿš€ Setting up NxMesh development environment..." just setup-rust-tools just setup-frontend just db-setup @echo "โœ… Setup complete!" # Setup Rust dependencies and tools setup-rust-tools: @echo "๐Ÿ“ฆ Installing Rust dependencies..." cargo fetch @echo "๐Ÿ”ง Installing cargo tools..." cargo install --locked # Setup frontend dependencies setup-frontend: @echo "๐Ÿ“ฆ Installing frontend dependencies..." cd frontend && bun install # ============================================================================= # Development Commands # ============================================================================= # Start all services for development dev: @echo "๐Ÿš€ Starting all development services..." just dev-backend & just dev-frontend & wait # Start Rust backend with hot reload dev-backend: @echo "๐Ÿ”ง Starting Rust backend..." cargo watch -x run # Start Vite frontend development server dev-frontend: @echo "โš›๏ธ Starting Vite frontend..." cd frontend && bun dev # Start services (called by devcontainer post-start) start-services: @echo "๐Ÿ”ง Ensuring services are ready..." just db-wait # ============================================================================= # Build Commands # ============================================================================= # Build the entire project (backend + frontend) build: @echo "๐Ÿ—๏ธ Building entire project..." just build-frontend just build-backend # Build Rust backend build-backend: @echo "๐Ÿ”จ Building Rust backend..." cargo build --release # Build frontend and embed into backend build-frontend: @echo "โš›๏ธ Building frontend..." cd frontend && bun run build @echo "๐Ÿ“ฆ Embedding frontend into backend static files..." mkdir -p dist cp -r frontend/dist/* dist/ 2>/dev/null || true # ============================================================================= # Database Commands # ============================================================================= # Setup database db-setup: @echo "๐Ÿ˜ Setting up PostgreSQL database..." just db-wait sea-orm-cli setup 2>/dev/null || true just db-migrate # Wait for database to be ready db-wait: @echo "โณ Waiting for PostgreSQL..." @until pg_isready -h postgres -p 5432 -U postgres; do sleep 1; done @echo "โœ… PostgreSQL is ready!" # Run database migrations db-migrate: @echo "๐Ÿ”„ Running database migrations..." sea-orm-cli migrate up # Create new database migration db-new-migration name: @echo "๐Ÿ“ Creating new migration: {{name}}" sea-orm-cli migrate generate {{name}} # Reset database (drop and recreate) db-reset: @echo "โš ๏ธ Resetting database..." sea-orm-cli database reset # Connect to database with psql db-console: @echo "๐Ÿ˜ Connecting to PostgreSQL..." psql $DATABASE_URL # ============================================================================= # Testing Commands # ============================================================================= # Run all tests test: @echo "๐Ÿงช Running all tests..." just test-backend just test-frontend # Run Rust backend tests test-backend: @echo "๐Ÿฆ€ Running Rust tests..." cargo test # Run frontend tests test-frontend: @echo "โš›๏ธ Running frontend tests..." cd frontend && bun test # ============================================================================= # Lint & Format Commands # ============================================================================= # Format all code fmt: @echo "๐ŸŽจ Formatting code..." just fmt-rust just fmt-frontend # Format Rust code fmt-rust: @echo "๐Ÿฆ€ Formatting Rust..." cargo fmt # Format frontend code fmt-frontend: @echo "โš›๏ธ Formatting frontend..." cd frontend && bun run format # Lint all code lint: @echo "๐Ÿ” Linting code..." just lint-rust just lint-frontend # Lint Rust code lint-rust: @echo "๐Ÿฆ€ Linting Rust..." cargo clippy -- -D warnings # Lint frontend code lint-frontend: @echo "โš›๏ธ Linting frontend..." cd frontend && bun run lint # ============================================================================= # Docker Commands # ============================================================================= # Build Docker image for production docker-build: @echo "๐Ÿณ Building Docker image..." docker build -t nxmesh:latest -f Dockerfile.prod . # Run production Docker container docker-run: @echo "๐Ÿณ Running Docker container..." docker run -p 8080:8080 --env-file .env nxmesh:latest # ============================================================================= # Nginx Commands (Shared PID Namespace + Docker Fallback) # ============================================================================= # Reload nginx configuration (uses shared PID namespace if available) nginx-reload: @echo "๐Ÿ”„ Reloading nginx..." bash .devcontainer/scripts/nginx-reload.sh # Full nginx control via shared PID namespace # Usage: just nginx-ctl nginx-ctl cmd="reload": @bash .devcontainer/scripts/nginx-ctl.sh {{cmd}} # Quick status check nginx-status: @just nginx-ctl status # Test nginx configuration nginx-test: @echo "๐Ÿงช Testing nginx configuration..." bash .devcontainer/scripts/nginx-test.sh # Show nginx logs nginx-logs: @docker logs -f $(docker ps -q -f "ancestor=nginx:alpine" | head -1) 2>/dev/null || echo "Nginx container not found" # Edit nginx config and reload nginx-apply: @echo "๐Ÿ“ Testing and applying nginx config..." just nginx-test just nginx-reload # Copy local nginx config changes to container and reload nginx-update: @echo "๐Ÿ“ฆ Updating nginx configuration..." docker cp .devcontainer/nginx/nginx.conf $(docker ps -q -f "ancestor=nginx:alpine" | head -1):/etc/nginx/nginx.conf docker cp .devcontainer/nginx/conf.d $(docker ps -q -f "ancestor=nginx:alpine" | head -1):/etc/nginx/ just nginx-apply # ============================================================================= # Utility Commands # ============================================================================= # Clean build artifacts clean: @echo "๐Ÿงน Cleaning build artifacts..." cargo clean cd frontend && rm -rf dist node_modules bun.lockb rm -rf dist # Full clean (includes database) clean-all: clean @echo "๐Ÿงน Cleaning everything including database..." sea-orm-cli database drop 2>/dev/null || true # Update dependencies update: @echo "๐Ÿ“ฆ Updating dependencies..." cargo update cd frontend && bun update # Check project health health: @echo "๐Ÿฅ Checking project health..." @echo "PostgreSQL: $(pg_isready -h postgres -p 5432 -U postgres > /dev/null 2>&1 && echo 'โœ…' || echo 'โŒ')" @echo "Nginx: $(curl -sf http://nginx/health > /dev/null 2>&1 && echo 'โœ…' || echo 'โŒ')" @echo "Backend: $(curl -sf http://localhost:8080/health > /dev/null 2>&1 && echo 'โœ…' || echo 'โŒ')" @echo "Vite Dev: $(curl -sf http://localhost:3000 > /dev/null 2>&1 && echo 'โœ…' || echo 'โŒ')" # Show logs from all services logs: @echo "๐Ÿ“‹ Showing logs from all services..." cd .devcontainer && docker-compose logs -f # Generate project documentation docs: @echo "๐Ÿ“š Generating documentation..." cargo doc --open 2>/dev/null || cargo doc