callstack / react-native-builder-bob

👷‍♂️ Simple set of CLIs to scaffold and build React Native libraries for different targets
https://callstack.github.io/react-native-builder-bob/
2.78k stars 184 forks source link

feat: add `--example none`, `--replace-directory`, and `--skip-git` options #668

Open gabrielmoreira opened 2 days ago

gabrielmoreira commented 2 days ago

Hello! First, thank you for the work on Bob and create-react-native-library.

I've made a few modifications on create-react-native-library to support a tooling (qdk) setup I'm working on.

Summary of Changes:

  1. Added --example none option: Allows creating libraries without an example app.
  2. Added --replace-directory option: Enables overwriting the template in an existing directory, using a similar option name as in the React Native CLI.
  3. Added --skip-git option: Prevents any git commands from running during template creation, also following a naming convention similar to the React Native CLI.

Context:

In my tool (qdk), I have templates for different project structures, and one of these templates uses create-react-native-library to set up a React Native library project. The goal is to generate only the library code, without an example app, without interfering with the project git, and with the flexibility to overwrite an existing directory if it already contains some files.

Thanks for considering these additions!

P.S.: By the way, the options added here follow a similar naming convention to npx @react-native-community/cli init options, for consistency.

I also considered contributing an optional parameter to fix the version of npx @react-native-community/cli@<<VERSION>> init, but for my case, not creating the example app was more beneficial. The vanilla example was giving me errors during generation, even though it was working a few days ago. Fixing the version of create-react-library wasn’t enough.

Additionally, I thought about adding an option to specify the package manager instead of trying to detect it. However, this would require more testing with various package managers, so I decided to hold off on that for now.