Skip to content

Commit 0b7a052

Browse files
committed
Add package manager plugin
1 parent cdad681 commit 0b7a052

File tree

4 files changed

+139
-1
lines changed

4 files changed

+139
-1
lines changed

docs_headless/astro.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { defineConfig } from 'astro/config';
33
import starlight from '@astrojs/starlight';
44
import starlightSidebarTopics from 'starlight-sidebar-topics';
55
import tailwindcss from '@tailwindcss/vite';
6+
import mdx from '@astrojs/mdx';
67

78
// https://astro.build/config
89
export default defineConfig({
@@ -24,6 +25,10 @@ export default defineConfig({
2425
link: '/mui/guides/architecture',
2526
icon: 'open-book',
2627
items: [
28+
{
29+
label: 'Getting Started',
30+
slug: 'mui/guides/createreactadmin',
31+
},
2732
{
2833
label: 'Guides & Concepts',
2934
items: [
@@ -635,6 +640,7 @@ export default defineConfig({
635640
Sidebar: './src/components/CustomSidebar.astro',
636641
},
637642
}),
643+
mdx(),
638644
],
639645

640646
vite: {

docs_headless/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
"astro": "astro"
1111
},
1212
"dependencies": {
13+
"@astrojs/mdx": "^4.3.1",
1314
"@astrojs/starlight": "^0.34.8",
1415
"@astrojs/starlight-tailwind": "^4.0.1",
1516
"@tailwindcss/vite": "^4.1.11",
1617
"astro": "^5.6.1",
1718
"sharp": "^0.34.2",
19+
"starlight-package-managers": "^0.11.0",
1820
"starlight-sidebar-topics": "^0.6.0",
1921
"tailwindcss": "^4.1.11"
2022
},
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
title: "The create-react-admin CLI"
3+
---
4+
5+
import { PackageManagers } from 'starlight-package-managers';
6+
7+
# `create-react-admin`
8+
9+
Use `create-react-admin` to quickly bootstrap a react-admin project using [Vite](https://vitejs.dev/). It's the preferred way to create a new react-admin application.
10+
11+
<iframe src="https://www.youtube-nocookie.com/embed/i_TbS7quzww" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen style="aspect-ratio: 16 / 9;width:100%;margin-bottom:1em;"></iframe>
12+
13+
## Usage
14+
15+
<PackageManagers type="dlx" pkg="create-react-admin@latest" args="your-admin-name" />
16+
Or
17+
<PackageManagers type="create" pkg="react-admin@latest" args="your-admin-name" />
18+
19+
This will create an empty react-admin application in a directory called `your-admin-name`, powered by [Vite.js](./Vite.md), and install the dependencies.
20+
21+
You can run the app with:
22+
23+
```sh
24+
cd your-admin-name
25+
npm run dev
26+
```
27+
28+
**Tip**: If you need to pass extra options, depending on the command you choose you may need to add `--` before the arguments:
29+
30+
<PackageManagers type="dlx" pkg="create-react-admin@latest" args="your-admin-name --interactive" />
31+
Or
32+
<PackageManagers type="create" pkg="react-admin@latest" args="your-admin-name --interactive" />
33+
34+
```sh
35+
# `npx` doesn't require the `--` before the arguments
36+
npx create-react-admin@latest your-admin-name --interactive
37+
# `npm create` does require the `--` before the arguments
38+
npm create react-admin@latest your-admin-name -- --interactive
39+
```
40+
41+
## Options
42+
43+
The command accepts the following options:
44+
45+
* `--interactive`: Enable the CLI interactive mode
46+
* `--data-provider`: Set the data provider to use ("data-fakerest", "data-simple-rest", "data-json-server", "supabase" or "none")
47+
* `--auth-provider`: Set the auth provider to use ("local-auth-provider" or "none")
48+
* `--resource`: Add a resource that will be initialized with guessers (can be used multiple times). Set to "skip" to bypass the interactive resource step.
49+
* `--install`: Set the package manager to use for installing dependencies ("yarn", "npm", "bun" or "skip" to bypass the interactive install step)
50+
51+
## `--interactive`
52+
53+
When using this option, the terminal will ask you to choose:
54+
55+
* a [data provider](./DataFetchingGuide.md#the-data-provider)
56+
* an [auth provider](./DataFetchingGuide.md#authentication)
57+
* the names of the [resources](./Resource.md) to add
58+
* the [package manager](#package-manager) to use to install the dependencies
59+
60+
<video controls autoplay playsinline muted loop>
61+
<source src="./img/create-react-admin.webm" type="video/webm"/>
62+
<source src="./img/create-react-admin.mp4" type="video/mp4"/>
63+
Your browser does not support the video tag.
64+
</video>
65+
66+
## `--data-provider`
67+
68+
`create-react-admin` currently supports five presets for the application's data provider:
69+
70+
* `fakerest`: A client-side data provider that use a JSON object for data, powered by [FakeRest](https://github.com/marmelab/FakeRest).
71+
* `json-server`: A data provider based on the [JSON Server](https://github.com/typicode/json-server) API
72+
* `simple-rest`: A data provider for [simple REST APIs](https://github.com/marmelab/react-admin/tree/master/packages/ra-data-simple-rest)
73+
* `supabase`: A data provider for [Supabase](https://github.com/marmelab/ra-supabase/tree/main/packages/ra-supabase). The auth-provider and resources steps will be skipped.
74+
* `none` (default): To configure the data provider yourself
75+
76+
You can set your data provider directly with the `--data-provider` option:
77+
78+
```sh
79+
npx create-react-admin@latest your-admin-name --data-provider json-server
80+
```
81+
82+
## `--auth-provider`
83+
84+
`create-react-admin` currently supports two presets to set the application's auth provider which are:
85+
86+
* `local-auth-provider`: Hard coded username/password.
87+
* `none` (default): No authProvider.
88+
89+
You can set your auth provider directly with the `--auth-provider` option:
90+
91+
```sh
92+
npx create-react-admin@latest your-admin-name --auth-provider local-auth-provider
93+
```
94+
95+
## `--resource`
96+
97+
`create-react-admin` creates an empty app by default. You can initialize CRUD pages for some resources with the `--resource` option:
98+
99+
```sh
100+
npx create-react-admin@latest your-admin-name --resource posts --resource comments
101+
```
102+
103+
**Warning:** the `--resource` flag is incompatible with a `--data-provider supabase` due to a specific [`<AdminGuesser>` component](https://github.com/marmelab/ra-supabase/tree/main/packages/ra-supabase#usage) from `ra-supabase`.
104+
105+
## `--install`
106+
107+
`create-react-admin` can install dependencies using any of the following package managers:
108+
109+
* `npm` (default)
110+
* `yarn`
111+
* `bun`
112+
* `pnpm`
113+
* `none` (if you want to install dependencies yourself)
114+
115+
You choose an alternative package manager with the `--install` option:
116+
117+
```sh
118+
npx create-react-admin@latest your-admin-name --install bun
119+
```

yarn.lock

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ __metadata:
112112
languageName: node
113113
linkType: hard
114114

115-
"@astrojs/mdx@npm:^4.2.3":
115+
"@astrojs/mdx@npm:^4.2.3, @astrojs/mdx@npm:^4.3.1":
116116
version: 4.3.1
117117
resolution: "@astrojs/mdx@npm:4.3.1"
118118
dependencies:
@@ -19156,13 +19156,15 @@ __metadata:
1915619156
version: 0.0.0-use.local
1915719157
resolution: "ra-core-doc@workspace:docs_headless"
1915819158
dependencies:
19159+
"@astrojs/mdx": "npm:^4.3.1"
1915919160
"@astrojs/starlight": "npm:^0.34.8"
1916019161
"@astrojs/starlight-tailwind": "npm:^4.0.1"
1916119162
"@tailwindcss/vite": "npm:^4.1.11"
1916219163
astro: "npm:^5.6.1"
1916319164
prettier: "npm:^3.2.5"
1916419165
prettier-plugin-astro: "npm:^0.14.1"
1916519166
sharp: "npm:^0.34.2"
19167+
starlight-package-managers: "npm:^0.11.0"
1916619168
starlight-sidebar-topics: "npm:^0.6.0"
1916719169
tailwindcss: "npm:^4.1.11"
1916819170
languageName: unknown
@@ -21841,6 +21843,15 @@ __metadata:
2184121843
languageName: node
2184221844
linkType: hard
2184321845

21846+
"starlight-package-managers@npm:^0.11.0":
21847+
version: 0.11.0
21848+
resolution: "starlight-package-managers@npm:0.11.0"
21849+
peerDependencies:
21850+
"@astrojs/starlight": ">=0.22.0"
21851+
checksum: 3dee89f8a9317799108bbc53f45d918cc2e75c7a44bee63994788256ebc115143b44316a540082414fbb792eb7d55b888bab7c20c8b914609322f49f6540a8a5
21852+
languageName: node
21853+
linkType: hard
21854+
2184421855
"starlight-sidebar-topics@npm:^0.6.0":
2184521856
version: 0.6.0
2184621857
resolution: "starlight-sidebar-topics@npm:0.6.0"

0 commit comments

Comments
 (0)