// /incrementVersion.ts const fs = require("fs"); const path = require("path"); const versionFilePath = path.join(process.cwd(), "config/webVersion.ts"); // Falls die Datei nicht existiert, erstelle eine Standardversion if (!fs.existsSync(versionFilePath)) { fs.writeFileSync( versionFilePath, `export const WEB_VERSION = "1.0.0.0";\n`, "utf8" ); } const versionFile = fs.readFileSync(versionFilePath, "utf8"); // Regex, um Versionsnummer zu finden (vX.Y.Z oder vX.Y.Z.N) const versionRegex = /(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?/; const match = versionFile.match(versionRegex); if (match) { let [major, minor, patch, build] = match .slice(1) .map((num) => (num !== undefined ? Number(num) : 0)); const isHotfix = process.env.HOTFIX_MODE === "true"; // Umgebungsvariable für Hotfixes if (isHotfix) { build++; // Falls ein Hotfix gemacht wird, nur `N` erhöhen (vX.Y.Z.N) console.log( `🔧 Hotfix-Modus aktiv – Erhöhe Patch-Fix auf: ${major}.${minor}.${patch}.${build}` ); } else { patch++; // Normale Builds erhöhen `Z` build = 0; // Falls es kein Hotfix ist, beginnt `N` wieder bei 0 console.log( `📦 Normale Build-Erhöhung – Neue Version: ${major}.${minor}.${patch}` ); } const newVersion = isHotfix ? `${major}.${minor}.${patch}.${build}` : `${major}.${minor}.${patch}`; const updatedFile = versionFile.replace(versionRegex, newVersion); fs.writeFileSync(versionFilePath, updatedFile, "utf8"); console.log(`✅ Webversion aktualisiert auf: ${newVersion}`); } else { console.error("❌ Konnte die Version nicht finden!"); process.exit(1); }