update the updates doc

This commit is contained in:
Zeke Sikelianos 2017-08-14 13:26:33 -07:00
parent 235ae0989f
commit 6a872dd938

View file

@ -1,31 +1,47 @@
# Updating Applications
There are several ways to update an Electron application. The easiest and officially supported one is taking advantage of the built-in [Squirrel](https://github.com/Squirrel) framework and the [autoUpdater](../api/auto-updater.md) module that comes with it.
There are several ways to update an Electron application. The easiest and
officially supported one is taking advantage of the built-in
[Squirrel](https://github.com/Squirrel) framework and
Electron's [autoUpdater](../api/auto-updater.md) module.
## Deploying an Update Server
## Deploying an update server
To get started, you firstly need to deploy an update server (that's where the [autoUpdater](../api/auto-updater.md) module will download new updates from).
To get started, you first need to deploy a server that the
[autoUpdater](../api/auto-updater.md) module will download new updates from.
Depending on your needs, you can choose from one of these:
- [Hazel](https://github.com/zeit/hazel) Pulls new releases from [GitHub Releases](https://help.github.com/articles/creating-releases/) and is **perfect for getting started**
- [Nuts](https://github.com/GitbookIO/nuts) Also uses [GitHub Releases](https://help.github.com/articles/creating-releases/), but caches app updates on disk and supports private repositories
- [electron-release-server](https://github.com/ArekSredzki/electron-release-server) Provides you with a dashboard for handling releases
- [Hazel](https://github.com/zeit/hazel) Pulls new releases from
[GitHub Releases](https://help.github.com/articles/creating-releases/) and can
be deployed for free on the [Now](https://zeit.co/now) hosting platform.
- [Nuts](https://github.com/GitbookIO/nuts) Also uses
[GitHub Releases](https://help.github.com/articles/creating-releases/),
but caches app updates on disk and supports private repositories.
- [electron-release-server](https://github.com/ArekSredzki/electron-release-server)
Provides a dashboard for handling releases
## Implementing Updates into Your App
## Implementing updates in your app
Once you've deployed your update server, continue with importing the required modules in your code (the following code might vary for different server software, but it works like described when using [Hazel](https://github.com/zeit/hazel)).
Once you've deployed your update server, continue with importing the required
modules in your code. The following code might vary for different server
software, but it works like described when using
[Hazel](https://github.com/zeit/hazel).
**Important:** Please ensure that the code below will only be executed in production - you can use [electron-is-dev](https://github.com/sindresorhus/electron-is-dev) to check for the environment).
**Important:** Please ensure that the code below will only be executed in
your packaged app. You can use
[electron-is-dev](https://github.com/sindresorhus/electron-is-dev) to check for
the environment.
```js
const { app, autoUpdater } = require('electron')
```
Next, put together the URL of the update server and tell [autoUpdater](../api/auto-updater.md) about it:
Next, construct the URL of the update server and tell
[autoUpdater](../api/auto-updater.md) about it:
```js
const server = <your-deployment-url>
const server = 'https://your-deployment-url.com'
const feed = `${server}/update/${process.platform}/${app.getVersion()}`
autoUpdater.setFeedURL(feed)
@ -39,10 +55,16 @@ setInterval(() => {
}, 60000)
```
That's all. Once [built](../tutorial/application-distribution.md), your application will receive an update for each new [GitHub Release](https://help.github.com/articles/creating-releases/) that you create.
That's all. Once [built](../tutorial/application-distribution.md), your
application will receive an update for each new
[GitHub Release](https://help.github.com/articles/creating-releases/) that you
create.
## Further Steps
## Further steps
Now that you've configured the basic update mechanism for your application, you need to ensure that the user will get notified when there's an update (this can be achieved using [events](../api/auto-updater.md#events)).
Now that you've configured the basic update mechanism for your application, you
need to ensure that the user will get notified when there's an update
(this can be achieved using [events](../api/auto-updater.md#events)).
Also make sure that potential errors are [being handled](../api/auto-updater.md#event-error).
Also make sure that potential errors are
[being handled](../api/auto-updater.md#event-error).