husky install for version increment

This commit is contained in:
Ismail Ali
2025-02-10 19:13:31 +01:00
parent da75c99197
commit 5f3f9bbe8d
4 changed files with 37 additions and 8 deletions

24
incrementVersion.ts Normal file
View File

@@ -0,0 +1,24 @@
// /incrementVersion.ts
import fs from "fs";
import path from "path";
const filePath = path.join(__dirname, "../config/webVersion.ts");
const fileContent = fs.readFileSync(filePath, "utf8");
const versionRegex = /const webVersion = "(\d+)\.(\d+)\.(\d+)\.(\d+)";/;
const match = fileContent.match(versionRegex);
if (!match) {
console.error("Version format not found!");
process.exit(1);
}
const [_, major, minor, build, patch] = match;
const newVersion = `${major}.${minor}.${build}.${parseInt(patch, 10) + 1}`;
const updatedContent = fileContent.replace(
versionRegex,
`const webVersion = "${newVersion}";`
);
fs.writeFileSync(filePath, updatedContent, "utf8");
console.log(`Version updated to ${newVersion}`);