# =============================================================================
# BUILD SYSTEM COMMANDS - Rustelo Framework
# =============================================================================
# Enhanced build tools and cross-platform building

# Build CSS bundles
build-css-bundles:
    @echo "🎨 Building CSS bundles..."
    node ./scripts/build/build-css-bundles.js

# Build design system
build-design-system:
    @echo "🎨 Building design system..."
    node ./scripts/build/build-design-system.js

# Build theme system
build-theme:
    @echo "🎨 Building theme system..."
    node ./scripts/build/build-theme.js

# Copy CSS assets to public directory
copy-css-assets:
    @echo "🎨 Copying CSS assets..."
    node ./scripts/build/copy-css-assets.js

# Build for production with enhanced Leptos build
build-enhanced-prod:
    @echo "🔨 Building enhanced production version..."
    ./scripts/build/leptos-build.sh

# Cross-platform Docker build
build-cross-platform:
    @echo "🐳 Building for cross-platform deployment..."
    ./scripts/build/build-docker-cross.sh

# Pack project for distribution
dist-pack:
    @echo "📦 Packing project for distribution..."
    ./scripts/dist-pack.sh

# Cross-build for Linux AMD64
cross-build:
    @echo "📦 Cross-building for Linux AMD64..."
    ./scripts/cross-build.sh

# Build all assets (CSS + JS + themes)
build-all-assets:
    @echo "🎨 Building all frontend assets..."
    @just build-css-bundles
    @just build-design-system
    @just build-theme
    @just copy-css-assets

# =============================================================================
# DEPENDENCY SYNC - registry/Cargo.toml → workspace.dependencies
# =============================================================================
# `registry/Cargo.toml` is the single source of truth (editable in Zed via
# rust-analyzer's inline upgrade hints). These recipes propagate it to
# `rustelo/Cargo.toml` and to any implementation workspace.

# Propagate the registry into rustelo's own Cargo.toml managed region.
deps-sync:
    @echo "🔗 Syncing rustelo/Cargo.toml from registry/Cargo.toml..."
    cargo xtask sync-deps

# Verify rustelo/Cargo.toml matches the registry (exit 1 if drifted).
deps-sync-check:
    @echo "🔍 Checking rustelo/Cargo.toml for drift from registry..."
    cargo xtask sync-deps --check

# Propagate the registry into an implementation workspace.
# Example: just deps-sync-impl ../jpl-website
deps-sync-impl target:
    @echo "🔗 Syncing {{target}}/Cargo.toml from registry/Cargo.toml..."
    cargo xtask sync-deps --target {{target}}

# Verify an implementation's Cargo.toml matches the registry (exit 1 if drifted).
deps-sync-check-impl target:
    @echo "🔍 Checking {{target}}/Cargo.toml for drift from registry..."
    cargo xtask sync-deps --check --target {{target}}

# Sync rustelo + every implementation declared in registry/sync.toml [impls.known].
# Adding a new implementation is a registry/sync.toml edit — no recipe change needed.
deps-sync-all:
    @echo "🔗 Syncing rustelo + every known implementation..."
    cargo xtask sync-deps --all

# Verify rustelo + every implementation matches the registry (exit 1 if any drifts).
deps-sync-check-all:
    @echo "🔍 Checking rustelo + every known implementation for drift..."
    cargo xtask sync-deps --check --all
