Skip to content

added info CLI command#14428

Closed
tabrindle wants to merge 9 commits into
react:masterfrom
tabrindle:feature/react-native-cli-info
Closed

added info CLI command#14428
tabrindle wants to merge 9 commits into
react:masterfrom
tabrindle:feature/react-native-cli-info

Conversation

@tabrindle

Copy link
Copy Markdown
Contributor

Motivation (required)

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

Test Plan (required)

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 

Next Steps

  • CLA signed ✅
  • Verify functionality + implementation

- install os-name package
- require info in commands.js
- implement info.js with node/npm versions etc
@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Jun 9, 2017
@st0ffern

st0ffern commented Jun 9, 2017

Copy link
Copy Markdown

Great idea.
Would you add a Android Studio version check + packages if possible too? 😉

@tabrindle

Copy link
Copy Markdown
Contributor Author

Gets a bit hairy there because Android studio can be installed anywhere. Also sdkmanager and the older android manager very different.

I'll do my best, any recommendations are welcome.

@hramos hramos self-assigned this Jun 9, 2017
@tabrindle

Copy link
Copy Markdown
Contributor Author

@Stoffern By packages do you mean dev/Dependencies from package.json?

Trevor Brindle added 3 commits June 12, 2017 13:02
- rename confusing variable for buildnumber
- add wmic and type calls for version/build for windows android studio
- It is, in fact, named Program Files
- add better fallback language
@st0ffern

st0ffern commented Jun 12, 2017

Copy link
Copy Markdown

@tabrindle yes react-native and react versions should cover it

@tabrindle

Copy link
Copy Markdown
Contributor Author

Output now looks like this:

