Files
firefrost-services/services/modpack-version-checker/blueprint-extension/build.sh
Claude (Chronicler #63) 0cbea6d993 feat(modpackchecker): Phase 5 complete - Dashboard badge and cron job
Phase 5 Components (completing Pyrrhus's work):

NEW FILES:
- views/dashboard/UpdateBadge.tsx: Dashboard badge component
  - Shows 🟢 (up to date) or 🟠 (update available) next to server names
  - Global cache prevents multiple API calls on page load
  - Reads from local database, never calls external APIs directly
  - Fire (#FF6B35) and Frost (#4ECDC4) brand colors

- console/CheckModpackUpdates.php: Laravel cron command
  - Run with: php artisan modpackchecker:check
  - Loops through servers with MODPACK_PLATFORM variable
  - Checks CurseForge, Modrinth, FTB, Technic APIs
  - Rate limited (2s sleep between checks)
  - Stores results in modpackchecker_servers table

UPDATED FILES:
- Controllers/ModpackAPIController.php:
  - Added getStatus() method for dashboard badge endpoint
  - Returns all user's servers' update status in single query
  - Added DB facade import

- routes/client.php:
  - Added GET /extensions/modpackchecker/status route

- build.sh:
  - Complete rewrite for Phase 5
  - Handles both console widget AND dashboard badge
  - Auto-detects extension directory (dev vs extensions)
  - Copies CheckModpackUpdates.php to app/Console/Commands/
  - Injects UpdateBadge into ServerRow.tsx
  - Clear status output and next-steps guide

Architecture (Gemini-approved):
  CRON (hourly) → Database cache → Single API endpoint → React badge
  Dashboard badge is 'dumb' - only reads from cache, never external APIs

Completing work started by Chronicler #62 (Pyrrhus).
UpdateBadge.tsx was lost in Blueprint corruption - reconstructed from
handoff notes and architecture documentation.

Signed-off-by: Claude (Chronicler #63) <claude@firefrostgaming.com>
2026-04-06 08:53:27 +00:00

96 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
# build.sh - Executes automatically during blueprint -build
# Phase 5: Console widget + Dashboard badge injection
echo "=========================================="
echo "ModpackChecker Build Script - Phase 5"
echo "=========================================="
# Determine the extension source directory
# Blueprint may run from .blueprint/dev/ or .blueprint/extensions/modpackchecker/
if [ -d ".blueprint/extensions/modpackchecker/views" ]; then
EXT_DIR=".blueprint/extensions/modpackchecker"
elif [ -d ".blueprint/dev/views" ]; then
EXT_DIR=".blueprint/dev"
else
echo "ERROR: Cannot find extension views directory"
exit 1
fi
echo "Using extension directory: $EXT_DIR"
# ===========================================
# 1. CONSOLE WIDGET (wrapper.tsx → ModpackVersionCard)
# ===========================================
echo ""
echo "--- Console Widget ---"
if [ -f "$EXT_DIR/views/server/wrapper.tsx" ]; then
cp "$EXT_DIR/views/server/wrapper.tsx" resources/scripts/components/server/ModpackVersionCard.tsx
echo "✓ Copied ModpackVersionCard.tsx"
else
echo "⚠ wrapper.tsx not found, skipping console widget"
fi
# Inject into ServerConsoleContainer.tsx
if ! grep -q "ModpackVersionCard" resources/scripts/components/server/console/ServerConsoleContainer.tsx 2>/dev/null; then
sed -i '1i import ModpackVersionCard from "@/components/server/ModpackVersionCard";' resources/scripts/components/server/console/ServerConsoleContainer.tsx
sed -i '/<ServerDetailsBlock className/a \ <ModpackVersionCard />' resources/scripts/components/server/console/ServerConsoleContainer.tsx
echo "✓ Injected ModpackVersionCard into ServerConsoleContainer.tsx"
else
echo "○ ModpackVersionCard already present in ServerConsoleContainer.tsx"
fi
# ===========================================
# 2. DASHBOARD BADGE (UpdateBadge.tsx)
# ===========================================
echo ""
echo "--- Dashboard Badge ---"
if [ -f "$EXT_DIR/views/dashboard/UpdateBadge.tsx" ]; then
# Ensure target directory exists
mkdir -p resources/scripts/components/dashboard
cp "$EXT_DIR/views/dashboard/UpdateBadge.tsx" resources/scripts/components/dashboard/UpdateBadge.tsx
echo "✓ Copied UpdateBadge.tsx"
else
echo "⚠ UpdateBadge.tsx not found, skipping dashboard badge"
fi
# Inject into ServerRow.tsx (dashboard server list)
if ! grep -q "UpdateBadge" resources/scripts/components/dashboard/ServerRow.tsx 2>/dev/null; then
# Add import at top
sed -i '1i import UpdateBadge from "@/components/dashboard/UpdateBadge";' resources/scripts/components/dashboard/ServerRow.tsx
# Inject badge right after the server name
# The pattern looks for the server name paragraph and adds our badge inside it
sed -i 's|<p css={tw`text-lg break-words`}>{server.name}</p>|<p css={tw`text-lg break-words`}>{server.name}<UpdateBadge serverUuid={server.uuid} /></p>|' resources/scripts/components/dashboard/ServerRow.tsx
echo "✓ Injected UpdateBadge into ServerRow.tsx"
else
echo "○ UpdateBadge already present in ServerRow.tsx"
fi
# ===========================================
# 3. CONSOLE COMMAND (CheckModpackUpdates.php)
# ===========================================
echo ""
echo "--- Console Command ---"
if [ -f "$EXT_DIR/console/CheckModpackUpdates.php" ]; then
cp "$EXT_DIR/console/CheckModpackUpdates.php" app/Console/Commands/CheckModpackUpdates.php
echo "✓ Copied CheckModpackUpdates.php to app/Console/Commands/"
else
echo "⚠ CheckModpackUpdates.php not found, skipping cron command"
fi
echo ""
echo "=========================================="
echo "ModpackChecker injection complete!"
echo "=========================================="
echo ""
echo "Next steps:"
echo " 1. Run: yarn build:production"
echo " 2. Restart: systemctl restart php8.3-fpm"
echo " 3. Test cron: php artisan modpackchecker:check"
echo ""