chore: zentrale Versionsverwaltung verbessert und appVersion.js entfernt
- Versionsnummer wird nun automatisch in package.json, package-lock.json, .env.development und .env.production aktualisiert - appVersion.js entfernt, da die Version nun direkt über process.env.NEXT_PUBLIC_APP_VERSION verwendet wird - bumpVersion-Skript aktualisiert und vereinfacht - Vorbereitungen für klarere Versionshistorie und Releases
This commit is contained in:
@@ -1,46 +1,45 @@
|
||||
// @/scripts/bumpVersion.js
|
||||
// /scripts/bumpVersion.js
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { execSync } = require("child_process");
|
||||
|
||||
// Pfade definieren
|
||||
const versionFilePath = path.join(__dirname, "../config/appVersion.js");
|
||||
const packageJsonPath = path.join(__dirname, "../package.json");
|
||||
const envPaths = [
|
||||
path.join(__dirname, "../.env.development"),
|
||||
path.join(__dirname, "../.env.production"),
|
||||
];
|
||||
const pkgPath = 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");
|
||||
// 🟢 Versionsnummer aus package.json holen
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
||||
const [major, minor, patch] = pkg.version.split(".").map(Number);
|
||||
const newVersion = `${major}.${minor}.${patch + 1}`;
|
||||
|
||||
// 🟢 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");
|
||||
// 🟢 .env Dateien aktualisieren
|
||||
envPaths.forEach(envFile => {
|
||||
if (!fs.existsSync(envFile)) return;
|
||||
|
||||
let content = fs.readFileSync(envFile, "utf8");
|
||||
const versionRegex = /^NEXT_PUBLIC_APP_VERSION=.*$/m;
|
||||
|
||||
if (versionRegex.test(content)) {
|
||||
content = content.replace(versionRegex, `NEXT_PUBLIC_APP_VERSION=${newVersion}`);
|
||||
} else {
|
||||
content += `\nNEXT_PUBLIC_APP_VERSION=${newVersion}`;
|
||||
}
|
||||
|
||||
fs.writeFileSync(envFile, content, "utf8");
|
||||
});
|
||||
|
||||
// 🟢 package-lock.json aktualisieren
|
||||
try {
|
||||
execSync("npm install --package-lock-only", { stdio: "inherit" });
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler beim Aktualisieren der package-lock.json:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`✅ Version erhöht auf ${newVersion}`);
|
||||
|
||||
Reference in New Issue
Block a user