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

docs: sync nextui-cli api #3035

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion apps/docs/config/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@
"key": "cli-api",
"title": "NextUI CLI",
"keywords": "api references, nextui, api, cli",
"path": "/docs/api-references/cli-api.mdx"
"path": "/docs/api-references/cli-api.mdx",
"updated": true
},
{
"key": "nextui-provider",
Expand Down
102 changes: 67 additions & 35 deletions apps/docs/content/docs/api-references/cli-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,46 @@ nextui init [projectName] [options]
### Options

- `-t --template [string]` The template to use for the new project e.g. app, pages
- `-p --package [string]` The package manager to use for the new project (default: `npm`)

### Example

```codeBlock bash
nextui init my-nextui-app -t app
```

output:

```codeBlock bash
NextUI CLI v0.2.1

┌ Create a new project
◇ Select a template (Enter to select)
│ ● App (A Next.js 14 with app directory template pre-configured with NextUI (v2) and Tailwind CSS.)
│ ○ Pages (A Next.js 14 with pages directory template pre-configured with NextUI (v2) and Tailwind CSS.)
◇ New project name (Enter to skip with default name)
│ my-nextui-app
◇ Select a package manager (Enter to select)
│ ● npm
│ ○ yarn
│ ○ pnpm
│ ○ bun
◇ Template created successfully!
◇ Next steps ───────╮
│ │
│ cd my-nextui-app │
│ npm install │
│ │
├────────────────────╯
└ 🚀 Get started with npm run dev
```

## add

> 1. Auto add the missing required `dependencies` to your project
Expand All @@ -79,7 +112,6 @@ nextui add [components...] [options]
- `--prettier` [boolean] Add prettier format in the add content which required installed prettier - (default: false)
winchesHe marked this conversation as resolved.
Show resolved Hide resolved
- `--addApp` [boolean] Add App.tsx file content which required provider (default: `false`)


### Example

Without setting a specific component, the `add` command will show a list of available components.
Expand All @@ -91,27 +123,22 @@ nextui add
Output:

```codeBlock bash
NextUI CLI v0.1.2
NextUI CLI v0.2.1

? Which components would you like to add? › - Space to select. Return to submit
Instructions:
↑/↓: Highlight option
←/→/[space]: Toggle selection
[a,b,c]/delete: Filter choices
enter/return: Complete answer
? Which components would you like to add? › - Space to select. Return to submit

Filtered results for: Enter something to filter

accordion
◯ autocomplete
◯ avatar
◯ badge
◯ breadcrumbs
◯ button
card
checkbox
chip
code
accordion
autocomplete
avatar
badge
breadcrumbs
button
calendar
card
checkbox
↓ chip
```

If you want to add a specific component, you can specify the component name.
Expand All @@ -123,7 +150,7 @@ nextui add button input
Output:

```bash
NextUI CLI v0.1.2
NextUI CLI v0.2.1

Adding the required dependencies: @nextui-org/button

Expand All @@ -142,7 +169,6 @@ Tailwind CSS settings have been updated in: /project-path/tailwind.config.js
✅ Components added successfully
```


## upgrade

Upgrade the NextUI components to the latest version.
Expand All @@ -157,27 +183,33 @@ nextui upgrade [components...] [options]
- `-a --all` [boolean] Upgrade all the NextUI components (default: `false`).
- `-h, --help` Display help for commands.


### Example

```codeBlock bash
nextui upgrade button
```


Output:

```bash
NextUI CLI v0.1.2
NextUI CLI v0.2.1

╭───────────────────────── Component ─────────────────────────╮
│ @nextui-org/button ^2.0.11 -> ^2.0.31 │
╰─────────────────────────────────────────────────────────────╯

Required min version: @nextui-org/theme>=2.1.0, tailwindcss>=3.4.0
╭───────────────────── PeerDependencies ─────────────────────╮
│ @nextui-org/theme 2.0.1 -> 2.1.0 │
│ tailwindcss ^3.2.3 -> ^3.4.0 │
╰────────────────────────────────────────────────────────────╯
2 minor, 1 patch

╭───────────────────────────────────────────────────────────╮
│ @nextui-org/button 2.0.24 -> 2.0.27 │
╰───────────────────────────────────────────────────────────╯
? Would you like to proceed with the upgrade? › - Use arrow-keys. Return to submit.
❯ Yes
No

pnpm add @nextui-org/button@2.0.27
pnpm add @nextui-org/button@2.0.31 @nextui-org/theme@2.1.0 tailwindcss@3.4.0
Already up to date
Progress: resolved 474, reused 465, downloaded 0, added 0, done
Done in 2.9s
Expand All @@ -195,7 +227,6 @@ Remove NextUI components from your project.
nextui remove [components...] [options]
```


### Options

- `-p --packagePath` [string] The path to the package.json file.
Expand All @@ -213,7 +244,7 @@ nextui remove button
Output:

```bash
NextUI CLI v0.1.2
NextUI CLI v0.2.1

❗️ Components slated for removal:
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
Expand Down Expand Up @@ -249,8 +280,8 @@ nextui list [options]

### Options

- `-p --packagePath` [string] The path to the package.json file.
- `-c --current` List the current installed components.
- `-p --packagePath` [string] The path to the package.json file
- `-r --remote` List all components available remotely

### Example

Expand All @@ -261,7 +292,7 @@ nextui list
Output:

```codeBlock bash
NextUI CLI v0.1.2
NextUI CLI v0.2.1

Current installed components:

Expand All @@ -283,6 +314,7 @@ Diagnose problems in your project.
> 2. Check whether the NextUI components `required dependencies are installed` in the project
> 3. Check the required `tailwind.config.js` file and the content is correct
> 4. Check `.npmrc` is correct when using `pnpm`
> 5. Check `peerDependencies with required version` are installed in the project

```codeBlock bash
nextui doctor [options]
Expand Down Expand Up @@ -310,7 +342,7 @@ Output:
If there is a problem in your project, the `doctor` command will display the problem information.

```codeBlock bash
NextUI CLI v0.1.2
NextUI CLI v0.2.1

NextUI CLI: ❌ Your project has 1 issue that require attention

Expand All @@ -322,7 +354,7 @@ Missing tailwind.config.(j|t)s file. To set up, visit: https://nextui.org/docs/g
Otherwise, the `doctor` command will display the following message.

```codeBlock bash
NextUI CLI v0.1.2
NextUI CLI v0.2.1

✅ Your project has no detected issues.
```
Expand All @@ -348,7 +380,7 @@ nextui env
Output:

```codeBlock bash
NextUI CLI 0.1.0
NextUI CLI 0.2.1

Current installed components:

Expand Down
45 changes: 37 additions & 8 deletions apps/docs/content/docs/guide/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,41 @@ nextui init my-nextui-app
You will be prompted to configure your project:

```codeBlock bash
? Select a template › - Use arrow-keys. Return to submit.
❯ App
A Next.js 13 with app directory template pre-configured with NextUI (v2) and Tailwind CSS.
Pages
A Next.js 13 with pages directory template pre-configured with NextUI (v2) and Tailwind CSS.
┌ Create a new project
◇ Select a template (Enter to select)
│ ● App (A Next.js 14 with app directory template pre-configured with NextUI (v2) and Tailwind CSS.)
│ ○ Pages (A Next.js 14 with pages directory template pre-configured with NextUI (v2) and Tailwind CSS.)
◇ New project name (Enter to skip with default name)
│ my-nextui-app
◇ Select a package manager (Enter to select)
│ ● npm
│ ○ yarn
│ ○ pnpm
│ ○ bun
◇ Template created successfully!
◇ Next steps ───────╮
│ │
│ cd my-nextui-app │
│ npm install │
│ │
├────────────────────╯
└ 🚀 Get started with npm run dev
```

Install the dependencies to start the local server:

```codeBlock bash
cd my-nextui-app && npm install
```

Start the local server:

```codeBlock bash
npm run dev
```
Expand Down Expand Up @@ -164,9 +186,16 @@ You will be asked to confirm the upgrade:

```codeBlock bash

╭───────────────────────────────────────────────────────────╮
│ @nextui-org/button 2.0.24 -> 2.0.27 │
╰───────────────────────────────────────────────────────────╯
╭───────────────────────── Component ─────────────────────────╮
│ @nextui-org/button ^2.0.11 -> ^2.0.31 │
╰─────────────────────────────────────────────────────────────╯

Required min version: @nextui-org/theme>=2.1.0, tailwindcss>=3.4.0
╭───────────────────── PeerDependencies ─────────────────────╮
│ @nextui-org/theme 2.0.1 -> 2.1.0 │
│ tailwindcss ^3.2.3 -> ^3.4.0 │
╰────────────────────────────────────────────────────────────╯
2 minor, 1 patch

? Would you like to proceed with the upgrade? › - Use arrow-keys. Return to submit.
❯ Yes
Expand Down
Loading