const fs = require('fs'); const path = require('path'); const { execSync } = require('child_process'); const SITE_DIR = path.resolve(__dirname, '..'); const ACTUAL_DIR = path.resolve(SITE_DIR, '../Actual_Website'); const OLD_VER = '0.3.5'; const NEW_VER = '0.4.0'; const OLD_HASH = '6B2935E732A35175D01F586D7D8578DF63FB445444460464039FEBC7EA841CCA'; const NEW_HASH = 'FB2AF27C5509D220E18BD40219192D137368203A11D9B789BF5E1DA6C50B70F6'; console.log(`[DEPLOY-v0.4.0] Updating _Site to v${NEW_VER}...`); // 1. gws/index.html const gwsPath = path.join(SITE_DIR, 'gws/index.html'); let gwsContent = fs.readFileSync(gwsPath, 'utf8'); gwsContent = gwsContent.replaceAll(OLD_VER, NEW_VER); gwsContent = gwsContent.replaceAll(OLD_HASH, NEW_HASH); // Add v0.4.0 changelog in gws/index.html if not present const gwsTimelineMarker = '
'; const gwsV040Entry = `
Dernière version

Version 0.4.0 · Format .gws & Écosystème Connecté

23 septembre 2026

Introduction du système de mise à jour instantanée par paquets .gws, cartographie épurée avec infobulles compactes, guide interactif au premier lancement et nouveau hub officiel.

  • Mises à jour instantanées (.gws) : Déploiement et association de fichier native pour les paquets .gws. Installation par simple glisser-déposer dans l'interface sans relancer d'installeur Windows ni déclencher de faux positifs SmartScreen. Permutation atomique et vérification SHA-256.
  • Cartographie haute lisibilité : Refonte complète des infobulles au survol des sites (affichage compact nom, classification thermique et taille de dépression). Épuration du bandeau textuel et suppression du bouton "+ Point" (création directe par clic droit ou appui long).
  • Prise en main express : Nouveau guide de démarrage rapide au premier lancement pour accompagner la prise en main de l'interface Studio (accessible à tout moment depuis les Paramètres).
  • Hub officiel & Guide Defender : Déploiement du sas de téléchargement sur gastinel.me/gws/ avec contrôle d'intégrité en un clic et explications pédagogiques sur les certificats indépendants.
`; if (!gwsContent.includes('Version 0.4.0')) { gwsContent = gwsContent.replace(gwsTimelineMarker, gwsV040Entry); // remove 'current' class from old 0.3.5 entry gwsContent = gwsContent.replace('
', '
'); gwsContent = gwsContent.replace('Dernière version', 'Version précédente'); } fs.writeFileSync(gwsPath, gwsContent, 'utf8'); console.log('✓ gws/index.html updated to v0.4.0'); // 2. index.html const indexPath = path.join(SITE_DIR, 'index.html'); let indexContent = fs.readFileSync(indexPath, 'utf8'); indexContent = indexContent.replaceAll(OLD_VER, NEW_VER); indexContent = indexContent.replaceAll(OLD_HASH, NEW_HASH); // Add v0.4.0 in SPA section changelog const spaTimelineMarker = '
'; if (!indexContent.includes('Version 0.4.0 · Format .gws')) { indexContent = indexContent.replace(spaTimelineMarker, gwsV040Entry); indexContent = indexContent.replace('
', '
'); indexContent = indexContent.replace('Dernière version', 'Version précédente'); } fs.writeFileSync(indexPath, indexContent, 'utf8'); console.log('✓ index.html updated to v0.4.0'); // 3. Update test-verify.js const testVerifyPath = path.join(SITE_DIR, 'tools/test-verify.js'); let testContent = fs.readFileSync(testVerifyPath, 'utf8'); testContent = testContent.replaceAll(OLD_VER, NEW_VER); testContent = testContent.replaceAll(OLD_HASH, NEW_HASH); fs.writeFileSync(testVerifyPath, testContent, 'utf8'); console.log('✓ tools/test-verify.js updated to v0.4.0'); // 4. Synchronize Actual_Website function copyDirSync(src, dest) { if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true }); const entries = fs.readdirSync(src, { withFileTypes: true }); for (const entry of entries) { const srcPath = path.join(src, entry.name); const destPath = path.join(dest, entry.name); if (entry.isDirectory()) { if (entry.name === '.git' || entry.name === 'node_modules') continue; copyDirSync(srcPath, destPath); } else { fs.copyFileSync(srcPath, destPath); } } } copyDirSync(path.join(SITE_DIR, 'gws'), path.join(ACTUAL_DIR, 'gws')); fs.copyFileSync(indexPath, path.join(ACTUAL_DIR, 'index.html')); fs.copyFileSync(path.join(SITE_DIR, 'sitemap.xml'), path.join(ACTUAL_DIR, 'sitemap.xml')); fs.copyFileSync(path.join(SITE_DIR, 'llms.txt'), path.join(ACTUAL_DIR, 'llms.txt')); console.log('✓ Synchronized with Actual_Website'); // 5. Precompress console.log('[DEPLOY-v0.4.0] Running precompression...'); execSync('node ' + path.join(SITE_DIR, 'tools/precompress.js'), { stdio: 'inherit', cwd: SITE_DIR }); // 6. Test verification console.log('[DEPLOY-v0.4.0] Running validation tests...'); execSync('node ' + path.join(SITE_DIR, 'tools/test-verify.js'), { stdio: 'inherit', cwd: SITE_DIR }); console.log('[DEPLOY-v0.4.0] All done successfully!');