Skip to content

Commit 1f30993

Browse files
committed
feat(cli): add info command
1 parent 576a30e commit 1f30993

File tree

6 files changed

+58
-2
lines changed

6 files changed

+58
-2
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"cSpell.words": [
2020
"devtool",
2121
"docsearch",
22+
"envinfo",
2223
"esbuild",
2324
"frontmatter",
2425
"globby",

packages/@vuepress/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@vuepress/utils": "2.0.0-alpha.7",
3535
"cac": "^6.7.1",
3636
"chokidar": "^3.4.3",
37+
"envinfo": "^7.7.3",
3738
"esbuild": "^0.8.21"
3839
},
3940
"publishConfig": {

packages/@vuepress/cli/src/cli.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cac } from 'cac'
22
import { chalk } from '@vuepress/utils'
3-
import { build, dev } from './commands'
3+
import { build, dev, info } from './commands'
44
import { allowTs } from './utils'
55

66
/**
@@ -61,5 +61,10 @@ export const cli = (): void => {
6161
.option('--debug', 'Enable debug mode')
6262
.action(wrapCommand(build))
6363

64+
// register `info` command
65+
program
66+
.command('info', 'Display environment information')
67+
.action(wrapCommand(info))
68+
6469
program.parse(process.argv)
6570
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './build'
22
export * from './dev'
3+
export * from './info'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as envinfo from 'envinfo'
2+
import { ora } from '@vuepress/utils'
3+
4+
export const info = async (): Promise<void> => {
5+
const spinner = ora()
6+
spinner.start('Collecting Environment Info')
7+
8+
const result = await envinfo.run(
9+
{
10+
System: ['OS', 'CPU', 'Memory', 'Shell'],
11+
Binaries: ['Node', 'Yarn', 'npm'],
12+
Utilities: ['Git'],
13+
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
14+
npmPackages: [
15+
'@vuepress/bundler-webpack',
16+
'@vuepress/cli',
17+
'@vuepress/client',
18+
'@vuepress/core',
19+
'@vuepress/markdown',
20+
'@vuepress/plugin-active-header-links',
21+
'@vuepress/plugin-back-to-top',
22+
'@vuepress/plugin-container',
23+
'@vuepress/plugin-debug',
24+
'@vuepress/plugin-docsearch',
25+
'@vuepress/plugin-git',
26+
'@vuepress/plugin-google-analytics',
27+
'@vuepress/plugin-medium-zoom',
28+
'@vuepress/plugin-nprogress',
29+
'@vuepress/plugin-palette-stylus',
30+
'@vuepress/plugin-pwa',
31+
'@vuepress/plugin-pwa-popup',
32+
'@vuepress/shared',
33+
'@vuepress/theme-default',
34+
'@vuepress/theme-vue',
35+
'@vuepress/utils',
36+
'vuepress',
37+
],
38+
},
39+
{
40+
showNotFound: true,
41+
duplicates: true,
42+
fullTree: true,
43+
}
44+
)
45+
spinner.stop()
46+
47+
console.info(result)
48+
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5021,7 +5021,7 @@ env-paths@^2.2.0:
50215021
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.0.tgz#cdca557dc009152917d6166e2febe1f039685e43"
50225022
integrity sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==
50235023

5024-
envinfo@^7.3.1:
5024+
envinfo@^7.3.1, envinfo@^7.7.3:
50255025
version "7.7.3"
50265026
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.7.3.tgz#4b2d8622e3e7366afb8091b23ed95569ea0208cc"
50275027
integrity sha512-46+j5QxbPWza0PB1i15nZx0xQ4I/EfQxg9J8Had3b408SV63nEtor2e+oiY63amTo9KTuh2a3XLObNwduxYwwA==

0 commit comments

Comments
 (0)