-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathcli.tsx
More file actions
77 lines (72 loc) · 2.62 KB
/
cli.tsx
File metadata and controls
77 lines (72 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env node
import React from 'react';
import { render } from 'ink';
import meow from 'meow';
import App from './app.js';
import { SupportedDataProviders } from './StepDataProvider.js';
import { SupportedAuthProviders } from './StepAuthProvider.js';
const cli = meow(
`
Usage
$ create-admin-app <name>
Options
--data-provider Set the data provider to use ("ra-data-fakerest", "ra-data-simple-rest", "ra-data-json-server" or "none")
--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),
},
authProvider: {
type: 'string',
choices: SupportedAuthProviders.map(choice => choice.value),
},
resource: {
type: 'string',
isMultiple: true,
},
install: {
type: 'string',
choices: ['yarn', 'npm', 'skip'],
},
},
}
);
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.length === 0
? []
: cli.flags.resource;
render(
<App
name={cli.input.length > 0 ? cli.input[0] : undefined}
dataProvider={dataProvider}
authProvider={authProvider}
resources={resources}
install={install}
/>
);
}