upd : build version

Deskripsi;
- build version otomatis

No Issues
This commit is contained in:
2025-09-03 16:49:40 +08:00
parent 1122e51047
commit 270001aa4f
4 changed files with 53 additions and 6 deletions

38
bump-version.js Normal file
View File

@@ -0,0 +1,38 @@
const fs = require("fs");
const path = require("path");
const configPath = path.join(__dirname, "app.config.js");
let configFile = fs.readFileSync(configPath, "utf8");
// --- Update versionCode ---
const codeRegex = /versionCode:\s*(\d+)/;
const codeMatch = configFile.match(codeRegex);
if (!codeMatch) {
console.error("❌ Tidak menemukan versionCode di app.config.js");
process.exit(1);
}
const currentCode = parseInt(codeMatch[1], 10);
const newCode = currentCode + 1;
configFile = configFile.replace(codeRegex, `versionCode: ${newCode}`);
// --- Update versionName ---
const nameRegex = /version:\s*"(.*?)"/;
const nameMatch = configFile.match(nameRegex);
if (!nameMatch) {
console.error("❌ Tidak menemukan version di app.config.js");
process.exit(1);
}
let [major, minor, patch] = nameMatch[1].split(".").map(Number);
patch += 1; // bump patch version
const newName = `${major}.${minor}.${patch}`;
configFile = configFile.replace(nameRegex, `version: "${newName}"`);
// --- Simpan file ---
fs.writeFileSync(configPath, configFile, "utf8");
console.log(`✅ versionCode: ${currentCode}${newCode}`);
console.log(`✅ versionName: ${nameMatch[1]}${newName}`);