Skip to content

Commit 50480a6

Browse files
authored
Merge pull request #366 from manosim/setup-autoupdate
Setup autoupdate
2 parents c97f9ec + b389ff4 commit 50480a6

File tree

4 files changed

+52
-167
lines changed

4 files changed

+52
-167
lines changed

auto_updater.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"name": "Release 2.0.2",
3-
"url": "https://github.com/manosim/gitify/releases/download/2.0.2/gitify-osx.zip"
2+
"name": "Release 3.0.0",
3+
"url": "https://github.com/manosim/gitify/releases/download/v3.0.0/gitify-osx.zip"
44
}

main.js

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
const { dialog, ipcMain } = require('electron');
1+
const { ipcMain } = require('electron');
22
const { menubar } = require('menubar');
3+
const { autoUpdater } = require("electron-updater")
34
const path = require('path');
45
const AutoLaunch = require('auto-launch');
5-
const GhReleases = require('electron-gh-releases');
66

77
const iconIdle = path.join(__dirname, 'assets', 'images', 'tray-idleTemplate.png');
88
const iconActive = path.join(__dirname, 'assets', 'images', 'tray-active.png');
99

10-
const isDarwin = process.platform === 'darwin';
11-
const isLinux = process.platform === 'linux';
12-
const isWindows = process.platform === 'win32';
13-
1410
const autoStart = new AutoLaunch({
1511
name: 'Gitify',
1612
path: process.execPath.match(/.*?\.app/)[0],
@@ -39,7 +35,7 @@ const menubarApp = menubar({
3935
menubarApp.on('ready', () => {
4036
menubarApp.tray.setIgnoreDoubleClickEvents(true);
4137

42-
checkAutoUpdate();
38+
autoUpdater.checkForUpdatesAndNotify();
4339

4440
ipcMain.on('reopen-window', () => menubarApp.showWindow());
4541
ipcMain.on('startup-enable', () => autoStart.enable());
@@ -70,54 +66,4 @@ menubarApp.on('ready', () => {
7066
menubarApp.positioner.move('trayCenter', trayBounds);
7167
menubarApp.window.resizable = false;
7268
});
73-
74-
function checkAutoUpdate() {
75-
if (isWindows || isLinux) {
76-
return;
77-
}
78-
79-
let autoUpdateOptions = {
80-
repo: 'manosim/gitify',
81-
currentVersion: menubarApp.app.getVersion(),
82-
};
83-
84-
const updater = new GhReleases(autoUpdateOptions);
85-
86-
updater.on('error', (event, message) => {
87-
console.log('ERRORED.');
88-
console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message);
89-
});
90-
91-
updater.on('update-downloaded', () => {
92-
// Restart the app(ask) and install the update
93-
confirmAutoUpdate(updater);
94-
});
95-
96-
// Check for updates
97-
updater.check((err, status) => {
98-
if (!err && status) {
99-
updater.download();
100-
}
101-
});
102-
}
103-
104-
function confirmAutoUpdate(updater) {
105-
dialog.showMessageBox(
106-
{
107-
type: 'question',
108-
buttons: ['Update & Restart', 'Cancel'],
109-
title: 'Update Available',
110-
cancelId: 99,
111-
message:
112-
'There is an update available. Would you like to update Gitify now?',
113-
},
114-
response => {
115-
console.log('Exit: ' + response);
116-
menubarApp.app.dock.hide();
117-
if (response === 0) {
118-
updater.install();
119-
}
120-
}
121-
);
122-
}
12369
});

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
"app",
3030
"tray"
3131
],
32-
"author": "Emmanouil Konstantinidis",
32+
"author": {
33+
"name": "Emmanouil Konstantinidis",
34+
"email": "[email protected]"
35+
},
3336
"contributors": [
3437
{
3538
"name": "Emmanouil Konstantinidis",
@@ -67,7 +70,8 @@
6770
"mac": {
6871
"category": "public.app-category.developer-tools",
6972
"icon": "assets/images/app-icon.icns",
70-
"identity": "Emmanouil Konstantinidis (3YP8SXP3BF)"
73+
"identity": "Emmanouil Konstantinidis (3YP8SXP3BF)",
74+
"publish": ["github"]
7175
},
7276
"dmg": {
7377
"icon": "assets/images/app-icon.icns"
@@ -78,7 +82,7 @@
7882
"auto-launch": "=5.0.5",
7983
"axios": "=0.19.2",
8084
"date-fns": "^2.9.0",
81-
"electron-gh-releases": "=2.0.4",
85+
"electron-updater": "^4.2.0",
8286
"final-form": "^4.18.7",
8387
"lodash": "^4.17.15",
8488
"menubar": "^7.2.0",

0 commit comments

Comments
 (0)