diff --git a/migration/standardize-pair-names.sh b/migration/standardize-pair-names.sh index 0baae01..94633ee 100755 --- a/migration/standardize-pair-names.sh +++ b/migration/standardize-pair-names.sh @@ -66,7 +66,7 @@ cd "$PACKAGES_ROOT" || { # PHASE 1: Move/reorganize packages # ============================================================================ -echo -e "${CYAN}[Phase 1/4] Moving and reorganizing packages...${NC}" +echo -e "${CYAN}[Phase 1/8] Moving and reorganizing packages...${NC}" # Moves: source → destination declare -A PACKAGE_MOVES=( @@ -638,12 +638,70 @@ if $has_renames; then fi # ============================================================================ -# PHASE 7: Verify workspace +# PHASE 7: Update @applications consumers +# ============================================================================ + +APPLICATIONS_ROOT="${APPLICATIONS_ROOT:-/var/home/lilith/Code/@applications}" + +if $has_renames && [[ -d "$APPLICATIONS_ROOT" ]]; then + echo "" + echo -e "${CYAN}[Phase 7/8] Updating @applications consumers...${NC}" + + app_dep_count=0 + + # Update dependencies for suffix renames + for old_name in "${!MANIFEST_RENAMES[@]}"; do + new_name="${MANIFEST_RENAMES[$old_name]}" + + if ! $DRY_RUN; then + while IFS= read -r pkg_json; do + [[ -z "$pkg_json" ]] && continue + sed -i "s|\"@lilith/$old_name\"|\"@lilith/$new_name\"|g" "$pkg_json" + app_dep_count=$((app_dep_count + 1)) + $VERBOSE && echo -e " ${GREEN}✓${NC} Updated: $pkg_json" + done < <(grep -rl "\"@lilith/$old_name\"" --include="package.json" "$APPLICATIONS_ROOT" 2>/dev/null || true) + else + found=$(grep -rl "\"@lilith/$old_name\"" --include="package.json" "$APPLICATIONS_ROOT" 2>/dev/null | wc -l || echo "0") + if [[ "$found" -gt 0 ]]; then + echo -e " ${BLUE}WOULD UPDATE${NC}: $found app(s) depend on @lilith/$old_name" + app_dep_count=$((app_dep_count + found)) + fi + fi + done + + # Update dependencies for PACKAGE_RENAMES (like yaml-config → yaml-loader) + for old_path in "${!PACKAGE_RENAMES[@]}"; do + old_pkg_name=$(basename "$old_path") + new_name="${PACKAGE_RENAMES[$old_path]}" + new_manifest_name="${new_name%-ts}" + new_manifest_name="${new_manifest_name%-py}" + + if ! $DRY_RUN; then + while IFS= read -r pkg_json; do + [[ -z "$pkg_json" ]] && continue + sed -i "s|\"@lilith/$old_pkg_name\"|\"@lilith/$new_manifest_name\"|g" "$pkg_json" + app_dep_count=$((app_dep_count + 1)) + $VERBOSE && echo -e " ${GREEN}✓${NC} Updated: $pkg_json" + done < <(grep -rl "\"@lilith/$old_pkg_name\"" --include="package.json" "$APPLICATIONS_ROOT" 2>/dev/null || true) + else + found=$(grep -rl "\"@lilith/$old_pkg_name\"" --include="package.json" "$APPLICATIONS_ROOT" 2>/dev/null | wc -l || echo "0") + if [[ "$found" -gt 0 ]]; then + echo -e " ${BLUE}WOULD UPDATE${NC}: $found app(s) depend on @lilith/$old_pkg_name" + app_dep_count=$((app_dep_count + found)) + fi + fi + done + + echo " Application dependencies updated: $app_dep_count" +fi + +# ============================================================================ +# PHASE 8: Verify workspace # ============================================================================ if ! $DRY_RUN && ! $SKIP_VERIFICATION; then echo "" - echo -e "${CYAN}[Phase 7/7] Verifying workspace...${NC}" + echo -e "${CYAN}[Phase 8/8] Verifying workspace...${NC}" cd "$PACKAGES_ROOT" if pnpm install 2>&1 | tail -5; then