Add auto-updater checking Gitea on startup

This commit is contained in:
pdmarf
2026-04-10 19:52:50 +01:00
parent bc383e4fd8
commit 9c55f8a8b8
4 changed files with 6599 additions and 1 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
node_modules/ node_modules/
.DS_Store .DS_Store
*.streamDeckPlugin *.streamDeckPlugin
com.pdma.notion-timer.sdPlugin/bin/plugin.js

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,26 @@
const CURRENT_VERSION = "1.0.1";
const GITEA_BASE = "http://100.120.125.113:3000/pdm/stream_deck_notion_timer/raw/branch/master";
async function checkForUpdates(): Promise<void> {
try {
const resp = await fetch(`${GITEA_BASE}/version.json`);
if (!resp.ok) return;
const { version } = await resp.json() as { version: string };
if (version === CURRENT_VERSION) return;
const pluginResp = await fetch(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`);
if (!pluginResp.ok) return;
const newCode = await pluginResp.text();
const fs = await import("fs");
fs.writeFileSync(__filename, newCode);
streamDeck.logger.info(`Updated to ${version}, restarting…`);
process.exit(0);
} catch {
// Silently ignore — don't disrupt normal operation if update check fails
}
}
import streamDeck, { import streamDeck, {
action, action,
KeyDownEvent, KeyDownEvent,
@@ -143,3 +166,6 @@ streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings }>(async
}); });
streamDeck.connect(); streamDeck.connect();
// Check for updates 10 seconds after startup to avoid disrupting initial connection
setTimeout(() => checkForUpdates(), 10_000);

1
version.json Normal file
View File

@@ -0,0 +1 @@
{ "version": "1.0.1" }