@nexus-ioc/graph-analyzer 0.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/CHANGELOG.md +112 -0
- package/LICENSE +21 -0
- package/README.md +742 -0
- package/dist/analyzer/circular-dependency-detector.d.ts +94 -0
- package/dist/analyzer/circular-dependency-detector.js +203 -0
- package/dist/analyzer/circular-dependency-detector.js.map +1 -0
- package/dist/analyzer/module-depth-analyzer.d.ts +117 -0
- package/dist/analyzer/module-depth-analyzer.js +221 -0
- package/dist/analyzer/module-depth-analyzer.js.map +1 -0
- package/dist/analyzer/provider-scope-analyzer.d.ts +91 -0
- package/dist/analyzer/provider-scope-analyzer.js +137 -0
- package/dist/analyzer/provider-scope-analyzer.js.map +1 -0
- package/dist/analyzer/unused-provider-detector.d.ts +73 -0
- package/dist/analyzer/unused-provider-detector.js +147 -0
- package/dist/analyzer/unused-provider-detector.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +537 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/config-loader.d.ts +27 -0
- package/dist/config/config-loader.js +205 -0
- package/dist/config/config-loader.js.map +1 -0
- package/dist/config/config-schema.d.ts +83 -0
- package/dist/config/config-schema.js +97 -0
- package/dist/config/config-schema.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/graph-output.interface.d.ts +126 -0
- package/dist/interfaces/graph-output.interface.js +3 -0
- package/dist/interfaces/graph-output.interface.js.map +1 -0
- package/dist/interfaces/providers.interface.d.ts +10 -0
- package/dist/interfaces/providers.interface.js +3 -0
- package/dist/interfaces/providers.interface.js.map +1 -0
- package/dist/parser/dependency-extractor.d.ts +88 -0
- package/dist/parser/dependency-extractor.js +334 -0
- package/dist/parser/dependency-extractor.js.map +1 -0
- package/dist/parser/parse-entry-file.d.ts +15 -0
- package/dist/parser/parse-entry-file.js +46 -0
- package/dist/parser/parse-entry-file.js.map +1 -0
- package/dist/parser/parse-imports.d.ts +15 -0
- package/dist/parser/parse-imports.js +65 -0
- package/dist/parser/parse-imports.js.map +1 -0
- package/dist/parser/parse-ns-module.d.ts +39 -0
- package/dist/parser/parse-ns-module.js +122 -0
- package/dist/parser/parse-ns-module.js.map +1 -0
- package/dist/parser/parse-provider.d.ts +2 -0
- package/dist/parser/parse-provider.js +7 -0
- package/dist/parser/parse-provider.js.map +1 -0
- package/dist/parser/parse-ts-config.d.ts +10 -0
- package/dist/parser/parse-ts-config.js +40 -0
- package/dist/parser/parse-ts-config.js.map +1 -0
- package/dist/parser/parser-rec.d.ts +1 -0
- package/dist/parser/parser-rec.js +52 -0
- package/dist/parser/parser-rec.js.map +1 -0
- package/dist/parser/parser.d.ts +1 -0
- package/dist/parser/parser.js +61 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/provider/class-parser.d.ts +20 -0
- package/dist/parser/provider/class-parser.js +137 -0
- package/dist/parser/provider/class-parser.js.map +1 -0
- package/dist/parser/provider/providers-parser.d.ts +9 -0
- package/dist/parser/provider/providers-parser.js +32 -0
- package/dist/parser/provider/providers-parser.js.map +1 -0
- package/dist/parser/provider/use-class-parser.d.ts +25 -0
- package/dist/parser/provider/use-class-parser.js +161 -0
- package/dist/parser/provider/use-class-parser.js.map +1 -0
- package/dist/parser/provider/use-factory-parser.d.ts +15 -0
- package/dist/parser/provider/use-factory-parser.js +53 -0
- package/dist/parser/provider/use-factory-parser.js.map +1 -0
- package/dist/parser/provider/use-value-parser.d.ts +13 -0
- package/dist/parser/provider/use-value-parser.js +41 -0
- package/dist/parser/provider/use-value-parser.js.map +1 -0
- package/dist/parser/rules.d.ts +10 -0
- package/dist/parser/rules.js +37 -0
- package/dist/parser/rules.js.map +1 -0
- package/dist/utils/error-formatter.d.ts +27 -0
- package/dist/utils/error-formatter.js +177 -0
- package/dist/utils/error-formatter.js.map +1 -0
- package/dist/utils/validator.d.ts +45 -0
- package/dist/utils/validator.js +252 -0
- package/dist/utils/validator.js.map +1 -0
- package/dist/visualize/generator.d.ts +26 -0
- package/dist/visualize/generator.js +75 -0
- package/dist/visualize/generator.js.map +1 -0
- package/dist/visualize/graph-analyzer.d.ts +126 -0
- package/dist/visualize/graph-analyzer.js +199 -0
- package/dist/visualize/graph-analyzer.js.map +1 -0
- package/dist/visualize/html-generator.d.ts +71 -0
- package/dist/visualize/html-generator.js +1312 -0
- package/dist/visualize/html-generator.js.map +1 -0
- package/dist/visualize/json-formatter.d.ts +106 -0
- package/dist/visualize/json-formatter.js +252 -0
- package/dist/visualize/json-formatter.js.map +1 -0
- package/docs/API_REFERENCE.md +747 -0
- package/docs/ARCHITECTURE.md +486 -0
- package/docs/CLI_GUIDE.md +576 -0
- package/docs/HTML_VISUALIZATION.md +365 -0
- package/package.json +85 -0
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
# CLI Usage Guide
|
|
2
|
+
|
|
3
|
+
Complete guide to using the Nexus IoC Graph Analyzer command-line interface.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Basic Usage](#basic-usage)
|
|
9
|
+
- [Command Reference](#command-reference)
|
|
10
|
+
- [Output Formats](#output-formats)
|
|
11
|
+
- [Configuration](#configuration)
|
|
12
|
+
- [Examples](#examples)
|
|
13
|
+
- [Troubleshooting](#troubleshooting)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### Local Installation (Recommended)
|
|
18
|
+
|
|
19
|
+
Install as a development dependency in your project:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --save-dev graph-analyzer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then use via npm scripts or npx:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Via npx
|
|
29
|
+
npx graph-analyzer src/main.ts
|
|
30
|
+
|
|
31
|
+
# Via npm script (add to package.json)
|
|
32
|
+
{
|
|
33
|
+
"scripts": {
|
|
34
|
+
"analyze": "graph-analyzer src/main.ts"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
npm run analyze
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Global Installation
|
|
41
|
+
|
|
42
|
+
Install globally to use from anywhere:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install -g graph-analyzer
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Then use directly:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
graph-analyzer src/main.ts
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Basic Usage
|
|
55
|
+
|
|
56
|
+
### Simplest Command
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
graph-analyzer src/main.ts
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This will:
|
|
63
|
+
1. Analyze `src/main.ts` as the entry point
|
|
64
|
+
2. Look for `tsconfig.json` in the current directory
|
|
65
|
+
3. Generate `graph.json` with dependency data
|
|
66
|
+
4. Generate `graph.png` with visualization
|
|
67
|
+
|
|
68
|
+
### Common Patterns
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# JSON output only
|
|
72
|
+
graph-analyzer -f json src/main.ts
|
|
73
|
+
|
|
74
|
+
# PNG output only
|
|
75
|
+
graph-analyzer -f png src/main.ts
|
|
76
|
+
|
|
77
|
+
# Custom output path
|
|
78
|
+
graph-analyzer -o output/dependencies.json src/main.ts
|
|
79
|
+
|
|
80
|
+
# Custom tsconfig
|
|
81
|
+
graph-analyzer -c tsconfig.build.json src/main.ts
|
|
82
|
+
|
|
83
|
+
# All options combined
|
|
84
|
+
graph-analyzer -c config/tsconfig.json -f json -o dist/graph.json src/main.ts
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Command Reference
|
|
88
|
+
|
|
89
|
+
### Syntax
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
graph-analyzer [options] <entry-file>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Arguments
|
|
96
|
+
|
|
97
|
+
#### `<entry-file>` (Required)
|
|
98
|
+
|
|
99
|
+
Path to your application's entry point file.
|
|
100
|
+
|
|
101
|
+
**Examples**:
|
|
102
|
+
```bash
|
|
103
|
+
graph-analyzer src/main.ts
|
|
104
|
+
graph-analyzer ./app/index.ts
|
|
105
|
+
graph-analyzer packages/server/src/bootstrap.ts
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Requirements**:
|
|
109
|
+
- Must be a TypeScript file (.ts)
|
|
110
|
+
- Must contain a Nexus IoC bootstrap call
|
|
111
|
+
- Must be accessible from current directory
|
|
112
|
+
|
|
113
|
+
### Options
|
|
114
|
+
|
|
115
|
+
#### `-c, --config <path>`
|
|
116
|
+
|
|
117
|
+
Specify path to tsconfig.json file.
|
|
118
|
+
|
|
119
|
+
**Default**: `./tsconfig.json`
|
|
120
|
+
|
|
121
|
+
**Examples**:
|
|
122
|
+
```bash
|
|
123
|
+
# Use tsconfig in subdirectory
|
|
124
|
+
graph-analyzer -c config/tsconfig.json src/main.ts
|
|
125
|
+
|
|
126
|
+
# Use build-specific config
|
|
127
|
+
graph-analyzer -c tsconfig.build.json src/main.ts
|
|
128
|
+
|
|
129
|
+
# Absolute path
|
|
130
|
+
graph-analyzer -c /path/to/tsconfig.json src/main.ts
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Behavior**:
|
|
134
|
+
- If file not found, searches parent directories
|
|
135
|
+
- If still not found, uses default TypeScript options
|
|
136
|
+
- Path aliases from tsconfig are respected
|
|
137
|
+
|
|
138
|
+
#### `-o, --output <path>`
|
|
139
|
+
|
|
140
|
+
Specify output file path.
|
|
141
|
+
|
|
142
|
+
**Default**:
|
|
143
|
+
- `./graph.json` for JSON format
|
|
144
|
+
- `./graph.png` for PNG format
|
|
145
|
+
|
|
146
|
+
**Examples**:
|
|
147
|
+
```bash
|
|
148
|
+
# Custom JSON output
|
|
149
|
+
graph-analyzer -f json -o dependencies.json src/main.ts
|
|
150
|
+
|
|
151
|
+
# Custom PNG output
|
|
152
|
+
graph-analyzer -f png -o docs/architecture.png src/main.ts
|
|
153
|
+
|
|
154
|
+
# Output to subdirectory
|
|
155
|
+
graph-analyzer -o output/graph.json src/main.ts
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Notes**:
|
|
159
|
+
- Directory must exist (not created automatically)
|
|
160
|
+
- Existing files will be overwritten
|
|
161
|
+
- For "both" format, creates two files with appropriate extensions
|
|
162
|
+
|
|
163
|
+
#### `-f, --format <format>`
|
|
164
|
+
|
|
165
|
+
Specify output format.
|
|
166
|
+
|
|
167
|
+
**Options**: `json`, `png`, `both`
|
|
168
|
+
|
|
169
|
+
**Default**: `both`
|
|
170
|
+
|
|
171
|
+
**Examples**:
|
|
172
|
+
```bash
|
|
173
|
+
# JSON only
|
|
174
|
+
graph-analyzer -f json src/main.ts
|
|
175
|
+
|
|
176
|
+
# PNG only
|
|
177
|
+
graph-analyzer -f png src/main.ts
|
|
178
|
+
|
|
179
|
+
# Both formats (default)
|
|
180
|
+
graph-analyzer -f both src/main.ts
|
|
181
|
+
graph-analyzer src/main.ts # Same as above
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Format Details**:
|
|
185
|
+
|
|
186
|
+
| Format | Output | Use Case |
|
|
187
|
+
|--------|--------|----------|
|
|
188
|
+
| `json` | Structured JSON data | Programmatic analysis, CI/CD, documentation generation |
|
|
189
|
+
| `png` | Visual graph image | Documentation, presentations, quick overview |
|
|
190
|
+
| `both` | JSON + PNG | Complete analysis with both data and visualization |
|
|
191
|
+
|
|
192
|
+
#### `-h, --help`
|
|
193
|
+
|
|
194
|
+
Display help message and exit.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
graph-analyzer --help
|
|
198
|
+
graph-analyzer -h
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Output**:
|
|
202
|
+
```
|
|
203
|
+
Nexus IoC Graph Analyzer
|
|
204
|
+
|
|
205
|
+
Analyze and visualize dependency injection graphs in Nexus IoC applications.
|
|
206
|
+
|
|
207
|
+
Usage:
|
|
208
|
+
graph-analyzer [options] <entry-file>
|
|
209
|
+
|
|
210
|
+
Arguments:
|
|
211
|
+
entry-file Path to application entry point (e.g., src/main.ts)
|
|
212
|
+
|
|
213
|
+
Options:
|
|
214
|
+
-c, --config <path> Path to tsconfig.json (default: ./tsconfig.json)
|
|
215
|
+
-o, --output <path> Output file path (default: ./graph.json or ./graph.png)
|
|
216
|
+
-f, --format <format> Output format: json, png, or both (default: both)
|
|
217
|
+
-h, --help Display this help message
|
|
218
|
+
-v, --version Display version number
|
|
219
|
+
|
|
220
|
+
Examples:
|
|
221
|
+
graph-analyzer src/main.ts
|
|
222
|
+
graph-analyzer -f json -o output.json src/main.ts
|
|
223
|
+
graph-analyzer -c tsconfig.build.json src/main.ts
|
|
224
|
+
|
|
225
|
+
For more information, visit: https://github.com/Isqanderm/ioc
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### `-v, --version`
|
|
229
|
+
|
|
230
|
+
Display version number and exit.
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
graph-analyzer --version
|
|
234
|
+
graph-analyzer -v
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Output**:
|
|
238
|
+
```
|
|
239
|
+
0.0.1
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Output Formats
|
|
243
|
+
|
|
244
|
+
### JSON Format
|
|
245
|
+
|
|
246
|
+
Structured data representation of the dependency graph.
|
|
247
|
+
|
|
248
|
+
**File**: `graph.json` (or custom path)
|
|
249
|
+
|
|
250
|
+
**Structure**:
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"modules": [...], // Array of module information
|
|
254
|
+
"providers": [...], // Array of provider information
|
|
255
|
+
"metadata": {...} // Analysis metadata
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Use Cases**:
|
|
260
|
+
- Automated analysis in CI/CD pipelines
|
|
261
|
+
- Generating documentation
|
|
262
|
+
- Detecting circular dependencies
|
|
263
|
+
- Finding unused providers
|
|
264
|
+
- Validating architecture rules
|
|
265
|
+
|
|
266
|
+
**Example Analysis**:
|
|
267
|
+
```bash
|
|
268
|
+
# Generate JSON
|
|
269
|
+
graph-analyzer -f json src/main.ts
|
|
270
|
+
|
|
271
|
+
# Analyze with jq
|
|
272
|
+
cat graph.json | jq '.providers | length' # Count providers
|
|
273
|
+
cat graph.json | jq '.modules[] | select(.isGlobal == true)' # Find global modules
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### PNG Format
|
|
277
|
+
|
|
278
|
+
Visual graph representation using Graphviz.
|
|
279
|
+
|
|
280
|
+
**File**: `graph.png` (or custom path)
|
|
281
|
+
|
|
282
|
+
**Visual Elements**:
|
|
283
|
+
- **Nodes**: Modules
|
|
284
|
+
- **Edges**: Dependencies
|
|
285
|
+
- **Colors**: Different provider types
|
|
286
|
+
- **Shapes**: Global vs regular modules
|
|
287
|
+
|
|
288
|
+
**Use Cases**:
|
|
289
|
+
- Documentation
|
|
290
|
+
- Architecture presentations
|
|
291
|
+
- Onboarding new developers
|
|
292
|
+
- Quick visual overview
|
|
293
|
+
|
|
294
|
+
**Requirements**:
|
|
295
|
+
- Graphviz must be installed on the system
|
|
296
|
+
- `dot` command must be in PATH
|
|
297
|
+
|
|
298
|
+
**Install Graphviz**:
|
|
299
|
+
```bash
|
|
300
|
+
# macOS
|
|
301
|
+
brew install graphviz
|
|
302
|
+
|
|
303
|
+
# Ubuntu/Debian
|
|
304
|
+
sudo apt-get install graphviz
|
|
305
|
+
|
|
306
|
+
# Windows
|
|
307
|
+
choco install graphviz
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Both Formats
|
|
311
|
+
|
|
312
|
+
Generate both JSON and PNG outputs.
|
|
313
|
+
|
|
314
|
+
**Files**: `graph.json` and `graph.png`
|
|
315
|
+
|
|
316
|
+
**Example**:
|
|
317
|
+
```bash
|
|
318
|
+
graph-analyzer src/main.ts
|
|
319
|
+
# Creates:
|
|
320
|
+
# - ./graph.json
|
|
321
|
+
# - ./graph.png
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Configuration
|
|
325
|
+
|
|
326
|
+
### TypeScript Configuration
|
|
327
|
+
|
|
328
|
+
The analyzer respects your tsconfig.json settings:
|
|
329
|
+
|
|
330
|
+
**Path Aliases**:
|
|
331
|
+
```json
|
|
332
|
+
{
|
|
333
|
+
"compilerOptions": {
|
|
334
|
+
"baseUrl": "./src",
|
|
335
|
+
"paths": {
|
|
336
|
+
"@app/*": ["app/*"],
|
|
337
|
+
"@shared/*": ["shared/*"]
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
These aliases are resolved when analyzing imports.
|
|
344
|
+
|
|
345
|
+
**Compiler Options**:
|
|
346
|
+
- `target`: Affects AST parsing
|
|
347
|
+
- `module`: Affects module resolution
|
|
348
|
+
- `experimentalDecorators`: Required for legacy decorators
|
|
349
|
+
- `emitDecoratorMetadata`: Not required (static analysis)
|
|
350
|
+
|
|
351
|
+
### Project Structure
|
|
352
|
+
|
|
353
|
+
**Monorepo**:
|
|
354
|
+
```bash
|
|
355
|
+
# Analyze specific package
|
|
356
|
+
cd packages/api
|
|
357
|
+
graph-analyzer -c tsconfig.json src/main.ts
|
|
358
|
+
|
|
359
|
+
# Or from root
|
|
360
|
+
graph-analyzer -c packages/api/tsconfig.json packages/api/src/main.ts
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Multiple Entry Points**:
|
|
364
|
+
```bash
|
|
365
|
+
# Analyze different entry points
|
|
366
|
+
graph-analyzer -o api-graph.json src/api/main.ts
|
|
367
|
+
graph-analyzer -o worker-graph.json src/worker/main.ts
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Examples
|
|
371
|
+
|
|
372
|
+
### Example 1: Basic Analysis
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
graph-analyzer src/main.ts
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Output**:
|
|
379
|
+
```
|
|
380
|
+
Analyzing: /path/to/src/main.ts
|
|
381
|
+
Using tsconfig: /path/to/tsconfig.json
|
|
382
|
+
JSON output written to: ./graph.json
|
|
383
|
+
PNG output written to: ./graph.png
|
|
384
|
+
|
|
385
|
+
Analysis complete!
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Example 2: CI/CD Integration
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
#!/bin/bash
|
|
392
|
+
# analyze-dependencies.sh
|
|
393
|
+
|
|
394
|
+
# Generate JSON for analysis
|
|
395
|
+
graph-analyzer -f json -o dist/dependencies.json src/main.ts
|
|
396
|
+
|
|
397
|
+
# Check for circular dependencies
|
|
398
|
+
if grep -q "circular" dist/dependencies.json; then
|
|
399
|
+
echo "Error: Circular dependencies detected!"
|
|
400
|
+
exit 1
|
|
401
|
+
fi
|
|
402
|
+
|
|
403
|
+
# Count providers
|
|
404
|
+
PROVIDER_COUNT=$(cat dist/dependencies.json | jq '.providers | length')
|
|
405
|
+
echo "Total providers: $PROVIDER_COUNT"
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Example 3: Documentation Generation
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# Generate PNG for docs
|
|
412
|
+
graph-analyzer -f png -o docs/architecture/dependency-graph.png src/main.ts
|
|
413
|
+
|
|
414
|
+
# Generate JSON for automated docs
|
|
415
|
+
graph-analyzer -f json -o docs/data/dependencies.json src/main.ts
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Example 4: Multiple Configurations
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
# Development config
|
|
422
|
+
graph-analyzer -c tsconfig.dev.json -o dev-graph.json src/main.ts
|
|
423
|
+
|
|
424
|
+
# Production config
|
|
425
|
+
graph-analyzer -c tsconfig.prod.json -o prod-graph.json src/main.ts
|
|
426
|
+
|
|
427
|
+
# Compare differences
|
|
428
|
+
diff dev-graph.json prod-graph.json
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### Example 5: NPM Scripts
|
|
432
|
+
|
|
433
|
+
Add to `package.json`:
|
|
434
|
+
|
|
435
|
+
```json
|
|
436
|
+
{
|
|
437
|
+
"scripts": {
|
|
438
|
+
"analyze": "graph-analyzer src/main.ts",
|
|
439
|
+
"analyze:json": "graph-analyzer -f json -o dist/graph.json src/main.ts",
|
|
440
|
+
"analyze:png": "graph-analyzer -f png -o docs/graph.png src/main.ts",
|
|
441
|
+
"analyze:ci": "graph-analyzer -f json -o coverage/dependencies.json src/main.ts"
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Usage:
|
|
447
|
+
```bash
|
|
448
|
+
npm run analyze
|
|
449
|
+
npm run analyze:json
|
|
450
|
+
npm run analyze:ci
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
## Troubleshooting
|
|
454
|
+
|
|
455
|
+
### Error: "File not found"
|
|
456
|
+
|
|
457
|
+
**Problem**: Entry file doesn't exist
|
|
458
|
+
|
|
459
|
+
**Solution**:
|
|
460
|
+
```bash
|
|
461
|
+
# Check file exists
|
|
462
|
+
ls -la src/main.ts
|
|
463
|
+
|
|
464
|
+
# Use correct path
|
|
465
|
+
graph-analyzer ./src/main.ts # Relative
|
|
466
|
+
graph-analyzer /absolute/path/to/main.ts # Absolute
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### Error: "tsconfig.json not found"
|
|
470
|
+
|
|
471
|
+
**Problem**: TypeScript config not found
|
|
472
|
+
|
|
473
|
+
**Solution**:
|
|
474
|
+
```bash
|
|
475
|
+
# Specify config explicitly
|
|
476
|
+
graph-analyzer -c path/to/tsconfig.json src/main.ts
|
|
477
|
+
|
|
478
|
+
# Or create tsconfig.json
|
|
479
|
+
echo '{}' > tsconfig.json
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Error: "Empty entry module"
|
|
483
|
+
|
|
484
|
+
**Problem**: Entry file doesn't bootstrap a module
|
|
485
|
+
|
|
486
|
+
**Solution**:
|
|
487
|
+
Ensure your entry file has a bootstrap call:
|
|
488
|
+
```typescript
|
|
489
|
+
// src/main.ts
|
|
490
|
+
import { NexusFactory } from '@nexus-ioc/core';
|
|
491
|
+
import { AppModule } from './app.module';
|
|
492
|
+
|
|
493
|
+
async function bootstrap() {
|
|
494
|
+
const app = await NexusFactory.create(AppModule);
|
|
495
|
+
await app.listen(3000);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
bootstrap();
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
### Error: "Graphviz not found"
|
|
502
|
+
|
|
503
|
+
**Problem**: PNG generation requires Graphviz
|
|
504
|
+
|
|
505
|
+
**Solution**:
|
|
506
|
+
```bash
|
|
507
|
+
# Install Graphviz
|
|
508
|
+
brew install graphviz # macOS
|
|
509
|
+
sudo apt-get install graphviz # Linux
|
|
510
|
+
|
|
511
|
+
# Or use JSON only
|
|
512
|
+
graph-analyzer -f json src/main.ts
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### Warning: "Could not resolve import"
|
|
516
|
+
|
|
517
|
+
**Problem**: Import path cannot be resolved
|
|
518
|
+
|
|
519
|
+
**Solution**:
|
|
520
|
+
1. Check tsconfig.json path aliases
|
|
521
|
+
2. Ensure all dependencies are installed
|
|
522
|
+
3. Verify import paths are correct
|
|
523
|
+
|
|
524
|
+
### Performance Issues
|
|
525
|
+
|
|
526
|
+
**Problem**: Analysis is slow
|
|
527
|
+
|
|
528
|
+
**Solutions**:
|
|
529
|
+
- Reduce number of modules
|
|
530
|
+
- Use more specific entry point
|
|
531
|
+
- Check for circular dependencies
|
|
532
|
+
- Ensure tsconfig.json is optimized
|
|
533
|
+
|
|
534
|
+
## Advanced Usage
|
|
535
|
+
|
|
536
|
+
### Programmatic Usage
|
|
537
|
+
|
|
538
|
+
For more control, use the programmatic API:
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
import { GraphAnalyzer } from 'graph-analyzer';
|
|
542
|
+
// See API_REFERENCE.md for details
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### Custom Output Processing
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
# Generate JSON and process
|
|
549
|
+
graph-analyzer -f json -o - src/main.ts | jq '.providers'
|
|
550
|
+
|
|
551
|
+
# Pipe to custom script
|
|
552
|
+
graph-analyzer -f json src/main.ts
|
|
553
|
+
node process-graph.js graph.json
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
### Integration with Other Tools
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
# Generate and commit
|
|
560
|
+
graph-analyzer -o docs/graph.png src/main.ts
|
|
561
|
+
git add docs/graph.png
|
|
562
|
+
git commit -m "docs: update dependency graph"
|
|
563
|
+
|
|
564
|
+
# Generate and upload
|
|
565
|
+
graph-analyzer -f png -o graph.png src/main.ts
|
|
566
|
+
aws s3 cp graph.png s3://my-bucket/docs/
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
## Getting Help
|
|
570
|
+
|
|
571
|
+
- 📖 [README](../README.md) - Overview and quick start
|
|
572
|
+
- 🏗️ [Architecture](./ARCHITECTURE.md) - Technical details
|
|
573
|
+
- 📚 [API Reference](./API_REFERENCE.md) - Programmatic usage
|
|
574
|
+
- 🐛 [Issues](https://github.com/Isqanderm/ioc/issues) - Report bugs
|
|
575
|
+
- 💡 [Discussions](https://github.com/Isqanderm/ioc/discussions) - Ask questions
|
|
576
|
+
|