-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Manish Jangir
committed
Sep 12, 2018
1 parent
088a03c
commit bdc263a
Showing
250 changed files
with
667 additions
and
87,963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,10 @@ app/build | |
node_modules | ||
stats.json | ||
app/node_modules | ||
release | ||
|
||
# Cruft | ||
.DS_Store | ||
npm-debug.log | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* eslint global-require: 0 */ | ||
import { app, dialog, shell } from 'electron'; | ||
import { autoUpdater } from 'electron-updater'; | ||
import es from 'electron-settings'; | ||
import isDev from 'electron-is-dev'; | ||
|
||
function appUpdater(updateFromMenu = false) { | ||
// Don't initiate auto-updates in development | ||
if (isDev) { | ||
return; | ||
} | ||
|
||
if (process.platform === 'linux' && !process.env.APPIMAGE) { | ||
// const { linuxUpdateNotification } = require('./linuxupdater'); | ||
// linuxUpdateNotification(); | ||
return; | ||
} | ||
|
||
let updateAvailable = false; | ||
|
||
// Create Logs directory | ||
const logsDir = `${app.getPath('userData')}/logs`; | ||
|
||
// Log whats happening | ||
const log = require('electron-log'); | ||
|
||
log.transports.file.file = `${logsDir}/updates.log`; | ||
log.transports.file.level = 'info'; | ||
autoUpdater.logger = log; | ||
|
||
// Handle auto updates for beta/pre releases | ||
autoUpdater.allowPrerelease = es.get('allowPreRelease') || false; | ||
|
||
const eventsListenerRemove = ['update-available', 'update-not-available']; | ||
|
||
autoUpdater.on('update-available', info => { | ||
if (updateFromMenu) { | ||
dialog.showMessageBox({ | ||
message: `A new version ${info.version}, of Reactron is available`, | ||
detail: | ||
'The update will be downloaded in the background. You will be notified when it is ready to be installed.', | ||
}); | ||
|
||
updateAvailable = true; | ||
|
||
eventsListenerRemove.forEach(event => { | ||
autoUpdater.removeAllListeners(event); | ||
}); | ||
} | ||
}); | ||
|
||
autoUpdater.on('update-not-available', () => { | ||
if (updateFromMenu) { | ||
dialog.showMessageBox({ | ||
message: 'No updates available', | ||
detail: `You are running the latest version of Reactron.\nVersion: ${app.getVersion()}`, | ||
}); | ||
autoUpdater.removeAllListeners(); | ||
} | ||
}); | ||
|
||
autoUpdater.on('error', error => { | ||
if (updateFromMenu) { | ||
const messageText = updateAvailable | ||
? 'Unable to download the updates' | ||
: 'Unable to check for updates'; | ||
dialog.showMessageBox( | ||
{ | ||
type: 'error', | ||
buttons: ['Manual Download', 'Cancel'], | ||
message: messageText, | ||
detail: `${error.toString()}\n\nThe latest version of Reactron Website is available at - | ||
\nhttps://github.com/mjangir/reactron/.\nCurrent Version: ${app.getVersion()}`, | ||
}, | ||
response => { | ||
if (response === 0) { | ||
shell.openExternal('https://github.com/mjangir/reactron'); | ||
} | ||
}, | ||
); | ||
autoUpdater.removeAllListeners(); | ||
} | ||
}); | ||
|
||
// Ask the user if update is available | ||
// eslint-disable-next-line no-unused-vars | ||
autoUpdater.on('update-downloaded', event => { | ||
// Ask user to update the app | ||
dialog.showMessageBox( | ||
{ | ||
type: 'question', | ||
buttons: ['Install and Relaunch', 'Install Later'], | ||
defaultId: 0, | ||
message: `A new update ${event.version} has been downloaded`, | ||
detail: | ||
'It will be installed the next time you restart the application', | ||
}, | ||
response => { | ||
if (response === 0) { | ||
setTimeout(() => { | ||
autoUpdater.quitAndInstall(); | ||
// force app to quit. This is just a workaround, ideally autoUpdater.quitAndInstall() should relaunch the app. | ||
app.quit(); | ||
}, 1000); | ||
} | ||
}, | ||
); | ||
}); | ||
// Init for updates | ||
autoUpdater.checkForUpdates(); | ||
} | ||
|
||
export default { | ||
appUpdater, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.