Fichiers
site-principal/tools/test-verify.js
T
2026-10-11 01:57:33 +02:00

132 lignes
6.8 KiB
JavaScript

const fs = require('fs');
const path = require('path');
console.log('====================================================');
console.log(' TEST DE VALIDATION RIGOUREUX — REFONTE GWS & SITE');
console.log('====================================================\n');
let failures = 0;
function assert(desc, condition) {
if (condition) {
console.log(`✓ PASS: ${desc}`);
} else {
console.error(`✗ FAIL: ${desc}`);
failures++;
}
}
const siteDir = path.resolve(__dirname, '..');
const actualDir = path.resolve(siteDir, '../Actual_Website');
const indexHtml = fs.readFileSync(path.join(siteDir, 'index.html'), 'utf8');
const gwsHtml = fs.readFileSync(path.join(siteDir, 'gws/index.html'), 'utf8');
const downloadHtml = fs.readFileSync(path.join(siteDir, 'gws/download/index.html'), 'utf8');
const sitemapXml = fs.readFileSync(path.join(siteDir, 'sitemap.xml'), 'utf8');
// Emoji detector
const emojiRegex = /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}]/u;
// 1. Syntaxe JS & JSON-LD
console.log('[1] Contrôle syntaxique JS et JSON-LD...');
function validateScripts(html, filename) {
const scriptRegex = /<script(?:\s+[^>]*)?>([\s\S]*?)<\/script>/gi;
let match;
let scriptIdx = 0;
while ((match = scriptRegex.exec(html)) !== null) {
scriptIdx++;
const content = match[1].trim();
if (!content) continue;
if (content.startsWith('{') || content.startsWith('[')) {
try {
JSON.parse(content);
assert(`${filename} Script ${scriptIdx} (JSON-LD)`, true);
} catch (e) {
assert(`${filename} Script ${scriptIdx} (JSON-LD) - ${e.message}`, false);
}
} else {
try {
new Function(content);
assert(`${filename} Script ${scriptIdx} (JavaScript)`, true);
} catch (e) {
assert(`${filename} Script ${scriptIdx} (JavaScript) - ${e.message}`, false);
}
}
}
}
validateScripts(indexHtml, 'index.html');
validateScripts(gwsHtml, 'gws/index.html');
validateScripts(downloadHtml, 'gws/download/index.html');
// 2. Vérification Zéro Emoji & Zéro Clé Crypto dans toute l'interface
console.log('\n[2] Sobriété & Clarté (Zéro Emoji & Zéro Hash Crypto Lambda)...');
assert('Aucun emoji dans gws/index.html', !emojiRegex.test(gwsHtml));
assert('Aucun emoji dans gws/download/index.html', !emojiRegex.test(downloadHtml));
assert('Aucun emoji dans index.html', !emojiRegex.test(indexHtml));
assert('Aucun hash SHA-256 encombrant dans gws/index.html', !gwsHtml.includes('FB2AF27C5509D220E18BD40219192D137368203A11D9B789BF5E1DA6C50B70F6'));
assert('Aucun hash SHA-256 encombrant dans gws/download/index.html', !downloadHtml.includes('FB2AF27C5509D220E18BD40219192D137368203A11D9B789BF5E1DA6C50B70F6'));
assert('Aucun hash SHA-256 encombrant dans index.html', !indexHtml.includes('FB2AF27C5509D220E18BD40219192D137368203A11D9B789BF5E1DA6C50B70F6'));
// 3. Séparation Présentation vs Téléchargements
console.log('\n[3] Séparation Présentation (/gws/) vs Téléchargements (/gws/download/)...');
assert('Page Présentation : bouton CTA propre vers /gws/download/', gwsHtml.includes('https://gastinel.me/gws/download/'));
assert('Page Téléchargements : Hero v0.4.0 présent', downloadHtml.includes('v0.4.0'));
assert('Page Téléchargements : Téléchargement .exe présent', downloadHtml.includes('Gastinel_Weather_Studio_0.4.0_x64-setup.exe'));
assert('Page Téléchargements : Téléchargement .gws présent', downloadHtml.includes('update-0.4.0.gws'));
assert('Page Téléchargements : Explication claire entre les 2 paquets', downloadHtml.includes('première installation') && downloadHtml.includes('Mise à jour'));
assert('Page Téléchargements : Guide SmartScreen présent avec 3 étapes', downloadHtml.includes('Informations complémentaires') && downloadHtml.includes('Exécuter quand même'));
assert('Page Téléchargements : Changelog v0.4.0 présent', downloadHtml.includes('Version 0.4.0'));
assert('Page Téléchargements : Explication certificat et indépendance', downloadHtml.includes('indépendant') && downloadHtml.includes('Microsoft'));
// 4. Bandeau dans #apps
console.log('\n[4] Bandeau Gastinel Weather Studio dans #apps...');
assert('Bandeau GWS présent dans #apps', indexHtml.includes('id="app-weather-studio"'));
assert('Lien vers présentation dans le bandeau', indexHtml.includes('href="https://gastinel.me/gws/"'));
assert('Lien vers téléchargements dans le bandeau', indexHtml.includes('href="https://gastinel.me/gws/download/"'));
// 5. Robustesse Semver et API Live
console.log('\n[5] Robustesse Semver & API Live...');
assert('Semver compare présent dans index.html', indexHtml.includes('compareSemver'));
// 6. Fichiers et Assets statiques
console.log('\n[6] Vérification des assets physiques...');
const requiredAssets = [
'assets/apps/gastinel-weather-studio/icone.webp',
'assets/apps/gastinel-weather-studio/icon-512.png',
'assets/apps/gastinel-weather-studio/studio.webp',
'assets/apps/gastinel-weather-studio/accueil.webp',
'assets/apps/gastinel-weather-studio/logger.webp',
'assets/fonts/inter-latin.woff2',
'assets/fonts/comfortaa-latin.woff2'
];
for (const rel of requiredAssets) {
assert(`Asset ${rel} existe dans _Site`, fs.existsSync(path.join(siteDir, rel)));
}
// 7. Conformité Sitemap.xml
console.log('\n[7] Conformité Sitemap XML...');
assert('Sitemap XML contient gastinel.me/', sitemapXml.includes('<loc>https://gastinel.me/</loc>'));
assert('Sitemap XML contient gastinel.me/gws/', sitemapXml.includes('<loc>https://gastinel.me/gws/</loc>'));
assert('Sitemap XML contient gastinel.me/gws/download/', sitemapXml.includes('<loc>https://gastinel.me/gws/download/</loc>'));
assert('Sitemap XML ne contient aucun fragment # (interdit par Google)', !sitemapXml.includes('<loc>https://gastinel.me/#'));
// 8. Synchronisation avec Actual_Website
console.log('\n[8] Synchronisation _Site <-> Actual_Website...');
const actualIndex = fs.readFileSync(path.join(actualDir, 'index.html'), 'utf8');
const actualGws = fs.readFileSync(path.join(actualDir, 'gws/index.html'), 'utf8');
const actualDownload = fs.readFileSync(path.join(actualDir, 'gws/download/index.html'), 'utf8');
assert('index.html synchronisé à l\'octet près', actualIndex === indexHtml);
assert('gws/index.html synchronisé à l\'octet près', actualGws === gwsHtml);
assert('gws/download/index.html synchronisé à l\'octet près', actualDownload === downloadHtml);
console.log('====================================================');
if (failures === 0) {
console.log(' RÉSULTAT : 100% DES VÉRIFICATIONS RÉUSSIES !');
console.log('====================================================');
process.exit(0);
} else {
console.error(` RÉSULTAT : ${failures} ÉCHECS DÉTECTÉS !`);
console.log('====================================================');
process.exit(1);
}