2016-01-18 15:38:52 +00:00
#! /usr/bin/env node
import path from 'path' ;
import program from 'commander' ;
2016-01-18 16:40:24 +00:00
import async from 'async' ;
2016-01-18 15:38:52 +00:00
2016-01-18 14:07:22 +00:00
import optionsFactory from './options' ;
import buildApp from './buildApp' ;
2016-01-18 13:45:18 +00:00
2016-01-18 15:38:52 +00:00
const packageJson = require ( path . join ( '..' , 'package' ) ) ;
function main ( program ) {
2016-01-18 16:40:24 +00:00
async . waterfall ( [
callback => {
optionsFactory (
program . appName ,
program . targetUrl ,
program . platform ,
program . arch ,
program . electronVersion ,
program . outDir ,
program . overwrite ,
program . conceal ,
program . icon ,
program . badge ,
program . width ,
program . height , callback ) ;
} ,
( options , callback ) => {
buildApp ( options , callback ) ;
}
] , ( error , appPath ) => {
2016-01-18 13:45:18 +00:00
if ( error ) {
2016-01-18 15:38:52 +00:00
console . error ( error ) ;
2016-01-18 13:45:18 +00:00
return ;
}
console . log ( ` App built to ${ appPath } ` ) ;
} ) ;
}
2016-01-18 15:38:52 +00:00
if ( require . main === module ) {
program
. version ( packageJson . version )
2016-01-18 17:17:12 +00:00
. arguments ( '<targetUrl> [dest]' )
2016-01-18 15:38:52 +00:00
. action ( function ( targetUrl , appDir ) {
program . targetUrl = targetUrl ;
program . outDir = appDir ;
} )
2016-01-18 17:17:12 +00:00
. option ( '-n, --app-name <value>' , 'app name' )
. option ( '-p, --platform <value>' , '\'linux\', \'win32\', or \'darwin\'' )
. option ( '-a, --arch <value>' , '\'ia32\' or \'x64\'' )
. option ( '-e, --electron-version <value>' , 'electron version to package, without the \'v\', see https://github.com/atom/electron/releases' )
. option ( '-o, --overwrite' , 'if output directory for a platform already exists, replaces it rather than skipping it, defaults to false' )
2016-01-18 15:38:52 +00:00
. option ( '-c, --conceal' , 'packages the source code within your app into an archive, defaults to false, see http://electron.atom.io/docs/v0.36.0/tutorial/application-packaging/' )
. option ( '-b, --badge' , 'if the target app should show badges in the dock on receipt of desktop notifications (OSX only), defaults to false' )
2016-01-18 17:17:12 +00:00
. option ( '-i, --icon <value>' , 'the icon file to use as the icon for the app (should be a .icns file on OSX)' )
. option ( '-w, --width <value>' , 'set window width, defaults to 1280px' , parseInt )
. option ( '-h, --height <value>' , 'set window height, defaults to 800px' , parseInt )
2016-01-18 15:38:52 +00:00
. parse ( process . argv ) ;
if ( ! process . argv . slice ( 2 ) . length ) {
program . help ( ) ;
}
main ( program ) ;
}