From 1aa3da8de58f2445a8526cb056a63bc44772c73e Mon Sep 17 00:00:00 2001 From: Daniel Allaire Date: Tue, 23 Jun 2026 21:28:52 -0400 Subject: [PATCH] Corriger l'erreur de syntaxe JS qui cassait tout le GUI dessinerServeurs contenait une apostrophe mal echappee (l\\'inventaire) qui, une fois rendue, terminait prematurement la chaine JS : une seule erreur de syntaxe fait tomber tout le script -> page inutilisable. Remplace par l'apostrophe typographique (sans echappement). Garde-fou : scripts/verifier_gui.py extrait le JS embarque et le passe a `node --check` (saute si node absent), integre a make inventaire-verifier. py_compile ne voyait pas le JS ; ce trou est desormais ferme. Co-Authored-By: Claude Opus 4.8 --- Makefile | 1 + scripts/inventory_gui.py | 2 +- scripts/verifier_gui.py | 44 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 scripts/verifier_gui.py diff --git a/Makefile b/Makefile index b839705..8251027 100644 --- a/Makefile +++ b/Makefile @@ -370,6 +370,7 @@ inventaire-verifier: ansible-runtime ansible-inventory -i $(INVENTAIRE_PRODUCTION) --list > /dev/null python3 scripts/inventory_host.py --inventaire $(INVENTAIRE_PRODUCTION) verifier-playbooks --dossier-playbooks $(DOSSIER_PLAYBOOKS_GROUPES) python3 scripts/inventory_host.py --inventaire $(INVENTAIRE_PRODUCTION) --dependances $(FICHIER_DEPENDANCES) verifier-dependances --dossier-playbooks $(DOSSIER_PLAYBOOKS_GROUPES) + python3 scripts/verifier_gui.py python3 scripts/serveurs.py verifier python3 scripts/applications.py verifier python3 scripts/bases_donnees.py verifier diff --git a/scripts/inventory_gui.py b/scripts/inventory_gui.py index f66c906..f703a32 100644 --- a/scripts/inventory_gui.py +++ b/scripts/inventory_gui.py @@ -1060,7 +1060,7 @@ HTML = r""" function dessinerServeurs() { const cible = document.getElementById('grilles'); - if (!serveurs.length) { cible.innerHTML = '
Aucun serveur dans le planLance « make serveurs-bootstrap » pour générer docs/serveurs.yml depuis l\\'inventaire.
'; return; } + if (!serveurs.length) { cible.innerHTML = '
Aucun serveur dans le planLance « make serveurs-bootstrap » pour générer docs/serveurs.yml depuis l’inventaire.
'; return; } const clsStatut = (s) => s === 'reconcilie' ? 'actif' : (s === 'divergence' ? 'bloque' : 'attente'); const libStatut = (s) => s === 'reconcilie' ? 'réconcilié' : (s === 'divergence' ? 'divergence' : 'absent inv.'); const lignes = serveurs.map(s => ` diff --git a/scripts/verifier_gui.py b/scripts/verifier_gui.py new file mode 100644 index 0000000..49254b1 --- /dev/null +++ b/scripts/verifier_gui.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""Verifie la syntaxe du JavaScript embarque dans inventory_gui.py. + +Garde-fou : py_compile ne voit pas le JS (il est dans une chaine Python). +Une seule erreur de syntaxe JS casse toute la page. On extrait le JS et on le +passe a `node --check`. Si node est absent, la verification est sautee (signale). +""" + +from __future__ import annotations + +import re +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +import inventory_gui as g # noqa: E402 + + +def main() -> int: + if not shutil.which("node"): + print("node absent : verification de la syntaxe JS du GUI sautee.") + return 0 + html = g.HTML.replace("__JETON__", "TEST") + blocs = re.findall(r"", html, re.S) + if not blocs: + print("erreur: aucun bloc