Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-updates to Electron

I'm looking to deploy an auto-update feature to an Electron installation that I have, however I am finding it difficult to find any resources on the web.

I've built a self contained application using Adobe Air before and it seemed to be a lot easier writing update code that effectively checked a url and automatically downloaded and installed the update across Windows and MAC OSX.

I am currently using the electron-boilerplate for ease of build.

I have a few questions:

  • How do I debug the auto update feature? Do I setup a local connection and test through that using a local Node server or can I use any web server?
  • In terms of signing the application I am only looking to run apps on MAC OSX and particularly Windows. Do I have to sign the applications in order to run auto-updates? (I managed to do this with Adobe Air using a local certificate.
  • Are there any good resources that detail how to implement the auto-update feature? As I'm having difficulty finding some good documentation on how to do this.
like image 754
Neil Young Avatar asked Dec 07 '15 09:12

Neil Young


1 Answers

I am also new to Electron but I think there is no simple auto-update from electron-boilerplate (which I also use). Electron's auto-updater uses Squirrel.Windows installer which you also need to implement into your solution in order to use it.

I am currently trying to use this:

  • https://www.npmjs.com/package/electron-installer-squirrel-windows

And more info can be found here:

  • https://github.com/atom/electron/blob/master/docs/api/auto-updater.md
  • https://github.com/squirrel/squirrel.windows

EDIT: I just opened the project to try it for a while and it looks it works. Its pretty straightforward. These are pieces from my gulpfile.

In current configuration, I use electron-packager to create a package.

var packager = require('electron-packager')
var createPackage = function () {
    var deferred = Q.defer();


    packager({
        //OPTIONS
    }, function done(err, appPath) {
        if (err) {
            gulpUtil.log(err);
        }

        deferred.resolve();
    });

    return deferred.promise;
};

Then I create an installer with electron-installer-squirrel-windows.

var squirrelBuilder = require('electron-installer-squirrel-windows');
var createInstaller = function () {
    var deferred = Q.defer();

squirrelBuilder({
// OPTIONS
}, function (err) {
        if (err)
            gulpUtil.log(err);

        deferred.resolve();
    });

    return deferred.promise;
}

Also you need to add some code for the Squirrel to your electron background/main code. I used a template electron-squirrel-startup.

if(require('electron-squirrel-startup')) return;

The whole thing is described on the electron-installer-squirrel-windows npm documentation mentioned above. Looks like the bit of documentation is enough to make it start. Now I am working on with electron branding through Squirrel and with creating appropriate gulp scripts for automation.

like image 86
Josef Jura Avatar answered Oct 12 '22 14:10

Josef Jura