From a59bf8dceb69e3d8ed49561a8bbee962b43f4ffd Mon Sep 17 00:00:00 2001 From: truemiller Date: Thu, 3 Oct 2024 02:34:43 +0100 Subject: [PATCH] fix: test autoUpdater const --- electron/components/PearlOTA.js | 11 +++++------ electron/constants/config.js | 34 ++++----------------------------- 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/electron/components/PearlOTA.js b/electron/components/PearlOTA.js index 4cbbd823..75c348e1 100644 --- a/electron/components/PearlOTA.js +++ b/electron/components/PearlOTA.js @@ -1,8 +1,8 @@ const { ipcMain } = require('electron'); -const { MacUpdater, NsisUpdater } = require('electron-updater'); +const { autoUpdater } = require('electron-updater'); const { logger } = require('../logger'); -const { isWindows, isMac } = require('../constants'); -const { githubUpdateOptions } = require('../constants/config'); +// const { isWindows, isMac } = require('../constants'); +// const { githubUpdateOptions } = require('../constants/config'); /** Over-the-air update manager * @example @@ -16,12 +16,11 @@ const { githubUpdateOptions } = require('../constants/config'); */ class PearlOTA { /** - * @type {MacUpdater | NsisUpdater | null} */ + * @type {import('electron-updater').AppUpdater} */ updater = null; constructor() { - if (isWindows) this.updater = new NsisUpdater(githubUpdateOptions); - if (isMac) this.updater = new MacUpdater(githubUpdateOptions); + this.updater = autoUpdater; if (this.updater) { this.updater.autoDownload = false; diff --git a/electron/constants/config.js b/electron/constants/config.js index d7f75ec5..7a45e31e 100644 --- a/electron/constants/config.js +++ b/electron/constants/config.js @@ -1,14 +1,6 @@ const { isDev } = require('../constants'); require('dotenv').config(); -/** - * GitHub publish options - * @see https://www.electron.build/auto-update#githuboptions - * @type {{ - * releaseType: 'draft' | 'prerelease' | 'release', - * token?: string - * } & PearlGithubUpdateOptions} - */ /** * Pearl GitHub publish options type definition @@ -21,8 +13,10 @@ require('dotenv').config(); * channel: string, * vPrefixedTagName: boolean, * protocol: "https" | "http", - * token?: string, * releaseType: 'draft' | 'prerelease' | 'release', + * private: boolean, + * token?: string, + * allowPrerelease: boolean, * }} PearlGithubPublishOptions */ @@ -37,31 +31,11 @@ const githubPublishOptions = { publishAutoUpdate: true, // Publishes the update to GitHub vPrefixedTagName: true, protocol: 'https', - channel: isDev ? 'dev' : 'latest', // Github only supports latest, dev stops overwrite -}; - -/** - * Pearl GitHub update options type definition - * @see https://www.electron.build/auto-update#githuboptions - * @typedef {{ - * private: boolean, - * token?: string, - * allowPrerelease: boolean, - * } & PearlGithubPublishOptions} PearlGithubUpdateOptions - */ - -/** - * GitHub update options - * @see https://www.electron.build/auto-update#githuboptions - * @type {PearlGithubUpdateOptions} - */ -const githubUpdateOptions = { - ...githubPublishOptions, + channel: isDev ? 'dev' : 'latest', // Github only supports latest, dev stops overwrite, private: false, // Only set to true if the repo is private allowPrerelease: true, // Allow pre-release versions to be installed }; module.exports = { - githubUpdateOptions, githubPublishOptions, };