Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Frame() {
// Logging
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
autoUpdater.autoDownload = false;
autoUpdater.allowDowngrade = true;
autoUpdater.allowPrerelease = true;
log.info('App starting...');
win = null;
showNoUpdate = false;
tray = null;
quitting = false;
}
constructor({ app }) {
super();
this.app = app;
autoUpdater.logger = log;
autoUpdater.channel = 'beta';
autoUpdater.allowDowngrade = false;
autoUpdater.autoDownload = false;
autoUpdater.on('update-available', info => this.emit('update-available', info));
autoUpdater.on('download-progress', progress => this.emit('download-progress', progress));
autoUpdater.on('update-downloaded', info => this.emit('update-downloaded', info));
}
import { dialog } from 'electron'
import { autoUpdater } from 'electron-updater'
import isDev from 'electron-is-dev'
import { updaterLog } from '../utils/log'
autoUpdater.logger = updaterLog
/**
* Update Channel
* supported channels are 'alpha', 'beta' and 'latest'
* Refer electron-builder docs
*/
autoUpdater.channel = process.env.AUTOUPDATE_CHANNEL || 'beta'
autoUpdater.allowDowngrade = false
/**
* @class ZapController
*
* The ZapUpdater class manages the electron auto update process.
*/
class ZapUpdater {
/**
* Create a new ZapUpdater instance.
* @param {BrowserWindow} mainWindow BrowserWindow instance to interact with
*/
constructor(mainWindow) {
this.mainWindow = mainWindow
}
init() {
let upgrade = ver=>etask(function*(){
if (!can_upgrade)
{
let res = yield show_message({type: 'info', title: 'Luminati update',
message: (ver ? `Luminati version ${ver}` : 'Luminati update')
+' will be installed on exit',
buttons: ['Install on exit', 'Install now']});
if (!res)
return void console.log('Update postponed until exit');
}
console.log('Starting upgrade');
auto_updater.quitAndInstall();
});
auto_updater.allowDowngrade = true;
auto_updater.autoDownload = false;
auto_updater.on('error', ()=>{});
auto_updater.on('update-available', e=>etask(function*(){
const changelog_url = 'https://github.com/luminati-io/luminati-proxy/blob/'
+'master/CHANGELOG.md';
console.log(`Update version ${e.version} is available. Full list of
changes is available here: ${changelog_url}`);
if (!can_upgrade)
{
let res = yield show_message({type: 'info',
title: `Luminati update ${e.version} is available`,
message: 'Luminati version '+e.version
+' is available, would you like to download it?',
buttons: ['No', 'Yes']});
if (!res)
private onUpdateNotAvailable(version: UpdateInfo) {
log.info('DefaultUpdater', `update not available (latest version: ${version.version}, downgrade is ${autoUpdater.allowDowngrade ? 'allowed' : 'disallowed'})`);
this.state = State.Idle;
this.send(ApplicationUpdatesChannelName.CheckResponse, new NoUpdatesAvailableEvent());
}
private onUpdateNotAvailable(version: UpdateInfo) {
log.info('MacOSUpdater', `update not available (latest version: ${version.version}, downgrade is ${autoUpdater.allowDowngrade ? 'allowed' : 'disallowed'})`);
this.state = State.Idle;
this.send(ApplicationUpdatesChannelName.CheckResponse, new NoUpdatesAvailableEvent());
}
if (!can_upgrade)
{
let res = yield show_message({type: 'info', title: 'Luminati update',
message: (ver ? `Luminati version ${ver}` : 'Luminati update')
+' will be installed on exit',
buttons: ['Install on exit', 'Install now']});
if (!res)
return void logger.notice('Update postponed until exit');
}
logger.notice('Starting upgrade');
is_upgrading = true;
zerr.perr('upgrade_start');
auto_updater.quitAndInstall();
});
auto_updater.allowDowngrade = true;
auto_updater.autoDownload = false;
auto_updater.on('error', e=>zerr.perr('upgrade_error', {error: e}));
auto_updater.on('before-quit', ()=>{
if (is_upgrading)
zerr.perr('upgrade_finish');
});
auto_updater.on('update-available', e=>etask(function*(){
if (semver.lt(e.version, pkg.version))
{
if (!config.is_lum)
{
zerr.perr('upgrade_invalid_version',
{upgrade_v: e.version, current_v: pkg.version});
}
return;
autoUpdater.on('update-not-available', (versionInfo: VersionInfo) => {
log.info(`Updates', 'update not available (latest version: ${versionInfo.version}, downgrade is ${autoUpdater.allowDowngrade ? 'allowed' : 'disallowed'})`);
});