@@ -33,40 +33,41 @@ program.option('--createUser', 'helper tool to allow you to generate secure user
3333program . option ( '--createMFA' , 'helper tool to allow you to generate multi-factor authentication secrets.' ) ;
3434
3535program . parse ( process . argv ) ;
36+ const options = program . opts ( ) ;
3637
37- for ( const key in program ) {
38+ for ( const key in options ) {
3839 const func = CLIHelper [ key ] ;
3940 if ( func && typeof func === 'function' ) {
4041 func ( ) ;
4142 return ;
4243 }
4344}
4445
45- const host = program . host || process . env . HOST || '0.0.0.0' ;
46- const port = program . port || process . env . PORT || 4040 ;
47- const mountPath = program . mountPath || process . env . MOUNT_PATH || '/' ;
48- const allowInsecureHTTP = program . allowInsecureHTTP || process . env . PARSE_DASHBOARD_ALLOW_INSECURE_HTTP ;
49- const cookieSessionSecret = program . cookieSessionSecret || process . env . PARSE_DASHBOARD_COOKIE_SESSION_SECRET ;
50- const trustProxy = program . trustProxy || process . env . PARSE_DASHBOARD_TRUST_PROXY ;
51- const dev = program . dev ;
46+ const host = options . host || process . env . HOST || '0.0.0.0' ;
47+ const port = options . port || process . env . PORT || 4040 ;
48+ const mountPath = options . mountPath || process . env . MOUNT_PATH || '/' ;
49+ const allowInsecureHTTP = options . allowInsecureHTTP || process . env . PARSE_DASHBOARD_ALLOW_INSECURE_HTTP ;
50+ const cookieSessionSecret = options . cookieSessionSecret || process . env . PARSE_DASHBOARD_COOKIE_SESSION_SECRET ;
51+ const trustProxy = options . trustProxy || process . env . PARSE_DASHBOARD_TRUST_PROXY ;
52+ const dev = options . dev ;
5253
5354if ( trustProxy && allowInsecureHTTP ) {
5455 console . log ( 'Set only trustProxy *or* allowInsecureHTTP, not both. Only one is needed to handle being behind a proxy.' ) ;
5556 process . exit ( - 1 ) ;
5657}
5758
58- let explicitConfigFileProvided = ! ! program . config ;
59+ let explicitConfigFileProvided = ! ! options . config ;
5960let configFile = null ;
6061let configFromCLI = null ;
61- let configServerURL = program . serverURL || process . env . PARSE_DASHBOARD_SERVER_URL ;
62- let configGraphQLServerURL = program . graphQLServerURL || process . env . PARSE_DASHBOARD_GRAPHQL_SERVER_URL ;
63- let configMasterKey = program . masterKey || process . env . PARSE_DASHBOARD_MASTER_KEY ;
64- let configAppId = program . appId || process . env . PARSE_DASHBOARD_APP_ID ;
65- let configAppName = program . appName || process . env . PARSE_DASHBOARD_APP_NAME ;
66- let configUserId = program . userId || process . env . PARSE_DASHBOARD_USER_ID ;
67- let configUserPassword = program . userPassword || process . env . PARSE_DASHBOARD_USER_PASSWORD ;
68- let configSSLKey = program . sslKey || process . env . PARSE_DASHBOARD_SSL_KEY ;
69- let configSSLCert = program . sslCert || process . env . PARSE_DASHBOARD_SSL_CERT ;
62+ let configServerURL = options . serverURL || process . env . PARSE_DASHBOARD_SERVER_URL ;
63+ let configGraphQLServerURL = options . graphQLServerURL || process . env . PARSE_DASHBOARD_GRAPHQL_SERVER_URL ;
64+ let configMasterKey = options . masterKey || process . env . PARSE_DASHBOARD_MASTER_KEY ;
65+ let configAppId = options . appId || process . env . PARSE_DASHBOARD_APP_ID ;
66+ let configAppName = options . appName || process . env . PARSE_DASHBOARD_APP_NAME ;
67+ let configUserId = options . userId || process . env . PARSE_DASHBOARD_USER_ID ;
68+ let configUserPassword = options . userPassword || process . env . PARSE_DASHBOARD_USER_PASSWORD ;
69+ let configSSLKey = options . sslKey || process . env . PARSE_DASHBOARD_SSL_KEY ;
70+ let configSSLCert = options . sslCert || process . env . PARSE_DASHBOARD_SSL_CERT ;
7071
7172function handleSIGs ( server ) {
7273 const signals = {
@@ -86,7 +87,7 @@ function handleSIGs(server) {
8687 } ) ;
8788}
8889
89- if ( ! program . config && ! process . env . PARSE_DASHBOARD_CONFIG ) {
90+ if ( ! options . config && ! process . env . PARSE_DASHBOARD_CONFIG ) {
9091 if ( configServerURL && configMasterKey && configAppId ) {
9192 configFromCLI = {
9293 data : {
@@ -114,13 +115,13 @@ if (!program.config && !process.env.PARSE_DASHBOARD_CONFIG) {
114115 } else if ( ! configServerURL && ! configMasterKey && ! configAppName ) {
115116 configFile = path . join ( __dirname , 'parse-dashboard-config.json' ) ;
116117 }
117- } else if ( ! program . config && process . env . PARSE_DASHBOARD_CONFIG ) {
118+ } else if ( ! options . config && process . env . PARSE_DASHBOARD_CONFIG ) {
118119 configFromCLI = {
119120 data : JSON . parse ( process . env . PARSE_DASHBOARD_CONFIG )
120121 } ;
121122} else {
122- configFile = program . config ;
123- if ( program . appId || program . serverURL || program . masterKey || program . appName || program . graphQLServerURL ) {
123+ configFile = options . config ;
124+ if ( options . appId || options . serverURL || options . masterKey || options . appName || options . graphQLServerURL ) {
124125 console . log ( 'You must provide either a config file or other CLI options (appName, appId, masterKey, serverURL, and graphQLServerURL); not both.' ) ;
125126 process . exit ( 3 ) ;
126127 }
0 commit comments