ops-toolkit 1.1.0
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/.commitlintrc.js +25 -0
- package/.env.example +25 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.opencode/README.md +320 -0
- package/.opencode/command/add-cmd.md +38 -0
- package/.opencode/command/add-pkg.md +28 -0
- package/.opencode/command/build.md +27 -0
- package/.opencode/command/debug.md +36 -0
- package/.opencode/command/fix.md +23 -0
- package/.opencode/command/release.md +28 -0
- package/.opencode/command/review.md +36 -0
- package/.opencode/command/test.md +25 -0
- package/.prettierrc +16 -0
- package/.release-it.json +29 -0
- package/.versionrc.js +18 -0
- package/.vscode/extensions.json +14 -0
- package/.vscode/launch.json +33 -0
- package/.vscode/typescript.code-snippets +61 -0
- package/AGENTS.md +277 -0
- package/CHANGELOG.md +24 -0
- package/QUICKSTART.md +136 -0
- package/README.md +143 -0
- package/bin/ops-toolkit.ts +92 -0
- package/bun.lock +1921 -0
- package/dist/index.js +3726 -0
- package/docs/DEBUGGING.md +255 -0
- package/docs/DEVELOPMENT_GUIDE.md +538 -0
- package/eslint.config.js +64 -0
- package/package.json +90 -0
- package/src/commands/deploy/index.ts +97 -0
- package/src/commands/monitor/index.ts +60 -0
- package/src/commands/system/index.ts +120 -0
- package/src/index.ts +82 -0
- package/src/types/commands.ts +41 -0
- package/src/types/index.ts +3 -0
- package/src/types/system.ts +65 -0
- package/src/types/ui.ts +61 -0
- package/src/utils/config.ts +146 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/logger.ts +62 -0
- package/src/utils/system.ts +183 -0
- package/tsconfig.json +48 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
# ops-toolkit 开发技巧指南
|
|
2
|
+
|
|
3
|
+
本指南提供开发 ops-toolkit 项目时的高效技巧和最佳实践。
|
|
4
|
+
|
|
5
|
+
## 🤖 使用 OpenCode AI 助手
|
|
6
|
+
|
|
7
|
+
### 项目感知能力
|
|
8
|
+
|
|
9
|
+
OpenCode AI 助手已经通过 `AGENTS.md` 配置,了解项目的:
|
|
10
|
+
|
|
11
|
+
- **技术栈**: Bun + TypeScript + Commander + Chalk + OpenTUI
|
|
12
|
+
- **项目结构**: 命令模式,`src/index.ts` 为入口点
|
|
13
|
+
- **代码规范**: ESLint + Prettier,遵循 conventional commits
|
|
14
|
+
- **开发流程**: watch 模式开发,tsx 调试
|
|
15
|
+
|
|
16
|
+
### 常见任务示例
|
|
17
|
+
|
|
18
|
+
#### 添加新 CLI 命令
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
帮我添加一个名为 backup 的命令,用于备份数据
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
OpenCode 会自动:
|
|
25
|
+
|
|
26
|
+
1. 在 `src/commands/` 创建命令文件
|
|
27
|
+
2. 在 `src/index.ts` 注册命令
|
|
28
|
+
3. 添加类型定义(如果需要)
|
|
29
|
+
|
|
30
|
+
#### 修复 Bug
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
帮我修复 monitor 命令中的错误
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
OpenCode 会:
|
|
37
|
+
|
|
38
|
+
1. 搜索相关代码
|
|
39
|
+
2. 分析问题原因
|
|
40
|
+
3. 提供修复方案
|
|
41
|
+
4. 运行类型检查和 lint
|
|
42
|
+
|
|
43
|
+
#### 重构代码
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
重构 src/utils/logger.ts,提高性能
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
OpenCode 会:
|
|
50
|
+
|
|
51
|
+
1. 分析现有代码结构
|
|
52
|
+
2. 识别性能瓶颈
|
|
53
|
+
3. 提供优化建议
|
|
54
|
+
4. 保持功能不变
|
|
55
|
+
|
|
56
|
+
### 高效提问技巧
|
|
57
|
+
|
|
58
|
+
#### ✅ 好的提问
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
帮我在 monitor 命令中添加 CPU 使用率显示功能,
|
|
62
|
+
要求:
|
|
63
|
+
1. 实时刷新(每秒)
|
|
64
|
+
2. 使用 chalk 显示不同颜色(<50% 绿色,50-80% 黄色,>80% 红色)
|
|
65
|
+
3. 显示百分比和具体数值
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### ❌ 不好的提问
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
帮我优化代码
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 🎯 VS Code 开发技巧
|
|
75
|
+
|
|
76
|
+
### 快捷键组合
|
|
77
|
+
|
|
78
|
+
| 快捷键 | 功能 | 使用场景 |
|
|
79
|
+
| --------------------------------- | -------------- | ------------------- |
|
|
80
|
+
| `F5` | 启动调试 | 调试代码 |
|
|
81
|
+
| `Cmd+Shift+B` | 运行任务 | 执行 dev/build/test |
|
|
82
|
+
| `Cmd+Shift+F` | 格式化文档 | 保存后自动格式化 |
|
|
83
|
+
| `Cmd+Shift+P` → "ESLint: Fix all" | 修复 lint 问题 | 提交前检查 |
|
|
84
|
+
| `Cmd+P` | 快速打开文件 | 导航到特定文件 |
|
|
85
|
+
| `Cmd+Shift+O` | 符号导航 | 跳转到函数/类 |
|
|
86
|
+
| `Cmd+Click` | 跳转到定义 | 查看代码实现 |
|
|
87
|
+
| `Opt+Click` | Peek 定义 | 在侧边预览定义 |
|
|
88
|
+
| `F12` | 转到定义 | 查看代码定义 |
|
|
89
|
+
| `Shift+F12` | 查找所有引用 | 了解代码使用情况 |
|
|
90
|
+
|
|
91
|
+
### 工作区任务
|
|
92
|
+
|
|
93
|
+
通过 `Cmd+Shift+B` 或任务面板可以快速访问:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# 开发模式(推荐日常使用)
|
|
97
|
+
Dev: Watch (默认)
|
|
98
|
+
|
|
99
|
+
# 构建和测试
|
|
100
|
+
Build
|
|
101
|
+
Test
|
|
102
|
+
Lint / Lint: Fix
|
|
103
|
+
Typecheck
|
|
104
|
+
Format
|
|
105
|
+
|
|
106
|
+
# 快速运行
|
|
107
|
+
Start (运行一次)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 分屏开发
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# 垂直分屏
|
|
114
|
+
Cmd+K 然后 Cmd+V
|
|
115
|
+
|
|
116
|
+
# 水平分屏
|
|
117
|
+
Cmd+K 然后 Cmd+H
|
|
118
|
+
|
|
119
|
+
# 在新窗口打开
|
|
120
|
+
Cmd+K 然后 Cmd+O
|
|
121
|
+
|
|
122
|
+
# 在编辑器组间移动
|
|
123
|
+
Cmd+Opt+左右箭头
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 多光标编辑
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# 添加光标
|
|
130
|
+
Opt+Click
|
|
131
|
+
|
|
132
|
+
# 选择所有相同单词
|
|
133
|
+
Cmd+D
|
|
134
|
+
|
|
135
|
+
# 选择所有匹配项
|
|
136
|
+
Cmd+Shift+L
|
|
137
|
+
|
|
138
|
+
# 在行尾添加光标
|
|
139
|
+
Cmd+Opt+I
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## 🧩 代码片段使用
|
|
143
|
+
|
|
144
|
+
项目配置了常用代码片段,输入前缀后按 `Tab` 即可展开。
|
|
145
|
+
|
|
146
|
+
### CLI 命令片段
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// 输入: cli-cmd + Tab
|
|
150
|
+
// 生成:
|
|
151
|
+
program
|
|
152
|
+
.command('commandName')
|
|
153
|
+
.description('Description')
|
|
154
|
+
.action(async options => {
|
|
155
|
+
// 光标在这里
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 异步函数片段
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// 输入: async-fn + Tab
|
|
163
|
+
// 生成:
|
|
164
|
+
async function functionName(args): Promise<returnType> {
|
|
165
|
+
// 光标在这里
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### 错误处理片段
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
// 输入: try-catch + Tab
|
|
173
|
+
// 生成:
|
|
174
|
+
try {
|
|
175
|
+
// 光标在这里
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error(chalk.red('❌ Error:'), error);
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 彩色日志片段
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// 输入: log + Tab
|
|
186
|
+
// 生成:
|
|
187
|
+
console.log(chalk.red('message'));
|
|
188
|
+
// 使用 Tab 切换颜色: red, green, yellow, blue, magenta, cyan, gray, white
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 测试片段
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
// 输入: test-desc + Tab
|
|
195
|
+
// 生成:
|
|
196
|
+
describe('test suite', () => {
|
|
197
|
+
it('test case', () => {
|
|
198
|
+
// 光标在这里
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## 🐛 调试技巧
|
|
204
|
+
|
|
205
|
+
### 设置断点
|
|
206
|
+
|
|
207
|
+
#### 方法 1: 行号断点(推荐)
|
|
208
|
+
|
|
209
|
+
在行号左侧点击设置断点
|
|
210
|
+
|
|
211
|
+
#### 方法 2: 条件断点
|
|
212
|
+
|
|
213
|
+
右键行号 → "Add Conditional Breakpoint" → 输入条件
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
// 只在特定条件下断点
|
|
217
|
+
process.env.DEBUG === 'true';
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### 方法 3: 日志断点
|
|
221
|
+
|
|
222
|
+
右键行号 → "Add Logpoint" → 输入表达式
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
// 不中断,只记录日志
|
|
226
|
+
{
|
|
227
|
+
variableName;
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 调试变量检查
|
|
232
|
+
|
|
233
|
+
#### 调试面板功能
|
|
234
|
+
|
|
235
|
+
- **Variables**: 查看作用域内所有变量
|
|
236
|
+
- **Watch**: 监视特定表达式
|
|
237
|
+
- **Call Stack**: 查看调用堆栈
|
|
238
|
+
- **Breakpoints**: 管理所有断点
|
|
239
|
+
|
|
240
|
+
#### 控制台调试
|
|
241
|
+
|
|
242
|
+
在调试控制台中可以:
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
// 查看变量值
|
|
246
|
+
variableName;
|
|
247
|
+
|
|
248
|
+
// 修改变量值
|
|
249
|
+
variableName = newValue;
|
|
250
|
+
|
|
251
|
+
// 执行表达式
|
|
252
|
+
someFunction();
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### 常见调试场景
|
|
256
|
+
|
|
257
|
+
#### 调试 CLI 参数解析
|
|
258
|
+
|
|
259
|
+
在 `src/index.ts` 中找到:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
const options = program.opts();
|
|
263
|
+
// 在这里设置断点查看解析的参数
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### 调试异步操作
|
|
267
|
+
|
|
268
|
+
在 `await` 前后都设置断点:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
const result = await someAsyncCall();
|
|
272
|
+
// 设置断点查看 result
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### 调试错误处理
|
|
276
|
+
|
|
277
|
+
在 catch 块设置断点:
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
try {
|
|
281
|
+
// 可能出错的代码
|
|
282
|
+
} catch (error) {
|
|
283
|
+
debugger; // 或在这里设置断点
|
|
284
|
+
// 查看 error 对象
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## 🚀 高效开发工作流
|
|
289
|
+
|
|
290
|
+
### 日常开发流程
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# 1. 启动开发服务器(watch 模式)
|
|
294
|
+
bun run dev
|
|
295
|
+
|
|
296
|
+
# 2. 在 VS Code 中开发
|
|
297
|
+
# - 使用代码片段快速编码
|
|
298
|
+
# - 保存时自动格式化和 lint
|
|
299
|
+
# - F5 调试问题
|
|
300
|
+
|
|
301
|
+
# 3. 完成功能后
|
|
302
|
+
# 运行类型检查
|
|
303
|
+
bun run typecheck
|
|
304
|
+
|
|
305
|
+
# 运行测试
|
|
306
|
+
bun test
|
|
307
|
+
|
|
308
|
+
# 提交代码
|
|
309
|
+
git add .
|
|
310
|
+
git commit -m "feat: 添加新功能"
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 添加新功能流程
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# 1. 使用 OpenCode 询问
|
|
317
|
+
"帮我添加一个 backup 命令,包含备份和恢复子命令"
|
|
318
|
+
|
|
319
|
+
# 2. 测试功能
|
|
320
|
+
bun run dev
|
|
321
|
+
# 在另一个终端测试命令
|
|
322
|
+
|
|
323
|
+
# 3. 运行质量检查
|
|
324
|
+
bun run typecheck
|
|
325
|
+
bun run lint:fix
|
|
326
|
+
bun test
|
|
327
|
+
|
|
328
|
+
# 4. 提交代码
|
|
329
|
+
git add .
|
|
330
|
+
git commit -m "feat: add backup command"
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Bug 修复流程
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# 1. 复现 Bug
|
|
337
|
+
bun run dev
|
|
338
|
+
# 运行出问题的命令
|
|
339
|
+
|
|
340
|
+
# 2. 使用 F5 调试
|
|
341
|
+
# 设置断点,检查变量
|
|
342
|
+
|
|
343
|
+
# 3. 修复代码
|
|
344
|
+
# 或让 OpenCode 帮助修复
|
|
345
|
+
"帮我修复 monitor 命令中的错误"
|
|
346
|
+
|
|
347
|
+
# 4. 验证修复
|
|
348
|
+
bun run dev
|
|
349
|
+
# 重新测试
|
|
350
|
+
|
|
351
|
+
# 5. 提交修复
|
|
352
|
+
git add .
|
|
353
|
+
git commit -m "fix: 修复 monitor 命令的错误"
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## 📋 Git 工作流
|
|
357
|
+
|
|
358
|
+
### 提交信息格式
|
|
359
|
+
|
|
360
|
+
项目使用 conventional commits,必须遵循:
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
feat: 新功能
|
|
364
|
+
fix: Bug 修复
|
|
365
|
+
refactor: 代码重构
|
|
366
|
+
docs: 文档更新
|
|
367
|
+
style: 代码格式调整
|
|
368
|
+
test: 测试相关
|
|
369
|
+
chore: 构建/工具配置
|
|
370
|
+
perf: 性能优化
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### 提交前检查
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# 运行所有检查
|
|
377
|
+
bun run typecheck
|
|
378
|
+
bun run lint:fix
|
|
379
|
+
bun test
|
|
380
|
+
|
|
381
|
+
# 提交(husky 会自动运行 lint-staged)
|
|
382
|
+
git add .
|
|
383
|
+
git commit -m "feat: 添加功能"
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### 分支管理
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
# 创建功能分支
|
|
390
|
+
git checkout -b feature/your-feature
|
|
391
|
+
|
|
392
|
+
# 开发完成后
|
|
393
|
+
git checkout master
|
|
394
|
+
git merge feature/your-feature
|
|
395
|
+
git branch -d feature/your-feature
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
## 🎨 代码风格快速修复
|
|
399
|
+
|
|
400
|
+
### 批量格式化
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
# 格式化所有文件
|
|
404
|
+
bun run format
|
|
405
|
+
|
|
406
|
+
# 或使用 VS Code
|
|
407
|
+
Cmd+Shift+P → "Format Document"
|
|
408
|
+
# 或
|
|
409
|
+
Cmd+Shift+P → "Format All Documents"
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### 批量 lint 修复
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# 自动修复所有可修复的 lint 问题
|
|
416
|
+
bun run lint:fix
|
|
417
|
+
|
|
418
|
+
# 或使用 VS Code
|
|
419
|
+
Cmd+Shift+P → "ESLint: Fix all auto-fixable Problems"
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### 保存时自动操作
|
|
423
|
+
|
|
424
|
+
VS Code 已配置保存时:
|
|
425
|
+
|
|
426
|
+
- 自动格式化文档
|
|
427
|
+
- 自动修复 ESLint 问题
|
|
428
|
+
- 自动组织导入
|
|
429
|
+
|
|
430
|
+
## 🔍 搜索和导航
|
|
431
|
+
|
|
432
|
+
### 文件内搜索
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
Cmd+F # 查找
|
|
436
|
+
Cmd+G # 查找下一个
|
|
437
|
+
Cmd+Shift+G # 查找上一个
|
|
438
|
+
Cmd+Opt+F # 查找和替换
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### 项目范围搜索
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
Cmd+Shift+F # 在文件中搜索
|
|
445
|
+
Cmd+Shift+H # 在文件中替换
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### 符号导航
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
Cmd+Shift+O # 跳转到文件中的符号
|
|
452
|
+
Cmd+T # 跳转到任何文件
|
|
453
|
+
Cmd+P # 快速打开文件
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### Git 导航
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
Cmd+Shift+G # 打开 Git 视图
|
|
460
|
+
Cmd+Click # 查看上一提交
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
## 💡 高级技巧
|
|
464
|
+
|
|
465
|
+
### 自定义代码片段
|
|
466
|
+
|
|
467
|
+
在 `.vscode/typescript.code-snippets` 中添加:
|
|
468
|
+
|
|
469
|
+
```json
|
|
470
|
+
{
|
|
471
|
+
"Custom Snippet": {
|
|
472
|
+
"prefix": "custom-prefix",
|
|
473
|
+
"body": ["your code here", "$0"],
|
|
474
|
+
"description": "Description"
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### 多项目工作区
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
# 创建工作区文件
|
|
483
|
+
File → Save Workspace As...
|
|
484
|
+
|
|
485
|
+
# 在工作区中打开多个项目
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### 远程开发
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
# 使用 VS Code Remote
|
|
492
|
+
Cmd+Shift+P → "Remote-SSH: Connect to Host"
|
|
493
|
+
|
|
494
|
+
# 或使用 GitHub Codespaces
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### 集成终端快捷键
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
Cmd+` # 切换终端
|
|
501
|
+
Cmd+Shift+` # 新建终端
|
|
502
|
+
Cmd+K # 清空终端
|
|
503
|
+
Ctrl+C # 中断当前命令
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
## 📚 资源链接
|
|
507
|
+
|
|
508
|
+
- [OpenCode 文档](https://opencode.ai/docs)
|
|
509
|
+
- [Bun 文档](https://bun.sh/docs)
|
|
510
|
+
- [Commander.js](https://github.com/tj/commander.js)
|
|
511
|
+
- [Chalk](https://github.com/chalk/chalk)
|
|
512
|
+
- [VS Code 快捷键](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf)
|
|
513
|
+
|
|
514
|
+
## 🆘 获取帮助
|
|
515
|
+
|
|
516
|
+
### 在 OpenCode 中
|
|
517
|
+
|
|
518
|
+
```
|
|
519
|
+
/show-config # 显示项目配置
|
|
520
|
+
/help # 显示帮助信息
|
|
521
|
+
/status # 显示当前状态
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### 在项目中
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
# 查看可用命令
|
|
528
|
+
bun run dev --help
|
|
529
|
+
|
|
530
|
+
# 查看文档
|
|
531
|
+
cat README.md
|
|
532
|
+
cat AGENTS.md
|
|
533
|
+
cat docs/DEVELOPMENT_GUIDE.md
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
**提示**: 熟练掌握这些技巧可以显著提高开发效率!建议保存本文档作为参考。
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const js = require('@eslint/js');
|
|
2
|
+
const typescript = require('@typescript-eslint/eslint-plugin');
|
|
3
|
+
const typescriptParser = require('@typescript-eslint/parser');
|
|
4
|
+
const prettier = require('eslint-config-prettier');
|
|
5
|
+
const prettierPlugin = require('eslint-plugin-prettier');
|
|
6
|
+
|
|
7
|
+
module.exports = [
|
|
8
|
+
js.configs.recommended,
|
|
9
|
+
{
|
|
10
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
11
|
+
languageOptions: {
|
|
12
|
+
parser: typescriptParser,
|
|
13
|
+
parserOptions: {
|
|
14
|
+
ecmaVersion: 'latest',
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
project: './tsconfig.json',
|
|
17
|
+
},
|
|
18
|
+
globals: {
|
|
19
|
+
console: 'readonly',
|
|
20
|
+
process: 'readonly',
|
|
21
|
+
Buffer: 'readonly',
|
|
22
|
+
__dirname: 'readonly',
|
|
23
|
+
__filename: 'readonly',
|
|
24
|
+
module: 'readonly',
|
|
25
|
+
require: 'readonly',
|
|
26
|
+
exports: 'readonly',
|
|
27
|
+
global: 'readonly',
|
|
28
|
+
setTimeout: 'readonly',
|
|
29
|
+
clearTimeout: 'readonly',
|
|
30
|
+
setInterval: 'readonly',
|
|
31
|
+
clearInterval: 'readonly',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
plugins: {
|
|
35
|
+
'@typescript-eslint': typescript,
|
|
36
|
+
prettier: prettierPlugin,
|
|
37
|
+
},
|
|
38
|
+
rules: {
|
|
39
|
+
...typescript.configs.recommended.rules,
|
|
40
|
+
'prettier/prettier': 'error',
|
|
41
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
42
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
43
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
44
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
45
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
46
|
+
'prefer-const': 'error',
|
|
47
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
48
|
+
'no-console': 'off',
|
|
49
|
+
'prefer-const': 'error',
|
|
50
|
+
'no-var': 'error',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
prettier,
|
|
54
|
+
{
|
|
55
|
+
ignores: [
|
|
56
|
+
'dist/**',
|
|
57
|
+
'build/**',
|
|
58
|
+
'node_modules/**',
|
|
59
|
+
'coverage/**',
|
|
60
|
+
'*.config.js',
|
|
61
|
+
'*.config.ts',
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ops-toolkit",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "A comprehensive DevOps CLI toolkit with terminal UI",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ops": "./bin/ops-toolkit.ts",
|
|
8
|
+
"ops-toolkit": "./bin/ops-toolkit.ts"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "bun --watch src/index.ts",
|
|
12
|
+
"build": "bun build src/index.ts --outdir dist --target node",
|
|
13
|
+
"start": "bun src/index.ts",
|
|
14
|
+
"lint": "eslint src bin",
|
|
15
|
+
"lint:fix": "eslint src bin --fix",
|
|
16
|
+
"format": "prettier --write src/**/*.{ts,tsx}",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"test": "bun test",
|
|
19
|
+
"prepare": "husky install",
|
|
20
|
+
"release": "standard-version",
|
|
21
|
+
"release:minor": "standard-version --release-as minor",
|
|
22
|
+
"release:major": "standard-version --release-as major",
|
|
23
|
+
"publish": "release-it"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"cli",
|
|
27
|
+
"devops",
|
|
28
|
+
"ops",
|
|
29
|
+
"toolkit",
|
|
30
|
+
"terminal",
|
|
31
|
+
"tui",
|
|
32
|
+
"monitoring",
|
|
33
|
+
"logs",
|
|
34
|
+
"deployment"
|
|
35
|
+
],
|
|
36
|
+
"author": "ops-toolkit",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/username/ops-toolkit.git"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/username/ops-toolkit/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/username/ops-toolkit#readme",
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18.0.0",
|
|
48
|
+
"bun": ">=1.0.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@opentui/core": "^0.1.0",
|
|
52
|
+
"@opentui/react": "^0.1.0",
|
|
53
|
+
"commander": "^11.0.0",
|
|
54
|
+
"chalk": "^5.3.0",
|
|
55
|
+
"inquirer": "^9.2.0",
|
|
56
|
+
"ora": "^7.0.0",
|
|
57
|
+
"figlet": "^1.6.0",
|
|
58
|
+
"cli-table3": "^0.6.3",
|
|
59
|
+
"boxen": "^7.1.1"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/cli": "^17.8.1",
|
|
63
|
+
"@commitlint/config-conventional": "^17.8.1",
|
|
64
|
+
"@release-it/conventional-changelog": "^5.1.1",
|
|
65
|
+
"@types/figlet": "^1.5.8",
|
|
66
|
+
"@types/inquirer": "^9.0.7",
|
|
67
|
+
"@types/node": "^20.0.0",
|
|
68
|
+
"@types/react": "^19.2.8",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
70
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
71
|
+
"eslint": "^8.57.0",
|
|
72
|
+
"eslint-config-prettier": "^9.1.0",
|
|
73
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
74
|
+
"husky": "^8.0.3",
|
|
75
|
+
"lint-staged": "^15.2.0",
|
|
76
|
+
"prettier": "^3.2.5",
|
|
77
|
+
"release-it": "^16.3.0",
|
|
78
|
+
"standard-version": "^9.5.0",
|
|
79
|
+
"tsx": "^4.21.0",
|
|
80
|
+
"typescript": "^5.3.3"
|
|
81
|
+
},
|
|
82
|
+
"lint-staged": {
|
|
83
|
+
"*.{ts}": [
|
|
84
|
+
"bun run lint:fix"
|
|
85
|
+
],
|
|
86
|
+
"*.{json,md,yml,yaml}": [
|
|
87
|
+
"prettier --write"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|