Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-forge

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-forge

A complete tool for building modern Electron applications

  • 2.7.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
854
increased by0.71%
Maintainers
2
Weekly downloads
 
Created
Source

Electron Forge

Linux/macOS Build Status Windows Build status Commitizen friendly npm version npm license status

A complete tool for building modern Electron applications.

Electron Forge unifies the existing (and well maintained) build tools for Electron development into a simple, easy to use package so that anyone can jump right in to Electron development.

Getting Started

Note: Electron Forge requires Node 6 or above, plus git installed.

npm install -g electron-forge
electron-forge init my-new-app
cd my-new-app
electron-forge start

Project Goals

  1. Starting with Electron should be as simple as a single command.
  2. Developers shouldn't have to worry about babel, browserify, webpack, etc. Everything should "just work" for them out of the box.
  3. Everything from creating the project to packaging the project for release should be handled by one dependency in a standard way while still offering users maximum choice and freedom.

With these goals in mind, under the hood this project uses electron-compile: a tool that lets you use modern and futuristic languages inside Electron without worrying about transpiling or build tooling.

Usage

Starting a new Project

npm install -g electron-forge
electron-forge init my-new-project

This command will generate a brand new project folder and install all your NPM dependencies so you will be all set to go. By default we will also install the airbnb linting modules. If you want to follow the standard linting rules instead, use the --lintstyle=standard argument.

You can also start a project with your favorite framework with the --template argument. E.g. --template=react.

Importing an existing Project

electron-forge import existing-project-directory

Given an existing Electron project, this command will attempt to interactively navigate through the process of importing it to the Electron Forge format, so the commands listed below can be used. This includes being prompted to remove existing Electron build tools in favor of Electron Forge equivalents.

Launching your Project

electron-forge start

Any arguments after "start" will be passed through to your application when it's launched.

Packaging your Project

electron-forge package

Yes, it really is that simple. If you want to specify platform / arch, use the --platform=<platform> and --arch=<arch> arguments.

Generating a distributable for your Project

electron-forge make

This will generate platform specific distributables (installers, distribution packages, etc.) for you. Note that you can only generate distributables for your current platform.

Linting your Project

electron-forge lint

Publishing your Project

electron-forge publish

This will make your project and publish any generated artifacts. By default it will publish to GitHub but you can change the publish target with --target=YourTarget.

Config

Once you have generated a project, your package.json file will have some default forge configuration. Below is the reference structure for this config object:

{
  "make_targets": {
    "win32": ["squirrel"], // An array of win32 make targets
    "darwin": ["zip", "dmg"], // An array of darwin make targets
    "linux": ["deb", "rpm", "flatpak"] // An array of linux make targets
  },
  "electronPackagerConfig": {},
  "electronWinstallerConfig": {},
  "electronInstallerDMG": {},
  "electronInstallerFlatpak": {},
  "electronInstallerDebian": {},
  "electronInstallerRedhat": {}
}

Possible make targets

Target NameAvailable PlatformsDescriptionConfigurable OptionsDefault?Requirements
zipAllZips your packaged applicationNoneYeszip on Darwin/Linux
squirrelWindowsGenerates an installer and .nupkg files for Squirrel.WindowselectronWinstallerConfigYes
appxWindowsGenerates a Windows Store packagewindowsStoreConfigNo
dmgDarwinGenerates a DMG fileelectronInstallerDMGNo
debLinuxGenerates a Debian packageelectronInstallerDebianYesfakeroot and dpkg
rpmLinuxGenerates an RPM packageelectronInstallerRedhatYesrpm
flatpakLinuxGenerates a Flatpak fileelectronInstallerFlatpakNoflatpak-builder

Configuring package

You can set electronPackagerConfig with any of the options from Electron Packager.

NOTE: You can also set your forge config property of your package.json to point to a JS file that exports the config object:

{
  ...
  "config": {
    "forge": "./forge.config.js"
  }
  ...
}

NOTE: If you use the JSON object then the afterCopy and afterExtract options are mapped to require calls internally, so provide a path to a file that exports your hooks and they will still run. If you use the JS file method mentioned above then you can use functions normally.

Possible publish targets

Target NameDescriptionRequired Config
githubMakes a new release for the current version (if required) and uploads the make artifacts as release assetsprocess.env.GITHUB_TOKEN - A personal access token with access to your releases
forge.github_repository.owner - The owner of the GitHub repository
forge.github_repository.name - The name of the GitHub repository
forge.github_repository.draft - Create the release as a draft, defaults to true
forge.github_repository.prerelease - Identify the release as a prerelease, defaults to false

Custom make and publish targets

You can make your own custom targets for the make and publish targets. If you publish them as electron-forge-publisher-{name} or electron-forge-maker-{name} you can then just specify {name} as your make / publish target. The API for each is documented below.

API for make targets

You must export a Function that returns a Promise. Your function will be called with the following parameters.

  • appDir - The directory containing the packaged application
  • appName - The productName of the application
  • targetArch - The target architecture of the make command
  • forgeConfig - An object representing the users forgeConfig
  • packageJSON - An object representing the users package.json file

Your promise must resolve with an array of the artifacts you generated.

API for publish targets

You must export a Function that returns a Promise. Your function will be called with the following parameters.

  • artifactPaths - An array of absolute paths to artifacts to publish
  • packageJSON - An object representing the users package.json file
  • forgeConfig - An object representing the users forgeConfig
  • authToken - The value of --auth-token
  • tag - The value of --tag

You should use ora to indicate your publish progress.

FAQs

Package last updated on 24 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc