fix: simplification modification Navigation.tsx avec sed + Python inline

- Utilisation de sed en premier (plus simple)
- Fallback avec Python en une seule ligne si sed échoue
- Pas de heredoc complexe qui cause des problèmes d'échappement
This commit is contained in:
syoul
2025-12-07 08:15:08 +01:00
parent 387b3f4806
commit 56f227e939

View File

@@ -110,50 +110,13 @@ RUN echo "✅ Page team.tsx créée"
# Modifier Navigation.tsx pour ajouter le lien Équipe
RUN if ! grep -q 'href="/team"' .techradar/src/components/Navigation/Navigation.tsx; then \
echo " Ajout du lien Équipe dans Navigation.tsx..." && \
python3 << 'PYTHON_EOF'
import re
nav_file = ".techradar/src/components/Navigation/Navigation.tsx"
with open(nav_file, 'r') as f:
content = f.read()
# Trouver la fin du lien Overview et insérer le nouveau lien avant le commentaire
pattern = r'(</Link>\s*</li>\s*)(\{/\*)'
replacement = r'\1 <li className={styles.item}>\n <Link href="/team">\n <span className={styles.label}>👥 Équipe</span>\n </Link>\n </li>\n \2'
new_content = re.sub(pattern, replacement, content)
if new_content != content:
with open(nav_file, 'w') as f:
f.write(new_content)
print("✅ Navigation.tsx modifié avec succès")
else:
print("⚠️ Pattern non trouvé, tentative alternative...")
# Alternative: insérer après la ligne avec </Link> de overview
lines = content.split('\n')
for i, line in enumerate(lines):
if 'href="/overview"' in line:
# Trouver la ligne </li> qui suit </Link>
for j in range(i, min(i+10, len(lines))):
if '</Link>' in lines[j] and j+1 < len(lines) and '</li>' in lines[j+1]:
# Insérer après </li>
new_lines = lines[:j+2] + [
' <li className={styles.item}>',
' <Link href="/team">',
' <span className={styles.label}>👥 Équipe</span>',
' </Link>',
' </li>'
] + lines[j+2:]
with open(nav_file, 'w') as f:
f.write('\n'.join(new_lines))
print("✅ Navigation.tsx modifié avec succès (méthode alternative)")
break
break
else:
print("❌ Impossible de modifier Navigation.tsx")
exit(1)
PYTHON_EOF
RUN grep -q 'href="/team"' .techradar/src/components/Navigation/Navigation.tsx && echo "✅ Lien Équipe ajouté" || (echo "❌ Lien Équipe non trouvé après modification" && cat .techradar/src/components/Navigation/Navigation.tsx && exit 1)
sed -i '/href="\/overview"/,/<\/Link>/ { /<\/Link>/a\ <li className={styles.item}>\ <Link href="/team">\ <span className={styles.label}>👥 Équipe</span>\ </Link>\ </li> }' .techradar/src/components/Navigation/Navigation.tsx && \
grep -q 'href="/team"' .techradar/src/components/Navigation/Navigation.tsx && echo "✅ Lien Équipe ajouté" || (echo "❌ Lien Équipe non trouvé après modification avec sed, tentative avec Python..." && \
python3 -c "import re; content = open('.techradar/src/components/Navigation/Navigation.tsx').read(); lines = content.split('\n'); insert_idx = -1; [setattr(locals(), 'insert_idx', j+2) or None for i, line in enumerate(lines) if 'href=\"/overview\"' in line for j in range(i, min(i+10, len(lines))) if '</Link>' in lines[j] and j+1 < len(lines) and '</li>' in lines[j+1]]; new_lines = lines[:insert_idx] + [' <li className={styles.item}>', ' <Link href=\"/team\">', ' <span className={styles.label}>👥 Équipe</span>', ' </Link>', ' </li>'] + lines[insert_idx:] if insert_idx > 0 else lines; open('.techradar/src/components/Navigation/Navigation.tsx', 'w').write('\n'.join(new_lines)) if insert_idx > 0 else None; print('✅ Navigation.tsx modifié' if insert_idx > 0 else '❌ Échec')" && \
grep -q 'href="/team"' .techradar/src/components/Navigation/Navigation.tsx && echo "✅ Lien Équipe ajouté avec Python" || (echo "❌ Lien Équipe toujours non trouvé" && cat .techradar/src/components/Navigation/Navigation.tsx && exit 1)); \
else \
echo " Lien Équipe déjà présent dans Navigation.tsx"; \
fi
# Builder l'application en mode production pour éviter Fast Refresh
# Utiliser WORKDIR pour changer de répertoire de manière fiable