Permalink
Browse files

added info CLI command

Summary:
Many issues filed on Github are missing platform/toolchain version information. Others have different ways of writing it, and require the issue writer to look in multiple places for these versions.
Other CLI tools like Ionic have this function, and it's incredibly useful. Related to #14420

Run in terminal/command prompt `react-native info`

```
trevors-imac:AwesomeProject tabrindle$ react-native info
Versions:
  React Native:  1000.0.0
  OS:  macOS Sierra
  Node:  v6.10.3
  Yarn:  0.24.5
  npm:  5.0.0
  Xcode:  Xcode 8.3.3 Build version 8E3004b
```

- CLA signed 
- Verify functionality + implementation
Closes #14428

Differential Revision: D5392446

Pulled By: hramos

fbshipit-source-id: 460079f3860c0af1e0b77bf26552c26032e974be
  • Loading branch information...
Trevor Brindle authored and facebook-github-bot committed Jul 18, 2017
1 parent 0681887 commit 95ee3f5cab2ce734aac74f681f9859c7ed5a11d3
Showing with 49 additions and 0 deletions.
  1. +1 −0 local-cli/commands.js
  2. +47 −0 local-cli/info/info.js
  3. +1 −0 package.json
View
@@ -51,6 +51,7 @@ const documentedCommands = [
require('./logAndroid/logAndroid'),
require('./logIOS/logIOS'),
require('./dependencies/dependencies'),
require('./info/info'),
];
// The user should never get here because projects are inited by
View
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const envinfo = require('envinfo');
const info = function() {
const args = Array.prototype.slice.call(arguments)[2];
try {
envinfo.print({
packages: typeof args.packages === 'string' ? ['react', 'react-native'].concat(args.packages.split(',')) : args.packages
});
} catch (error) {
console.log('Error: unable to print environment info');
console.log(error);
}
};
module.exports = {
name: 'info',
description: 'Get relevant version info about OS, toolchain and libraries',
options: [
{
command: '--packages [string]',
description: 'Which packages from your package.json to include, in addition to the default React Native and React versions.',
default: ['react', 'react-native']
},
],
examples: [
{
desc: 'Get standard version info',
cmd: 'react-native info',
},
{
desc: 'Get standard version info & specified package versions',
cmd: 'react-native info --packages jest,eslint,babel-polyfill',
}
],
func: info,
};
View
@@ -166,6 +166,7 @@
"create-react-class": "^15.5.2",
"debug": "^2.2.0",
"denodeify": "^1.2.1",
"envinfo": "^3.0.0",
"errno": ">=0.1.1 <0.2.0-0",
"event-target-shim": "^1.0.5",
"fbjs": "0.8.12",

0 comments on commit 95ee3f5

Please sign in to comment.