fix: création script Python séparé pour modification Navigation.tsx
- Script Python dans /tmp/add_team_link.py - Plus lisible et fiable que Python inline - Pas de problèmes d'échappement - Gestion d'erreurs avec sys.exit
This commit is contained in:
@@ -110,7 +110,38 @@ 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 -c "import re; f='.techradar/src/components/Navigation/Navigation.tsx'; c=open(f).read(); l=c.split('\n'); idx=-1; [[setattr(locals(),'idx',j+2) for j in range(i,min(i+10,len(l))) if '</Link>' in l[j] and j+1<len(l) and '</li>' in l[j+1]] for i,ln in enumerate(l) if 'href=\"/overview\"' in ln]; nl=l[:idx]+[' <li className={styles.item}>',' <Link href=\"/team\">',' <span className={styles.label}>👥 Équipe</span>',' </Link>',' </li>']+l[idx:] if idx>0 else l; open(f,'w').write('\n'.join(nl)) if idx>0 else None; print('✅ Modifié' if idx>0 else '❌ Échec')" && \
|
||||
cat > /tmp/add_team_link.py << 'PYEOF'
|
||||
import sys
|
||||
f = ".techradar/src/components/Navigation/Navigation.tsx"
|
||||
with open(f, 'r') as file:
|
||||
lines = file.readlines()
|
||||
|
||||
insert_idx = -1
|
||||
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]:
|
||||
insert_idx = j + 2
|
||||
break
|
||||
break
|
||||
|
||||
if insert_idx > 0:
|
||||
new_lines = lines[:insert_idx] + [
|
||||
' <li className={styles.item}>\n',
|
||||
' <Link href="/team">\n',
|
||||
' <span className={styles.label}>👥 Équipe</span>\n',
|
||||
' </Link>\n',
|
||||
' </li>\n'
|
||||
] + lines[insert_idx:]
|
||||
with open(f, 'w') as file:
|
||||
file.writelines(new_lines)
|
||||
print("✅ Navigation.tsx modifié")
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("❌ Impossible de trouver l'emplacement")
|
||||
sys.exit(1)
|
||||
PYEOF
|
||||
python3 /tmp/add_team_link.py && \
|
||||
grep -q 'href="/team"' .techradar/src/components/Navigation/Navigation.tsx && echo "✅ Lien Équipe ajouté" || (echo "❌ Lien Équipe non trouvé" && cat .techradar/src/components/Navigation/Navigation.tsx && exit 1); \
|
||||
else \
|
||||
echo "ℹ️ Lien Équipe déjà présent dans Navigation.tsx"; \
|
||||
|
||||
Reference in New Issue
Block a user