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,255 @@
|
|
|
1
|
+
# 🐛 Debugging Guide for ops-toolkit
|
|
2
|
+
|
|
3
|
+
This guide shows you how to debug the ops-toolkit CLI application using various debugging methods.
|
|
4
|
+
|
|
5
|
+
## 🔧 VS Code Debugging (Recommended)
|
|
6
|
+
|
|
7
|
+
### 1. Install VS Code Extensions
|
|
8
|
+
|
|
9
|
+
Make sure you have these extensions installed:
|
|
10
|
+
|
|
11
|
+
- **Bun** (`oven.bun-vscode`)
|
|
12
|
+
- **TypeScript** (`ms-vscode.vscode-typescript-next`)
|
|
13
|
+
- **ESLint** (`ms-vscode.vscode-eslint`)
|
|
14
|
+
- **Prettier** (`esbenp.prettier-vscode`)
|
|
15
|
+
|
|
16
|
+
### 2. Set Breakpoints
|
|
17
|
+
|
|
18
|
+
Open any TypeScript file and click in the gutter to set breakpoints:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
// Example: src/commands/monitor/index.ts
|
|
22
|
+
.action(async (_options: MonitorOptions) => {
|
|
23
|
+
debugger; // ← Click here to set breakpoint
|
|
24
|
+
console.log(chalk.blue('📊 System Monitor'));
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 3. Start Debugging
|
|
29
|
+
|
|
30
|
+
- Press `F5` or go to **Run and Debug** panel
|
|
31
|
+
- Select "Debug CLI (ops-toolkit)" from the dropdown
|
|
32
|
+
- Click the green play button ▶️
|
|
33
|
+
|
|
34
|
+
### 4. Available Debug Configurations
|
|
35
|
+
|
|
36
|
+
#### **Debug CLI (ops-toolkit)**
|
|
37
|
+
|
|
38
|
+
- Runs the CLI without arguments
|
|
39
|
+
- Full debugging support
|
|
40
|
+
- Break on startup
|
|
41
|
+
|
|
42
|
+
#### **Debug CLI with arguments**
|
|
43
|
+
|
|
44
|
+
- Runs `ops monitor` command
|
|
45
|
+
- Perfect for testing specific commands
|
|
46
|
+
|
|
47
|
+
#### **Debug TypeScript file directly**
|
|
48
|
+
|
|
49
|
+
- Debug any TypeScript file
|
|
50
|
+
- Select file from prompt
|
|
51
|
+
|
|
52
|
+
## 🚀 Command Line Debugging
|
|
53
|
+
|
|
54
|
+
### Method 1: Bun Inspector
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Start debugging server
|
|
58
|
+
bun run debug
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Connect to Chrome DevTools
|
|
62
|
+
# Open Chrome and go to: chrome://inspect
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Method 2: Node Inspector
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Start with node inspector
|
|
69
|
+
bun --inspect-brk bin/ops-toolkit.ts
|
|
70
|
+
|
|
71
|
+
# This will wait for debugger to connect
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 📍 Breakpoint Strategies
|
|
75
|
+
|
|
76
|
+
### 1. Entry Points
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// bin/ops-toolkit.ts
|
|
80
|
+
async function main() {
|
|
81
|
+
debugger; // ← Program startup
|
|
82
|
+
// ... code
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Command Handlers
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// src/commands/monitor/index.ts
|
|
90
|
+
.action(async (_options: MonitorOptions) => {
|
|
91
|
+
debugger; // ← Command execution
|
|
92
|
+
console.log(chalk.blue('📊 System Monitor'));
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 3. Utility Functions
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// src/utils/system.ts
|
|
100
|
+
static async getProcessList(): Promise<any[]> {
|
|
101
|
+
debugger; // ← Utility function entry
|
|
102
|
+
try {
|
|
103
|
+
const platform = os.platform();
|
|
104
|
+
// ... code
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 4. Error Handling
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
// bin/ops-toolkit.ts
|
|
113
|
+
process.on('uncaughtException', error => {
|
|
114
|
+
debugger; // ← Error breakpoint
|
|
115
|
+
console.error(chalk.red('❌ Uncaught Exception:'), error);
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## 🔍 Chrome DevTools Integration
|
|
120
|
+
|
|
121
|
+
### 1. Start with Inspector
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
bun --inspect-brk bin/ops-toolkit.ts
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 2. Open Chrome DevTools
|
|
128
|
+
|
|
129
|
+
1. Open Chrome
|
|
130
|
+
2. Go to `chrome://inspect`
|
|
131
|
+
3. Find "Node.js" target
|
|
132
|
+
4. Click "inspect"
|
|
133
|
+
|
|
134
|
+
### 3. Debugging Features
|
|
135
|
+
|
|
136
|
+
- **Breakpoints**: Set/clear breakpoints
|
|
137
|
+
- **Call Stack**: Navigate function calls
|
|
138
|
+
- **Variables**: Inspect local and global variables
|
|
139
|
+
- **Console**: Execute code in context
|
|
140
|
+
- **Network**: Monitor network requests
|
|
141
|
+
|
|
142
|
+
## 🐛 Common Debugging Scenarios
|
|
143
|
+
|
|
144
|
+
### Debug CLI Argument Parsing
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// bin/ops-toolkit.ts
|
|
148
|
+
// Set breakpoint here to inspect parsed arguments
|
|
149
|
+
const options = program.opts();
|
|
150
|
+
debugger;
|
|
151
|
+
console.log('CLI Options:', options);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Debug Error Conditions
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// src/utils/system.ts
|
|
158
|
+
static async execCommand(command: string): Promise<string> {
|
|
159
|
+
try {
|
|
160
|
+
debugger; // ← Debug before execution
|
|
161
|
+
const { stdout } = await execAsync(command);
|
|
162
|
+
return stdout.trim();
|
|
163
|
+
} catch (error) {
|
|
164
|
+
debugger; // ← Debug error handling
|
|
165
|
+
throw new Error(`Command execution failed: ${command}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 🛠️ Advanced Debugging
|
|
171
|
+
|
|
172
|
+
### 1. Conditional Breakpoints
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
if (process.env.DEBUG && someCondition) {
|
|
176
|
+
debugger; // Only breaks when condition is true
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 2. Log Point Breakpoints
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
// Instead of breaking, just log values
|
|
184
|
+
console.log('🐛 Debug Value:', someVariable);
|
|
185
|
+
// debugger; // Uncomment to actually break
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### 3. Async Debugging
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
async function asyncOperation() {
|
|
192
|
+
debugger; // ← Break before async operation
|
|
193
|
+
const result = await someAsyncCall();
|
|
194
|
+
debugger; // ← Break after async operation completes
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## 📱 Debugging with Console
|
|
200
|
+
|
|
201
|
+
### Real-time Variable Inspection
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Run with debug flag
|
|
205
|
+
DEBUG=true bun bin/ops-toolkit.ts monitor
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Environment Variables for Debugging
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Enable verbose logging
|
|
212
|
+
NODE_ENV=development DEBUG=* bun bin/ops-toolkit.ts
|
|
213
|
+
|
|
214
|
+
# Enable specific debug modules
|
|
215
|
+
DEBUG=system,config bun bin/ops-toolkit.ts
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## 🚨 Troubleshooting
|
|
219
|
+
|
|
220
|
+
### Breakpoints Not Working?
|
|
221
|
+
|
|
222
|
+
1. Ensure you're running with `--inspect` flag
|
|
223
|
+
2. Check that source maps are enabled
|
|
224
|
+
3. Verify files are included in tsconfig.json
|
|
225
|
+
|
|
226
|
+
### Source Maps Issues?
|
|
227
|
+
|
|
228
|
+
- Files must be included in `tsconfig.json`
|
|
229
|
+
- Use `verbatimModuleSyntax: false`
|
|
230
|
+
- Ensure proper TypeScript configuration
|
|
231
|
+
|
|
232
|
+
### Inspector Not Connecting?
|
|
233
|
+
|
|
234
|
+
1. Check if port 9229 is available
|
|
235
|
+
2. Try `--inspect-brk` to wait for connection
|
|
236
|
+
3. Verify firewall settings
|
|
237
|
+
|
|
238
|
+
## 🎯 Pro Tips
|
|
239
|
+
|
|
240
|
+
1. **Use meaningful variable names** - Makes debugging easier
|
|
241
|
+
2. **Add debug logs early** - Instrument code before you need it
|
|
242
|
+
3. **Test edge cases** - Debug with invalid inputs
|
|
243
|
+
4. **Use conditional breakpoints** - Reduce noise
|
|
244
|
+
5. **Document debug findings** - Save insights for later
|
|
245
|
+
|
|
246
|
+
## 📚 Additional Resources
|
|
247
|
+
|
|
248
|
+
- [Bun Debugging Documentation](https://bun.sh/docs/debugger)
|
|
249
|
+
- [VS Code Debugging Guide](https://code.visualstudio.com/docs/editor/debugging)
|
|
250
|
+
- [Chrome DevTools Documentation](https://developer.chrome.com/docs/devtools/)
|
|
251
|
+
- [TypeScript Debugging](https://code.visualstudio.com/docs/typescript/typescript-debugging)
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
Happy debugging! 🐛✨
|