Enterify
Easily package your Meteor apps with Electron, and butter.
TL;DR
npm install -g enterifycd /your/meteor/appenterify
Compatibility
Works on all Meteor's supported platforms.
Help
$ enterify -h Usage: enterify [command] [options] Commands: run start meteor app within enterify context bundle bundle meteor app at `.enterify` dir package bundle and package app to `--output` dir Options: -h, --help output usage information -V, --version output the version number -i, --input <path> meteor app dir | default = . -o, --output <path> output dir | default = .enterify/.dist -s, --settings <path> meteor settings file | default = null Examples: # cd into meteor dir first cd /your/meteor/app enterify enterify run enterify package enterify package -o /dist/dir enterify package -o /dist/dir -s file.json enterify package -i /app/dir -o /dist/dir -s dev.json enterify package -- <electron-packager-options> # more info about electron packager options: # ~> https://www.npmjs.com/package/electron-packager
Installation
npm install -g enterify
For invoking Electron methods from Meteor, you'll also need to install the
enteryazilim:enterify
meteor package. For more info check Meteor x Electron integration.
Running app
cd /your/meteor/appenterify
Packaging
cd /your/meteor/appenterify package
The packaging process is done under the hood using electron-packager
npm package. The following variables are automatically set:
--out
-- comes from cli option [-o, --out]--arch
-- comes from system [current arch]--platform
-- comes from system [current platform]--version
-- comes from .enterify/package.json [current app version]
You can overwrite these default values and also set others by passing custom
arguments directly to electron-packager
after --
, i.e:
cd /your/meteor/appenterify package -- --icon=/folder/x/img/icon.png --version=x.y.z
All the available options for electron-packager
can be found here:
https://www.npmjs.com/package/electron-packager
Notes
The output app will match your current operational system and arch type.
- To get an OSX app, run it from a Osx machine.
- To get an Linux 32bit app, run it from a 32bit Linux machine.
- To get an Linux 64bit app, run it from a 64bit Linux machine.
- To get an Windows 32bit app, run it from a 32bit Windows machine.
- To get an Windows 64bit app, run it from a 64bit Windows machine.
Due to NodeJS native bindings of such libraries such as Fibers -- which are mandatory for Meteor, you'll need to have your Meteor app fully working on the desired platform before installing this plugin and packaging your app.
So, at this time, you cannot package your app in a cross-platform fashion from one single OS.
Perhaps you can live with it? :)
DO NOT use options to output for multiple arch/platforms at once, such as
--arch=all
. It won't work, Enterify can bundle Meteor apps only for the platform you're running on.
Options
-i, --input
- Meteor app folder, default is current directory (process.cwd()
).-o, --output
- Sets output folder for your packaged app, default is/your/meteor/app/.dist
-s, --settings
Sets path for Meteor settings file, this will be available inside your Meteor code both in development and after being packaged.
Structure
You'll notice a new folder called .enterify
in your meteor app dir, its
structure will be like this:
/your/meteor/app
├── .enterify
│ ├── .gitignore
│ ├── enterify.json
│ ├── index.js
│ └── package.json
├── .meteor
└── ...
This is a pure Electron project, so you can use the whole Electron API from JS
files in this folder. Also, you can install electron dependencies and store them
in the package.json
file. Note that the enterify
package is itself a
dependency.
See this folder as the desktop layer
for your Meteor app. Remember to check
out the index.js
file, it constains the enterify start/stop usage.
The enterify.json
file will hold specific preferences for Enterify, such as
plugins and so on. It's still a WIP, but you can get around it.
enterify.json
)
Config (For now there's only one option here: preserve_db
.
Set it to true to preserve database between installs. It works by saving the mongo data dir inside user's data folder, instead of being self contained within the app folder (which gets deleted when new version is installed).
Customizing
Let's see how one would be able to do a simple SplashScreen:
var app = ;var browser = ;var enterify = __dirname; var window = null;var splash = null; // splash variable app; // ....
Meteor x Electron integration
You can seamlessly call Electron methods from your Meteor's client/server code.
Define your Electron methods inside the .enterify
folder:
// `.enterify/index.js` fileenterify;
Then, in your Meteor code (client and server), you can call this method like:
// Enterify.call(method_name, args, done_callback);Enterify;
IMPORTANT
You can only call methods after the connection is made between Meteor and Electron, to make sure it's ready you can wrap your code in a startup block:
Enterify;
Upgrading
When upgrading to newer versions, it's important to know that:
~> templates
Once these files exists on disk, they will not be overwritten.
.enterify/index.js
.enterify/package.json
.enterify/enterify.json
.enterify/.gitignore.json
~> api
As these files above is never overwritten, in case of any API change that needs adjustments, these will have to be made manually.
~> version matching
Always keep the same enterify version in your Meteor, and inside the
.enterify
folder, as per specified in .enterify/package.json
file.