Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions resources/js/electron-plugin/dist/server/api/autoUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
},
});
});
Expand All @@ -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,
},
});
});
Expand Down
59 changes: 53 additions & 6 deletions resources/js/electron-plugin/src/server/api/autoUpdater.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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);
Expand All @@ -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,
},
});
});
Expand All @@ -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,
},
});
});
Expand Down
Loading