Skip to content

Commit

Permalink
fix: fix updater (#1407)
Browse files Browse the repository at this point in the history
* start some autoupdater adjustments

* WIP: feat: use electron-updater for checking updates

* chore: move t function to helpers

* fix: improve presentation of update message boxes

* chore: remove old updater code

* chore: remove more old updater code

* docs: fix references to updater

* chore: add comment to clarify download behavior
  • Loading branch information
eglitise committed Apr 5, 2024
1 parent 9e54c76 commit 9100b2d
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 272 deletions.
9 changes: 0 additions & 9 deletions app/main/auto-updater/config.js

This file was deleted.

36 changes: 0 additions & 36 deletions app/main/auto-updater/index.js

This file was deleted.

126 changes: 0 additions & 126 deletions app/main/auto-updater/update-checker.js

This file was deleted.

4 changes: 4 additions & 0 deletions app/main/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import i18n from '../configs/i18next.config';

const APPIUM_SESSION_FILE_VERSION = '1.0';

export function getAppiumSessionFilePath(argv, isPackaged, isDev) {
Expand Down Expand Up @@ -26,4 +28,6 @@ export function getSaveableState(reduxState) {
};
}

export const t = (string, params = null) => i18n.t(string, params);

export const APPIUM_SESSION_EXTENSION = 'appiumsession';
10 changes: 4 additions & 6 deletions app/main/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {Menu, app, dialog, shell} from 'electron';

import {languageList} from '../configs/app.config';
import i18n from '../configs/i18next.config';
import {checkNewUpdates} from './auto-updater';
import {APPIUM_SESSION_EXTENSION} from './helpers';
import {checkForUpdates} from './updater';
import {APPIUM_SESSION_EXTENSION, t} from './helpers';
import {launchNewSessionWindow} from './windows';

const INSPECTOR_DOCS_URL = 'https://appium.github.io/appium-inspector';
Expand All @@ -12,8 +12,6 @@ const APPIUM_FORUM_URL = 'https://discuss.appium.io';
const GITHUB_ISSUES_URL = 'https://github.com/appium/appium-inspector/issues';
const CROWDIN_URL = 'https://crowdin.com/project/appium-desktop';

const t = (string, params = null) => i18n.t(string, params);

const separator = {type: 'separator'};

function showAppInfoPopup() {
Expand All @@ -40,7 +38,7 @@ async function openFile(mainWindow) {

async function saveAs(mainWindow) {
const {canceled, filePath} = await dialog.showSaveDialog({
title: i18n.t('saveAs'),
title: t('saveAs'),
filters: [{name: 'Appium', extensions: [APPIUM_SESSION_EXTENSION]}],
});
if (!canceled) {
Expand All @@ -67,7 +65,7 @@ function optionAbout() {
function optionCheckForUpdates() {
return {
label: t('Check for Updates…'),
click: () => checkNewUpdates(true),
click: () => checkForUpdates(),
};
}

Expand Down
57 changes: 57 additions & 0 deletions app/main/updater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {dialog} from 'electron';
import {autoUpdater} from 'electron-updater';

import {t} from './helpers';

const RELEASES_LINK = 'https://github.com/appium/appium-inspector/releases';

autoUpdater.autoDownload = false;
autoUpdater.autoInstallOnAppQuit = false;

autoUpdater.on('error', (error) => {
dialog.showErrorBox(t('Could not download update'), t('updateDownloadFailed', {message: error}));
});

autoUpdater.on('update-not-available', () => {
dialog.showMessageBox({
type: 'info',
buttons: [t('OK')],
message: t('No update available'),
detail: t('Appium Inspector is up-to-date'),
});
});

autoUpdater.on('update-available', async ({version, releaseDate}) => {
const pubDate = new Date(releaseDate).toDateString();
const {response} = await dialog.showMessageBox({
type: 'info',
message: t('appiumIsAvailable', {name: version}),
buttons: [t('Install Now'), t('Install Later')],
detail: t('updateDetails', {pubDate, notes: RELEASES_LINK}),
});
if (response === 0) {
// download is started without waiting for the dialog box to be dismissed
dialog.showMessageBox({
type: 'info',
buttons: [t('OK')],
message: t('updateIsBeingDownloaded'),
});
autoUpdater.downloadUpdate();
}
});

autoUpdater.on('update-downloaded', async ({releaseName}) => {
const {response} = await dialog.showMessageBox({
type: 'info',
buttons: [t('Restart Now'), t('Later')],
message: t('Update Downloaded'),
detail: t('updateIsDownloaded', {releaseName}),
});
if (response === 0) {
autoUpdater.quitAndInstall();
}
});

export function checkForUpdates() {
autoUpdater.checkForUpdates();
}
7 changes: 0 additions & 7 deletions app/renderer/actions/Updater.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/renderer/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as inspectorActions from './Inspector';
import * as sessionActions from './Session';
import * as updaterActions from './Updater';

export default {
...inspectorActions,
...sessionActions,
...updaterActions,
};
12 changes: 0 additions & 12 deletions app/renderer/reducers/Updater.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/renderer/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import {combineReducers} from '@reduxjs/toolkit';

import inspector from './Inspector';
import session from './Session';
import updater from './Updater';

// create our root reducer
export default function createRootReducer() {
return combineReducers({
session,
inspector,
updater,
});
}
1 change: 0 additions & 1 deletion assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"Save Server Arguments Preset": "Save Server Arguments Preset",
"Save": "Save",
"Cancel": "Cancel",
"datetimeFormat": "MMM Do YYYY, h:mma",
"updateDetails": "Release Date: {{pubDate}}\n\nRelease Notes: {{notes}}",
"appiumIsAvailable": "Appium Inspector {{name}} is available",
"updateIsBeingDownloaded": "Update is being downloaded now. You will be notified again when it is complete",
Expand Down
10 changes: 6 additions & 4 deletions docs/menu-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ However, there are a few specific options as well:

## Update Checker

!!! warning

[This functionality is currently unavailable.](./troubleshooting.md#auto-updater-not-working)

The update checker is available under the _File_ menu (Windows/Linux) or the application menu
(macOS). It can be used to check if there is a newer version of the Inspector available, and if so,
it is possible to automatically download and install the latest version.

Updating is supported for the following application formats:

- macOS: `.dmg`
- Windows: `.exe` installer
- Linux: `.AppImage`

## Open/Save Session

The _Open Session File_ / _Save As_ options in the _File_ menu provides the ability to import and
Expand Down
5 changes: 0 additions & 5 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ This page aims to act as a reference for issues that may be encountered when usi

Please refer to the [Installation guide](./quickstart/installation.md).

## Auto-updater not working

This is [a known issue](https://github.com/appium/appium-inspector/issues/733) and is planned to be
fixed in future versions.

## Cannot start a session using browser Inspector

The reason for this issue is [cross-origin resource sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
Expand Down
1 change: 0 additions & 1 deletion env/.env-dev.js

This file was deleted.

6 changes: 0 additions & 6 deletions env/.env-nsis.js

This file was deleted.

7 changes: 0 additions & 7 deletions env/.env.js

This file was deleted.

1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9100b2d

Please sign in to comment.