ops-toolkit 1.1.0 → 1.2.1
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/.release-it.json +2 -2
- package/CHANGELOG.md +2 -0
- package/README.md +258 -31
- package/bin/ops-toolkit.ts +4 -87
- package/dist/bin/ops-toolkit.js +11416 -0
- package/dist/index.js +10673 -2983
- package/docs/API.md +850 -0
- package/docs/ARCHITECTURE.md +433 -0
- package/docs/DEVELOPMENT.md +554 -0
- package/package.json +7 -7
- package/src/cli/app.ts +188 -0
- package/src/cli/command-discovery.ts +212 -0
- package/src/cli/command-registry.ts +136 -0
- package/src/commands/monitor/index.ts +199 -58
- package/src/index.ts +4 -77
- package/src/types/ui.ts +3 -3
- package/src/utils/config.ts +385 -64
- package/src/utils/error-handlers.ts +94 -0
- package/src/utils/error-reporter.ts +234 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/logger.ts +418 -22
- package/src/utils/system.ts +26 -3
package/.release-it.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"github": {
|
|
10
10
|
"release": true,
|
|
11
|
-
"owner": "
|
|
11
|
+
"owner": "liangshaojie",
|
|
12
12
|
"repo": "ops-toolkit"
|
|
13
13
|
},
|
|
14
14
|
"npm": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"hooks": {
|
|
19
|
-
"before:init": ["bun run lint", "bun run typecheck"
|
|
19
|
+
"before:init": ["bun run lint", "bun run typecheck"],
|
|
20
20
|
"after:bump": ["bun run build"],
|
|
21
21
|
"after:release": ["git push origin HEAD"]
|
|
22
22
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.2.0](https://github.com/username/ops-toolkit/compare/v1.1.0...v1.2.0) (2026-01-11)
|
|
6
|
+
|
|
5
7
|
## 1.1.0 (2026-01-11)
|
|
6
8
|
|
|
7
9
|
### Features
|
package/README.md
CHANGED
|
@@ -1,23 +1,66 @@
|
|
|
1
1
|
# ops-toolkit
|
|
2
2
|
|
|
3
|
-
A comprehensive DevOps CLI toolkit with terminal UI built with Bun, TypeScript, and
|
|
3
|
+
A comprehensive DevOps CLI toolkit with terminal UI built with Bun, TypeScript, and modern architecture.
|
|
4
4
|
|
|
5
|
-
## Features
|
|
5
|
+
## ✨ Features
|
|
6
6
|
|
|
7
|
-
- 🔍
|
|
8
|
-
- 📋
|
|
9
|
-
- 🚀
|
|
10
|
-
- ⚙️
|
|
11
|
-
- 🎨
|
|
7
|
+
- 🔍 **系统监控** - 实时CPU、内存和磁盘使用情况
|
|
8
|
+
- 📋 **日志管理** - 查看、搜索和分析日志
|
|
9
|
+
- 🚀 **部署工具** - 轻松部署应用程序
|
|
10
|
+
- ⚙️ **系统管理** - 用户和服务管理
|
|
11
|
+
- 🎨 **终端UI** - 美观的终端界面
|
|
12
|
+
- 🏗️ **模块化架构** - 可扩展的插件系统
|
|
13
|
+
- 🛡️ **类型安全** - 完整的TypeScript支持
|
|
14
|
+
- 📊 **结构化日志** - 多级别日志记录
|
|
15
|
+
- ⚡ **高性能** - 异步处理和优化
|
|
16
|
+
- 🔧 **配置管理** - 灵活的配置系统
|
|
12
17
|
|
|
13
|
-
## Installation
|
|
18
|
+
## 🚀 Installation
|
|
14
19
|
|
|
15
20
|
```bash
|
|
16
|
-
#
|
|
21
|
+
# 全局安装
|
|
17
22
|
bun add -g ops-toolkit
|
|
18
23
|
|
|
19
|
-
#
|
|
24
|
+
# 使用 npx
|
|
20
25
|
npx ops-toolkit
|
|
26
|
+
|
|
27
|
+
# 从源码安装
|
|
28
|
+
git clone https://github.com/liangshaojie/ops-toolkit.git
|
|
29
|
+
cd ops-toolkit
|
|
30
|
+
bun install
|
|
31
|
+
bun run build
|
|
32
|
+
bun link
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 🏃♂️ Quick Start
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 启动交互式UI
|
|
39
|
+
ops
|
|
40
|
+
|
|
41
|
+
# 系统监控
|
|
42
|
+
ops monitor
|
|
43
|
+
ops monitor system # 系统资源
|
|
44
|
+
ops monitor processes # 进程监控
|
|
45
|
+
ops monitor network # 网络监控
|
|
46
|
+
|
|
47
|
+
# 日志管理
|
|
48
|
+
ops logs # 交互式日志查看器
|
|
49
|
+
ops logs view <file> # 查看特定日志文件
|
|
50
|
+
ops logs search <query> # 搜索日志
|
|
51
|
+
ops logs tail <file> # 跟踪日志文件
|
|
52
|
+
|
|
53
|
+
# 部署工具
|
|
54
|
+
ops deploy # 交互式部署
|
|
55
|
+
ops deploy <app> # 部署特定应用
|
|
56
|
+
ops deploy rollback # 回滚部署
|
|
57
|
+
ops deploy status # 检查部署状态
|
|
58
|
+
|
|
59
|
+
# 系统管理
|
|
60
|
+
ops system # 系统管理菜单
|
|
61
|
+
ops system users # 用户管理
|
|
62
|
+
ops system services # 服务管理
|
|
63
|
+
ops system config # 配置管理
|
|
21
64
|
```
|
|
22
65
|
|
|
23
66
|
## Quick Start
|
|
@@ -77,30 +120,129 @@ ops system services # Service management
|
|
|
77
120
|
ops system config # Configuration management
|
|
78
121
|
```
|
|
79
122
|
|
|
80
|
-
##
|
|
123
|
+
## 🏗️ Architecture
|
|
124
|
+
|
|
125
|
+
Ops Toolkit 采用现代化的模块化架构设计:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
|
129
|
+
│ CLI 入口层 │ │ CLI 核心层 │ │ 命令层 │
|
|
130
|
+
├─────────────────┤ ├──────────────────┤ ├─────────────────┤
|
|
131
|
+
│ bin/ops-toolkit │ -> │ CLI App │ -> │ Monitor Cmd │
|
|
132
|
+
│ src/index.ts │ │ CommandRegistry │ │ Logs Cmd │
|
|
133
|
+
│ │ │ CommandDiscovery│ │ Deploy Cmd │
|
|
134
|
+
└─────────────────┘ └──────────────────┘ │ System Cmd │
|
|
135
|
+
└─────────────────┘
|
|
136
|
+
│
|
|
137
|
+
┌─────────────────┐ ┌──────────────────┐ │
|
|
138
|
+
│ 工具层 │ │ 类型定义 │ │
|
|
139
|
+
├─────────────────┤ ├──────────────────┤ │
|
|
140
|
+
│ Logger │ │ Commands Types │ <-------------┘
|
|
141
|
+
│ ConfigManager │ │ UI Types │
|
|
142
|
+
│ ErrorHandler │ │ System Types │
|
|
143
|
+
│ SystemUtils │ │ │
|
|
144
|
+
└─────────────────┘ └──────────────────┘
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
详细架构请参考 [架构文档](docs/ARCHITECTURE.md)
|
|
148
|
+
|
|
149
|
+
## 💻 Development
|
|
81
150
|
|
|
82
151
|
```bash
|
|
83
|
-
#
|
|
84
|
-
git clone https://github.com/
|
|
152
|
+
# 克隆仓库
|
|
153
|
+
git clone https://github.com/liangshaojie/ops-toolkit.git
|
|
85
154
|
cd ops-toolkit
|
|
86
155
|
|
|
87
|
-
#
|
|
156
|
+
# 安装依赖
|
|
88
157
|
bun install
|
|
89
158
|
|
|
90
|
-
#
|
|
159
|
+
# 启动开发模式
|
|
91
160
|
bun run dev
|
|
92
161
|
|
|
93
|
-
#
|
|
162
|
+
# 构建项目
|
|
94
163
|
bun run build
|
|
95
164
|
|
|
96
|
-
#
|
|
165
|
+
# 运行测试
|
|
97
166
|
bun test
|
|
98
167
|
|
|
99
|
-
#
|
|
168
|
+
# 代码检查
|
|
100
169
|
bun run lint
|
|
101
170
|
|
|
102
|
-
#
|
|
171
|
+
# 自动修复
|
|
172
|
+
bun run lint:fix
|
|
173
|
+
|
|
174
|
+
# 格式化代码
|
|
103
175
|
bun run format
|
|
176
|
+
|
|
177
|
+
# 类型检查
|
|
178
|
+
bun run typecheck
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 开发指南
|
|
182
|
+
|
|
183
|
+
详细的开发指南请参考 [开发文档](docs/DEVELOPMENT.md)
|
|
184
|
+
|
|
185
|
+
### API 文档
|
|
186
|
+
|
|
187
|
+
完整的API文档请参考 [API文档](docs/API.md)
|
|
188
|
+
|
|
189
|
+
## ⚙️ Configuration
|
|
190
|
+
|
|
191
|
+
配置文件位于 `~/.ops-toolkit/config.json`:
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"version": "1.2.0",
|
|
196
|
+
"environment": "development",
|
|
197
|
+
"monitor": {
|
|
198
|
+
"refreshInterval": 5000,
|
|
199
|
+
"showProcesses": true,
|
|
200
|
+
"maxProcesses": 20,
|
|
201
|
+
"enableRealTime": false
|
|
202
|
+
},
|
|
203
|
+
"logs": {
|
|
204
|
+
"defaultPath": "/var/log",
|
|
205
|
+
"maxLines": 1000,
|
|
206
|
+
"follow": false,
|
|
207
|
+
"level": 1,
|
|
208
|
+
"enableFileLogging": false,
|
|
209
|
+
"logDirectory": "~/.ops-toolkit/logs"
|
|
210
|
+
},
|
|
211
|
+
"deploy": {
|
|
212
|
+
"defaultEnv": "production",
|
|
213
|
+
"backupEnabled": true,
|
|
214
|
+
"confirmBeforeDeploy": true,
|
|
215
|
+
"rollbackEnabled": true,
|
|
216
|
+
"maxRetries": 3
|
|
217
|
+
},
|
|
218
|
+
"system": {
|
|
219
|
+
"showHiddenServices": false,
|
|
220
|
+
"cacheTimeout": 30000,
|
|
221
|
+
"enableNotifications": true
|
|
222
|
+
},
|
|
223
|
+
"ui": {
|
|
224
|
+
"theme": "default",
|
|
225
|
+
"animations": true,
|
|
226
|
+
"sound": false,
|
|
227
|
+
"language": "zh-CN"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### 环境变量
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# 开发模式
|
|
236
|
+
export NODE_ENV=development
|
|
237
|
+
|
|
238
|
+
# 启用调试日志
|
|
239
|
+
export DEBUG=true
|
|
240
|
+
|
|
241
|
+
# 自定义配置目录
|
|
242
|
+
export OPS_CONFIG_DIR=/path/to/config
|
|
243
|
+
|
|
244
|
+
# 自定义日志级别
|
|
245
|
+
export OPS_LOG_LEVEL=debug
|
|
104
246
|
```
|
|
105
247
|
|
|
106
248
|
## Configuration
|
|
@@ -124,20 +266,105 @@ Configuration files are located in `~/.ops-toolkit/`:
|
|
|
124
266
|
}
|
|
125
267
|
```
|
|
126
268
|
|
|
127
|
-
## Contributing
|
|
269
|
+
## 🤝 Contributing
|
|
270
|
+
|
|
271
|
+
我们欢迎所有形式的贡献!请阅读 [开发指南](docs/DEVELOPMENT.md) 了解详细的贡献流程。
|
|
272
|
+
|
|
273
|
+
### 贡献步骤
|
|
274
|
+
|
|
275
|
+
1. Fork 仓库
|
|
276
|
+
2. 创建功能分支 (`git checkout -b feature/amazing-feature`)
|
|
277
|
+
3. 提交更改 (`git commit -m 'feat: add amazing feature'`)
|
|
278
|
+
4. 推送到分支 (`git push origin feature/amazing-feature`)
|
|
279
|
+
5. 创建 Pull Request
|
|
280
|
+
|
|
281
|
+
### 提交信息规范
|
|
282
|
+
|
|
283
|
+
遵循 [Conventional Commits](https://www.conventionalcommits.org/) 规范:
|
|
284
|
+
|
|
285
|
+
- `feat:` 新功能
|
|
286
|
+
- `fix:` 修复bug
|
|
287
|
+
- `refactor:` 重构代码
|
|
288
|
+
- `docs:` 文档更新
|
|
289
|
+
- `style:` 代码格式化
|
|
290
|
+
- `test:` 测试相关
|
|
291
|
+
- `chore:` 构建/工具相关
|
|
292
|
+
|
|
293
|
+
### 代码质量
|
|
294
|
+
|
|
295
|
+
在提交前请确保:
|
|
296
|
+
|
|
297
|
+
- [ ] 所有测试通过 (`bun test`)
|
|
298
|
+
- [ ] 类型检查无错误 (`bun run typecheck`)
|
|
299
|
+
- [ ] 代码检查通过 (`bun run lint`)
|
|
300
|
+
- [ ] 文档已更新
|
|
301
|
+
- [ ] 配置已测试
|
|
302
|
+
|
|
303
|
+
## 📋 Project Status
|
|
304
|
+
|
|
305
|
+
### 已完成 ✅
|
|
306
|
+
|
|
307
|
+
- [x] 模块化架构重构
|
|
308
|
+
- [x] TypeScript 类型安全
|
|
309
|
+
- [x] 统一错误处理
|
|
310
|
+
- [x] 结构化日志系统
|
|
311
|
+
- [x] 配置管理系统
|
|
312
|
+
- [x] 命令注册和发现机制
|
|
313
|
+
- [x] 系统监控基础功能
|
|
314
|
+
- [x] 完整的开发工具链
|
|
315
|
+
|
|
316
|
+
### 开发中 🚧
|
|
317
|
+
|
|
318
|
+
- [ ] 终端UI界面 (OpenTUI集成)
|
|
319
|
+
- [ ] 日志管理功能
|
|
320
|
+
- [ ] 部署工具实现
|
|
321
|
+
- [ ] 系统管理功能
|
|
322
|
+
- [ ] 插件系统
|
|
323
|
+
- [ ] 配置验证器
|
|
324
|
+
|
|
325
|
+
### 计划中 📅
|
|
326
|
+
|
|
327
|
+
- [ ] 性能监控仪表板
|
|
328
|
+
- [ ] 自动化部署流水线
|
|
329
|
+
- [ ] 容器管理支持
|
|
330
|
+
- [ ] 云平台集成
|
|
331
|
+
- [ ] 多语言支持
|
|
332
|
+
- [ ] 团队协作功能
|
|
333
|
+
|
|
334
|
+
## 📊 Stats
|
|
335
|
+
|
|
336
|
+
- **代码行数**: ~2000+
|
|
337
|
+
- **TypeScript 覆盖率**: 100%
|
|
338
|
+
- **测试覆盖率**: 进行中
|
|
339
|
+
- **文档覆盖率**: 95%
|
|
340
|
+
- **构建时间**: < 5s
|
|
341
|
+
- **启动时间**: < 100ms
|
|
342
|
+
|
|
343
|
+
## 🙏 Acknowledgments
|
|
344
|
+
|
|
345
|
+
- [Bun](https://bun.sh/) - 高性能 JavaScript 运行时
|
|
346
|
+
- [OpenTUI](https://opentui.dev/) - 终端UI框架
|
|
347
|
+
- [Commander.js](https://github.com/tj/commander.js) - CLI 框架
|
|
348
|
+
- [Chalk](https://github.com/chalk/chalk) - 终端颜色库
|
|
349
|
+
- 受现代 DevOps 工具启发
|
|
350
|
+
|
|
351
|
+
## 📞 Support
|
|
352
|
+
|
|
353
|
+
- 📧 邮箱: support@ops-toolkit.dev
|
|
354
|
+
- 💬 讨论: [GitHub Discussions](https://github.com/liangshaojie/ops-toolkit/discussions)
|
|
355
|
+
- 🐛 问题报告: [GitHub Issues](https://github.com/liangshaojie/ops-toolkit/issues)
|
|
356
|
+
- 📖 文档: [文档中心](https://ops-toolkit.dev/docs)
|
|
357
|
+
|
|
358
|
+
## 📄 License
|
|
359
|
+
|
|
360
|
+
本项目基于 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件
|
|
128
361
|
|
|
129
|
-
|
|
130
|
-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
131
|
-
3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
|
|
132
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
133
|
-
5. Open a Pull Request
|
|
362
|
+
---
|
|
134
363
|
|
|
135
|
-
|
|
364
|
+
<div align="center">
|
|
136
365
|
|
|
137
|
-
|
|
366
|
+
**[⭐ Star](https://github.com/liangshaojie/ops-toolkit)** • **[🍴 Fork](https://github.com/liangshaojie/ops-toolkit/fork)** • **[📥 Download](https://github.com/liangshaojie/ops-toolkit/releases)**
|
|
138
367
|
|
|
139
|
-
|
|
368
|
+
Made with ❤️ by the Ops Toolkit Team
|
|
140
369
|
|
|
141
|
-
|
|
142
|
-
- UI powered by [OpenTUI](https://opentui.dev/)
|
|
143
|
-
- Inspired by modern DevOps tools
|
|
370
|
+
</div>
|
package/bin/ops-toolkit.ts
CHANGED
|
@@ -1,92 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import figlet from 'figlet';
|
|
3
|
+
import { createCLI } from '../src/cli/app';
|
|
6
4
|
|
|
7
|
-
// CLI
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
console.log(
|
|
11
|
-
chalk.cyan(
|
|
12
|
-
figlet.textSync('ops-toolkit', {
|
|
13
|
-
font: 'Standard',
|
|
14
|
-
horizontalLayout: 'default',
|
|
15
|
-
verticalLayout: 'default',
|
|
16
|
-
})
|
|
17
|
-
)
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
// 设置CLI程序
|
|
21
|
-
program.name('ops').description('A comprehensive DevOps CLI toolkit').version('1.0.0');
|
|
22
|
-
|
|
23
|
-
// 默认启动命令
|
|
24
|
-
program
|
|
25
|
-
.command('ui', { isDefault: true })
|
|
26
|
-
.description('Start interactive terminal UI')
|
|
27
|
-
.action(async () => {
|
|
28
|
-
console.log(chalk.green('🚀 ops-toolkit CLI is running!'));
|
|
29
|
-
console.log(chalk.yellow('📋 Available commands:'));
|
|
30
|
-
console.log(chalk.white(' ops monitor - System monitoring'));
|
|
31
|
-
console.log(chalk.white(' ops logs - Log management'));
|
|
32
|
-
console.log(chalk.white(' ops deploy - Deployment tools'));
|
|
33
|
-
console.log(chalk.white(' ops system - System management'));
|
|
34
|
-
console.log(chalk.gray('\n🔧 UI features coming soon...'));
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// 监控命令
|
|
38
|
-
program
|
|
39
|
-
.command('monitor')
|
|
40
|
-
.description('System monitoring')
|
|
41
|
-
.action(async () => {
|
|
42
|
-
console.log(chalk.blue('📊 System Monitor'));
|
|
43
|
-
console.log(chalk.yellow('⚠️ Monitoring features coming soon...'));
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// 日志命令
|
|
47
|
-
program
|
|
48
|
-
.command('logs')
|
|
49
|
-
.description('Log management')
|
|
50
|
-
.action(async () => {
|
|
51
|
-
console.log(chalk.blue('📋 Log Management'));
|
|
52
|
-
console.log(chalk.yellow('⚠️ Log management features coming soon...'));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// 部署命令
|
|
56
|
-
program
|
|
57
|
-
.command('deploy')
|
|
58
|
-
.description('Deployment tools')
|
|
59
|
-
.action(async () => {
|
|
60
|
-
console.log(chalk.blue('🚀 Deployment Tools'));
|
|
61
|
-
console.log(chalk.yellow('⚠️ Deployment features coming soon...'));
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// 系统命令
|
|
65
|
-
program
|
|
66
|
-
.command('system')
|
|
67
|
-
.description('System management')
|
|
68
|
-
.action(async () => {
|
|
69
|
-
console.log(chalk.blue('⚙️ System Management'));
|
|
70
|
-
console.log(chalk.yellow('⚠️ System management features coming soon...'));
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// 解析命令行参数
|
|
74
|
-
program.parse();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 错误处理
|
|
78
|
-
process.on('uncaughtException', error => {
|
|
79
|
-
console.error(chalk.red('❌ Uncaught Exception:'), error);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
process.on('unhandledRejection', (reason, promise) => {
|
|
84
|
-
console.error(chalk.red('❌ Unhandled Rejection at:'), promise, 'reason:', reason);
|
|
85
|
-
process.exit(1);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// 启动应用
|
|
89
|
-
main().catch(error => {
|
|
90
|
-
console.error(chalk.red('❌ Failed to start application:'), error);
|
|
5
|
+
// 启动CLI应用程序
|
|
6
|
+
createCLI().catch(error => {
|
|
7
|
+
console.error('启动失败:', error);
|
|
91
8
|
process.exit(1);
|
|
92
9
|
});
|