Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Autoupdate overhaul #435

Merged
merged 3 commits into from
Mar 5, 2018
Merged

Autoupdate overhaul #435

merged 3 commits into from
Mar 5, 2018

Conversation

dpgraham
Copy link
Contributor

@dpgraham dpgraham commented Mar 2, 2018

  • Added zeit server (https://hazel-server-pxufsrwofl.now.sh/)
  • Switched from electron-userland/builder to native autoupdate
    • Need to use native to use zeit
    • Ripped out React components and just use native dialogs for autoupdate notifications
    • Process is:
      • Checks for update
      • If update available show notification saying so
      • If accepted, call autoupdate.checkForUpdates() and wait for download
      • When download complete ask user to restart app
  • Checks for updates every hour and 10 seconds after first startup

(also related to https://github.com/appium/appium-desktop/issues/266)

autoUpdater.emit('update-not-available');
} else {
// If no updates found check for updates every hour
await B.delay(60 * 1000);
Copy link
Contributor

Choose a reason for hiding this comment

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

is the interval in seconds or millis?

Copy link
Contributor

Choose a reason for hiding this comment

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

why don't we use setTimeout?

Copy link
Member

Choose a reason for hiding this comment

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

ms; setTimeout does not return a promise and can't be awaited

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to 60 * 60 * 1000 so that it checks for updates every hour and not every minute.

const res = await request.get(getFeedUrl(currentVersion));
if (res) {
return JSON.parse(res);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

else is redundant

import { getFeedUrl } from './config';

export async function getUpdate (currentVersion) {
const res = await request.get(getFeedUrl(currentVersion));
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this may throw an exception in case of request failure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Good catch. It should return false on error.

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

love it

import AppiumMethodHandler from './appium-method-handler';
import request from 'request-promise';
import { checkNewUpdates } from './auto-updater/auto-updater';
Copy link
Member

Choose a reason for hiding this comment

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

if you rename it to index.js you can just do from './auto-updater';

const update = await getUpdate(app.getVersion());
if (update) {
let {name, notes, pub_date} = update;
pub_date = moment(pub_date).format('MMM Do YYYY, h:mma');
Copy link
Member

Choose a reason for hiding this comment

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

even if update really has to have snake_case, we should name our own variables using camelCase

@@ -0,0 +1,8 @@
const config = {
baseFeedUrl: `https://hazel-server-pxufsrwofl.now.sh`,
Copy link
Member

Choose a reason for hiding this comment

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

is this a stable url? should we pay for the ability to run it on say update.appium.io?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jlipps It's hosted by https://zeit.co/now... not sure how stable that is. I ran this server by following the instructions on zeit/hazel git page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The URL itself is permanent and I'm pretty sure the server should be up-and-running permanently; if it ever were taken down, I think we would get notice first.


before(async function () {
const latestReleaseUrl = `https://api.github.com/repos/appium/appium-desktop/releases/latest`;
const res = JSON.parse(await request.get(latestReleaseUrl, { headers: {'user-agent': 'node.js'} }));
Copy link
Member

Choose a reason for hiding this comment

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

{headers: {'user-agent': 'node.js'}}

@dpgraham dpgraham force-pushed the dpgraham-autocomplete-overhaul branch from f70ec43 to df679fc Compare March 3, 2018 21:19
* Native autoUpdater downloads updates automatically
* We want to be able to check if updates are available first
* So, make a call to /update endpoint directly and pass in the version to check if there's an update available
* Use the native electron dialogs instead of using a custom React workflow
* Right now it automatically downloads it
* Next step will be to check for availability first before proceeding to download
@dpgraham dpgraham force-pushed the dpgraham-autocomplete-overhaul branch from df04fae to 5167875 Compare March 4, 2018 22:03
@dpgraham
Copy link
Contributor Author

dpgraham commented Mar 5, 2018

@jlipps Is this good to merge?

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

just one question, otherwise LGTM

@@ -1,5 +1,5 @@
environment:
nodejs_version: "6"
nodejs_version: "7"
Copy link
Member

Choose a reason for hiding this comment

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

why 7 and not 8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

8 caused the issues with WebDriverAgent privateheaders

Copy link
Member

Choose a reason for hiding this comment

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

ok

@dpgraham dpgraham merged commit d7537bb into master Mar 5, 2018
@dpgraham dpgraham deleted the dpgraham-autocomplete-overhaul branch March 5, 2018 23:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants