mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 03:19:36 +01:00
feat(chore): Included provision to show up local environment information (#1365)
* feat: adds provision to show up environment information Fixes #1364 * feat: include docker info * fix: pin envinfo * fix: lock file * fix: docker config * fix: minor refactor handle async behaviour * feat: add short version for info
This commit is contained in:
parent
6ff356b312
commit
eb6bf5168b
@ -28,6 +28,7 @@
|
||||
"cookies": "0.7.3",
|
||||
"cors": "2.8.5",
|
||||
"dayjs": "1.8.14",
|
||||
"envinfo": "7.3.1",
|
||||
"express": "4.16.4",
|
||||
"handlebars": "4.1.2",
|
||||
"http-errors": "1.7.2",
|
||||
|
@ -31,29 +31,24 @@ process.title = 'verdaccio';
|
||||
const logger = require('./logger');
|
||||
logger.setup(); // default setup
|
||||
|
||||
const envinfo = require('envinfo');
|
||||
const commander = require('commander');
|
||||
const pkgVersion = module.exports.version;
|
||||
const pkgName = module.exports.name;
|
||||
|
||||
commander
|
||||
.option('-i, --info', 'prints debugging information about the local environment')
|
||||
.option('-l, --listen <[host:]port>', 'host:port number to listen on (default: localhost:4873)')
|
||||
.option('-c, --config <config.yaml>', 'use this configuration file (default: ./config.yaml)')
|
||||
.version(pkgVersion)
|
||||
.parse(process.argv);
|
||||
|
||||
if (commander.args.length == 1 && !commander.config) {
|
||||
// handling "verdaccio [config]" case if "-c" is missing in command line
|
||||
commander.config = commander.args.pop();
|
||||
}
|
||||
function init() {
|
||||
let verdaccioConfiguration;
|
||||
let configPathLocation;
|
||||
const cliListener = commander.listen;
|
||||
|
||||
if (commander.args.length !== 0) {
|
||||
commander.help();
|
||||
}
|
||||
let verdaccioConfiguration;
|
||||
let configPathLocation;
|
||||
const cliListener = commander.listen;
|
||||
|
||||
try {
|
||||
try {
|
||||
configPathLocation = findConfigFile(commander.config);
|
||||
verdaccioConfiguration = parseConfigFile(configPathLocation);
|
||||
process.title = verdaccioConfiguration.web && verdaccioConfiguration.web.title || 'verdaccio';
|
||||
@ -68,9 +63,35 @@ try {
|
||||
logger.logger.warn({file: configPathLocation}, 'config file - @{file}');
|
||||
|
||||
startVerdaccio(verdaccioConfiguration, cliListener, configPathLocation, pkgVersion, pkgName, listenDefaultCallback);
|
||||
} catch (err) {
|
||||
} catch (err) {
|
||||
logger.logger.fatal({file: configPathLocation, err: err}, 'cannot open config file @{file}: @{!err.message}');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (commander.info) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('\nEnvironment Info:');
|
||||
(async () => {
|
||||
const data = await envinfo.run({
|
||||
System: ['OS', 'CPU'],
|
||||
Binaries: ['Node', 'Yarn', 'npm'],
|
||||
Virtualization: ['Docker'],
|
||||
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
||||
npmGlobalPackages: ['verdaccio'],
|
||||
});
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(data);
|
||||
process.exit(1);
|
||||
})();
|
||||
} else if (commander.args.length == 1 && !commander.config) {
|
||||
// handling "verdaccio [config]" case if "-c" is missing in command line
|
||||
commander.config = commander.args.pop();
|
||||
init();
|
||||
} else if (commander.args.length !== 0) {
|
||||
commander.help();
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
|
||||
process.on('uncaughtException', function(err) {
|
||||
|
BIN
yarn.lock
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in New Issue
Block a user