Skip to content

Commit

Permalink
New electron-updater (#3084)
Browse files Browse the repository at this point in the history
  • Loading branch information
philrz authored Jun 12, 2024
1 parent 9c37575 commit a9af42a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 43 deletions.
2 changes: 1 addition & 1 deletion apps/insiders/src/insiders-packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class InsidersPackager {
const version =
this.strategy === 'match-stable'
? this.stableVersion
: semver.inc(this.lastVersion, 'prerelease');
: semver.inc(this.lastVersion, 'prerelease', 'insiders');

return version;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/zui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"electron-localshortcut": "^3.2.1",
"electron-log": "5.0.0-beta.6",
"electron-mock-ipc": "^0.3.12",
"electron-updater": "^4.3.8",
"electron-updater": "6.2.1",
"esbuild": "^0.18.14",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
27 changes: 9 additions & 18 deletions apps/zui/src/domain/updates/linux-updater.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import {app, shell} from "electron"
import fetch from "node-fetch"
import {autoUpdater} from "electron-updater"
import {Updater} from "./types"
import semver from "semver"
import {app, shell} from "electron"
import env from "src/app/core/env"
import links from "src/app/core/links"
import pkg from "src/electron/pkg"
import {Updater} from "./types"
import {getMainObject} from "src/core/main"

autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = false
autoUpdater.forceDevUpdateConfig = true

export class LinuxUpdater implements Updater {
async check() {
const latest = await this.latest()
const {updateInfo} = await autoUpdater.checkForUpdates()
const latest = updateInfo.version
const current = app.getVersion()
if (semver.lt(current, latest)) {
return latest
Expand All @@ -22,19 +26,6 @@ export class LinuxUpdater implements Updater {
shell.openExternal(this.downloadUrl())
}

private async latest() {
const resp = await fetch(this.latestUrl())
if (resp.status === 204) return app.getVersion()
const data = await resp.json()
return data.name
}

private latestUrl() {
const repo = getMainObject().appMeta.repo
const platform = "darwin-x64" // If the mac version exists, the linux does too
return `https://update.electronjs.org/${repo}/${platform}/${app.getVersion()}`
}

private downloadUrl() {
if (env.isInsiders) {
return pkg.repository + "/releases/latest"
Expand Down
1 change: 1 addition & 0 deletions apps/zui/src/domain/updates/mac-win-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {getMainObject} from "src/core/main"

autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = false
autoUpdater.forceDevUpdateConfig = true

export class MacWinUpdater implements Updater {
async check() {
Expand Down
51 changes: 28 additions & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5579,7 +5579,7 @@ __metadata:
languageName: node
linkType: hard

"@types/semver@npm:^7.3.3, @types/semver@npm:^7.3.4":
"@types/semver@npm:^7.3.3":
version: 7.3.4
resolution: "@types/semver@npm:7.3.4"
checksum: 577dc7f607fbf46cf185f61ba726e4cfecea41c4b17e55069e70a64b6cd92658f8286aa075a607303455658e87ed045d3d14c32a513c0eff381d64aecd7b72a7
Expand Down Expand Up @@ -7299,16 +7299,6 @@ __metadata:
languageName: node
linkType: hard

"builder-util-runtime@npm:8.7.3":
version: 8.7.3
resolution: "builder-util-runtime@npm:8.7.3"
dependencies:
debug: ^4.3.2
sax: ^1.2.4
checksum: eaf55ffcbde90a65639d7e102626ea819d0c0e4b296984755dab8d9df2bd85c56fb586e536a175b9229477d7e122c8f553aa232827aa7e275b43274b87a6e3e5
languageName: node
linkType: hard

"builder-util-runtime@npm:9.2.4":
version: 9.2.4
resolution: "builder-util-runtime@npm:9.2.4"
Expand Down Expand Up @@ -9219,18 +9209,19 @@ __metadata:
languageName: node
linkType: hard

"electron-updater@npm:^4.3.8":
version: 4.3.8
resolution: "electron-updater@npm:4.3.8"
"electron-updater@npm:6.2.1":
version: 6.2.1
resolution: "electron-updater@npm:6.2.1"
dependencies:
"@types/semver": ^7.3.4
builder-util-runtime: 8.7.3
fs-extra: ^9.1.0
js-yaml: ^4.0.0
lazy-val: ^1.0.4
builder-util-runtime: 9.2.4
fs-extra: ^10.1.0
js-yaml: ^4.1.0
lazy-val: ^1.0.5
lodash.escaperegexp: ^4.1.2
lodash.isequal: ^4.5.0
semver: ^7.3.4
checksum: 1814fe7c99eb6c1cb2251fc24eb62f51df716e44c891d5433e8e036a77ff2beec241249f7ba26b33a60cf134158c2160a74117dff7751b4d2e59c57e688ae17a
semver: ^7.3.8
tiny-typed-emitter: ^2.1.0
checksum: 92a064610a3c9df747dce9c3eccd69c48adb2c8b37b9d7c13d1c39f7e2a9ffaef4e909ab50e6973d557566bde6de7ec9c64e2cc3a2cdef18b3220c5d91333e1c
languageName: node
linkType: hard

Expand Down Expand Up @@ -13287,7 +13278,7 @@ __metadata:
languageName: node
linkType: hard

"js-yaml@npm:4.1.0, js-yaml@npm:^4.0.0, js-yaml@npm:^4.1.0":
"js-yaml@npm:4.1.0, js-yaml@npm:^4.1.0":
version: 4.1.0
resolution: "js-yaml@npm:4.1.0"
dependencies:
Expand Down Expand Up @@ -13759,6 +13750,13 @@ __metadata:
languageName: node
linkType: hard

"lodash.escaperegexp@npm:^4.1.2":
version: 4.1.2
resolution: "lodash.escaperegexp@npm:4.1.2"
checksum: 6d99452b1cfd6073175a9b741a9b09ece159eac463f86f02ea3bee2e2092923fce812c8d2bf446309cc52d1d61bf9af51c8118b0d7421388e6cead7bd3798f0f
languageName: node
linkType: hard

"lodash.isequal@npm:^4.5.0":
version: 4.5.0
resolution: "lodash.isequal@npm:4.5.0"
Expand Down Expand Up @@ -18197,6 +18195,13 @@ __metadata:
languageName: node
linkType: hard

"tiny-typed-emitter@npm:^2.1.0":
version: 2.1.0
resolution: "tiny-typed-emitter@npm:2.1.0"
checksum: 709bca410054e08df4dc29d5ea0916328bb2900d60245c6a743068ea223887d9fd2c945b6070eb20336275a557a36c2808e5c87d2ed4b60633458632be4a3e10
languageName: node
linkType: hard

"tiny-warning@npm:^1.0.0, tiny-warning@npm:^1.0.3":
version: 1.0.3
resolution: "tiny-warning@npm:1.0.3"
Expand Down Expand Up @@ -19701,7 +19706,7 @@ __metadata:
electron-localshortcut: ^3.2.1
electron-log: 5.0.0-beta.6
electron-mock-ipc: ^0.3.12
electron-updater: ^4.3.8
electron-updater: 6.2.1
esbuild: ^0.18.14
eslint: ^8.11.0
eslint-config-prettier: ^8.5.0
Expand Down

0 comments on commit a9af42a

Please sign in to comment.