2016-01-18 15:38:52 +00:00
#! /usr/bin/env node
2016-01-24 13:07:22 +00:00
import 'source-map-support/register' ;
2016-01-18 15:38:52 +00:00
import path from 'path' ;
import program from 'commander' ;
2016-01-29 06:26:35 +00:00
import nativefier from './index' ;
2016-01-18 15:38:52 +00:00
const packageJson = require ( path . join ( '..' , 'package' ) ) ;
2016-02-25 06:56:32 +00:00
function collect ( val , memo ) {
memo . push ( val ) ;
return memo ;
}
2016-01-18 15:38:52 +00:00
if ( require . main === module ) {
2016-02-25 06:56:32 +00:00
2016-01-18 15:38:52 +00:00
program
. version ( packageJson . version )
2016-01-18 17:17:12 +00:00
. arguments ( '<targetUrl> [dest]' )
2016-01-23 18:02:23 +00:00
. action ( function ( targetUrl , appDir ) {
2016-01-18 15:38:52 +00:00
program . targetUrl = targetUrl ;
2016-01-29 03:37:54 +00:00
program . out = appDir ;
2016-01-18 15:38:52 +00:00
} )
2016-01-29 03:37:54 +00:00
. option ( '-n, --name <value>' , 'app name' )
2016-03-12 08:47:18 +00:00
. option ( '-p, --platform <value>' , '\'osx\', \'linux\' or \'windows\'' )
2016-01-18 17:17:12 +00:00
. 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' )
2016-03-12 08:07:21 +00:00
. option ( '--no-overwrite' , 'do not override output directory if it already exists, 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/' )
2016-01-22 03:35:05 +00:00
. option ( '--counter' , 'if the target app should use a persistant counter badge in the dock (OSX only), defaults to false' )
2016-01-26 06:24:47 +00:00
. option ( '-i, --icon <value>' , 'the icon file to use as the icon for the app (should be a .icns file on OSX, .png for Windows and Linux)' )
2016-05-26 09:11:51 +00:00
. option ( '--width <value>' , 'set window default width, defaults to 1280px' , parseInt )
. option ( '--height <value>' , 'set window default height, defaults to 800px' , parseInt )
. option ( '--min-width <value>' , 'set window minimum width, defaults to 0px' , parseInt )
. option ( '--min-height <value>' , 'set window minimum height, defaults to 0px' , parseInt )
. option ( '--max-width <value>' , 'set window maximum width, default is no limit' , parseInt )
. option ( '--max-height <value>' , 'set window maximum height, default is no limit' , parseInt )
2016-01-22 14:42:56 +00:00
. option ( '-m, --show-menu-bar' , 'set menu bar visible, defaults to false' )
2016-04-25 22:09:01 +00:00
. option ( '-f, --fast-quit' , 'quit app after window close (OSX only), defaults to false' )
2016-01-19 03:30:42 +00:00
. option ( '-u, --user-agent <value>' , 'set the user agent string for the app' )
2016-01-22 03:59:57 +00:00
. option ( '--honest' , 'prevent the nativefied app from changing the user agent string to masquerade as a regular chrome browser' )
2016-02-23 13:31:47 +00:00
. option ( '--ignore-certificate' , 'ignore certificate related errors' )
. option ( '--insecure' , 'enable loading of insecure content, defaults to false' )
2016-03-26 07:06:50 +00:00
. option ( '--flash' , 'if flash should be enabled' )
. option ( '--flash-path <value>' , 'path to Chrome flash plugin, find it in `Chrome://plugins`' )
2017-04-16 16:19:03 +00:00
. option ( '--inject <value>' , 'path to a CSS/JS file to be injected' , collect , [ ] )
2016-02-25 10:26:28 +00:00
. option ( '--full-screen' , 'if the app should always be started in full screen' )
2016-03-22 17:09:21 +00:00
. option ( '--maximize' , 'if the app should always be started maximized' )
2016-04-16 23:05:17 +00:00
. option ( '--hide-window-frame' , 'disable window frame and controls' )
2016-03-25 12:50:52 +00:00
. option ( '--verbose' , 'if verbose logs should be displayed' )
2016-04-16 14:06:25 +00:00
. option ( '--disable-context-menu' , 'disable the context menu' )
2016-05-26 10:02:43 +00:00
. option ( '--disable-dev-tools' , 'disable developer tools' )
2016-07-12 01:32:40 +00:00
. option ( '--zoom <value>' , 'default zoom factor to use when the app is opened, defaults to 1.0' , parseFloat )
2016-08-06 18:03:53 +00:00
. option ( '--internal-urls <value>' , 'regular expression of URLs to consider "internal"; all other URLs will be opened in an external browser. (default: URLs on same second-level domain as app)' )
2016-10-09 05:52:50 +00:00
. option ( '--crash-reporter <value>' , 'remote server URL to send crash reports' )
2017-04-10 02:02:49 +00:00
. option ( '--single-instance' , 'allow only a single instance of the application' )
2016-01-18 15:38:52 +00:00
. parse ( process . argv ) ;
if ( ! process . argv . slice ( 2 ) . length ) {
program . help ( ) ;
}
2016-01-29 06:26:35 +00:00
nativefier ( program , ( error , appPath ) => {
2016-01-24 12:40:32 +00:00
if ( error ) {
console . error ( error ) ;
return ;
}
2016-01-29 17:57:56 +00:00
if ( ! appPath ) {
// app exists and --overwrite is not passed
return ;
}
2016-01-24 12:40:32 +00:00
console . log ( ` App built to ${ appPath } ` ) ;
} ) ;
2016-01-18 15:38:52 +00:00
}