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

electron_packager

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron_packager

A Electron packager that stores huge frameworks globally in the library to reduce the size of the packaged .app bundle to a few kb's.

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Electron Packager

A Electron packager that packages your .app bundle smaller than 1 MB.

How does it works?

The packaged .app bundle doesn't include (e.g. Electron Framework.framework) huge files like big frameworks but store them globally in the library of the system.

These global required resources are accessible from every .app that is packaged in this way. Therefore you just have to install the required resources one times.

Works out of the box

Yes. The packaged .app bundle contains a small downloading process for the required resources. The specific mirror is the github repository of electron.

Install

npm install electron_packager -g

Command Line Interface

All CLI arguments are optional except the src.

electron_packager src=/path/to/app/folder
ArgumentValueDefault
src/path/to/appRequired
target/path/to/outputParent folder of src
platform'darwin' || 'win' || 'linux' ||'darwin'
nameCustom Name{package.json->name}
icon/path/to/icon/filefalse
identifiercom.developer.myappcom.{package.json->author}.{package.json->name}

Please make sure that the packager actually only suppports macOS (darwin)!

Support for windows and linux is in development.

Functionality

The functionality is very modular.

In AppBundle.app/Contents/Bundle.json you'll find a file that contains all outsourced resources. This resources will be deleted in your app bundle and therefore accessed using the library. In this file, everything is described. That means, which resources are outsourced and where the global electron app bundle is stored. (e.g. ~/Library/Electron). Normally you shouldn't touch this file because it outsources everything that makes sense.

Process in detail

If your app starts, it will look at the destination and try to open itself with the resources stored there in the Electron.app bundle. If the version of your Bundle.json is higher than the version of the (in destination stored) Electron.app and its resources or if there isn't any instance of a Electron.app a download progress will begin that downloads the latest version of Electron and saves it to destination. This progress will use GitHub as mirror and the npm registry for information about electron in general. Just d nothing. When your electron instance is installed, every app that is packaged in this way can use this global electron instance. (Of course, only if the destination in Bundle.json points on the default folder ~/Library/Electron which should be the case beacuse you shouldn't touch it).

This is, how the Bundle.json normally looks like:

{
  "electron": {
    "version": "v1.6.11",
    "destination": "~/Library/Electron",
    "bundle": "Electron.app",
    "resources": [
      "Frameworks/Electron Framework.framework",
      "Frameworks/Squirrel.framework",
      "Frameworks/Mantle.framework",
      "Frameworks/ReactiveCocoa.framework",
      "Resources/electron.asar"
    ]
  },
  "executable": "MacOS/Electron"
}
Important

The property version of electron is automatically generated. It's required to update the global electron instance when your app needs a newer one. It updates automatically to the newest one, not to the version of your app. That means, if you use a version in your Bundle.jsonthat is higher than the newest one, your app will open a download progress every time you try to open it. But because of the impossibility to use a electron version that doesn't exists, you just have to keep in mind that you shouldn't touch this file. And if you touch it, just change the resources. Please keep in mind that every resource that is not declared in your Bundle.json wouldn't be outsources. Therefore you have to package it. But be careful because it can be dangerous to outsource some files and others not because they dependent from each other and if the versions of your app's (not outsourced) resources are not the newest one but some resources you outsource in the system are the newest one, something could go wrong. For example, think of the case you don't outsource Electron Framework.framework but not Mantle.framework. That means, your app will use Mantle.framework from your apps directory (which could be very old) and Electron Framework.framework from ~/Library/Electron/... (which could be very new). And if this versions aren't compatible, your app wouldn't work.

And because of that, just don't touch it. Just don't do it if there is no special reason for it.

Module

const packager = require('electron_packager');

packager.package({
 source: "path/to/your/app", // Optional.  This is an example that will work with the git repository
 platform: "darwin", // Default 'darwin'
 target: "path/to/your/destination", // Default = parent directory of 'source'
 name: "You App Name", // Default 'name' from package.json
 icon: "path/to/your/custom/icon.icns", // Default false
 identifier: "com.yourCompany.yourAppName" // Default generated from package.json
});

Keywords

FAQs

Package last updated on 28 Aug 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