ng-di-graph 0.4.5 → 0.4.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.
Files changed (2) hide show
  1. package/README.md +67 -136
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -8,95 +8,75 @@ A command-line tool that analyzes Angular TypeScript codebases to extract depend
8
8
 
9
9
  **Target Angular Versions:** 17-20
10
10
 
11
- ## Requirements
12
-
13
- - Node.js 20.x LTS (see `.node-version`; e.g., `mise use node@$(cat .node-version)`)
14
- - npm 10+ (ships with Node 20). Use your preferred version manager (mise recommended) to match the pinned runtime before installing dependencies.
15
-
16
- ## Features
17
-
18
- ✨ **Complete Feature Set** - Production-ready dependency graph analysis for Angular applications
19
-
20
- - 🔍 **Dependency Analysis** - Extract DI relationships from `@Injectable`, `@Component`, and `@Directive` classes
21
- - 🎯 **Constructor Injection** - Analyze constructor parameters with type annotations and `@Inject()` tokens
22
- - 🏷️ **Decorator Flags** - Capture `@Optional`, `@Self`, `@SkipSelf`, and `@Host` parameter decorators
23
- - 📊 **Multiple Output Formats** - JSON (machine-readable) and Mermaid (visual flowcharts)
24
- - 🎨 **Entry Point Filtering** - Generate sub-graphs from specific starting nodes
25
- - 🔄 **Bidirectional Analysis** - Explore upstream dependencies, downstream consumers, or both
26
- - 🔁 **Circular Detection** - Automatically detect and report circular dependencies
11
+ ## Prerequisites
12
+ - Node.js 20.x (npm 10+)
13
+ - Angular project targeting v17-20 with a `tsconfig.json` you can point to
27
14
 
28
15
  ## Installation
29
-
30
16
  ```bash
31
17
  npm install -g ng-di-graph
32
18
  ```
33
19
 
34
- ## Usage
35
-
20
+ ## Quick start
36
21
  ```bash
37
- # Target specific files without the --files flag (positional shortcut)
38
- ng-di-graph src/app/app.component.ts --project ./tsconfig.json --format json
22
+ # Analyze the whole project and print JSON
23
+ ng-di-graph --project ./tsconfig.json --format json
39
24
 
40
- # Analyze an Angular project and output JSON
41
- ng-di-graph --project ./my-angular-app/tsconfig.json --format json
25
+ # Generate a Mermaid diagram and save it
26
+ ng-di-graph --project ./tsconfig.json --format mermaid --out docs/di-graph.mmd
42
27
 
43
- # Generate a Mermaid flowchart
44
- ng-di-graph --project ./tsconfig.json --format mermaid --out graph.mmd
28
+ # Target specific files via positional filePaths
29
+ ng-di-graph src/app/app.component.ts src/app/auth.service.ts --project ./tsconfig.json --format json
45
30
 
46
- # Analyze dependencies of a specific component
47
- ng-di-graph --project ./tsconfig.json --entry AppComponent --format mermaid
31
+ # Use the default tsconfig at ./tsconfig.json (no --project needed)
32
+ ng-di-graph src/app --format mermaid --out docs/di-graph.mmd
48
33
 
49
- # Focus on a specific file (similar to eslint targets)
50
- ng-di-graph --project ./tsconfig.json --files src/app/app.component.ts
34
+ # Focus on a symbol and see who depends on it
35
+ ng-di-graph --project ./tsconfig.json --entry UserService --direction upstream
36
+ ```
51
37
 
52
- # Show verbose logging with detailed type resolution
53
- ng-di-graph --project ./tsconfig.json --verbose
38
+ ## Features
54
39
 
55
- # Include parameter decorator flags
56
- ng-di-graph --project ./tsconfig.json --include-decorators
40
+ **Complete Feature Set** - Production-ready dependency graph analysis for Angular applications
57
41
 
58
- # Analyze upstream dependencies (who depends on this?)
59
- ng-di-graph --project ./tsconfig.json --entry UserService --direction upstream
60
- ```
42
+ - 🔍 **Dependency Analysis** - Extract DI relationships from `@Injectable`, `@Component`, and `@Directive` classes
43
+ - 🎯 **Constructor Injection** - Analyze constructor parameters with type annotations and `@Inject()` tokens
44
+ - 🏷️ **Decorator Flags** - Capture `@Optional`, `@Self`, `@SkipSelf`, and `@Host` parameter decorators
45
+ - 📊 **Multiple Output Formats** - JSON (machine-readable) and Mermaid (visual flowcharts)
46
+ - 🎨 **Entry Point Filtering** - Generate sub-graphs from specific starting nodes
47
+ - 🔄 **Bidirectional Analysis** - Explore upstream dependencies, downstream consumers, or both
48
+ - 🔁 **Circular Detection** - Automatically detect and report circular dependencies
61
49
 
62
- ## CLI Reference
50
+ ## Common commands
51
+ - Full project, JSON output:
52
+ `ng-di-graph --project ./tsconfig.json --format json`
53
+ - Mermaid diagram to file:
54
+ `ng-di-graph --project ./tsconfig.json --format mermaid --out docs/di-graph.mmd`
55
+ - Filter to specific symbols:
56
+ `ng-di-graph --project ./tsconfig.json --entry AppComponent`
57
+ - Upstream consumers of a service:
58
+ `ng-di-graph --project ./tsconfig.json --entry UserService --direction upstream`
59
+ - Include decorator flags with verbose logging:
60
+ `ng-di-graph --project ./tsconfig.json --include-decorators --verbose`
61
+
62
+ ## CLI options at a glance
63
63
 
64
64
  ```