Versions:
  React Native:  1000.0.0
  React:  16.0.0-alpha.12
  OS:  macOS Sierra
  Node:  v6.10.3
  Yarn:  0.24.5
  npm:  5.0.0
  Xcode:  Xcode 8.3.3 Build version 8E3004b 
  Android Studio:  2.3 AI-162.3934792 ```

@st0ffern

st0ffern commented Jun 13, 2017

Copy link
Copy Markdown

Thats all i have. Is it fully tested and ready to be merged?

@tabrindle

Copy link
Copy Markdown
Contributor Author

I have tested on Windows Linux and MacOS for typical install locations, mostly because of Android Studio being difficult. If nobody has any objections, I believe it is ready.

@st0ffern

st0ffern commented Jun 13, 2017

Copy link
Copy Markdown

@tabrindle great work.
Looks good to me 😉

@tabrindle

Copy link
Copy Markdown
Contributor Author

My other PR has been updated to reflect the changes here as well - can you review that one too? It is for the issue template.
#14422

@st0ffern

st0ffern commented Jun 13, 2017

Copy link
Copy Markdown

@tabrindle i do not have the rights to confirm the review.
Perhaps @hramos can help out with both? 😉

@tabrindle

Copy link
Copy Markdown
Contributor Author

I got tired of waiting for this PR to be looked at - I have been working on a separate module based on this work called envinfo on npm. That way, this can be used and extended in other projects.

npm i -g envinfo, then envinfo will result in essentially the same output as above.

If you use npx (npm i -g npx) you can directly invoke envinfo (or any other package) without a global install, then invoke it like this: npx envinfo

Bonus, this package now has the ability to specify through command line args which packages to pull from the cwd package.json, or all of them, like this: envinfo --packages react,react-native and it will look like this:

Environment:
  OS:  macOS Sierra
  Node:  v7.10.0
  Yarn:  0.24.5
  npm:  4.2.0
  Xcode:  Xcode 8.3.3 Build version 8E3004b 
  Android Studio:  2.3 AI-162.3934792 
  react:  16.0.0-alpha.6
  react-native:  0.44.0

In an effort to start helping user+maintainers in the issues, I will start posting this.

@hramos

hramos commented Jun 22, 2017

Copy link
Copy Markdown
Contributor

Sorry for the delay in getting this looked at. As you may have noticed, I've been spending more time trying to get the number of issues down rather than working on getting PRs moving as we usually do. Providing this as a separate package seems like a better approach as this can benefit many other projects. I suppose we can pull in this as a dependency on the CLI and therefore still provide a info command?

@tabrindle

Copy link
Copy Markdown
Contributor Author

No problem at all! I just wanted to be able to help get the issue count down. Once this is in, we can just close issues without the relevant debug info.

As long as you are comfortable pulling in my separate package, and just using it for the react-native info command, I will modify this PR for that.

I wasn't sure if that was the direction I should go, considering how few external modules are used in the CLI. I am planning to continue developing my envinfo module, and wasn't sure the react/react-native team would allow code that wasn't reviewed first hand.

@shergin

shergin commented Jun 29, 2017

Copy link
Copy Markdown
Contributor

Omg, I think it is suuuuper useful.
I have not strong point about where it should live, but I believe it should be available as react-native info without additional hassle.

We have to merge #14422 as well!

@tabrindle

Copy link
Copy Markdown
Contributor Author

I have updated the PR to simply wrap my envinfo module. I have also added options through the react native cli to add additional package versions if necessary, along with examples to go with it. By default the react-native info command will pass react and react-native to the envinfo --packages command, but you can add whatever else you want.

Output now looks like this by default:

Environment:
  OS:  macOS Sierra 10.12.4
  Node:  v7.10.0
  Yarn:  0.24.5
  npm:  4.2.0
  Xcode:  Xcode 8.3.3 Build version 8E3004b 
  Android Studio:  2.3 AI-162.3934792 
Packages:
  react:  16.0.0-alpha.6
  react-native:  0.44

--help looks like this:

  react-native info [options]
  Get relevant version info about OS, toolchain and libraries

  Options:

    -h, --help           output usage information
    --packages [string]  Which packages from your package.json to include, in addition to the default React Native and React versions.
    --config [string]    Path to the CLI configuration file

  Example usage:

    Get standard version info: 
    react-native info

    Get standard version info & specified package versions: 
    react-native info --packages jest,eslint,babel-polyfill

adding additional packages looks like this:

Environment:
  OS:  macOS Sierra 10.12.4
  Node:  v7.10.0
  Yarn:  0.24.5
  npm:  4.2.0
  Xcode:  Xcode 8.3.3 Build version 8E3004b 
  Android Studio:  2.3 AI-162.3934792 
Packages:
  react:  16.0.0-alpha.6
  react-native:  0.44
  jest:  ^20.0.4
  eslint:  ^3.19.0
  babel-polyfill:  ^6.23.0

@hramos Let me know if there is anything else you can think of.

@hramos
hramos requested a review from grabbou June 29, 2017 22:18
@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Jul 10, 2017
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@facebook-github-bot facebook-github-bot added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Jul 11, 2017
@hramos

hramos commented Jul 11, 2017

Copy link
Copy Markdown
Contributor

Working on the merge failure, shouldn't be too long.

@tabrindle

Copy link
Copy Markdown
Contributor Author

Would it help if I rebased @hramos?

@hramos

hramos commented Jul 18, 2017

Copy link
Copy Markdown
Contributor

It should be landing shortly. Don't add any more commits, please.

@tabrindle

Copy link
Copy Markdown
Contributor Author

👍

facebook-github-bot pushed a commit that referenced this pull request May 30, 2018
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
```

#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 #19331

Differential Revision: D8049650

Pulled By: hramos

fbshipit-source-id: 35c677f369bcad1a014eb083b2ce60ba33fee0ea
grabbou pushed a commit to react-native-community/cli that referenced this pull request Sep 26, 2018
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 react/react-native#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 react/react-native#14428

Differential Revision: D5392446

Pulled By: hramos

fbshipit-source-id: 460079f3860c0af1e0b77bf26552c26032e974be
grabbou pushed a commit to react-native-community/cli that referenced this pull request Sep 26, 2018
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
```

react/react-native#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 react/react-native#19331

Differential Revision: D8049650

Pulled By: hramos

fbshipit-source-id: 35c677f369bcad1a014eb083b2ce60ba33fee0ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants