v1.0.19: auto-updater now replaces UI and image assets

Previously only plugin.js was replaced on auto-update, leaving
property-inspector.html, idle.png, and running.png at the originally
installed version. Staff would see the old button colours and missing
UI elements (username dropdown, Update button) even after the code
updated successfully.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
pdmarf
2026-04-23 20:02:14 +01:00
parent 8d63a6c7c4
commit 3632300d08
5 changed files with 45 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
const CURRENT_VERSION = "1.0.18";
const CURRENT_VERSION = "1.0.19";
const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/master";
const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
@@ -35,9 +35,10 @@ async function checkForUpdates(sendStatus?: (msg: string) => void): Promise<void
}
sendStatus?.(`Updating to v${version}`);
const PLUGIN_BASE = `${GITEA_BASE}/com.pdma.notion-timer.sdPlugin`;
const [pluginResp, sigResp] = await Promise.all([
fetchWithTimeout(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`),
fetchWithTimeout(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig`),
fetchWithTimeout(`${PLUGIN_BASE}/bin/plugin.js`),
fetchWithTimeout(`${PLUGIN_BASE}/bin/plugin.js.sig`),
]);
if (!pluginResp.ok || !sigResp.ok) { sendStatus?.("Download failed"); return; }
@@ -53,7 +54,25 @@ async function checkForUpdates(sendStatus?: (msg: string) => void): Promise<void
}
const fs = await import("fs");
const path = await import("path");
const pluginRoot = path.join(path.dirname(__filename), "..");
// Also update UI and image assets. These are not separately signed — they run in a browser
// sandbox (not Node), and are fetched over HTTPS from the same trusted server.
const ASSETS = [
"ui/property-inspector.html",
"ui/global-property-inspector.html",
"imgs/idle.png",
"imgs/running.png",
];
const assetResps = await Promise.all(ASSETS.map(p => fetchWithTimeout(`${PLUGIN_BASE}/${p}`)));
fs.writeFileSync(__filename, newCode);
for (let i = 0; i < ASSETS.length; i++) {
if (!assetResps[i].ok) { streamDeck.logger.warn(`Asset download failed: ${ASSETS[i]}`); continue; }
fs.writeFileSync(path.join(pluginRoot, ASSETS[i]), Buffer.from(await assetResps[i].arrayBuffer()));
}
streamDeck.logger.info(`Updated to ${version}, restarting…`);
process.exit(0);
} catch (err) {