65
65
  ng-di-graph [filePaths...] [options]
66
-
67
- Arguments:
68
- filePaths Optional list of files/directories to analyze (alias for --files)
69
-
70
- Options:
71
- -p, --project <path> Path to tsconfig.json (default: ./tsconfig.json)
72
- --files <paths...> Specific file paths to analyze (similar to eslint targets)
73
- -f, --format <format> Output format: json | mermaid (default: json)
74
- -e, --entry <symbol...> Starting nodes for sub-graph filtering
75
- -d, --direction <dir> Filter direction: upstream | downstream | both (default: downstream)
76
- --include-decorators Include @Optional, @Self, @SkipSelf, @Host flags in output
77
- --out <file> Output file path (prints to stdout if omitted)
78
- -v, --verbose Show detailed parsing and resolution information
79
- -h, --help Display help information
80
66
  ```
81
67
 
82
- ### Option Details
83
-
84
- - **`filePaths` (positional)**: Optional positional arguments that act as a shortcut for `--files`,
85
- allowing you to target specific files or directories without the flag; omit to scan the full project
86
- - **`--project`**: Specifies the TypeScript configuration file to use for project analysis (required
87
- when your tsconfig lives outside `./tsconfig.json`)
88
- - **`--files`**: Restrict analysis to one or more specific TypeScript files (relative paths supported)
89
- and merges with positional `filePaths` when both are provided; useful when targeting a subset of your
90
- project similar to ESLint CLI usage
91
- - **`--format`**: Choose between JSON (structured data) or Mermaid (visual diagram)
92
- - **`--entry`**: Filter the graph to show only dependencies related to specified symbols (supports multiple entries)
93
- - **`--direction`**:
94
- - `downstream` (default): Show what the entry depends on
95
- - `upstream`: Show what depends on the entry
96
- - `both`: Show both upstream and downstream dependencies
97
- - **`--include-decorators`**: Add parameter decorator information to edge flags
98
- - **`--out`**: Save output to a file instead of stdout
99
- - **`--verbose`**: Enable detailed logging including timing metrics, memory usage, and type resolution details
68
+ Option | Default | Description
69
+ -- | -- | --
70
+ `filePaths` | none | Positional alias for `--files`; combines with `--files` when both are set.
71
+ `-p, --project <path>` | `./tsconfig.json` | Path to the TypeScript config file to analyze.
72
+ `--files <paths...>` | none | Limit analysis to specific files or directories.
73
+ `-f, --format <format>` | `json` | Output as `json` or `mermaid`.
74
+ `-e, --entry <symbol...>` | none | Start the graph from one or more symbols.
75
+ `-d, --direction <dir>` | `downstream` | `downstream`, `upstream`, or `both` relative to entries.
76
+ `--include-decorators` | `false` | Add `@Optional`, `@Self`, `@SkipSelf`, `@Host` flags to edges.
77
+ `--out <file>` | stdout | Write output to a file.
78
+ `-v, --verbose` | `false` | Show detailed parsing and resolution logs.
79
+ `-h, --help` | `false` | Display CLI help.
100
80
 
101
81
  ## Output Formats
102
82
 
@@ -107,21 +87,26 @@ Options:
107
87
  "nodes": [
108
88
  { "id": "AppComponent", "kind": "component" },
109
89
  { "id": "UserService", "kind": "service" },
110
- { "id": "AuthService", "kind": "service" }
90
+ { "id": "AuthService", "kind": "service" },
91
+ { "id": "Logger", "kind": "service" }
111
92
  ],
112
93
  "edges": [
113
94
  {
114
95
  "from": "AppComponent",
115
- "to": "UserService",
116
- "flags": { "optional": false }
96
+ "to": "UserService"
117
97
  },
118
98
  {
119
99
  "from": "UserService",
120
100
  "to": "AuthService",
121
- "flags": { "optional": true, "self": false }
101
+ "flags": { "optional": true, "self": false, "skipSelf": false, "host": false }
102
+ },
103
+ {
104
+ "from": "AuthService",
105
+ "to": "Logger",
106
+ "flags": { "optional": false, "self": false, "skipSelf": false, "host": false }
122
107
  }
123
108
  ],
124
- "circularDependencies": []
109
+ "circularDependencies": [["UserService", "AuthService", "UserService"]]
125
110
  }
126
111
  ```
