-
-
Notifications
You must be signed in to change notification settings - Fork 94
Add auto-updater API to Electron server #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
16c233e
1920ff6
00ce033
1de495c
3b68c51
63326ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import express from "express"; | ||
import electronUpdater from "electron-updater"; | ||
import { notifyLaravel } from "../utils.js"; | ||
const router = express.Router(); | ||
const { autoUpdater } = electronUpdater; | ||
router.post("/check-for-updates", (req, res) => { | ||
autoUpdater.checkForUpdates(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idea: If you add a guard clause here you might be able to prevent the download from happening multiple times. Set a Boolean & make sure to reset it when the download finishes/fails There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's such a bad idea, but I don't know how reliably it will work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it def needs some manual testing. We can always add it later if we want. What do you think @SRWieZ ? |
||
res.sendStatus(200); | ||
}); | ||
router.post("/quit-and-install", (req, res) => { | ||
autoUpdater.quitAndInstall(); | ||
res.sendStatus(200); | ||
}); | ||
autoUpdater.addListener("checking-for-update", () => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\CheckingForUpdate`, | ||
}); | ||
}); | ||
autoUpdater.addListener("update-available", () => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateAvailable`, | ||
}); | ||
}); | ||
autoUpdater.addListener("update-not-available", () => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateNotAvailable`, | ||
}); | ||
}); | ||
autoUpdater.addListener("error", (error) => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\Error`, | ||
payload: { | ||
error: error, | ||
}, | ||
}); | ||
}); | ||
autoUpdater.addListener("update-downloaded", (event) => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateDownloaded`, | ||
payload: { | ||
version: event.version, | ||
downloadedFile: event.downloadedFile, | ||
releaseDate: event.releaseDate, | ||
releaseNotes: event.releaseNotes, | ||
releaseName: event.releaseName, | ||
}, | ||
}); | ||
}); | ||
export default router; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import express from "express"; | ||
import electronUpdater, { UpdateDownloadedEvent } from "electron-updater"; | ||
import { notifyLaravel } from "../utils.js"; | ||
|
||
const router = express.Router(); | ||
const { autoUpdater } = electronUpdater; | ||
Check failure on line 6 in resources/js/electron-plugin/src/server/api/autoUpdater.ts
|
||
|
||
router.post("/check-for-updates", (req, res) => { | ||
autoUpdater.checkForUpdates(); | ||
res.sendStatus(200); | ||
}); | ||
|
||
router.post("/quit-and-install", (req, res) => { | ||
autoUpdater.quitAndInstall(); | ||
res.sendStatus(200); | ||
}); | ||
|
||
autoUpdater.addListener("checking-for-update", () => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\CheckingForUpdate`, | ||
}); | ||
}); | ||
|
||
autoUpdater.addListener("update-available", () => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateAvailable`, | ||
}); | ||
}); | ||
|
||
autoUpdater.addListener("update-not-available", () => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateNotAvailable`, | ||
}); | ||
}); | ||
|
||
autoUpdater.addListener("error", (error) => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\Error`, | ||
payload: { | ||
error: error, | ||
}, | ||
}); | ||
}); | ||
|
||
autoUpdater.addListener("update-downloaded", (event: UpdateDownloadedEvent) => { | ||
notifyLaravel("events", { | ||
event: `\\Native\\Laravel\\Events\\AutoUpdater\\UpdateDownloaded`, | ||
payload: { | ||
version: event.version, | ||
downloadedFile: event.downloadedFile, | ||
releaseDate: event.releaseDate, | ||
releaseNotes: event.releaseNotes, | ||
releaseName: event.releaseName, | ||
}, | ||
}); | ||
}, | ||
); | ||
|
||
export default router; |
Uh oh!
There was an error while loading. Please reload this page.