rename to electron-packager

This commit is contained in:
Max Ogden 2015-04-27 12:09:24 -07:00
parent c5a0fb00bf
commit 198f379d41
4 changed files with 36 additions and 34 deletions

2
cli.js
View File

@ -15,7 +15,7 @@ if (protocolSchemes && protocolNames && protocolNames.length === protocolSchemes
}
if (!args.dir || !args.name) {
console.error('Usage: atom-shell-packager <sourcedir> <Appname>')
console.error('Usage: electron-packager <sourcedir> <Appname>')
process.exit(1)
}

View File

@ -9,25 +9,25 @@ var rimraf = require('rimraf')
var ncp = require('ncp').ncp
module.exports = function packager (opts, cb) {
var atomShellPath
var electronPath
try {
atomShellPath = require.resolve('atom-shell')
atomShellPath = path.join(atomShellPath, '..')
electronPath = require.resolve('electron-prebuilt')
electronPath = path.join(electronPath, '..')
} catch (e) {
try {
atomShellPath = require.resolve(path.join(process.execPath, '../../lib/node_modules/atom-shell'))
atomShellPath = path.join(atomShellPath, '..')
electronPath = require.resolve(path.join(process.execPath, '../../lib/node_modules/electron-prebuilt'))
electronPath = path.join(electronPath, '..')
} catch (e) {
cb(new Error('Cannot find atom-shell from here, please install it from npm'))
cb(new Error('Cannot find electron-prebuilt from here, please install it from npm'))
}
}
var atomPkg = require(path.join(atomShellPath, 'package.json'))
console.error('Using atom-shell version', atomPkg.version, 'from', atomShellPath)
var electronPkg = require(path.join(electronPath, 'package.json'))
console.error('Using electron-prebuilt version', electronPkg.version, 'from', electronPath)
var atomShellApp = path.join(atomShellPath, 'dist', 'Atom.app')
var tmpDir = path.join(os.tmpdir(), 'atom-shell-packager-mac')
var electronApp = path.join(electronPath, 'dist', 'Electron.app')
var tmpDir = path.join(os.tmpdir(), 'electron-packager-mac')
var newApp = path.join(tmpDir, opts.name + '.app')
@ -37,7 +37,7 @@ module.exports = function packager (opts, cb) {
mkdirp(newApp, function mkdirpd () {
// ignore errors
// copy .app folder and use as template (this is exactly what Atom editor does)
ncp(atomShellApp, newApp, function copied (err) {
ncp(electronApp, newApp, function copied (err) {
if (err) return cb(err)
buildMacApp()
})
@ -47,7 +47,7 @@ module.exports = function packager (opts, cb) {
function buildMacApp () {
var paths = {
info1: path.join(newApp, 'Contents', 'Info.plist'),
info2: path.join(newApp, 'Contents', 'Frameworks', 'Atom Helper.app', 'Contents', 'Info.plist'),
info2: path.join(newApp, 'Contents', 'Frameworks', 'Electron Helper.app', 'Contents', 'Info.plist'),
app: path.join(newApp, 'Contents', 'Resources', 'app')
}
@ -55,8 +55,8 @@ module.exports = function packager (opts, cb) {
var pl1 = plist.parse(fs.readFileSync(paths.info1).toString())
var pl2 = plist.parse(fs.readFileSync(paths.info2).toString())
var bundleId = opts['app-bundle-id'] || 'com.atom-shell.' + opts.name.toLowerCase()
var bundleHelperId = opts['helper-bundle-id'] || 'com.atom-shell.' + opts.name.toLowerCase() + '.helper'
var bundleId = opts['app-bundle-id'] || 'com.electron.' + opts.name.toLowerCase()
var bundleHelperId = opts['helper-bundle-id'] || 'com.electron.' + opts.name.toLowerCase() + '.helper'
pl1.CFBundleDisplayName = opts.name
pl1.CFBundleIdentifier = bundleId

View File

@ -1,21 +1,21 @@
{
"name": "atom-shell-packager",
"name": "electron-packager",
"version": "2.1.1",
"description": "package and distribute your atom-shell app in OS executables (.app, .exe, etc) via JS or CLI",
"description": "package and distribute your electron app in OS executables (.app, .exe, etc) via JS or CLI",
"main": "index.js",
"bin": {
"atom-shell-packager": "cli.js"
"electron-packager": "cli.js"
},
"repository": {
"type": "git",
"url": "https://github.com/maxogden/atom-shell-packager.git"
"url": "https://github.com/maxogden/electron-packager.git"
},
"author": "max ogden",
"license": "BSD",
"bugs": {
"url": "https://github.com/maxogden/atom-shell-packager/issues"
"url": "https://github.com/maxogden/electron-packager/issues"
},
"homepage": "https://github.com/maxogden/atom-shell-packager",
"homepage": "https://github.com/maxogden/electron-packager",
"dependencies": {
"minimist": "^1.1.1",
"mkdirp": "^0.5.0",

View File

@ -1,10 +1,12 @@
# atom-shell-packager
# electron-packager
Build a distributable app from an atom-shell app source code directory. **Currently only Mac OS is implemented** but you can send PRs to implement windows/linux :)
Build a distributable app from an electron app source code directory. **Currently only Mac OS is implemented** but you can send PRs to implement windows/linux :)
[![NPM](https://nodei.co/npm/atom-shell-packager.png)](https://nodei.co/npm/atom-shell-packager/)
*formerly known as atom-shell-packager*
[![Build Status](https://travis-ci.org/maxogden/atom-shell-packager.svg?branch=master)](https://travis-ci.org/maxogden/atom-shell-packager)
[![NPM](https://nodei.co/npm/electron-packager.png)](https://nodei.co/npm/electron-packager/)
[![Build Status](https://travis-ci.org/maxogden/electron-packager.svg?branch=master)](https://travis-ci.org/maxogden/electron-packager)
For an example project using this, check out [Monu](https://github.com/maxogden/monu)
@ -12,36 +14,36 @@ For an example project using this, check out [Monu](https://github.com/maxogden/
```
# for use in npm scripts
npm i atom-shell-packager --save-dev
npm i electron-packager --save-dev
# for use from cli
npm i atom-shell-packager -g
npm i electron-packager -g
# you also need atom-shell installed
npm i atom-shell
# you also need electron installed
npm i electron-prebuilt
```
### usage
```
$ atom-shell-packager my-app-source-dir AppName
$ electron-packager my-app-source-dir AppName
```
This will:
- Find the closest local version of `atom-shell` installed (using `require.resolve`)
- Use that version of atom-shell to create a Mac app in `cwd` called `AppName.app`
- Find the closest local version of `electron` installed (using `require.resolve`)
- Use that version of electron to create a Mac app in `cwd` called `AppName.app`
You should be able to double-click `AppName.app` to launch the app. If not, check your settings and try again.
**Be careful** not to include node_modules you don't want into your final app. For example, do not include the `node_modules/atom-shell-packager` folder or `node_modules/atom-shell`. You can use `--ignore=node_modules/atom-shell` to ignore of these
**Be careful** not to include node_modules you don't want into your final app. For example, do not include the `node_modules/electron-packager` folder or `node_modules/electron-prebuilt`. You can use `--ignore=node_modules/electron-prebuilt` to ignore of these
### options
these are optional CLI options you can pass in
- `out` (default current working dir) - the dir to put the app into at the end
- `version` (default hardcoded in source) - atom-shell version to use
- `version` (default hardcoded in source) - electron version to use
- `app-bundle-id` - bundle identifier to use in the app plist
- `helper-bundle-id` - bundle identifier to use in the app helper plist
- `ignore` (default none) - do not copy files into App whose filenames regex .match this string