From abb924e84498fedf80dec2fec1b6526179ce2ca4 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Tue, 11 Oct 2022 16:39:25 +0200 Subject: [PATCH] Add linux support to maker and updater --- config.forge.js | 4 ++ package.json | 1 + src/client/assets/js/checkingUpdate.js | 6 +- src/server/updater.js | 59 +++++++++++----- yarn.lock | 93 +++++++++++++++++++++++++- 5 files changed, 144 insertions(+), 19 deletions(-) diff --git a/config.forge.js b/config.forge.js index 4d0ece5..dc29d8e 100644 --- a/config.forge.js +++ b/config.forge.js @@ -19,6 +19,10 @@ module.exports = { setupIcon: path.resolve(__dirname, 'icon.ico'), setupExe: `${pkg.name}-${pkg.version}-win32-x64.exe` } + }, + { + name: '@electron-forge/maker-zip', + platforms: ['linux'] } ], publishers: [ diff --git a/package.json b/package.json index 28e5dd2..653cf88 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "devDependencies": { "@electron-forge/cli": "^6.0.0-beta.65", "@electron-forge/maker-squirrel": "^6.0.0-beta.65", + "@electron-forge/maker-zip": "^6.0.0-beta.67", "@electron-forge/publisher-github": "^6.0.0-beta.65", "electron": "^20.1.0" }, diff --git a/src/client/assets/js/checkingUpdate.js b/src/client/assets/js/checkingUpdate.js index 728e75b..b1977f5 100644 --- a/src/client/assets/js/checkingUpdate.js +++ b/src/client/assets/js/checkingUpdate.js @@ -20,4 +20,8 @@ app.mount("#vue"); ipcRenderer.on("update-available", (event, arg) => { app.fullscreenText = "Mise à jour disponible, téléchargement..." -}); \ No newline at end of file +}); + +ipcRenderer.on("please-download-update", (event, args) => { + app.fullscreenText = `Veuillez télécharger la mise à jour en cliquant sur le lien suivant: ${args.url}` +}) \ No newline at end of file diff --git a/src/server/updater.js b/src/server/updater.js index de8e6fa..f33c289 100644 --- a/src/server/updater.js +++ b/src/server/updater.js @@ -1,4 +1,5 @@ const isDev = require('electron-is-dev') +const fetch = require('node-fetch').default const pkg = require('../../package.json') const server = 'https://update.electronjs.org' @@ -23,7 +24,6 @@ class Updater { return } this.logger.info(`production version ${this.app.getVersion()}`) - // TODO : replace dialog by automatic restart this.autoUpdater.on('update-downloaded', (_event, releaseNotes, releaseName) => { this.logger.info(`update downloaded ${releaseName}`) @@ -40,23 +40,48 @@ class Updater { } this.logger.info("Checking for update...") const feed = `${server}/${pkg.repository}/${process.platform}-${process.arch}/${this.app.getVersion()}` - this.autoUpdater.setFeedURL(feed) - this.autoUpdater.checkForUpdates() - this.autoUpdater.on('error', message => { - this.logger.error('There was a problem updating the application') - this.logger.error(message) - win.loadFile('src/client/login.html').then(() => { - showNotification("Une erreur est survenue lors de la vérification de la mise à jour", "Veuillez vérifier votre connexion internet et réessayer", "error") + if(process.platform != 'linux') { + this.autoUpdater.setFeedURL(feed) + this.autoUpdater.checkForUpdates() + this.autoUpdater.on('error', message => { + this.displayError(win, showNotification, message) }) - }) - - this.autoUpdater.on('update-available', () => { - this.logger.info("update available, downloading...") - win.webContents.send("update-available") - }) - this.autoUpdater.on("update-not-available", () => { - this.logger.info("update not available") - win.loadFile('src/client/login.html') + + this.autoUpdater.on('update-available', () => { + this.logger.info("update available, downloading...") + win.webContents.send("update-available") + }) + this.autoUpdater.on("update-not-available", () => { + this.logger.info("update not available") + win.loadFile('src/client/login.html') + }) + } else { + fetch(feed).then(response => { + if(response.status === 200) { + response.json().then(json => { + win.webContents.send("please-download-update", { url: json.url} ) + }) + } else { + if(response.status === 204) { + this.logger.info("update not available") + win.loadFile('src/client/login.html') + } else { + this.displayError(win, showNotification, "Server return " + response.status + " http code") + } + + } + }).catch(err => { + this.displayError(win, showNotification, err) + }) + } + + } + + displayError(win, showNotification, errorMessage) { + this.logger.error('There was a problem updating the application') + this.logger.error(errorMessage) + win.loadFile('src/client/login.html').then(() => { + showNotification("Une erreur est survenue lors de la vérification de la mise à jour", "Veuillez vérifier votre connexion internet et réessayer", "error") }) } diff --git a/yarn.lock b/yarn.lock index 2a8bf03..b592c28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18,6 +18,17 @@ ora "^5.0.0" pretty-ms "^7.0.0" +"@electron-forge/async-ora@6.0.0-beta.67": + version "6.0.0-beta.67" + resolved "https://registry.yarnpkg.com/@electron-forge/async-ora/-/async-ora-6.0.0-beta.67.tgz#c5740d19e4d836cb856ac4c0ca897acbdc11da83" + integrity sha512-pqQlxHRnECDAAQhi3U2JgSj60TBv3e3ZLvL9Wv+dIBVv64Oc2QTRrryO5Svd7w2J1t+enVwQue18IrVaYUjw0w== + dependencies: + chalk "^4.0.0" + debug "^4.3.1" + log-symbols "^4.0.0" + ora "^5.0.0" + pretty-ms "^7.0.0" + "@electron-forge/cli@^6.0.0-beta.65": version "6.0.0-beta.65" resolved "https://registry.yarnpkg.com/@electron-forge/cli/-/cli-6.0.0-beta.65.tgz#1a23546693a8ada6377c0a1672bac42633c289f2" @@ -151,6 +162,15 @@ fs-extra "^10.0.0" which "^2.0.2" +"@electron-forge/maker-base@6.0.0-beta.67": + version "6.0.0-beta.67" + resolved "https://registry.yarnpkg.com/@electron-forge/maker-base/-/maker-base-6.0.0-beta.67.tgz#4c7f5d8e8b3c0008b3de4218aac4daac83e40786" + integrity sha512-WYwY01zEUr1II5lXiaGmGDUZ12swB/MJBOE5JNtGnirh6y/0MlSWhQOjbZxmLG72MrKbnEjvyqOb/8+3Yk4hzg== + dependencies: + "@electron-forge/shared-types" "6.0.0-beta.67" + fs-extra "^10.0.0" + which "^2.0.2" + "@electron-forge/maker-squirrel@^6.0.0-beta.65": version "6.0.0-beta.65" resolved "https://registry.yarnpkg.com/@electron-forge/maker-squirrel/-/maker-squirrel-6.0.0-beta.65.tgz#84bbea588464d66b22aa7431104d5b396548583a" @@ -162,6 +182,16 @@ optionalDependencies: electron-winstaller "^5.0.0" +"@electron-forge/maker-zip@^6.0.0-beta.67": + version "6.0.0-beta.67" + resolved "https://registry.yarnpkg.com/@electron-forge/maker-zip/-/maker-zip-6.0.0-beta.67.tgz#812ab0572f7fb44203b7c833d8ede90aeb396a60" + integrity sha512-T5Zr3Ye+LGaBZlFd3EOv4kTSfEIvj62/RRMtx4xOCqCTeAdzMlR99q53JR43ghXG3FPWy5JlBVCmTutI96jOZA== + dependencies: + "@electron-forge/maker-base" "6.0.0-beta.67" + "@electron-forge/shared-types" "6.0.0-beta.67" + cross-zip "^4.0.0" + fs-extra "^10.0.0" + "@electron-forge/plugin-base@6.0.0-beta.65": version "6.0.0-beta.65" resolved "https://registry.yarnpkg.com/@electron-forge/plugin-base/-/plugin-base-6.0.0-beta.65.tgz#65f78a92970b6adb6fd94831ffefa402ecbd5ff0" @@ -202,6 +232,16 @@ electron-rebuild "^3.2.6" ora "^5.0.0" +"@electron-forge/shared-types@6.0.0-beta.67": + version "6.0.0-beta.67" + resolved "https://registry.yarnpkg.com/@electron-forge/shared-types/-/shared-types-6.0.0-beta.67.tgz#1fd01ceff4c4868892382f1dc73e5c0ea19c29e6" + integrity sha512-QzL0yINK2d98trUbhrJPnIKhhhQSKOoiUBG0GM44dR0pstdOexNMNdgWX2+48PHiDwiqosgQBB9b47uJCrPR0Q== + dependencies: + "@electron-forge/async-ora" "6.0.0-beta.67" + electron-packager "^16.0.0" + electron-rebuild "^3.2.6" + ora "^5.0.0" + "@electron-forge/template-base@6.0.0-beta.65": version "6.0.0-beta.65" resolved "https://registry.yarnpkg.com/@electron-forge/template-base/-/template-base-6.0.0-beta.65.tgz#64e926e2bc8b3b5f672df939690d60d47d4483d5" @@ -260,6 +300,22 @@ global-agent "^3.0.0" global-tunnel-ng "^2.7.1" +"@electron/get@^2.0.0": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@electron/get/-/get-2.0.1.tgz#d960dd4bdbeb44613af7c196231e376ef4c48a6f" + integrity sha512-8nmTGC/3/6IaEfeTcQwtJdjLA/L3sb0XQJUv9x3ZfM0pfmKvkSdelbT4pgF3dpCQOvSmJ97kYAvFltikVjfepA== + dependencies: + debug "^4.1.1" + env-paths "^2.2.0" + fs-extra "^8.1.0" + got "^11.8.5" + progress "^2.0.3" + semver "^6.2.0" + sumchecker "^3.0.1" + optionalDependencies: + global-agent "^3.0.0" + global-tunnel-ng "^2.7.1" + "@electron/universal@^1.2.1": version "1.2.1" resolved "https://registry.yarnpkg.com/@electron/universal/-/universal-1.2.1.tgz#3c2c4ff37063a4e9ab1e6ff57db0bc619bc82339" @@ -1125,6 +1181,11 @@ cross-spawn@^7.0.1: shebang-command "^2.0.0" which "^2.0.1" +cross-zip@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/cross-zip/-/cross-zip-4.0.0.tgz#c29bfb2c001659a6d480ae9596f3bee83b48a230" + integrity sha512-MEzGfZo0rqE10O/B+AEcCSJLZsrWuRUvmqJTqHNqBtALhaJc3E3ixLGLJNTRzEA2K34wbmOHC4fwYs9sVsdcCA== + csstype@^2.6.8: version "2.6.20" resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.20.tgz#9229c65ea0b260cf4d3d997cb06288e36a8d6dda" @@ -1368,6 +1429,31 @@ electron-packager@^15.4.0: semver "^7.1.3" yargs-parser "^20.0.0" +electron-packager@^16.0.0: + version "16.0.0" + resolved "https://registry.yarnpkg.com/electron-packager/-/electron-packager-16.0.0.tgz#2eb7f14114e06b545207496ef66b10c24b7c8ba1" + integrity sha512-7Ey4UUaHg3FYhA7ktsAvCWP8srp9+iPljGdeJBsNaZBakU6HWhvRC+Pc7LWXGCgAVIN5BQsUwR3xrCbFno91VA== + dependencies: + "@electron/get" "^2.0.0" + "@electron/universal" "^1.2.1" + asar "^3.1.0" + cross-spawn-windows-exe "^1.2.0" + debug "^4.0.1" + electron-notarize "^1.1.1" + electron-osx-sign "^0.5.0" + extract-zip "^2.0.0" + filenamify "^4.1.0" + fs-extra "^10.1.0" + galactus "^0.2.1" + get-package-info "^1.0.0" + junk "^3.1.0" + parse-author "^2.0.0" + plist "^3.0.0" + rcedit "^3.0.1" + resolve "^1.1.6" + semver "^7.1.3" + yargs-parser "^21.1.1" + electron-rebuild@^3.2.6: version "3.2.7" resolved "https://registry.yarnpkg.com/electron-rebuild/-/electron-rebuild-3.2.7.tgz#0f56c1cc99a6fec0a5b990532283c2a8c838c19b" @@ -1664,7 +1750,7 @@ fs-constants@^1.0.0: resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== -fs-extra@^10.0.0: +fs-extra@^10.0.0, fs-extra@^10.1.0: version "10.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== @@ -3876,6 +3962,11 @@ yargs-parser@^21.0.0: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35" integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg== +yargs-parser@^21.1.1: + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== + yargs@^17.0.1: version "17.5.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e"