@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,122 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseNsModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const tsquery_1 = require("@phenomnomnominal/tsquery");
6
- const ts = tslib_1.__importStar(require("typescript"));
7
- const parse_imports_1 = require("./parse-imports");
8
- const providers_parser_1 = require("./provider/providers-parser");
9
- class ParseNsModule {
10
- constructor(sourceFile, _currentFilePath, tsConfig) {
11
- this.sourceFile = sourceFile;
12
- this._currentFilePath = _currentFilePath;
13
- this.tsConfig = tsConfig;
14
- this.classNodeWithNsModuleDecorator = `ClassDeclaration:has(Decorator:has(CallExpression:has(Identifier[name="NsModule"])))`;
15
- this.classNodeWithGlobalDecorator = (moduleName) => `ClassDeclaration[name.name="${moduleName}"]:has(Decorator:has(CallExpression:has(Identifier[name="Global"])))`;
16
- this._imports = [];
17
- this._providers = [];
18
- this._exports = [];
19
- this._deps = [];
20
- this._name = null;
21
- this._isGlobal = false;
22
- this._modules = new Map();
23
- this.ast = (0, tsquery_1.ast)(sourceFile.text);
24
- }
25
- findNsModulesImports(imports) {
26
- return new parse_imports_1.ParseImports(this.sourceFile, this._currentFilePath, this.tsConfig).findAllNsModuleImports(imports);
27
- }
28
- findClassWithNsModule() {
29
- const nodes = (0, tsquery_1.query)(this.ast, this.classNodeWithNsModuleDecorator);
30
- for (const node of nodes) {
31
- if (ts.isClassDeclaration(node)) {
32
- const moduleName = node.name?.text;
33
- if (!moduleName) {
34
- throw new Error("Module name can`t be empty");
35
- }
36
- this._name = moduleName;
37
- this._isGlobal = this.isNsModuleGlobal(moduleName);
38
- if (ts.canHaveDecorators(node)) {
39
- const decorators = ts.getDecorators(node) || [];
40
- for (const decorator of decorators) {
41
- if (ts.isCallExpression(decorator.expression)) {
42
- const expression = decorator.expression;
43
- if (ts.isIdentifier(expression.expression) &&
44
- expression.expression.text === "NsModule") {
45
- const args = expression.arguments;
46
- if (args.length && ts.isObjectLiteralExpression(args[0])) {
47
- const properties = args[0];
48
- const nsModuleArguments = this.parseNsModuleProperties(properties);
49
- this._imports.push(...nsModuleArguments.imports);
50
- this._providers.push(...this.parseProviders(nsModuleArguments.providers));
51
- this._exports.push(...nsModuleArguments.exports);
52
- this._deps.push(...this.findNsModulesImports(nsModuleArguments.imports));
53
- this._modules.set(moduleName, nsModuleArguments);
54
- }
55
- }
56
- }
57
- }
58
- }
59
- }
60
- }
61
- }
62
- parseNsModuleProperties(properties) {
63
- const args = {
64
- imports: [],
65
- exports: [],
66
- providers: [],
67
- };
68
- for (const property of properties.properties) {
69
- if (ts.isPropertyAssignment(property) && ts.isIdentifier(property.name)) {
70
- const nodes = property.initializer.elements.map((element) => {
71
- return element.getText();
72
- });
73
- if (property.name.text === "imports") {
74
- args.imports.push(...nodes);
75
- }
76
- else if (property.name.text === "providers") {
77
- args.providers.push(...nodes);
78
- }
79
- else if (property.name.text === "exports") {
80
- args.exports.push(...nodes);
81
- }
82
- }
83
- }
84
- return args;
85
- }
86
- parseProviders(providers) {
87
- return new providers_parser_1.ProvidersParser(providers, this.sourceFile, this._currentFilePath).parse();
88
- }
89
- isNsModuleGlobal(moduleName) {
90
- const nodes = (0, tsquery_1.query)(this.ast, this.classNodeWithGlobalDecorator(moduleName));
91
- return nodes.length > 0;
92
- }
93
- parse() {
94
- this.findClassWithNsModule();
95
- }
96
- get imports() {
97
- return this._imports;
98
- }
99
- get modules() {
100
- return this._modules;
101
- }
102
- get providers() {
103
- return this._providers;
104
- }
105
- get exports() {
106
- return this._exports;
107
- }
108
- get deps() {
109
- return this._deps;
110
- }
111
- get filePath() {
112
- return this._currentFilePath;
113
- }
114
- get name() {
115
- return this._name;
116
- }
117
- get isGlobal() {
118
- return this._isGlobal;
119
- }
120
- }
121
- exports.ParseNsModule = ParseNsModule;
122
- //# sourceMappingURL=parse-ns-module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-ns-module.js","sourceRoot":"","sources":["../../src/parser/parse-ns-module.ts"],"names":[],"mappings":";;;;AAAA,uDAAuD;AACvD,uDAAiC;AAEjC,mDAA+C;AAE/C,kEAA8D;AAQ9D,MAAa,aAAa;IAczB,YACkB,UAAyB,EACzB,gBAAwB,EACxB,QAAuB;QAFvB,eAAU,GAAV,UAAU,CAAe;QACzB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,aAAQ,GAAR,QAAQ,CAAe;QAhBxB,mCAA8B,GAC9C,sFAAsF,CAAC;QACvE,iCAA4B,GAAG,CAAC,UAAkB,EAAE,EAAE,CACtE,+BAA+B,UAAU,sEAAsE,CAAC;QAEhG,aAAQ,GAAa,EAAE,CAAC;QACxB,eAAU,GAAyB,EAAE,CAAC;QACtC,aAAQ,GAAa,EAAE,CAAC;QACxB,U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OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;CACD;AAnKD,sCAmKC"}
@@ -1,2 +0,0 @@
1
- export declare class ParseProvider {
2
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseProvider = void 0;
4
- class ParseProvider {
5
- }
6
- exports.ParseProvider = ParseProvider;
7
- //# sourceMappingURL=parse-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-provider.js","sourceRoot":"","sources":["../../src/parser/parse-provider.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;CAAG;AAA7B,sCAA6B"}
@@ -1,10 +0,0 @@
1
- export declare class ParseTsConfig {
2
- private readonly config;
3
- private readonly basePath;
4
- private aliasPaths;
5
- private srcPath;
6
- constructor(config: string, basePath: string);
7
- private parse;
8
- resolveAliasPath(path: string): string;
9
- getSrcBasePath(): string;
10
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseTsConfig = void 0;
4
- const tslib_1 = require("tslib");
5
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
- class ParseTsConfig {
7
- constructor(config, basePath) {
8
- this.config = config;
9
- this.basePath = basePath;
10
- this.aliasPaths = {};
11
- this.srcPath = "";
12
- this.parse();
13
- }
14
- parse() {
15
- const config = JSON.parse(this.config);
16
- // Guard against missing compilerOptions
17
- if (!config.compilerOptions) {
18
- this.aliasPaths = {};
19
- this.srcPath = "";
20
- return;
21
- }
22
- this.aliasPaths = config.compilerOptions.paths || {};
23
- this.srcPath = config.compilerOptions.baseUrl || "";
24
- }
25
- resolveAliasPath(path) {
26
- for (const aliaKey of Object.keys(this.aliasPaths)) {
27
- const aliasStart = aliaKey.slice(0, -1);
28
- if (path.startsWith(aliasStart)) {
29
- const [resolvePath] = this.aliasPaths[aliaKey] || [];
30
- return path.replace(aliasStart, resolvePath.slice(0, -1));
31
- }
32
- }
33
- return path;
34
- }
35
- getSrcBasePath() {
36
- return node_path_1.default.resolve(this.basePath, this.srcPath);
37
- }
38
- }
39
- exports.ParseTsConfig = ParseTsConfig;
40
- //# sourceMappingURL=parse-ts-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-ts-config.js","sourceRoot":"","sources":["../../src/parser/parse-ts-config.ts"],"names":[],"mappings":";;;;AAAA,kEAA6B;AAE7B,MAAa,aAAa;IAGzB,YACkB,MAAc,EACd,QAAgB;QADhB,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAQ;QAJ1B,eAAU,GAA6B,EAAE,CAAC;QAC1C,YAAO,GAAG,EAAE,CAAC;QAKpB,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;IAEO,KAAK;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,wCAAwC;QACxC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;YAClB,OAAO;QACR,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,eAAe,CAAC,KAAK,IAAI,EAAE,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,IAAI,EAAE,CAAC;IACrD,CAAC;IAEM,gBAAgB,CAAC,IAAY;QACnC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACpD,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACxC,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACjC,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBACrD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,cAAc;QACpB,OAAO,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CACD;AAtCD,sCAsCC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const fs = tslib_1.__importStar(require("node:fs"));
5
- const path = tslib_1.__importStar(require("node:path"));
6
- const ts = tslib_1.__importStar(require("typescript"));
7
- const graph_analyzer_1 = require("../visualize/graph-analyzer");
8
- const parse_entry_file_1 = require("./parse-entry-file");
9
- const parse_ns_module_1 = require("./parse-ns-module");
10
- const parse_ts_config_1 = require("./parse-ts-config");
11
- const modulesGraph = new Map();
12
- async function buildDependencyGraph(entryFile, tsConfig) {
13
- const graph = {};
14
- const filesToProcess = [entryFile];
15
- while (filesToProcess.length) {
16
- const currentFile = filesToProcess.pop();
17
- if (graph[currentFile]) {
18
- continue;
19
- }
20
- const content = fs.readFileSync(currentFile, "utf8");
21
- const sourceFile = ts.createSourceFile(currentFile, content, ts.ScriptTarget.Latest, true);
22
- const nsModuleParser = new parse_ns_module_1.ParseNsModule(sourceFile, currentFile, tsConfig);
23
- nsModuleParser.parse();
24
- modulesGraph.set(nsModuleParser.name, nsModuleParser);
25
- graph[currentFile] = nsModuleParser.deps;
26
- filesToProcess.push(...nsModuleParser.deps);
27
- }
28
- return graph;
29
- }
30
- async function parseEntryPoint(entryFile, tsConfig, basePath) {
31
- const content = fs.readFileSync(entryFile, "utf8");
32
- const config = fs.readFileSync(tsConfig, "utf8");
33
- const sourceFile = ts.createSourceFile(entryFile, content, ts.ScriptTarget.Latest, true);
34
- const parseTsConfig = new parse_ts_config_1.ParseTsConfig(config, basePath);
35
- const parseEntryFile = new parse_entry_file_1.ParseEntryFile(sourceFile, entryFile, parseTsConfig);
36
- parseEntryFile.parse();
37
- if (!parseEntryFile.name) {
38
- throw new Error("No entry module");
39
- }
40
- modulesGraph.set("entry", parseEntryFile);
41
- return await buildDependencyGraph(parseEntryFile.imports[0], parseTsConfig);
42
- }
43
- const entryPath = path.resolve("./example/src/entry.ts");
44
- const tsConfig = path.resolve("./example/tsconfig.json");
45
- const basePath = path.resolve("./example");
46
- parseEntryPoint(entryPath, tsConfig, basePath).then((_graph) => {
47
- // console.log("Граф зависимостей:", graph);
48
- new graph_analyzer_1.GraphAnalyzer(modulesGraph, entryPath, {
49
- outputFormat: "both",
50
- }).parse();
51
- });
52
- //# sourceMappingURL=parser-rec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser-rec.js","sourceRoot":"","sources":["../../src/parser/parser-rec.ts"],"names":[],"mappings":";;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,uDAAiC;AACjC,gEAA4D;AAC5D,yDAAoD;AACpD,uDAAkD;AAClD,uDAAkD;AAMlD,MAAM,YAAY,GAAG,IAAI,GAAG,EAA0C,CAAC;AAEvE,KAAK,UAAU,oBAA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AG,IAAI,+BAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC1D,MAAM,cAAc,GAAG,IAAI,iCAAc,CACxC,UAAU,EACV,SAAS,EACT,aAAa,CACb,CAAC;IAEF,cAAc,CAAC,KAAK,EAAE,CAAC;IAEvB,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;IAED,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE1C,OAAO,MAAM,oBAAoB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAC3C,eAAe,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;IAC9D,4CAA4C;IAE5C,IAAI,8BAAa,CAAC,YAAY,EAAE,SAAS,EAAE;QAC1C,YAAY,EAAE,MAAM;KACpB,CAAC,CAAC,KAAK,EAAE,CAAC;AACZ,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const fs = tslib_1.__importStar(require("node:fs"));
5
- const path = tslib_1.__importStar(require("node:path"));
6
- const tsquery_1 = require("@phenomnomnominal/tsquery");
7
- const ts = tslib_1.__importStar(require("typescript"));
8
- const rules_1 = require("./rules");
9
- function findAllImports(entryFilePath) {
10
- const alreadyVisited = new Set();
11
- const filesToVisit = [entryFilePath];
12
- while (filesToVisit.length > 0) {
13
- const currentFile = filesToVisit.pop();
14
- if (alreadyVisited.has(currentFile)) {
15
- continue;
16
- }
17
- alreadyVisited.add(currentFile);
18
- const content = fs.readFileSync(currentFile, "utf8");
19
- const sourceFile = ts.createSourceFile(currentFile, content, ts.ScriptTarget.Latest, true);
20
- const contentAst = (0, tsquery_1.ast)(sourceFile.text);
21
- const importNodes = (0, tsquery_1.query)(contentAst, "ImportDeclaration");
22
- for (const node of importNodes) {
23
- if (ts.isImportDeclaration(node) &&
24
- node.moduleSpecifier &&
25
- ts.isStringLiteral(node.moduleSpecifier)) {
26
- let moduleName = node.moduleSpecifier.text;
27
- if (!moduleName.startsWith(".")) {
28
- continue; // Пропуск модулей из node_modules
29
- }
30
- moduleName = path.resolve(path.dirname(currentFile), moduleName);
31
- if (!moduleName.endsWith(".ts")) {
32
- if (fs.existsSync(`${moduleName}/index.ts`)) {
33
- moduleName += "/index.ts";
34
- }
35
- else if (fs.existsSync(`${moduleName}/index.tsx`)) {
36
- moduleName += "/index.tsx";
37
- }
38
- else {
39
- moduleName += ".ts";
40
- }
41
- }
42
- if (fs.existsSync(moduleName) && !alreadyVisited.has(moduleName)) {
43
- filesToVisit.push(moduleName);
44
- }
45
- }
46
- }
47
- for (const rule of rules_1.rules) {
48
- const result = (0, tsquery_1.query)(contentAst, rule.rule);
49
- if (!result.length) {
50
- break;
51
- }
52
- rule.name ?? console.group(rule.name);
53
- rule.callback?.(result, sourceFile);
54
- rule.name ?? console.groupEnd();
55
- }
56
- }
57
- console.log("Обработанные файлы:", alreadyVisited);
58
- }
59
- const entryPath = path.resolve("./example/entry.ts");
60
- findAllImports(entryPath);
61
- //# sourceMappingURL=parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser/parser.ts"],"names":[],"mappings":";;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,uDAAuD;AACvD,uDAAiC;AACjC,mCAAgC;AAEhC,S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C,EAAE,CAAC;oBACjC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,UAAU,WAAW,CAAC,EAAE,CAAC;wBAC7C,UAAU,IAAI,WAAW,CAAC;oBAC3B,CAAC;yBAAM,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,UAAU,YAAY,CAAC,EAAE,CAAC;wBACrD,UAAU,IAAI,YAAY,CAAC;oBAC5B,CAAC;yBAAM,CAAC;wBACP,UAAU,IAAI,KAAK,CAAC;oBACrB,CAAC;gBACF,CAAC;gBAED,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;oBAClE,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,aAAK,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,IAAA,eAAK,EAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAE5C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACpB,MAAM;YACP,CAAC;YAED,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACjC,CAAC;IACF,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACrD,cAAc,CAAC,SAAS,CAAC,CAAC"}
@@ -1,20 +0,0 @@
1
- import * as ts from "typescript";
2
- import type { ProvidersInterface } from "../../interfaces/providers.interface";
3
- import { type Dependency } from "../dependency-extractor";
4
- export declare class ClassParser implements ProvidersInterface {
5
- readonly _token: string;
6
- private readonly sourceFile?;
7
- private readonly currentFilePath?;
8
- readonly type = "Class";
9
- private _dependencies;
10
- private dependencyExtractor;
11
- constructor(_token: string, sourceFile?: ts.SourceFile | undefined, currentFilePath?: string | undefined);
12
- parse(): this;
13
- private extractDependenciesFromClass;
14
- private findAndLoadClassFile;
15
- private findImportPathForClass;
16
- private resolveImportPath;
17
- private findClassDeclaration;
18
- get token(): string;
19
- get dependencies(): Dependency[];
20
- }
@@ -1,137 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClassParser = 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
- class ClassParser {
11
- constructor(_token, sourceFile, currentFilePath) {
12
- this._token = _token;
13
- this.sourceFile = sourceFile;
14
- this.currentFilePath = currentFilePath;
15
- this.type = "Class";
16
- this._dependencies = [];
17
- this.dependencyExtractor = new dependency_extractor_1.DependencyExtractor();
18
- }
19
- parse() {
20
- // If we have a source file, extract dependencies
21
- if (this.sourceFile) {
22
- this._dependencies = this.extractDependenciesFromClass();
23
- }
24
- return this;
25
- }
26
- extractDependenciesFromClass() {
27
- if (!this.sourceFile) {
28
- return [];
29
- }
30
- // First, try to find the class in the current file (module file)
31
- let classDeclaration = this.findClassDeclaration(this._token, this.sourceFile);
32
- let targetSourceFile = this.sourceFile;
33
- // If not found, try to find the import and load the actual class file
34
- if (!classDeclaration && this.currentFilePath) {
35
- const classSourceFile = this.findAndLoadClassFile(this._token);
36
- if (classSourceFile) {
37
- classDeclaration = this.findClassDeclaration(this._token, classSourceFile);
38
- targetSourceFile = classSourceFile;
39
- }
40
- }
41
- if (!classDeclaration) {
42
- return [];
43
- }
44
- // Extract dependencies using the DependencyExtractor
45
- return this.dependencyExtractor.extractDependencies(classDeclaration, targetSourceFile);
46
- }
47
- findAndLoadClassFile(className) {
48
- if (!this.sourceFile || !this.currentFilePath) {
49
- return undefined;
50
- }
51
- // Find the import statement for this class
52
- const importPath = this.findImportPathForClass(className);
53
- if (!importPath) {
54
- return undefined;
55
- }
56
- // Resolve the full path
57
- const fullPath = this.resolveImportPath(importPath);
58
- if (!fullPath || !fs.existsSync(fullPath)) {
59
- return undefined;
60
- }
61
- // Load and parse the file
62
- try {
63
- const content = fs.readFileSync(fullPath, "utf8");
64
- return ts.createSourceFile(fullPath, content, ts.ScriptTarget.Latest, true);
65
- }
66
- catch (_error) {
67
- return undefined;
68
- }
69
- }
70
- findImportPathForClass(className) {
71
- if (!this.sourceFile) {
72
- return undefined;
73
- }
74
- // Find import declarations that include this class
75
- const importDeclarations = (0, tsquery_1.query)(this.sourceFile, "ImportDeclaration");
76
- for (const node of importDeclarations) {
77
- if (!ts.isImportDeclaration(node)) {
78
- continue;
79
- }
80
- const importClause = node.importClause;
81
- if (!importClause || !importClause.namedBindings) {
82
- continue;
83
- }
84
- // Check named imports
85
- if (ts.isNamedImports(importClause.namedBindings)) {
86
- for (const element of importClause.namedBindings.elements) {
87
- if (element.name.text === className) {
88
- // Found the import!
89
- if (ts.isStringLiteral(node.moduleSpecifier)) {
90
- return node.moduleSpecifier.text;
91
- }
92
- }
93
- }
94
- }
95
- }
96
- return undefined;
97
- }
98
- resolveImportPath(importPath) {
99
- if (!this.currentFilePath) {
100
- return undefined;
101
- }
102
- // Skip node_modules
103
- if (!importPath.startsWith(".")) {
104
- return undefined;
105
- }
106
- const dir = path.dirname(this.currentFilePath);
107
- const resolved = path.resolve(dir, importPath);
108
- // Try different extensions
109
- const extensions = [".ts", ".tsx", "/index.ts", "/index.tsx"];
110
- for (const ext of extensions) {
111
- const fullPath = resolved.endsWith(".ts") ? resolved : resolved + ext;
112
- if (fs.existsSync(fullPath)) {
113
- return fullPath;
114
- }
115
- }
116
- return undefined;
117
- }
118
- findClassDeclaration(className, sourceFile) {
119
- // Use tsquery to find the class declaration
120
- const selector = `ClassDeclaration[name.name="${className}"]`;
121
- const nodes = (0, tsquery_1.query)(sourceFile, selector);
122
- for (const node of nodes) {
123
- if (ts.isClassDeclaration(node)) {
124
- return node;
125
- }
126
- }
127
- return undefined;
128
- }
129
- get token() {
130
- return this._token;
131
- }
132
- get dependencies() {
133
- return this._dependencies;
134
- }
135
- }
136
- exports.ClassParser = ClassParser;
137
- //# sourceMappingURL=class-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"class-parser.js","sourceRoot":"","sources":["../../../src/parser/provider/class-parser.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,uDAAkD;AAClD,uDAAiC;AAEjC,kEAA+E;AAE/E,MAAa,WAAW;IAKvB,YACiB,MAAc,EACb,UAA0B,EAC1B,eAAwB;QAFzB,WAAM,GAAN,MAAM,CAAQ;QACb,eAAU,GAAV,UAAU,CAAgB;QAC1B,oBAAe,GAAf,eAAe,CAAS;QAP1B,SAAI,GAAG,OAAO,CAAC;QACvB,kBAAa,GAAiB,EAAE,CAAC;QACjC,wBAAmB,GAAG,IAAI,0CAAmB,EAAE,CAAC;IAMrD,CAAC;IAEJ,KAAK;QACJ,iDAAiD;QACjD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAC1D,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAEO,4BAA4B;QACnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,EAAE,CAAC;QACX,CAAC;QAED,iEAAiE;QACjE,IAAI,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,CAC/C,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU,CACf,CAAC;QACF,IAAI,gBAAgB,GAAG,I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- import type * as ts from "typescript";
2
- import type { ProvidersInterface } from "../../interfaces/providers.interface";
3
- export declare class ProvidersParser {
4
- private readonly providers;
5
- private readonly sourceFile?;
6
- private readonly currentFilePath?;
7
- constructor(providers: string[], sourceFile?: ts.SourceFile | undefined, currentFilePath?: string | undefined);
8
- parse(): ProvidersInterface[];
9
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProvidersParser = void 0;
4
- const class_parser_1 = require("./class-parser");
5
- const use_class_parser_1 = require("./use-class-parser");
6
- const use_factory_parser_1 = require("./use-factory-parser");
7
- const use_value_parser_1 = require("./use-value-parser");
8
- class ProvidersParser {
9
- constructor(providers, sourceFile, currentFilePath) {
10
- this.providers = providers;
11
- this.sourceFile = sourceFile;
12
- this.currentFilePath = currentFilePath;
13
- }
14
- parse() {
15
- return this.providers.map((provider) => {
16
- const cleanProvider = provider.replace(/\s+/g, "");
17
- if (cleanProvider.includes("useValue:")) {
18
- return new use_value_parser_1.UseValueParser(cleanProvider).parse();
19
- }
20
- if (cleanProvider.includes("useFactory:")) {
21
- return new use_factory_parser_1.UseFactoryParser(cleanProvider).parse();
22
- }
23
- if (cleanProvider.includes("useClass:")) {
24
- return new use_class_parser_1.UseClassParser(cleanProvider, this.sourceFile, this.currentFilePath).parse();
25
- }
26
- // For class providers, pass the source file and file path to enable dependency extraction
27
- return new class_parser_1.ClassParser(cleanProvider, this.sourceFile, this.currentFilePath).parse();
28
- });
29
- }
30
- }
31
- exports.ProvidersParser = ProvidersParser;
32
- //# sourceMappingURL=providers-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers-parser.js","sourceRoot":"","sources":["../../../src/parser/provider/providers-parser.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAC7C,yDAAoD;AACpD,6DAAwD;AACxD,yDAAoD;AAEpD,MAAa,eAAe;IAC3B,YACkB,SAAmB,EACnB,UAA0B,EAC1B,eAAwB;QAFxB,cAAS,GAAT,SAAS,CAAU;QACnB,eAAU,GAAV,UAAU,CAAgB;QAC1B,oBAAe,GAAf,eAAe,CAAS;IACvC,CAAC;IAEG,KAAK;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACtC,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAEnD,IAAI,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACzC,OAAO,IAAI,iCAAc,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,CAAC;YAClD,CAAC;YAED,IAAI,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC3C,OAAO,IAAI,qCAAgB,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,CAAC;YACpD,CAAC;YAED,IAAI,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACzC,OAAO,IAAI,iCAAc,CACxB,aAAa,EACb,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,eAAe,CACpB,CAAC,KAAK,EAAE,CAAC;YACX,CAAC;YAED,0FAA0F;YAC1F,OAAO,IAAI,0BAAW,CACrB,aAAa,EACb,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,eAAe,CACpB,CAAC,KAAK,EAAE,CAAC;QACX,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAnCD,0CAmCC"}
@@ -1,25 +0,0 @@
1
- import * as ts from "typescript";
2
- import type { ProvidersInterface } from "../../interfaces/providers.interface";
3
- import { type Dependency } from "../dependency-extractor";
4
- export declare class UseClassParser implements ProvidersInterface {
5
- private readonly provider;
6
- private readonly sourceFile?;
7
- private readonly currentFilePath?;
8
- readonly type = "UseClass";
9
- private _token;
10
- private _value;
11
- private _scope;
12
- private _dependencies;
13
- private dependencyExtractor;
14
- constructor(provider: string, sourceFile?: ts.SourceFile | undefined, currentFilePath?: string | undefined);
15
- parse(): this;
16
- private extractDependenciesFromClass;
17
- private findAndLoadClassFile;
18
- private findImportPathForClass;
19
- private resolveImportPath;
20
- private findClassDeclaration;
21
- get token(): string | null;
22
- get value(): string | null;
23
- get scope(): string | null;
24
- get dependencies(): Dependency[];
25
- }