# Bluesky Dashboard - Just commands
# https://github.com/casey/just

# Default recipe - show available commands
default:
    @just --list

# Run the development server (backend on port 5000)
run:
    #!/usr/bin/env bash
    if [ -z "$IN_NIX_SHELL" ]; then
        echo "Not in nix-shell, entering nix develop..."
        exec nix develop -c just run
    fi
    echo "Starting Bluesky Dashboard server..."
    python run.py

# Run with hot reload (backend + file watcher)
dev:
    #!/usr/bin/env bash
    if [ -z "$IN_NIX_SHELL" ]; then
        echo "Not in nix-shell, entering nix develop..."
        exec nix develop -c just dev
    fi
    echo "Starting with hot reload..."
    watchexec -r -e py -- python run.py

# Build frontend only
build:
    cd ClientApp && npm run build

# Watch and rebuild frontend on changes
watch:
    cd ClientApp && npm run watch

# Clean build artifacts
clean:
    rm -rf app_data
    rm -rf ClientApp/node_modules
    rm -f wwwroot/js/app.js
    rm -rf wwwroot/js/*.js.map

# Run linting and type checks
check:
    cd ClientApp && npm run typecheck

# Format code
fmt:
    cd ClientApp && npm run format

# Database operations
db-reset:
    rm -rf app_data/*.db
    echo "Database reset. Run 'just run' to recreate."

# Test the API endpoints
test-api:
    #!/usr/bin/env bash
    echo "Testing API endpoints..."
    curl -s http://localhost:5000/api/feed-generators | head -20

# Full setup (build frontend)
setup: build
    @echo "Setup complete! Run 'just run' to start."
An unhandled error has occurred. Reload 🗙