From 3eeb080ec04fbde6547e670397dd423b97521cbf Mon Sep 17 00:00:00 2001 From: James George Date: Sun, 5 May 2019 07:06:13 +0530 Subject: [PATCH] feat($core): info command (#1573) --- packages/docs/docs/api/cli.md | 4 ++++ packages/vuepress/lib/registerCoreCommands.js | 22 +++++++++++++++++++ packages/vuepress/package.json | 3 ++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/docs/docs/api/cli.md b/packages/docs/docs/api/cli.md index 76154de439..3a4fa7b0ac 100644 --- a/packages/docs/docs/api/cli.md +++ b/packages/docs/docs/api/cli.md @@ -46,6 +46,10 @@ do not clear screen when dev server is ready. Copy the default theme into `.vuepress/theme` for customization. +## info + +Shows debugging information about the local environment. + ## more commands You can create a custom command with [extendCli](../plugin/option-api.md#extendcli). diff --git a/packages/vuepress/lib/registerCoreCommands.js b/packages/vuepress/lib/registerCoreCommands.js index ee0a78fdd3..44e40a081f 100644 --- a/packages/vuepress/lib/registerCoreCommands.js +++ b/packages/vuepress/lib/registerCoreCommands.js @@ -4,6 +4,9 @@ * Module dependencies. */ +const { chalk } = require('@vuepress/shared-utils') +const envinfo = require('envinfo') + const { dev, build, eject } = require('@vuepress/core') const { path, logger, env } = require('@vuepress/shared-utils') const { wrapCommand } = require('./util') @@ -69,4 +72,23 @@ module.exports = function (cli, options) { .action((dir = '.') => { wrapCommand(eject)(path.resolve(dir)) }) + + cli + .command('info', 'Shows debugging information about the local environment') + .action(() => { + console.log(chalk.bold('\nEnvironment Info:')) + envinfo.run( + { + System: ['OS', 'CPU'], + Binaries: ['Node', 'Yarn', 'npm'], + Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'], + npmPackages: ['/**/{@vuepress/*/}'] + }, + { + showNotFound: true, + duplicates: true, + fullTree: true + } + ).then(console.log) + }) } diff --git a/packages/vuepress/package.json b/packages/vuepress/package.json index 9048abe96d..c55526efad 100644 --- a/packages/vuepress/package.json +++ b/packages/vuepress/package.json @@ -31,7 +31,8 @@ "dependencies": { "@vuepress/core": "^1.0.0-alpha.47", "@vuepress/theme-default": "^1.0.0-alpha.47", - "cac": "^6.3.9" + "cac": "^6.3.9", + "envinfo": "^7.2.0" }, "engines": { "node": ">=8.6"