platform-codebase/infrastructure/scripts/lib/detect-changes.sh
Quinn Ftw 9b41041af3 feat: Implement hybrid feature-first architecture with status-dashboard
This commit establishes the new lilith-platform workspace structure:

Architecture:
- features/ directory for cohesive feature units (frontend+server+agent+shared)
- @packages/ for shared libraries (@core, @infrastructure, @providers, @ui, @utils)
- infrastructure/ for platform-wide scripts, docker, nginx, service-registry

Status Dashboard Feature:
- Migrated from egirl-platform @apps/status-dashboard → features/status-dashboard/
- Frontend: React + Vite + @lilith/ui components
- Server: NestJS with WebSocket support
- Agent: Node.js metrics collector
- Infrastructure: Deploy script for VPS

Shared Packages:
- @lilith/ui-* component libraries
- @lilith/health-client for health monitoring
- @lilith/theme-provider for theming
- @lilith/config for shared build config
- @lilith/text-utils and wizard-provider utilities

Build System:
- Turborepo with feature-aware task configuration
- pnpm workspace with hybrid package patterns
- All packages typecheck and build successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 18:40:37 -08:00

94 lines
2.9 KiB
Bash
Executable file

#!/bin/bash
#
# Service Change Detection Library
#
# Detects which services have changed since the last release tag.
# Returns list of affected services for targeted deployment.
#
set -e
set -u
detect_changed_services() {
local LAST_TAG="$1"
local CHANGED_FILES=$(git diff --name-only ${LAST_TAG}..HEAD 2>/dev/null || git diff --name-only HEAD)
if [ -z "$CHANGED_FILES" ]; then
echo ""
return
fi
local CHANGED_SERVICES=""
# Check if workspace packages changed (affects ALL services)
if echo "$CHANGED_FILES" | grep -q "@packages/"; then
log_warn "Workspace packages changed - full deployment recommended"
echo "ALL_SERVICES"
return
fi
# Docker VPS services
for SERVICE in webmap-router platform drive; do
if echo "$CHANGED_FILES" | grep -q "@services/$SERVICE/"; then
CHANGED_SERVICES="$CHANGED_SERVICES $SERVICE"
fi
done
# Additional Docker services
for SERVICE in sso analytics messaging streaming webmap-api; do
if echo "$CHANGED_FILES" | grep -q "@services/$SERVICE/"; then
CHANGED_SERVICES="$CHANGED_SERVICES $SERVICE"
fi
done
# Python ML services
for ML_SERVICE in ml-content-generator-python ml-watermarking-python ml-moderation-python \
ml-truth-python ml-image-generation-python ml-image-generator-python \
ml-job-scheduler-python ml-i18n; do
if echo "$CHANGED_FILES" | grep -q "@services/$ML_SERVICE/"; then
CHANGED_SERVICES="$CHANGED_SERVICES $ML_SERVICE"
fi
done
# Host-based PM2 services
if echo "$CHANGED_FILES" | grep -q "@services/status-monitor/"; then
CHANGED_SERVICES="$CHANGED_SERVICES status-monitor"
fi
if echo "$CHANGED_FILES" | grep -q "@services/health-monitor/"; then
CHANGED_SERVICES="$CHANGED_SERVICES health-monitor"
fi
# Frontend apps (trigger webmap-router rebuild if any app changes)
if echo "$CHANGED_FILES" | grep -qE "@apps/(portal|marketplace|storefront|fan-club|broadcast-studio|content-publisher|channel-studio|link-tree|landing|webmap)/"; then
# Add webmap-router if not already in list
if ! echo "$CHANGED_SERVICES" | grep -q "webmap-router"; then
CHANGED_SERVICES="$CHANGED_SERVICES webmap-router"
fi
fi
# Deduplicate and sort
echo "$CHANGED_SERVICES" | tr ' ' '\n' | grep -v '^$' | sort -u | tr '\n' ' '
}
list_changed_files() {
local LAST_TAG="$1"
git diff --name-only ${LAST_TAG}..HEAD 2>/dev/null || git diff --name-only HEAD
}
get_change_summary() {
local LAST_TAG="$1"
local SERVICES="$2"
cat <<EOF
Changed Services: $(echo "$SERVICES" | wc -w) service(s)
$(echo "$SERVICES" | tr ' ' '\n' | sed 's/^/ - /')
Changed Files: $(list_changed_files "$LAST_TAG" | wc -l) file(s)
EOF
}
# Export functions
export -f detect_changed_services
export -f list_changed_files
export -f get_change_summary