Skip to content

Commit 558eecf

Browse files
committed
docs: clean-up list of cli commands
1 parent 1fa1781 commit 558eecf

1 file changed

Lines changed: 14 additions & 117 deletions

File tree

adminforth/documentation/docs/tutorial/06-CLICommands.md

Lines changed: 14 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ description: "Reference page for the AdminForth CLI, including create-app, creat
88
99
## Usage
1010

11-
```bash
12-
13-
adminforth <command> [...options]
11+
To use a command, write it in format like:
1412

13+
```bash
14+
pnpx adminforth <command> [...options]
1515
```
1616

17+
For example: `pnpx adminforth create-app --app-name myadmin --db "sqlite://.db.sqlite"`
18+
1719
## Commands
1820

1921
### `create-app`
@@ -27,30 +29,18 @@ This command scaffolds a brand new AdminForth application in a specified directo
2729
**Usage:**
2830

2931
```bash
30-
adminforth create-app [--app-name <name>] [--db <database_url>]
32+
pnpx adminforth create-app [--app-name <name>] [--db <database_url>]
3133
```
3234

3335
**Options:**
3436

3537
- **`--app-name`**: The name of your new application. This becomes the project directory. Defaults to `adminforth-app`.
3638
- **`--db `**: The connection URL for your database. Currently PostgreSQL, MongoDB, SQLite, MySQL, Clickhouse are supported. If not provided, defaults to `sqlite://.db.sqlite`.
3739

38-
<!-- **What it does:**
39-
40-
1. ✅ Parses CLI arguments (or prompts if missing).
41-
2. 🔍 Validates Node.js version and checks if target folder exists.
42-
3. 📁 Creates project directory structure:
43-
- `custom/`
44-
- `resources/`
45-
- `.env`, `package.json`, `tsconfig.json`, etc.
46-
4. 🛠 Applies database-specific templates using Handlebars.
47-
5. 📦 Installs dependencies in both main and custom directories.
48-
6. 📌 Prints helpful next steps to start developing immediately. -->
49-
5040
**Example:**
5141

5242
```bash
53-
adminforth create-app --app-name my-app --db sqlite://mydb.sqlite
43+
pnpx adminforth create-app --app-name my-app --db sqlite://mydb.sqlite
5444
```
5545

5646
**Result:**
@@ -92,55 +82,23 @@ This command sets up a fresh AdminForth plugin project by generating the require
9282
**Usage:**
9383

9484
```bash
95-
adminforth create-plugin [--plugin-name <name>]
85+
pnpx adminforth create-plugin [--plugin-name <name>]
9686
```
9787

9888
**Options:**
9989

10090
- **`--plugin-name`**: The name of your new plugin. This becomes the folder name and is used in generated files. If not provided, you'll be prompted.
10191

102-
<!-- **What it does:**
103-
104-
1. ✅ Parses CLI arguments (or prompts interactively).
105-
2. 🔍 Performs initial checks:
106-
- Validates Node.js version (>= 20)
107-
- Ensures no existing `package.json` exists in the current directory
108-
3. 📁 Creates a plugin folder structure with files such as:
109-
- `tsconfig.json`
110-
- `package.json`
111-
- `index.ts`, `types.ts`
112-
- `custom/tsconfig.json`
113-
- `.gitignore`
114-
4. 📦 Installs dependencies in both root and `custom` directories.
115-
5. 📌 Prints post-setup instructions for building and testing. -->
116-
11792
**Example:**
11893

11994
```bash
120-
adminforth create-plugin --plugin-name my-awesome-plugin
95+
pnpx adminforth create-plugin --plugin-name my-awesome-plugin
12196
```
12297

12398
**Result:**
12499

125100
Creates a folder with all the necessary files for your plugin and instructions for linking it into an AdminForth project.
126101

