#!/usr/bin/env node /** * Script pour incrémenter automatiquement le numéro de version patch * lors du déploiement Firebase Hosting */ const fs = require('fs'); const path = require('path'); const VERSION_FILE = path.join(__dirname, '../lib/config/app_version.dart'); function incrementVersion() { try { // Lire le fichier let content = fs.readFileSync(VERSION_FILE, 'utf8'); // Extraire la version actuelle const versionRegex = /static const String version = '(\d+)\.(\d+)\.(\d+)';/; const match = content.match(versionRegex); if (!match) { console.error('❌ Impossible de trouver la version dans le fichier'); process.exit(1); } const major = parseInt(match[1]); const minor = parseInt(match[2]); const patch = parseInt(match[3]); // Incrémenter le patch const newPatch = patch + 1; const newVersion = `${major}.${minor}.${newPatch}`; // Remplacer dans le fichier const newContent = content.replace( versionRegex, `static const String version = '${newVersion}';` ); // Écrire le fichier fs.writeFileSync(VERSION_FILE, newContent, 'utf8'); console.log(`✅ Version incrémentée: ${match[0].match(/\d+\.\d+\.\d+/)[0]} → ${newVersion}`); return newVersion; } catch (error) { console.error('❌ Erreur lors de l\'incrémentation:', error.message); process.exit(1); } } // Exécuter si appelé directement if (require.main === module) { incrementVersion(); } module.exports = { incrementVersion };