Files
CPLv4.0/incrementVersion.ts
ISA 9057490541 feat: Neue Versionierungsstrategie mit Build- und Hotfix-Postfix eingeführt
- Versionierung auf das Muster `vX.Y.Z` für Builds und `vX.Y.Z.N` für Hotfixes umgestellt.
- `Z` wird nun bei jedem Commit als Build-Nummer erhöht, um Änderungen nachzuvollziehen.
- `N` wird als Patch-Postfix für Bugfixes in bestehenden Versionen genutzt (`vX.Y.Z.1`, `vX.Y.Z.2` usw.).
- Erleichtert Wartung und gezielte Fehlerbehebung für Kunden mit älteren Versionen.
- Verbesserte Struktur für langfristige Skalierbarkeit und Nachvollziehbarkeit.
2025-02-13 14:14:47 +01:00

53 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// /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);
}