@@ -1,4 +1,4 @@
|
||||
const CURRENT_VERSION = "1.0.17";
|
||||
const CURRENT_VERSION = "1.0.18";
|
||||
const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/master";
|
||||
const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
||||
@@ -6,11 +6,15 @@ MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
||||
|
||||
function isNewerVersion(remote: string, current: string): boolean {
|
||||
const parse = (v: string) => v.split(".").map(Number);
|
||||
const [rMaj, rMin, rPat] = parse(remote);
|
||||
const [cMaj, cMin, cPat] = parse(current);
|
||||
if (rMaj !== cMaj) return rMaj > cMaj;
|
||||
if (rMin !== cMin) return rMin > cMin;
|
||||
return rPat > cPat;
|
||||
const r = parse(remote);
|
||||
const c = parse(current);
|
||||
const len = Math.max(r.length, c.length);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const rv = r[i] ?? 0;
|
||||
const cv = c[i] ?? 0;
|
||||
if (rv !== cv) return rv > cv;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function fetchWithTimeout(url: string): Promise<Response> {
|
||||
@@ -24,7 +28,7 @@ async function checkForUpdates(sendStatus?: (msg: string) => void): Promise<void
|
||||
const resp = await fetchWithTimeout(`${GITEA_BASE}/version.json`);
|
||||
if (!resp.ok) { sendStatus?.("Update check failed"); return; }
|
||||
const { version } = await resp.json() as { version: string };
|
||||
if (!/^\d+\.\d+\.\d+$/.test(version)) return;
|
||||
if (!/^\d+(\.\d+)+$/.test(version)) return;
|
||||
if (!isNewerVersion(version, CURRENT_VERSION)) {
|
||||
sendStatus?.(`Already up to date (v${CURRENT_VERSION})`);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user