127-
---
128-
129-
**Next steps after creation:**
130-
131-
```bash
132-
cd my-awesome-plugin
133-
pnpm build
134-
pnpm link
135-
```
136-
137-
Then in your AdminForth project:
138-
139-
```bash
140-
pnpm link my-awesome-plugin
141-
```
142-
143-
---
144102

145103

146104

@@ -171,30 +129,17 @@ This command scans the current working directory for a valid AdminForth instance
171129
**Usage:**
172130

173131
```bash
174-
adminforth generate-models [--env-file=<path>]
132+
pnpx adminforth generate-models [--env-file=<path>]
175133
```
176134

177135
**Options:**
178136

179137
- **`--env-file=<path>`**: (optional) Path to a custom `.env` file to load environment variables. Defaults to `.env`.
180138

181-
<!-- **What it does:**
182-
183-
1. 📁 Scans the current directory for `.js` or `.ts` files.
184-
2. 🔍 Looks for an AdminForth instance and calls `discoverDatabases()` to introspect resource definitions.
185-
3. 🧠 Extracts all resources and their columns.
186-
4. 🛠 Converts resource definitions into TypeScript type declarations using:
187-
- Resource ID → PascalCase type name
188-
- Column types → TypeScript equivalents
189-
5. ✍️ Writes output to:
190-
```
191-
node_modules/adminforth/models/models.ts
192-
``` -->
193-
194139
**Example:**
195140

196141
```bash
197-
adminforth generate-models --env-file=.env.dev
142+
pnpx adminforth generate-models --env-file=.env.dev
198143
```
199144

200145
**Result:**
@@ -251,38 +196,13 @@ This command bundles the AdminForth front-end (SPA) using your current AdminFort
251196
**Usage:**
252197

253198
```bash
254-
adminforth bundle
199+
pnpx adminforth bundle
255200
```
256201

257-
<!-- **What it does:**
258-
259-
1. 🔍 Looks for a valid AdminForth instance file using `findAdminInstance()`.
260-
2. 📦 Dynamically loads the instance using `callTsProxy`.
261-
3. 🧰 Calls `admin.bundleNow({ hotReload: false })` to build the production-ready front-end. -->
262-
263202
**Output:**
264203

265204
The output files (typically JavaScript/CSS assets) will be generated in the directory configured by your AdminForth project (usually `dist` or `public`).
266205

267-
**Example:**
268-
269-
```bash
270-
adminforth bundle
271-
```
272-
273-
You should see:
274-
275-
```
276-
Bundling admin SPA...
277-
```
278-
279-
And after successful execution, your compiled AdminForth front-end will be ready for deployment.
280-
281-
---
282-
283-
284-
285-
286206

287207

288208

@@ -332,7 +252,7 @@ Config will be auto-updated.
332252

333253
Usage shortcut:
334254
```bash
335-
adminforth component fields.show.user.email
255+
pnpx adminforth component fields.show.user.email
336256
```
337257

338258
---
@@ -429,30 +349,7 @@ This command helps you scaffold a new resource file for a selected table in your
429349
**Usage:**
430350

431351
```bash
432-
adminforth resource
433-
```
434-
435-
436-
<!-- **What it does:**
437-
438-
1. 🔍 Discovers all available tables across configured databases.
439-
2. 🧭 Prompts the user to select a table using a searchable list.
440-
3. 📑 Fetches all columns for the selected table.
441-
4. 🛠 Generates a resource file from a Handlebars template (`templates/resource.ts.hbs`), including:
442-
- Table name
443-
- Column definitions
444-
- Database source name
445-
- Resource metadata
446-
5. 🚫 Skips file creation if a matching resource already exists with the same `dataSource`.
447-
6. 🧠 Appends the new resource to the app’s main `index.ts`:
448-
- Adds an import statement.
449-
- Registers the resource in the `resources` array.
450-
- Adds a corresponding entry to the admin `menu`. -->
451-
452-
**Example:**
453-
454-
```bash
455-
adminforth resource
352+
pnpx adminforth resource
456353
```
457354

458355
**Result:**

0 commit comments

Comments
 (0)