@nexus-ioc/graph-analyzer 0.1.0 → 0.2.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +63 -26
  3. package/dist/analyzer/circular-dependency-detector.d.ts +29 -9
  4. package/dist/analyzer/circular-dependency-detector.js +106 -63
  5. package/dist/analyzer/circular-dependency-detector.js.map +1 -1
  6. package/dist/analyzer/module-depth-analyzer.d.ts +10 -13
  7. package/dist/analyzer/module-depth-analyzer.js +40 -52
  8. package/dist/analyzer/module-depth-analyzer.js.map +1 -1
  9. package/dist/analyzer/provider-scope-analyzer.d.ts +7 -44
  10. package/dist/analyzer/provider-scope-analyzer.js +13 -84
  11. package/dist/analyzer/provider-scope-analyzer.js.map +1 -1
  12. package/dist/analyzer/unused-provider-detector.d.ts +11 -9
  13. package/dist/analyzer/unused-provider-detector.js +35 -55
  14. package/dist/analyzer/unused-provider-detector.js.map +1 -1
  15. package/dist/cli.js +34 -129
  16. package/dist/cli.js.map +1 -1
  17. package/dist/config/config-loader.js +3 -27
  18. package/dist/config/config-loader.js.map +1 -1
  19. package/dist/config/config-schema.d.ts +2 -16
  20. package/dist/config/config-schema.js +0 -18
  21. package/dist/config/config-schema.js.map +1 -1
  22. package/dist/graph/build-nexus-graph-model.d.ts +13 -0
  23. package/dist/graph/build-nexus-graph-model.js +202 -0
  24. package/dist/graph/build-nexus-graph-model.js.map +1 -0
  25. package/dist/graph/nexus-graph-model.d.ts +112 -0
  26. package/dist/graph/nexus-graph-model.js +10 -0
  27. package/dist/graph/nexus-graph-model.js.map +1 -0
  28. package/dist/graph/scope-resolution.d.ts +16 -0
  29. package/dist/graph/scope-resolution.js +46 -0
  30. package/dist/graph/scope-resolution.js.map +1 -0
  31. package/dist/index.d.ts +27 -29
  32. package/dist/index.js +34 -34
  33. package/dist/index.js.map +1 -1
  34. package/dist/interfaces/graph-output.interface.d.ts +49 -14
  35. package/dist/utils/error-formatter.js +1 -6
  36. package/dist/utils/error-formatter.js.map +1 -1
  37. package/dist/utils/validator.d.ts +0 -5
  38. package/dist/utils/validator.js +0 -60
  39. package/dist/utils/validator.js.map +1 -1
  40. package/dist/visualize/json-formatter.d.ts +5 -6
  41. package/dist/visualize/json-formatter.js +49 -47
  42. package/dist/visualize/json-formatter.js.map +1 -1
  43. package/package.json +5 -4
  44. package/dist/interfaces/providers.interface.d.ts +0 -10
  45. package/dist/interfaces/providers.interface.js +0 -3
  46. package/dist/interfaces/providers.interface.js.map +0 -1
  47. package/dist/parser/dependency-extractor.d.ts +0 -88
  48. package/dist/parser/dependency-extractor.js +0 -334
  49. package/dist/parser/dependency-extractor.js.map +0 -1
  50. package/dist/parser/parse-entry-file.d.ts +0 -15
  51. package/dist/parser/parse-entry-file.js +0 -46
  52. package/dist/parser/parse-entry-file.js.map +0 -1
  53. package/dist/parser/parse-imports.d.ts +0 -15
  54. package/dist/parser/parse-imports.js +0 -65
  55. package/dist/parser/parse-imports.js.map +0 -1
  56. package/dist/parser/parse-ns-module.d.ts +0 -39
  57. package/dist/parser/parse-ns-module.js +0 -122
  58. package/dist/parser/parse-ns-module.js.map +0 -1
  59. package/dist/parser/parse-provider.d.ts +0 -2
  60. package/dist/parser/parse-provider.js +0 -7
  61. package/dist/parser/parse-provider.js.map +0 -1
  62. package/dist/parser/parse-ts-config.d.ts +0 -10
  63. package/dist/parser/parse-ts-config.js +0 -40
  64. package/dist/parser/parse-ts-config.js.map +0 -1
  65. package/dist/parser/parser-rec.d.ts +0 -1
  66. package/dist/parser/parser-rec.js +0 -52
  67. package/dist/parser/parser-rec.js.map +0 -1
  68. package/dist/parser/parser.d.ts +0 -1
  69. package/dist/parser/parser.js +0 -61
  70. package/dist/parser/parser.js.map +0 -1
  71. package/dist/parser/provider/class-parser.d.ts +0 -20
  72. package/dist/parser/provider/class-parser.js +0 -137
  73. package/dist/parser/provider/class-parser.js.map +0 -1
  74. package/dist/parser/provider/providers-parser.d.ts +0 -9
  75. package/dist/parser/provider/providers-parser.js +0 -32
  76. package/dist/parser/provider/providers-parser.js.map +0 -1
  77. package/dist/parser/provider/use-class-parser.d.ts +0 -25
  78. package/dist/parser/provider/use-class-parser.js +0 -161
  79. package/dist/parser/provider/use-class-parser.js.map +0 -1
  80. package/dist/parser/provider/use-factory-parser.d.ts +0 -15
  81. package/dist/parser/provider/use-factory-parser.js +0 -53
  82. package/dist/parser/provider/use-factory-parser.js.map +0 -1
  83. package/dist/parser/provider/use-value-parser.d.ts +0 -13
  84. package/dist/parser/provider/use-value-parser.js +0 -41
  85. package/dist/parser/provider/use-value-parser.js.map +0 -1
  86. package/dist/parser/rules.d.ts +0 -10
  87. package/dist/parser/rules.js +0 -37
  88. package/dist/parser/rules.js.map +0 -1
  89. package/dist/visualize/generator.d.ts +0 -26
  90. package/dist/visualize/generator.js +0 -75
  91. package/dist/visualize/generator.js.map +0 -1
  92. package/dist/visualize/graph-analyzer.d.ts +0 -126
  93. package/dist/visualize/graph-analyzer.js +0 -199
  94. package/dist/visualize/graph-analyzer.js.map +0 -1
  95. package/dist/visualize/html-generator.d.ts +0 -71
  96. package/dist/visualize/html-generator.js +0 -1312
  97. package/dist/visualize/html-generator.js.map +0 -1
