
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
electron-basic-updater
Advanced tools
A NodeJs module for Electron, that handles the application updates, in the most basic way.
Well, right now I am working on an Electron application for me and my collegues to use at work, after finishing the application and giving them the .exe release I needed to change couple of things, so I asked myself: what to do now ?! I read this but for the life of me I couldn't get it to work :( (but to be fair, I didn't give it enough time, I wanted to create this instead :) ). So I decided to create a module to handle this, in the most basic way possible. So ...
$ npm install --save electron-basic-updater
Now, inside the main.js file, call it like this:
const Electron = require('electron');
const Application = Electron.app;
const EBU = require('electron-basic-updater');
Application.on('ready', function(){
// Initiate the module
EBU.init({
'api': 'http:// .... ' // The API EBU will talk to
});
});
That's it. Now, you can use EBU.check()
to trigger the update process; EBU will first check for updates, if there was a new update, EBU will download it and extract it to the application folder. Inside a window you can use it like this:
<script>
var remote = require('remote'),
app = remote.require('app'),
EBU = remote.require('electron-basic-updater');
function(){
EBU.check(function(error){
if(error){
alert(error);
return false;
}
alert('App updated successfully! Restart it please.');
app.quit();
});
}
</script>
Init( setup )
api (string) The URL EBU will call to check for updates.
logFile (string) [optional] The file to log the update process updates and errors to it, pass FALSE to omit logging . Defaults to "updater-log.txt".
requestOptions (object) [optional] The global options for the HTTP requests EBU will make to check for updates and download them. EBU uses the cool restler for these requests, and the requestOptions
will be used for all the requests (the full options list). You can use this option to pass an accessToken
or a username
and password
along with the request, or even send some extra data along with the request through the data
property.
EBU.init({
'api': 'http:// ...',
'requestOptions': {'accessToken': ..., 'data': {'group': 'friends'}}
});
callback (function) [optional] The callback that will be trigger at the end of the process, whether the update was a success or not. You can set the callback here, or you can pass it directly to check( ... )
, I use the later option, to be able to console.log()
the error in the DevTools.
EBU.init({
'callback': function(error){ ... }
});
check( callback )
Will check for an update, if an update was found, will download it and install it! As mentioned, this method must be tirggerd, EBU wont check for updates on its own.
And I mean this in the most simple way possible. This server/API will recieve one request, which is the check for updates, and will send one response of :
{"last": " [the new version] ", "source": " [the .zip file url] "}
EBU wont make any version comparsions, it will simply download the source
url and extract it. So, you will need to handle this on your side, EBU sends (POST-type request) you the client's current version (as current
), you can use this to send the correct update!My current update server (for the app I descriped above) is simple:
<?php
print json_encode([
'last' => '1.0.1',
'source' => 'http:// ... /update.zip'
]);
I change this manually and tell the guys to hit the "update" button, which will trigger .check()
The MIT License (MIT) - Copyright (c) 2015 Ahmed Zain tamkeenlms@gmail.com
FAQs
Handles Electron application updates, IN THE MOST BASIC WAY.
We found that electron-basic-updater demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.