2016-09-24 13:34:05 -04:00
|
|
|
import program from './commander';
|
|
|
|
|
|
|
|
|
|
function logStartupOptions(options) {
|
2023-08-18 02:11:24 +02:00
|
|
|
if (!options.verbose) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Keys that may include sensitive information that will be redacted in logs
|
|
|
|
|
const keysToRedact = [
|
|
|
|
|
'databaseURI',
|
|
|
|
|
'masterKey',
|
|
|
|
|
'maintenanceKey',
|
|
|
|
|
'push',
|
|
|
|
|
];
|
2016-12-07 15:17:05 -08:00
|
|
|
for (const key in options) {
|
2016-09-24 13:34:05 -04:00
|
|
|
let value = options[key];
|
2023-08-18 02:11:24 +02:00
|
|
|
if (keysToRedact.includes(key)) {
|
|
|
|
|
value = '<REDACTED>';
|
2019-01-27 19:59:15 +01:00
|
|
|
}
|
2016-09-24 13:34:05 -04:00
|
|
|
if (typeof value === 'object') {
|
2017-10-23 08:43:05 -04:00
|
|
|
try {
|
2018-09-01 13:58:06 -04:00
|
|
|
value = JSON.stringify(value);
|
|
|
|
|
} catch (e) {
|
2017-10-23 08:43:05 -04:00
|
|
|
if (value && value.constructor && value.constructor.name) {
|
|
|
|
|
value = value.constructor.name;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-24 13:34:05 -04:00
|
|
|
}
|
2016-11-24 15:47:41 -05:00
|
|
|
/* eslint-disable no-console */
|
2016-09-24 13:34:05 -04:00
|
|
|
console.log(`${key}: ${value}`);
|
2016-11-24 15:47:41 -05:00
|
|
|
/* eslint-enable no-console */
|
2016-09-24 13:34:05 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-13 11:19:04 -06:00
|
|
|
export default function ({ definitions, help, usage, start }) {
|
2016-09-24 13:34:05 -04:00
|
|
|
program.loadDefinitions(definitions);
|
|
|
|
|
if (usage) {
|
|
|
|
|
program.usage(usage);
|
|
|
|
|
}
|
|
|
|
|
if (help) {
|
|
|
|
|
program.on('--help', help);
|
|
|
|
|
}
|
|
|
|
|
program.parse(process.argv, process.env);
|
|
|
|
|
|
2016-12-07 15:17:05 -08:00
|
|
|
const options = program.getOptions();
|
2020-12-13 11:19:04 -06:00
|
|
|
start(program, options, function () {
|
2016-09-24 13:34:05 -04:00
|
|
|
logStartupOptions(options);
|
|
|
|
|
});
|
2016-12-01 10:24:46 -08:00
|
|
|
}
|