mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 03:32:12 -08:00
Added basic auto update implementation.
This commit is contained in:
parent
5b74ecef21
commit
95afe5c63a
@ -46,10 +46,9 @@ If you use VS Code, you can run this directly from the IDE. Copy the following c
|
|||||||
"windows": {
|
"windows": {
|
||||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
||||||
},
|
},
|
||||||
"program": "${workspaceRoot}/index.js",
|
"args": ["."],
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"protocol": "inspector",
|
"protocol": "inspector"
|
||||||
"timeout": 100000000
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Debug Renderer Process",
|
"name": "Debug Renderer Process",
|
||||||
@ -60,7 +59,7 @@ If you use VS Code, you can run this directly from the IDE. Copy the following c
|
|||||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
||||||
},
|
},
|
||||||
"runtimeArgs": [
|
"runtimeArgs": [
|
||||||
"${workspaceRoot}/index.js",
|
"${workspaceRoot}/.",
|
||||||
"--remote-debugging-port=9222"
|
"--remote-debugging-port=9222"
|
||||||
],
|
],
|
||||||
"webRoot": "${workspaceRoot}"
|
"webRoot": "${workspaceRoot}"
|
||||||
|
@ -1002,8 +1002,12 @@ p {
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-top: 50px;
|
margin-top: 50px;
|
||||||
}
|
}
|
||||||
|
#image_seal_container[update]{
|
||||||
|
cursor: pointer
|
||||||
|
}
|
||||||
#image_seal_container[update]:before,
|
#image_seal_container[update]:before,
|
||||||
#image_seal_container[update]:after {
|
#image_seal_container[update]:after {
|
||||||
|
cursor: pointer;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
content: '';
|
content: '';
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -1013,10 +1017,47 @@ p {
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
box-shadow: 0 0 15px #43c628;
|
box-shadow: 0 0 15px #43c628;
|
||||||
animation: glow-grow 4s ease-out infinite;
|
animation: glow-grow 4s ease-out infinite;
|
||||||
|
background: rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
#image_seal_container[update]:after {
|
#image_seal_container[update]:before {
|
||||||
animation-delay: 2s;
|
animation-delay: 2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#updateAvailableTooltip {
|
||||||
|
cursor: pointer;
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
width: 100px;
|
||||||
|
height: 15px;
|
||||||
|
background-color: rgb(0, 0, 0);
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 2px;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
|
top: 115%;
|
||||||
|
left: -17.5px;
|
||||||
|
font-family: 'Avenir Medium';
|
||||||
|
font-size: 12px;
|
||||||
|
transition: visibility 0s linear 0.25s, opacity 0.25s ease;
|
||||||
|
}
|
||||||
|
#updateAvailableTooltip::after {
|
||||||
|
content: " ";
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: 100%;
|
||||||
|
margin-left: -5px;
|
||||||
|
border-width: 5px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: transparent transparent rgb(0, 0, 0) transparent;
|
||||||
|
}
|
||||||
|
#image_seal_container[update]:hover #updateAvailableTooltip {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
transition-delay: 0s;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes glow-grow {
|
@keyframes glow-grow {
|
||||||
0% {
|
0% {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 969 KiB After Width: | Height: | Size: 502 KiB |
BIN
app/assets/images/backgrounds/6.jpg
Normal file
BIN
app/assets/images/backgrounds/6.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 MiB |
BIN
app/assets/images/backgrounds/7.jpg
Normal file
BIN
app/assets/images/backgrounds/7.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 MiB |
@ -6,7 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
// Requirements
|
// Requirements
|
||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
const {remote, shell, webFrame} = require('electron')
|
const {ipcRenderer, remote, shell, webFrame} = require('electron')
|
||||||
|
const isDev = require('electron-is-dev')
|
||||||
|
|
||||||
// Disable eval function.
|
// Disable eval function.
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
@ -26,6 +27,61 @@ webFrame.setZoomLevel(0)
|
|||||||
webFrame.setVisualZoomLevelLimits(1, 1)
|
webFrame.setVisualZoomLevelLimits(1, 1)
|
||||||
webFrame.setLayoutZoomLevelLimits(0, 0)
|
webFrame.setLayoutZoomLevelLimits(0, 0)
|
||||||
|
|
||||||
|
// Initialize auto updates in production environments.
|
||||||
|
// TODO Make this the case after implementation is done.
|
||||||
|
if(!isDev){
|
||||||
|
ipcRenderer.on('autoUpdateNotification', (event, arg, info) => {
|
||||||
|
switch(arg){
|
||||||
|
case 'checking-for-update':
|
||||||
|
console.log('Checking for update..')
|
||||||
|
break
|
||||||
|
case 'update-available':
|
||||||
|
console.log('New update available', info.version)
|
||||||
|
break
|
||||||
|
case 'update-downloaded':
|
||||||
|
console.log('Update ' + info.version + ' ready to be installed.')
|
||||||
|
showUpdateUI(info)
|
||||||
|
break
|
||||||
|
case 'update-not-available':
|
||||||
|
console.log('No new update found.')
|
||||||
|
break
|
||||||
|
case 'ready':
|
||||||
|
ipcRenderer.send('autoUpdateAction', 'checkForUpdate')
|
||||||
|
case 'error':
|
||||||
|
console.log('Error during update check..')
|
||||||
|
console.debug('Error Code:', info != null ? info.code : null)
|
||||||
|
if(err.code === 'ERR_UPDATER_INVALID_RELEASE_FEED'){
|
||||||
|
console.log('No suitable releases found.')
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
console.log('Unknown argument', arg)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
ipcRenderer.send('autoUpdateAction', 'initAutoUpdater')
|
||||||
|
}
|
||||||
|
|
||||||
|
function showUpdateUI(info){
|
||||||
|
//TODO Make this message a bit more informative `${info.version}`
|
||||||
|
document.getElementById('image_seal_container').setAttribute('update', true)
|
||||||
|
document.getElementById('image_seal_container').onclick = () => {
|
||||||
|
setOverlayContent('Update Available', 'A new update for the launcher is available. Would you like to install now?', 'Install', 'Later')
|
||||||
|
setOverlayHandler(() => {
|
||||||
|
if(!isDev){
|
||||||
|
ipcRenderer.send('autoUpdateAction', 'installUpdateNow')
|
||||||
|
} else {
|
||||||
|
console.error('Cannot install updates in development environment.')
|
||||||
|
toggleOverlay(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
setDismissHandler(() => {
|
||||||
|
toggleOverlay(false)
|
||||||
|
})
|
||||||
|
toggleOverlay(true, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* jQuery Example
|
/* jQuery Example
|
||||||
$(function(){
|
$(function(){
|
||||||
console.log('UICore Initialized');
|
console.log('UICore Initialized');
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<div id="left">
|
<div id="left">
|
||||||
<div id="image_seal_container">
|
<div id="image_seal_container">
|
||||||
<img id="image_seal" src="assets/images/WesterosSealCircle.png"/>
|
<img id="image_seal" src="assets/images/WesterosSealCircle.png"/>
|
||||||
|
<div id="updateAvailableTooltip">Update Available</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
3
dev-app-update.yml
Normal file
3
dev-app-update.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
owner: WesterosCraftCode
|
||||||
|
repo: ElectronLauncher
|
||||||
|
provider: github
|
48
index.js
48
index.js
@ -1,10 +1,54 @@
|
|||||||
const {app, BrowserWindow} = require('electron')
|
const {app, BrowserWindow, ipcMain} = require('electron')
|
||||||
//const autoUpdater = require("electron-updater").autoUpdater
|
const autoUpdater = require("electron-updater").autoUpdater
|
||||||
|
const isDev = require('electron-is-dev')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const url = require('url')
|
const url = require('url')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const ejse = require('ejs-electron')
|
const ejse = require('ejs-electron')
|
||||||
|
|
||||||
|
function initAutoUpdater(event){
|
||||||
|
// Defaults to true if application version contains prerelease components (e.g. 0.12.1-alpha.1)
|
||||||
|
// autoUpdater.allowPrerelease = true
|
||||||
|
if(isDev){
|
||||||
|
autoUpdater.autoInstallOnAppQuit = false
|
||||||
|
autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml')
|
||||||
|
}
|
||||||
|
autoUpdater.on('update-available', (info) => {
|
||||||
|
event.sender.send('autoUpdateNotification', 'update-available', info)
|
||||||
|
})
|
||||||
|
autoUpdater.on('update-downloaded', (info) => {
|
||||||
|
event.sender.send('autoUpdateNotification', 'update-downloaded', info)
|
||||||
|
})
|
||||||
|
autoUpdater.on('update-not-available', (info) => {
|
||||||
|
event.sender.send('autoUpdateNotification', 'update-not-available', info)
|
||||||
|
})
|
||||||
|
autoUpdater.on('checking-for-update', () => {
|
||||||
|
event.sender.send('autoUpdateNotification', 'checking-for-update')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcMain.on('autoUpdateAction', (event, arg) => {
|
||||||
|
switch(arg){
|
||||||
|
case 'initAutoUpdater':
|
||||||
|
console.log('Initializing auto updater.')
|
||||||
|
initAutoUpdater(event)
|
||||||
|
event.sender.send('autoUpdateNotification', 'ready')
|
||||||
|
break
|
||||||
|
case 'checkForUpdate':
|
||||||
|
autoUpdater.checkForUpdates()
|
||||||
|
.catch(err => {
|
||||||
|
event.sender.send('autoUpdateNotification', 'error', err)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'installUpdateNow':
|
||||||
|
autoUpdater.quitAndInstall()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
console.log('Unknown argument', arg)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Disable hardware acceleration.
|
// Disable hardware acceleration.
|
||||||
// https://electronjs.org/docs/tutorial/offscreen-rendering
|
// https://electronjs.org/docs/tutorial/offscreen-rendering
|
||||||
app.disableHardwareAcceleration()
|
app.disableHardwareAcceleration()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "westeroscraftlauncher",
|
"name": "westeroscraftlauncher",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1-dev",
|
||||||
"description": "Custom modded launcher for Westeroscraft",
|
"description": "Custom modded launcher for Westeroscraft",
|
||||||
"productName": "WesterosCraft Launcher",
|
"productName": "WesterosCraft Launcher",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@ -33,6 +33,7 @@
|
|||||||
"discord-rpc": "^3.0.0-beta.10",
|
"discord-rpc": "^3.0.0-beta.10",
|
||||||
"ejs": "^2.5.9",
|
"ejs": "^2.5.9",
|
||||||
"ejs-electron": "^2.0.1",
|
"ejs-electron": "^2.0.1",
|
||||||
|
"electron-is-dev": "^0.3.0",
|
||||||
"electron-updater": "^2.21.8",
|
"electron-updater": "^2.21.8",
|
||||||
"jquery": "^3.3.1",
|
"jquery": "^3.3.1",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
@ -92,7 +93,7 @@
|
|||||||
},
|
},
|
||||||
"compression": "maximum",
|
"compression": "maximum",
|
||||||
"files": [
|
"files": [
|
||||||
"!{target,logs,.vscode,docs}"
|
"!{target,logs,.vscode,docs,dev-app-update.yml}"
|
||||||
],
|
],
|
||||||
"asar": true
|
"asar": true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user