@@ -1,161 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UseClassParser = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs = tslib_1.__importStar(require("node:fs"));
6
- const path = tslib_1.__importStar(require("node:path"));
7
- const tsquery_1 = require("@phenomnomnominal/tsquery");
8
- const ts = tslib_1.__importStar(require("typescript"));
9
- const dependency_extractor_1 = require("../dependency-extractor");
10
- const provideRegexp = /provide:\s*([^,\s]+)/;
11
- const useClassRegexp = /useClass:\s*([A-Za-z_][A-Za-z0-9_]*)/;
12
- const scopeRegexp = /scope:\s*([A-Za-z_][\w.]*)/;
13
- class UseClassParser {
14
- constructor(provider, sourceFile, currentFilePath) {
15
- this.provider = provider;
16
- this.sourceFile = sourceFile;
17
- this.currentFilePath = currentFilePath;
18
- this.type = "UseClass";
19
- this._token = null;
20
- this._value = null;
21
- this._scope = null;
22
- this._dependencies = [];
23
- this.dependencyExtractor = new dependency_extractor_1.DependencyExtractor();
24
- }
25
- parse() {
26
- const token = this.provider.match(provideRegexp);
27
- const useClass = this.provider.match(useClassRegexp);
28
- const scope = this.provider.match(scopeRegexp);
29
- if (token) {
30
- this._token = token[1];
31
- }
32
- if (useClass) {
33
- this._value = useClass[1];
34
- // Extract dependencies from the class
35
- if (this.sourceFile && this._value) {
36
- this._dependencies = this.extractDependenciesFromClass(this._value);
37
- }
38
- }
39
- if (scope) {
40
- this._scope = scope[1];
41
- }
42
- return this;
43
- }
44
- extractDependenciesFromClass(className) {
45
- if (!this.sourceFile) {
46
- return [];
47
- }
48
- // First, try to find the class in the current file (module file)
49
- let classDeclaration = this.findClassDeclaration(className, this.sourceFile);
50
- let targetSourceFile = this.sourceFile;
51
- // If not found, try to find the import and load the actual class file
52
- if (!classDeclaration && this.currentFilePath) {
53
- const classSourceFile = this.findAndLoadClassFile(className);
54
- if (classSourceFile) {
55
- classDeclaration = this.findClassDeclaration(className, classSourceFile);
56
- targetSourceFile = classSourceFile;
57
- }
58
- }
59
- if (!classDeclaration) {
60
- return [];
61
- }
62
- // Extract dependencies using the DependencyExtractor
63
- return this.dependencyExtractor.extractDependencies(classDeclaration, targetSourceFile);
64
- }
65
- findAndLoadClassFile(className) {
66
- if (!this.sourceFile || !this.currentFilePath) {
67
- return undefined;
68
- }
69
- // Find the import statement for this class
70
- const importPath = this.findImportPathForClass(className);
71
- if (!importPath) {
72
- return undefined;
73
- }
74
- // Resolve the full path
75
- const fullPath = this.resolveImportPath(importPath);
76
- if (!fullPath || !fs.existsSync(fullPath)) {
77
- return undefined;
78
- }
79
- // Load and parse the file
80
- try {
81
- const content = fs.readFileSync(fullPath, "utf8");
82
- return ts.createSourceFile(fullPath, content, ts.ScriptTarget.Latest, true);
83
- }
84
- catch (_error) {
85
- return undefined;
86
- }
87
- }
88
- findImportPathForClass(className) {
89
- if (!this.sourceFile) {
90
- return undefined;
91
- }
92
- // Find import declarations that include this class
93
- const importDeclarations = (0, tsquery_1.query)(this.sourceFile, "ImportDeclaration");
94
- for (const node of importDeclarations) {
95
- if (!ts.isImportDeclaration(node)) {
96
- continue;
97
- }
98
- const importClause = node.importClause;
99
- if (!importClause || !importClause.namedBindings) {
100
- continue;
101
- }
102
- // Check named imports
103
- if (ts.isNamedImports(importClause.namedBindings)) {
104
- for (const element of importClause.namedBindings.elements) {
105
- if (element.name.text === className) {
106
- // Found the import!
107
- if (ts.isStringLiteral(node.moduleSpecifier)) {
108
- return node.moduleSpecifier.text;
109
- }
110
- }
111
- }
112
- }
113
- }
114
- return undefined;
115
- }
116
- resolveImportPath(importPath) {
117
- if (!this.currentFilePath) {
118
- return undefined;
119
- }
120
- // Skip node_modules
121
- if (!importPath.startsWith(".")) {
122
- return undefined;
123
- }
124
- const dir = path.dirname(this.currentFilePath);
125
- const resolved = path.resolve(dir, importPath);
126
- // Try different extensions
127
- const extensions = [".ts", ".tsx", "/index.ts", "/index.tsx"];
128
- for (const ext of extensions) {
129
- const fullPath = resolved.endsWith(".ts") ? resolved : resolved + ext;
130
- if (fs.existsSync(fullPath)) {
131
- return fullPath;
132
- }
133
- }
134
- return undefined;
135
- }
136
- findClassDeclaration(className, sourceFile) {
137
- // Use tsquery to find the class declaration
138
- const selector = `ClassDeclaration[name.name="${className}"]`;
139
- const nodes = (0, tsquery_1.query)(sourceFile, selector);
140
- for (const node of nodes) {
141
- if (ts.isClassDeclaration(node)) {
142
- return node;
143
- }
144
- }
145
- return undefined;
146
- }
147
- get token() {
148
- return this._token;
149
- }
150
- get value() {
151
- return this._value;
152
- }
153
- get scope() {
154
- return this._scope;
155
- }
156
- get dependencies() {
157
- return this._dependencies;
158
- }
159
- }
160
- exports.UseClassParser = UseClassParser;
161
- //# sourceMappingURL=use-class-parser.js.map
@@ -1 +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,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,IAAI,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjC,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAI,YAAY;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AApMD,wCAoMC"}
@@ -1,15 +0,0 @@
1
- import type { ProvidersInterface } from "../../interfaces/providers.interface";
2
- export declare class UseFactoryParser implements ProvidersInterface {
3
- private readonly provider;
4
- readonly type = "UseFactory";
5
- private _token;
6
- private _value;
7
- private _inject;
8
- private _scope;
9
- constructor(provider: string);
10
- parse(): this;
11
- get token(): string | null;
12
- get value(): string | null;
13
- get inject(): string[];
14
- get scope(): string | null;
15
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UseFactoryParser = void 0;
4
- const provideRegexp = /provide:\s*"([^"]+)"/;
5
- const useFactoryRegexp = /useFactory:\s*((?:\([^)]*\)\s*=>\s*\{[^}]*\}))/;
6
- const injectRegexp = /inject:\s*\[([^\]]+)\]/;
7
- const scopeRegexp = /scope:\s*([^,}]+)/;
8
- class UseFactoryParser {
9
- constructor(provider) {
10
- this.provider = provider;
11
- this.type = "UseFactory";
12
- this._token = null;
13
- this._value = null;
14
- this._inject = [];
15
- this._scope = null;
16
- }
17
- parse() {
18
- const token = this.provider.match(provideRegexp);
19
- const useFactory = this.provider.match(useFactoryRegexp);
20
- const inject = this.provider.match(injectRegexp);
21
- const scope = this.provider.match(scopeRegexp);
22
- if (token) {
23
- this._token = token[1];
24
- }
25
- if (useFactory) {
26
- this._value = useFactory[1];
27
- }
28
- if (inject) {
29
- this._inject = inject[1]
30
- .split(",")
31
- .map((inject) => inject.trim())
32
- .map((inject) => inject.replace(/^["']|["']$/g, "")); // Remove surrounding quotes
33
- }
34
- if (scope) {
35
- this._scope = scope[1].trim();
36
- }
37
- return this;
38
- }
39
- get token() {
40
- return this._token;
41
- }
42
- get value() {
43
- return this._value;
44
- }
45
- get inject() {
46
- return this._inject;
47
- }
48
- get scope() {
49
- return this._scope;
50
- }
51
- }
52
- exports.UseFactoryParser = UseFactoryParser;
53
- //# sourceMappingURL=use-factory-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-factory-parser.js","sourceRoot":"","sources":["../../../src/parser/provider/use-factory-parser.ts"],"names":[],"mappings":";;;AAEA,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,MAAM,gBAAgB,GAAG,gDAAgD,CAAC;AAC1E,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAC9C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAa,gBAAgB;IAO5B,YAA6B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAN7B,SAAI,GAAG,YAAY,CAAC;QAC5B,WAAM,GAAkB,IAAI,CAAC;QAC7B,WAAM,GAAkB,IAAI,CAAC;QAC7B,YAAO,GAAa,EAAE,CAAC;QACvB,WAAM,GAAkB,IAAI,CAAC;IAEW,CAAC;IAEjD,KAAK;QACJ,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE/C,IAAI,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;iBACtB,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;iBAC9B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,4BAA4B;QACpF,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD;AApDD,4CAoDC"}
@@ -1,13 +0,0 @@
1
- import type { ProvidersInterface } from "../../interfaces/providers.interface";
2
- export declare class UseValueParser implements ProvidersInterface {
3
- private readonly provider;
4
- readonly type = "UseValue";
5
- private _token;
6
- private _value;
7
- private _scope;
8
- constructor(provider: string);
9
- parse(): this;
10
- get token(): string | null;
11
- get value(): string | null;
12
- get scope(): string | null;
13
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UseValueParser = void 0;
4
- const provideRegexp = /provide:\s*"([^"]+)"/;
5
- const useValueRegexp = /useValue:\s*"([^"]+)"/;
6
- const scopeRegexp = /scope:\s*([^,}]+)/;
7
- class UseValueParser {
8
- constructor(provider) {
9
- this.provider = provider;
10
- this.type = "UseValue";
11
- this._token = null;
12
- this._value = null;
13
- this._scope = null;
14
- }
15
- parse() {
16
- const token = this.provider.match(provideRegexp);
17
- const useValue = this.provider.match(useValueRegexp);
18
- const scope = this.provider.match(scopeRegexp);
19
- if (token) {
20
- this._token = token[1];
21
- }
22
- if (useValue) {
23
- this._value = useValue[1];
24
- }
25
- if (scope) {
26
- this._scope = scope[1].trim();
27
- }
28
- return this;
29
- }
30
- get token() {
31
- return this._token;
32
- }
33
- get value() {
34
- return this._value;
35
- }
36
- get scope() {
37
- return this._scope;
38
- }
39
- }
40
- exports.UseValueParser = UseValueParser;
41
- //# sourceMappingURL=use-value-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-value-parser.js","sourceRoot":"","sources":["../../../src/parser/provider/use-value-parser.ts"],"names":[],"mappings":";;;AAEA,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAa,cAAc;IAM1B,YAA6B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAL7B,SAAI,GAAG,UAAU,CAAC;QAC1B,WAAM,GAAkB,IAAI,CAAC;QAC7B,WAAM,GAAkB,IAAI,CAAC;QAC7B,WAAM,GAAkB,IAAI,CAAC;IAEW,CAAC;IAEjD,KAAK;QACJ,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QACrD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE/C,IAAI,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD;AAvCD,wCAuCC"}
@@ -1,10 +0,0 @@
1
- import type * as ts from "typescript";
2
- export declare const rules: ({
3
- rule: string;
4
- callback(nodes: ts.Node[], _file: ts.SourceFile): void;
5
- name?: undefined;
6
- } | {
7
- name: string;
8
- rule: string;
9
- callback(nodes: ts.Node[], _file: ts.SourceFile): void;
10
- })[];
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rules = void 0;
4
- let entryModule = null;
5
- exports.rules = [
6
- {
7
- rule: "CallExpression",
8
- callback(nodes, _file) {
9
- if (entryModule) {
10
- return;
11
- }
12
- for (const node of nodes) {
13
- const text = node.getText();
14
- const match = text.match(/\.create\((\w+)\)/);
15
- if (match) {
16
- entryModule = match[1];
17
- return;
18
- }
19
- }
20
- },
21
- },
22
- {
23
- name: "findNsModuleDecorators",
24
- rule: 'Decorator[expression.expression.name="NsModule"]',
25
- callback(nodes, _file) {
26
- for (const node of nodes) {
27
- const text = node.getText();
28
- const match = text.match(/imports:\s*\[([^\]]+)\]/);
29
- if (match) {
30
- const modules = match[1].split(",").map((m) => m.trim());
31
- console.log("modules: ", modules);
32
- }
33
- }
34
- },
35
- },
36
- ];
37
- //# sourceMappingURL=rules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/parser/rules.ts"],"names":[],"mappings":";;;AAEA,IAAI,WAAW,GAAkB,IAAI,CAAC;AAEzB,QAAA,KAAK,GAAG;IACpB;QACC,IAAI,EAAE,gBAAgB;QACtB,QAAQ,CAAC,KAAgB,EAAE,KAAoB;YAC9C,IAAI,WAAW,EAAE,CAAC;gBACjB,OAAO;YACR,CAAC;YAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;gBAE9C,IAAI,KAAK,EAAE,CAAC;oBACX,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;oBACvB,OAAO;gBACR,CAAC;YACF,CAAC;QACF,CAAC;KACD;IACD;QACC,IAAI,EAAE,wBAAwB;QAC9B,IAAI,EAAE,kDAAkD;QACxD,QAAQ,CAAC,KAAgB,EAAE,KAAoB;YAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;gBAEpD,IAAI,KAAK,EAAE,CAAC;oBACX,MAAM,OAAO,GAAa,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;oBAEnE,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;gBACnC,CAAC;YACF,CAAC;QACF,CAAC;KACD;CACD,CAAC"}
@@ -1,26 +0,0 @@
1
- type ModuleInfo = {
2
- name: string;
3
- imports: string[];
4
- exports: string[];
5
- isGlobal: boolean;
6
- providers: any[];
7
- dependencies: string[];
8
- };
9
- type ModulesData = {
10
- [key: string]: ModuleInfo;
11
- };
12
- export declare class GraphGenerator {
13
- private readonly json;
14
- private readonly outputPath;
15
- constructor(json: ModulesData, outputPath: string);
16
- private typeColors;
17
- /**
18
- * Escape special characters for DOT format
19
- * Escapes quotes, backslashes, and newlines to prevent injection
20
- */
21
- private escapeDotString;
22
- private generateDotGraph;
23
- scan(): void;
24
- protected ensureDirectoryExists(filePath: string): void;
25
- }
26
- export {};
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GraphGenerator = void 0;
4
- const node_child_process_1 = require("node:child_process");
5
- const node_fs_1 = require("node:fs");
6
- const node_path_1 = require("node:path");
7
- class GraphGenerator {
8
- constructor(json, outputPath) {
9
- this.json = json;
10
- this.outputPath = outputPath;
11
- this.typeColors = {
12
- Class: "lightblue",
13
- UseValue: "lightgreen",
14
- UseFactory: "lightcoral",
15
- UseClass: "lightyellow",
16
- };
17
- }
18
- /**
19
- * Escape special characters for DOT format
20
- * Escapes quotes, backslashes, and newlines to prevent injection
21
- */
22
- escapeDotString(str) {
23
- return str
24
- .replace(/\\/g, "\\\\") // Escape backslashes first
25
- .replace(/"/g, '\\"') // Escape quotes
26
- .replace(/\n/g, "\\n") // Escape newlines
27
- .replace(/\r/g, "\\r"); // Escape carriage returns
28
- }
29
- generateDotGraph() {
30
- let dot = "digraph G {\n";
31
- dot += " node [shape=box];\n"; // Set node shape
32
- dot += " rankdir=LR;\n"; // Set horizontal graph direction
33
- for (const [moduleName, moduleInfo] of Object.entries(this.json)) {
34
- const escapedModuleName = this.escapeDotString(moduleName);
35
- dot += ` "${escapedModuleName}" [label="${escapedModuleName}", style=filled, fillcolor="lightgray"];\n`;
36
- if (moduleInfo.providers && moduleInfo.providers.length > 0) {
37
- moduleInfo.providers.forEach((provider, index) => {
38
- const providerName = `${escapedModuleName}_Provider${index}`;
39
- const escapedToken = this.escapeDotString(provider.token);
40
- const escapedType = this.escapeDotString(provider.type);
41
- const providerLabel = `"${escapedToken} (${escapedType})"`;
42
- const color = this.typeColors[provider.type] || "white";
43
- dot += ` "${providerName}" [label=${providerLabel}, style=filled, fillcolor="${color}"];\n`;
44
- dot += ` "${escapedModuleName}" -> "${providerName}";\n`;
45
- });
46
- }
47
- for (const imp of moduleInfo.imports) {
48
- const escapedImp = this.escapeDotString(imp);
49
- dot += ` "${escapedModuleName}" -> "${escapedImp}";\n`;
50
- }
51
- }
52
- dot += "}\n";
53
- return dot;
54
- }
55
- scan() {
56
- const dotGraph = this.generateDotGraph();
57
- this.ensureDirectoryExists(this.outputPath);
58
- const dotProcess = (0, node_child_process_1.spawnSync)("dot", ["-Tpng", "-o", this.outputPath], {
59
- input: dotGraph,
60
- encoding: "utf-8",
61
- });
62
- if (dotProcess.error) {
63
- console.error("Error running dot command:", dotProcess.error);
64
- }
65
- else {
66
- console.log(`Graph visualized as ${this.outputPath}`);
67
- }
68
- }
69
- ensureDirectoryExists(filePath) {
70
- const dir = (0, node_path_1.dirname)(filePath);
71
- (0, node_fs_1.mkdirSync)(dir, { recursive: true });
72
- }
73
- }
74
- exports.GraphGenerator = GraphGenerator;
75
- //# sourceMappingURL=generator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/visualize/generator.ts"],"names":[],"mappings":";;;AAAA,2DAA+C;AAC/C,qCAAoC;AACpC,yCAAoC;AAgBpC,MAAa,cAAc;IAC1B,YACkB,IAAiB,EACjB,UAA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B,CAAC,QAAgB;QAC/C,MAAM,GAAG,GAAG,IAAA,mBAAO,EAAC,QAAQ,CAAC,CAAC;QAC9B,IAAA,mBAAS,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrC,CAAC;CACD;AA5ED,wCA4EC"}
@@ -1,126 +0,0 @@
1
- import type { GraphOutput } from "../interfaces/graph-output.interface";
2
- import type { ParseEntryFile } from "../parser/parse-entry-file";
3
- import type { ParseNsModule } from "../parser/parse-ns-module";
4
- import { type HtmlGeneratorOptions } from "./html-generator";
5
- /**
6
- * Options for configuring GraphAnalyzer output
7
- */
8
- export interface GraphAnalyzerOptions {
9
- /** Output format: 'json', 'png', 'html', or 'both' (default: 'both') */
10
- outputFormat?: "json" | "png" | "html" | "both";
11
- /** Output file path (used when format is not 'both') */
12
- outputPath?: string;
13
- /** JSON output file path (default: './graph.json') */
14
- jsonOutputPath?: string;
15
- /** PNG output file path (default: './graph.png') */
16
- pngOutputPath?: string;
17
- /** HTML output file path (default: './graph.html') */
18
- htmlOutputPath?: string;
19
- /** HTML generator options */
20
- htmlOptions?: HtmlGeneratorOptions;
21
- /** Enable circular dependency detection (default: false) */
22
- checkCircular?: boolean;
23
- /** Enable unused provider detection (default: false) */
24
- checkUnused?: boolean;
25
- /** Enable module depth analysis (default: false) */
26
- checkDepth?: boolean;
27
- /** Threshold for identifying deep modules (default: 5) */
28
- deepModuleThreshold?: number;
29
- /** Enable provider scope analysis (default: false) */
30
- checkScope?: boolean;
31
- }
32
- /**
33
- * Main analyzer class for dependency injection graphs
34
- *
35
- * Analyzes Nexus IoC dependency graphs and generates JSON and/or PNG outputs.
36
- *
37
- * @example
38
- * ```typescript
39
- * const analyzer = new GraphAnalyzer(modulesGraph, 'src/main.ts', {
40
- * outputFormat: 'json',
41
- * jsonOutputPath: './output/graph.json'
42
- * });
43
- *
44
- * const output = analyzer.parse();
45
- * console.log(`Found ${output.metadata.totalProviders} providers`);
46
- * ```
47
- */
48
- export declare class GraphAnalyzer {
49
- private readonly graph;
50
- private readonly entryPoint;
51
- private readonly options;
52
- /**
53
- * Create a new GraphAnalyzer instance
54
- *
55
- * @param graph - Map of module names to parsed modules
56
- * @param entryPoint - Path to application entry point file
57
- * @param options - Configuration options for output generation
58
- */
59
- constructor(graph: Map<string, ParseNsModule | ParseEntryFile>, entryPoint: string, options?: GraphAnalyzerOptions);
60
- /**
61
- * Parse the dependency graph and generate output based on configured format
62
- *
63
- * @returns GraphOutput object if format is 'json', 'html', or 'both', void if format is 'png'
64
- *
65
- * @example
66
- * ```typescript
67
- * // Generate JSON only
68
- * const output = analyzer.parse();
69
- *
70
- * // Generate PNG only
71
- * analyzer.parse(); // Returns void
72
- *
73
- * // Generate HTML only
74
- * analyzer.parse(); // Returns void
75
- *
76
- * // Generate both JSON and PNG
77
- * const output = analyzer.parse(); // Returns GraphOutput and creates PNG
78
- * ```
79
- */
80
- parse(): GraphOutput | undefined;
81
- /**
82
- * Generate JSON output of the dependency graph
83
- *
84
- * Creates a structured JSON representation of all modules, providers, and dependencies.
85
- * Optionally writes the output to a file if jsonOutputPath or outputPath is configured.
86
- *
87
- * @returns GraphOutput object containing modules, providers, and metadata
88
- *
89
- * @example
90
- * ```typescript
91
- * const output = analyzer.generateJson();
92
- * console.log(`Total modules: ${output.metadata.totalModules}`);
93
- * console.log(`Total providers: ${output.metadata.totalProviders}`);
94
- * ```
95
- */
96
- generateJson(): GraphOutput;
97
- /**
98
- * Generate PNG visualization of the dependency graph using Graphviz
99
- *
100
- * Creates a visual graph representation showing modules as nodes and dependencies as edges.
101
- * Requires Graphviz to be installed on the system.
102
- *
103
- * @throws Error if Graphviz is not installed or graph generation fails
104
- *
105
- * @example
106
- * ```typescript
107
- * analyzer.generatePng();
108
- * // Creates graph.png in the configured output path
109
- * ```
110
- */
111
- generatePng(): void;
112
- /**
113
- * Generate interactive HTML visualization of the dependency graph
114
- *
115
- * Creates an interactive HTML page with a graph visualization using Cytoscape.js.
116
- * The HTML includes zoom/pan controls, node details, search functionality, and
117
- * clickable file paths that open in your IDE.
118
- *
119
- * @example
120
- * ```typescript
121
- * analyzer.generateHtml();
122
- * // Creates graph.html in the configured output path
123
- * ```
124
- */
125
- generateHtml(): void;
126
- }