@nocobase/cli 2.1.0-beta.2 → 2.1.0-beta.21

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.
Files changed (145) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +367 -19
  3. package/README.zh-CN.md +336 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +131 -0
  6. package/dist/commands/api/resource/create.js +15 -0
  7. package/dist/commands/api/resource/destroy.js +15 -0
  8. package/dist/commands/api/resource/get.js +15 -0
  9. package/dist/commands/api/resource/index.js +20 -0
  10. package/dist/commands/api/resource/list.js +16 -0
  11. package/dist/commands/api/resource/query.js +15 -0
  12. package/dist/commands/api/resource/update.js +15 -0
  13. package/dist/commands/build.js +57 -0
  14. package/dist/commands/db/logs.js +85 -0
  15. package/dist/commands/db/ps.js +60 -0
  16. package/dist/commands/db/shared.js +95 -0
  17. package/dist/commands/db/start.js +70 -0
  18. package/dist/commands/db/stop.js +70 -0
  19. package/dist/commands/dev.js +156 -0
  20. package/dist/commands/down.js +197 -0
  21. package/dist/commands/download.js +865 -0
  22. package/dist/commands/env/add.js +307 -0
  23. package/dist/commands/env/auth.js +55 -0
  24. package/dist/commands/env/list.js +36 -0
  25. package/dist/commands/env/remove.js +59 -0
  26. package/dist/commands/env/update.js +67 -0
  27. package/dist/commands/env/use.js +28 -0
  28. package/dist/commands/init.js +950 -0
  29. package/dist/commands/install.js +1927 -0
  30. package/dist/commands/logs.js +97 -0
  31. package/dist/commands/pm/disable.js +63 -0
  32. package/dist/commands/pm/enable.js +63 -0
  33. package/dist/commands/pm/list.js +61 -0
  34. package/dist/commands/prompts-stages.js +150 -0
  35. package/dist/commands/prompts-test.js +181 -0
  36. package/dist/commands/ps.js +119 -0
  37. package/dist/commands/restart.js +74 -0
  38. package/dist/commands/scaffold/migration.js +38 -0
  39. package/dist/commands/scaffold/plugin.js +37 -0
  40. package/dist/commands/self/check.js +71 -0
  41. package/dist/commands/self/index.js +20 -0
  42. package/dist/commands/self/update.js +86 -0
  43. package/dist/commands/skills/check.js +69 -0
  44. package/dist/commands/skills/index.js +20 -0
  45. package/dist/commands/skills/install.js +71 -0
  46. package/dist/commands/skills/update.js +71 -0
  47. package/dist/commands/start.js +218 -0
  48. package/dist/commands/stop.js +97 -0
  49. package/dist/commands/test.js +466 -0
  50. package/dist/commands/upgrade.js +594 -0
  51. package/dist/generated/command-registry.js +133 -0
  52. package/dist/help/runtime-help.js +20 -0
  53. package/dist/lib/api-client.js +244 -0
  54. package/dist/lib/app-runtime.js +153 -0
  55. package/dist/lib/auth-store.js +357 -0
  56. package/dist/lib/bootstrap.js +388 -0
  57. package/dist/lib/build-config.js +10 -0
  58. package/dist/lib/cli-home.js +61 -0
  59. package/dist/lib/cli-locale.js +115 -0
  60. package/dist/lib/command-discovery.js +39 -0
  61. package/dist/lib/env-auth.js +872 -0
  62. package/dist/lib/generated-command.js +150 -0
  63. package/dist/lib/http-request.js +49 -0
  64. package/dist/lib/naming.js +70 -0
  65. package/dist/lib/openapi.js +62 -0
  66. package/dist/lib/post-processors.js +23 -0
  67. package/dist/lib/prompt-catalog.js +581 -0
  68. package/dist/lib/prompt-validators.js +185 -0
  69. package/dist/lib/prompt-web-ui.js +2096 -0
  70. package/dist/lib/resource-command.js +343 -0
  71. package/dist/lib/resource-request.js +104 -0
  72. package/dist/lib/run-npm.js +197 -0
  73. package/dist/lib/runtime-generator.js +419 -0
  74. package/dist/lib/runtime-store.js +56 -0
  75. package/dist/lib/self-manager.js +246 -0
  76. package/dist/lib/skills-manager.js +269 -0
  77. package/dist/lib/startup-update.js +203 -0
  78. package/dist/lib/ui.js +175 -0
  79. package/dist/locale/en-US.json +336 -0
  80. package/dist/locale/zh-CN.json +336 -0
  81. package/dist/post-processors/data-modeling.js +66 -0
  82. package/dist/post-processors/data-source-manager.js +114 -0
  83. package/dist/post-processors/index.js +19 -0
  84. package/nocobase-ctl.config.json +287 -0
  85. package/package.json +60 -26
  86. package/LICENSE +0 -661
  87. package/bin/index.js +0 -39
  88. package/nocobase.conf.tpl +0 -95
  89. package/src/cli.js +0 -19
  90. package/src/commands/benchmark.js +0 -73
  91. package/src/commands/build.js +0 -49
  92. package/src/commands/clean.js +0 -30
  93. package/src/commands/client.js +0 -166
  94. package/src/commands/create-nginx-conf.js +0 -37
  95. package/src/commands/create-plugin.js +0 -33
  96. package/src/commands/dev.js +0 -200
  97. package/src/commands/doc.js +0 -76
  98. package/src/commands/e2e.js +0 -265
  99. package/src/commands/global.js +0 -43
  100. package/src/commands/index.js +0 -45
  101. package/src/commands/instance-id.js +0 -47
  102. package/src/commands/locale/cronstrue.js +0 -122
  103. package/src/commands/locale/react-js-cron/en-US.json +0 -75
  104. package/src/commands/locale/react-js-cron/index.js +0 -17
  105. package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
  106. package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
  107. package/src/commands/locale.js +0 -81
  108. package/src/commands/p-test.js +0 -88
  109. package/src/commands/perf.js +0 -63
  110. package/src/commands/pkg.js +0 -321
  111. package/src/commands/pm2.js +0 -37
  112. package/src/commands/postinstall.js +0 -88
  113. package/src/commands/start.js +0 -148
  114. package/src/commands/tar.js +0 -36
  115. package/src/commands/test-coverage.js +0 -55
  116. package/src/commands/test.js +0 -107
  117. package/src/commands/umi.js +0 -33
  118. package/src/commands/update-deps.js +0 -72
  119. package/src/commands/upgrade.js +0 -47
  120. package/src/commands/view-license-key.js +0 -44
  121. package/src/index.js +0 -14
  122. package/src/license.js +0 -76
  123. package/src/logger.js +0 -75
  124. package/src/plugin-generator.js +0 -80
  125. package/src/util.js +0 -517
  126. package/templates/bundle-status.html +0 -338
  127. package/templates/create-app-package.json +0 -39
  128. package/templates/plugin/.npmignore.tpl +0 -2
  129. package/templates/plugin/README.md.tpl +0 -1
  130. package/templates/plugin/client.d.ts +0 -2
  131. package/templates/plugin/client.js +0 -1
  132. package/templates/plugin/package.json.tpl +0 -11
  133. package/templates/plugin/server.d.ts +0 -2
  134. package/templates/plugin/server.js +0 -1
  135. package/templates/plugin/src/client/client.d.ts +0 -249
  136. package/templates/plugin/src/client/index.tsx.tpl +0 -1
  137. package/templates/plugin/src/client/locale.ts +0 -21
  138. package/templates/plugin/src/client/models/index.ts +0 -12
  139. package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
  140. package/templates/plugin/src/index.ts +0 -2
  141. package/templates/plugin/src/locale/en-US.json +0 -1
  142. package/templates/plugin/src/locale/zh-CN.json +0 -1
  143. package/templates/plugin/src/server/collections/.gitkeep +0 -0
  144. package/templates/plugin/src/server/index.ts.tpl +0 -1
  145. package/templates/plugin/src/server/plugin.ts.tpl +0 -19
