Skip to content

Commit

Permalink
feat(cli): add sysinfo command
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucharz committed Aug 21, 2018
1 parent 4ba93f4 commit 9dd7890
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ const setup = async () => {
new commands.Logout(context).run(options)
})

program
.command('sysinfo')
.group('Basics')
.description('Sys info for debug purpose')
.action((...options) => {
trackAndDebug(options)
new commands.SysInfo(context).run(options)
})

program
.command('hot [socket_name]')
.group('Project')
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import ComponentLink from './component-link'
import InstanceList from './instance-list'
import InstanceCreate from './instance-create'
import InstanceDelete from './instance-delete'
import SysInfo from './sysinfo'

export default {
Attach,
Expand Down Expand Up @@ -51,5 +52,6 @@ export default {
ComponentLink,
InstanceList,
InstanceCreate,
InstanceDelete
InstanceDelete,
SysInfo
}
37 changes: 37 additions & 0 deletions packages/cli/src/commands/sysinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os from 'os'
import child_process from 'child_process'
import format from 'chalk'

import logger from '../utils/debug'
import { p, echo, echon } from '../utils/print-tools'
import pjson from '../../package.json'

const { debug } = logger('cmd-sysinfo')

export default class SysInfoCmd {
constructor (context) {
debug('SysInfoCmd.constructor')
this.context = context
this.session = context.session
}

async run ([cmd]) {
const npmVersion = child_process.spawnSync('npm', ['-v'])
.stdout
.toString()
.trim()

echo()
echon(2)(` ${format.dim('cli version')}:`)
echo(` ${format.cyan(pjson.version)}`)
echon(2)(`${format.dim('node version')}:`)
echo(` ${format.cyan(process.version)}`)
echon(2)(` ${format.dim('npm version')}:`)
echo(` ${format.cyan(npmVersion)}`)
echon(2)(` ${format.dim('platform')}:`)
echo(` ${format.cyan(os.type)}`)
echon(2)(` ${format.dim('arch')}:`)
echo(` ${format.cyan(process.arch)}`)
echo()
}
}

0 comments on commit 9dd7890

Please sign in to comment.