nodebbs 0.0.0 → 0.0.2

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 (59) hide show
  1. package/README.md +378 -249
  2. package/dist/commands/db/generate.d.ts +5 -0
  3. package/dist/commands/db/generate.js +12 -0
  4. package/dist/commands/db/index.d.ts +5 -0
  5. package/dist/commands/db/index.js +11 -0
  6. package/dist/commands/db/migrate.d.ts +5 -0
  7. package/dist/commands/db/migrate.js +12 -0
  8. package/dist/commands/db/push.d.ts +5 -0
  9. package/dist/commands/db/push.js +12 -0
  10. package/dist/commands/db/reset.d.ts +5 -0
  11. package/dist/commands/db/reset.js +22 -0
  12. package/dist/commands/db/seed.d.ts +5 -0
  13. package/dist/commands/db/seed.js +12 -0
  14. package/dist/commands/deploy/index.d.ts +8 -0
  15. package/dist/commands/deploy/index.js +95 -0
  16. package/dist/commands/dev/index.d.ts +9 -0
  17. package/dist/commands/dev/index.js +59 -0
  18. package/dist/commands/logs/api.d.ts +5 -0
  19. package/dist/commands/logs/api.js +11 -0
  20. package/dist/commands/logs/db.d.ts +5 -0
  21. package/dist/commands/logs/db.js +11 -0
  22. package/dist/commands/logs/index.d.ts +5 -0
  23. package/dist/commands/logs/index.js +11 -0
  24. package/dist/commands/logs/redis.d.ts +5 -0
  25. package/dist/commands/logs/redis.js +11 -0
  26. package/dist/commands/logs/web.d.ts +5 -0
  27. package/dist/commands/logs/web.js +11 -0
  28. package/dist/commands/restart/index.d.ts +5 -0
  29. package/dist/commands/restart/index.js +12 -0
  30. package/dist/commands/setup/index.d.ts +5 -0
  31. package/dist/commands/setup/index.js +12 -0
  32. package/dist/commands/shell/api.d.ts +5 -0
  33. package/dist/commands/shell/api.js +11 -0
  34. package/dist/commands/shell/db.d.ts +5 -0
  35. package/dist/commands/shell/db.js +11 -0
  36. package/dist/commands/shell/redis.d.ts +5 -0
  37. package/dist/commands/shell/redis.js +11 -0
  38. package/dist/commands/shell/web.d.ts +5 -0
  39. package/dist/commands/shell/web.js +11 -0
  40. package/dist/commands/status/index.d.ts +5 -0
  41. package/dist/commands/status/index.js +11 -0
  42. package/dist/commands/stop/index.d.ts +8 -0
  43. package/dist/commands/stop/index.js +37 -0
  44. package/dist/templates/docker-compose.lowmem.yml +126 -0
  45. package/dist/templates/docker-compose.prod.yml +120 -0
  46. package/dist/templates/docker-compose.yml +127 -0
  47. package/dist/templates/init-db.sql +14 -0
  48. package/dist/utils/docker.d.ts +8 -0
  49. package/dist/utils/docker.js +101 -0
  50. package/dist/utils/env.d.ts +2 -0
  51. package/dist/utils/env.js +108 -0
  52. package/dist/utils/logger.d.ts +7 -0
  53. package/dist/utils/logger.js +14 -0
  54. package/oclif.manifest.json +441 -26
  55. package/package.json +9 -3
  56. package/dist/commands/hello/index.d.ts +0 -12
  57. package/dist/commands/hello/index.js +0 -19
  58. package/dist/commands/hello/world.d.ts +0 -8
  59. package/dist/commands/hello/world.js +0 -14
package/README.md CHANGED
@@ -1,397 +1,526 @@
1
- nodebbs
2
- =================
3
-
4
- A new CLI generated with oclif
1
+ # NodeBBS CLI
5
2
 
3
+ > 全栈友好的 NodeBBS 部署和管理命令行工具
6
4
 
