Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 5 commits into
base: next
Choose a base branch
from

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
Collaborator

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 <[email protected]>
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants