diff --git a/local-cli/commands.js b/local-cli/commands.js index 38912ba4d9b13b..9f27908e9d6dcf 100644 --- a/local-cli/commands.js +++ b/local-cli/commands.js @@ -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 diff --git a/local-cli/info/info.js b/local-cli/info/info.js new file mode 100644 index 00000000000000..f443146ef59c4b --- /dev/null +++ b/local-cli/info/info.js @@ -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, +}; diff --git a/package.json b/package.json index c8d17004014afd..577e3904534259 100644 --- a/package.json +++ b/package.json @@ -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",