Skip to content

Commit 95ee3f5

Browse files
Trevor Brindlefacebook-github-bot
authored andcommitted
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
1 parent 0681887 commit 95ee3f5

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

local-cli/commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const documentedCommands = [
5151
require('./logAndroid/logAndroid'),
5252
require('./logIOS/logIOS'),
5353
require('./dependencies/dependencies'),
54+
require('./info/info'),
5455
];
5556

5657
// The user should never get here because projects are inited by

local-cli/info/info.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
'use strict';
10+
11+
const envinfo = require('envinfo');
12+
13+
const info = function() {
14+
const args = Array.prototype.slice.call(arguments)[2];
15+
16+
try {
17+
envinfo.print({
18+
packages: typeof args.packages === 'string' ? ['react', 'react-native'].concat(args.packages.split(',')) : args.packages
19+
});
20+
} catch (error) {
21+
console.log('Error: unable to print environment info');
22+
console.log(error);
23+
}
24+
};
25+
26+
module.exports = {
27+
name: 'info',
28+
description: 'Get relevant version info about OS, toolchain and libraries',
29+
options: [
30+
{
31+
command: '--packages [string]',
32+
description: 'Which packages from your package.json to include, in addition to the default React Native and React versions.',
33+
default: ['react', 'react-native']
34+
},
35+
],
36+
examples: [
37+
{
38+
desc: 'Get standard version info',
39+
cmd: 'react-native info',
40+
},
41+
{
42+
desc: 'Get standard version info & specified package versions',
43+
cmd: 'react-native info --packages jest,eslint,babel-polyfill',
44+
}
45+
],
46+
func: info,
47+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
"create-react-class": "^15.5.2",
167167
"debug": "^2.2.0",
168168
"denodeify": "^1.2.1",
169+
"envinfo": "^3.0.0",
169170
"errno": ">=0.1.1 <0.2.0-0",
170171
"event-target-shim": "^1.0.5",
171172
"fbjs": "0.8.12",

0 commit comments

Comments
 (0)