7
5
  [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
8
6
  [![Version](https://img.shields.io/npm/v/nodebbs.svg)](https://npmjs.org/package/nodebbs)
9
- [![Downloads/week](https://img.shields.io/npm/dw/nodebbs.svg)](https://npmjs.org/package/nodebbs)
10
7
 
8
+ ## 📖 简介
11
9
 
12
- <!-- toc -->
13
- * [Usage](#usage)
14
- * [Commands](#commands)
15
- <!-- tocstop -->
16
- # Usage
17
- <!-- usage -->
18
- ```sh-session
19
- $ npm install -g nodebbs
20
- $ nodebbs COMMAND
21
- running command...
22
- $ nodebbs (--version)
23
- nodebbs/0.0.0 darwin-arm64 node-v22.19.0
24
- $ nodebbs --help [COMMAND]
25
- USAGE
26
- $ nodebbs COMMAND
27
- ...
28
- ```
29
- <!-- usagestop -->
30
- # Commands
31
- <!-- commands -->
32
- * [`nodebbs hello PERSON`](#nodebbs-hello-person)
33
- * [`nodebbs hello world`](#nodebbs-hello-world)
34
- * [`nodebbs help [COMMAND]`](#nodebbs-help-command)
35
- * [`nodebbs plugins`](#nodebbs-plugins)
36
- * [`nodebbs plugins add PLUGIN`](#nodebbs-plugins-add-plugin)
37
- * [`nodebbs plugins:inspect PLUGIN...`](#nodebbs-pluginsinspect-plugin)
38
- * [`nodebbs plugins install PLUGIN`](#nodebbs-plugins-install-plugin)
39
- * [`nodebbs plugins link PATH`](#nodebbs-plugins-link-path)
40
- * [`nodebbs plugins remove [PLUGIN]`](#nodebbs-plugins-remove-plugin)
41
- * [`nodebbs plugins reset`](#nodebbs-plugins-reset)
42
- * [`nodebbs plugins uninstall [PLUGIN]`](#nodebbs-plugins-uninstall-plugin)
43
- * [`nodebbs plugins unlink [PLUGIN]`](#nodebbs-plugins-unlink-plugin)
44
- * [`nodebbs plugins update`](#nodebbs-plugins-update)
10
+ NodeBBS CLI 是一个专为全栈开发者设计的命令行工具,用于简化 NodeBBS 项目的开发、部署和管理流程。它提供了直观的命令接口,让你可以轻松管理 Docker 容器、查看日志、操作数据库等。
11
+
12
+ ### 特性
13
+
14
+ - 🚀 **快速启动** - 一键启动开发环境
15
+ - 🎯 **全栈友好** - 命令设计贴近开发者思维
16
+ - 🔧 **服务级控制** - 可以单独管理每个服务
17
+ - 📊 **实时日志** - 方便查看各服务日志
18
+ - 💾 **数据库管理** - 内置数据库迁移和管理工具
19
+ - 🌐 **内置模板** - 无需本地配置文件即可使用
20
+ - 🇨🇳 **中文界面** - 所有输出均为中文
45
21
 
46
- ## `nodebbs hello PERSON`
22
+ ## 📦 安装
47
23
 
48
- Say hello
24
+ ```bash
25
+ # 使用 npm
26
+ npm install -g nodebbs
49
27
 
28
+ # 使用 pnpm
29
+ pnpm add -g nodebbs
30
+
31
+ # 使用 yarn
32
+ yarn global add nodebbs
50
33
  ```
51
- USAGE
52
- $ nodebbs hello PERSON -f <value>
53
34
 
54
- ARGUMENTS
55
- PERSON Person to say hello to
35
+ 或者直接使用 npx(无需安装):
36
+
37
+ ```bash
38
+ npx nodebbs [command]
39
+ ```
56
40
 
57
- FLAGS
58
- -f, --from=<value> (required) Who is saying hello
41
+ ## 🚀 快速开始
59
42
 
60
- DESCRIPTION
61
- Say hello
43
+ ### 1. 初始化项目
62
44
 
63
- EXAMPLES
64
- $ nodebbs hello friend --from oclif
65
- hello friend from oclif! (./src/commands/hello/index.ts)
45
+ ```bash
46
+ # 首次使用,初始化项目环境
47
+ npx nodebbs setup
66
48
  ```
67
49
 
68
- _See code: [src/commands/hello/index.ts](https://github.com/nodebbs/nodebbs/blob/v0.0.0/src/commands/hello/index.ts)_
50
+ 这会创建 `.env` 文件,请编辑该文件并修改:
51
+ - `POSTGRES_PASSWORD` - 数据库密码
52
+ - `REDIS_PASSWORD` - Redis 密码
53
+ - `JWT_SECRET` - JWT 密钥
69
54
 
70
- ## `nodebbs hello world`
55
+ ### 2. 启动开发环境
71
56
 
72
- Say hello world
57
+ ```bash
58
+ # 启动所有服务
59
+ npx nodebbs dev
73
60
 
61
+ # 或者重新构建并启动
62
+ npx nodebbs dev --rebuild
74
63
  ```
75
- USAGE
76
- $ nodebbs hello world
77
64
 
78
- DESCRIPTION
79
- Say hello world
65
+ ### 3. 查看服务状态
80
66
 
81
- EXAMPLES
82
- $ nodebbs hello world
83
- hello world! (./src/commands/hello/world.ts)
67
+ ```bash
68
+ # 查看所有服务状态
69
+ npx nodebbs status
84
70
  ```
85
71
 
86
- _See code: [src/commands/hello/world.ts](https://github.com/nodebbs/nodebbs/blob/v0.0.0/src/commands/hello/world.ts)_
72
+ ### 4. 访问应用
87
73
 
88
- ## `nodebbs help [COMMAND]`
74
+ - **Web 前端**: http://localhost:3100
75
+ - **API 文档**: http://localhost:7100/docs
76
+ - **健康检查**: http://localhost:7100/api
89
77
 
90
- Display help for nodebbs.
78
+ ## 📚 命令参考
91
79
 
80
+ ### 核心命令
81
+
82
+ #### `nodebbs setup`
83
+ 初始化项目(首次使用)
84
+
85
+ ```bash
86
+ npx nodebbs setup
92
87
  ```
93
- USAGE
94
- $ nodebbs help [COMMAND...] [-n]
95
88
 
96
- ARGUMENTS
97
- [COMMAND...] Command to show help for.
89
+ #### `nodebbs dev`
90
+ 启动开发环境
98
91
 
99
- FLAGS
100
- -n, --nested-commands Include all nested commands in the output.
92
+ ```bash
93
+ # 启动所有服务
94
+ npx nodebbs dev
101
95
 
102
- DESCRIPTION
103
- Display help for nodebbs.
96
+ # 重新构建并启动
97
+ npx nodebbs dev --rebuild
98
+ npx nodebbs dev -r
99
+
100
+ # 指定环境启动
101
+ npx nodebbs dev -e production
102
+ npx nodebbs dev -e lowmem
103
+ npx nodebbs dev -e basic
104
104
  ```
105
105
 
106
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
106
+ **参数**:
107
+ - `-e, --env` - 部署环境(production, lowmem, basic)
108
+ - `-r, --rebuild` - 重新构建镜像
107
109
 
108
- ## `nodebbs plugins`
110
+ #### `nodebbs deploy`
111
+ 部署到生产环境
109
112
 
110
- List installed plugins.
113
+ ```bash
114
+ # 完整部署流程
115
+ npx nodebbs deploy
111
116
 
117
+ # 指定环境部署
118
+ npx nodebbs deploy -e production
112
119
  ```
113
- USAGE
114
- $ nodebbs plugins [--json] [--core]
115
120
 
116
- FLAGS
117
- --core Show core plugins.
121
+ 包含:
122
+ - Docker 环境检查
123
+ - 环境变量验证
124
+ - 镜像构建
125
+ - 服务启动
126
+ - 健康检查
127
+ - 数据库初始化(可选)
118
128
 
119
- GLOBAL FLAGS
120
- --json Format output as json.
129
+ #### `nodebbs stop`
130
+ 停止服务
121
131
 
122
- DESCRIPTION
123
- List installed plugins.
132
+ ```bash
133
+ # 停止所有服务
134
+ npx nodebbs stop
124
135
 
125
- EXAMPLES
126
- $ nodebbs plugins
136
+ # 停止服务并删除数据卷(危险!)
137
+ npx nodebbs stop --volumes
138
+ npx nodebbs stop -v
127
139
  ```
128
140
 
129
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/index.ts)_
141
+ **参数**:
142
+ - `-v, --volumes` - 同时删除数据卷
130
143
 
131
- ## `nodebbs plugins add PLUGIN`
144
+ #### `nodebbs restart`
145
+ 重启所有服务
132
146
 
133
- Installs a plugin into nodebbs.
147
+ ```bash
148
+ npx nodebbs restart
149
+ ```
134
150
 
151
+ #### `nodebbs status`
152
+ 查看服务状态
153
+
154
+ ```bash
155
+ npx nodebbs status
135
156
  ```
136
- USAGE
137
- $ nodebbs plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
138
157
 
139
- ARGUMENTS
140
- PLUGIN... Plugin to install.
158
+ ### 日志管理
141
159
 
142
- FLAGS
143
- -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
144
- -h, --help Show CLI help.
145
- -s, --silent Silences npm output.
146
- -v, --verbose Show verbose npm output.
160
+ #### `nodebbs logs`
161
+ 查看所有服务日志
147
162
 
148
- GLOBAL FLAGS
149
- --json Format output as json.
163
+ ```bash
164
+ npx nodebbs logs
165
+ ```
150
166
 
151
- DESCRIPTION
152
- Installs a plugin into nodebbs.
167
+ #### `nodebbs logs:api`
168
+ 查看 API 服务日志
153
169
 
154
- Uses npm to install plugins.
170
+ ```bash
171
+ npx nodebbs logs:api
172
+ ```
155
173
 
156
- Installation of a user-installed plugin will override a core plugin.
174
+ #### `nodebbs logs:web`
175
+ 查看 Web 服务日志
157
176
 
158
- Use the NODEBBS_NPM_LOG_LEVEL environment variable to set the npm loglevel.
159
- Use the NODEBBS_NPM_REGISTRY environment variable to set the npm registry.
177
+ ```bash
178
+ npx nodebbs logs:web
179
+ ```
160
180
 
161
- ALIASES
162
- $ nodebbs plugins add
181
+ #### `nodebbs logs:db`
182
+ 查看数据库日志
163
183
 
164
- EXAMPLES
165
- Install a plugin from npm registry.
184
+ ```bash
185
+ npx nodebbs logs:db
186
+ ```
166
187
 
167
- $ nodebbs plugins add myplugin
188
+ #### `nodebbs logs:redis`
189
+ 查看 Redis 日志
168
190
 
169
- Install a plugin from a github url.
191
+ ```bash
192
+ npx nodebbs logs:redis
193
+ ```
170
194
 
171
- $ nodebbs plugins add https://github.com/someuser/someplugin
195
+ ### Shell 访问
172
196
 
173
- Install a plugin from a github slug.
197
+ #### `nodebbs shell:api`
198
+ 进入 API 容器
174
199
 
175
- $ nodebbs plugins add someuser/someplugin
200
+ ```bash
201
+ npx nodebbs shell:api
176
202
  ```
177
203
 
178
- ## `nodebbs plugins:inspect PLUGIN...`
204
+ #### `nodebbs shell:web`
205
+ 进入 Web 容器
179
206
 
180
- Displays installation properties of a plugin.
207
+ ```bash
208
+ npx nodebbs shell:web
209
+ ```
181
210
 
211
+ #### `nodebbs shell:db`
212
+ 进入数据库(自动启动 psql)
213
+
214
+ ```bash
215
+ npx nodebbs shell:db
182
216
  ```
183
- USAGE
184
- $ nodebbs plugins inspect PLUGIN...
185
217
 
186
- ARGUMENTS
187
- PLUGIN... [default: .] Plugin to inspect.
218
+ #### `nodebbs shell:redis`
219
+ 进入 Redis(自动启动 redis-cli)
188
220
 
189
- FLAGS
190
- -h, --help Show CLI help.
191
- -v, --verbose
221
+ ```bash
222
+ npx nodebbs shell:redis
223
+ ```
192
224
 
193
- GLOBAL FLAGS
194
- --json Format output as json.
225
+ ### 数据库管理
195
226
 
196
- DESCRIPTION
197
- Displays installation properties of a plugin.
227
+ #### `nodebbs db`
228
+ 打开数据库管理界面(Drizzle Studio)
198
229
 
199
- EXAMPLES
200
- $ nodebbs plugins inspect myplugin
230
+ ```bash
231
+ npx nodebbs db
201
232
  ```
202
233
 
203
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/inspect.ts)_
234
+ #### `nodebbs db:generate`
235
+ 生成数据库迁移文件
204
236
 
205
- ## `nodebbs plugins install PLUGIN`
237
+ ```bash
238
+ npx nodebbs db:generate
239
+ ```
206
240
 
207
- Installs a plugin into nodebbs.
241
+ #### `nodebbs db:migrate`
242
+ 执行数据库迁移
208
243
 
244
+ ```bash
245
+ npx nodebbs db:migrate
209
246
  ```
210
- USAGE
211
- $ nodebbs plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
212
247
 
213
- ARGUMENTS
214
- PLUGIN... Plugin to install.
248
+ #### `nodebbs db:push`
249
+ 推送数据库 schema
215
250
 
216
- FLAGS
217
- -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
218
- -h, --help Show CLI help.
219
- -s, --silent Silences npm output.
220
- -v, --verbose Show verbose npm output.
251
+ ```bash
252
+ npx nodebbs db:push
253
+ ```
221
254
 
222
- GLOBAL FLAGS
223
- --json Format output as json.
255
+ #### `nodebbs db:seed`
256
+ 初始化数据库数据
224
257
 
225
- DESCRIPTION
226
- Installs a plugin into nodebbs.
258
+ ```bash
259
+ npx nodebbs db:seed
260
+ ```
227
261
 
228
- Uses npm to install plugins.
262
+ #### `nodebbs db:reset`
263
+ 重置并重新初始化数据(危险!)
229
264
 
230
- Installation of a user-installed plugin will override a core plugin.
265
+ ```bash
266
+ npx nodebbs db:reset
267
+ ```
231
268
 
232
- Use the NODEBBS_NPM_LOG_LEVEL environment variable to set the npm loglevel.
233
- Use the NODEBBS_NPM_REGISTRY environment variable to set the npm registry.
269
+ ## 🎯 使用场景
234
270
 
235
- ALIASES
236
- $ nodebbs plugins add
271
+ ### 场景 1:新开发者加入项目
237
272
 
238
- EXAMPLES
239
- Install a plugin from npm registry.
273
+ ```bash
274
+ # 1. 初始化项目
275
+ npx nodebbs setup
240
276
 
241
- $ nodebbs plugins install myplugin
277
+ # 2. 启动开发环境
278
+ npx nodebbs dev
242
279
 
243
- Install a plugin from a github url.
280
+ # 3. 初始化数据库
281
+ npx nodebbs db:push
282
+ npx nodebbs db:seed
244
283
 
245
- $ nodebbs plugins install https://github.com/someuser/someplugin
284
+ # 4. 查看服务状态
285
+ npx nodebbs status
286
+ ```
246
287
 
247
- Install a plugin from a github slug.
288
+ ### 场景 2:日常开发
248
289
 
249
- $ nodebbs plugins install someuser/someplugin
250
- ```
290
+ ```bash
291
+ # 启动开发环境
292
+ npx nodebbs dev
251
293
 
252
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/install.ts)_
294
+ # 查看 API 日志
295
+ npx nodebbs logs:api
253
296
 
254
- ## `nodebbs plugins link PATH`
297
+ # 进入 API 容器调试
298
+ npx nodebbs shell:api
255
299
 
256
- Links a plugin into the CLI for development.
300
+ # 打开数据库管理
301
+ npx nodebbs db
257
302
 
303
+ # 重置测试数据
304
+ npx nodebbs db:reset
258
305
  ```
259
- USAGE
260
- $ nodebbs plugins link PATH [-h] [--install] [-v]
261
306
 
262
- ARGUMENTS
263
- PATH [default: .] path to plugin
307
+ ### 场景 3:代码更新后重新构建
308
+
309
+ ```bash
310
+ # 停止服务
311
+ npx nodebbs stop
264
312
 
265
- FLAGS
266
- -h, --help Show CLI help.
267
- -v, --verbose
268
- --[no-]install Install dependencies after linking the plugin.
313
+ # 重新构建并启动
314
+ npx nodebbs dev --rebuild
269
315
 
270
- DESCRIPTION
271
- Links a plugin into the CLI for development.
316
+ # 查看日志确认启动成功
317
+ npx nodebbs logs
318
+ ```
272
319
 
273
- Installation of a linked plugin will override a user-installed or core plugin.
320
+ ### 场景 4:生产部署
274
321
 
275
- e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
276
- command will override the user-installed or core plugin implementation. This is useful for development work.
322
+ ```bash
323
+ # 部署到生产环境
324
+ npx nodebbs deploy -e production
277
325
 
326
+ # 查看服务状态
327
+ npx nodebbs status
278
328
 
279
- EXAMPLES
280
- $ nodebbs plugins link myplugin
329
+ # 查看日志
330
+ npx nodebbs logs
331
+
332
+ # 执行数据库迁移
333
+ npx nodebbs db:migrate
281
334
  ```
282
335
 
283
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/link.ts)_
336
+ ### 场景 5:数据库操作
337
+
338
+ ```bash
339
+ # 打开数据库管理界面
340
+ npx nodebbs db
284
341
 
285
- ## `nodebbs plugins remove [PLUGIN]`
342
+ # 运行迁移
343
+ npx nodebbs db:migrate
286
344
 
287
- Removes a plugin from the CLI.
345
+ # 填充数据
346
+ npx nodebbs db:seed
288
347
 
348
+ # 进入数据库命令行
349
+ npx nodebbs shell:db
289
350
  ```
290
- USAGE
291
- $ nodebbs plugins remove [PLUGIN...] [-h] [-v]
292
351
 
293
- ARGUMENTS
294
- [PLUGIN...] plugin to uninstall
352
+ ## 🔄 从 Makefile 迁移
295
353
 
296
- FLAGS
297
- -h, --help Show CLI help.
298
- -v, --verbose
354
+ 如果你之前使用 Makefile,这里是命令对照表:
299
355
 
300
- DESCRIPTION
301
- Removes a plugin from the CLI.
356
+ | Makefile 命令 | NodeBBS CLI 命令 |
357
+ |--------------|-----------------|
358
+ | `make init` | `npx nodebbs setup` |
359
+ | `make up` | `npx nodebbs dev` |
360
+ | `make build` | `npx nodebbs dev --rebuild` |
361
+ | `make rebuild` | `npx nodebbs dev --rebuild` |
362
+ | `ENV=prod make rebuild` | `npx nodebbs deploy -e production` |
363
+ | `make down` | `npx nodebbs stop` |
364
+ | `make restart` | `npx nodebbs restart` |
365
+ | `make ps` | `npx nodebbs status` |
366
+ | `make logs` | `npx nodebbs logs` |
367
+ | `make logs-api` | `npx nodebbs logs:api` |
368
+ | `make exec-api` | `npx nodebbs shell:api` |
369
+ | `make db-studio` | `npx nodebbs db` |
370
+ | `make clean-all` | `npx nodebbs stop --volumes` |
302
371
 
303
- ALIASES
304
- $ nodebbs plugins unlink
305
- $ nodebbs plugins remove
372
+ ## ⚙️ 环境配置
306
373
 
307
- EXAMPLES
308
- $ nodebbs plugins remove myplugin
309
- ```
374
+ ### 支持的环境
310
375
 
311
- ## `nodebbs plugins reset`
376
+ - **basic** - 基础环境(仅用于测试)
377
+ - **lowmem** - 低配环境(1C1G/1C2G)
378
+ - **production** - 生产环境(2C4G+,推荐)
312
379
 
313
- Remove all user-installed and linked plugins.
380
+ ### 环境变量
314
381
 
315
- ```
316
- USAGE
317
- $ nodebbs plugins reset [--hard] [--reinstall]
382
+ 在 `.env` 文件中配置:
383
+
384
+ ```env
385
+ # 数据库配置
386
+ POSTGRES_PASSWORD=your_secure_password
387
+ POSTGRES_DB=nodebbs
388
+
389
+ # Redis 配置
390
+ REDIS_PASSWORD=your_redis_password
391
+
392
+ # JWT 配置
393
+ JWT_SECRET=your_jwt_secret
318
394
 
319
- FLAGS
320
- --hard Delete node_modules and package manager related files in addition to uninstalling plugins.
321
- --reinstall Reinstall all plugins after uninstalling.
395
+ # 应用配置
396
+ APP_URL=http://localhost:3100
397
+ API_URL=http://localhost:7100
398
+
399
+ # CORS 配置
400
+ CORS_ORIGIN=*
322
401
  ```
323
402
 
324
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/reset.ts)_
403
+ ## 🛠️ 高级用法
325
404
 
326
- ## `nodebbs plugins uninstall [PLUGIN]`
405
+ ### 内置模板
327
406
 
328
- Removes a plugin from the CLI.
407
+ NodeBBS CLI 内置了 Docker Compose 配置文件,即使项目中没有这些文件,也可以直接使用:
329
408
 
409
+ ```bash
410
+ # 在任何目录运行
411
+ npx nodebbs dev
330
412
  ```
331
- USAGE
332
- $ nodebbs plugins uninstall [PLUGIN...] [-h] [-v]
333
413
 
334
- ARGUMENTS
335
- [PLUGIN...] plugin to uninstall
414
+ CLI 会自动:
415
+ 1. 检查当前目录是否有 `docker-compose.yml`
416
+ 2. 如果没有,使用内置模板
417
+ 3. 使用当前目录作为项目目录
336
418
 
337
- FLAGS
338
- -h, --help Show CLI help.
339
- -v, --verbose
419
+ ### 自定义配置
340
420
 
341
- DESCRIPTION
342
- Removes a plugin from the CLI.
421
+ 如果需要自定义配置,在项目根目录创建:
422
+ - `docker-compose.yml` - 基础配置
423
+ - `docker-compose.prod.yml` - 生产环境配置
424
+ - `docker-compose.lowmem.yml` - 低配环境配置
343
425
 
344
- ALIASES
345
- $ nodebbs plugins unlink
346
- $ nodebbs plugins remove
426
+ CLI 会优先使用本地配置文件。
347
427
 
348
- EXAMPLES
349
- $ nodebbs plugins uninstall myplugin
350
- ```
428
+ ## 🐛 故障排除
351
429
 
352
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/uninstall.ts)_
430
+ ### 服务启动失败
353
431
 
354
- ## `nodebbs plugins unlink [PLUGIN]`
432
+ ```bash
433
+ # 查看日志
434
+ npx nodebbs logs
355
435
 
356
- Removes a plugin from the CLI.
436
+ # 查看特定服务日志
437
+ npx nodebbs logs:api
357
438
 
439
+ # 检查服务状态
440
+ npx nodebbs status
358
441
  ```
359
- USAGE
360
- $ nodebbs plugins unlink [PLUGIN...] [-h] [-v]
361
442
 
362
- ARGUMENTS
363
- [PLUGIN...] plugin to uninstall
443
+ ### 数据库连接问题
364
444
 
365
- FLAGS
366
- -h, --help Show CLI help.
367
- -v, --verbose
445
+ ```bash
446
+ # 进入数据库检查
447
+ npx nodebbs shell:db
448
+
449
+ # 重置数据库
450
+ npx nodebbs db:reset
451
+ ```
368
452
 
369
- DESCRIPTION
370
- Removes a plugin from the CLI.
453
+ ### 端口冲突
371
454
 
372
- ALIASES
373
- $ nodebbs plugins unlink
374
- $ nodebbs plugins remove
455
+ 检查以下端口是否被占用:
456
+ - 3100 - Web 前端
457
+ - 7100 - API 服务
458
+ - 5432 - PostgreSQL
459
+ - 6379 - Redis
375
460
 
376
- EXAMPLES
377
- $ nodebbs plugins unlink myplugin
461
+ ### 清理环境
462
+
463
+ ```bash
464
+ # 停止所有服务
465
+ npx nodebbs stop
466
+
467
+ # 停止并删除所有数据(危险!)
468
+ npx nodebbs stop --volumes
378
469
  ```
379
470
 
380
- ## `nodebbs plugins update`
471
+ ## 📝 开发
472
+
473
+ ### 本地开发
381
474
 
382
- Update installed plugins.
475
+ ```bash
476
+ # 克隆仓库
477
+ git clone https://github.com/nodebbs/nodebbs.git
478
+ cd nodebbs
383
479
 
480
+ # 安装依赖
481
+ pnpm install
482
+
483
+ # 构建
484
+ pnpm build
485
+
486
+ # 运行
487
+ ./bin/run.js [command]
384
488
  ```
385
- USAGE
386
- $ nodebbs plugins update [-h] [-v]
387
489
 
388
- FLAGS
389
- -h, --help Show CLI help.
390
- -v, --verbose
490
+ ### 测试命令
491
+
492
+ ```bash
493
+ # 查看帮助
494
+ ./bin/run.js --help
495
+
496
+ # 测试 dev 命令
497
+ ./bin/run.js dev --help
391
498
 
392
- DESCRIPTION
393
- Update installed plugins.
499
+ # 测试 logs 命令
500
+ ./bin/run.js logs --help
394
501
  ```
395
502
 
396
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.54/src/commands/plugins/update.ts)_
397
- <!-- commandsstop -->
503
+ ## 🤝 贡献
504
+
505
+ 欢迎贡献!请查看 [CONTRIBUTING.md](CONTRIBUTING.md) 了解详情。
506
+
507
+ ## 📄 许可证
508
+
509
+ MIT License - 详见 [LICENSE](LICENSE) 文件
510
+
511
+ ## 🔗 相关链接
512
+
513
+ - [NodeBBS 项目](https://github.com/nodebbs/nodebbs)
514
+ - [问题反馈](https://github.com/nodebbs/nodebbs/issues)
515
+ - [更新日志](CHANGELOG.md)
516
+
517
+ ## 💡 提示
518
+
519
+ - 使用 `npx nodebbs --help` 查看所有可用命令
520
+ - 使用 `npx nodebbs [command] --help` 查看特定命令的帮助
521
+ - 所有命令都支持 `--help` 参数
522
+ - 建议在生产环境使用前先在测试环境验证
523
+
524
+ ---
525
+
526
+ Made with ❤️ by NodeBBS Team