diff --git a/auto_updater.json b/auto_updater.json new file mode 100644 index 00000000..00aad445 --- /dev/null +++ b/auto_updater.json @@ -0,0 +1,3 @@ +{ + "url": "https://github.com/officert/mongotron/releases/download/1.0.0-alpha.1/Mongotron-darwin-x64.zip" +} diff --git a/package.json b/package.json index f1a7e046..787de668 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "bluebird": "3.0.6", "bson": "https://github.com/officert/js-bson/tarball/master", "csv": "0.4.6", + "electron-gh-releases": "2.0.2", "electron-packager": "5.2.1", "escodegen": "1.8.0", "esprima": "2.7.1", diff --git a/src/browser/main.js b/src/browser/main.js index 40d3068c..d7a58fd3 100644 --- a/src/browser/main.js +++ b/src/browser/main.js @@ -5,12 +5,39 @@ const BrowserWindow = require('browser-window'); const crashReporter = require('crash-reporter'); const ipcMain = require('electron').ipcMain; const path = require('path'); +const GhReleases = require('electron-gh-releases'); require('src/mongotron').init(); const appConfig = require('src/config/appConfig'); const logger = require('lib/modules/logger'); +let autoUpdateOptions = { + repo: 'officert/mongotron', + currentVersion: app.getVersion() +}; + +const updater = new GhReleases(autoUpdateOptions); + +// Check for updates +// `status` returns true if there is a new update available +updater.check((err, status) => { + console.log('updater check', err, status); + + if (!err && status) { + // Download the update + updater.download(); + } +}); + +// When an update has been downloaded +updater.on('update-downloaded', (info) => { + console.log('updater downloaded', info); + + // Restart the app and install the update + updater.install(); +}); + /* ------------------------------------------------ * App initialization * ------------------------------------------------ */