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,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"recommendations": [
|
|
3
|
+
"oven.bun-vscode",
|
|
4
|
+
"ms-vscode.vscode-typescript-next",
|
|
5
|
+
"ms-vscode.vscode-eslint",
|
|
6
|
+
"esbenp.prettier-vscode",
|
|
7
|
+
"streetsidesoftware.code-spell-checker",
|
|
8
|
+
"eamodio.gitlens",
|
|
9
|
+
"christian-kohler.path-intellisense",
|
|
10
|
+
"usernamehw.errorlens",
|
|
11
|
+
"wayou.vscode-todo-highlight",
|
|
12
|
+
"gruntfuggly.todo-tree"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"name": "调试 CLI (tsx)",
|
|
6
|
+
"type": "node",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"program": "${workspaceFolder}/node_modules/.bin/tsx",
|
|
9
|
+
"args": ["${workspaceFolder}/src/index.ts"],
|
|
10
|
+
"console": "integratedTerminal",
|
|
11
|
+
"internalConsoleOptions": "neverOpen",
|
|
12
|
+
"skipFiles": ["<node_internals>/**"]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "调试指定命令 (tsx)",
|
|
16
|
+
"type": "node",
|
|
17
|
+
"request": "launch",
|
|
18
|
+
"program": "${workspaceFolder}/node_modules/.bin/tsx",
|
|
19
|
+
"args": ["${workspaceFolder}/src/index.ts", "${input:command}"],
|
|
20
|
+
"console": "integratedTerminal",
|
|
21
|
+
"internalConsoleOptions": "neverOpen",
|
|
22
|
+
"skipFiles": ["<node_internals>/**"]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"inputs": [
|
|
26
|
+
{
|
|
27
|
+
"id": "command",
|
|
28
|
+
"type": "promptString",
|
|
29
|
+
"description": "输入 CLI 命令 (如 monitor, logs, deploy, system)",
|
|
30
|
+
"default": "ui"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"TypeScript CLI Command": {
|
|
3
|
+
"prefix": "cli-cmd",
|
|
4
|
+
"body": [
|
|
5
|
+
"program",
|
|
6
|
+
" .command('${1:commandName}')",
|
|
7
|
+
" .description('${2:Description}')",
|
|
8
|
+
" .action(async (${3:options}) => {",
|
|
9
|
+
" $0",
|
|
10
|
+
" });"
|
|
11
|
+
],
|
|
12
|
+
"description": "Create a new CLI command"
|
|
13
|
+
},
|
|
14
|
+
"TypeScript Async Function": {
|
|
15
|
+
"prefix": "async-fn",
|
|
16
|
+
"body": [
|
|
17
|
+
"async function ${1:functionName}(${2:args}): Promise<${3:returnType}> {",
|
|
18
|
+
" $0",
|
|
19
|
+
"}"
|
|
20
|
+
],
|
|
21
|
+
"description": "Create an async function"
|
|
22
|
+
},
|
|
23
|
+
"Try-Catch Error Handler": {
|
|
24
|
+
"prefix": "try-catch",
|
|
25
|
+
"body": [
|
|
26
|
+
"try {",
|
|
27
|
+
" $0",
|
|
28
|
+
"} catch (error) {",
|
|
29
|
+
" console.error(chalk.red('❌ Error:'), error);",
|
|
30
|
+
" process.exit(1);",
|
|
31
|
+
"}"
|
|
32
|
+
],
|
|
33
|
+
"description": "Try-catch with error handling"
|
|
34
|
+
},
|
|
35
|
+
"Chalk Colored Log": {
|
|
36
|
+
"prefix": "log",
|
|
37
|
+
"body": ["console.log(chalk.${1|red,green,yellow,blue,magenta,cyan,gray,white}('$2'));"],
|
|
38
|
+
"description": "Colored console log with chalk"
|
|
39
|
+
},
|
|
40
|
+
"Commander Option": {
|
|
41
|
+
"prefix": "cmd-opt",
|
|
42
|
+
"body": ["program.option('${1:-f, --flag}', '${2:description}', ${3|true,false|});"],
|
|
43
|
+
"description": "Add a Commander CLI option"
|
|
44
|
+
},
|
|
45
|
+
"Bun Test": {
|
|
46
|
+
"prefix": "test-desc",
|
|
47
|
+
"body": [
|
|
48
|
+
"describe('${1:test suite}', () => {",
|
|
49
|
+
" it('${2:test case}', () => {",
|
|
50
|
+
" $0",
|
|
51
|
+
" });",
|
|
52
|
+
"});"
|
|
53
|
+
],
|
|
54
|
+
"description": "Bun test describe block"
|
|
55
|
+
},
|
|
56
|
+
"Import Statement": {
|
|
57
|
+
"prefix": "imp",
|
|
58
|
+
"body": ["import { $1 } from '$2';"],
|
|
59
|
+
"description": "Import statement"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# OpenCode Configuration for ops-toolkit
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
**Type**: Bun + TypeScript CLI toolkit
|
|
6
|
+
**Purpose**: DevOps CLI tool with terminal UI
|
|
7
|
+
**Tech Stack**: Bun, TypeScript, Commander, Chalk, OpenTUI
|
|
8
|
+
**Entry Point**: `src/index.ts`
|
|
9
|
+
**Debug Entry**: Use `bun --watch src/index.ts` for development, `tsx` for debugging
|
|
10
|
+
|
|
11
|
+
## Essential Commands
|
|
12
|
+
|
|
13
|
+
### Development
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun run dev # Run in watch mode (use this for active development)
|
|
17
|
+
bun run start # Run once
|
|
18
|
+
bun run build # Build for production
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Code Quality
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun run lint # Run ESLint
|
|
25
|
+
bun run lint:fix # Auto-fix linting issues
|
|
26
|
+
bun run format # Format code with Prettier
|
|
27
|
+
bun run typecheck # TypeScript type checking
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Testing
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
bun test # Run all tests
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Git & Release
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bun run release # Create release with changelog
|
|
40
|
+
bun run release:minor # Minor version bump
|
|
41
|
+
bun run release:major # Major version bump
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Code Style & Conventions
|
|
45
|
+
|
|
46
|
+
### Commit Message Format
|
|
47
|
+
|
|
48
|
+
Must follow conventional commits:
|
|
49
|
+
|
|
50
|
+
- `feat:` - New feature
|
|
51
|
+
- `fix:` - Bug fix
|
|
52
|
+
- `refactor:` - Code refactoring
|
|
53
|
+
- `docs:` - Documentation changes
|
|
54
|
+
- `style:` - Code style changes (formatting)
|
|
55
|
+
- `test:` - Adding or updating tests
|
|
56
|
+
- `chore:` - Maintenance tasks
|
|
57
|
+
- `perf:` - Performance improvements
|
|
58
|
+
|
|
59
|
+
**Note**: Commit messages are automatically linted. Body lines must be ≤72 characters.
|
|
60
|
+
|
|
61
|
+
### Code Style
|
|
62
|
+
|
|
63
|
+
- Use TypeScript strict mode
|
|
64
|
+
- Follow ESLint rules (auto-fix available)
|
|
65
|
+
- Use Prettier for formatting
|
|
66
|
+
- No console.log in production code (use Logger utils when available)
|
|
67
|
+
- Error handling with try-catch in async functions
|
|
68
|
+
- Use chalk for colored terminal output
|
|
69
|
+
|
|
70
|
+
### File Structure
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
src/
|
|
74
|
+
├── index.ts # Main CLI entry point
|
|
75
|
+
├── commands/ # CLI command implementations
|
|
76
|
+
├── components/ # UI components
|
|
77
|
+
├── utils/ # Utility functions
|
|
78
|
+
└── types/ # TypeScript type definitions
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Development Workflow
|
|
82
|
+
|
|
83
|
+
### When Adding New Features
|
|
84
|
+
|
|
85
|
+
1. Create command handler in `src/commands/`
|
|
86
|
+
2. Add CLI command in `src/index.ts`
|
|
87
|
+
3. Write tests (if applicable)
|
|
88
|
+
4. Run `bun run typecheck` and `bun run lint`
|
|
89
|
+
5. Test manually with `bun run dev`
|
|
90
|
+
|
|
91
|
+
### When Fixing Bugs
|
|
92
|
+
|
|
93
|
+
1. Identify the issue location
|
|
94
|
+
2. Create a fix
|
|
95
|
+
3. Run `bun run typecheck` and `bun run lint:fix`
|
|
96
|
+
4. Test the fix manually
|
|
97
|
+
|
|
98
|
+
### Debugging
|
|
99
|
+
|
|
100
|
+
1. Use `ts-node` or `tsx` for debugging with VS Code
|
|
101
|
+
2. Breakpoints can be set in `.ts` files directly
|
|
102
|
+
3. Use F5 or the "Run and Debug" panel in VS Code
|
|
103
|
+
4. The launch.json is configured for tsx debugging
|
|
104
|
+
|
|
105
|
+
## Important Notes
|
|
106
|
+
|
|
107
|
+
- **Never commit secrets or credentials**
|
|
108
|
+
- **Always run lint:fix before committing** (handled automatically by husky)
|
|
109
|
+
- **Use Bun as the runtime** (not Node)
|
|
110
|
+
- **The bin entry is `bin/ops-toolkit.ts`** (not src/index.ts)
|
|
111
|
+
- **TypeScript is configured with strict mode** - all types must be defined
|
|
112
|
+
- **Husky pre-commit hooks run lint-staged** automatically
|
|
113
|
+
|
|
114
|
+
## Common Tasks
|
|
115
|
+
|
|
116
|
+
### Add a new CLI command
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# 1. Create command file
|
|
120
|
+
touch src/commands/mycommand/index.ts
|
|
121
|
+
|
|
122
|
+
# 2. Implement the command handler
|
|
123
|
+
# Follow existing command patterns
|
|
124
|
+
|
|
125
|
+
# 3. Register in src/index.ts
|
|
126
|
+
program
|
|
127
|
+
.command('mycommand')
|
|
128
|
+
.description('Description here')
|
|
129
|
+
.action(async () => {
|
|
130
|
+
// Implementation
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Add a new dependency
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Runtime dependency
|
|
138
|
+
bun add <package>
|
|
139
|
+
|
|
140
|
+
# Dev dependency
|
|
141
|
+
bun add -d <package>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Run type checking only
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
bun run typecheck
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Format all files
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
bun run format
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## VS Code Shortcuts
|
|
157
|
+
|
|
158
|
+
Recommended VS Code extensions:
|
|
159
|
+
|
|
160
|
+
- Bun (oven.bun-vscode)
|
|
161
|
+
- TypeScript (ms-vscode.vscode-typescript-next)
|
|
162
|
+
- ESLint (ms-vscode.vscode-eslint)
|
|
163
|
+
- Prettier (esbenp.prettier-vscode)
|
|
164
|
+
|
|
165
|
+
Useful shortcuts:
|
|
166
|
+
|
|
167
|
+
- `Cmd+Shift+B` - Build project
|
|
168
|
+
- `F5` - Start debugging
|
|
169
|
+
- `Cmd+Shift+F` - Format document
|
|
170
|
+
- `Cmd+Shift+P` then "ESLint: Fix all auto-fixable Problems"
|
|
171
|
+
|
|
172
|
+
## Testing Strategy
|
|
173
|
+
|
|
174
|
+
Tests are run with `bun test`. When adding features:
|
|
175
|
+
|
|
176
|
+
- Unit tests for utility functions
|
|
177
|
+
- Integration tests for CLI commands
|
|
178
|
+
- Test edge cases and error conditions
|
|
179
|
+
|
|
180
|
+
## Performance Notes
|
|
181
|
+
|
|
182
|
+
- Bun is used as runtime for performance
|
|
183
|
+
- Avoid blocking operations in event loop
|
|
184
|
+
- Use async/await for all I/O operations
|
|
185
|
+
- Optimize large file operations
|
|
186
|
+
|
|
187
|
+
## Error Handling Pattern
|
|
188
|
+
|
|
189
|
+
Always handle errors in async operations:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
try {
|
|
193
|
+
// Your code here
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error(chalk.red('❌ Error:'), error);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Quick Reference
|
|
201
|
+
|
|
202
|
+
| Task | Command |
|
|
203
|
+
| ---------------- | ------------------- |
|
|
204
|
+
| Start dev server | `bun run dev` |
|
|
205
|
+
| Build project | `bun run build` |
|
|
206
|
+
| Run tests | `bun test` |
|
|
207
|
+
| Type check | `bun run typecheck` |
|
|
208
|
+
| Lint and fix | `bun run lint:fix` |
|
|
209
|
+
| Format code | `bun run format` |
|
|
210
|
+
| Debug | F5 in VS Code |
|
|
211
|
+
|
|
212
|
+
## OpenCode Custom Commands
|
|
213
|
+
|
|
214
|
+
The project includes custom OpenCode commands for faster development. These commands are available in `.opencode/command/` directory:
|
|
215
|
+
|
|
216
|
+
### Available Commands
|
|
217
|
+
|
|
218
|
+
- `/add-cmd <name>` - Add a new CLI command
|
|
219
|
+
- `/fix <issue>` - Fix code issues with automated checks
|
|
220
|
+
- `/test` - Run and analyze test suite
|
|
221
|
+
- `/release` - Prepare project for release
|
|
222
|
+
- `/review <location>` - Review code changes
|
|
223
|
+
- `/build` - Build and verify project
|
|
224
|
+
- `/add-pkg <package>` - Add a new dependency
|
|
225
|
+
- `/debug <issue>` - Get debugging help
|
|
226
|
+
|
|
227
|
+
### Usage Examples
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Add a new command
|
|
231
|
+
/add-cmd backup
|
|
232
|
+
|
|
233
|
+
# Fix an issue
|
|
234
|
+
/fix monitor command error
|
|
235
|
+
|
|
236
|
+
# Run and analyze tests
|
|
237
|
+
/test
|
|
238
|
+
|
|
239
|
+
# Prepare for release
|
|
240
|
+
/release
|
|
241
|
+
|
|
242
|
+
# Review code
|
|
243
|
+
/review src/utils/logger.ts
|
|
244
|
+
|
|
245
|
+
# Build and verify
|
|
246
|
+
/build
|
|
247
|
+
|
|
248
|
+
# Add dependency
|
|
249
|
+
/add-pkg axios
|
|
250
|
+
|
|
251
|
+
# Get debugging help
|
|
252
|
+
/debug async function not awaiting
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Documentation
|
|
256
|
+
|
|
257
|
+
See `.opencode/README.md` for detailed documentation of all custom commands.
|
|
258
|
+
|
|
259
|
+
### Creating Custom Commands
|
|
260
|
+
|
|
261
|
+
To create your own commands:
|
|
262
|
+
|
|
263
|
+
1. Create a `.md` file in `.opencode/command/`
|
|
264
|
+
2. Use YAML frontmatter for configuration
|
|
265
|
+
3. Use `$ARGUMENTS` for command arguments
|
|
266
|
+
4. Use `!`command`` for shell output
|
|
267
|
+
5. Use `@filename` for file references
|
|
268
|
+
|
|
269
|
+
Example:
|
|
270
|
+
|
|
271
|
+
```yaml
|
|
272
|
+
---
|
|
273
|
+
description: My custom command
|
|
274
|
+
agent: build
|
|
275
|
+
---
|
|
276
|
+
My prompt template with $ARGUMENTS
|
|
277
|
+
```
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
## 1.1.0 (2026-01-11)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- add comprehensive debugging setup ([6e56daa](https://github.com/username/ops-toolkit/commits/6e56daac18a80c49a1d3dd5a95e45a82054216f4))
|
|
10
|
+
- add OpenCode custom commands for ops-toolkit ([228a2db](https://github.com/username/ops-toolkit/commits/228a2dbd58ea9c7f21db4ad94b4bad5c8ec53bb8))
|
|
11
|
+
- initialize ops-toolkit CLI project ([b55190c](https://github.com/username/ops-toolkit/commits/b55190cbd81666b8893aab99ab24c5e264b81ce2))
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- add scripts directory to TypeScript include ([ce6324a](https://github.com/username/ops-toolkit/commits/ce6324a2cb0ce358419361d23910de32ec368648))
|
|
16
|
+
|
|
17
|
+
### Code Refactoring
|
|
18
|
+
|
|
19
|
+
- clean up debug code and add tsx support ([087b83d](https://github.com/username/ops-toolkit/commits/087b83d656fb3cf434bd6c6f458bd7bc32688970))
|
|
20
|
+
|
|
21
|
+
### Documentation
|
|
22
|
+
|
|
23
|
+
- add custom commands reference ([340cc12](https://github.com/username/ops-toolkit/commits/340cc12889d30b99a21334457e28e601a5fc2bb9))
|
|
24
|
+
- add development guide with tips and tricks ([b8017af](https://github.com/username/ops-toolkit/commits/b8017affb22ff7448c897d47e4b3b57c548c80b1))
|
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# ops-toolkit - DevOps CLI Toolkit
|
|
2
|
+
|
|
3
|
+
一个使用Bun、TypeScript和OpenTUI构建的综合DevOps CLI工具集。
|
|
4
|
+
|
|
5
|
+
## 🚀 快速开始
|
|
6
|
+
|
|
7
|
+
### 安装依赖
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 基本使用
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 运行默认命令
|
|
17
|
+
bun bin/ops-toolkit.ts
|
|
18
|
+
|
|
19
|
+
# 或者使用bun直接运行
|
|
20
|
+
bun run start
|
|
21
|
+
|
|
22
|
+
# 显示帮助
|
|
23
|
+
bun bin/ops-toolkit.ts --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 📋 可用命令
|
|
27
|
+
|
|
28
|
+
### 基础命令
|
|
29
|
+
|
|
30
|
+
- `ops ui` - 启动交互式终端UI(默认)
|
|
31
|
+
- `ops monitor` - 系统监控
|
|
32
|
+
- `ops logs` - 日志管理
|
|
33
|
+
- `ops deploy` - 部署工具
|
|
34
|
+
- `ops system` - 系统管理
|
|
35
|
+
|
|
36
|
+
### 监控命令
|
|
37
|
+
|
|
38
|
+
- `ops monitor system` - 系统资源监控
|
|
39
|
+
- `ops monitor processes` - 进程监控
|
|
40
|
+
- `ops monitor network` - 网络监控
|
|
41
|
+
- `ops monitor disk` - 磁盘使用监控
|
|
42
|
+
|
|
43
|
+
### 日志命令
|
|
44
|
+
|
|
45
|
+
- `ops logs view <file>` - 查看日志文件
|
|
46
|
+
- `ops logs search <pattern>` - 搜索日志
|
|
47
|
+
- `ops logs analyze <file>` - 日志分析
|
|
48
|
+
- `ops logs export <file> <output>` - 导出日志
|
|
49
|
+
|
|
50
|
+
### 部署命令
|
|
51
|
+
|
|
52
|
+
- `ops deploy app <app>` - 部署应用
|
|
53
|
+
- `ops deploy rollback <app>` - 回滚部署
|
|
54
|
+
- `ops deploy status` - 部署状态
|
|
55
|
+
- `ops deploy history` - 部署历史
|
|
56
|
+
|
|
57
|
+
### 系统管理命令
|
|
58
|
+
|
|
59
|
+
- `ops system users` - 用户管理
|
|
60
|
+
- `ops system services` - 服务管理
|
|
61
|
+
- `ops system config` - 配置管理
|
|
62
|
+
- `ops system info` - 系统信息
|
|
63
|
+
|
|
64
|
+
## 🛠️ 开发
|
|
65
|
+
|
|
66
|
+
### 脚本命令
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# 开发模式
|
|
70
|
+
bun run dev
|
|
71
|
+
|
|
72
|
+
# 构建项目
|
|
73
|
+
bun run build
|
|
74
|
+
|
|
75
|
+
# 类型检查
|
|
76
|
+
bun run typecheck
|
|
77
|
+
|
|
78
|
+
# 代码检查
|
|
79
|
+
bun run lint
|
|
80
|
+
|
|
81
|
+
# 自动修复代码格式
|
|
82
|
+
bun run lint:fix
|
|
83
|
+
|
|
84
|
+
# 代码格式化
|
|
85
|
+
bun run format
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 项目结构
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
ops-toolkit/
|
|
92
|
+
├── bin/ # CLI入口文件
|
|
93
|
+
│ └── ops-toolkit.ts
|
|
94
|
+
├── src/
|
|
95
|
+
│ ├── commands/ # 命令模块
|
|
96
|
+
│ │ ├── monitor/ # 监控命令
|
|
97
|
+
│ │ ├── logs/ # 日志命令
|
|
98
|
+
│ │ ├── deploy/ # 部署命令
|
|
99
|
+
│ │ └── system/ # 系统命令
|
|
100
|
+
│ ├── types/ # TypeScript类型定义
|
|
101
|
+
│ ├── utils/ # 工具函数
|
|
102
|
+
│ └── index.ts # 主入口
|
|
103
|
+
├── scripts/ # 构建脚本
|
|
104
|
+
├── docs/ # 文档
|
|
105
|
+
└── 配置文件...
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 🎯 特性
|
|
109
|
+
|
|
110
|
+
- ✅ TypeScript支持
|
|
111
|
+
- ✅ Bun包管理和运行时
|
|
112
|
+
- ✅ ESLint + Prettier代码规范
|
|
113
|
+
- ✅ Husky + lint-staged + commitlint Git工作流
|
|
114
|
+
- ✅ Commander.js命令行解析
|
|
115
|
+
- ✅ 彩色终端输出(chalk)
|
|
116
|
+
- ✅ 模块化架构设计
|
|
117
|
+
- 🚧 OpenTUI终端UI集成(开发中)
|
|
118
|
+
|
|
119
|
+
## 📝 开发计划
|
|
120
|
+
|
|
121
|
+
- [ ] 完整的OpenTUI界面实现
|
|
122
|
+
- [ ] 系统监控功能
|
|
123
|
+
- [ ] 日志管理功能
|
|
124
|
+
- [ ] 部署工具功能
|
|
125
|
+
- [ ] 系统管理功能
|
|
126
|
+
- [ ] 配置文件管理
|
|
127
|
+
- [ ] 插件系统
|
|
128
|
+
- [ ] 单元测试
|
|
129
|
+
|
|
130
|
+
## 📄 许可证
|
|
131
|
+
|
|
132
|
+
MIT License
|
|
133
|
+
|
|
134
|
+
## 🤝 贡献
|
|
135
|
+
|
|
136
|
+
欢迎提交Issue和Pull Request!
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# ops-toolkit
|
|
2
|
+
|
|
3
|
+
A comprehensive DevOps CLI toolkit with terminal UI built with Bun, TypeScript, and OpenTUI.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔍 **System Monitoring** - Real-time CPU, memory, and disk usage
|
|
8
|
+
- 📋 **Log Management** - View, search, and analyze logs
|
|
9
|
+
- 🚀 **Deployment Tools** - Deploy applications with ease
|
|
10
|
+
- ⚙️ **System Management** - User and service management
|
|
11
|
+
- 🎨 **Terminal UI** - Beautiful interface with OpenTUI
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install globally
|
|
17
|
+
bun add -g ops-toolkit
|
|
18
|
+
|
|
19
|
+
# Or use npx
|
|
20
|
+
npx ops-toolkit
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Start the interactive UI
|
|
27
|
+
ops
|
|
28
|
+
|
|
29
|
+
# Show system monitoring
|
|
30
|
+
ops monitor
|
|
31
|
+
|
|
32
|
+
# View logs
|
|
33
|
+
ops logs
|
|
34
|
+
|
|
35
|
+
# Deploy application
|
|
36
|
+
ops deploy
|
|
37
|
+
|
|
38
|
+
# System management
|
|
39
|
+
ops system
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Commands
|
|
43
|
+
|
|
44
|
+
### Monitor
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
ops monitor # Show system monitoring dashboard
|
|
48
|
+
ops monitor system # System resources
|
|
49
|
+
ops monitor processes # Process monitoring
|
|
50
|
+
ops monitor network # Network monitoring
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Logs
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
ops logs # Interactive log viewer
|
|
57
|
+
ops logs view <file> # View specific log file
|
|
58
|
+
ops logs search <query> # Search logs
|
|
59
|
+
ops logs tail <file> # Tail log file
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Deploy
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
ops deploy # Interactive deployment
|
|
66
|
+
ops deploy <app> # Deploy specific application
|
|
67
|
+
ops deploy rollback # Rollback deployment
|
|
68
|
+
ops deploy status # Check deployment status
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### System
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
ops system # System management menu
|
|
75
|
+
ops system users # User management
|
|
76
|
+
ops system services # Service management
|
|
77
|
+
ops system config # Configuration management
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Clone the repository
|
|
84
|
+
git clone https://github.com/username/ops-toolkit.git
|
|
85
|
+
cd ops-toolkit
|
|
86
|
+
|
|
87
|
+
# Install dependencies
|
|
88
|
+
bun install
|
|
89
|
+
|
|
90
|
+
# Run in development mode
|
|
91
|
+
bun run dev
|
|
92
|
+
|
|
93
|
+
# Build the project
|
|
94
|
+
bun run build
|
|
95
|
+
|
|
96
|
+
# Run tests
|
|
97
|
+
bun test
|
|
98
|
+
|
|
99
|
+
# Lint code
|
|
100
|
+
bun run lint
|
|
101
|
+
|
|
102
|
+
# Format code
|
|
103
|
+
bun run format
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Configuration
|
|
107
|
+
|
|
108
|
+
Configuration files are located in `~/.ops-toolkit/`:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"monitor": {
|
|
113
|
+
"refreshInterval": 1000,
|
|
114
|
+
"showProcesses": true
|
|
115
|
+
},
|
|
116
|
+
"logs": {
|
|
117
|
+
"defaultPath": "/var/log",
|
|
118
|
+
"maxLines": 1000
|
|
119
|
+
},
|
|
120
|
+
"deploy": {
|
|
121
|
+
"defaultEnv": "production",
|
|
122
|
+
"backupEnabled": true
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Contributing
|
|
128
|
+
|
|
129
|
+
1. Fork the repository
|
|
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
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
138
|
+
|
|
139
|
+
## Acknowledgments
|
|
140
|
+
|
|
141
|
+
- Built with [Bun](https://bun.sh/)
|
|
142
|
+
- UI powered by [OpenTUI](https://opentui.dev/)
|
|
143
|
+
- Inspired by modern DevOps tools
|