@sun-asterisk/impact-analyzer 1.0.6 → 1.0.7
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/.specify/bugs/bug-004-fix-summary.md +59 -0
- package/.specify/bugs/bug-004-raw-sql-detection.md +158 -0
- package/.specify/bugs/bug-005-queue-processor-detection.md +197 -0
- package/.specify/tasks/task-005-cli-optimization.md +284 -0
- package/.specify/tasks/task-005-completion.md +99 -0
- package/README.md +150 -36
- package/cli.js +68 -0
- package/config/default-config.js +5 -9
- package/core/detectors/database-detector.js +408 -3
- package/core/utils/logger.js +2 -1
- package/core/utils/method-call-graph.js +249 -4
- package/index.js +6 -0
- package/package.json +5 -2
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Task 005 - CLI Optimization - Completion Report
|
|
2
|
+
|
|
3
|
+
## Status: ✅ COMPLETED
|
|
4
|
+
|
|
5
|
+
## Summary
|
|
6
|
+
|
|
7
|
+
Successfully optimized CLI tool with sensible defaults and comprehensive documentation.
|
|
8
|
+
|
|
9
|
+
## Changes Implemented
|
|
10
|
+
|
|
11
|
+
### 1. Default Configuration Update ✅
|
|
12
|
+
- **Changed default base ref**: `origin/main` → `HEAD~1`
|
|
13
|
+
- **Rationale**: Simpler for quick local analysis of last commit
|
|
14
|
+
- **Location**: `config/default-config.js`
|
|
15
|
+
|
|
16
|
+
### 2. Help Command Implementation ✅
|
|
17
|
+
- Added `--help` and `-h` flags
|
|
18
|
+
- Created comprehensive help guide with:
|
|
19
|
+
- Usage examples
|
|
20
|
+
- All CLI options explained
|
|
21
|
+
- Common use cases
|
|
22
|
+
- References to architecture and coding rules
|
|
23
|
+
- **Location**: `cli.js`
|
|
24
|
+
|
|
25
|
+
### 3. Documentation Overhaul ✅
|
|
26
|
+
|
|
27
|
+
#### README.md Updates
|
|
28
|
+
- Added "Quick Reference" section
|
|
29
|
+
- Expanded CLI options table with defaults and examples
|
|
30
|
+
- Added multiple usage scenarios
|
|
31
|
+
- Updated CI/CD examples to use new defaults
|
|
32
|
+
- Enhanced troubleshooting section
|
|
33
|
+
- Added references to architecture and coding standards
|
|
34
|
+
|
|
35
|
+
#### New QUICK_START.md
|
|
36
|
+
- Step-by-step quick start guide
|
|
37
|
+
- Common scenario examples
|
|
38
|
+
- Output explanation
|
|
39
|
+
- Troubleshooting tips
|
|
40
|
+
- CI/CD minimal setup
|
|
41
|
+
|
|
42
|
+
### 4. Package.json Scripts ✅
|
|
43
|
+
Updated npm scripts:
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"analyze": "node index.js", // Uses defaults (HEAD~1)
|
|
47
|
+
"analyze:last": "node index.js --base=HEAD~1", // Explicit last commit
|
|
48
|
+
"analyze:main": "node index.js --base=origin/main", // Compare with main
|
|
49
|
+
"analyze:verbose": "node index.js --verbose", // Debug mode
|
|
50
|
+
"help": "node index.js --help" // Show help
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Testing
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Test help command
|
|
58
|
+
$ node index.js --help
|
|
59
|
+
✅ Shows comprehensive help guide
|
|
60
|
+
|
|
61
|
+
# Test default behavior
|
|
62
|
+
$ node index.js
|
|
63
|
+
✅ Uses HEAD~1 as default base
|
|
64
|
+
|
|
65
|
+
# Test validation removed
|
|
66
|
+
$ node index.js --base=origin/main
|
|
67
|
+
✅ No longer requires --base to be explicitly set
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Files Modified
|
|
71
|
+
|
|
72
|
+
1. `cli.js` - Added help command functionality
|
|
73
|
+
2. `config/default-config.js` - Changed defaults and removed strict validation
|
|
74
|
+
3. `index.js` - Added help command check
|
|
75
|
+
4. `package.json` - Updated scripts
|
|
76
|
+
5. `README.md` - Comprehensive documentation update
|
|
77
|
+
6. `QUICK_START.md` - New quick start guide (created)
|
|
78
|
+
|
|
79
|
+
## Benefits
|
|
80
|
+
|
|
81
|
+
1. **Easier onboarding**: Simpler default behavior (analyze last commit)
|
|
82
|
+
2. **Better DX**: Comprehensive help at `--help`
|
|
83
|
+
3. **Flexible**: Can still compare with branches using `--base=origin/main`
|
|
84
|
+
4. **Well-documented**: Multiple documentation layers (help, quick start, README)
|
|
85
|
+
5. **CI/CD ready**: Updated examples for modern workflows
|
|
86
|
+
|
|
87
|
+
## Alignment with Requirements
|
|
88
|
+
|
|
89
|
+
✅ Remove required base argument - uses HEAD~1 default
|
|
90
|
+
✅ Update reference to architecture.md and copilot-instructions.md
|
|
91
|
+
✅ Comprehensive usage documentation
|
|
92
|
+
✅ Sensible defaults for all arguments
|
|
93
|
+
✅ Help command implementation
|
|
94
|
+
|
|
95
|
+
## References
|
|
96
|
+
|
|
97
|
+
- Architecture: `.specify/plans/architecture.md`
|
|
98
|
+
- Coding Rules: `.github/copilot-instructions.md`
|
|
99
|
+
- Task Spec: `.specify/tasks/task-005-cli-optimization.md`
|
package/README.md
CHANGED
|
@@ -13,7 +13,14 @@ npm install @sun-asterisk/impact-analyzer
|
|
|
13
13
|
### Usage
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
|
|
16
|
+
# Analyze last commit (simplest - uses HEAD~1 as base)
|
|
17
|
+
npx @sun-asterisk/impact-analyzer
|
|
18
|
+
|
|
19
|
+
# Analyze changes between branch and current
|
|
20
|
+
npx @sun-asterisk/impact-analyzer --base=origin/main
|
|
21
|
+
|
|
22
|
+
# Full options
|
|
23
|
+
npx @sun-asterisk/impact-analyzer --input=src --base=origin/main --output=report.md
|
|
17
24
|
```
|
|
18
25
|
|
|
19
26
|
## Features
|
|
@@ -121,38 +128,91 @@ Controller (@Get/@Post) ──┐
|
|
|
121
128
|
|
|
122
129
|
## Usage
|
|
123
130
|
|
|
124
|
-
###
|
|
131
|
+
### Quick Reference
|
|
125
132
|
|
|
126
133
|
```bash
|
|
127
|
-
|
|
134
|
+
# Show help
|
|
135
|
+
npx @sun-asterisk/impact-analyzer --help
|
|
136
|
+
|
|
137
|
+
# Basic usage (analyzes last commit)
|
|
138
|
+
npx @sun-asterisk/impact-analyzer
|
|
139
|
+
|
|
140
|
+
# Analyze between branches
|
|
141
|
+
npx @sun-asterisk/impact-analyzer --base=origin/main
|
|
142
|
+
|
|
143
|
+
# Full example with all options
|
|
144
|
+
npx @sun-asterisk/impact-analyzer \
|
|
145
|
+
--input=src \
|
|
146
|
+
--base=HEAD~3 \
|
|
147
|
+
--output=report.md \
|
|
148
|
+
--json=report.json \
|
|
149
|
+
--verbose
|
|
128
150
|
```
|
|
129
151
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
|
133
|
-
|
|
134
|
-
| `--
|
|
135
|
-
| `--
|
|
136
|
-
| `--
|
|
137
|
-
| `--
|
|
152
|
+
### CLI Options
|
|
153
|
+
|
|
154
|
+
| Option | Description | Default | Example |
|
|
155
|
+
|--------|-------------|---------|---------|
|
|
156
|
+
| `--input=<path>` | Source directory to analyze | `src` | `--input=backend/src` |
|
|
157
|
+
| `--base=<ref>` | Base git reference for comparison | `HEAD~1` | `--base=origin/main` |
|
|
158
|
+
| `--head=<ref>` | Head git reference | Working directory | `--head=HEAD` |
|
|
159
|
+
| `--exclude=<paths>` | Comma-separated paths to exclude | `node_modules,dist,build,specs,coverage` | `--exclude=test,coverage` |
|
|
160
|
+
| `--output=<file>` | Markdown report output | `impact-report.md` | `--output=report.md` |
|
|
161
|
+
| `--json=<file>` | JSON report output (optional) | - | `--json=report.json` |
|
|
162
|
+
| `--max-depth=<n>` | Maximum call graph depth | `3` | `--max-depth=5` |
|
|
163
|
+
| `--include-tests` | Include test files in analysis | `false` | `--include-tests` |
|
|
164
|
+
| `--verbose` | Show verbose output | `false` | `--verbose` |
|
|
165
|
+
| `--no-fail` | Don't exit with error on critical | `false` | `--no-fail` |
|
|
166
|
+
| `--help`, `-h` | Show help message | - | `--help` |
|
|
138
167
|
|
|
139
168
|
### Examples
|
|
140
169
|
|
|
170
|
+
**Analyze last commit (default behavior)**
|
|
141
171
|
```bash
|
|
142
|
-
|
|
143
|
-
|
|
172
|
+
npx @sun-asterisk/impact-analyzer
|
|
173
|
+
# Compares HEAD~1 (previous commit) with current working directory
|
|
174
|
+
```
|
|
144
175
|
|
|
145
|
-
|
|
146
|
-
|
|
176
|
+
**Analyze changes between main branch and current**
|
|
177
|
+
```bash
|
|
178
|
+
npx @sun-asterisk/impact-analyzer --base=origin/main
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Analyze last 5 commits**
|
|
182
|
+
```bash
|
|
183
|
+
npx @sun-asterisk/impact-analyzer --base=HEAD~5
|
|
184
|
+
```
|
|
147
185
|
|
|
148
|
-
|
|
149
|
-
|
|
186
|
+
**Compare two specific commits**
|
|
187
|
+
```bash
|
|
188
|
+
npx @sun-asterisk/impact-analyzer --base=abc123 --head=def456
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Full analysis with reports**
|
|
192
|
+
```bash
|
|
193
|
+
npx @sun-asterisk/impact-analyzer \
|
|
194
|
+
--input=src \
|
|
195
|
+
--base=origin/main \
|
|
196
|
+
--output=impact-report.md \
|
|
197
|
+
--json=impact-report.json \
|
|
198
|
+
--verbose
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Analyze different directory**
|
|
202
|
+
```bash
|
|
203
|
+
npx @sun-asterisk/impact-analyzer --input=backend/src
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Include test files in analysis**
|
|
207
|
+
```bash
|
|
208
|
+
npx @sun-asterisk/impact-analyzer --include-tests
|
|
150
209
|
```
|
|
151
210
|
|
|
152
211
|
## CI/CD Integration
|
|
153
212
|
|
|
154
|
-
### GitHub Actions (Recommended
|
|
213
|
+
### GitHub Actions (Recommended)
|
|
155
214
|
|
|
215
|
+
**Simple - Analyze last commit in PR**
|
|
156
216
|
```yaml
|
|
157
217
|
name: Impact Analysis
|
|
158
218
|
on:
|
|
@@ -165,7 +225,7 @@ jobs:
|
|
|
165
225
|
steps:
|
|
166
226
|
- uses: actions/checkout@v4
|
|
167
227
|
with:
|
|
168
|
-
fetch-depth:
|
|
228
|
+
fetch-depth: 0 # Fetch full history for branch comparison
|
|
169
229
|
|
|
170
230
|
- uses: actions/setup-node@v3
|
|
171
231
|
with:
|
|
@@ -174,19 +234,37 @@ jobs:
|
|
|
174
234
|
- name: Run Impact Analysis
|
|
175
235
|
run: |
|
|
176
236
|
npx @sun-asterisk/impact-analyzer \
|
|
177
|
-
--input=src \
|
|
178
237
|
--base=origin/${{ github.event.pull_request.base.ref }} \
|
|
179
|
-
--
|
|
180
|
-
--
|
|
238
|
+
--output=impact-report.md \
|
|
239
|
+
--json=impact-report.json
|
|
181
240
|
|
|
182
|
-
- name: Upload
|
|
241
|
+
- name: Upload Reports
|
|
183
242
|
uses: actions/upload-artifact@v4
|
|
184
243
|
with:
|
|
185
|
-
name: impact-reports
|
|
186
|
-
path:
|
|
244
|
+
name: impact-reports
|
|
245
|
+
path: |
|
|
246
|
+
impact-report.md
|
|
247
|
+
impact-report.json
|
|
187
248
|
retention-days: 30
|
|
188
249
|
```
|
|
189
250
|
|
|
251
|
+
**Advanced - With PR Comment**
|
|
252
|
+
```yaml
|
|
253
|
+
- name: Comment PR with Impact Report
|
|
254
|
+
uses: actions/github-script@v7
|
|
255
|
+
with:
|
|
256
|
+
script: |
|
|
257
|
+
const fs = require('fs');
|
|
258
|
+
const report = fs.readFileSync('impact-report.md', 'utf8');
|
|
259
|
+
|
|
260
|
+
github.rest.issues.createComment({
|
|
261
|
+
issue_number: context.issue.number,
|
|
262
|
+
owner: context.repo.owner,
|
|
263
|
+
repo: context.repo.repo,
|
|
264
|
+
body: report
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
190
268
|
### GitLab CI
|
|
191
269
|
|
|
192
270
|
```yaml
|
|
@@ -194,18 +272,17 @@ impact-analysis:
|
|
|
194
272
|
stage: test
|
|
195
273
|
image: node:18
|
|
196
274
|
variables:
|
|
197
|
-
GIT_DEPTH:
|
|
275
|
+
GIT_DEPTH: 0 # Fetch full history
|
|
198
276
|
script:
|
|
199
277
|
- npx @sun-asterisk/impact-analyzer
|
|
200
|
-
--input=src
|
|
201
278
|
--base=origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
|
202
|
-
--head=HEAD
|
|
203
279
|
--output=impact-report.md
|
|
204
280
|
--json=impact-report.json
|
|
205
281
|
artifacts:
|
|
206
282
|
paths:
|
|
207
283
|
- impact-report.md
|
|
208
284
|
- impact-report.json
|
|
285
|
+
expire_in: 30 days
|
|
209
286
|
only:
|
|
210
287
|
- merge_requests
|
|
211
288
|
```
|
|
@@ -220,12 +297,12 @@ pipeline {
|
|
|
220
297
|
steps {
|
|
221
298
|
sh '''
|
|
222
299
|
npx @sun-asterisk/impact-analyzer \
|
|
223
|
-
--input=src \
|
|
224
300
|
--base=origin/main \
|
|
225
|
-
--head=HEAD \
|
|
226
301
|
--output=impact-report.md \
|
|
227
302
|
--json=impact-report.json
|
|
228
303
|
'''
|
|
304
|
+
|
|
305
|
+
archiveArtifacts artifacts: 'impact-report.*', fingerprint: true
|
|
229
306
|
}
|
|
230
307
|
}
|
|
231
308
|
}
|
|
@@ -253,20 +330,57 @@ pipeline {
|
|
|
253
330
|
### Common Issues
|
|
254
331
|
|
|
255
332
|
**"Source directory does not exist"**
|
|
256
|
-
|
|
333
|
+
```bash
|
|
334
|
+
# Check if directory exists
|
|
335
|
+
ls -la src
|
|
336
|
+
|
|
337
|
+
# Use correct path
|
|
338
|
+
npx @sun-asterisk/impact-analyzer --input=backend/src
|
|
339
|
+
```
|
|
257
340
|
|
|
258
341
|
**"Base ref does not exist"**
|
|
259
|
-
|
|
260
|
-
|
|
342
|
+
```bash
|
|
343
|
+
# Fetch latest branches
|
|
344
|
+
git fetch origin
|
|
345
|
+
|
|
346
|
+
# Verify branch exists
|
|
347
|
+
git show origin/main
|
|
348
|
+
|
|
349
|
+
# Or use commit SHA
|
|
350
|
+
npx @sun-asterisk/impact-analyzer --base=abc123
|
|
351
|
+
```
|
|
261
352
|
|
|
262
353
|
**"No changes detected"**
|
|
263
|
-
|
|
354
|
+
```bash
|
|
355
|
+
# Check if there are actual differences
|
|
356
|
+
git diff HEAD~1 HEAD
|
|
357
|
+
|
|
358
|
+
# Or compare with branch
|
|
359
|
+
git diff origin/main HEAD
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Need more details?**
|
|
363
|
+
```bash
|
|
364
|
+
# Enable verbose mode for detailed logs
|
|
365
|
+
npx @sun-asterisk/impact-analyzer --verbose
|
|
366
|
+
|
|
367
|
+
# Show help
|
|
368
|
+
npx @sun-asterisk/impact-analyzer --help
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Getting Help
|
|
264
372
|
|
|
265
|
-
**Debug Mode**
|
|
266
373
|
```bash
|
|
267
|
-
|
|
374
|
+
# Show comprehensive help guide
|
|
375
|
+
npx @sun-asterisk/impact-analyzer --help
|
|
268
376
|
```
|
|
269
377
|
|
|
378
|
+
### References
|
|
379
|
+
|
|
380
|
+
- **Architecture**: `.specify/plans/architecture.md` - System design and flow
|
|
381
|
+
- **Coding Rules**: `.github/copilot-instructions.md` - Development standards
|
|
382
|
+
- **Tasks**: `.specify/tasks/` - Implementation tasks and specifications
|
|
383
|
+
|
|
270
384
|
## License
|
|
271
385
|
|
|
272
386
|
MIT
|
package/cli.js
CHANGED
|
@@ -35,4 +35,72 @@ export class CLI {
|
|
|
35
35
|
getAllArgs() {
|
|
36
36
|
return Object.fromEntries(this.args);
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
showHelp() {
|
|
40
|
+
console.log(`
|
|
41
|
+
╔═══════════════════════════════════════════════════════════════════╗
|
|
42
|
+
║ 🔍 Impact Analyzer CLI - Help Guide ║
|
|
43
|
+
╚═══════════════════════════════════════════════════════════════════╝
|
|
44
|
+
|
|
45
|
+
USAGE:
|
|
46
|
+
impact-analyzer [OPTIONS]
|
|
47
|
+
|
|
48
|
+
DESCRIPTION:
|
|
49
|
+
Analyzes code changes and their impact on endpoints, database, and
|
|
50
|
+
components in TypeScript/JavaScript projects.
|
|
51
|
+
|
|
52
|
+
OPTIONS:
|
|
53
|
+
--input=<path> Source directory to analyze
|
|
54
|
+
Default: src
|
|
55
|
+
|
|
56
|
+
--base=<ref> Base git reference for comparison
|
|
57
|
+
Default: HEAD~1 (previous commit)
|
|
58
|
+
Examples: origin/main, HEAD~5, abc123
|
|
59
|
+
|
|
60
|
+
--head=<ref> Head git reference (optional)
|
|
61
|
+
Default: (working directory)
|
|
62
|
+
|
|
63
|
+
--exclude=<paths> Comma-separated paths to exclude
|
|
64
|
+
Default: node_modules,dist,build,specs,coverage
|
|
65
|
+
|
|
66
|
+
--output=<file> Output markdown report file
|
|
67
|
+
Default: impact-report.md
|
|
68
|
+
|
|
69
|
+
--json=<file> Output JSON report file (optional)
|
|
70
|
+
Example: --json=impact-report.json
|
|
71
|
+
|
|
72
|
+
--max-depth=<n> Maximum call graph depth
|
|
73
|
+
Default: 3
|
|
74
|
+
|
|
75
|
+
--include-tests Include test files in analysis
|
|
76
|
+
|
|
77
|
+
--verbose Show verbose output and stack traces
|
|
78
|
+
|
|
79
|
+
--no-fail Don't exit with error on critical impact
|
|
80
|
+
|
|
81
|
+
--help, -h Show this help message
|
|
82
|
+
|
|
83
|
+
EXAMPLES:
|
|
84
|
+
# Analyze changes in last commit (default)
|
|
85
|
+
impact-analyzer
|
|
86
|
+
|
|
87
|
+
# Analyze changes between main branch and current
|
|
88
|
+
impact-analyzer --base=origin/main
|
|
89
|
+
|
|
90
|
+
# Analyze specific directory with JSON output
|
|
91
|
+
impact-analyzer --input=backend/src --json=report.json
|
|
92
|
+
|
|
93
|
+
# Analyze last 3 commits with verbose output
|
|
94
|
+
impact-analyzer --base=HEAD~3 --verbose
|
|
95
|
+
|
|
96
|
+
# Compare two specific commits
|
|
97
|
+
impact-analyzer --base=abc123 --head=def456
|
|
98
|
+
|
|
99
|
+
REFERENCE:
|
|
100
|
+
Architecture: .specify/plans/architecture.md
|
|
101
|
+
Coding Rules: .github/copilot-instructions.md
|
|
102
|
+
|
|
103
|
+
For more information, visit: https://github.com/sun-asterisk/impact-analyzer
|
|
104
|
+
`);
|
|
105
|
+
}
|
|
38
106
|
}
|
package/config/default-config.js
CHANGED
|
@@ -13,8 +13,8 @@ export function loadConfig(cli) {
|
|
|
13
13
|
.split(',')
|
|
14
14
|
.map(p => p.trim()),
|
|
15
15
|
|
|
16
|
-
// Git references
|
|
17
|
-
baseRef: cli.getArg('base', '
|
|
16
|
+
// Git references - defaults to HEAD~1 (previous commit)
|
|
17
|
+
baseRef: cli.getArg('base', 'HEAD~1'),
|
|
18
18
|
headRef: cli.getArg('head', ''), // Empty means current working directory
|
|
19
19
|
|
|
20
20
|
// Analysis options
|
|
@@ -37,19 +37,15 @@ function validateConfig(config) {
|
|
|
37
37
|
if (!config.sourceDir) {
|
|
38
38
|
throw new Error('Source directory (--input) is required');
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
if (!config.baseRef) {
|
|
42
|
-
throw new Error('Base git reference (--base) is required');
|
|
43
|
-
}
|
|
44
40
|
|
|
45
|
-
// headRef
|
|
41
|
+
// baseRef and headRef are optional, have sensible defaults
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
export const DEFAULT_CONFIG = {
|
|
49
45
|
sourceDir: 'src',
|
|
50
46
|
excludePaths: ['node_modules', 'dist', 'build', 'specs', 'coverage'],
|
|
51
|
-
baseRef: '
|
|
52
|
-
headRef: 'HEAD',
|
|
47
|
+
baseRef: 'HEAD~1', // Previous commit
|
|
48
|
+
headRef: 'HEAD', // Current commit
|
|
53
49
|
maxDepth: 3,
|
|
54
50
|
includeTests: false,
|
|
55
51
|
verbose: false,
|