📝 Documenting updates
This commit is contained in:
parent
fe4762588c
commit
eeb5845aac
1 changed files with 30 additions and 18 deletions
|
@ -5,25 +5,31 @@ officially supported one is taking advantage of the built-in
|
||||||
[Squirrel](https://github.com/Squirrel) framework and
|
[Squirrel](https://github.com/Squirrel) framework and
|
||||||
Electron's [autoUpdater](../api/auto-updater.md) module.
|
Electron's [autoUpdater](../api/auto-updater.md) module.
|
||||||
|
|
||||||
## Deploying an update server
|
## Deploying an Update Server
|
||||||
|
|
||||||
To get started, you first need to deploy a server that the
|
To get started, you first need to deploy a server that the
|
||||||
[autoUpdater](../api/auto-updater.md) module will download new updates from.
|
[autoUpdater](../api/auto-updater.md) module will download new updates from.
|
||||||
|
|
||||||
Depending on your needs, you can choose from one of these:
|
Depending on your needs, you can choose from one of these:
|
||||||
|
|
||||||
- [Hazel](https://github.com/zeit/hazel) – Update server for private or open-source apps. Can be deployed for free on [Now](https://zeit.co/now) (using a single command), pulls from [GitHub Releases](https://help.github.com/articles/creating-releases/) and leverages the power of GitHub's CDN.
|
- [Hazel][hazel] – Update server for private or open-source apps which can be
|
||||||
- [Nuts](https://github.com/GitbookIO/nuts) – Also uses
|
deployed for free on [Now][now]. It pulls from [GitHub Releases][gh-releases]
|
||||||
[GitHub Releases](https://help.github.com/articles/creating-releases/),
|
and leverages the power of GitHub's CDN.
|
||||||
but caches app updates on disk and supports private repositories.
|
- [Nuts][nuts] – Also uses [GitHub Releases][gh-releases], but caches app
|
||||||
- [electron-release-server](https://github.com/ArekSredzki/electron-release-server) – Provides a dashboard for handling releases
|
updates on disk and supports private repositories.
|
||||||
- [Nucleus](https://github.com/atlassian/nucleus) – A complete update server for Electron apps maintained by Atlassian. Supports multiple applications and channels; uses a static file store to minify server cost.
|
- [electron-release-server][electron-release-server] – Provides a dashboard for
|
||||||
|
handling releases and does not require releases to originate on GitHub.
|
||||||
|
- [Nucleus][nucleus] – A complete update server for Electron apps maintained by
|
||||||
|
Atlassian. Supports multiple applications and channels; uses a static file store
|
||||||
|
to minify server cost.
|
||||||
|
|
||||||
If your app is packaged with [electron-builder][electron-builder-lib] you can use the
|
If your app is packaged with [`electron-builder`][electron-builder-lib] you can use the
|
||||||
[electron-updater] module, which does not require a server and allows for updates
|
[electron-updater] module, which does not require a server and allows for updates
|
||||||
from S3, GitHub or any other static file host.
|
from S3, GitHub or any other static file host. This sidesteps Electron's built-in
|
||||||
|
update mechanism, meaning that the rest of this documentation will not apply to
|
||||||
|
`electron-builder`'s updater.
|
||||||
|
|
||||||
## Implementing updates in your app
|
## Implementing Updates in Your App
|
||||||
|
|
||||||
Once you've deployed your update server, continue with importing the required
|
Once you've deployed your update server, continue with importing the required
|
||||||
modules in your code. The following code might vary for different server
|
modules in your code. The following code might vary for different server
|
||||||
|
@ -35,14 +41,14 @@ your packaged app, and not in development. You can use
|
||||||
[electron-is-dev](https://github.com/sindresorhus/electron-is-dev) to check for
|
[electron-is-dev](https://github.com/sindresorhus/electron-is-dev) to check for
|
||||||
the environment.
|
the environment.
|
||||||
|
|
||||||
```js
|
```javascript
|
||||||
const {app, autoUpdater, dialog} = require('electron')
|
const { app, autoUpdater, dialog } = require('electron')
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, construct the URL of the update server and tell
|
Next, construct the URL of the update server and tell
|
||||||
[autoUpdater](../api/auto-updater.md) about it:
|
[autoUpdater](../api/auto-updater.md) about it:
|
||||||
|
|
||||||
```js
|
```javascript
|
||||||
const server = 'https://your-deployment-url.com'
|
const server = 'https://your-deployment-url.com'
|
||||||
const feed = `${server}/update/${process.platform}/${app.getVersion()}`
|
const feed = `${server}/update/${process.platform}/${app.getVersion()}`
|
||||||
|
|
||||||
|
@ -51,25 +57,25 @@ autoUpdater.setFeedURL(feed)
|
||||||
|
|
||||||
As the final step, check for updates. The example below will check every minute:
|
As the final step, check for updates. The example below will check every minute:
|
||||||
|
|
||||||
```js
|
```javascript
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
autoUpdater.checkForUpdates()
|
autoUpdater.checkForUpdates()
|
||||||
}, 60000)
|
}, 60000)
|
||||||
```
|
```
|
||||||
|
|
||||||
Once your application is [packaged](../tutorial/application-distribution.md),
|
Once your application is [packaged](../tutorial/application-distribution.md),
|
||||||
it will receive an update for each new
|
it will receive an update for each new
|
||||||
[GitHub Release](https://help.github.com/articles/creating-releases/) that you
|
[GitHub Release](https://help.github.com/articles/creating-releases/) that you
|
||||||
publish.
|
publish.
|
||||||
|
|
||||||
## Applying updates
|
## Applying Updates
|
||||||
|
|
||||||
Now that you've configured the basic update mechanism for your application, you
|
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
|
need to ensure that the user will get notified when there's an update. This
|
||||||
can be achieved using the autoUpdater API
|
can be achieved using the autoUpdater API
|
||||||
[events](../api/auto-updater.md#events):
|
[events](../api/auto-updater.md#events):
|
||||||
|
|
||||||
```js
|
```javascript
|
||||||
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
|
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
|
||||||
const dialogOpts = {
|
const dialogOpts = {
|
||||||
type: 'info',
|
type: 'info',
|
||||||
|
@ -89,7 +95,7 @@ Also make sure that errors are
|
||||||
[being handled](../api/auto-updater.md#event-error). Here's an example
|
[being handled](../api/auto-updater.md#event-error). Here's an example
|
||||||
for logging them to `stderr`:
|
for logging them to `stderr`:
|
||||||
|
|
||||||
```js
|
```javascript
|
||||||
autoUpdater.on('error', message => {
|
autoUpdater.on('error', message => {
|
||||||
console.error('There was a problem updating the application')
|
console.error('There was a problem updating the application')
|
||||||
console.error(message)
|
console.error(message)
|
||||||
|
@ -98,3 +104,9 @@ autoUpdater.on('error', message => {
|
||||||
|
|
||||||
[electron-builder-lib]: https://github.com/electron-userland/electron-builder
|
[electron-builder-lib]: https://github.com/electron-userland/electron-builder
|
||||||
[electron-updater]: https://www.electron.build/auto-update
|
[electron-updater]: https://www.electron.build/auto-update
|
||||||
|
[now]: https://zeit.co/now
|
||||||
|
[hazel]: https://github.com/zeit/hazel
|
||||||
|
[nuts]: https://github.com/GitbookIO/nuts
|
||||||
|
[gh-releases]: https://help.github.com/articles/creating-releases/
|
||||||
|
[electron-release-server]: https://github.com/ArekSredzki/electron-release-server
|
||||||
|
[nucleus]: https://github.com/atlassian/nucleus
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue