refactor(version): read LOCAL_VERSION from package.json dynamically

This commit is contained in:
xenos
2025-11-29 00:06:55 +01:00
parent d1a64774da
commit 91333c1a3e
+12 -4
View File
@@ -8,10 +8,6 @@ import readline from "readline";
import https from "https"; import https from "https";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
// Version info
const LOCAL_VERSION = "2.0.8";
const GITHUB_REPO = "xenos1337/httptoolkit-patcher";
const isWin = process.platform === "win32"; const isWin = process.platform === "win32";
const isMac = process.platform === "darwin"; const isMac = process.platform === "darwin";
const isLinux = process.platform === "linux"; const isLinux = process.platform === "linux";
@@ -27,6 +23,18 @@ const __filename = (() => {
return fileURLToPath(import.meta.url); return fileURLToPath(import.meta.url);
})(); })();
// Version info - read from package.json
const GITHUB_REPO = "xenos1337/httptoolkit-patcher";
const LOCAL_VERSION = (() => {
try {
const packageJsonPath = path.join(path.dirname(__filename), "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
return packageJson.version || "0.0.0";
} catch {
return "0.0.0";
}
})();
// Check if running with elevated privileges // Check if running with elevated privileges
function isElevated() { function isElevated() {
if (isWin) { if (isWin) {