Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Commit 497adf1

Browse files
author
h17263
committed
testing new autoupdater
1 parent d5a8a52 commit 497adf1

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

DECSV_project/app.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const BrowserWindow = electron.BrowserWindow;
55
const path = require('path');
66
const url = require('url');
77
const fs = require('fs');
8-
const autoUpdater = electron.autoUpdater;
8+
const autoUpdater = require("electron-updater").autoUpdater;
99
const dialog = electron.dialog;
1010
const windowStateKeeper = require('electron-window-state');
1111
const Store = require('electron-store');
@@ -19,6 +19,7 @@ if (require('electron-squirrel-startup')) { app.quit(); }
1919
///////////////////////////////
2020
logger.transports.file.level = "info";
2121
logger.transports.console.level = "silly";
22+
autoUpdater.logger = logger;
2223
///////////////////////////////
2324

2425
const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) => {
@@ -444,8 +445,8 @@ app.on('activate', function () {
444445
});
445446

446447
/* AUTOUPDATER */
447-
var updatePath = "http://testing-tyaisurm.c9users.io/update/win32/" + app.getVersion().toString();
448-
autoUpdater.setFeedURL(updatePath);
448+
//var updatePath = "http://testing-tyaisurm.c9users.io/update/win32/" + app.getVersion().toString();
449+
//autoUpdater.setFeedURL(updatePath);
449450

450451
app.on('will-quit', function () {
451452
logger.info("application will quit...");
@@ -458,13 +459,14 @@ app.on('quit', function () {
458459

459460
ipcMain.on("check-updates", (event, arg) => {
460461

461-
autoUpdater.on('checking-for-update', function () {
462+
autoUpdater.on('checking-for-update', function () {
462463
logger.info("Checking for updates...");
463464
logger.info("Current version: " + app.getVersion().toString());
464465
event.sender.send("check-updates-reply", 0);
465466
});
466-
autoUpdater.on('update-available', function () {
467+
autoUpdater.on('update-available', function (info) {
467468
logger.info("Update available!");
469+
logger.info(info);
468470

469471
event.sender.send("check-updates-reply", 1);
470472
var options = {
@@ -496,8 +498,9 @@ autoUpdater.on('error', function (err) {
496498
//
497499
});
498500
});
499-
autoUpdater.on('update-not-available', function () {
501+
autoUpdater.on('update-not-available', function (info) {
500502
logger.info("Update not available!");
503+
logger.info(info);
501504

502505
event.sender.send("check-updates-reply", 2);
503506
clearUpdaterListeners();
@@ -514,15 +517,15 @@ autoUpdater.on('update-not-available', function () {
514517
});
515518
});
516519

517-
autoUpdater.on('update-downloaded', function (ev, relNot, relNam, relDat, updUrl) {
520+
autoUpdater.on('update-downloaded', function (info){//ev, relNot, relNam, relDat, updUrl) {
518521
logger.info("Update has been downloaded!");
519-
logger.debug(relNot,relNam,relDat,updUrl);
522+
logger.info(info);
520523
event.sender.send("check-updates-reply", 2);
521524
clearUpdaterListeners();
522525
var options = {
523526
type: 'info',
524527
title: "Update downloaded",
525-
message: "New version "+relNam+" is ready to be installed",
528+
message: "New version is ready to be installed",
526529
detail: "Would you like to close the application and update?",
527530
buttons: ["yes", "no"]
528531
};
@@ -537,16 +540,25 @@ autoUpdater.on('update-downloaded', function (ev, relNot, relNam, relDat, updUrl
537540
}
538541
});
539542
});
540-
logger.debug("CALLING CHECKFORUPDATES!!!");
541-
autoUpdater.checkForUpdates();
543+
544+
autoUpdater.on('download-progress', function (progressObj) {
545+
let log_message = "Download speed: " + progressObj.bytesPerSecond;
546+
log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
547+
log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
548+
logger.info(progressObj);
549+
logger.info(log_message);
550+
});
551+
logger.debug("CALLING CHECKFORUPDATES!!!");
552+
autoUpdater.checkForUpdates();
542553
});
543554

544555
function clearUpdaterListeners() {
545556
autoUpdater.removeAllListeners('checking-for-update');
546-
autoUpdater.removeAllListeners('update-available')
547-
autoUpdater.removeAllListeners('error')
548-
autoUpdater.removeAllListeners('update-not-available')
549-
autoUpdater.removeAllListeners('update-downloaded')
557+
autoUpdater.removeAllListeners('update-available');
558+
autoUpdater.removeAllListeners('error');
559+
autoUpdater.removeAllListeners('update-not-available');
560+
autoUpdater.removeAllListeners('update-downloaded');
561+
autoUpdater.removeAllListeners('download-progress');
550562
}
551563

552564
global.createAboutWin = function () {

DECSV_project/package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
{
22
"name": "decsv",
33
"productName": "DECSV",
4-
"version": "1.3.0",
4+
"version": "1.3.1",
55
"description": "SLIPPS survey results review and edit application.",
66
"main": "app.js",
77
"scripts": {
88
"start": "electron .",
99
"pack-win": "electron-builder --win --ia32 --dir",
1010
"dist-win": "electron-builder --win --ia32",
11-
"dist-multi": "electron-builder -mwl"
11+
"dist-multi": "electron-builder -mwl",
12+
"release": "build --win --ia32 -p always"
1213
},
1314
"build": {
15+
"publish": [
16+
{
17+
"provider": "github",
18+
"owner": "Tyaisurm",
19+
"repo": "DECSV"
20+
}
21+
],
1422
"appId": "com.squirrel.decsv.DECSV",
1523
"win": {
16-
"target": "squirrel",
24+
"target": "nsis",
1725
"icon": "./build/icon.ico"
1826
},
1927
"mac": {
@@ -22,7 +30,7 @@
2230
},
2331
"squirrelWindows": {
2432
"iconUrl": "https://github.com/Tyaisurm/DECSV/blob/master/DECSV_project/build/icon.ico?raw=true",
25-
"remoteReleases": "https://github.com/Tyaisurm/testing",
33+
"remoteReleases": "https://github.com/Tyaisurm/DECSV",
2634
"loadingGif": "./build/install-spinner.gif"
2735
}
2836
},

0 commit comments

Comments
 (0)