Skip to content

Commit

Permalink
feat($core): info command (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored and ulivz committed May 5, 2019
1 parent 3c560d1 commit 3eeb080
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/docs/docs/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
22 changes: 22 additions & 0 deletions packages/vuepress/lib/registerCoreCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
})
}
3 changes: 2 additions & 1 deletion packages/vuepress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3eeb080

Please sign in to comment.