package/LICENSE.txt ADDED
@@ -0,0 +1,107 @@
1
+ Updated Date: February 24, 2026
2
+
3
+ NocoBase License Agreement
4
+
5
+ NOCOBASE PTE. LTD.,a Singaporean Exempt Private Company Limited by Shares with its principal place of business located at 112 ROBINSON ROAD, #03-01, SINGAPORE ("The Company") https://www.nocobase.com/ issues this License Agreement ("Agreement") to you. You, as an individual or a company ("The User"), will be deemed to voluntarily accept all terms of this Agreement by using NocoBase (including but not limited to obtaining NocoBase source code or installation package in any form, installing and using NocoBase, purchasing NocoBase commercial license and services, purchasing NocoBase commercial plugins). If the User does not agree to any term of this Agreement, or cannot accurately understand our interpretation of the relevant terms, please stop using it immediately.
6
+
7
+ This Agreement applies to any use, quotation, contract, invoice, and all software delivered by the Company. The User and the Company or NocoBase's agents can no longer sign a separate license agreement for the sale and delivery of the software.
8
+
9
+ The Company reserves the right to formulate and modify this Agreement from time to time as needed. If there are changes, the Company will announce them in the form of website announcements, without further individual notification. The changed Agreement will automatically take effect once it is announced, becoming part of this Agreement.
10
+
11
+ ==============
12
+ 1. Definitions
13
+ ==============
14
+
15
+ 1.1 "Software" refers to the NocoBase kernel and plugins placed in the same code repository as the kernel, including their source code, installation packages, images, and all their modifications, updates, and upgrades.
16
+
17
+ 1.2 "Community Edition" refers to the free version of the Software provided to the User through public channels.
18
+
19
+ 1.3 "Commercial Edition" refers to the paid version of the Software purchased by the User from the Company or its agents, downloaded through exclusive channels, and includes additional benefits. It consists of three versions: Standard Edition, Professional Edition, and Enterprise Edition.
20
+
21
+ 1.4 "Upper Layer Application" refers to a specific business use case application serving internal or external customers of the User, developed based on Software and Commercial Plugins, such as ERP/CRM.
22
+
23
+ 1.5 "Customer" refers to the clients who purchase the User's Upper Layer Application.
24
+
25
+ 1.6 "Third-Party Open Source Software" refers to open source software provided with Software and Commercial Plugins. They are licensed through various published open source software licenses or copyright notices accompanying such software.
26
+
27
+ ===================================
28
+ 2. Intellectual Property Protection
29
+ ===================================
30
+
31
+ Except for Third-Party Open Source Software, the Company owns all copyrights, trademark rights, patent rights, trade secrets, and other intellectual property rights of the Software, and has registered and protected them in relevant countries and regions according to the "Paris Convention" or "TRIPS Agreement", ensuring that the intellectual property rights of the Software and Commercial Plugins are internationally recognized and protected.
32
+
33
+ =============
34
+ 3. Disclaimer
35
+ =============
36
+
37
+ 3.1 The User shall not use the Software and Commercial Plugins to engage in activities that contravene applicable laws and regulations or offend against public order or religious prohibitions. All legal liabilities and consequences arising from the User’s use shall be borne by the User.
38
+
39
+ 3.2 The Company shall not be liable for any direct, indirect, special, incidental, or consequential damages (including but not limited to loss of profits, business interruption, data loss, or business information disclosure) caused by the User's use of the Software and Commercial Plugins, even if it has been previously informed of the possibility of such damages.
40
+
41
+ ===============
42
+ 4. License Type
43
+ ===============
44
+
45
+ 4.1 This Agreement serves as the unified license agreement for NocoBase Software, applying to both the Community Edition and the Commercial Editions.
46
+
47
+ 4.2 This Agreement incorporates and references the full text of the Apache License, Version 2.0 ("Apache-2.0", available at: https://www.apache.org/licenses/LICENSE-2.0 ). Users must comply with the Apache-2.0 License as well as the supplementary terms set forth in this Agreement. In case of any inconsistency between Apache-2.0 and this Agreement, the supplementary terms of this Agreement shall prevail.
48
+
49
+ ================================================
50
+ 5. Rights and Obligations of Open Source License
51
+ ================================================
52
+
53
+ 5.1 The Software can be used for commercial purposes.
54
+
55
+ 5.2 It is not allowed to remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface, except for the main LOGO in the upper left corner of the page.
56
+
57
+ 5.3 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
58
+
59
+ 5.4 It is not allowed to provide to the public any form of no-code, zero-code, low-code, AI platform SaaS/PaaS products using the original or modified Software.
60
+
61
+ ===============================
62
+ 6. Rights of Commercial License
63
+ ===============================
64
+
65
+ 6.1 Obtain a permanent commercial license of the Software.
66
+
67
+ 6.2 Get software upgrades and exclusive technical support during the upgrade validity period.
68
+
69
+ 6.3 The licensed Software can be used for commercial purposes with no restrictions on the number of applications and users.
70
+
71
+ 6.4 Can remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface.
72
+
73
+ 6.5 The User holding a Professional or Enterprise Edition License can sell Upper Layer Application to its Customers.
74
+
75
+ 6.6 If there are other agreements in the contract for the above rights, the contract agreement shall prevail.
76
+
77
+ ====================================
78
+ 7. Obligations of Commercial License
79
+ ====================================
80
+
81
+ 7.1 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
82
+
83
+ 7.2 It is not allowed to sell, transfer, lease, share, gift, or distribute the Commercial License.
84
+
85
+ 7.3 It is not allowed to sell, transfer, lease, share, or distribute any form of no-code, zero-code, low-code, AI platform, or developer tools developed based on Software.
86
+
87
+ 7.4 It is not allowed to provide any form of no-code, zero-code, low-code, AI platform SaaS/PaaS products to the public using the original or modified Software.
88
+
89
+ 7.5 It is not allowed for the User holding a Standard Edition license to sell Upper Layer Application to Customers without a Commercial license.
90
+
91
+ 7.6 It is not allowed for the User holding a Professional or Enterprise Edition license to sell Upper Layer Application to Customers without a Commercial license with access to further development and configuration.
92
+
93
+ 7.7 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
94
+
95
+ 7.8 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
96
+
97
+ =============================================================
98
+ 8. Legal Jurisdiction, Interpretation, and Dispute Resolution
99
+ =============================================================
100
+
101
+ 8.1 Except for Mainland China, the interpretation, application, and all matters related to this agreement are subject to the jurisdiction of Singapore law.
102
+
103
+ 8.2 Any dispute related to this Agreement should first be resolved through friendly negotiation. If the negotiation fails to resolve the dispute, the dispute should be submitted to the International Chamber of Commerce (ICC) for arbitration. The arbitration venue should be Singapore, conducted in English.
104
+
105
+ 8.3 All terms and conditions of this Agreement shall be deemed enforceable to the maximum extent permitted by applicable law. If any term of this Agreement is deemed invalid by any applicable law, the invalidity of that term does not affect the validity of any other term of this Agreement, and it should be deemed that the invalid term has been modified as much as possible to make it valid and enforceable, or if the term cannot be modified, it should be deemed to have been deleted from this Agreement.
106
+
107
+ 8.4 The arbitration award is final, binding on both parties, and can be enforced in any court with jurisdiction.
package/README.md CHANGED
@@ -1,30 +1,378 @@
1
- # NocoBase
1
+ # NocoBase CLI
2
2
 
3
- <video width="100%" controls>
4
- <source src="https://static-docs.nocobase.com/NocoBase0510.mp4" type="video/mp4">
5
- </video>
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.
6
7
 
8
+ The CLI supports two common setup paths:
7
9
 
8
- ## What is NocoBase
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.
9
12
 
10
- NocoBase is a scalability-first, open-source no-code development platform.
11
- Instead of investing years of time and millions of dollars in research and development, deploy NocoBase in a few minutes and you'll have a private, controllable, and extremely scalable no-code development platform!
13
+ ## Prerequisites
12
14
 
13
- Homepage:
14
- https://www.nocobase.com/
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
15
19
 
16
- Online Demo:
17
- https://demo.nocobase.com/new
20
+ ## Installation
18
21
 
19
- Documents:
20
- https://docs.nocobase.com/
22
+ Install the CLI globally:
21
23
 
22
- Commericial license & plugins:
23
- https://www.nocobase.com/en/commercial
24
+ ```bash
25
+ npm install -g @nocobase/cli@alpha
26
+ ```
24
27
 
25
- License agreement:
26
- https://www.nocobase.com/en/agreement
28
+ Check the available commands:
27
29
 
30
+ ```bash
31
+ nb --help
32
+ nb init --help
33
+ ```
28
34
 
29
- ## Contact Us:
30
- hello@nocobase.com
35
+ ## Core Concepts
36
+
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.
42
+
43
+ ## Quick Start
44
+
45
+ ### Guided Setup
46
+
47
+ Run the guided terminal flow:
48
+
49
+ ```bash
50
+ nb init
51
+ ```
52
+
53
+ Use the browser-based setup form:
54
+
55
+ ```bash
56
+ nb init --ui
57
+ ```
58
+
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`) globally.
62
+
63
+ ### Non-Interactive Setup
64
+
65
+ When prompts are skipped, an app/env name is required:
66
+
67
+ ```bash
68
+ nb init --env app1 --yes
69
+ ```
70
+
71
+ Install with Docker:
72
+
73
+ ```bash
74
+ nb init --env app1 --yes --source docker --version alpha
75
+ ```
76
+
77
+ Install from npm:
78
+
79
+ ```bash
80
+ nb init --env app1 --yes --source npm --version alpha --app-port 13080
81
+ ```
82
+
83
+ Install from Git source:
84
+
85
+ ```bash
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 restart` | Stop, then start the selected local app or Docker container. |
142
+ | `nb dev` | Run development mode for npm/Git source envs. |
143
+ | `nb logs` | Show app logs for npm/Git or Docker envs. |
144
+ | `nb ps` | Show runtime status for configured envs. |
145
+ | `nb db` | Inspect or manage built-in database runtime status for local envs. |
146
+ | `nb upgrade` | Refresh code/image and restart the selected app. |
147
+ | `nb down` | Stop and remove local runtime containers for an env. |
148
+ | `nb env` | Manage saved CLI env connections. |
149
+ | `nb api` | Call NocoBase API resources from the CLI. |
150
+ | `nb pm` | Manage plugins for the selected NocoBase env. |
151
+ | `nb self` | Check or update the installed NocoBase CLI. |
152
+ | `nb skills` | Check, install, or update global NocoBase AI coding skills. |
153
+
154
+ Recommended style: use `--env` explicitly for app/runtime commands. `-e` is the short form:
155
+
156
+ ```bash
157
+ nb start --env app1
158
+ nb restart --env app1
159
+ nb logs --env app1
160
+ nb ps --env app1
161
+ nb db ps --env app1
162
+ ```
163
+
164
+ Equivalent shorthand examples:
165
+
166
+ ```bash
167
+ nb start -e app1
168
+ nb restart -e app1
169
+ nb logs -e app1
170
+ nb upgrade -e app1
171
+ nb db start -e app1
172
+ ```
173
+
174
+ ## CLI And Skills Updates
175
+
176
+ Check whether the installed CLI itself is up to date:
177
+
178
+ ```bash
179
+ nb self check
180
+ nb self check --json
181
+ ```
182
+
183
+ Update the CLI when it is installed globally with npm:
184
+
185
+ ```bash
186
+ nb self update
187
+ ```
188
+
189
+ Check whether the global NocoBase AI coding skills are installed:
190
+
191
+ ```bash
192
+ nb skills check
193
+ nb skills check --json
194
+ ```
195
+
196
+ Install the skills for the first time, or update an existing `nocobase/skills` install:
197
+
198
+ ```bash
199
+ nb skills install
200
+ nb skills update
201
+ ```
202
+
203
+ ## Runtime Types
204
+
205
+ ### Docker
206
+
207
+ Docker envs are managed through saved Docker containers and images:
208
+
209
+ ```bash
210
+ nb init --env app1 --yes --source docker --version alpha
211
+ nb start --env app1
212
+ nb restart --env app1
213
+ nb logs --env app1
214
+ nb stop --env app1
215
+ ```
216
+
217
+ Docker downloads support platform selection:
218
+
219
+ ```bash
220
+ nb download --source docker --version alpha --docker-platform auto
221
+ nb download --source docker --version alpha --docker-platform linux/amd64
222
+ nb download --source docker --version alpha --docker-platform linux/arm64
223
+ ```
224
+
225
+ ### npm and Git
226
+
227
+ npm and Git envs use a local source directory and can run development mode:
228
+
229
+ ```bash
230
+ nb init --env app1 --yes --source git --version alpha
231
+ nb dev --env app1
232
+ ```
233
+
234
+ `nb dev` only supports npm/Git source envs. Docker envs can be inspected with
235
+ `nb logs`, and remote envs only support API/env operations.
236
+
237
+ ### Existing NocoBase App
238
+
239
+ To connect an existing app, use `nb init` and choose the existing-app setup
240
+ path, or add the env directly:
241
+
242
+ ```bash
243
+ nb env add app1 --api-base-url http://localhost:13000/api
244
+ ```
245
+
246
+ `nb env add` will start the authentication flow automatically when needed.
247
+
248
+ ## Upgrade
249
+
250
+ Upgrade refreshes the saved source or image, then restarts the app:
251
+
252
+ ```bash
253
+ nb upgrade --env app1
254
+ ```
255
+
256
+ Use `--skip-code-update` or `-s` to restart with the saved local code or Docker
257
+ image without downloading updates first:
258
+
259
+ ```bash
260
+ nb upgrade --env app1 -s
261
+ ```
262
+
263
+ ## Database Commands
264
+
265
+ Use `nb db` to inspect or manage the built-in database runtime for a local env:
266
+
267
+ ```bash
268
+ nb db ps
269
+ nb db ps --env app1
270
+ nb db start --env app1
271
+ nb db stop --env app1
272
+ nb db logs --env app1
273
+ ```
274
+
275
+ Notes:
276
+
277
+ - `nb db start` and `nb db stop` only work for envs created with the built-in database option enabled.
278
+ - `nb db logs` only works for envs created with the built-in database option enabled.
279
+ - `nb db ps` can also show `external` or `remote` status for envs that do not have a CLI-managed database container.
280
+
281
+ ## Cleanup
282
+
283
+ Bring down a local env:
284
+
285
+ ```bash
286
+ nb down --env app1
287
+ ```
288
+
289
+ By default, `nb down` stops the app and removes app/database containers if they
290
+ exist. It keeps user data, source files, and CLI env config.
291
+
292
+ Use explicit flags for destructive cleanup:
293
+
294
+ ```bash
295
+ nb down --env app1 --remove-data
296
+ nb down --env app1 --remove-source
297
+ nb down --env app1 --remove-env
298
+ ```
299
+
300
+ - `--remove-data`: delete storage and managed database data. This requires confirmation unless `--yes` is used.
301
+ - `--remove-source`: delete the npm/Git source directory.
302
+ - `--remove-env`: remove the saved CLI env config.
303
+
304
+ ## Environment Management
305
+
306
+ Show the current env:
307
+
308
+ ```bash
309
+ nb env
310
+ ```
311
+
312
+ List configured envs:
313
+
314
+ ```bash
315
+ nb env list
316
+ ```
317
+
318
+ Switch the current env:
319
+
320
+ ```bash
321
+ nb env use app1
322
+ ```
323
+
324
+ Re-authenticate an env when credentials need to be refreshed:
325
+
326
+ ```bash
327
+ nb env auth app1
328
+ ```
329
+
330
+ Update runtime command metadata from the selected app:
331
+
332
+ ```bash
333
+ nb env update app1
334
+ ```
335
+
336
+ ## API Commands
337
+
338
+ The CLI can call NocoBase resources through the configured env:
339
+
340
+ ```bash
341
+ nb api resource list --resource users -e app1
342
+ nb api resource get --resource users --filter-by-tk 1 -e app1
343
+ nb api resource create --resource users --values '{"nickname":"Ada"}' -e app1
344
+ ```
345
+
346
+ Use `-j, --json-output` to print raw JSON when available:
347
+
348
+ ```bash
349
+ nb api resource list --resource users -e app1 -j
350
+ ```
351
+
352
+ Available API command topics:
353
+
354
+ | Command | Description |
355
+ | --- | --- |
356
+ | `nb api acl` | Manage access control based on roles, resources, and actions. |
357
+ | `nb api api-keys` | Manage API keys for HTTP API access. |
358
+ | `nb api app` | Manage application resources. |
359
+ | `nb api authenticators` | Manage user authentication, including password auth, SMS auth, SSO protocols, and extensible providers. |
360
+ | `nb api data-modeling` | Manage data sources, collections, and database modeling resources. |
361
+ | `nb api file-manager` | Manage file storage services, file collections, and attachment fields. |
362
+ | `nb api flow-surfaces` | Compose and mutate page, tab, block, field, and action surfaces. |
363
+ | `nb api pm` | Manage plugins through API commands. |
364
+ | `nb api resource` | Work with generic collection resources. |
365
+ | `nb api system-settings` | Adjust system title, logo, language, and other global settings. |
366
+ | `nb api theme-editor` | Customize UI colors and dimensions, save themes, and switch between them. |
367
+ | `nb api workflow` | Manage workflow resources for business automation. |
368
+
369
+ ## Local Data
370
+
371
+ The CLI stores workspace-level config in `.nocobase`:
372
+
373
+ - `config.json`: env definitions, current env, and workspace-level settings.
374
+ - `versions/<version>/commands.json`: cached runtime commands generated from the target app.
375
+
376
+ Runtime data such as source files, storage files, Docker containers, and
377
+ database data are managed separately according to the env source and install
378
+ options.