Skip to content

Commit

Permalink
fix: test autoUpdater const
Browse files Browse the repository at this point in the history
  • Loading branch information
truemiller committed Oct 3, 2024
1 parent f0d8ebd commit a59bf8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
11 changes: 5 additions & 6 deletions electron/components/PearlOTA.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down
34 changes: 4 additions & 30 deletions electron/constants/config.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
*/

Expand All @@ -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,
};

0 comments on commit a59bf8d

Please sign in to comment.