Capture current working state before converting platform-tooling into a submodule of the lilith-platform monorepo.
213 lines
7.5 KiB
Bash
Executable file
213 lines
7.5 KiB
Bash
Executable file
#!/bin/bash
|
||
set -euo pipefail
|
||
|
||
#
|
||
# Migration Script: @lilith/theme-provider → @lilith/ui-theme
|
||
# Moves theme-provider from @providers to @ui and updates all references
|
||
#
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||
|
||
# Colors
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[0;33m'
|
||
BLUE='\033[0;34m'
|
||
NC='\033[0m'
|
||
|
||
log_step() { echo -e "\n${BLUE}▶${NC} $1"; }
|
||
log_success() { echo -e "${GREEN} ✓${NC} $1"; }
|
||
log_info() { echo -e "${YELLOW} ℹ${NC} $1"; }
|
||
log_error() { echo -e "${RED} ✗${NC} $1"; }
|
||
|
||
# =============================================================================
|
||
# CONFIGURATION
|
||
# =============================================================================
|
||
|
||
OLD_PACKAGE="@lilith/theme-provider"
|
||
NEW_PACKAGE="@lilith/ui-theme"
|
||
OLD_PATH_SEGMENT="@providers/theme-provider"
|
||
NEW_PATH_SEGMENT="@ui/ui-theme"
|
||
|
||
# Directories to process
|
||
DIRS=(
|
||
"$PROJECT_ROOT/codebase"
|
||
"$PROJECT_ROOT/releases"
|
||
"$PROJECT_ROOT/docs"
|
||
)
|
||
|
||
# =============================================================================
|
||
# STEP 1: Move directories
|
||
# =============================================================================
|
||
|
||
move_directories() {
|
||
log_step "Moving package directories..."
|
||
|
||
for base in "codebase" "releases"; do
|
||
local old_dir="$PROJECT_ROOT/$base/@packages/@providers/theme-provider"
|
||
local new_dir="$PROJECT_ROOT/$base/@packages/@ui/ui-theme"
|
||
|
||
if [ -d "$old_dir" ]; then
|
||
log_info "Moving $base/@packages/@providers/theme-provider → @ui/ui-theme"
|
||
mv "$old_dir" "$new_dir"
|
||
log_success "Moved $base"
|
||
else
|
||
log_info "Directory not found: $old_dir (skipping)"
|
||
fi
|
||
done
|
||
}
|
||
|
||
# =============================================================================
|
||
# STEP 2: Update package.json name fields
|
||
# =============================================================================
|
||
|
||
update_package_names() {
|
||
log_step "Updating package.json name fields..."
|
||
|
||
for base in "codebase" "releases"; do
|
||
local pkg_json="$PROJECT_ROOT/$base/@packages/@ui/ui-theme/package.json"
|
||
|
||
if [ -f "$pkg_json" ]; then
|
||
log_info "Updating $pkg_json"
|
||
sed -i 's/"name": "@lilith\/theme-provider"/"name": "@lilith\/ui-theme"/' "$pkg_json"
|
||
log_success "Updated $base package.json"
|
||
fi
|
||
done
|
||
}
|
||
|
||
# =============================================================================
|
||
# STEP 3: Update all imports in source files
|
||
# =============================================================================
|
||
|
||
update_imports() {
|
||
log_step "Updating import statements..."
|
||
|
||
local count=0
|
||
|
||
for dir in "${DIRS[@]}"; do
|
||
if [ -d "$dir" ]; then
|
||
# Update TypeScript/JavaScript imports
|
||
while IFS= read -r -d '' file; do
|
||
if grep -q "@lilith/theme-provider" "$file" 2>/dev/null; then
|
||
sed -i "s|@lilith/theme-provider|@lilith/ui-theme|g" "$file"
|
||
((count++))
|
||
fi
|
||
done < <(find "$dir" -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \) -print0 2>/dev/null)
|
||
fi
|
||
done
|
||
|
||
# Also update current working directory (releases/features/status-dashboard/frontend)
|
||
local cwd="$PROJECT_ROOT/releases/features/status-dashboard/frontend"
|
||
if [ -d "$cwd" ]; then
|
||
while IFS= read -r -d '' file; do
|
||
if grep -q "@lilith/theme-provider" "$file" 2>/dev/null; then
|
||
sed -i "s|@lilith/theme-provider|@lilith/ui-theme|g" "$file"
|
||
((count++))
|
||
fi
|
||
done < <(find "$cwd" -type f \( -name "*.ts" -o -name "*.tsx" \) -print0 2>/dev/null)
|
||
fi
|
||
|
||
log_success "Updated $count source files"
|
||
}
|
||
|
||
# =============================================================================
|
||
# STEP 4: Update package.json dependencies
|
||
# =============================================================================
|
||
|
||
update_dependencies() {
|
||
log_step "Updating package.json dependencies..."
|
||
|
||
local count=0
|
||
|
||
for dir in "${DIRS[@]}"; do
|
||
if [ -d "$dir" ]; then
|
||
while IFS= read -r -d '' file; do
|
||
if grep -q "@lilith/theme-provider" "$file" 2>/dev/null; then
|
||
sed -i 's/"@lilith\/theme-provider"/"@lilith\/ui-theme"/g' "$file"
|
||
((count++))
|
||
fi
|
||
done < <(find "$dir" -type f -name "package.json" -print0 2>/dev/null)
|
||
fi
|
||
done
|
||
|
||
# Also update status-dashboard frontend
|
||
local pkg="$PROJECT_ROOT/releases/features/status-dashboard/frontend/package.json"
|
||
if [ -f "$pkg" ] && grep -q "@lilith/theme-provider" "$pkg"; then
|
||
sed -i 's/"@lilith\/theme-provider"/"@lilith\/ui-theme"/g' "$pkg"
|
||
((count++))
|
||
fi
|
||
|
||
log_success "Updated $count package.json files"
|
||
}
|
||
|
||
# =============================================================================
|
||
# STEP 5: Update tsconfig paths
|
||
# =============================================================================
|
||
|
||
update_tsconfig() {
|
||
log_step "Updating tsconfig.base.json path mappings..."
|
||
|
||
for base in "codebase" "releases"; do
|
||
local tsconfig="$PROJECT_ROOT/$base/tsconfig.base.json"
|
||
|
||
if [ -f "$tsconfig" ]; then
|
||
log_info "Updating $tsconfig"
|
||
# Update the path alias
|
||
sed -i 's|"@lilith/theme-provider": \["./@packages/@providers/theme-provider/src"\]|"@lilith/ui-theme": ["./@packages/@ui/ui-theme/src"]|g' "$tsconfig"
|
||
log_success "Updated $base tsconfig"
|
||
fi
|
||
done
|
||
}
|
||
|
||
# =============================================================================
|
||
# STEP 6: Cleanup empty @providers if needed
|
||
# =============================================================================
|
||
|
||
cleanup_providers() {
|
||
log_step "Checking @providers directories..."
|
||
|
||
for base in "codebase" "releases"; do
|
||
local providers_dir="$PROJECT_ROOT/$base/@packages/@providers"
|
||
|
||
if [ -d "$providers_dir" ]; then
|
||
# Count remaining items
|
||
local remaining=$(ls -A "$providers_dir" 2>/dev/null | wc -l)
|
||
log_info "@providers in $base has $remaining remaining packages"
|
||
fi
|
||
done
|
||
}
|
||
|
||
# =============================================================================
|
||
# MAIN
|
||
# =============================================================================
|
||
|
||
main() {
|
||
echo ""
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo " Theme Provider Migration"
|
||
echo " @lilith/theme-provider → @lilith/ui-theme"
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo ""
|
||
|
||
move_directories
|
||
update_package_names
|
||
update_imports
|
||
update_dependencies
|
||
update_tsconfig
|
||
cleanup_providers
|
||
|
||
echo ""
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo " ${GREEN}✓${NC} Migration Complete!"
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo ""
|
||
echo " Next steps:"
|
||
echo " 1. Run: pnpm install (to update lockfile)"
|
||
echo " 2. Run: pnpm build (to verify)"
|
||
echo " 3. Verify no remaining 'theme-provider' references:"
|
||
echo " grep -r 'theme-provider' --include='*.ts' --include='*.tsx'"
|
||
echo ""
|
||
}
|
||
|
||
main "$@"
|