@antares-core/devtools
v2.5.3
Published
L4 工具链:CLI(lint:gatebind / bench / openapi)+ 测试工具集。devDependency,产物剥离
Readme
@antares-core/devtools
L4 开发工具链:altair CLI——契约埋点扫描、并发压测基线、OpenAPI 生成、SBOM、灾备演练、CRUD 脚手架、可视化面板等开发期命令。
仅用于开发 / CI 环境,作为 devDependency 安装,生产构建产物自动剥离。
安装
npm install -D @antares-core/devtools
# 或全局安装直接使用 altair 命令
npm install -g @antares-core/devtools命令总览
altair --help # 查看全部命令与选项契约埋点扫描(lint:gatebind)
扫描 Controller 中缺少 @GateBind() 契约注解的接口,防止漏埋点上线:
altair lint:gatebind --dir=src --strict
# --strict:存在遗漏时非零码退出,推荐接入 CI
# --dir:扫描目录,可重复指定,默认 src并发压测(bench)
# 单点压测:200 并发持续 60 秒
altair bench --url=http://localhost:3000/user/public --concurrency=200 --duration=60000
# 并发梯度矩阵:输出基线表并写入 bench-baseline.json
altair bench --url=http://localhost:3000/user/public --matrix --levels=1,10,50,100,200矩阵模式输出示例(单进程,完整中间件链):
压测基线表(单进程,文档 13.2)
┌────────┬────────┬─────────┬─────────┬────────┐
│ 并发数 │ QPS │ P50(ms) │ P99(ms) │ 失败率 │
├────────┼────────┼─────────┼─────────┼────────┤
│ 1 │ 2806 │ 0.3 │ 1.8 │ 0.00% │
│ 10 │ 7090 │ 1 │ 5.1 │ 0.00% │
│ 100 │ 7295 │ 12.9 │ 26.4 │ 0.00% │
│ 200 │ 6109 │ 27.8 │ 145.1 │ 0.00% │
└────────┴────────┴─────────┴─────────┴────────┘
容量换算:总 QPS = 单进程 QPS × 副本数 × 0.85其他命令
| 命令 | 说明 |
|---|---|
| openapi --dir=src --out=openapi.json | 扫描 Controller 生成 OpenAPI 文档 |
| sbom --dir=. --out=sbom.json | 生成 CycloneDX 软件物料清单(SBOM) |
| gen:crud --name=Product --columns=title:string,price:number | CRUD 模块脚手架 |
| gen:deploy --app=myapp --port=3000 --replicas=2 | 生成 Dockerfile / K8s 部署清单 |
| build --entry=dist/main.js | 单文件打包(含完整性校验) |
| bundle --entry=dist/main.js --out=bundle.js | bundle 构建 |
| migrate:build / migrate:show | 数据库迁移构建与查看 |
| backup --kind=pg --target=<conn> | 数据库 / 文件备份 |
| backup:rpo --rpo=1440 | RPO(恢复点目标)校验 |
| drill --kind=pg --backup=xx.dump --target=<conn> | 灾备恢复演练(RTO 计时) |
| api:report --pkg=packages/core | 包 API 面积报告 |
| gui --port=4200 | 可视化面板(Web 版) |
CI 接入示例
# GitHub Actions
- name: 契约埋点扫描
run: npx altair lint:gatebind --dir=src --strict
- name: 生成 SBOM
run: npx altair sbom --out=sbom.json相关包
@antares-core/core— L0+L1 内核@antares-core/modules— L2 业务模块@antares-core/license— L3 商业授权
License
MIT — 详见本包根目录的 LICENSE 文件。
