Husky eingerichtet mit post-commit Hook für automatische Versionsanpassung
This commit is contained in:
33
scripts/bumpVersion.js
Normal file
33
scripts/bumpVersion.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
// Pfad zur appVersion.js
|
||||
const versionFilePath = path.join(__dirname, "../config/appVersion.js");
|
||||
|
||||
// Datei einlesen
|
||||
let content = fs.readFileSync(versionFilePath, "utf8");
|
||||
|
||||
// Version auslesen
|
||||
const versionRegex = /APP_VERSION = "(\d+)\.(\d+)\.(\d+)"/;
|
||||
const match = content.match(versionRegex);
|
||||
|
||||
if (!match) {
|
||||
console.error("Konnte Version nicht finden!");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let [fullMatch, major, minor, patch] = match.map(Number);
|
||||
|
||||
// Dritte Stelle (Patch) erhöhen
|
||||
patch++;
|
||||
|
||||
// Neue Version zusammenbauen
|
||||
const newVersion = `${major}.${minor}.${patch}`;
|
||||
|
||||
// Dateiinhalt ersetzen
|
||||
const newContent = content.replace(versionRegex, `APP_VERSION = "${newVersion}"`);
|
||||
|
||||
// Datei speichern
|
||||
fs.writeFileSync(versionFilePath, newContent, "utf8");
|
||||
|
||||
console.log(`✅ Version erhöht auf: ${newVersion}`);
|
||||
Reference in New Issue
Block a user