chore: Clean up variable replacement paths

This commit is contained in:
Dries Augustyns
2026-01-11 08:37:01 +01:00
parent c07816c2a1
commit d57f6c81cb
2 changed files with 39 additions and 38 deletions
+28 -6
View File
@@ -26,10 +26,23 @@ PLACEHOLDER_WIKI="https://next-wiki.useplunk.com"
MANIFEST_FILE="$APP_DIR/.next/url-manifest.txt"
# Find all files that contain placeholder URLs and save to manifest
# Search in .next directory for relevant file types
find "$APP_DIR/.next" -type f \( -name "*.js" -o -name "*.json" -o -name "*.html" -o -name "*.rsc" \) \
-exec grep -l -E "$PLACEHOLDER_API|$PLACEHOLDER_DASHBOARD|$PLACEHOLDER_LANDING|$PLACEHOLDER_WIKI" {} \; \
2>/dev/null > "$MANIFEST_FILE" || true
# IMPORTANT: Only scan the standalone directory, not the entire .next directory
# This avoids including server-only files that won't exist in the runtime container
STANDALONE_DIR="$APP_DIR/.next/standalone/apps/$APP_NAME"
if [ -d "$STANDALONE_DIR" ]; then
# Search in standalone directory for files that will be deployed
# Store paths RELATIVE to the standalone directory for easier runtime processing
find "$STANDALONE_DIR/.next" -type f \( -name "*.js" -o -name "*.json" -o -name "*.html" -o -name "*.rsc" \) \
-exec grep -l -E "$PLACEHOLDER_API|$PLACEHOLDER_DASHBOARD|$PLACEHOLDER_LANDING|$PLACEHOLDER_WIKI" {} \; \
2>/dev/null | sed "s|$STANDALONE_DIR/||g" > "$MANIFEST_FILE" || true
else
echo "⚠️ Warning: Standalone directory not found at $STANDALONE_DIR"
echo " Falling back to scanning entire .next directory"
find "$APP_DIR/.next" -type f \( -name "*.js" -o -name "*.json" -o -name "*.html" -o -name "*.rsc" \) \
-exec grep -l -E "$PLACEHOLDER_API|$PLACEHOLDER_DASHBOARD|$PLACEHOLDER_LANDING|$PLACEHOLDER_WIKI" {} \; \
2>/dev/null > "$MANIFEST_FILE" || true
fi
# Count files
FILE_COUNT=$(wc -l < "$MANIFEST_FILE" | tr -d ' ')
@@ -37,9 +50,18 @@ FILE_COUNT=$(wc -l < "$MANIFEST_FILE" | tr -d ' ')
echo "✅ Generated manifest for $APP_NAME: $FILE_COUNT files need URL replacement"
echo " Manifest saved to: $MANIFEST_FILE"
# Also generate manifest for sitemap/robots files
# Also generate manifest for sitemap/robots files in standalone public directory
SITEMAP_MANIFEST_FILE="$APP_DIR/.next/sitemap-manifest.txt"
find "$APP_DIR/public" -type f \( -name "sitemap*.xml" -o -name "robots.txt" \) 2>/dev/null > "$SITEMAP_MANIFEST_FILE" || true
if [ -d "$STANDALONE_DIR/public" ]; then
# Store paths RELATIVE to the standalone directory
find "$STANDALONE_DIR/public" -type f \( -name "sitemap*.xml" -o -name "robots.txt" \) \
2>/dev/null | sed "s|$STANDALONE_DIR/||g" > "$SITEMAP_MANIFEST_FILE" || true
else
# Fallback to app public directory
find "$APP_DIR/public" -type f \( -name "sitemap*.xml" -o -name "robots.txt" \) 2>/dev/null > "$SITEMAP_MANIFEST_FILE" || true
fi
SITEMAP_COUNT=$(wc -l < "$SITEMAP_MANIFEST_FILE" | tr -d ' ')
echo "✅ Generated sitemap manifest for $APP_NAME: $SITEMAP_COUNT files"