check-next-symlinks.sh 955 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. # Check that all .next/node_modules/ symlinks resolve correctly after assemble-prod.sh.
  3. # fslightbox-react is intentionally broken (useEffect-only import, never accessed during SSR).
  4. # Usage: bash apps/app/bin/check-next-symlinks.sh (from monorepo root)
  5. set -euo pipefail
  6. NEXT_MODULES="apps/app/.next/node_modules"
  7. broken=$(find "$NEXT_MODULES" -maxdepth 2 -type l | while read -r link; do
  8. linkdir=$(dirname "$link")
  9. target=$(readlink "$link")
  10. resolved=$(cd "$linkdir" 2>/dev/null && realpath -m "$target" 2>/dev/null || echo "UNRESOLVABLE")
  11. { [ "$resolved" = "UNRESOLVABLE" ] || [ ! -e "$resolved" ]; } && echo "BROKEN: $link"
  12. done | grep -v 'fslightbox-react' || true)
  13. if [ -n "$broken" ]; then
  14. echo "ERROR: Broken symlinks found in $NEXT_MODULES:"
  15. echo "$broken"
  16. echo "Move these packages from devDependencies to dependencies in apps/app/package.json."
  17. exit 1
  18. fi
  19. echo "OK: All $NEXT_MODULES symlinks resolve correctly."