@nocobase/plugin-ai 2.1.0-beta.47 → 2.1.0-beta.48
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/dist/ai/docs/nocobase/api/cli/app/restart.md +1 -3
- package/dist/ai/docs/nocobase/api/cli/app/start.md +1 -7
- package/dist/ai/docs/nocobase/api/cli/index.md +0 -1
- package/dist/ai/docs/nocobase/api/cli/init.md +30 -0
- package/dist/ai/docs/nocobase/data-sources/data-source-external-nocobase/index.md +157 -0
- package/dist/ai/docs/nocobase/data-sources/data-source-manager/index.md +5 -0
- package/dist/ai/docs/nocobase/ops-management/version-control/index.md +7 -1
- package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-version-control/index.md +14 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +16 -16
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/package.json +2 -2
- package/dist/ai/docs/nocobase/ai/install-upgrade-migration.mdx +0 -402
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'Installation and Upgrade Migration Guide: Using NocoBase CLI'
|
|
3
|
-
description: 'Migrate from legacy Docker, create-nocobase-app, and Git source installation upgrade methods to the new NocoBase CLI workflow.'
|
|
4
|
-
keywords: 'NocoBase CLI,installation migration,upgrade migration,nb init,nb app upgrade,Docker,create-nocobase-app,Git source'
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Installation and Upgrade Migration Guide: Using NocoBase CLI
|
|
8
|
-
|
|
9
|
-
:::danger
|
|
10
|
-
The CLI's installation and application maintenance capabilities are still under development. At present, it is more suitable for local development, test environments, and AI Agent integration scenarios, and is not recommended for direct installation, upgrade, operation, and maintenance in production environments.
|
|
11
|
-
:::
|
|
12
|
-
|
|
13
|
-
The new NocoBase CLI (`nb`) unifies installation, connection, startup, shutdown, log viewing, upgrade, and cleanup into one set of commands. Compared with the separate workflows in the old documentation for Docker, create-nocobase-app, and Git source, the CLI is better suited for local development, test environment maintenance, and AI Agent integration and collaboration.
|
|
14
|
-
|
|
15
|
-
This article applies to the following scenarios:
|
|
16
|
-
|
|
17
|
-
- You are installing or upgrading NocoBase according to the old documentation and want to switch to the new CLI approach.
|
|
18
|
-
- You already have a NocoBase deployed in a legacy way and want the CLI to manage or connect to it.
|
|
19
|
-
- You need to prepare a connectable and maintainable NocoBase environment for an AI Agent.
|
|
20
|
-
|
|
21
|
-
## Differences between the old and new approaches
|
|
22
|
-
|
|
23
|
-
The old approach splits documentation by installation source, and each source requires separate download, configuration, installation, startup, and upgrade commands.
|
|
24
|
-
|
|
25
|
-
**Old installation documentation**
|
|
26
|
-
|
|
27
|
-
- [Docker installation](/get-started/installation/docker)
|
|
28
|
-
- [create-nocobase-app installation](/get-started/installation/create-nocobase-app)
|
|
29
|
-
- [Git source installation](/get-started/installation/git)
|
|
30
|
-
|
|
31
|
-
**Old upgrade documentation**
|
|
32
|
-
|
|
33
|
-
- [Upgrading a Docker installation](/get-started/upgrading/docker)
|
|
34
|
-
- [Upgrading a create-nocobase-app installation](/get-started/upgrading/create-nocobase-app)
|
|
35
|
-
- [Upgrading a Git source installation](/get-started/upgrading/git)
|
|
36
|
-
|
|
37
|
-
The new approach uses `nb init` as the entry point and records the application source, runtime directory, storage directory, database, and API connection information in a CLI env. After that, whether the source is Docker, npm, or Git, maintenance uses the same set of `nb app`, `nb source`, and `nb db` commands as much as possible.
|
|
38
|
-
|
|
39
|
-
| Scenario | Old approach | New CLI approach |
|
|
40
|
-
| ----------------------------------- | --------------------------------------------------------- | ------------------------------------------------- |
|
|
41
|
-
| Installation entry point | `docker compose`, `create-nocobase-app`, `git clone` | `nb init` or `nb init --ui` |
|
|
42
|
-
| Application runtime management | Switch directories, modify compose, run yarn/pm2 commands | `nb app start/stop/restart/logs`, `nb env remove` |
|
|
43
|
-
| Upgrade | One set of commands per installation method | `nb app upgrade -e <env>` |
|
|
44
|
-
| Development mode | `yarn dev` | `nb source dev -e <env>` |
|
|
45
|
-
| Database status | Manually inspect containers or database services | `nb db ps -e <env>` |
|
|
46
|
-
| View environment status and details | Manually record paths, ports, and access URLs | `nb env list`, `nb env info <env>` |
|
|
47
|
-
| Access existing applications | Not covered uniformly in old installation docs | `nb init --ui` or `nb init --api-base-url` |
|
|
48
|
-
|
|
49
|
-
## Install the CLI
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm install -g @nocobase/cli@beta
|
|
53
|
-
nb --version
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
After installation, you can view the help:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
nb --help
|
|
60
|
-
nb init --help
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Install NocoBase using the new approach
|
|
64
|
-
|
|
65
|
-
### Recommended: use the visual wizard
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
nb init --ui
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
The wizard will guide you to choose:
|
|
72
|
-
|
|
73
|
-
- Create a new application or connect to an existing application
|
|
74
|
-
- Installation source: Docker, npm, Git
|
|
75
|
-
- NocoBase version
|
|
76
|
-
- Use the built-in database or an external database
|
|
77
|
-
- Administrator account and password
|
|
78
|
-
|
|
79
|
-
### Use the terminal interactive wizard
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
nb init
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Use non-interactive commands
|
|
86
|
-
|
|
87
|
-
The default installation method is Docker and uses the built-in PostgreSQL database:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
nb init --yes --env app1
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Install a specified version with Docker:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
nb init --yes --env app1 --source docker --version beta
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Install with npm:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
nb init --yes --env app1 --source npm --version beta --app-port 13080
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Install from Git source:
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
nb init --yes --env app1 --source git --version beta
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Install from Git source and specify the built-in database type:
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
nb init --yes --env app1 --source git --version beta --db-dialect mysql
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Connect to an existing NocoBase application:
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
# Uses OAuth authentication by default
|
|
121
|
-
nb init --yes --env app1 --api-base-url=http://next.v2.test.nocobase.com/nocobase/api
|
|
122
|
-
|
|
123
|
-
# Use token authentication
|
|
124
|
-
nb init --yes --env app1 \
|
|
125
|
-
--api-base-url=http://next.v2.test.nocobase.com/nocobase/api \
|
|
126
|
-
--auth-type=token \
|
|
127
|
-
--access-token=<token>
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
:::tip
|
|
131
|
-
`--env` is the environment name in the CLI. Subsequent commands such as startup, upgrade, and log viewing can all specify the target application with `-e app1`.
|
|
132
|
-
:::
|
|
133
|
-
|
|
134
|
-
## Upgrade using the new approach
|
|
135
|
-
|
|
136
|
-
In the old approach, the upgrade commands for Docker, create-nocobase-app, and Git source were different; the new CLI unifies them as:
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
nb app upgrade -e app1
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
If you only want to run the upgrade process using the source code or image that has already been downloaded, without pulling new code or images:
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
nb app upgrade -e app1 --skip-code-update
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Or use the short form:
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
nb app upgrade -e app1 -s
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Common maintenance commands
|
|
155
|
-
|
|
156
|
-
| Operation | Command |
|
|
157
|
-
| -------------------------------------------------- | ------------------------------------ |
|
|
158
|
-
| Start application | `nb app start -e app1` |
|
|
159
|
-
| Stop application | `nb app stop -e app1` |
|
|
160
|
-
| Restart application | `nb app restart -e app1` |
|
|
161
|
-
| View logs | `nb app logs -e app1` |
|
|
162
|
-
| View env and API authentication status | `nb env list` |
|
|
163
|
-
| View env details | `nb env info app1` |
|
|
164
|
-
| View built-in database status | `nb db ps -e app1` |
|
|
165
|
-
| Upgrade application | `nb app upgrade -e app1` |
|
|
166
|
-
| Stop application and built-in database | `nb app stop -e app1 --with-db` |
|
|
167
|
-
| Completely remove env and locally hosted resources | `nb env remove app1 --purge --force` |
|
|
168
|
-
|
|
169
|
-
If you just want to stop the application together with the built-in database managed by the CLI, the default is to simply use `nb app stop -e app1 --with-db`.
|
|
170
|
-
|
|
171
|
-
If you are sure this env is no longer needed, then use `nb env remove app1 --purge --force`. It will remove hosted runtime resources, storage data, and, when applicable, local app files downloaded and managed by the CLI.
|
|
172
|
-
|
|
173
|
-
## Daily development commands
|
|
174
|
-
|
|
175
|
-
`nb source` is used to manage local source projects and is mainly suitable for npm and Git source envs.
|
|
176
|
-
|
|
177
|
-
| Operation | Command |
|
|
178
|
-
| ----------------------------------- | --------------------------------------------------- |
|
|
179
|
-
| Run application in development mode | `nb source dev -e app1` |
|
|
180
|
-
| Build source code | `nb source build --cwd /your/workspace/app1/source` |
|
|
181
|
-
| Run tests | `nb source test --cwd /your/workspace/app1/source` |
|
|
182
|
-
| Download or refresh source/image | `nb source download --source git --version beta` |
|
|
183
|
-
|
|
184
|
-
:::tip
|
|
185
|
-
Docker envs are usually managed through `nb app start`, `nb app logs`, and `nb app upgrade`, and do not use `nb source dev`.
|
|
186
|
-
:::
|
|
187
|
-
|
|
188
|
-
## NB_CLI_ROOT and directory structure
|
|
189
|
-
|
|
190
|
-
The CLI stores global configuration and local application files in the directory corresponding to `NB_CLI_ROOT`.
|
|
191
|
-
|
|
192
|
-
By default, `NB_CLI_ROOT` is the current user's home directory, that is, the path returned by Node.js `os.homedir()`. For example, on macOS it is usually `/Users/<user>`. Therefore, without additional configuration, the files generated by `nb init --yes --env app1` are usually located at:
|
|
193
|
-
|
|
194
|
-
```text
|
|
195
|
-
~
|
|
196
|
-
├── .nocobase
|
|
197
|
-
│ └── config.json
|
|
198
|
-
└── app1
|
|
199
|
-
├── source
|
|
200
|
-
└── storage
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
You can also explicitly specify `NB_CLI_ROOT`:
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
export NB_CLI_ROOT=/your/workspace
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
After setting it, the configuration file and default application directory will both be placed under that directory:
|
|
210
|
-
|
|
211
|
-
```text
|
|
212
|
-
/your/workspace
|
|
213
|
-
├── .nocobase
|
|
214
|
-
│ └── config.json
|
|
215
|
-
└── app1
|
|
216
|
-
├── source
|
|
217
|
-
└── storage
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Where:
|
|
221
|
-
|
|
222
|
-
- `.nocobase/config.json` stores information such as envs, current environment, API address, source path, storage path, and database configuration.
|
|
223
|
-
- `<envName>/source` is the source code or application directory managed by the CLI.
|
|
224
|
-
- `<envName>/storage` is the application storage directory managed by the CLI.
|
|
225
|
-
|
|
226
|
-
:::warning
|
|
227
|
-
After initializing the same application, keep using the same `NB_CLI_ROOT`. If you later change `NB_CLI_ROOT`, the CLI will look for `.nocobase/config.json` in the new directory, and relative `appRootPath` and `storagePath` will also be resolved against the new directory, which may cause the application to not be found or to read and write to the wrong directory.
|
|
228
|
-
:::
|
|
229
|
-
|
|
230
|
-
The CLI currently only uses the global configuration scope. If you need to adjust where configuration and local application files are stored, set `NB_CLI_ROOT`.
|
|
231
|
-
|
|
232
|
-
When viewing and locating applications, prefer `nb env list` and `nb env info`:
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
# View configured envs and API authentication status
|
|
236
|
-
nb env list
|
|
237
|
-
|
|
238
|
-
# View detailed information for an env
|
|
239
|
-
nb env info app1
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
`nb env list` is intended for a quick overview. Here, `App Status` is the authentication status obtained by accessing the application API with the saved Token/OAuth credentials, and no longer displays database status. To view the running status of the built-in database, use:
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
nb db ps -e app1
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Only use this when you need to switch the default env:
|
|
249
|
-
|
|
250
|
-
```bash
|
|
251
|
-
nb env use app1
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## Migrate from the old approach to CLI
|
|
255
|
-
|
|
256
|
-
There are two migration strategies: **connect to an existing application**, or **bring a local application directory under CLI management**. If your old application is already running stably, it is recommended to first use "connect to an existing application", which has the lowest risk.
|
|
257
|
-
|
|
258
|
-
### Method 1: connect to an existing application
|
|
259
|
-
|
|
260
|
-
Suitable for NocoBase instances already running via Docker, create-nocobase-app, Git source, or server deployment.
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
# Uses OAuth authentication by default
|
|
264
|
-
nb init --yes --env app1 --api-base-url=http://next.v2.test.nocobase.com/nocobase/api
|
|
265
|
-
|
|
266
|
-
# Use token authentication
|
|
267
|
-
nb init --yes --env "app$RANDOM" \
|
|
268
|
-
--api-base-url=http://next.v2.test.nocobase.com/nocobase/api \
|
|
269
|
-
--auth-type=token \
|
|
270
|
-
--access-token=<token>
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
This approach only stores the API connection. The CLI will not take over startup, shutdown, upgrade, source directory, or storage directory management of the old application. It is suitable for allowing AI Agents or CLI API commands to connect to existing applications.
|
|
274
|
-
|
|
275
|
-
If you need to refresh authentication:
|
|
276
|
-
|
|
277
|
-
```bash
|
|
278
|
-
nb env auth app1
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Method 2: create a new CLI env and then migrate files
|
|
282
|
-
|
|
283
|
-
Suitable for scenarios where you want to use `nb app` and `nb source` to manage local applications afterward.
|
|
284
|
-
|
|
285
|
-
Before migration, complete the following first:
|
|
286
|
-
|
|
287
|
-
1. Stop the old application.
|
|
288
|
-
2. Back up the old database.
|
|
289
|
-
3. Back up the old `storage` directory.
|
|
290
|
-
4. Record the key environment variables of the old application, such as `APP_KEY`, `TZ`, `DB_*`, and `DB_UNDERSCORED`.
|
|
291
|
-
|
|
292
|
-
#### Migrate from an old Docker installation
|
|
293
|
-
|
|
294
|
-
The old Docker approach usually stores application data in the project's `storage` directory:
|
|
295
|
-
|
|
296
|
-
```text
|
|
297
|
-
/old-docker-project
|
|
298
|
-
├── docker-compose.yml
|
|
299
|
-
└── storage
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
It is recommended to first determine the new `NB_CLI_ROOT`, then use the CLI to create a new Docker env. The following example assumes that `NB_CLI_ROOT` is `/your/workspace`.
|
|
303
|
-
|
|
304
|
-
```bash
|
|
305
|
-
export NB_CLI_ROOT=/your/workspace
|
|
306
|
-
nb init --yes --env app2 --source docker --version beta
|
|
307
|
-
nb app stop -e app2
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
The new env will use the following directories by default:
|
|
311
|
-
|
|
312
|
-
```text
|
|
313
|
-
/your/workspace
|
|
314
|
-
└── app2
|
|
315
|
-
├── source
|
|
316
|
-
└── storage
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
Then copy the old `storage` to `/your/workspace/app2/storage`, and make sure the database connection, `APP_KEY`, and other configurations match the old environment.
|
|
320
|
-
|
|
321
|
-
After the copy is complete and the database configuration is confirmed, start the application:
|
|
322
|
-
|
|
323
|
-
```bash
|
|
324
|
-
nb app start -e app2
|
|
325
|
-
nb app logs -e app2
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
#### Migrate from an old create-nocobase-app or Git source installation
|
|
329
|
-
|
|
330
|
-
The old npm/Git approach usually places the source code, `.env`, and `storage` in the same project directory:
|
|
331
|
-
|
|
332
|
-
```text
|
|
333
|
-
/old-nocobase
|
|
334
|
-
├── .env
|
|
335
|
-
├── package.json
|
|
336
|
-
├── packages
|
|
337
|
-
└── storage
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
It is recommended to first determine the new `NB_CLI_ROOT`, then create a new npm or Git env. The following example assumes that `NB_CLI_ROOT` is `/your/workspace`.
|
|
341
|
-
|
|
342
|
-
```bash
|
|
343
|
-
export NB_CLI_ROOT=/your/workspace
|
|
344
|
-
nb init --yes --env app3 --source git --version beta
|
|
345
|
-
nb app stop -e app3
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
Then migrate as needed:
|
|
349
|
-
|
|
350
|
-
- Migrate custom plugin source code from the old project to the corresponding directory under `/your/workspace/app3/source`.
|
|
351
|
-
- Copy the old project's `storage` to `/your/workspace/app3/storage`.
|
|
352
|
-
- Sync key configurations from the old `.env` to the CLI env configuration or initialization parameters.
|
|
353
|
-
- If using the original database, disable the built-in database during initialization and fill in the old database connection information.
|
|
354
|
-
|
|
355
|
-
Example of initialization with an external database:
|
|
356
|
-
|
|
357
|
-
```bash
|
|
358
|
-
nb init --yes --env app3 --source git --version beta \
|
|
359
|
-
--no-builtin-db \
|
|
360
|
-
--db-dialect postgres \
|
|
361
|
-
--db-host 127.0.0.1 \
|
|
362
|
-
--db-port 5432 \
|
|
363
|
-
--db-database nocobase \
|
|
364
|
-
--db-user nocobase \
|
|
365
|
-
--db-password nocobase
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
After migration, start it and view the logs:
|
|
369
|
-
|
|
370
|
-
```bash
|
|
371
|
-
nb app start -e app3
|
|
372
|
-
nb app logs -e app3
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
:::warning
|
|
376
|
-
Do not directly overwrite `source`, `storage`, or connect to the production database for upgrades without a backup. Before formal migration, it is recommended to do a full rehearsal once in a test environment.
|
|
377
|
-
:::
|
|
378
|
-
|
|
379
|
-
## Quick reference for old command migration
|
|
380
|
-
|
|
381
|
-
| Old command | New CLI command |
|
|
382
|
-
| ----------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
383
|
-
| `docker compose up -d app` | `nb app start -e app1` |
|
|
384
|
-
| `docker compose stop app` | `nb app stop -e app1` |
|
|
385
|
-
| `docker compose logs -f app` | `nb app logs -e app1` |
|
|
386
|
-
| `docker compose pull app && docker compose up -d app` | `nb app upgrade -e app1` |
|
|
387
|
-
| `yarn create nocobase-app my-nocobase-app ...` | `nb init --yes --env app1 --source npm --version beta` |
|
|
388
|
-
| `npx create-nocobase-app@beta my-nocobase-app ...` | `nb init --yes --env app1 --source npm --version beta` |
|
|
389
|
-
| `git clone ... -b next --depth=1 my-nocobase` | `nb init --yes --env app1 --source git --version beta` |
|
|
390
|
-
| `git clone ... -b develop --depth=1 my-nocobase` | `nb init --yes --env app1 --source git --version alpha` |
|
|
391
|
-
| `yarn dev` | `nb source dev -e app1` |
|
|
392
|
-
| `yarn nocobase upgrade` | `nb app upgrade -e app1` |
|
|
393
|
-
| `yarn nocobase upgrade --skip-code-update` | `nb app upgrade -e app1 -s` |
|
|
394
|
-
| Manually record multiple application addresses | `nb env list`, `nb env info app1` |
|
|
395
|
-
| Manually connect to an existing application | `nb init --yes --env app1 --api-base-url=http://next.v2.test.nocobase.com/nocobase/api` |
|
|
396
|
-
|
|
397
|
-
## Related links
|
|
398
|
-
|
|
399
|
-
- [AI Agent Integration Guide](/ai/quick-start)
|
|
400
|
-
- [NocoBase CLI Command Reference](/api/cli)
|
|
401
|
-
- [Installation methods and version comparison](/get-started/quickstart)
|
|
402
|
-
- [Install and upgrade plugins](/get-started/install-upgrade-plugins)
|