• Stars
    star
    1,559
  • Rank 30,018 (Top 0.6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build Windows Installers for Electron apps

Electron Installer

CircleCI NPM package

NPM module that builds Windows installers for Electron apps using Squirrel.

Installing

npm install --save-dev electron-winstaller

Usage

Require the package:

const electronInstaller = require('electron-winstaller');

Then do a build like so..

// NB: Use this syntax within an async function, Node does not have support for
//     top-level await as of Node 12.
try {
  await electronInstaller.createWindowsInstaller({
    appDirectory: '/tmp/build/my-app-64',
    outputDirectory: '/tmp/build/installer64',
    authors: 'My App Inc.',
    exe: 'myapp.exe'
  });
  console.log('It worked!');
} catch (e) {
  console.log(`No dice: ${e.message}`);
}

After running you will have an .nupkg, a RELEASES file, and a .exe installer file in the outputDirectory folder for each multi task target given under the config entry.

There are several configuration settings supported:

Config Name Required Description
appDirectory Yes The folder path of your Electron app
outputDirectory No The folder path to create the .exe installer in. Defaults to the installer folder at the project root.
loadingGif No The local path to a .gif file to display during install.
authors Yes The authors value for the nuget package metadata. Defaults to the author field from your app's package.json file when unspecified.
owners No The owners value for the nuget package metadata. Defaults to the authors field when unspecified.
exe No The name of your app's main .exe file. This uses the name field in your app's package.json file with an added .exe extension when unspecified.
description No The description value for the nuget package metadata. Defaults to the description field from your app's package.json file when unspecified.
version No The version value for the nuget package metadata. Defaults to the version field from your app's package.json file when unspecified.
title No The title value for the nuget package metadata. Defaults to the productName field and then the name field from your app's package.json file when unspecified.
name No Windows Application Model ID (appId). Defaults to the name field in your app's package.json file.
certificateFile No The path to an Authenticode Code Signing Certificate
certificatePassword No The password to decrypt the certificate given in certificateFile
signWithParams No Params to pass to signtool. Overrides certificateFile and certificatePassword.
iconUrl No A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Atom icon.
setupIcon No The ICO file to use as the icon for the generated Setup.exe
skipUpdateIcon No Disables setting the icon of Update.exe. This can solve installation errors with the following message: "This application could not be started", when the setup is built on a non-Windows system.
setupExe No The name to use for the generated Setup.exe file
setupMsi No The name to use for the generated Setup.msi file
noMsi No Should Squirrel.Windows create an MSI installer?
noDelta No Should Squirrel.Windows delta packages? (disable only if necessary, they are a Good Thing)
remoteReleases No A URL to your existing updates. If given, these will be downloaded to create delta updates
remoteToken No Authentication token for remote updates
frameworkVersion No Set the required .NET framework version, e.g. net461

Sign your installer or else bad things will happen

For development / internal use, creating installers without a signature is okay, but for a production app you need to sign your application. Internet Explorer's SmartScreen filter will block your app from being downloaded, and many anti-virus vendors will consider your app as malware unless you obtain a valid cert.

Any certificate valid for "Authenticode Code Signing" will work here, but if you get the right kind of code certificate, you can also opt-in to Windows Error Reporting. This MSDN page has the latest links on where to get a WER-compatible certificate. The "Standard Code Signing" certificate is sufficient for this purpose.

Handling Squirrel Events

Squirrel will spawn your app with command line flags on first run, updates, and uninstalls. it is very important that your app handle these events as early as possible, and quit immediately after handling them. Squirrel will give your app a short amount of time (~15sec) to apply these operations and quit.

The electron-squirrel-startup module will handle the most common events for you, such as managing desktop shortcuts. Add the following to the top of your main.js and you're good to go:

if (require('electron-squirrel-startup')) return;

You should handle these events in your app's main entry point with something such as:

const app = require('app');

// this should be placed at top of main.js to handle setup events quickly
if (handleSquirrelEvent()) {
  // squirrel event handled and app will exit in 1000ms, so don't do anything else
  return;
}

function handleSquirrelEvent() {
  if (process.argv.length === 1) {
    return false;
  }

  const ChildProcess = require('child_process');
  const path = require('path');

  const appFolder = path.resolve(process.execPath, '..');
  const rootAtomFolder = path.resolve(appFolder, '..');
  const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
  const exeName = path.basename(process.execPath);

  const spawn = function(command, args) {
    let spawnedProcess, error;

    try {
      spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
    } catch (error) {}

    return spawnedProcess;
  };

  const spawnUpdate = function(args) {
    return spawn(updateDotExe, args);
  };

  const squirrelEvent = process.argv[1];
  switch (squirrelEvent) {
    case '--squirrel-install':
    case '--squirrel-updated':
      // Optionally do things such as:
      // - Add your .exe to the PATH
      // - Write to the registry for things like file associations and
      //   explorer context menus

      // Install desktop and start menu shortcuts
      spawnUpdate(['--createShortcut', exeName]);

      setTimeout(app.quit, 1000);
      return true;

    case '--squirrel-uninstall':
      // Undo anything you did in the --squirrel-install and
      // --squirrel-updated handlers

      // Remove desktop and start menu shortcuts
      spawnUpdate(['--removeShortcut', exeName]);

      setTimeout(app.quit, 1000);
      return true;

    case '--squirrel-obsolete':
      // This is called on the outgoing version of your app before
      // we update to the new version - it's the opposite of
      // --squirrel-updated

      app.quit();
      return true;
  }
};

Notice that the first time the installer launches your app, your app will see a --squirrel-firstrun flag. This allows you to do things like showing up a splash screen or presenting a settings UI. Another thing to be aware of is that, since the app is spawned by squirrel and squirrel acquires a file lock during installation, you won't be able to successfully check for app updates till a few seconds later when squirrel releases the lock.

Debugging this package

You can get debug messages from this package by running with the environment variable DEBUG=electron-windows-installer:main e.g.

DEBUG=electron-windows-installer:main node tasks/electron-winstaller.js

More Repositories

1

electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
C++
113,167
star
2

electron-quick-start

Clone to try a simple Electron app
JavaScript
11,060
star
3

electron-api-demos

Explore the Electron APIs
HTML
10,247
star
4

fiddle

:electron: πŸš€ The easiest way to get started with Electron
TypeScript
7,414
star
5

forge

:electron: A complete tool for building and publishing Electron applications
TypeScript
6,371
star
6

asar

Simple extensive tar-like archive format with indexing
JavaScript
2,520
star
7

apps

A collection of apps built on Electron
JavaScript
1,674
star
8

rcedit

Command line tool to edit resources of exe
C++
1,642
star
9

electronjs.org-old

Electron website
Handlebars
1,603
star
10

electron-quick-start-typescript

Clone to try a simple Electron app (in TypeScript)
TypeScript
1,181
star
11

rebuild

Package to rebuild native Node.js modules against the currently installed Electron version
TypeScript
1,008
star
12

update-electron-app

🌲 A drop-in module that adds autoUpdating capabilities to Electron apps
TypeScript
729
star
13

i18n

🌍 The home of Electron's translated documentation
TypeScript
625
star
14

simple-samples

Minimal Electron applications with ideas for taking them further
JavaScript
610
star
15

update.electronjs.org

πŸ“‘ A free service that makes it easy for open-source Electron apps to update themselves.
JavaScript
601
star
16

osx-sign

Codesign Electron macOS apps
TypeScript
559
star
17

libchromiumcontent

Shared library build of Chromium’s Content module
Python
485
star
18

remote

Bridge JavaScript objects from the main process to the renderer process in Electron.
TypeScript
369
star
19

get

Download Electron release artifacts
TypeScript
336
star
20

build-tools

The GN scripts to use for Electron dev-flows
JavaScript
254
star
21

releases

πŸ“¦ Complete and up-to-date info about every release of Electron
JavaScript
244
star
22

mini-breakpad-server

Minimum breakpad crash reports collecting server
CoffeeScript
243
star
23

node

Node fork to make it suitable for embedding in Electron
234
star
24

node-rcedit

Node module to edit resources of exe
JavaScript
186
star
25

node-abi

🐒 πŸš€ Get the Node.js and Electron ABI for a given target and runtime
JavaScript
159
star
26

packager

Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI
TypeScript
154
star
27

governance

Public repository for governance issues and documents
Shell
138
star
28

sheriff

Controls and monitors organization permissions across GitHub, Slack and GSuite. Built with ❀️ by The Electron Team
TypeScript
138
star
29

chromedriver

Download ChromeDriver for Electron
JavaScript
129
star
30

notarize

Notarize your macOS Electron Apps
TypeScript
129
star
31

typescript-definitions

Convert the Electron API JSON file to electron.d.ts
TypeScript
125
star
32

universal

Create Universal macOS applications from two x64 and arm64 Electron applications
TypeScript
112
star
33

website

:electron: The Electron website
TypeScript
108
star
34

mksnapshot

Electron mksnapshot binaries
JavaScript
102
star
35

trop

automate the backporting process
TypeScript
72
star
36

node-minidump

Node module to process minidump files
JavaScript
67
star
37

pdf-viewer

Fork of Chrome pdf extension to work as webui page in Electron
JavaScript
51
star
38

clerk

Verify PRs have release notes
TypeScript
48
star
39

hubdown

Convert markdown to GitHub-style HTML using a common set of remark plugins
JavaScript
39
star
40

native-mate

Fork of Chromium's gin library that makes it easier to marshal types between C++ and JavaScript.
C++
38
star
41

fuses

TypeScript
35
star
42

download-stats

⬇️ Download stats for Electron. Updated daily.
JavaScript
35
star
43

onboarding-guide

or, "So You Want to Be an Electron Hacker"
34
star
44

crashpad

Electron fork of crashpad
C++
32
star
45

symbolicate-mac

Symbolicate macOS Electron crash reports
JavaScript
30
star
46

chromium-breakpad

GitHub clone of the breakpad used by Chromium
C++
29
star
47

node-chromium-pickle-js

Binary value packing and unpacking library compatible with Chromium's Pickle class
JavaScript
22
star
48

electron-docs-linter

Parse and validate Electron's API documentation
JavaScript
21
star
49

windows-sign

Codesign Electron apps for Windows
TypeScript
20
star
50

docs-parser

Parse Electron docs in a lossless way into a JSON file
TypeScript
20
star
51

nightlies

Nightly release store
19
star
52

be

Scripts to help building Electron
JavaScript
18
star
53

dependent-repos

Public GitHub repos that depend on Electron. spiritual successor to https://github.com/electron/repos-using-electron
JavaScript
18
star
54

season-of-docs-2020

πŸ“– Project repository for Electron's possible participation in Google's Season of Docs
18
star
55

debian-sysroot-image-creator

Scripts to create debian sysroot image for building electron
Python
18
star
56

asar-require

Enable "require" scripts in asar archives
CoffeeScript
18
star
57

cation

Electron's PR monitoring bot
TypeScript
17
star
58

packages

A collection of all npm packages that mention `electron` in their package.json
JavaScript
17
star
59

symbol-server

Electron symbol server
TypeScript
16
star
60

unreleased

Checks for and reports commits unreleased for a specific release branch.
JavaScript
13
star
61

archaeologist

Digging up your artifacts since 2018
TypeScript
13
star
62

algolia-indices

Algolia search index data for Electron APIs, Tutorials, Packages, and Repos
JavaScript
13
star
63

fiddle-core

Run fiddles from anywhere, on any Electron release
TypeScript
13
star
64

github-app-auth

Gets an auth token for a repo via a GitHub app installation
TypeScript
11
star
65

electron-frameworks

Frameworks used by Electron
11
star
66

search-with-your-keyboard

Add keyboard navigation to your existing client-side search interface.
JavaScript
10
star
67

build-images

Base docker image used to build Electron on CI
Shell
10
star
68

electron-api-historian

Find the birthday of every Electron API
JavaScript
9
star
69

gyp

Python
9
star
70

electron-api-docs

πŸ“ Electron's API documentation in a structured JSON format [ARCHIVED]
JavaScript
9
star
71

build-tools-installer

Installer for Electron's wrapper toolkit for working with Electron.js source code
JavaScript
9
star
72

electron-docs

Fetch Electron documentation as raw markdown strings
JavaScript
8
star
73

.github

organization-wide defaults for all electron/* repos
7
star
74

rfcs

7
star
75

bugbot

Making life easier for people who report or triage Electron issues.
TypeScript
6
star
76

node-is-valid-window

Validates if a pointer to window is valid.
C++
5
star
77

electron-translators

Everyone who has helped translate Electron's documentation into different languages.
JavaScript
5
star
78

eslint-config

ESLint config used by Electron and Electron maintained modules
JavaScript
5
star
79

circleci-oidc-secret-exchange

Provides dynamic access to secrets in exchange for a valid OIDC token
TypeScript
5
star
80

electron-userland-reports

Slices of data about packages, repos, and users in Electron userland. Collected from the GitHub API, npm registry, and libraries.io
JavaScript
5
star
81

lint-roller

JavaScript
4
star
82

roller

🎡rollin on upstream 🎡
TypeScript
4
star
83

github-app-auth-action

TypeScript
3
star
84

tweets

3
star
85

electron-website-updater

JavaScript
3
star
86

zoilist

Nag @electron/api-wg to do API reviews
TypeScript
3
star
87

libcc-check

A little tool for checking up on libchromiumcontent builds.
JavaScript
2
star
88

slack-chromium-helper

Slack bot to unfurl Chromium development URLs
TypeScript
2
star
89

release-status

Public facing release status information
JavaScript
2
star
90

electron-issues

An experiment to better understand the issues filed on the electron/electron repo
JavaScript
2
star
91

hippo

TypeScript
2
star
92

ventifact

TypeScript
2
star
93

node-orb

Shell
1
star
94

electron-notarize

Notarize your macOS Electron Apps
TypeScript
1
star
95

docs-reviewer

TypeScript
1
star