#!/bin/bash
# Quick script to check all generated code locations

echo "=== Generated Page Components (Build Output) ==="
echo "Location: target/*/build/pages-*/out/"
echo ""

# Find the most recent build output
PAGES_OUT=$(find target -name "page_*.rs" -path "*/pages-*/out/*" | head -1 | xargs dirname 2>/dev/null)
if [ -n "$PAGES_OUT" ]; then
    echo "📂 Most recent build output: $PAGES_OUT"
    echo "Files:"
    ls -1 "$PAGES_OUT"/page_*.rs 2>/dev/null | head -10 | sed 's/.*\//  - /'
    echo ""

    echo "📄 Sample generated component (Home):"
    find "$PAGES_OUT" -name "page_Home.rs" -exec head -20 {} \; 2>/dev/null
else
    echo "❌ No build output found. Run 'just build' first."
fi

echo ""
echo "=== Generated Page Cache (rustelo-cache) ==="
echo "Location: target/rustelo-cache/pages/"
echo ""

if [ -d "target/rustelo-cache/pages" ]; then
    echo "📂 Cached page components:"
    ls -1 target/rustelo-cache/pages/page_*.rs 2>/dev/null | head -10 | sed 's/.*\//  - /'
    echo ""

    echo "📄 Sample cached component (Home):"
    head -25 target/rustelo-cache/pages/page_Home.rs 2>/dev/null
else
    echo "❌ No cached page components found. Run 'cargo build' first."
fi

echo ""
echo "=== Generated Tools Components (Review Copy) ==="
echo "Location: site/devtools/data/pages/generated/"
echo ""

if [ -d "site/devtools/data/pages/generated" ]; then
    echo "📂 Development review copy:"
    ls -1 site/devtools/data/pages/generated/*.rs 2>/dev/null | head -10 | sed 's/.*\//  - /'
    echo ""

    echo "📄 Sample tools component (Home):"
    head -25 site/devtools/data/pages/generated/home.rs 2>/dev/null
else
    echo "❌ No devtools generated pages found. Run build with tools enabled."
fi

echo ""
echo "=== Route Configuration (Source) ==="
echo "Location: site/config/routes/"
echo ""

if [ -d "site/config/routes" ]; then
    echo "📂 Route configuration files:"
    ls -1 site/config/routes/*.toml 2>/dev/null | sed 's/.*\//  - /'
else
    echo "❌ No route configuration found."
fi

echo ""
echo "=== Analysis Documentation ==="
echo "Location: site/info/ (from SITE_INFO_PATH)"
echo ""

if [ -d "site/info" ]; then
    echo "📂 Generated analysis files:"
    ls -1 site/info/*analysis*.md site/info/*pages*.md 2>/dev/null | head -5 | sed 's/.*\//  - /'
    echo ""

    echo "📄 Sample analysis content (pages):"
    head -5 site/info/pages_analysis.md 2>/dev/null || echo "  No pages analysis available"
else
    echo "❌ No analysis documentation found."
fi

echo ""
echo "=== Content Structure ==="
echo "📝 Source content (clean): site/content/ - Only .md and source files"
echo "🌐 Generated content: public/r/ - Processed .html and .json files"
echo "📋 Standard frontmatter: Organized with comments, industry best practices"

echo ""
echo "=== Quick Commands ==="
echo "  just build                            # Generate all components"
echo "  just dev                              # Build and start with hot reload"
echo "  bash scripts/content/verify-clean-structure.sh  # Check content structure"
echo "  bash $0                               # Run this script again"
