feat(deploy): indexability guard and production SEO launch suite (MITHOME-127)
The staging noindex (MITHOME-116) hinges on a build variable; leaking it into production would silently drop the site from Google. deploy.sh now refuses to build production when NEXT_PUBLIC_DEPLOY_ENV=staging is set, and after every deploy runs scripts/check-indexability.sh, expecting an indexable production and a blocked staging (node tests cover both ways, stray noindex and unreachable endpoints; added to pre-deploy tests). A separate Playwright project, production-seo (npm run test:seo:production), checks robots.txt, that all 12 sitemap URLs are final/indexable with self canonicals and sitemap hreflangs, SSR content and links, the / -> /hu redirect and real 404s; host redirects are gated until the production domain is live. Verified on a production-mode build of a staging DB copy (5 passed) and failing as expected against staging. eslint now ignores generated test output (playwright-report, test-results, coverage), which broke the pre-deploy lint after local e2e runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
104756db7f
commit
dc7a777d9f
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
# MITHOME-127: indexelhetőségi őr — a telepített oldal robots.txt-je,
|
||||
# sitemapje és noindex-jelölése egyezik-e a környezet elvárásával.
|
||||
#
|
||||
# Használat: scripts/check-indexability.sh <base-url> <indexable|blocked>
|
||||
# indexable — production: nincs noindex, a robots.txt enged és a sitemapre
|
||||
# mutat, a sitemap nem üres
|
||||
# blocked — staging: noindex, mindent tiltó robots.txt, üres sitemap
|
||||
#
|
||||
# WHY: a staging tiltása a NEXT_PUBLIC_DEPLOY_ENV build-változón múlik
|
||||
# (MITHOME-116). Ha az éles build hibásan kapja meg, a Google csendben
|
||||
# kiveszi az oldalt a találatok közül — ezt a deploy azonnal jelezze.
|
||||
# Kilépési kód: 0 = egyezik, 1 = eltérés, 2 = hibás használat / elérhetetlen.
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
BASE_URL="${1:-}"
|
||||
EXPECT="${2:-}"
|
||||
if [ -z "$BASE_URL" ] || { [ "$EXPECT" != "indexable" ] && [ "$EXPECT" != "blocked" ]; }; then
|
||||
echo "Használat: $0 <base-url> <indexable|blocked>" >&2
|
||||
exit 2
|
||||
fi
|
||||
BASE_URL="${BASE_URL%/}"
|
||||
|
||||
fetch() {
|
||||
# -f: a 4xx/5xx válasz (pl. hiányzó robots.txt) is hiba, nem üres tartalom.
|
||||
curl -fsS --max-time 20 "$BASE_URL$1"
|
||||
}
|
||||
|
||||
ROBOTS="$(fetch /robots.txt)" || { echo "❌ robots.txt nem érhető el: $BASE_URL/robots.txt" >&2; exit 2; }
|
||||
SITEMAP="$(fetch /sitemap.xml)" || { echo "❌ sitemap.xml nem érhető el: $BASE_URL/sitemap.xml" >&2; exit 2; }
|
||||
HOME_HTML="$(fetch /hu)" || { echo "❌ A főoldal nem érhető el: $BASE_URL/hu" >&2; exit 2; }
|
||||
|
||||
has_disallow_all=0
|
||||
printf '%s\n' "$ROBOTS" | grep -qiE '^Disallow:[[:space:]]*/[[:space:]]*$' && has_disallow_all=1
|
||||
has_sitemap_ref=0
|
||||
printf '%s\n' "$ROBOTS" | grep -qi '^Sitemap:' && has_sitemap_ref=1
|
||||
has_noindex=0
|
||||
printf '%s' "$HOME_HTML" | grep -qiE '<meta[^>]*name="robots"[^>]*noindex' && has_noindex=1
|
||||
url_count="$(printf '%s' "$SITEMAP" | grep -o '<url>' | wc -l | tr -d ' ')"
|
||||
|
||||
errors=()
|
||||
if [ "$EXPECT" = "indexable" ]; then
|
||||
[ "$has_disallow_all" -eq 0 ] || errors+=("a robots.txt mindent tilt (Disallow: /)")
|
||||
[ "$has_sitemap_ref" -eq 1 ] || errors+=("a robots.txt nem hivatkozik a sitemapre")
|
||||
[ "$has_noindex" -eq 0 ] || errors+=("a főoldalon noindex jelölés van")
|
||||
[ "$url_count" -gt 0 ] || errors+=("a sitemap üres")
|
||||
else
|
||||
[ "$has_disallow_all" -eq 1 ] || errors+=("a robots.txt nem tilt mindent")
|
||||
[ "$has_noindex" -eq 1 ] || errors+=("a főoldalon nincs noindex jelölés")
|
||||
[ "$url_count" -eq 0 ] || errors+=("a sitemap nem üres ($url_count URL)")
|
||||
fi
|
||||
|
||||
if [ "${#errors[@]}" -gt 0 ]; then
|
||||
echo "❌ Indexelhetőség nem az elvárt ($EXPECT) — $BASE_URL:" >&2
|
||||
printf ' - %s\n' "${errors[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Indexelhetőség rendben ($EXPECT): $BASE_URL (sitemap: $url_count URL)"
|
||||
Reference in New Issue
Block a user