general update checking improvements + jsdoc + dev mode notifs
This commit is contained in:
parent
18f9df48e7
commit
159ee76432
6 changed files with 65 additions and 9 deletions
|
@ -4,6 +4,12 @@ import * as path from 'path';
|
||||||
import * as log from 'electron-log';
|
import * as log from 'electron-log';
|
||||||
import {utils} from './utils';
|
import {utils} from './utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file Creates App instance
|
||||||
|
* @author CiderCollective
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @namespace */
|
||||||
export class AppEvents {
|
export class AppEvents {
|
||||||
private protocols: string[] = [
|
private protocols: string[] = [
|
||||||
"ame",
|
"ame",
|
||||||
|
@ -17,6 +23,7 @@ export class AppEvents {
|
||||||
private tray: any = undefined;
|
private tray: any = undefined;
|
||||||
private i18n: any = undefined;
|
private i18n: any = undefined;
|
||||||
|
|
||||||
|
/** @constructor */
|
||||||
constructor() {
|
constructor() {
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
|
@ -90,6 +97,7 @@ export class AppEvents {
|
||||||
/***********************************************************************************************************************
|
/***********************************************************************************************************************
|
||||||
* Protocols
|
* Protocols
|
||||||
**********************************************************************************************************************/
|
**********************************************************************************************************************/
|
||||||
|
/** */
|
||||||
if (process.defaultApp) {
|
if (process.defaultApp) {
|
||||||
if (process.argv.length >= 2) {
|
if (process.argv.length >= 2) {
|
||||||
this.protocols.forEach((protocol: string) => {
|
this.protocols.forEach((protocol: string) => {
|
||||||
|
|
|
@ -16,7 +16,12 @@ import {utils} from './utils';
|
||||||
const fileWatcher = require('chokidar');
|
const fileWatcher = require('chokidar');
|
||||||
const AdmZip = require("adm-zip");
|
const AdmZip = require("adm-zip");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file Creates the BrowserWindow
|
||||||
|
* @author CiderCollective
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @namespace */
|
||||||
export class BrowserWindow {
|
export class BrowserWindow {
|
||||||
public static win: any | undefined = null;
|
public static win: any | undefined = null;
|
||||||
private devMode: boolean = !app.isPackaged;
|
private devMode: boolean = !app.isPackaged;
|
||||||
|
@ -273,6 +278,9 @@ export class BrowserWindow {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the browser window
|
* Creates the browser window
|
||||||
|
* @generator
|
||||||
|
* @function createWindow
|
||||||
|
* @yields {object} Electron browser window
|
||||||
*/
|
*/
|
||||||
async createWindow(): Promise<Electron.BrowserWindow> {
|
async createWindow(): Promise<Electron.BrowserWindow> {
|
||||||
this.clientPort = await getPort({port: 9000});
|
this.clientPort = await getPort({port: 9000});
|
||||||
|
@ -926,11 +934,11 @@ export class BrowserWindow {
|
||||||
|
|
||||||
ipcMain.on('get-remote-pair-url', (_event, _) => {
|
ipcMain.on('get-remote-pair-url', (_event, _) => {
|
||||||
let url = `http://${BrowserWindow.getIP()}:${this.remotePort}`;
|
let url = `http://${BrowserWindow.getIP()}:${this.remotePort}`;
|
||||||
if (app.isPackaged) {
|
//if (app.isPackaged) {
|
||||||
BrowserWindow.win.webContents.send('send-remote-pair-url', (`https://cider.sh/pair-remote?url=${Buffer.from(encodeURI(url)).toString('base64')}`).toString());
|
BrowserWindow.win.webContents.send('send-remote-pair-url', (`https://cider.sh/pair-remote?url=${Buffer.from(encodeURI(url)).toString('base64')}`).toString());
|
||||||
} else {
|
//} else {
|
||||||
BrowserWindow.win.webContents.send('send-remote-pair-url', (`http://127.0.0.1:5500/pair-remote.html?url=${Buffer.from(encodeURI(url)).toString('base64')}`).toString());
|
// BrowserWindow.win.webContents.send('send-remote-pair-url', (`http://127.0.0.1:5500/pair-remote.html?url=${Buffer.from(encodeURI(url)).toString('base64')}`).toString());
|
||||||
}
|
//}
|
||||||
|
|
||||||
});
|
});
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
|
@ -957,6 +965,7 @@ export class BrowserWindow {
|
||||||
await utils.checkForUpdate();
|
await utils.checkForUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ipcMain.on('disable-update', (event) => {
|
ipcMain.on('disable-update', (event) => {
|
||||||
// Check if using app store builds so people don't get pissy wen button go bonk
|
// Check if using app store builds so people don't get pissy wen button go bonk
|
||||||
if (app.isPackaged && !process.mas || !process.windowsStore) {
|
if (app.isPackaged && !process.mas || !process.windowsStore) {
|
||||||
|
@ -966,6 +975,8 @@ export class BrowserWindow {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ipcMain.on('share-menu', async (_event, url) => {
|
ipcMain.on('share-menu', async (_event, url) => {
|
||||||
if (process.platform != 'darwin') return;
|
if (process.platform != 'darwin') return;
|
||||||
//https://www.electronjs.org/docs/latest/api/share-menu
|
//https://www.electronjs.org/docs/latest/api/share-menu
|
||||||
|
|
|
@ -3,6 +3,18 @@ import * as path from 'path';
|
||||||
import * as electron from 'electron'
|
import * as electron from 'electron'
|
||||||
import {utils} from './utils';
|
import {utils} from './utils';
|
||||||
|
|
||||||
|
//
|
||||||
|
// Hello, this our loader for the various plugins that the Cider Development Team built for our
|
||||||
|
// numerous plugins internally and ones made by the community
|
||||||
|
//
|
||||||
|
// To learn how to make your own, visit https://github.com/ciderapp/Cider/wiki/Plugins
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* @class
|
||||||
|
* Plugin Loading
|
||||||
|
* @author booploops#7139
|
||||||
|
* @see {@link https://github.com/ciderapp/Cider/wiki/Plugins|Documentation}
|
||||||
|
*/
|
||||||
export class Plugins {
|
export class Plugins {
|
||||||
private basePluginsPath = path.join(__dirname, '../plugins');
|
private basePluginsPath = path.join(__dirname, '../plugins');
|
||||||
private userPluginsPath = path.join(electron.app.getPath('userData'), 'Plugins');
|
private userPluginsPath = path.join(electron.app.getPath('userData'), 'Plugins');
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import {Store} from "./store";
|
import {Store} from "./store";
|
||||||
import {BrowserWindow as bw} from "./browserwindow";
|
import {BrowserWindow as bw} from "./browserwindow";
|
||||||
import {app, dialog} from "electron";
|
import {app, dialog, ipcMain, Notification, shell } from "electron";
|
||||||
import fetch from "electron-fetch";
|
import fetch from "electron-fetch";
|
||||||
import {AppImageUpdater, NsisUpdater} from "electron-updater";
|
import {AppImageUpdater, NsisUpdater} from "electron-updater";
|
||||||
import * as log from "electron-log";
|
import * as log from "electron-log";
|
||||||
|
@ -115,7 +115,13 @@ export class utils {
|
||||||
* Checks the application for updates
|
* Checks the application for updates
|
||||||
*/
|
*/
|
||||||
static async checkForUpdate(): Promise<void> {
|
static async checkForUpdate(): Promise<void> {
|
||||||
|
if (!app.isPackaged) {
|
||||||
|
new Notification({ title: "Application Update", body: "Can't update as app is in DEV mode. Please build or grab a copy by clicking me"})
|
||||||
|
.on('click', () => {shell.openExternal('https://download.cider.sh/?utm_source=app&utm_medium=dev-mode-warning')})
|
||||||
|
.show()
|
||||||
|
bw.win.webContents.send('update-response', "update-error")
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Get the artifacts
|
// Get the artifacts
|
||||||
const response = await fetch(`https://circleci.com/api/v1.1/project/gh/ciderapp/Cider/latest/artifacts?branch=${utils.getStoreValue('general.update_branch')}&filter=successful`)
|
const response = await fetch(`https://circleci.com/api/v1.1/project/gh/ciderapp/Cider/latest/artifacts?branch=${utils.getStoreValue('general.update_branch')}&filter=successful`)
|
||||||
if (response.status != 200) {
|
if (response.status != 200) {
|
||||||
|
@ -141,6 +147,10 @@ export class utils {
|
||||||
autoUpdater = await new AppImageUpdater(options) //Linux and Mac (AppImages work on macOS btw)
|
autoUpdater = await new AppImageUpdater(options) //Linux and Mac (AppImages work on macOS btw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
autoUpdater.on('checking-for-update', () => {
|
||||||
|
new Notification({ title: "Cider Update", body: "Cider is currently checking for updates."}).show()
|
||||||
|
})
|
||||||
|
|
||||||
autoUpdater.on('error', (error: any) => {
|
autoUpdater.on('error', (error: any) => {
|
||||||
console.error(`[AutoUpdater] Error: ${error}`)
|
console.error(`[AutoUpdater] Error: ${error}`)
|
||||||
bw.win.webContents.send('update-response', "update-error")
|
bw.win.webContents.send('update-response', "update-error")
|
||||||
|
@ -150,6 +160,9 @@ export class utils {
|
||||||
console.log('[AutoUpdater] Update not available.')
|
console.log('[AutoUpdater] Update not available.')
|
||||||
bw.win.webContents.send('update-response', "update-not-available");
|
bw.win.webContents.send('update-response', "update-not-available");
|
||||||
})
|
})
|
||||||
|
autoUpdater.on('download-progress', (event: any, progress: any) => {
|
||||||
|
bw.win.setProgressBar(progress.percent / 100)
|
||||||
|
})
|
||||||
|
|
||||||
autoUpdater.on('update-downloaded', (info: any) => {
|
autoUpdater.on('update-downloaded', (info: any) => {
|
||||||
console.log('[AutoUpdater] Update downloaded.')
|
console.log('[AutoUpdater] Update downloaded.')
|
||||||
|
@ -165,6 +178,9 @@ export class utils {
|
||||||
dialog.showMessageBox(dialogOpts).then((returnValue) => {
|
dialog.showMessageBox(dialogOpts).then((returnValue) => {
|
||||||
if (returnValue.response === 0) autoUpdater.quitAndInstall()
|
if (returnValue.response === 0) autoUpdater.quitAndInstall()
|
||||||
})
|
})
|
||||||
|
new Notification({ title: "Application Update", body: info}).on('click', () => {
|
||||||
|
bw.win.show()
|
||||||
|
}).show()
|
||||||
})
|
})
|
||||||
|
|
||||||
log.transports.file.level = "debug"
|
log.transports.file.level = "debug"
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {store} from './vuex-store.js';
|
||||||
Vue.use(VueHorizontal);
|
Vue.use(VueHorizontal);
|
||||||
Vue.use(VueObserveVisibility);
|
Vue.use(VueObserveVisibility);
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
/* @namespace */
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
store: store,
|
store: store,
|
||||||
data: {
|
data: {
|
||||||
|
@ -290,6 +290,13 @@ const app = new Vue({
|
||||||
this.lz = ipcRenderer.sendSync("get-i18n", lang)
|
this.lz = ipcRenderer.sendSync("get-i18n", lang)
|
||||||
this.mklang = await this.MKJSLang()
|
this.mklang = await this.MKJSLang()
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Grabs translation for localization.
|
||||||
|
* @param {string} message - The key to grab the translated term
|
||||||
|
* @param {object} options - Optional options
|
||||||
|
* @author booploops#7139
|
||||||
|
* @memberOf app
|
||||||
|
*/
|
||||||
getLz(message, options = {}) {
|
getLz(message, options = {}) {
|
||||||
if (this.lz[message]) {
|
if (this.lz[message]) {
|
||||||
if (options["count"]) {
|
if (options["count"]) {
|
||||||
|
@ -3993,6 +4000,8 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
checkForUpdate() {
|
checkForUpdate() {
|
||||||
ipcRenderer.send('check-for-update')
|
ipcRenderer.send('check-for-update')
|
||||||
|
document.getElementById('settings.option.general.updateCider.check').innerHTML = 'Checking...'
|
||||||
|
notyf.success('Checking for update in background...')
|
||||||
ipcRenderer.on('update-response', (event, res) => {
|
ipcRenderer.on('update-response', (event, res) => {
|
||||||
if (res === "update-not-available") {
|
if (res === "update-not-available") {
|
||||||
notyf.error(app.getLz(`settings.notyf.updateCider.${res}`))
|
notyf.error(app.getLz(`settings.notyf.updateCider.${res}`))
|
||||||
|
@ -4003,7 +4012,7 @@ const app = new Vue({
|
||||||
} else if (res === "update-timeout") {
|
} else if (res === "update-timeout") {
|
||||||
notyf.error(app.getLz(`settings.notyf.updateCider.${res}`))
|
notyf.error(app.getLz(`settings.notyf.updateCider.${res}`))
|
||||||
}
|
}
|
||||||
|
document.getElementById('settings.option.general.updateCider.check').innerHTML = app.getLz('term.check')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,7 +731,7 @@
|
||||||
{{$root.getLz('settings.option.general.updateCider')}}
|
{{$root.getLz('settings.option.general.updateCider')}}
|
||||||
</div>
|
</div>
|
||||||
<div class="md-option-segment md-option-segment_auto">
|
<div class="md-option-segment md-option-segment_auto">
|
||||||
<button class="md-btn" @click="app.checkForUpdate()">
|
<button class="md-btn" id='settings.option.general.updateCider.check' @click="app.checkForUpdate()">
|
||||||
{{$root.getLz('term.check')}}
|
{{$root.getLz('term.check')}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue