// @/scripts/bumpVersion.js const fs = require("fs"); const path = require("path"); // Pfade definieren const versionFilePath = path.join(__dirname, "../config/appVersion.js"); const packageJsonPath = path.join(__dirname, "../package.json"); // Aktuelle Version aus appVersion.js lesen let appVersionContent = fs.readFileSync(versionFilePath, "utf8"); const versionRegex = /export const APP_VERSION = "(\d+)\.(\d+)\.(\d+)"/; const match = appVersionContent.match(versionRegex); if (!match) { console.error("❌ Konnte APP_VERSION nicht finden!"); process.exit(1); } let [_, major, minor, patch] = match.map(Number); let newPatch = patch + 1; const newVersion = `${major}.${minor}.${newPatch}`; // 🟢 appVersion.js aktualisieren appVersionContent = appVersionContent.replace( versionRegex, `export const APP_VERSION = "${newVersion}"` ); fs.writeFileSync(versionFilePath, appVersionContent, "utf8"); // 🟢 package.json aktualisieren const pkgPath = path.resolve(packageJsonPath); const pkg = JSON.parse(fs.readFileSync(pkgPath)); pkg.version = newVersion; fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), "utf8"); // ✅ Log (optional bei DEBUG) if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { console.log(`✅ Version erhöht auf: ${newVersion}`); } const { execSync } = require("child_process"); try { execSync("npm install --package-lock-only", { stdio: "inherit" }); } catch (error) { console.error("❌ Fehler beim Aktualisieren der package-lock.json:", error); }