How to use electron-updater - 10 common examples

To help you get started, we’ve selected a few electron-updater examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenBuilds / OpenBuilds-CONTROL / index-backup.js View on Github external
var height = 200;

// Electron app
const electron = require('electron');
const electronApp = electron.app;
console.log("Local User Data: " + electronApp.getPath('userData'))
const BrowserWindow = electron.BrowserWindow;
const Tray = electron.Tray;
const nativeImage = require('electron').nativeImage
const Menu = require('electron').Menu

var appIcon = null,
  jogWindow = null,
  mainWindow = null

const autoUpdater = require("electron-updater").autoUpdater

autoUpdater.on('checking-for-update', () => {
  var string = 'Checking for update...';
  var output = {
    'command': 'autoupdate',
    'response': string
  }
  io.sockets.emit('updatedata', output);
  if (jogWindow && !jogWindow.isFocused()) {
    appIcon.displayBalloon({
      icon: nativeImage.createFromPath(iconPath),
      title: "OpenBuilds CONTROL",
      content: string
    })
  }
})
github Mokkapps / scrum-daily-standup-picker / main.js View on Github external
"use strict";
exports.__esModule = true;
var electron_1 = require("electron");
var path = require("path");
var url = require("url");
var log = require("electron-log");
var electron_updater_1 = require("electron-updater");
var isDev = require("electron-is-dev");
var win, serve;
var args = process.argv.slice(1);
serve = args.some(function (val) { return val === '--serve'; });
var GITHUB_RELEASE_URL = 'https://github.com/Mokkapps/scrum-daily-standup-picker/releases';
var isLinux = process.platform === 'linux';
log.transports.file.level = 'debug';
electron_updater_1.autoUpdater.logger = log;
// Disable auto download as ASAR is disabled and therefore code signing cannot be done
electron_updater_1.autoUpdater.autoDownload = false;
log.info('App starting...');
// Manage unhandled exceptions as early as possible
process.on('uncaughtException', function (e) {
    console.error("Caught unhandled exception: " + e);
    log.error("Caught unhandled exception: " + e);
    electron_1.dialog.showErrorBox('Caught unhandled exception', e.message || 'Unknown error message');
    electron_1.app.quit();
});
function createWindow() {
    var electronScreen = electron_1.screen;
    var size = electronScreen.getPrimaryDisplay().workAreaSize;
    // Create the browser window.
    win = new electron_1.BrowserWindow({
        webPreferences: {
github z------------- / CPod / main.js View on Github external
app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit()
  }
})

app.on("activate", () => {
  if (win === null) {
    createWindow()
  }
})

/* auto-update */

if (settings.autoUpdaterAllowPrerelease) {
  autoUpdater.allowPrerelease = true
}

// autoUpdater.fullChangelog = true
autoUpdater.autoDownload = false

var currentVersion

autoUpdater.checkForUpdates()
.then((updateCheckResult) => {
  let info = updateCheckResult.updateInfo
  console.log(info, info.releaseNotes)

  var isNewer = false;
  currentVersion = package.version
  let cvs = currentVersion.split(".").map(s => Number(s))
  let uvs = info.version.split(".").map(s => Number(s))
github ooni / probe-desktop / main / index.js View on Github external
// On macOS it's normal to quit the app only when you do apple-Q
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

function sendStatusToWindow(text) {
  const aboutWindow = openAboutWindow()
  log.info(text)
  aboutWindow.webContents.send('update-message', text)
}

autoUpdater.on('checking-for-update', () => {
  sendStatusToWindow('Checking for update...')
})
autoUpdater.on('update-available', () => {
  sendStatusToWindow('Update available.')
})
autoUpdater.on('update-not-available', () => {
  sendStatusToWindow('Update not available.')
})
autoUpdater.on('error', (err) => {
  sendStatusToWindow('Error in auto-updater. ' + err)
})
autoUpdater.on('download-progress', (progressObj) => {
  let log_message = 'Download speed: ' + progressObj.bytesPerSecond
  log_message = log_message + ' - Downloaded ' + progressObj.percent + '%'
  log_message = log_message + ' (' + progressObj.transferred + '/' + progressObj.total + ')'
  sendStatusToWindow(log_message)
})
autoUpdater.on('update-downloaded', () => {
  sendStatusToWindow('Update downloaded. Quitting and installing.')
github taurusai / kungfu / app / src / main / index.js View on Github external
});
    autoUpdater.on('checking-for-update', () => {
        sendUpdateMessage(mainWindow, message.checking)
    });
    autoUpdater.on('update-available', (info) => {
        sendUpdateMessage(mainWindow, message.updateAva)
    });
    autoUpdater.on('update-not-available', (info) => {
        sendUpdateMessage(mainWindow, message.updateNotAva)
    });

    // 更新下载进度事件
    autoUpdater.on('download-progress', (progressObj) => {
        mainWindow.webContents.send('downloadProgress', progressObj)
    })
    autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) => {
        dialog.showMessageBox({
            type: 'question',
            title: '提示',
            defaultId: 0,
            cancelId: 1,
            message: "检测到新版本,更新会退出应用,是否立即更新?",
            buttons: ['立即更新', '否'],
            icon: path.join(__resources, 'icon', 'icon.png')
        }, (index) => {
            if(index === 0){
				KillAll().then(() => {
					setImmediate(() => {
						autoUpdater.quitAndInstall(); 
						app.quit()
					})
				})
github imolorhe / altair / packages / altair-electron / src / updates.js View on Github external
//   };

  //   dialog.showMessageBox(dialogOpts, (response) => {
  //     if (response === 0) {
  //       autoUpdater.quitAndInstall();
  //     }
  //   });
  // });

  // autoUpdater.on('error', message => {
  //   console.error('There was a problem updating the application');
  //   console.error(message);
  // });

  log.transports.file.level = 'info';
  autoUpdater.logger = log;
  // autoUpdater.checkForUpdatesAndNotify();
  autoUpdater.checkForUpdates();
};
github yjlintw / comic-reader / main.js View on Github external
const electron = require('electron');
const {app, BrowserWindow, dialog} = electron;
const path = require('path');
const url = require('url');
const settings = require('electron-settings');
const log = require('electron-log');
const {autoUpdater} = require("electron-updater");
const EA = require("electron-analytics");
const ipc = electron.ipcMain;
EA.init("Bkles-YA1-");

require('electron-debug')({showDevTools: false});

// Logging
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = "info";
// autoUpdater.autoDownload = false;
autoUpdater.allowPrerelease = false;
log.info('App Starting');

let manualupdate = false;

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
require('electron-context-menu')();

let win;

function sendStatusToWindow(text) {
  log.info('', text);
  // win.webContents.send('message', text);
}
github kopia / kopia / app / public / electron.js View on Github external
app.on('ready', () => {
  loadConfigs();

  if (isPortableConfig()) {
    const logDir = path.join(configDir(), "logs");

    log.transports.file.resolvePath = (variables) => path.join(logDir, variables.fileName);
  }

  log.transports.console.level = "warn"
  log.transports.file.level = "debug"
  autoUpdater.logger = log

  if (maybeMoveToApplicationsFolder()) {
    return
  }

  checkForUpdates();

  // re-check for updates every 24 hours
  setInterval(checkForUpdates, 86400000);

  tray = new Tray(
    path.join(
      resourcesPath(), 'icons',
      selectByOS({ mac: 'kopia-tray.png', win: 'kopia-tray.ico', linux: 'kopia-tray.png' })));

  tray.setToolTip('Kopia');
github cronoh / nanovault / main.js View on Github external
const { app, BrowserWindow, shell, Menu, protocol, webFrame, ipcMain } = require('electron');
const autoUpdater = require('electron-updater').autoUpdater;
const url = require('url');
const path = require('path');

// const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid');

app.setAsDefaultProtocolClient('xrb'); // Register handler for xrb: links

console.log(`Starting ledger@!`);

const ledger = require('./desktop-app/src/lib/ledger');

ledger.initialize();

// const Ledger = new ledger();

// Ledger.loadLedger();
github z------------- / CPod / main.js View on Github external
const { app, dialog, shell, globalShortcut, ipcMain, BrowserWindow, Menu, Tray } = require("electron")
const path = require("path")
const url = require("url")
const autoUpdater = require("electron-updater").autoUpdater
const fs = require("fs")
const i18n = require("./lib/i18n.js")
const request = require("request")

let win, tray, menu // keep globals

const package = require("./package.json");

const configDirName = "cumulonimbus"
const configDirPath = path.join( path.parse(app.getPath("userData")).dir, configDirName )
try {
  fs.mkdirSync(configDirPath)
} catch (exp) {
  console.log("Looks like config dir already exists, continuing")
}
app.setPath("userData", configDirPath)