@nocobase/cli 2.1.0-alpha.20 → 2.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +256 -89
- package/README.zh-CN.md +332 -0
- package/bin/run.js +21 -2
- package/dist/commands/build.js +7 -1
- package/dist/commands/db/logs.js +85 -0
- package/dist/commands/db/ps.js +60 -0
- package/dist/commands/db/shared.js +81 -0
- package/dist/commands/db/start.js +55 -7
- package/dist/commands/db/stop.js +70 -0
- package/dist/commands/dev.js +112 -21
- package/dist/commands/down.js +193 -0
- package/dist/commands/download.js +633 -183
- package/dist/commands/env/add.js +260 -131
- package/dist/commands/env/auth.js +9 -8
- package/dist/commands/init.js +723 -103
- package/dist/commands/install.js +1702 -565
- package/dist/commands/logs.js +90 -0
- package/dist/commands/pm/disable.js +35 -3
- package/dist/commands/pm/enable.js +35 -3
- package/dist/commands/pm/list.js +37 -4
- package/dist/commands/prompts-stages.js +150 -0
- package/dist/commands/prompts-test.js +181 -0
- package/dist/commands/ps.js +116 -0
- package/dist/commands/start.js +171 -15
- package/dist/commands/stop.js +90 -0
- package/dist/commands/upgrade.js +559 -11
- package/dist/lib/api-client.js +49 -5
- package/dist/lib/app-runtime.js +142 -0
- package/dist/lib/auth-store.js +44 -3
- package/dist/lib/bootstrap.js +7 -3
- package/dist/lib/cli-locale.js +115 -0
- package/dist/lib/env-auth.js +427 -82
- package/dist/lib/prompt-catalog.js +574 -0
- package/dist/lib/prompt-validators.js +185 -0
- package/dist/lib/prompt-web-ui.js +2061 -0
- package/dist/lib/run-npm.js +71 -7
- package/dist/lib/runtime-generator.js +12 -1
- package/dist/locale/en-US.json +282 -0
- package/dist/locale/zh-CN.json +282 -0
- package/package.json +5 -4
- package/dist/commands/restart.js +0 -32
- package/dist/lib/init-browser-wizard.js +0 -431
package/README.md
CHANGED
|
@@ -1,176 +1,343 @@
|
|
|
1
|
-
# NocoBase
|
|
1
|
+
# NocoBase CLI
|
|
2
2
|
|
|
3
|
-
NocoBase
|
|
3
|
+
NocoBase CLI (`nb`) is a command-line tool for setting up and managing NocoBase
|
|
4
|
+
apps in a local workspace. It helps you connect coding agents to NocoBase by
|
|
5
|
+
preparing the app, saving the CLI env config, and providing day-to-day commands
|
|
6
|
+
for start, stop, logs, upgrade, and cleanup.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
The CLI supports two common setup paths:
|
|
9
|
+
|
|
10
|
+
- Connect an existing NocoBase app so coding agents can use it.
|
|
11
|
+
- Install a new NocoBase app from Docker, npm, or Git, then connect it as a CLI env.
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Node.js v20+
|
|
16
|
+
- Yarn 1.x
|
|
17
|
+
- Git, required when installing from Git source
|
|
18
|
+
- Docker, required when installing with Docker or using the built-in database
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Install the CLI globally:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g @nocobase/cli@alpha
|
|
18
26
|
```
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
Check the available commands:
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
```bash
|
|
31
|
+
nb --help
|
|
32
|
+
nb init --help
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Core Concepts
|
|
24
36
|
|
|
25
|
-
|
|
37
|
+
- **Workspace**: the current project folder where `.nocobase` is stored.
|
|
38
|
+
- **Env**: a named NocoBase connection saved by the CLI. In `nb init`, the app name is also the env name.
|
|
39
|
+
- **Source**: how the local app is obtained. Supported values are `docker`, `npm`, and `git`.
|
|
40
|
+
- **Remote env**: an env that only stores an API connection to an existing NocoBase app.
|
|
41
|
+
- **Runtime resources**: local app process, Docker app container, built-in database container, source directory, and storage directory managed by CLI commands.
|
|
26
42
|
|
|
27
43
|
## Quick Start
|
|
28
44
|
|
|
29
|
-
|
|
45
|
+
### Guided Setup
|
|
46
|
+
|
|
47
|
+
Run the guided terminal flow:
|
|
30
48
|
|
|
31
49
|
```bash
|
|
32
|
-
|
|
50
|
+
nb init
|
|
33
51
|
```
|
|
34
52
|
|
|
35
|
-
|
|
53
|
+
Use the browser-based setup form:
|
|
36
54
|
|
|
37
55
|
```bash
|
|
38
|
-
nb
|
|
56
|
+
nb init --ui
|
|
39
57
|
```
|
|
40
58
|
|
|
41
|
-
|
|
59
|
+
`nb init` can either connect to an existing NocoBase app or install a new one.
|
|
60
|
+
When creating a new app, it can also install NocoBase AI coding skills
|
|
61
|
+
(`nocobase/skills`) for the current workspace.
|
|
62
|
+
|
|
63
|
+
### Non-Interactive Setup
|
|
64
|
+
|
|
65
|
+
When prompts are skipped, an app/env name is required:
|
|
42
66
|
|
|
43
67
|
```bash
|
|
44
|
-
nb
|
|
68
|
+
nb init --env app1 --yes
|
|
45
69
|
```
|
|
46
70
|
|
|
47
|
-
|
|
71
|
+
Install with Docker:
|
|
48
72
|
|
|
49
73
|
```bash
|
|
50
|
-
nb env
|
|
74
|
+
nb init --env app1 --yes --source docker --version alpha
|
|
51
75
|
```
|
|
52
76
|
|
|
53
|
-
|
|
77
|
+
Install from npm:
|
|
54
78
|
|
|
55
79
|
```bash
|
|
56
|
-
nb env
|
|
80
|
+
nb init --env app1 --yes --source npm --version alpha --app-port 13080
|
|
57
81
|
```
|
|
58
82
|
|
|
59
|
-
|
|
83
|
+
Install from Git source:
|
|
60
84
|
|
|
61
85
|
```bash
|
|
62
|
-
nb env
|
|
86
|
+
nb init --env app1 --yes --source git --version alpha
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For Git source installs, `--version alpha` resolves to the `develop` branch.
|
|
90
|
+
|
|
91
|
+
Install from a Git branch:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
nb init --env app1 --yes --source git --version fix/cli-v2
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`--version` is the shared version input across sources:
|
|
98
|
+
|
|
99
|
+
- npm: package version
|
|
100
|
+
- Docker: image tag
|
|
101
|
+
- Git: git ref such as a branch or tag
|
|
102
|
+
|
|
103
|
+
By default, a new local app uses:
|
|
104
|
+
|
|
105
|
+
- Source directory: `./<envName>/source/`
|
|
106
|
+
- Storage directory: `./<envName>/storage/`
|
|
107
|
+
|
|
108
|
+
### Resume an Interrupted Setup
|
|
109
|
+
|
|
110
|
+
If `nb init` was interrupted after the env config had already been saved, you can continue the same setup:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
nb init --env app1 --resume
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The advanced low-level equivalent is:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
nb install --env app1 --resume
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`--resume` reuses the saved workspace env config for app, source, database, and env connection settings. In interactive mode, it only asks for any missing setup-only values.
|
|
123
|
+
|
|
124
|
+
In non-interactive mode, pass these setup-only flags again because they are not saved in env config:
|
|
125
|
+
|
|
126
|
+
- `--lang`
|
|
127
|
+
- `--root-username`
|
|
128
|
+
- `--root-email`
|
|
129
|
+
- `--root-password`
|
|
130
|
+
- `--root-nickname`
|
|
131
|
+
|
|
132
|
+
## Daily Commands
|
|
133
|
+
|
|
134
|
+
| Command | Description |
|
|
135
|
+
| --- | --- |
|
|
136
|
+
| `nb init` | Set up NocoBase and connect it as a CLI env for coding agents. |
|
|
137
|
+
| `nb install` | Advanced command used by `nb init` to install a local NocoBase app and save env config. In most cases, use `nb init` instead. |
|
|
138
|
+
| `nb download` | Advanced command used by `nb init` or `nb upgrade` to fetch NocoBase from Docker, npm, or Git. It is rarely used directly. |
|
|
139
|
+
| `nb start` | Start the selected local app or Docker container. |
|
|
140
|
+
| `nb stop` | Stop the selected local app or Docker container. |
|
|
141
|
+
| `nb dev` | Run development mode for npm/Git source envs. |
|
|
142
|
+
| `nb logs` | Show app logs for npm/Git or Docker envs. |
|
|
143
|
+
| `nb ps` | Show runtime status for configured envs. |
|
|
144
|
+
| `nb db` | Inspect or manage built-in database runtime status for local envs. |
|
|
145
|
+
| `nb upgrade` | Refresh code/image and restart the selected app. |
|
|
146
|
+
| `nb down` | Stop and remove local runtime containers for an env. |
|
|
147
|
+
| `nb env` | Manage saved CLI env connections. |
|
|
148
|
+
| `nb api` | Call NocoBase API resources from the CLI. |
|
|
149
|
+
| `nb pm` | Manage plugins for the selected NocoBase env. |
|
|
150
|
+
|
|
151
|
+
Recommended style: use `--env` explicitly for app/runtime commands. `-e` is the short form:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
nb start --env app1
|
|
155
|
+
nb logs --env app1
|
|
156
|
+
nb ps --env app1
|
|
157
|
+
nb db ps --env app1
|
|
63
158
|
```
|
|
64
159
|
|
|
65
|
-
|
|
160
|
+
Equivalent shorthand examples:
|
|
66
161
|
|
|
67
162
|
```bash
|
|
68
|
-
nb
|
|
163
|
+
nb start -e app1
|
|
164
|
+
nb logs -e app1
|
|
165
|
+
nb upgrade -e app1
|
|
166
|
+
nb db start -e app1
|
|
69
167
|
```
|
|
70
168
|
|
|
71
|
-
|
|
169
|
+
## Runtime Types
|
|
170
|
+
|
|
171
|
+
### Docker
|
|
172
|
+
|
|
173
|
+
Docker envs are managed through saved Docker containers and images:
|
|
72
174
|
|
|
73
175
|
```bash
|
|
74
|
-
nb env
|
|
75
|
-
nb env
|
|
176
|
+
nb init --env app1 --yes --source docker --version alpha
|
|
177
|
+
nb start --env app1
|
|
178
|
+
nb logs --env app1
|
|
179
|
+
nb stop --env app1
|
|
76
180
|
```
|
|
77
181
|
|
|
78
|
-
|
|
182
|
+
Docker downloads support platform selection:
|
|
79
183
|
|
|
80
184
|
```bash
|
|
81
|
-
nb
|
|
82
|
-
nb
|
|
83
|
-
nb
|
|
185
|
+
nb download --source docker --version alpha --docker-platform auto
|
|
186
|
+
nb download --source docker --version alpha --docker-platform linux/amd64
|
|
187
|
+
nb download --source docker --version alpha --docker-platform linux/arm64
|
|
84
188
|
```
|
|
85
189
|
|
|
86
|
-
|
|
190
|
+
### npm and Git
|
|
87
191
|
|
|
88
|
-
|
|
192
|
+
npm and Git envs use a local source directory and can run development mode:
|
|
89
193
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
194
|
+
```bash
|
|
195
|
+
nb init --env app1 --yes --source git --version alpha
|
|
196
|
+
nb dev --env app1
|
|
197
|
+
```
|
|
94
198
|
|
|
95
|
-
|
|
199
|
+
`nb dev` only supports npm/Git source envs. Docker envs can be inspected with
|
|
200
|
+
`nb logs`, and remote envs only support API/env operations.
|
|
96
201
|
|
|
97
|
-
|
|
202
|
+
### Existing NocoBase App
|
|
98
203
|
|
|
99
|
-
|
|
204
|
+
To connect an existing app, use `nb init` and choose the existing-app setup
|
|
205
|
+
path, or add the env directly:
|
|
100
206
|
|
|
101
207
|
```bash
|
|
102
|
-
nb env
|
|
103
|
-
nb env auth prod
|
|
208
|
+
nb env add app1 --base-url http://localhost:13000/api
|
|
104
209
|
```
|
|
105
210
|
|
|
106
|
-
|
|
211
|
+
`nb env add` will start the authentication flow automatically when needed.
|
|
212
|
+
|
|
213
|
+
## Upgrade
|
|
214
|
+
|
|
215
|
+
Upgrade refreshes the saved source or image, then restarts the app:
|
|
107
216
|
|
|
108
217
|
```bash
|
|
109
|
-
nb
|
|
218
|
+
nb upgrade --env app1
|
|
110
219
|
```
|
|
111
220
|
|
|
112
|
-
|
|
221
|
+
Use `--skip-code-update` or `-s` to restart with the saved local code or Docker
|
|
222
|
+
image without downloading updates first:
|
|
113
223
|
|
|
114
224
|
```bash
|
|
115
|
-
nb env
|
|
225
|
+
nb upgrade --env app1 -s
|
|
116
226
|
```
|
|
117
227
|
|
|
118
|
-
##
|
|
228
|
+
## Database Commands
|
|
229
|
+
|
|
230
|
+
Use `nb db` to inspect or manage the built-in database runtime for a local env:
|
|
119
231
|
|
|
120
|
-
|
|
232
|
+
```bash
|
|
233
|
+
nb db ps
|
|
234
|
+
nb db ps --env app1
|
|
235
|
+
nb db start --env app1
|
|
236
|
+
nb db stop --env app1
|
|
237
|
+
nb db logs --env app1
|
|
238
|
+
```
|
|
121
239
|
|
|
122
|
-
|
|
123
|
-
- `global`: use the global `.nocobase-ctl` directory
|
|
240
|
+
Notes:
|
|
124
241
|
|
|
125
|
-
|
|
242
|
+
- `nb db start` and `nb db stop` only work for envs created with the built-in database option enabled.
|
|
243
|
+
- `nb db logs` only works for envs created with the built-in database option enabled.
|
|
244
|
+
- `nb db ps` can also show `external` or `remote` status for envs that do not have a CLI-managed database container.
|
|
245
|
+
|
|
246
|
+
## Cleanup
|
|
247
|
+
|
|
248
|
+
Bring down a local env:
|
|
126
249
|
|
|
127
250
|
```bash
|
|
128
|
-
nb env
|
|
129
|
-
nb env add prod -s global --base-url http://example.com/api --auth-type token --token <api-key>
|
|
130
|
-
nb env auth prod -s global
|
|
131
|
-
nb env use local -s project
|
|
251
|
+
nb down --env app1
|
|
132
252
|
```
|
|
133
253
|
|
|
134
|
-
|
|
254
|
+
By default, `nb down` stops the app and removes app/database containers if they
|
|
255
|
+
exist. It keeps user data, source files, and CLI env config.
|
|
135
256
|
|
|
136
|
-
|
|
137
|
-
2. `NOCOBASE_HOME_CLI`
|
|
138
|
-
3. your home directory
|
|
257
|
+
Use explicit flags for destructive cleanup:
|
|
139
258
|
|
|
140
|
-
|
|
259
|
+
```bash
|
|
260
|
+
nb down --env app1 --remove-data
|
|
261
|
+
nb down --env app1 --remove-source
|
|
262
|
+
nb down --env app1 --remove-env
|
|
263
|
+
```
|
|
141
264
|
|
|
142
|
-
|
|
265
|
+
- `--remove-data`: delete storage and managed database data. This requires confirmation unless `--yes` is used.
|
|
266
|
+
- `--remove-source`: delete the npm/Git source directory.
|
|
267
|
+
- `--remove-env`: remove the saved CLI env config.
|
|
143
268
|
|
|
144
|
-
|
|
145
|
-
- `api`
|
|
269
|
+
## Environment Management
|
|
146
270
|
|
|
147
|
-
|
|
271
|
+
Show the current env:
|
|
148
272
|
|
|
149
273
|
```bash
|
|
150
|
-
nb
|
|
151
|
-
|
|
152
|
-
|
|
274
|
+
nb env
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
List configured envs:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
nb env list
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Switch the current env:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
nb env use app1
|
|
153
287
|
```
|
|
154
288
|
|
|
155
|
-
|
|
289
|
+
Re-authenticate an env when credentials need to be refreshed:
|
|
156
290
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
- `-t, --token`: API key override
|
|
161
|
-
- `-j, --json-output`: print raw JSON response
|
|
291
|
+
```bash
|
|
292
|
+
nb env auth app1
|
|
293
|
+
```
|
|
162
294
|
|
|
163
|
-
|
|
295
|
+
Update runtime command metadata from the selected app:
|
|
164
296
|
|
|
165
297
|
```bash
|
|
166
|
-
nb env update
|
|
167
|
-
nb api resource list --resource users -e prod -j
|
|
168
|
-
nb api resource list --resource users -e prod --role admin
|
|
298
|
+
nb env update app1
|
|
169
299
|
```
|
|
170
300
|
|
|
301
|
+
## API Commands
|
|
302
|
+
|
|
303
|
+
The CLI can call NocoBase resources through the configured env:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
nb api resource list --resource users -e app1
|
|
307
|
+
nb api resource get --resource users --filter-by-tk 1 -e app1
|
|
308
|
+
nb api resource create --resource users --values '{"nickname":"Ada"}' -e app1
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Use `-j, --json-output` to print raw JSON when available:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
nb api resource list --resource users -e app1 -j
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Available API command topics:
|
|
318
|
+
|
|
319
|
+
| Command | Description |
|
|
320
|
+
| --- | --- |
|
|
321
|
+
| `nb api acl` | Manage access control based on roles, resources, and actions. |
|
|
322
|
+
| `nb api api-keys` | Manage API keys for HTTP API access. |
|
|
323
|
+
| `nb api app` | Manage application resources. |
|
|
324
|
+
| `nb api authenticators` | Manage user authentication, including password auth, SMS auth, SSO protocols, and extensible providers. |
|
|
325
|
+
| `nb api data-modeling` | Manage data sources, collections, and database modeling resources. |
|
|
326
|
+
| `nb api file-manager` | Manage file storage services, file collections, and attachment fields. |
|
|
327
|
+
| `nb api flow-surfaces` | Compose and mutate page, tab, block, field, and action surfaces. |
|
|
328
|
+
| `nb api pm` | Manage plugins through API commands. |
|
|
329
|
+
| `nb api resource` | Work with generic collection resources. |
|
|
330
|
+
| `nb api system-settings` | Adjust system title, logo, language, and other global settings. |
|
|
331
|
+
| `nb api theme-editor` | Customize UI colors and dimensions, save themes, and switch between them. |
|
|
332
|
+
| `nb api workflow` | Manage workflow resources for business automation. |
|
|
333
|
+
|
|
171
334
|
## Local Data
|
|
172
335
|
|
|
173
|
-
The CLI stores
|
|
336
|
+
The CLI stores workspace-level config in `.nocobase`:
|
|
337
|
+
|
|
338
|
+
- `config.json`: env definitions, current env, and workspace-level settings.
|
|
339
|
+
- `versions/<version>/commands.json`: cached runtime commands generated from the target app.
|
|
174
340
|
|
|
175
|
-
|
|
176
|
-
|
|
341
|
+
Runtime data such as source files, storage files, Docker containers, and
|
|
342
|
+
database data are managed separately according to the env source and install
|
|
343
|
+
options.
|