depgraph-core 1.5.0 β 1.5.2
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/README.md +41 -39
- package/depgraph-output.json +7138 -2482
- package/depgraph.js +1880 -5
- package/docs/README.md +1 -0
- package/docs/language-registry.md +15 -14
- package/docs/parser-conventions.md +194 -0
- package/docs/stage-impact.md +4 -4
- package/docs/stage-output.md +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DepGraph Core
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/depgraph-core)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
**DepGraph Core** is a powerful static analysis CLI that maps code dependencies and simulates the ripple-effect impact of changes across multi-language codebases β supporting JavaScript, TypeScript, Python, Go, C#, Java, Kotlin, PHP, Ruby, and
|
|
6
|
+
**DepGraph Core** is a powerful static analysis CLI that maps code dependencies and simulates the ripple-effect impact of changes across multi-language codebases β supporting JavaScript, TypeScript, Python, Go, C#, Java, Kotlin, PHP, Ruby, Swift, and Rust. By parsing imports, exports, functions, classes, interfaces, and methods, DepGraph constructs a comprehensive dependency graph, computes centrality metrics, and generates impact simulations β helping you prevent regression bugs in large systems.
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Key Features
|
|
11
11
|
|
|
12
|
-
-
|
|
12
|
+
- **Multi-Language AST & Regex Code Parsing**: Comprehensive native extractors for **11 languages**:
|
|
13
13
|
- **JavaScript / TypeScript / React** (`.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs`)
|
|
14
14
|
- **Python** (`.py`)
|
|
15
15
|
- **Go** (`.go`)
|
|
@@ -19,18 +19,19 @@
|
|
|
19
19
|
- **PHP** (`.php`)
|
|
20
20
|
- **Ruby** (`.rb`)
|
|
21
21
|
- **Swift** (`.swift`)
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
22
|
+
- **Rust** (`.rs`)
|
|
23
|
+
- **Dependency Graph Reconstruction**: Resolves local imports, aliases, namespace packages, and cross-file relationships to build a full topology map of your codebase.
|
|
24
|
+
- **Metrics & Centrality Analysis**: Calculates in-degree, out-degree, and centrality scores for every entity to automatically identify **Critical Nodes**.
|
|
25
|
+
- **Impact Simulation Engine**: Runs a reverse BFS to model the cascading impact of changing a specific function or class. Generates a risk score, lists affected nodes, and provides an actionable testing plan.
|
|
26
|
+
- **Git Diff Integration**: Automatically detects changed entities from your git history (uncommitted changes, a specific commit, or a branch comparison) across all supported languages and runs impact simulation on every changed symbol.
|
|
27
|
+
- **Rich CLI Interface**: Colorized, human-readable output with a `--no-color` flag for CI/CD pipelines.
|
|
28
|
+
- **Detailed JSON Output**: Exports a comprehensive report containing graph structure, metrics, and simulation results.
|
|
28
29
|
|
|
29
30
|
---
|
|
30
31
|
|
|
31
|
-
##
|
|
32
|
+
## Supported Languages
|
|
32
33
|
|
|
33
|
-
DepGraph Core provides native parsing and symbol extraction across
|
|
34
|
+
DepGraph Core provides native parsing and symbol extraction across 11 major programming languages:
|
|
34
35
|
|
|
35
36
|
| Language | Extensions | Extracted Entities | Import & Resolution Features |
|
|
36
37
|
| :--- | :--- | :--- | :--- |
|
|
@@ -43,10 +44,11 @@ DepGraph Core provides native parsing and symbol extraction across 10 major prog
|
|
|
43
44
|
| **PHP** | `.php` | Classes (abstract, final), Interfaces, Traits, Enums, Functions, Methods | Namespaces, single & grouped `use` statements, `use ... as` aliases, `require`/`include` file paths |
|
|
44
45
|
| **Ruby** | `.rb` | Classes, Modules, Instance methods, Class methods (`def self.`), `attr_accessor`/`reader`/`writer` | `require`, `require_relative`, `load`, `include`, `extend`, `prepend` |
|
|
45
46
|
| **Swift** | `.swift` | Classes, Structs, Enums, Protocols, Actors, Extensions (including `where` constraints), Functions, Initializers | Module imports, sub-module imports, kind-specifier imports (`import class/func/...`) |
|
|
47
|
+
| **Rust** | `.rs` | Functions, Structs (named & tuple fields), Enums (tuple & struct variants), Traits, Impl blocks, Methods | Single & grouped `use` statements, `crate::`/`super::`/`self::` modules, aliases (`as`) |
|
|
46
48
|
|
|
47
49
|
---
|
|
48
50
|
|
|
49
|
-
##
|
|
51
|
+
## Installation
|
|
50
52
|
|
|
51
53
|
### Global (recommended)
|
|
52
54
|
```bash
|
|
@@ -60,7 +62,7 @@ npx depgraph-core <projectDir> [options]
|
|
|
60
62
|
|
|
61
63
|
---
|
|
62
64
|
|
|
63
|
-
##
|
|
65
|
+
## CLI Usage
|
|
64
66
|
|
|
65
67
|
```bash
|
|
66
68
|
depgraph <projectDir> [options]
|
|
@@ -87,7 +89,7 @@ depgraph <projectDir> [options]
|
|
|
87
89
|
|
|
88
90
|
---
|
|
89
91
|
|
|
90
|
-
##
|
|
92
|
+
## Examples
|
|
91
93
|
|
|
92
94
|
### Standard Usage
|
|
93
95
|
|
|
@@ -113,11 +115,11 @@ depgraph ./src --no-color --output ./ci/depgraph.json
|
|
|
113
115
|
|
|
114
116
|
---
|
|
115
117
|
|
|
116
|
-
###
|
|
118
|
+
### Git Diff Integration
|
|
117
119
|
|
|
118
120
|
`--git-impact` automatically reads your git diff, detects every function or class that changed, and runs an impact simulation for each one β no need to manually select a target entity.
|
|
119
121
|
|
|
120
|
-
####
|
|
122
|
+
#### How It Works under the Hood
|
|
121
123
|
|
|
122
124
|
1. **Git Diff Execution**: Runs the appropriate git command depending on the mode:
|
|
123
125
|
- **Uncommitted Changes**: `git diff HEAD` (detects staged & unstaged changes).
|
|
@@ -128,7 +130,7 @@ depgraph ./src --no-color --output ./ci/depgraph.json
|
|
|
128
130
|
4. **Fallback Parsers**: Contains built-in fallback parser logic for popular OOP languages like Java (`.java`) and C# (`.cs`) to extract method signatures.
|
|
129
131
|
5. **Change Description Generation**: Automatically analyzes added/removed lines in the change hunk to build descriptive labels (e.g. `getUserById: 3 line(s) changed to 2 new line(s)`).
|
|
130
132
|
|
|
131
|
-
####
|
|
133
|
+
#### Git Commands Reference
|
|
132
134
|
|
|
133
135
|
| Mode | CLI Command | Under-the-hood Command | Description |
|
|
134
136
|
| :--- | :--- | :--- | :--- |
|
|
@@ -137,7 +139,7 @@ depgraph ./src --no-color --output ./ci/depgraph.json
|
|
|
137
139
|
| **Specific Commit** | `depgraph ./src --git-impact --commit <sha>` | `git diff <sha>~1 <sha>` | Analyze any commit by its SHA |
|
|
138
140
|
| **Branch Comparison** | `depgraph ./src --git-impact --from main --to feature/auth` | `git diff main...feature/auth` | Compare two branches |
|
|
139
141
|
|
|
140
|
-
####
|
|
142
|
+
#### CLI Output Example
|
|
141
143
|
|
|
142
144
|
Running `--git-impact` displays a colorized report of detected entities and runs an impact simulation for each one:
|
|
143
145
|
|
|
@@ -146,14 +148,14 @@ Running `--git-impact` displays a colorized report of detected entities and runs
|
|
|
146
148
|
DepGraph v1.0.0
|
|
147
149
|
βββββββββββββββββββββββββββββββββββββββββ
|
|
148
150
|
|
|
149
|
-
|
|
151
|
+
Scanning .
|
|
150
152
|
|
|
151
|
-
|
|
153
|
+
Graph Summary
|
|
152
154
|
Files : 27
|
|
153
155
|
Nodes : 76
|
|
154
156
|
Edges : 252
|
|
155
157
|
|
|
156
|
-
|
|
158
|
+
Reading git diff...
|
|
157
159
|
|
|
158
160
|
Found 2 changed entity(s):
|
|
159
161
|
β slugify (src/languages/javascript.ts)
|
|
@@ -163,7 +165,7 @@ Running impact simulation...
|
|
|
163
165
|
|
|
164
166
|
ββββββββββββββββββββββββββββββββββββββββββ
|
|
165
167
|
|
|
166
|
-
|
|
168
|
+
Impact Simulation
|
|
167
169
|
Target : slugify__javascript
|
|
168
170
|
Change : slugify: 16 line(s) added
|
|
169
171
|
Risk Score : 0
|
|
@@ -171,22 +173,22 @@ Running impact simulation...
|
|
|
171
173
|
|
|
172
174
|
β No affected nodes found
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
Testing Plan
|
|
175
177
|
β Test slugify directly after making changes
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
Recommendations
|
|
178
180
|
β Standard PR process is sufficient
|
|
179
181
|
β Unit tests for the changed node are enough
|
|
180
182
|
|
|
181
183
|
ββββββββββββββββββββββββββββββββββββββββββ
|
|
182
184
|
|
|
183
|
-
|
|
185
|
+
Impact Simulation
|
|
184
186
|
Target : LanguageParser__registry
|
|
185
187
|
Change : LanguageParser: 6 line(s) added
|
|
186
188
|
Risk Score : 100
|
|
187
189
|
Risk Level : CRITICAL
|
|
188
190
|
|
|
189
|
-
|
|
191
|
+
Affected Nodes (3)
|
|
190
192
|
|
|
191
193
|
[CRITICAL] extractEntities
|
|
192
194
|
file : src/languages/go.ts
|
|
@@ -206,27 +208,27 @@ Running impact simulation...
|
|
|
206
208
|
action : Update extractExports to handle the new interface of LanguageParser
|
|
207
209
|
breaking: YES
|
|
208
210
|
|
|
209
|
-
|
|
211
|
+
Testing Plan
|
|
210
212
|
β Test LanguageParser directly after making changes
|
|
211
213
|
β Regression test extractEntities β direct dependent
|
|
212
214
|
β Regression test extractImports β direct dependent
|
|
213
215
|
β Regression test extractExports β direct dependent
|
|
214
216
|
β Run full test suite β 3 nodes affected
|
|
215
217
|
|
|
216
|
-
|
|
218
|
+
Recommendations
|
|
217
219
|
β Full team review required before merging
|
|
218
220
|
β Consider a phased rollout
|
|
219
221
|
β Run full regression test suite
|
|
220
222
|
β 3 breaking change(s) must be updated before deploying
|
|
221
223
|
|
|
222
|
-
|
|
224
|
+
Output written to ./depgraph-output.json
|
|
223
225
|
```
|
|
224
226
|
|
|
225
|
-
**Supported languages for diff parsing:** All
|
|
227
|
+
**Supported languages for diff parsing:** All 11 languages (JavaScript/TypeScript, Python, Go, C#, Java, Kotlin, PHP, Ruby, Swift, and Rust) are fully supported via shared entity pattern registries and fallbacks.
|
|
226
228
|
|
|
227
229
|
---
|
|
228
230
|
|
|
229
|
-
##
|
|
231
|
+
## Impact Simulation Mechanics
|
|
230
232
|
|
|
231
233
|
When running `--impact` or `--git-impact`, the tool performs:
|
|
232
234
|
|
|
@@ -238,14 +240,14 @@ When running `--impact` or `--git-impact`, the tool performs:
|
|
|
238
240
|
- Number of medium/low-impact nodes
|
|
239
241
|
- The target node's in-degree
|
|
240
242
|
4. **Risk Level Mapping**:
|
|
241
|
-
-
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
243
|
+
- **CRITICAL** (β₯ 75): Comprehensive review, phased rollout, full regression testing.
|
|
244
|
+
- **HIGH** (50β74): Tech lead review, feature flag recommended.
|
|
245
|
+
- **MEDIUM** (25β49): Standard peer review, targeted module testing.
|
|
246
|
+
- **LOW** (< 25): Standard PR process is sufficient.
|
|
245
247
|
|
|
246
248
|
---
|
|
247
249
|
|
|
248
|
-
##
|
|
250
|
+
## Output JSON Schema
|
|
249
251
|
|
|
250
252
|
```json
|
|
251
253
|
{
|
|
@@ -303,7 +305,7 @@ When running `--impact` or `--git-impact`, the tool performs:
|
|
|
303
305
|
|
|
304
306
|
---
|
|
305
307
|
|
|
306
|
-
##
|
|
308
|
+
## Development & Contribution
|
|
307
309
|
|
|
308
310
|
### Setup
|
|
309
311
|
```bash
|
|
@@ -324,6 +326,6 @@ npm install
|
|
|
324
326
|
|
|
325
327
|
---
|
|
326
328
|
|
|
327
|
-
##
|
|
329
|
+
## License
|
|
328
330
|
|
|
329
331
|
This project is licensed under the MIT License β see the [LICENSE](LICENSE) file for details.
|