first tests with autoupdater
This commit is contained in:
parent
e887064533
commit
ea70c69240
9
build.js
9
build.js
@ -6,7 +6,7 @@ const Platform = builder.Platform
|
|||||||
* @type {import('electron-builder').Configuration}
|
* @type {import('electron-builder').Configuration}
|
||||||
*/
|
*/
|
||||||
const options = {
|
const options = {
|
||||||
appId: 'com.app.id',
|
appId: 'com.stratum.crunchyrolldownloader',
|
||||||
productName: 'Crunchyroll Downloader',
|
productName: 'Crunchyroll Downloader',
|
||||||
|
|
||||||
compression: 'maximum',
|
compression: 'maximum',
|
||||||
@ -15,13 +15,18 @@ const options = {
|
|||||||
nodeGypRebuild: true,
|
nodeGypRebuild: true,
|
||||||
buildDependenciesFromSource: true,
|
buildDependenciesFromSource: true,
|
||||||
|
|
||||||
|
publish: {
|
||||||
|
provider: 'github',
|
||||||
|
releaseType: 'release'
|
||||||
|
},
|
||||||
|
|
||||||
directories: {
|
directories: {
|
||||||
output: 'crunchyroll-downloader-output-${version}'
|
output: 'crunchyroll-downloader-output-${version}'
|
||||||
},
|
},
|
||||||
|
|
||||||
win: {
|
win: {
|
||||||
artifactName: 'crunchyroll-downloader-${version}-windows-installer.${ext}',
|
artifactName: 'crunchyroll-downloader-${version}-windows-installer.${ext}',
|
||||||
icon: "public/favicon.ico",
|
icon: 'public/favicon.ico',
|
||||||
target: [
|
target: [
|
||||||
{
|
{
|
||||||
target: 'nsis',
|
target: 'nsis',
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": ".output/src/electron/background.js",
|
"main": ".output/src/electron/background.js",
|
||||||
|
"repository": "https://github.com/stratuma/Crunchyroll-Downloader-v4.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxt dev -o",
|
"dev": "nuxt dev -o",
|
||||||
"build": "nuxt generate",
|
"build": "nuxt generate",
|
||||||
|
@ -2,27 +2,14 @@ import { BrowserWindow, ipcMain } from 'electron'
|
|||||||
import { autoUpdater } from 'electron-updater'
|
import { autoUpdater } from 'electron-updater'
|
||||||
import log from 'electron-log'
|
import log from 'electron-log'
|
||||||
|
|
||||||
// Logger
|
|
||||||
// ======
|
|
||||||
autoUpdater.logger = log
|
autoUpdater.logger = log
|
||||||
;(autoUpdater.logger as typeof log).transports.file.level = 'info'
|
;(autoUpdater.logger as typeof log).transports.file.level = 'info'
|
||||||
|
|
||||||
// Config
|
|
||||||
// ======
|
|
||||||
autoUpdater.autoDownload = true
|
autoUpdater.autoDownload = true
|
||||||
autoUpdater.autoInstallOnAppQuit = true
|
autoUpdater.autoInstallOnAppQuit = true
|
||||||
|
|
||||||
// Module
|
|
||||||
// ======
|
|
||||||
export default (mainWindow: BrowserWindow) => {
|
export default (mainWindow: BrowserWindow) => {
|
||||||
const isMac = process.platform === 'darwin'
|
|
||||||
if (isMac) {
|
|
||||||
autoUpdater.autoDownload = false
|
|
||||||
autoUpdater.autoInstallOnAppQuit = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helpers
|
|
||||||
// =======
|
|
||||||
let readyToInstall = false
|
let readyToInstall = false
|
||||||
function sendUpdaterStatus(...args: any[]) {
|
function sendUpdaterStatus(...args: any[]) {
|
||||||
mainWindow.webContents.send('updater:statusChanged', args)
|
mainWindow.webContents.send('updater:statusChanged', args)
|
||||||
@ -49,8 +36,6 @@ export default (mainWindow: BrowserWindow) => {
|
|||||||
readyToInstall = true
|
readyToInstall = true
|
||||||
})
|
})
|
||||||
|
|
||||||
// IPC Listeners
|
|
||||||
// =============
|
|
||||||
ipcMain.handle('updater:check', async (_event) => {
|
ipcMain.handle('updater:check', async (_event) => {
|
||||||
return await autoUpdater.checkForUpdates()
|
return await autoUpdater.checkForUpdates()
|
||||||
})
|
})
|
||||||
@ -62,7 +47,6 @@ export default (mainWindow: BrowserWindow) => {
|
|||||||
|
|
||||||
autoUpdater.checkForUpdates()
|
autoUpdater.checkForUpdates()
|
||||||
|
|
||||||
// Check for updates every 2 hours
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
autoUpdater.checkForUpdates()
|
autoUpdater.checkForUpdates()
|
||||||
}, 1000 * 60 * 60 * 2)
|
}, 1000 * 60 * 60 * 2)
|
||||||
|
Reference in New Issue
Block a user