From 2362137667dbcfeb89c4605a6f1b07b9f83846ec Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 14 Sep 2022 21:28:32 -0400 Subject: [PATCH 1/4] update commander --- package.json | 2 +- src/main.js | 122 ++++++++++++++++++++++++++------------------------- 2 files changed, 63 insertions(+), 61 deletions(-) diff --git a/package.json b/package.json index 6de09b1..60c4795 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "chokidar": "3.3.1", "clone": "2.1.2", "color": "3.1.2", - "commander": "4.1.1", + "commander": "9.4.0", "cors": "2.8.5", "esm": "3.2.25", "express": "4.17.1", diff --git a/src/main.js b/src/main.js index 2fb3723..ef44a3f 100644 --- a/src/main.js +++ b/src/main.js @@ -17,76 +17,78 @@ if (args.length >= 3 && args[2][0] !== '-') { args.splice(2, 0, '--mbtiles'); } -const opts = require('commander') - .description('tileserver-gl startup options') - .usage('tileserver-gl [mbtiles] [options]') - .option( - '--mbtiles ', - 'MBTiles file (uses demo configuration);\n' + - '\t ignored if the configuration file is also specified' - ) - .option( - '-c, --config ', - 'Configuration file [config.json]', - 'config.json' - ) - .option( - '-b, --bind
', - 'Bind address' - ) - .option( - '-p, --port ', - 'Port [8080]', - 8080, - parseInt - ) - .option( - '-C|--no-cors', - 'Disable Cross-origin resource sharing headers' - ) - .option( - '-u|--public_url ', - 'Enable exposing the server on subpaths, not necessarily the root of the domain' - ) - .option( - '-V, --verbose', - 'More verbose output' - ) - .option( - '-s, --silent', - 'Less verbose output' - ) - .option( - '-l|--log_file ', - 'output log file (defaults to standard out)' - ) - .option( - '-f|--log_format ', - 'define the log format: https://github.com/expressjs/morgan#morganformat-options' - ) - .version( - packageJson.version, - '-v, --version' - ) - .parse(args); +const { program } = require('commander'); +program + .description('tileserver-gl startup options') + .usage('tileserver-gl [mbtiles] [options]') + .option( + '--mbtiles ', + 'MBTiles file (uses demo configuration);\n' + + '\t ignored if the configuration file is also specified', + ) + .option( + '-c, --config ', + 'Configuration file [config.json]', + 'config.json', + ) + .option( + '-b, --bind
', + 'Bind address', + ) + .option( + '-p, --port ', + 'Port [8080]', + 8080, + parseInt, + ) + .option( + '-C|--no-cors', + 'Disable Cross-origin resource sharing headers', + ) + .option( + '-u|--public_url ', + 'Enable exposing the server on subpaths, not necessarily the root of the domain', + ) + .option( + '-V, --verbose', + 'More verbose output', + ) + .option( + '-s, --silent', + 'Less verbose output', + ) + .option( + '-l|--log_file ', + 'output log file (defaults to standard out)', + ) + .option( + '-f|--log_format ', + 'define the log format: https://github.com/expressjs/morgan#morganformat-options', + ) + .version( + packageJson.version, + '-v, --version', + ); +program.parse(process.argv); +const options = program.opts(); console.log(`Starting ${packageJson.name} v${packageJson.version}`); const startServer = (configPath, config) => { - let publicUrl = opts.public_url; + let publicUrl = options.public_url; if (publicUrl && publicUrl.lastIndexOf('/') !== publicUrl.length - 1) { publicUrl += '/'; } return require('./server')({ configPath: configPath, config: config, - bind: opts.bind, - port: opts.port, - cors: opts.cors, - verbose: opts.verbose, - silent: opts.silent, - logFile: opts.log_file, - logFormat: opts.log_format, + bind: options.bind, + port: options.port, + cors: options.cors, + verbose: options.verbose, + silent: options.silent, + logFile: options.log_file, + logFormat: options.log_format, publicUrl: publicUrl }); }; From b87a256e205dceb9c4ff5edaaeb6f49fa4efea61 Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 14 Sep 2022 21:31:02 -0400 Subject: [PATCH 2/4] use original variable name --- src/main.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.js b/src/main.js index ef44a3f..4440dea 100644 --- a/src/main.js +++ b/src/main.js @@ -70,25 +70,25 @@ program '-v, --version', ); program.parse(process.argv); -const options = program.opts(); +const opts = program.opts(); console.log(`Starting ${packageJson.name} v${packageJson.version}`); const startServer = (configPath, config) => { - let publicUrl = options.public_url; + let publicUrl = opts.public_url; if (publicUrl && publicUrl.lastIndexOf('/') !== publicUrl.length - 1) { publicUrl += '/'; } return require('./server')({ configPath: configPath, config: config, - bind: options.bind, - port: options.port, - cors: options.cors, - verbose: options.verbose, - silent: options.silent, - logFile: options.log_file, - logFormat: options.log_format, + bind: opts.bind, + port: opts.port, + cors: opts.cors, + verbose: opts.verbose, + silent: opts.silent, + logFile: opts.log_file, + logFormat: opts.log_format, publicUrl: publicUrl }); }; From b4cd42b1865373bb0713daa35fb2030f81099dba Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 14 Sep 2022 21:36:03 -0400 Subject: [PATCH 3/4] fix spacing --- src/main.js | 100 ++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/main.js b/src/main.js index 4440dea..a27e962 100644 --- a/src/main.js +++ b/src/main.js @@ -19,56 +19,56 @@ if (args.length >= 3 && args[2][0] !== '-') { const { program } = require('commander'); program - .description('tileserver-gl startup options') - .usage('tileserver-gl [mbtiles] [options]') - .option( - '--mbtiles ', - 'MBTiles file (uses demo configuration);\n' + - '\t ignored if the configuration file is also specified', - ) - .option( - '-c, --config ', - 'Configuration file [config.json]', - 'config.json', - ) - .option( - '-b, --bind
', - 'Bind address', - ) - .option( - '-p, --port ', - 'Port [8080]', - 8080, - parseInt, - ) - .option( - '-C|--no-cors', - 'Disable Cross-origin resource sharing headers', - ) - .option( - '-u|--public_url ', - 'Enable exposing the server on subpaths, not necessarily the root of the domain', - ) - .option( - '-V, --verbose', - 'More verbose output', - ) - .option( - '-s, --silent', - 'Less verbose output', - ) - .option( - '-l|--log_file ', - 'output log file (defaults to standard out)', - ) - .option( - '-f|--log_format ', - 'define the log format: https://github.com/expressjs/morgan#morganformat-options', - ) - .version( - packageJson.version, - '-v, --version', - ); + .description('tileserver-gl startup options') + .usage('tileserver-gl [mbtiles] [options]') + .option( + '--mbtiles ', + 'MBTiles file (uses demo configuration);\n' + + '\t ignored if the configuration file is also specified', + ) + .option( + '-c, --config ', + 'Configuration file [config.json]', + 'config.json', + ) + .option( + '-b, --bind
', + 'Bind address', + ) + .option( + '-p, --port ', + 'Port [8080]', + 8080, + parseInt, + ) + .option( + '-C|--no-cors', + 'Disable Cross-origin resource sharing headers', + ) + .option( + '-u|--public_url ', + 'Enable exposing the server on subpaths, not necessarily the root of the domain', + ) + .option( + '-V, --verbose', + 'More verbose output', + ) + .option( + '-s, --silent', + 'Less verbose output', + ) + .option( + '-l|--log_file ', + 'output log file (defaults to standard out)', + ) + .option( + '-f|--log_format ', + 'define the log format: https://github.com/expressjs/morgan#morganformat-options', + ) + .version( + packageJson.version, + '-v, --version', + ); program.parse(process.argv); const opts = program.opts(); From efb4b2c915b0c2d2b51d64bc2d87b4213ecb9091 Mon Sep 17 00:00:00 2001 From: acalcutt Date: Wed, 14 Sep 2022 21:39:35 -0400 Subject: [PATCH 4/4] orig formatting --- src/main.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main.js b/src/main.js index a27e962..c9725a2 100644 --- a/src/main.js +++ b/src/main.js @@ -24,51 +24,51 @@ program .option( '--mbtiles ', 'MBTiles file (uses demo configuration);\n' + - '\t ignored if the configuration file is also specified', + '\t ignored if the configuration file is also specified' ) .option( '-c, --config ', 'Configuration file [config.json]', - 'config.json', + 'config.json' ) .option( '-b, --bind
', - 'Bind address', + 'Bind address' ) .option( '-p, --port ', 'Port [8080]', 8080, - parseInt, + parseInt ) .option( '-C|--no-cors', - 'Disable Cross-origin resource sharing headers', + 'Disable Cross-origin resource sharing headers' ) .option( '-u|--public_url ', - 'Enable exposing the server on subpaths, not necessarily the root of the domain', + 'Enable exposing the server on subpaths, not necessarily the root of the domain' ) .option( '-V, --verbose', - 'More verbose output', + 'More verbose output' ) .option( '-s, --silent', - 'Less verbose output', + 'Less verbose output' ) .option( '-l|--log_file ', - 'output log file (defaults to standard out)', + 'output log file (defaults to standard out)' ) .option( '-f|--log_format ', - 'define the log format: https://github.com/expressjs/morgan#morganformat-options', + 'define the log format: https://github.com/expressjs/morgan#morganformat-options' ) .version( packageJson.version, - '-v, --version', - ); + '-v, --version' + ) program.parse(process.argv); const opts = program.opts();