From e9427b45687eea7edf7057db8d01579dda0d1fbf Mon Sep 17 00:00:00 2001 From: WINBIGFOX Date: Tue, 13 May 2025 22:31:30 +0200 Subject: [PATCH 1/2] Add detailed update info and new autoUpdater routes Extended autoUpdater listeners to include detailed update info, improving event payloads with version, files, release details, and more. Added new `/download-update` route for initiating update downloads and enhanced error reporting with structured error properties. --- .../src/server/api/autoUpdater.ts | 59 +++++++++++++++++-- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/resources/js/electron-plugin/src/server/api/autoUpdater.ts b/resources/js/electron-plugin/src/server/api/autoUpdater.ts index d1d08fec..ed931548 100644 --- a/resources/js/electron-plugin/src/server/api/autoUpdater.ts +++ b/resources/js/electron-plugin/src/server/api/autoUpdater.ts @@ -1,6 +1,10 @@ import express from "express"; import { autoUpdater } from "electron-updater"; -import type { ProgressInfo, UpdateDownloadedEvent } from "electron-updater"; +import type { + ProgressInfo, + UpdateDownloadedEvent, + UpdateInfo, +} from "electron-updater"; import { notifyLaravel } from "../utils.js"; const router = express.Router(); @@ -10,6 +14,11 @@ router.post("/check-for-updates", (req, res) => { res.sendStatus(200); }); +router.post("/download-update", (req, res) => { + autoUpdater.downloadUpdate(); + res.sendStatus(200); +}); + router.post("/quit-and-install", (req, res) => { autoUpdater.quitAndInstall(); res.sendStatus(200); @@ -21,23 +30,43 @@ autoUpdater.addListener("checking-for-update", () => { }); }); -autoUpdater.addListener("update-available", () => { +autoUpdater.addListener("update-available", (event: UpdateInfo) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateAvailable`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, + releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, }); }); -autoUpdater.addListener("update-not-available", () => { +autoUpdater.addListener("update-not-available", (event: UpdateInfo) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateNotAvailable`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, + releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, }); }); -autoUpdater.addListener("error", (error) => { +autoUpdater.addListener("error", (error: Error) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\Error`, payload: { - error: error, + name: error.name, + message: error.message, + stack: error.stack, }, }); }); @@ -59,11 +88,29 @@ autoUpdater.addListener("update-downloaded", (event: UpdateDownloadedEvent) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateDownloaded`, payload: { - version: event.version, downloadedFile: event.downloadedFile, + version: event.version, + files: event.files, releaseDate: event.releaseDate, + releaseName: event.releaseName, releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, + }); +}); + +autoUpdater.addListener("update-cancelled", (event: UpdateInfo) => { + notifyLaravel("events", { + event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateCancelled`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, }, }); }); From accb39b413f24db2f88e9729f90c69bdc306139f Mon Sep 17 00:00:00 2001 From: WINBIGFOX Date: Tue, 13 May 2025 22:31:30 +0200 Subject: [PATCH 2/2] Add detailed update info and new autoUpdater routes Extended autoUpdater listeners to include detailed update info, improving event payloads with version, files, release details, and more. Added new `/download-update` route for initiating update downloads and enhanced error reporting with structured error properties. --- .../dist/server/api/autoUpdater.js | 49 +++++++++++++-- .../src/server/api/autoUpdater.ts | 59 +++++++++++++++++-- 2 files changed, 98 insertions(+), 10 deletions(-) diff --git a/resources/js/electron-plugin/dist/server/api/autoUpdater.js b/resources/js/electron-plugin/dist/server/api/autoUpdater.js index 60808cac..a622dd65 100644 --- a/resources/js/electron-plugin/dist/server/api/autoUpdater.js +++ b/resources/js/electron-plugin/dist/server/api/autoUpdater.js @@ -6,6 +6,10 @@ router.post("/check-for-updates", (req, res) => { autoUpdater.checkForUpdates(); res.sendStatus(200); }); +router.post("/download-update", (req, res) => { + autoUpdater.downloadUpdate(); + res.sendStatus(200); +}); router.post("/quit-and-install", (req, res) => { autoUpdater.quitAndInstall(); res.sendStatus(200); @@ -15,21 +19,41 @@ autoUpdater.addListener("checking-for-update", () => { event: `\\Native\\Laravel\\Events\\AutoUpdater\\CheckingForUpdate`, }); }); -autoUpdater.addListener("update-available", () => { +autoUpdater.addListener("update-available", (event) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateAvailable`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, + releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, }); }); -autoUpdater.addListener("update-not-available", () => { +autoUpdater.addListener("update-not-available", (event) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateNotAvailable`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, + releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, }); }); autoUpdater.addListener("error", (error) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\Error`, payload: { - error: error, + name: error.name, + message: error.message, + stack: error.stack, }, }); }); @@ -49,11 +73,28 @@ autoUpdater.addListener("update-downloaded", (event) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateDownloaded`, payload: { - version: event.version, downloadedFile: event.downloadedFile, + version: event.version, + files: event.files, releaseDate: event.releaseDate, + releaseName: event.releaseName, releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, + }); +}); +autoUpdater.addListener("update-cancelled", (event) => { + notifyLaravel("events", { + event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateCancelled`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, }, }); }); diff --git a/resources/js/electron-plugin/src/server/api/autoUpdater.ts b/resources/js/electron-plugin/src/server/api/autoUpdater.ts index d1d08fec..ed931548 100644 --- a/resources/js/electron-plugin/src/server/api/autoUpdater.ts +++ b/resources/js/electron-plugin/src/server/api/autoUpdater.ts @@ -1,6 +1,10 @@ import express from "express"; import { autoUpdater } from "electron-updater"; -import type { ProgressInfo, UpdateDownloadedEvent } from "electron-updater"; +import type { + ProgressInfo, + UpdateDownloadedEvent, + UpdateInfo, +} from "electron-updater"; import { notifyLaravel } from "../utils.js"; const router = express.Router(); @@ -10,6 +14,11 @@ router.post("/check-for-updates", (req, res) => { res.sendStatus(200); }); +router.post("/download-update", (req, res) => { + autoUpdater.downloadUpdate(); + res.sendStatus(200); +}); + router.post("/quit-and-install", (req, res) => { autoUpdater.quitAndInstall(); res.sendStatus(200); @@ -21,23 +30,43 @@ autoUpdater.addListener("checking-for-update", () => { }); }); -autoUpdater.addListener("update-available", () => { +autoUpdater.addListener("update-available", (event: UpdateInfo) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateAvailable`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, + releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, }); }); -autoUpdater.addListener("update-not-available", () => { +autoUpdater.addListener("update-not-available", (event: UpdateInfo) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateNotAvailable`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, + releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, }); }); -autoUpdater.addListener("error", (error) => { +autoUpdater.addListener("error", (error: Error) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\Error`, payload: { - error: error, + name: error.name, + message: error.message, + stack: error.stack, }, }); }); @@ -59,11 +88,29 @@ autoUpdater.addListener("update-downloaded", (event: UpdateDownloadedEvent) => { notifyLaravel("events", { event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateDownloaded`, payload: { - version: event.version, downloadedFile: event.downloadedFile, + version: event.version, + files: event.files, releaseDate: event.releaseDate, + releaseName: event.releaseName, releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, + }, + }); +}); + +autoUpdater.addListener("update-cancelled", (event: UpdateInfo) => { + notifyLaravel("events", { + event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateCancelled`, + payload: { + version: event.version, + files: event.files, + releaseDate: event.releaseDate, releaseName: event.releaseName, + releaseNotes: event.releaseNotes, + stagingPercentage: event.stagingPercentage, + minimumSystemVersion: event.minimumSystemVersion, }, }); });