modify: chongming-cli

This commit is contained in:
2026-08-19 17:28:23 +08:00
parent 679f9e4259
commit 41ae36f34d
10 changed files with 60 additions and 1850 deletions
+9 -8
View File
@@ -50,7 +50,6 @@ chongming-zenoh/
│ │ ├── app/
│ │ │ ├── core/ # WorkerManager, RouteGenerator, MQTTBridge, contracts(契约校验), auth
│ │ │ └── routes/ # 内置路由(文件上传等)
│ │ └── scripts/ # build, gen_models, gen_plugin
│ ├── chongming-web/ # Vue 3 前端
│ │ └── src/
│ │ ├── api/generated/ # 自动生成 API 客户端
@@ -65,6 +64,7 @@ chongming-zenoh/
│ └── demo/ # 生产在独立容器部署,示例见本地目录)
├── utils/ # 独立工具包
│ ├── bytedance/ # 字节跳动安全通信 SDK
│ ├── cli/ # 命令脚本集合(build / gen_models / gen_plugin,chongming-cli)
│ ├── config/ # TOML 配置加载
│ ├── database/ # 异步 SQLite 封装
│ ├── jwt/ # Rust JWT 编解码
@@ -92,6 +92,7 @@ chongming-zenoh/
| ---------------- | ----------------------------------------------- | -------------------------- |
| `src/chongming/` | 本仓库(chongming-core) | 网关核心(FastAPI + Zenoh)|
| `utils/<name>/` | `chongming-utils-*`(9 个,见「工具包列表」) | 工具包,由 `uv sync` 按 git 源安装 |
| `utils/cli/` | `chongming-utils-cli`(规划中,暂以 path 源安装)| 命令脚本集合(build / build_plugin / gen_models / gen_plugin) |
| `src/plugins/` | `chongming-plugins` | Worker 插件源码 |
| `config/` | `chongming-config` | 应用与 Worker 路由配置 |
| `src/chongming-web/` | `chongming-web` | Vue 3 前端 |
@@ -396,7 +397,7 @@ python publisher.py example add '{"a":3,"b":5}' # 调用 add
2. 创建 config/workers/<name>/config.toml,在 [workers] 节注册插件
(type / module / factory / cleanup / count + [workers.config] 运行时配置)
3. 创建 config/workers/<name>/*.toml 端点定义
4. 运行 uv run python -m chongming.scripts.gen_models 生成模型
4. 运行 uv run gen_models 生成模型
5. 实现 router/<op>.py,引用 models/pydantic.py 中的模型
6. 更新 router/__init__.py 导入
```
@@ -409,7 +410,7 @@ python publisher.py example add '{"a":3,"b":5}' # 调用 add
```text
1. 创建 config/workers/<name>/<op>.toml
2. 运行 uv run python -m chongming.scripts.gen_models
2. 运行 uv run gen_models
3. 创建 router/<op>.py → 引用生成的模型
4. 更新 router/__init__.py
5. 重启服务
@@ -420,8 +421,8 @@ python publisher.py example add '{"a":3,"b":5}' # 调用 add
```bash
uv run serve # 启动开发服务
uv run gen_plugin <name> # 生成统一风格插件骨架
uv run python -m chongming.scripts.gen_models # 生成 Pydantic 模型
uv run python -m chongming.scripts.build # 构建打包(PyInstaller/Nuitka)
uv run gen_models # 生成 Pydantic 模型
uv run build # 构建打包(PyInstaller/Nuitka)
uv run worker_serve --type <name> # 独立 Worker 进程(本地调试,load_mode=external)
chongming-worker --type <name> # 独立 Worker 进程(容器入口)
uv pip install -e utils/<name> # 安装/更新工具包
@@ -485,10 +486,10 @@ uv pip install -e utils/<name> # 安装/更新工具包
```bash
# PyInstaller 打包
uv run python -m chongming.scripts.build pyinstaller
uv run build pyinstaller
# Nuitka 打包
uv run python -m chongming.scripts.build nuitka
uv run build nuitka
```
构建过程包括:模块加密打包 → 资源复制 → PyInstaller/Nuitka 打包 → 数据库初始化 → 前端编译 → VFS 挂载。
@@ -500,7 +501,7 @@ uv run python -m chongming.scripts.build nuitka
```bash
uv run serve # 启动开发服务器
uv run gen_plugin <name> # 生成统一风格插件骨架
uv run python -m chongming.scripts.gen_models # 生成 Pydantic 模型
uv run gen_models # 生成 Pydantic 模型
uv run build pyinstaller # PyInstaller 打包
uv run build nuitka # Nuitka 打包
uv run build_plugin <name> # 进程插件打包 → dist/<name>.zip