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

Merged
merged 5 commits into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions packages/create-react-admin/src/cli.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ const cli = meow(
--auth-provider Set the auth provider to use ("local-auth-provider" or "none")
--resource Add a resource that will be initialized with guessers (can be used multiple times). Set to "skip" to bypass the interactive resource step.
--install Set the package manager to use for installing dependencies ("yarn", "npm" or "skip" to bypass the interactive install step)
--basic Skip all the interactive steps and create a basic app with no data provider, no auth provider, no resources and no install step

Examples
$ create-admin-app my-admin
$ create-admin-app my-admin --data-provider ra-data-json-server --auth-provider local-auth-provider --resource posts --resource comments --install npm
$ create-admin-app my-admin --basic
`,
{
flags: {
help: {
type: 'boolean',
alias: 'h',
},
basic: {
type: 'boolean',
},
dataProvider: {
type: 'string',
choices: SupportedDataProviders.map(choice => choice.value),
Expand All @@ -50,19 +55,21 @@ const cli = meow(
if (cli.flags.h) {
cli.showHelp();
} else {
const dataProvider = cli.flags.basic ? 'none' : cli.flags.dataProvider;
const authProvider = cli.flags.basic ? 'none' : cli.flags.authProvider;
const install = cli.flags.basic ? 'skip' : cli.flags.install;
const resources =
cli.flags.basic || cli.flags.resource.includes('skip')
? []
: cli.flags.resource;

render(
<App
name={cli.input.length > 0 ? cli.input[0] : undefined}
dataProvider={cli.flags.dataProvider}
authProvider={cli.flags.authProvider}
resources={
cli.flags.resource.includes('skip')
? []
: cli.flags.resource.length > 0
? cli.flags.resource
: undefined
}
install={cli.flags.install}
dataProvider={dataProvider}
authProvider={authProvider}
resources={resources}
install={install}
/>
);
}
Loading