Add auto-updater checking Gitea on startup
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
node_modules/
|
||||
.DS_Store
|
||||
*.streamDeckPlugin
|
||||
com.pdma.notion-timer.sdPlugin/bin/plugin.js
|
||||
|
||||
6572
com.pdma.notion-timer.sdPlugin/bin/plugin.js
Normal file
6572
com.pdma.notion-timer.sdPlugin/bin/plugin.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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, {
|
||||
action,
|
||||
KeyDownEvent,
|
||||
@@ -143,3 +166,6 @@ streamDeck.ui.onSendToPlugin<{ event: string; settings?: TimerSettings }>(async
|
||||
});
|
||||
|
||||
streamDeck.connect();
|
||||
|
||||
// Check for updates 10 seconds after startup to avoid disrupting initial connection
|
||||
setTimeout(() => checkForUpdates(), 10_000);
|
||||
|
||||
1
version.json
Normal file
1
version.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "version": "1.0.1" }
|
||||
Reference in New Issue
Block a user