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

@@ -6438,7 +6438,7 @@ async function stopTimer(token, entryId) {
}
// src/plugin.ts
var CURRENT_VERSION = "1.0.18";
var CURRENT_VERSION = "1.0.19";
var GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/master";
var SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
@@ -6474,9 +6474,10 @@ async function checkForUpdates(sendStatus) {
return;
}
sendStatus?.(`Updating to v${version}\u2026`);
const PLUGIN_BASE = `${GITEA_BASE}/com.pdma.notion-timer.sdPlugin`;
const [pluginResp, sigResp] = await Promise.all([
fetchWithTimeout2(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js`),
fetchWithTimeout2(`${GITEA_BASE}/com.pdma.notion-timer.sdPlugin/bin/plugin.js.sig`)
fetchWithTimeout2(`${PLUGIN_BASE}/bin/plugin.js`),
fetchWithTimeout2(`${PLUGIN_BASE}/bin/plugin.js.sig`)
]);
if (!pluginResp.ok || !sigResp.ok) {
sendStatus?.("Download failed");
@@ -6492,7 +6493,23 @@ async function checkForUpdates(sendStatus) {
return;
}
const fs3 = await import("fs");
const path5 = await import("path");
const pluginRoot = path5.join(path5.dirname(__filename), "..");
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) => fetchWithTimeout2(`${PLUGIN_BASE}/${p}`)));
fs3.writeFileSync(__filename, newCode);
for (let i = 0; i < ASSETS.length; i++) {
if (!assetResps[i].ok) {
plugin_default.logger.warn(`Asset download failed: ${ASSETS[i]}`);
continue;
}
fs3.writeFileSync(path5.join(pluginRoot, ASSETS[i]), Buffer.from(await assetResps[i].arrayBuffer()));
}
plugin_default.logger.info(`Updated to ${version}, restarting\u2026`);
process.exit(0);
} catch (err) {