127
112
 
@@ -145,66 +130,18 @@ flowchart LR
145
130
  UserService --> AuthService
146
131
  ```
147
132
 
148
- Mermaid diagrams can be:
149
- - Rendered in GitHub/GitLab markdown
150
- - Viewed in the [Mermaid Live Editor](https://mermaid.live/)
151
- - Embedded in documentation sites
152
- - Converted to images using CLI tools
153
-
154
- ## Use Cases
155
-
156
- ### 1. Test Planning
157
- Quickly identify all dependencies of a component to plan test mocks:
158
- ```bash
159
- ng-di-graph --project ./tsconfig.json --entry MyComponent --format json
160
- ```
161
-
162
- ### 2. Impact Analysis
163
- Find all consumers of a service before making breaking changes:
164
- ```bash
165
- ng-di-graph --project ./tsconfig.json --entry UserService --direction upstream
166
- ```
133
+ Mermaid diagrams can be rendered in GitHub/GitLab markdown, viewed in the [Mermaid Live Editor](https://mermaid.live/), or converted to images with CLI tools.
167
134
 
168
- ### 3. Documentation
169
- Generate visual dependency diagrams for README or design docs:
170
- ```bash
171
- ng-di-graph --project ./tsconfig.json --format mermaid --out docs/architecture.mmd
172
- ```
173
-
174
- ### 4. Circular Dependency Detection
175
- Identify circular dependencies in your DI graph:
176
- ```bash
177
- ng-di-graph --project ./tsconfig.json --verbose
178
- # Check the "circularDependencies" array in output
179
- ```
180
-
181
- ### 5. Debugging Type Issues
182
- Investigate type resolution problems with verbose logging:
183
- ```bash
184
- ng-di-graph --project ./tsconfig.json --verbose
185
- # Shows detailed type resolution and warnings
186
- ```
135
+ ## Use cases
136
+ - Test planning: surface dependencies to decide what to mock.
137
+ - Impact analysis: list consumers before changing a service.
138
+ - Documentation: add Mermaid diagrams to READMEs or architecture docs.
187
139
 
188
140
  ## Release workflow
141
+ Releases are automated via Release Please; tag pushes run lint → typecheck → test → build → pack → publish. Maintainer runbook: see `docs/release/ci-publish.md`.
189
142
 
190
- - PR-driven releases via Release Please; release PR merges tag `vX.Y.Z`.
191
- - Tag pushes trigger publish workflow: lint typecheck test build pack → publish with provenance.
192
- - Maintainer runbook: see docs/release/ci-publish.md.
193
-
194
- ## Error Handling
195
-
196
- The tool provides graceful error handling:
197
-
198
- - **File Parsing Failures** - Skips unparseable files and continues processing
199
- - **Type Resolution Issues** - Logs warnings for `any`/`unknown` types
200
- - **Missing tsconfig.json** - Clear error message with suggestion
201
- - **Invalid CLI Arguments** - Help message with usage examples
202
- - **Circular Dependencies** - Detected and reported without blocking analysis
203
- - **Memory Constraints** - Suggestions for chunking large codebases
204
-
205
- Exit codes:
206
- - `0` - Success
207
- - `1` - Fatal error (invalid config, parsing failure, etc.)
143
+ ## Error handling
144
+ The CLI reports clear failures and continues past unparseable files; rerun with `--verbose` for detailed logs.
208
145
 
209
146
  ## Contributing
210
147
 
@@ -213,9 +150,3 @@ Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md)
213
150
  ## License
214
151
 
215
152
  MIT License - See [LICENSE](LICENSE) file for details
216
-
217
- ## Version
218
-
219
- Current version: **0.1.0**
220
-
221
- All core features are complete and production-ready.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-di-graph",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Angular DI dependency graph CLI tool",
5
5
  "homepage": "https://github.com/m-yoshiro/ng-di-graph/",
6
6
  "repository": {
@@ -48,7 +48,7 @@
48
48
  "@types/node": "^25.0.0",
49
49
  "@vitest/coverage-v8": "^4.0.13",
50
50
  "rimraf": "^6.1.2",
51
- "tsdown": "^0.17.0",
51
+ "tsdown": "^0.18.0",
52
52
  "tsx": "^4.8.1",
53
53
  "vitest": "^4.0.10"
54
54
  },