react-native/local-cli/info/info.js

86 lines
2.2 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const envinfo = require('envinfo');
const info = function() {
const args = Array.prototype.slice.call(arguments)[2];
try {
cli: upgrade envinfo for new features in `react-native info` Summary: envinfo has done a good job reporting issues in the issue template so far, and I've done a lot of work between version 3.x and 5.x that react-native could benefit from. This adds: - better information organization, including versions and paths - Platform/CPU/RAM - Android and iOS SDK version detection - npm package globbing (select all babel* packages - global npm packages (with globbing) envinfo also can report IDE versions, other binaries, languages and browsers if needed, and in different formats. Take a look here if interested: https://github.com/tabrindle/envinfo - run `react-native info` // standard info - run `react-native info --packages` // all packages in package.json - run `react-native info --packages jest,eslint,babel-polyfill` // specified packages - run `react-native info --packages *babel*` // globbed packages Sample standard output: ``` System: OS: macOS High Sierra 10.13 CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 97.59 MB / 16.00 GB Shell: 5.4.2 - /usr/local/bin/zsh Binaries: Node: 8.11.0 - ~/.nvm/versions/node/v8.11.0/bin/node Yarn: 1.5.1 - ~/.yarn/bin/yarn npm: 5.6.0 - ~/.nvm/versions/node/v8.11.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 11.0, macOS 10.13, tvOS 11.0, watchOS 4.0 Android SDK: Build Tools: 27.0.3 API Levels: 26 IDEs: Android Studio: 3.0 AI-171.4443003 Xcode: 9.0/9A235 - /usr/bin/xcodebuild npmPackages: react: 16.3.2 => 16.3.2 react-native: 0.55.0 => 0.55.0 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 ``` https://github.com/facebook/react-native/pull/14428 - original inclusion of `react-native info` [CLI] [ENHANCEMENT] [local-cli/info/info.js] - add more info to react-native info cli command, like global npm packages, binary paths, and SDK versions Closes https://github.com/facebook/react-native/pull/19331 Differential Revision: D8049650 Pulled By: hramos fbshipit-source-id: 35c677f369bcad1a014eb083b2ce60ba33fee0ea
2018-05-29 23:58:32 +00:00
envinfo
.run(
{
System: ['OS', 'CPU', 'Memory', 'Shell'],
Binaries: ['Node', 'Yarn', 'npm', 'Watchman'],
IDEs: ['Xcode', 'Android Studio'],
SDKs: ['iOS SDK', 'Android SDK'],
npmPackages:
(typeof args.packages === 'string' &&
!args.packages.includes('*')) ||
!args.packages
? ['react', 'react-native'].concat(
(args.packages || '').split(','),
)
: args.packages,
npmGlobalPackages: '*react-native*',
},
{
clipboard: !!args.clipboard,
title: 'React Native Environment Info',
},
)
.then(console.log)
.catch(err => {
console.log('Error: unable to print environment info');
console.log(err);
});
} catch (err) {
console.log('Error: unable to print environment info');
cli: upgrade envinfo for new features in `react-native info` Summary: envinfo has done a good job reporting issues in the issue template so far, and I've done a lot of work between version 3.x and 5.x that react-native could benefit from. This adds: - better information organization, including versions and paths - Platform/CPU/RAM - Android and iOS SDK version detection - npm package globbing (select all babel* packages - global npm packages (with globbing) envinfo also can report IDE versions, other binaries, languages and browsers if needed, and in different formats. Take a look here if interested: https://github.com/tabrindle/envinfo - run `react-native info` // standard info - run `react-native info --packages` // all packages in package.json - run `react-native info --packages jest,eslint,babel-polyfill` // specified packages - run `react-native info --packages *babel*` // globbed packages Sample standard output: ``` System: OS: macOS High Sierra 10.13 CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 97.59 MB / 16.00 GB Shell: 5.4.2 - /usr/local/bin/zsh Binaries: Node: 8.11.0 - ~/.nvm/versions/node/v8.11.0/bin/node Yarn: 1.5.1 - ~/.yarn/bin/yarn npm: 5.6.0 - ~/.nvm/versions/node/v8.11.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 11.0, macOS 10.13, tvOS 11.0, watchOS 4.0 Android SDK: Build Tools: 27.0.3 API Levels: 26 IDEs: Android Studio: 3.0 AI-171.4443003 Xcode: 9.0/9A235 - /usr/bin/xcodebuild npmPackages: react: 16.3.2 => 16.3.2 react-native: 0.55.0 => 0.55.0 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 ``` https://github.com/facebook/react-native/pull/14428 - original inclusion of `react-native info` [CLI] [ENHANCEMENT] [local-cli/info/info.js] - add more info to react-native info cli command, like global npm packages, binary paths, and SDK versions Closes https://github.com/facebook/react-native/pull/19331 Differential Revision: D8049650 Pulled By: hramos fbshipit-source-id: 35c677f369bcad1a014eb083b2ce60ba33fee0ea
2018-05-29 23:58:32 +00:00
console.log(err);
}
};
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.',
cli: upgrade envinfo for new features in `react-native info` Summary: envinfo has done a good job reporting issues in the issue template so far, and I've done a lot of work between version 3.x and 5.x that react-native could benefit from. This adds: - better information organization, including versions and paths - Platform/CPU/RAM - Android and iOS SDK version detection - npm package globbing (select all babel* packages - global npm packages (with globbing) envinfo also can report IDE versions, other binaries, languages and browsers if needed, and in different formats. Take a look here if interested: https://github.com/tabrindle/envinfo - run `react-native info` // standard info - run `react-native info --packages` // all packages in package.json - run `react-native info --packages jest,eslint,babel-polyfill` // specified packages - run `react-native info --packages *babel*` // globbed packages Sample standard output: ``` System: OS: macOS High Sierra 10.13 CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 97.59 MB / 16.00 GB Shell: 5.4.2 - /usr/local/bin/zsh Binaries: Node: 8.11.0 - ~/.nvm/versions/node/v8.11.0/bin/node Yarn: 1.5.1 - ~/.yarn/bin/yarn npm: 5.6.0 - ~/.nvm/versions/node/v8.11.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 11.0, macOS 10.13, tvOS 11.0, watchOS 4.0 Android SDK: Build Tools: 27.0.3 API Levels: 26 IDEs: Android Studio: 3.0 AI-171.4443003 Xcode: 9.0/9A235 - /usr/bin/xcodebuild npmPackages: react: 16.3.2 => 16.3.2 react-native: 0.55.0 => 0.55.0 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 ``` https://github.com/facebook/react-native/pull/14428 - original inclusion of `react-native info` [CLI] [ENHANCEMENT] [local-cli/info/info.js] - add more info to react-native info cli command, like global npm packages, binary paths, and SDK versions Closes https://github.com/facebook/react-native/pull/19331 Differential Revision: D8049650 Pulled By: hramos fbshipit-source-id: 35c677f369bcad1a014eb083b2ce60ba33fee0ea
2018-05-29 23:58:32 +00:00
},
{
command: '--clipboard [boolean]',
description:
'Automagically copy the environment report output to the clipboard',
},
],
examples: [
{
desc: 'Get standard version info',
cmd: 'react-native info',
},
{
desc: 'Get standard version info & specified package versions',
cli: upgrade envinfo for new features in `react-native info` Summary: envinfo has done a good job reporting issues in the issue template so far, and I've done a lot of work between version 3.x and 5.x that react-native could benefit from. This adds: - better information organization, including versions and paths - Platform/CPU/RAM - Android and iOS SDK version detection - npm package globbing (select all babel* packages - global npm packages (with globbing) envinfo also can report IDE versions, other binaries, languages and browsers if needed, and in different formats. Take a look here if interested: https://github.com/tabrindle/envinfo - run `react-native info` // standard info - run `react-native info --packages` // all packages in package.json - run `react-native info --packages jest,eslint,babel-polyfill` // specified packages - run `react-native info --packages *babel*` // globbed packages Sample standard output: ``` System: OS: macOS High Sierra 10.13 CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 97.59 MB / 16.00 GB Shell: 5.4.2 - /usr/local/bin/zsh Binaries: Node: 8.11.0 - ~/.nvm/versions/node/v8.11.0/bin/node Yarn: 1.5.1 - ~/.yarn/bin/yarn npm: 5.6.0 - ~/.nvm/versions/node/v8.11.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 11.0, macOS 10.13, tvOS 11.0, watchOS 4.0 Android SDK: Build Tools: 27.0.3 API Levels: 26 IDEs: Android Studio: 3.0 AI-171.4443003 Xcode: 9.0/9A235 - /usr/bin/xcodebuild npmPackages: react: 16.3.2 => 16.3.2 react-native: 0.55.0 => 0.55.0 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 ``` https://github.com/facebook/react-native/pull/14428 - original inclusion of `react-native info` [CLI] [ENHANCEMENT] [local-cli/info/info.js] - add more info to react-native info cli command, like global npm packages, binary paths, and SDK versions Closes https://github.com/facebook/react-native/pull/19331 Differential Revision: D8049650 Pulled By: hramos fbshipit-source-id: 35c677f369bcad1a014eb083b2ce60ba33fee0ea
2018-05-29 23:58:32 +00:00
cmd: 'react-native info --packages jest,eslint',
},
{
desc: 'Get standard version info & globbed package versions',
cmd: 'react-native info --packages "*react*"',
},
{
desc: 'Get standard version info & all package versions',
cmd: 'react-native info --packages',
},
],
func: info,
};