feat: add wrapper version update checks for PyPI and npm

Check for newer wrapper versions on startup (once per process).
Python queries PyPI, JS queries npm registry. Respects
CLOAKBROWSER_AUTO_UPDATE=false and CLOAKBROWSER_DOWNLOAD_URL
(custom mirror mode skips external registry calls).

Includes unit tests for both languages covering: update detection,
env var gating, network error handling, and once-per-process guard.
This commit is contained in:
CloakHQ
2026-03-03 01:21:41 +01:00
parent 1ad2b8d3a9
commit d8960447a0
8 changed files with 245 additions and 5 deletions
+14
View File
@@ -6,6 +6,20 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
// Read wrapper version from package.json (single source of truth)
let WRAPPER_VERSION = "0.0.0";
try {
const _configDir = path.dirname(fileURLToPath(import.meta.url));
const _pkgPath = path.resolve(_configDir, "..", "package.json");
const _pkg = JSON.parse(fs.readFileSync(_pkgPath, "utf-8")) as { version: string };
WRAPPER_VERSION = _pkg.version;
} catch {
// Fallback — package.json not found (bundled or unusual layout).
// Wrapper update check will compare against 0.0.0 and always suggest updating.
}
export { WRAPPER_VERSION };
// ---------------------------------------------------------------------------
// Chromium version shipped with this release.