Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix updater #1407

Merged
merged 9 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down
56 changes: 56 additions & 0 deletions app/main/updater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to show release notes for the particular version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did investigate this option, but decided against it for several reasons:

  • The raw release notes string requires post-processing to make it readable (remove HTML tags with regex, handle multi-level bullet points, etc)
  • The release notes can get quite large and cause the floating box buttons to go out of bounds, preventing any user interaction. I mainly observed this with the raw release notes string, but there is still a possibility that it can apply to the post-processed notes in the future. A quick search for scrolling options inside this box also didn't give me any results.
  • The user may skip one or more versions during the update, and showing the changelog only for the most recent version is not sufficient, in my opinion

Still, the floating box does have another problem - it cannot render clickable links, so the link shown here is unfortunately just text.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not very useful if it is just a text.
Anyway, I believe we could still show release notes nicely either by creating a HTML view or just using something link html-to-text to render it as a text and have scrolling there. Not for this PR though

});
if (response === 0) {
dialog.showMessageBox({
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
type: 'info',
buttons: [t('OK')],
message: t('updateIsBeingDownloaded'),
});
autoUpdater.downloadUpdate();
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
}
});

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