From c6a43aaa23c8d1593b172a5214f32981dfe038ed Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Wed, 29 Nov 2023 12:43:50 +0000 Subject: [PATCH 1/2] better logging of updates and added update checks to dev --- .vscode/launch.json | 44 +++++++++++++++++++++ src/extensions/updater/SettingsUpdate.tsx | 4 +- src/extensions/updater/autoupdater.ts | 47 +++++++++++++++-------- src/extensions/updater/index.ts | 11 +++++- 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e666c20dd..4992fa4f3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,6 +14,19 @@ }, "stopAll": true }, + { + "name": "Debug Electron (Next)", + "configurations": [ + "Debug Main Process (Next)", + "Debug Renderer Process" + ], + "presentation": { + "hidden": false, + "group": "", + "order": 1 + }, + "stopAll": true + }, { "name": "Debug Electron (Staging)", "configurations": [ @@ -131,6 +144,37 @@ "sourceMaps": true, "outFiles": [] }, + { + "name": "Debug Main Process (Next)", + "type": "node", + "request": "launch", + "program": "${workspaceFolder}/out/main.js", + "cwd": "${workspaceRoot}", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", + "windows": { + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" + }, + "runtimeArgs": [ + "--no-sandbox", + "--remote-debugging-port=9230", + "--enable-logging", + "." + ], + "env": { + "NODE_ENV": "development", + "SIMULATE_FS_ERRORS": "false", + "HIGHLIGHT_I18N": "false", + "BLUEBIRD_DEBUG": "0", + "FORCE_ALLOW_ELEVATED_SYMLINKING": "true", + "DEBUG_REACT_RENDERS": "false", + "START_DEVTOOLS": "true", + "IS_PREVIEW_BUILD": "true" + }, + "envFile": "${workspaceFolder}/.env", + "console": "integratedTerminal", + "sourceMaps": true, + "outFiles": [] + }, { "name": "Debug Main Process (Staging)", "type": "node", diff --git a/src/extensions/updater/SettingsUpdate.tsx b/src/extensions/updater/SettingsUpdate.tsx index f0916c1b3..99326c7cc 100644 --- a/src/extensions/updater/SettingsUpdate.tsx +++ b/src/extensions/updater/SettingsUpdate.tsx @@ -56,6 +56,7 @@ class SettingsUpdate extends ComponentEx { + {updateChannel === 'none' ? [( @@ -72,7 +73,8 @@ class SettingsUpdate extends ComponentEx { } private checkNow = () => { - ipcRenderer.send('check-for-updates', 'stable'); + // send what updateChannel you are on, unless it's none, then send stable + ipcRenderer.send('check-for-updates', this.props.updateChannel === 'none' ? 'stable' : this.props.updateChannel); } private selectChannel = (evt) => { diff --git a/src/extensions/updater/autoupdater.ts b/src/extensions/updater/autoupdater.ts index d85d1dce6..4bda31beb 100644 --- a/src/extensions/updater/autoupdater.ts +++ b/src/extensions/updater/autoupdater.ts @@ -70,9 +70,9 @@ function setupAutoUpdate(api: IExtensionApi) { const state: () => IState = () => api.store.getState(); let notified: boolean = false; let channelOverride: UpdateChannel; - if (process.env['IS_PREVIEW_BUILD'] === 'yes') { - log('info', 'forcing update channel for preview builds so that we don\'t automatically ' - + 'downgrade'); + + if (process.env.IS_PREVIEW_BUILD === 'true') { + log('info', 'forcing update channel for preview builds so that we don\'t automatically downgrade'); api.store.dispatch(setUpdateChannel('next')); } else if (state().settings.update.channel === 'next') { api.store.dispatch(setUpdateChannel('beta')); @@ -80,6 +80,7 @@ function setupAutoUpdate(api: IExtensionApi) { const queryUpdate = (version: string): Promise => { return new Promise((resolve, reject) => { + if (semver.satisfies(version, '^' + autoUpdater.currentVersion.version)) { // don't warn on a "compatible" update return resolve(); @@ -91,7 +92,7 @@ function setupAutoUpdate(api: IExtensionApi) { id: 'vortex-update-notification', type: 'info', title: 'Major update available', - message: 'After installing this update you shouldn\'t go back to an older version.', + message: `(${version}) After installing this update you shouldn't go back to an older version.`, noDismiss: true, actions: [ { @@ -153,7 +154,7 @@ function setupAutoUpdate(api: IExtensionApi) { }); autoUpdater.on('update-available', (info: UpdateInfo) => { - log('info', 'found update available', info.version); + log('info', 'found update available', info); const installedVersion = semver.parse(getApplication().version); const version = semver.parse(info.version); @@ -240,7 +241,7 @@ function setupAutoUpdate(api: IExtensionApi) { type: 'success', message: 'Update available', actions: [ - { + /*{ title: 'Changelog', action: () => { api.store.dispatch(showDialog('info', `Changelog ${info.version}`, { @@ -249,7 +250,7 @@ function setupAutoUpdate(api: IExtensionApi) { { label: 'Close' }, ])); }, - }, + },*/ { title: 'Restart & Install', action: () => { @@ -265,9 +266,11 @@ function setupAutoUpdate(api: IExtensionApi) { if (!state().session.base.networkConnected) { log('info', 'Not checking for updates because network is offline'); } - log('info', 'checking for vortex update'); + + log('info', 'checking for vortex update:', channel); const didOverride = channelOverride !== undefined; - autoUpdater.allowPrerelease = channel !== 'stable'; + autoUpdater.allowPrerelease = channel !== 'stable'; + autoUpdater.setFeedURL({ provider: 'github', owner: 'Nexus-Mods', @@ -275,18 +278,32 @@ function setupAutoUpdate(api: IExtensionApi) { private: false, publisherName: [ 'Black Tree Gaming Limited', - 'Black Tree Gaming Ltd'], + 'Black Tree Gaming Ltd' + ], }); autoUpdater.allowDowngrade = true; autoUpdater.autoDownload = false; + + log('info', 'update config is ', { + provider: 'github', + owner: 'Nexus-Mods', + repo: channel === 'next' ? 'Vortex-Next' : 'Vortex', + allowPrerelease: channel !== 'stable' + }); + autoUpdater.checkForUpdates() .then(check => { log('info', 'completed update check'); - if (truthy(check.downloadPromise)) { - check.downloadPromise.catch(err => { - log('warn', 'Checking for update failed', err); - }); - } + + // do a check here for if a regular type (properly installed, not dev or epic or whatever) + // then that's the only time that we want to do the auto download + if (api.getState().app.installType === 'regular') { + if (truthy(check.downloadPromise)) { + check.downloadPromise.catch(err => { + log('warn', 'Checking for update failed', err); + }); + } + } if (!didOverride && (channelOverride !== undefined)) { return checkNow(channelOverride); diff --git a/src/extensions/updater/index.ts b/src/extensions/updater/index.ts index bf508ebfc..caf27af8c 100644 --- a/src/extensions/updater/index.ts +++ b/src/extensions/updater/index.ts @@ -12,13 +12,22 @@ function init(context: IExtensionContext): boolean { context.registerSettings('Vortex', SettingsUpdate); context.onceMain(() => { + try { - if (context.api.getState().app.installType === 'regular') { + if (context.api.getState().app.installType === 'regular' || + process.env.NODE_ENV === 'development' + ) { setupAutoUpdater(context.api); } } catch (err) { log('error', 'failed to check for update', err.message); } + + log('info', 'updater config', { + isPreviewBuild: process.env.IS_PREVIEW_BUILD, + installType: context.api.getState().app.installType, + updateChannel: context.api.getState().settings.update.channel + }); }); context.once(() => { From bbc1f72a5018b9b623b2d31ede555cbfdc8ad381 Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Wed, 29 Nov 2023 14:54:31 +0000 Subject: [PATCH 2/2] added alerts for dev and preview modes --- src/extensions/updater/SettingsUpdate.tsx | 62 +++++++++++++++++++---- src/extensions/updater/autoupdater.ts | 15 ++++-- src/extensions/updater/index.ts | 5 +- 3 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/extensions/updater/SettingsUpdate.tsx b/src/extensions/updater/SettingsUpdate.tsx index 99326c7cc..4d68f89fa 100644 --- a/src/extensions/updater/SettingsUpdate.tsx +++ b/src/extensions/updater/SettingsUpdate.tsx @@ -27,26 +27,64 @@ class SettingsUpdate extends ComponentEx { public render(): JSX.Element { const { t, installType, updateChannel } = this.props; + const renderDevelopmentAlert = () => { + if(process.env.NODE_ENV === 'development') + return ( +
+ + + {t('Vortex is running in development mode and version will always remain at 0.0.1. Updates will be checked but they won\'t be downloaded or installed.')} + + +
+ ); + return null; + } + + const renderPreviewAlert = () => { + if(updateChannel === 'next') + return ( +
+ + + {t('Vortex is running in preview mode and using the hidden \'next\' update channel.')} + + +
+ ); + return null; + } + + // managed or development if (installType === 'managed') { - return ( - - {t('Update')} - - {t('Vortex was installed through a third-party service which will take care of updating it.')} - - - ); + + // managed and not development + if(process.env.NODE_ENV !== 'development') { + return ( + + + {t('Vortex was installed through a third-party service which will take care of updating it.')} + + + ); + } + + // managed and development + } + // regular return ( -
+ + {t('Update')} {getText('update-channel', t)} - + + { + + { renderPreviewAlert() } + + { renderDevelopmentAlert() } {updateChannel === 'none' ? [( diff --git a/src/extensions/updater/autoupdater.ts b/src/extensions/updater/autoupdater.ts index 4bda31beb..d0a9607b0 100644 --- a/src/extensions/updater/autoupdater.ts +++ b/src/extensions/updater/autoupdater.ts @@ -78,6 +78,8 @@ function setupAutoUpdate(api: IExtensionApi) { api.store.dispatch(setUpdateChannel('beta')); } + log('info', 'setupAutoUpdate complete'); + const queryUpdate = (version: string): Promise => { return new Promise((resolve, reject) => { @@ -320,14 +322,17 @@ function setupAutoUpdate(api: IExtensionApi) { ipcMain.on('set-update-channel', (event, channel: any, manual: boolean) => { try { - log('info', 'set channel', { channel, manual }); - if ((channel !== 'none') - && ((channelOverride === undefined) || manual) - && (process.env.NODE_ENV !== 'development') - && (process.env.IGNORE_UPDATES !== 'yes')) { + log('info', 'set channel', { channel, manual, channelOverride }); + + if ((channel !== 'none') + && ((channelOverride === undefined) || manual) + //&& (process.env.NODE_ENV !== 'development') + && (process.env.IGNORE_UPDATES !== 'yes')) { + if (manual) { channelOverride = channel; } + checkNow(channel); } } catch (err) { diff --git a/src/extensions/updater/index.ts b/src/extensions/updater/index.ts index caf27af8c..dcdf386f2 100644 --- a/src/extensions/updater/index.ts +++ b/src/extensions/updater/index.ts @@ -31,7 +31,10 @@ function init(context: IExtensionContext): boolean { }); context.once(() => { - if (context.api.getState().app.installType !== 'regular') { + + + if (context.api.getState().app.installType !== 'regular' && + process.env.NODE_ENV !== 'development') { return; }