Skip to content

Add a --basic flag to the create-react-admin package to skip interactive steps#10481

Merged
djhi merged 5 commits intonextfrom
feat/create-react-admin/add_a_basic_flag
Jan 31, 2025
Merged

Add a --basic flag to the create-react-admin package to skip interactive steps#10481
djhi merged 5 commits intonextfrom
feat/create-react-admin/add_a_basic_flag

Conversation

@erwanMarmelab
Copy link
Contributor

@erwanMarmelab erwanMarmelab commented Jan 28, 2025

Problem

To get a non-interactive `create-react-admin`, one must pass all options:

npx create-react-admin my-admin -- \
  --data-provider none
  --auth-provider none
  --resource skip
  --install skip

This is super verbose, especially in documentation.

Solution

Add a --basic option that replaces all the others

npm init react-admin test-admin1 -- --basic

How To Test

On the xx branch, build the cli:

make build-create-react-admin

Create a new project with npx:

npx create-react-admin test-admin-npx -- \
  --data-provider none
  --auth-provider none
  --resource skip
  --install skip

Create another one with the local version of the cli:

./node_modules/.bin/create-react-admin test-admin-local --basic

Compare folders:

diff test-admin-npx test-admin-local

Additional Checks

  • The PR targets master for a bugfix, or next for a feature
  • [ ] The PR includes unit tests (if not possible, describe why)
  • [ ] The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date (cli doc with help flag)
  • [ ] The documentation is up to date

@erwanMarmelab erwanMarmelab added the RFR Ready For Review label Jan 28, 2025
Comment on lines +57 to +66
} else if (cli.flags.basic) {
render(
<App
name={cli.input.length > 0 ? cli.input[0] : undefined}
dataProvider="none"
authProvider="none"
resources={[]}
install="skip"
/>
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid an else if by declaring local dataProvider, authProvider, resource and skip variables, initialize them depending on the cli.flags and then render the App

Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing, I notice that the generated App.tsx file still contains the guessers imports but they are not used anymore. You should modify generateAppFile.ts accordingly.

@fzaninotto
Copy link
Member

After testing, I notice that the generated App.tsx file still contains the guessers imports but they are not used anymore. You should modify generateAppFile.ts accordingly.

I don't think that's a regression caused by this PR, plus it may be useful for beginners (and for the tutorial).

@djhi djhi added this to the 5.6.0 milestone Jan 31, 2025
@djhi djhi merged commit c35a36a into next Jan 31, 2025
16 checks passed
@djhi djhi deleted the feat/create-react-admin/add_a_basic_flag branch January 31, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Development

Successfully merging this pull request may close these issues.

3 participants