react-native-community / discussions-and-proposals

Discussions and proposals related to the main React Native project
https://reactnative.dev
1.68k stars 127 forks source link

Improving the React Native command line experience #241

Open molant opened 4 years ago

molant commented 4 years ago

React Native and command line experience(s)

The RN community has a wide variety of command line tools (react-native-community/cli, create-react-native-app, expo-cli, ignite-cli, etc.). While all have unique features (templates, environment validation, generators, etc...), feature overlap causes confusing and unnecessary cognitive overheard to developers. In addition, a lot of documentation is a bit outdated and can be a detriment to new developers getting started with React Native. One of the main reasons we've learned that developers end up using different technologies is because React Native does not feel well integrated.

There have been some conversations in Discord about what could be done to improve this situation and the immediate outcome was to move this conversation to a public forum, discuss what things are important to each of us, and agree on a set of features and collectively decide how to get there.

What are the must have features you would like to see in this CLI?

From Microsoft's side these are the things that are important to us:

So the above would translate into:

  1. Fast and lightweight: npx is the "defacto-standard" to run most of the current solutions so we would like to make it as lean and fast as possible.
  2. Pluggable: The current react-native-community/cli allows for adding run-XXX parameters, but there are other aspects that are more "monolithic": init and doctor are the most obvious, but we might want to have an option to add or extend other commands.
  3. Shareable components: Splitting into multiple packages so they are easier to maintain and can be reused by other tools. This should also help with 1.
  4. Documented: We want developers to take advantage of the pluggability aspect. We should document things along the way so it's easier for them to write plugins and contribute back.

What are the things that are important to you that are not in here?

wynch commented 4 years ago

Templates for monorepo / multi-platform apps ? (I don't know if this fits in the scope of CLI experience)

mrbrentkelly commented 4 years ago

This is awesome! Here's my wish list off the top of my head:

I'm sure more things will pop into my head but those were the main things that came to mind 👍.

mrbrentkelly commented 4 years ago

Thought of a few more this morning 😄:

kmelmon commented 4 years ago

I'd like to see improvements to the Metro bundler:

brentvatne commented 4 years ago

This is a very broad topic, so I'll focus in on one aspect of the CLI experience in this comment - the project initialization experience. From Expo's side these are the that are important to us:

What I have described above is essentially what guided our design for create-react-native-app. This solves all of our problems very well, but it conflicts with the goal of minimizing the number of entry points and decisions that users need to make. If we were to converge onto a single tool for initialziing projects, there may be some conflicting priorities regarding the selection of defaults:

jamonholmgren commented 4 years ago

I'll add to what @brentvatne said from the context of Ignite CLI:

I'm current exploring moving Ignite over to using React Native templates, so we don't have to use our own template format (currently .ejs files with an Ignite CLI boilerplate.js script to generate them). However, I'm running into a few issues.

  1. We have a walkthrough when generating a new project (like @mrbrentkelly mentioned Expo has). But RN templates currently don't have a good way to add logic into files. See example below.
  2. Ignite CLI currently supports Expo or vanilla RN init with the same boilerplate. Given that Expo templates are different than RN cli templates, I don't see an obvious way to do that right now.

Example:

If the user chooses to integrate Detox into their Ignite Bowser app, we conditionally add certain lines of code to certain files.

  "scripts": {
<% if (props.includeDetox) { -%>
    "test:e2e": "detox test -c ios.sim.debug",
    "build:e2e": "detox build -c ios.sim.debug",
    "ci:test:e2e": "detox test -c ios.sim.release -l verbose --cleanup",
    "ci:build:e2e": "detox build -c ios.sim.release",
<% } -%>
    "compile": "tsc --noEmit -p . --pretty",

I'm very happy to see this discussion, though! I'm very interested in making Ignite CLI simpler and easier to work on, and pushing some of that capability upstream would be a good move that direction.

cederom commented 3 years ago

eject should be also in place by default all the time. It is easy to remove or break android/ or ios/ project. There should be some easy way to fix / recreate it :-) https://github.com/facebook/react-native/issues/32109