npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

electron-updater-sqlseer

v0.2.1

Published

Cross platform auto-updater for electron applications

Downloads

28

Readme

electron-updater

Cross platform auto-updater for electron apps

Build Status

Install

There are three main packages that make up the electron-updater.

$ npm install electron-updater --save
$ npm install electron-plugins --save
$ npm install electron-updater-tools -g

The electron-updater package itself runs in your app's main process and does the actual updating. The electron-plugins project specifically loads the plugins downloaded by the updater in the render process. The third project, electron-updater-tools contains various scripts useful for building native electron addons as well as linking plugins during development time.

Usage

Integrate the electron-updater into your electron main process. Below is a simplified example of the Electron Quick Start code with the electron-updater mixed in.

Example main.js

var app = require('app'),
    BrowserWindow = require('browser-window'),
    updater = require('electron-updater')

var mainWindow = null

app.on('ready', function() {
    updater.on('ready', function () {
        mainWindow = new BrowserWindow({width: 800, height: 600})
        mainWindow.loadUrl('file://' + __dirname + '/index.html')
        mainWindow.openDevTools({detach:true})        
        mainWindow.on('closed', function() {
            mainWindow = null;
        })
    })
    updater.on('updateRequired', function () {        
        app.quit();
    })
    updater.on('updateAvailable', function () {
        mainWindow.webContents.send('update-available');
    })
    updater.start()
})

Example index.js (running in render process)

var plugins = require('electron-plugins'),
	ipc = require('ipc')

document.addEventListener('DOMContentLoaded', function () {
	var context = { document: document }
	plugins.load(context, function (err, loaded) {
		if(err) return console.error(err)
		console.log('Plugins loaded successfully.')
	})
})

ipc.on('update-available', function () {
	console.log('there is an update available for download')
})

Publishing Updates

There are two kinds of updates you can publish:

  • The Application itself
  • Plugins

Both kinds of updatable packages are distributed through npm. This means that publishing updates to your application and plugins are essentially done like this:

$ npm pack
$ npm pub

The application will periodically check npm for updates to any packages and update them when it can.

Hosting your own npm server

If you are developing a commercial application, or just want to control distribution yourself, you should host your own packages on your own npm server.

Add a path to your registry in the applications package.json:

  "registry": "http://npm.mycompany.com:4873",

To tell npm to use this registry also, create a .npmrc file in your application root directory containing:

registry=http://npm.mycompany.com:4873

Fortunately, hosting your own npm server is very easy to do with sinopia.

$ npm install sinopia -g
$ sinopia

To run sinopia as a service, you can use forever.

$ npm install forever -g
$ forever start sinopia

Plugins

Plugins are different than normal dependencies. To establish a link to a plugin, add a plugins entry into your applications package.json:

  "dependencies": {
    # ...
  },
  "plugins": {
    "electron-updater-example-plugin": "~0.1.0"
  },

When your application runs it will download and install these plugins into your users AppDirectory.userData() folder. The main benefits of plugins is:

  • Gauranteed user directory, does not require elevation to update.
  • Supports side-by-side installation, so they can be updated while the app is running.
  • Application can be refreshed instead of restarted to apply updates.
  • Load arbitrary plugins using electron-plugins, instead of having fixed dependencies only.

In the userData folder there is also a .current file created, which is used to maintain the list of currently installed plugins. You can add items to that file to install non-default plugins.

Distributing binaries

TODO...

Related

See the electron-builder project for creating installers for various platforms.