Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle updates in main process, fix unnecessary update download bug
- Loading branch information
Showing
14 changed files
with
121 additions
and
148 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
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,21 @@ | ||
#!/bin/bash | ||
echo "Building middleman assets for production" | ||
(export ASSET_HOST=assets DEBUG_BUILD=true && ./build_prod.sh) | ||
|
||
echo "Clearing envkey-electron/assets and envkey-electron/dist" | ||
rm -rf envkey-electron/assets/* | ||
rm -rf envkey-electron/dist/* | ||
rm envkey-assets/source/javascripts/* | ||
|
||
echo "Copying assets to envkey-electron" | ||
cp -r envkey-assets/build/fonts envkey-assets/build/images envkey-assets/build/stylesheets envkey-electron/assets/ | ||
cp envkey-assets/build/javascripts/* envkey-assets/build/*.js envkey-electron/assets/ | ||
|
||
# echo "Building dmg only without signing" | ||
# export CSC_IDENTITY_AUTO_DISCOVERY=false | ||
(cd envkey-electron && npm run distmac) | ||
|
||
echo "Clearing middleman build and electron assets" | ||
rm -rf envkey-assets/build/* | ||
rm -rf envkey-electron/assets/* | ||
rm envkey-assets/source/javascripts/* |
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,57 @@ | ||
const updater = require('electron-simple-updater'), | ||
{dialog, BrowserWindow} = require('electron'), | ||
logger = require('electron-log') | ||
|
||
let versionAvailable, | ||
versionDownloaded, | ||
checkingUpdates = false | ||
|
||
logger.transports.file.level = 'info' | ||
|
||
// Auto-update | ||
updater.init({logger, autoDownload: false, checkUpdateOnStart: false}) | ||
|
||
const | ||
onUpdateDownloaded = ()=>{ | ||
logger.info("Update downloaded.") | ||
versionDownloaded = versionAvailable | ||
promptRestart() | ||
}, | ||
|
||
onUpdateAvailable = meta =>{ | ||
logger.info("Update available.") | ||
if(meta.version == versionAvailable)return | ||
versionAvailable = meta.version | ||
updater.downloadUpdate() | ||
}, | ||
|
||
promptRestart = ()=> { | ||
let choice = dialog.showMessageBox({ | ||
type: 'question', | ||
buttons: ['Yes', 'No'], | ||
title: 'Confirm', | ||
message: `EnvKey has auto-updated to v${versionDownloaded}. Do you want to restart with the latest version?` | ||
}) | ||
|
||
if(choice === 0){ | ||
updater.quitAndInstall() | ||
} | ||
} | ||
|
||
module.exports = { | ||
|
||
listenUpdater: ()=>{ | ||
if(checkingUpdates)return | ||
|
||
updater.on('update-available', onUpdateAvailable) | ||
updater.on('update-downloaded', onUpdateDownloaded) | ||
updater.on('error', err => logger.error(err)) | ||
|
||
// Check for updates every 10 minutes | ||
setInterval(()=> updater.checkForUpdates(), 1000 * 60 * 10) | ||
|
||
updater.checkForUpdates() | ||
|
||
checkingUpdates = true | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,16 +1,10 @@ | ||
const electron = require("electron"), | ||
{clipboard, remote, ipcRenderer, shell} = electron, | ||
updater = remote.require("electron-simple-updater") | ||
{clipboard, remote, ipcRenderer, shell} = electron | ||
|
||
window.copy = s => { | ||
clipboard.writeText(s) | ||
return true | ||
} | ||
|
||
window.ipc = ipcRenderer | ||
window.updater = updater | ||
window.shell = shell | ||
|
||
window.installUpdate = ()=> { | ||
updater.quitAndInstall() | ||
} |
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 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 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 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.