@grafema/core 0.1.0-alpha.5 → 0.1.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/Orchestrator.d.ts +24 -2
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +197 -24
- package/dist/config/ConfigLoader.d.ts +72 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +187 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/core/ASTWorker.d.ts +11 -36
- package/dist/core/ASTWorker.d.ts.map +1 -1
- package/dist/core/ASTWorker.js +93 -99
- package/dist/core/CoverageAnalyzer.d.ts +65 -0
- package/dist/core/CoverageAnalyzer.d.ts.map +1 -0
- package/dist/core/CoverageAnalyzer.js +198 -0
- package/dist/core/FileNodeManager.d.ts +40 -0
- package/dist/core/FileNodeManager.d.ts.map +1 -0
- package/dist/core/FileNodeManager.js +84 -0
- package/dist/core/GraphFreshnessChecker.d.ts +33 -0
- package/dist/core/GraphFreshnessChecker.d.ts.map +1 -0
- package/dist/core/GraphFreshnessChecker.js +101 -0
- package/dist/core/HashUtils.d.ts +24 -0
- package/dist/core/HashUtils.d.ts.map +1 -0
- package/dist/core/HashUtils.js +45 -0
- package/dist/core/IncrementalReanalyzer.d.ts +36 -0
- package/dist/core/IncrementalReanalyzer.d.ts.map +1 -0
- package/dist/core/IncrementalReanalyzer.js +132 -0
- package/dist/core/NodeFactory.d.ts +225 -17
- package/dist/core/NodeFactory.d.ts.map +1 -1
- package/dist/core/NodeFactory.js +208 -18
- package/dist/core/ScopeTracker.d.ts +84 -0
- package/dist/core/ScopeTracker.d.ts.map +1 -0
- package/dist/core/ScopeTracker.js +116 -0
- package/dist/core/SemanticId.d.ts +90 -0
- package/dist/core/SemanticId.d.ts.map +1 -0
- package/dist/core/SemanticId.js +115 -0
- package/dist/core/VersionManager.d.ts.map +1 -1
- package/dist/core/VersionManager.js +3 -2
- package/dist/core/nodes/ArgumentExpressionNode.d.ts +43 -0
- package/dist/core/nodes/ArgumentExpressionNode.d.ts.map +1 -0
- package/dist/core/nodes/ArgumentExpressionNode.js +60 -0
- package/dist/core/nodes/ArrayLiteralNode.d.ts +27 -0
- package/dist/core/nodes/ArrayLiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/ArrayLiteralNode.js +41 -0
- package/dist/core/nodes/CallSiteNode.d.ts +28 -0
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -1
- package/dist/core/nodes/CallSiteNode.js +46 -0
- package/dist/core/nodes/ClassNode.d.ts +33 -1
- package/dist/core/nodes/ClassNode.d.ts.map +1 -1
- package/dist/core/nodes/ClassNode.js +46 -2
- package/dist/core/nodes/DecoratorNode.d.ts +42 -0
- package/dist/core/nodes/DecoratorNode.d.ts.map +1 -0
- package/dist/core/nodes/DecoratorNode.js +62 -0
- package/dist/core/nodes/EnumNode.d.ts +42 -0
- package/dist/core/nodes/EnumNode.d.ts.map +1 -0
- package/dist/core/nodes/EnumNode.js +54 -0
- package/dist/core/nodes/ExportNode.d.ts +37 -1
- package/dist/core/nodes/ExportNode.d.ts.map +1 -1
- package/dist/core/nodes/ExportNode.js +48 -2
- package/dist/core/nodes/ExpressionNode.d.ts +97 -0
- package/dist/core/nodes/ExpressionNode.d.ts.map +1 -0
- package/dist/core/nodes/ExpressionNode.js +178 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts +28 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts.map +1 -0
- package/dist/core/nodes/ExternalModuleNode.js +41 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts +13 -6
- package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -1
- package/dist/core/nodes/ExternalStdioNode.js +15 -8
- package/dist/core/nodes/FunctionNode.d.ts +36 -0
- package/dist/core/nodes/FunctionNode.d.ts.map +1 -1
- package/dist/core/nodes/FunctionNode.js +80 -1
- package/dist/core/nodes/ImportNode.d.ts +19 -5
- package/dist/core/nodes/ImportNode.d.ts.map +1 -1
- package/dist/core/nodes/ImportNode.js +23 -5
- package/dist/core/nodes/InterfaceNode.d.ts +46 -0
- package/dist/core/nodes/InterfaceNode.d.ts.map +1 -0
- package/dist/core/nodes/InterfaceNode.js +55 -0
- package/dist/core/nodes/IssueNode.d.ts +73 -0
- package/dist/core/nodes/IssueNode.d.ts.map +1 -0
- package/dist/core/nodes/IssueNode.js +129 -0
- package/dist/core/nodes/MethodCallNode.d.ts +30 -0
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodCallNode.js +49 -0
- package/dist/core/nodes/MethodNode.d.ts +32 -0
- package/dist/core/nodes/MethodNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodNode.js +48 -0
- package/dist/core/nodes/ModuleNode.d.ts +31 -0
- package/dist/core/nodes/ModuleNode.d.ts.map +1 -1
- package/dist/core/nodes/ModuleNode.js +37 -0
- package/dist/core/nodes/NetworkRequestNode.d.ts +54 -0
- package/dist/core/nodes/NetworkRequestNode.d.ts.map +1 -0
- package/dist/core/nodes/NetworkRequestNode.js +65 -0
- package/dist/core/nodes/ObjectLiteralNode.d.ts +27 -0
- package/dist/core/nodes/ObjectLiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/ObjectLiteralNode.js +41 -0
- package/dist/core/nodes/ScopeNode.d.ts +31 -0
- package/dist/core/nodes/ScopeNode.d.ts.map +1 -1
- package/dist/core/nodes/ScopeNode.js +49 -0
- package/dist/core/nodes/TypeNode.d.ts +36 -0
- package/dist/core/nodes/TypeNode.d.ts.map +1 -0
- package/dist/core/nodes/TypeNode.js +53 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts +27 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -1
- package/dist/core/nodes/VariableDeclarationNode.js +40 -0
- package/dist/core/nodes/index.d.ts +12 -1
- package/dist/core/nodes/index.d.ts.map +1 -1
- package/dist/core/nodes/index.js +14 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts +98 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticCollector.js +129 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts +77 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticReporter.js +159 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts +31 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticWriter.js +43 -0
- package/dist/diagnostics/index.d.ts +14 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +11 -0
- package/dist/errors/GrafemaError.d.ts +118 -0
- package/dist/errors/GrafemaError.d.ts.map +1 -0
- package/dist/errors/GrafemaError.js +131 -0
- package/dist/index.d.ts +57 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -1
- package/dist/logging/Logger.d.ts +48 -0
- package/dist/logging/Logger.d.ts.map +1 -0
- package/dist/logging/Logger.js +134 -0
- package/dist/plugins/Plugin.d.ts +5 -1
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/Plugin.js +33 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/DatabaseAnalyzer.js +13 -6
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressAnalyzer.js +27 -19
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +21 -14
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +1 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/FetchAnalyzer.js +34 -14
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +6 -3
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -1
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +76 -80
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +180 -17
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/JSASTAnalyzer.js +1171 -471
- package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ReactAnalyzer.js +56 -57
- package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/RustAnalyzer.js +15 -10
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SQLiteAnalyzer.js +9 -7
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ServiceLayerAnalyzer.js +21 -9
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SocketIOAnalyzer.js +27 -15
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SystemDbAnalyzer.js +15 -5
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +34 -4
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/GraphBuilder.js +318 -298
- package/dist/plugins/analysis/ast/IdGenerator.d.ts +105 -0
- package/dist/plugins/analysis/ast/IdGenerator.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/IdGenerator.js +116 -0
- package/dist/plugins/analysis/ast/types.d.ts +176 -5
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts +33 -0
- package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/createParameterNodes.js +89 -0
- package/dist/plugins/analysis/ast/utils/index.d.ts +6 -0
- package/dist/plugins/analysis/ast/utils/index.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/index.js +5 -0
- package/dist/plugins/analysis/ast/utils/location.d.ts +87 -0
- package/dist/plugins/analysis/ast/utils/location.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/location.js +78 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +9 -4
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +6 -5
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +99 -9
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +663 -125
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +72 -32
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +128 -63
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +11 -8
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +12 -1
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +36 -14
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +17 -13
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/MonorepoServiceDiscovery.js +3 -2
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/SimpleProjectDiscovery.js +5 -1
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts +22 -0
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/WorkspaceDiscovery.js +136 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts +46 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts.map +1 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.js +86 -0
- package/dist/plugins/discovery/workspaces/detector.d.ts +21 -0
- package/dist/plugins/discovery/workspaces/detector.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/detector.js +49 -0
- package/dist/plugins/discovery/workspaces/globResolver.d.ts +35 -0
- package/dist/plugins/discovery/workspaces/globResolver.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/globResolver.js +184 -0
- package/dist/plugins/discovery/workspaces/index.d.ts +9 -0
- package/dist/plugins/discovery/workspaces/index.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/index.js +8 -0
- package/dist/plugins/discovery/workspaces/parsers.d.ts +38 -0
- package/dist/plugins/discovery/workspaces/parsers.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/parsers.js +80 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -1
- package/dist/plugins/enrichment/AliasTracker.js +14 -8
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +14 -7
- package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -1
- package/dist/plugins/enrichment/ImportExportLinker.js +23 -6
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MethodCallResolver.js +18 -12
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MountPointResolver.js +8 -3
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -1
- package/dist/plugins/enrichment/PrefixEvaluator.js +16 -7
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/RustFFIEnricher.js +6 -5
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +17 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -1
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +129 -10
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/IncrementalModuleIndexer.js +23 -14
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/JSModuleIndexer.js +63 -31
- package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/RustModuleIndexer.js +5 -4
- package/dist/plugins/indexing/ServiceDetector.d.ts +10 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -1
- package/dist/plugins/indexing/ServiceDetector.js +28 -15
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -1
- package/dist/plugins/validation/CallResolverValidator.js +8 -7
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -1
- package/dist/plugins/validation/DataFlowValidator.js +17 -12
- package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -1
- package/dist/plugins/validation/EvalBanValidator.js +17 -16
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -1
- package/dist/plugins/validation/GraphConnectivityValidator.js +19 -23
- package/dist/plugins/validation/NodeCreationValidator.d.ts +85 -0
- package/dist/plugins/validation/NodeCreationValidator.d.ts.map +1 -0
- package/dist/plugins/validation/NodeCreationValidator.js +415 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -1
- package/dist/plugins/validation/SQLInjectionValidator.js +59 -16
- package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -1
- package/dist/plugins/validation/ShadowingDetector.js +6 -5
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -1
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +12 -11
- package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -1
- package/dist/plugins/vcs/GitPlugin.js +10 -12
- package/dist/plugins/vcs/VCSPlugin.d.ts +3 -2
- package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -1
- package/dist/plugins/vcs/VCSPlugin.js +5 -5
- package/dist/storage/backends/RFDBServerBackend.d.ts +10 -17
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -1
- package/dist/storage/backends/RFDBServerBackend.js +31 -10
- package/dist/validation/PathValidator.d.ts +1 -2
- package/dist/validation/PathValidator.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/Orchestrator.ts +237 -24
- package/src/config/ConfigLoader.ts +263 -0
- package/src/config/index.ts +5 -0
- package/src/core/ASTWorker.ts +143 -139
- package/src/core/CoverageAnalyzer.ts +243 -0
- package/src/core/FileNodeManager.ts +100 -0
- package/src/core/GraphFreshnessChecker.ts +143 -0
- package/src/core/HashUtils.ts +48 -0
- package/src/core/IncrementalReanalyzer.ts +192 -0
- package/src/core/NodeFactory.ts +401 -18
- package/src/core/ScopeTracker.ts +154 -0
- package/src/core/SemanticId.ts +192 -0
- package/src/core/VersionManager.ts +3 -2
- package/src/core/nodes/ArgumentExpressionNode.ts +89 -0
- package/src/core/nodes/ArrayLiteralNode.ts +65 -0
- package/src/core/nodes/CallSiteNode.ts +58 -0
- package/src/core/nodes/ClassNode.ts +63 -2
- package/src/core/nodes/DecoratorNode.ts +91 -0
- package/src/core/nodes/EnumNode.ts +86 -0
- package/src/core/nodes/ExportNode.ts +70 -2
- package/src/core/nodes/ExpressionNode.ts +231 -0
- package/src/core/nodes/ExternalModuleNode.ts +56 -0
- package/src/core/nodes/ExternalStdioNode.ts +17 -9
- package/src/core/nodes/FunctionNode.ts +101 -1
- package/src/core/nodes/ImportNode.ts +32 -10
- package/src/core/nodes/InterfaceNode.ts +91 -0
- package/src/core/nodes/IssueNode.ts +177 -0
- package/src/core/nodes/MethodCallNode.ts +64 -0
- package/src/core/nodes/MethodNode.ts +63 -0
- package/src/core/nodes/ModuleNode.ts +50 -0
- package/src/core/nodes/NetworkRequestNode.ts +77 -0
- package/src/core/nodes/ObjectLiteralNode.ts +65 -0
- package/src/core/nodes/ScopeNode.ts +65 -0
- package/src/core/nodes/TypeNode.ts +78 -0
- package/src/core/nodes/VariableDeclarationNode.ts +52 -0
- package/src/core/nodes/index.ts +18 -1
- package/src/diagnostics/DiagnosticCollector.ts +163 -0
- package/src/diagnostics/DiagnosticReporter.ts +204 -0
- package/src/diagnostics/DiagnosticWriter.ts +50 -0
- package/src/diagnostics/index.ts +16 -0
- package/src/errors/GrafemaError.ts +174 -0
- package/src/index.ts +148 -1
- package/src/logging/Logger.ts +152 -0
- package/src/plugins/Plugin.ts +42 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +14 -8
- package/src/plugins/analysis/ExpressAnalyzer.ts +29 -19
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +22 -21
- package/src/plugins/analysis/FetchAnalyzer.ts +39 -16
- package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +84 -101
- package/src/plugins/analysis/JSASTAnalyzer.ts +1483 -503
- package/src/plugins/analysis/ReactAnalyzer.ts +57 -57
- package/src/plugins/analysis/RustAnalyzer.ts +15 -10
- package/src/plugins/analysis/SQLiteAnalyzer.ts +10 -7
- package/src/plugins/analysis/ServiceLayerAnalyzer.ts +22 -16
- package/src/plugins/analysis/SocketIOAnalyzer.ts +31 -22
- package/src/plugins/analysis/SystemDbAnalyzer.ts +16 -11
- package/src/plugins/analysis/ast/GraphBuilder.ts +439 -327
- package/src/plugins/analysis/ast/IdGenerator.ts +177 -0
- package/src/plugins/analysis/ast/types.ts +209 -6
- package/src/plugins/analysis/ast/utils/createParameterNodes.ts +104 -0
- package/src/plugins/analysis/ast/utils/index.ts +12 -0
- package/src/plugins/analysis/ast/utils/location.ts +103 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +11 -8
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +909 -83
- package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +97 -44
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +159 -93
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +12 -8
- package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +41 -14
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +37 -17
- package/src/plugins/discovery/MonorepoServiceDiscovery.ts +3 -2
- package/src/plugins/discovery/SimpleProjectDiscovery.ts +6 -1
- package/src/plugins/discovery/WorkspaceDiscovery.ts +177 -0
- package/src/plugins/discovery/resolveSourceEntrypoint.ts +103 -0
- package/src/plugins/discovery/workspaces/detector.ts +63 -0
- package/src/plugins/discovery/workspaces/globResolver.ts +229 -0
- package/src/plugins/discovery/workspaces/index.ts +23 -0
- package/src/plugins/discovery/workspaces/parsers.ts +99 -0
- package/src/plugins/enrichment/AliasTracker.ts +14 -8
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +14 -7
- package/src/plugins/enrichment/ImportExportLinker.ts +24 -6
- package/src/plugins/enrichment/MethodCallResolver.ts +18 -12
- package/src/plugins/enrichment/MountPointResolver.ts +8 -3
- package/src/plugins/enrichment/PrefixEvaluator.ts +16 -7
- package/src/plugins/enrichment/RustFFIEnricher.ts +6 -5
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +149 -12
- package/src/plugins/indexing/IncrementalModuleIndexer.ts +23 -14
- package/src/plugins/indexing/JSModuleIndexer.ts +74 -34
- package/src/plugins/indexing/RustModuleIndexer.ts +5 -4
- package/src/plugins/validation/CallResolverValidator.ts +8 -7
- package/src/plugins/validation/DataFlowValidator.ts +16 -12
- package/src/plugins/validation/EvalBanValidator.ts +17 -16
- package/src/plugins/validation/GraphConnectivityValidator.ts +19 -23
- package/src/plugins/validation/NodeCreationValidator.ts +554 -0
- package/src/plugins/validation/SQLInjectionValidator.ts +61 -15
- package/src/plugins/validation/ShadowingDetector.ts +6 -5
- package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +12 -11
- package/src/plugins/vcs/GitPlugin.ts +40 -12
- package/src/plugins/vcs/VCSPlugin.ts +7 -5
- package/src/storage/backends/RFDBServerBackend.ts +43 -29
- package/src/validation/PathValidator.ts +1 -1
- package/dist/core/AnalysisWorker.d.ts +0 -14
- package/dist/core/AnalysisWorker.d.ts.map +0 -1
- package/dist/core/AnalysisWorker.js +0 -307
- package/dist/core/ParallelAnalyzer.d.ts +0 -120
- package/dist/core/ParallelAnalyzer.d.ts.map +0 -1
- package/dist/core/ParallelAnalyzer.js +0 -331
- package/dist/core/QueueWorker.d.ts +0 -12
- package/dist/core/QueueWorker.d.ts.map +0 -1
- package/dist/core/QueueWorker.js +0 -567
- package/dist/core/RFDBClient.d.ts +0 -179
- package/dist/core/RFDBClient.d.ts.map +0 -1
- package/dist/core/RFDBClient.js +0 -429
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +0 -19
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +0 -1
- package/dist/plugins/discovery/ZonServiceDiscovery.js +0 -204
- package/src/core/AnalysisWorker.ts +0 -410
- package/src/core/ParallelAnalyzer.ts +0 -476
- package/src/core/QueueWorker.ts +0 -780
- package/src/plugins/indexing/ServiceDetector.ts +0 -230
|
@@ -17,6 +17,9 @@ import type {
|
|
|
17
17
|
import type { NodePath } from '@babel/traverse';
|
|
18
18
|
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers, type CounterRef } from './ASTVisitor.js';
|
|
19
19
|
import { ExpressionEvaluator } from '../ExpressionEvaluator.js';
|
|
20
|
+
import { ScopeTracker } from '../../../../core/ScopeTracker.js';
|
|
21
|
+
import { IdGenerator } from '../IdGenerator.js';
|
|
22
|
+
import { NodeFactory } from '../../../../core/NodeFactory.js';
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* Variable info extracted from pattern
|
|
@@ -100,22 +103,26 @@ interface VariableAssignmentInfo {
|
|
|
100
103
|
export class VariableVisitor extends ASTVisitor {
|
|
101
104
|
private extractVariableNamesFromPattern: ExtractVariableNamesCallback;
|
|
102
105
|
private trackVariableAssignment: TrackVariableAssignmentCallback;
|
|
106
|
+
private scopeTracker?: ScopeTracker;
|
|
103
107
|
|
|
104
108
|
/**
|
|
105
109
|
* @param module - Current module being analyzed
|
|
106
110
|
* @param collections - Must contain arrays and counter refs
|
|
107
111
|
* @param extractVariableNamesFromPattern - Helper for destructuring
|
|
108
112
|
* @param trackVariableAssignment - Helper for data flow tracking
|
|
113
|
+
* @param scopeTracker - Optional ScopeTracker for semantic ID generation
|
|
109
114
|
*/
|
|
110
115
|
constructor(
|
|
111
116
|
module: VisitorModule,
|
|
112
117
|
collections: VisitorCollections,
|
|
113
118
|
extractVariableNamesFromPattern: ExtractVariableNamesCallback,
|
|
114
|
-
trackVariableAssignment: TrackVariableAssignmentCallback
|
|
119
|
+
trackVariableAssignment: TrackVariableAssignmentCallback,
|
|
120
|
+
scopeTracker?: ScopeTracker
|
|
115
121
|
) {
|
|
116
122
|
super(module, collections);
|
|
117
123
|
this.extractVariableNamesFromPattern = extractVariableNamesFromPattern;
|
|
118
124
|
this.trackVariableAssignment = trackVariableAssignment;
|
|
125
|
+
this.scopeTracker = scopeTracker;
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
getHandlers(): VisitorHandlers {
|
|
@@ -126,6 +133,7 @@ export class VariableVisitor extends ASTVisitor {
|
|
|
126
133
|
const variableAssignments = this.collections.variableAssignments ?? [];
|
|
127
134
|
const varDeclCounterRef = (this.collections.varDeclCounterRef ?? { value: 0 }) as CounterRef;
|
|
128
135
|
const literalCounterRef = (this.collections.literalCounterRef ?? { value: 0 }) as CounterRef;
|
|
136
|
+
const scopeTracker = this.scopeTracker;
|
|
129
137
|
|
|
130
138
|
const extractVariableNamesFromPattern = this.extractVariableNamesFromPattern;
|
|
131
139
|
const trackVariableAssignment = this.trackVariableAssignment;
|
|
@@ -151,9 +159,18 @@ export class VariableVisitor extends ASTVisitor {
|
|
|
151
159
|
// For everything else - VARIABLE
|
|
152
160
|
const shouldBeConstant = isConst && (isLiteral || isNewExpression);
|
|
153
161
|
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
const nodeType = shouldBeConstant ? 'CONSTANT' : 'VARIABLE';
|
|
163
|
+
|
|
164
|
+
// Generate ID using centralized IdGenerator
|
|
165
|
+
const idGenerator = new IdGenerator(scopeTracker);
|
|
166
|
+
const varId = idGenerator.generate(
|
|
167
|
+
nodeType,
|
|
168
|
+
varInfo.name,
|
|
169
|
+
module.file,
|
|
170
|
+
varInfo.loc.start.line,
|
|
171
|
+
varInfo.loc.start.column,
|
|
172
|
+
varDeclCounterRef as CounterRef
|
|
173
|
+
);
|
|
157
174
|
|
|
158
175
|
if (shouldBeConstant) {
|
|
159
176
|
// CONSTANT node
|
|
@@ -213,20 +230,23 @@ export class VariableVisitor extends ASTVisitor {
|
|
|
213
230
|
expressionPath = `${initName}[${varInfo.arrayIndex}]`;
|
|
214
231
|
}
|
|
215
232
|
|
|
216
|
-
const expressionId = `EXPRESSION#${expressionPath}#${module.file}#${varInfo.loc.start.line}:${varInfo.loc.start.column}`;
|
|
217
|
-
|
|
218
233
|
// Create EXPRESSION node representing the property access
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
const expressionType = varInfo.propertyPath ? 'MemberExpression' : 'ArrayAccess';
|
|
235
|
+
const expressionNode = NodeFactory.createExpression(
|
|
236
|
+
expressionType,
|
|
237
|
+
module.file,
|
|
238
|
+
varInfo.loc.start.line,
|
|
239
|
+
varInfo.loc.start.column,
|
|
240
|
+
{
|
|
241
|
+
path: expressionPath,
|
|
242
|
+
baseName: initName,
|
|
243
|
+
propertyPath: varInfo.propertyPath || undefined,
|
|
244
|
+
arrayIndex: varInfo.arrayIndex
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
const expressionId = expressionNode.id;
|
|
249
|
+
(literals as LiteralExpressionInfo[]).push(expressionNode as LiteralExpressionInfo);
|
|
230
250
|
|
|
231
251
|
// Create ASSIGNED_FROM edge: VARIABLE -> EXPRESSION
|
|
232
252
|
(variableAssignments as VariableAssignmentInfo[]).push({
|
|
@@ -57,10 +57,11 @@ export class MonorepoServiceDiscovery extends DiscoveryPlugin {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
60
|
+
const logger = this.log(context);
|
|
60
61
|
const { projectPath, graph } = context;
|
|
61
62
|
const servicesPath = join(projectPath!, this.servicesDir);
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
logger.debug('Looking for services', { servicesPath });
|
|
64
65
|
|
|
65
66
|
if (!existsSync(servicesPath)) {
|
|
66
67
|
return createErrorResult(
|
|
@@ -71,7 +72,7 @@ export class MonorepoServiceDiscovery extends DiscoveryPlugin {
|
|
|
71
72
|
try {
|
|
72
73
|
const services: ServiceInfo[] = [];
|
|
73
74
|
const entries = readdirSync(servicesPath);
|
|
74
|
-
|
|
75
|
+
logger.debug('Found entries', { count: entries.length });
|
|
75
76
|
|
|
76
77
|
for (const entry of entries) {
|
|
77
78
|
const fullPath = join(servicesPath, entry);
|
|
@@ -11,6 +11,7 @@ import { join } from 'path';
|
|
|
11
11
|
import { NodeFactory } from '../../core/NodeFactory.js';
|
|
12
12
|
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
13
13
|
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
14
|
+
import { resolveSourceEntrypoint } from './resolveSourceEntrypoint.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Service info returned in metadata
|
|
@@ -33,6 +34,7 @@ interface PackageJson {
|
|
|
33
34
|
name?: string;
|
|
34
35
|
version?: string;
|
|
35
36
|
main?: string;
|
|
37
|
+
source?: string;
|
|
36
38
|
description?: string;
|
|
37
39
|
dependencies?: Record<string, string>;
|
|
38
40
|
}
|
|
@@ -70,7 +72,10 @@ export class SimpleProjectDiscovery extends Plugin {
|
|
|
70
72
|
try {
|
|
71
73
|
const packageJson: PackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
72
74
|
const serviceName = packageJson.name || 'unnamed-service';
|
|
73
|
-
|
|
75
|
+
// Prefer TypeScript source over compiled output
|
|
76
|
+
const entrypoint = resolveSourceEntrypoint(projectPath, packageJson)
|
|
77
|
+
?? packageJson.main
|
|
78
|
+
?? 'index.js';
|
|
74
79
|
|
|
75
80
|
// Используем NodeFactory для создания SERVICE ноды
|
|
76
81
|
const serviceNode = NodeFactory.createService(serviceName, projectPath, {
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkspaceDiscovery - Discovery plugin for npm/pnpm/yarn/lerna workspaces
|
|
3
|
+
*
|
|
4
|
+
* Detects workspace configuration and creates SERVICE nodes for each package.
|
|
5
|
+
* Priority: 110 (higher than MonorepoServiceDiscovery at 100)
|
|
6
|
+
*
|
|
7
|
+
* Supports:
|
|
8
|
+
* - pnpm-workspace.yaml
|
|
9
|
+
* - package.json workspaces (npm/yarn)
|
|
10
|
+
* - lerna.json
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { DiscoveryPlugin } from './DiscoveryPlugin.js';
|
|
14
|
+
import { createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
15
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
16
|
+
import { detectWorkspaceType } from './workspaces/detector.js';
|
|
17
|
+
import { parsePnpmWorkspace, parseNpmWorkspace, parseLernaConfig } from './workspaces/parsers.js';
|
|
18
|
+
import { resolveWorkspacePackages, type WorkspacePackage } from './workspaces/globResolver.js';
|
|
19
|
+
import { NodeFactory } from '../../core/NodeFactory.js';
|
|
20
|
+
import { resolveSourceEntrypoint } from './resolveSourceEntrypoint.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Service info returned in result metadata
|
|
24
|
+
*/
|
|
25
|
+
interface ServiceInfo {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
path: string;
|
|
29
|
+
type: string;
|
|
30
|
+
metadata: {
|
|
31
|
+
workspaceType: string;
|
|
32
|
+
relativePath: string;
|
|
33
|
+
entrypoint: string | null;
|
|
34
|
+
packageJson: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class WorkspaceDiscovery extends DiscoveryPlugin {
|
|
39
|
+
get metadata(): PluginMetadata {
|
|
40
|
+
return {
|
|
41
|
+
name: 'WorkspaceDiscovery',
|
|
42
|
+
phase: 'DISCOVERY',
|
|
43
|
+
priority: 110, // Higher than MonorepoServiceDiscovery (100)
|
|
44
|
+
creates: {
|
|
45
|
+
nodes: ['SERVICE'],
|
|
46
|
+
edges: []
|
|
47
|
+
},
|
|
48
|
+
dependencies: []
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async execute(context: PluginContext): Promise<PluginResult> {
|
|
53
|
+
const logger = this.log(context);
|
|
54
|
+
const { projectPath, graph } = context;
|
|
55
|
+
|
|
56
|
+
// Validate projectPath
|
|
57
|
+
if (!projectPath) {
|
|
58
|
+
return createErrorResult(new Error('projectPath is required'));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
logger.debug('Detecting workspace type', { projectPath });
|
|
62
|
+
|
|
63
|
+
// Step 1: Detect workspace type
|
|
64
|
+
const detection = detectWorkspaceType(projectPath);
|
|
65
|
+
|
|
66
|
+
if (!detection.type) {
|
|
67
|
+
logger.debug('Not a workspace project, skipping');
|
|
68
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, {
|
|
69
|
+
services: [],
|
|
70
|
+
skipped: true,
|
|
71
|
+
reason: 'No workspace configuration found'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
logger.info('Workspace detected', {
|
|
76
|
+
type: detection.type,
|
|
77
|
+
configPath: detection.configPath
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Step 2: Parse workspace configuration
|
|
81
|
+
let config;
|
|
82
|
+
try {
|
|
83
|
+
switch (detection.type) {
|
|
84
|
+
case 'pnpm':
|
|
85
|
+
config = parsePnpmWorkspace(detection.configPath!);
|
|
86
|
+
break;
|
|
87
|
+
case 'npm':
|
|
88
|
+
case 'yarn':
|
|
89
|
+
config = parseNpmWorkspace(detection.configPath!);
|
|
90
|
+
break;
|
|
91
|
+
case 'lerna':
|
|
92
|
+
config = parseLernaConfig(detection.configPath!);
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
throw new Error(`Unknown workspace type: ${detection.type}`);
|
|
96
|
+
}
|
|
97
|
+
} catch (error) {
|
|
98
|
+
return createErrorResult(error as Error);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
logger.debug('Workspace config parsed', {
|
|
102
|
+
patterns: config.patterns,
|
|
103
|
+
negativePatterns: config.negativePatterns
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Step 3: Resolve patterns to packages
|
|
107
|
+
const packages = resolveWorkspacePackages(projectPath, config);
|
|
108
|
+
|
|
109
|
+
logger.info('Workspace packages resolved', { count: packages.length });
|
|
110
|
+
|
|
111
|
+
// Step 4: Create SERVICE nodes
|
|
112
|
+
const services: ServiceInfo[] = [];
|
|
113
|
+
|
|
114
|
+
for (const pkg of packages) {
|
|
115
|
+
const serviceNode = this.createServiceNode(pkg, detection.type!, projectPath);
|
|
116
|
+
|
|
117
|
+
await graph.addNode(serviceNode);
|
|
118
|
+
|
|
119
|
+
services.push({
|
|
120
|
+
id: serviceNode.id,
|
|
121
|
+
name: pkg.name,
|
|
122
|
+
path: pkg.path,
|
|
123
|
+
type: 'workspace-package',
|
|
124
|
+
metadata: {
|
|
125
|
+
workspaceType: detection.type!,
|
|
126
|
+
relativePath: pkg.relativePath,
|
|
127
|
+
entrypoint: serviceNode.entrypoint,
|
|
128
|
+
packageJson: pkg.packageJson as Record<string, unknown>
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
logger.info('Services created from workspace', {
|
|
134
|
+
count: services.length,
|
|
135
|
+
workspaceType: detection.type
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return createSuccessResult(
|
|
139
|
+
{ nodes: services.length, edges: 0 },
|
|
140
|
+
{ services, workspaceType: detection.type }
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Create SERVICE node from workspace package.
|
|
146
|
+
*/
|
|
147
|
+
private createServiceNode(pkg: WorkspacePackage, workspaceType: string, _projectPath: string) {
|
|
148
|
+
// Resolve entrypoint (prefer TypeScript source)
|
|
149
|
+
const entrypoint = resolveSourceEntrypoint(pkg.path, pkg.packageJson)
|
|
150
|
+
?? (pkg.packageJson.main as string | undefined)
|
|
151
|
+
?? null;
|
|
152
|
+
|
|
153
|
+
const serviceNode = NodeFactory.createService(pkg.name, pkg.path, {
|
|
154
|
+
discoveryMethod: 'workspace',
|
|
155
|
+
entrypoint: entrypoint ?? undefined,
|
|
156
|
+
version: pkg.packageJson.version as string | undefined,
|
|
157
|
+
description: pkg.packageJson.description as string | undefined,
|
|
158
|
+
dependencies: Object.keys(pkg.packageJson.dependencies || {})
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// Add metadata for workspace-specific information
|
|
162
|
+
// BaseNodeRecord supports optional metadata field
|
|
163
|
+
const nodeWithMetadata = serviceNode as typeof serviceNode & { metadata: Record<string, unknown> };
|
|
164
|
+
nodeWithMetadata.metadata = {
|
|
165
|
+
workspaceType,
|
|
166
|
+
discoveryMethod: 'workspace',
|
|
167
|
+
relativePath: pkg.relativePath,
|
|
168
|
+
version: pkg.packageJson.version as string | undefined,
|
|
169
|
+
description: pkg.packageJson.description as string | undefined,
|
|
170
|
+
private: pkg.packageJson.private as boolean | undefined,
|
|
171
|
+
dependencies: Object.keys(pkg.packageJson.dependencies || {}),
|
|
172
|
+
entrypoint: entrypoint
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
return nodeWithMetadata;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves TypeScript source entrypoints for projects.
|
|
3
|
+
*
|
|
4
|
+
* This utility prefers TypeScript source files (src/index.ts) over compiled
|
|
5
|
+
* output (dist/index.js) when analyzing TypeScript projects.
|
|
6
|
+
*
|
|
7
|
+
* Resolution order:
|
|
8
|
+
* 1. If no tsconfig.json exists -> return null (not a TypeScript project)
|
|
9
|
+
* 2. Check package.json "source" field (explicit source declaration)
|
|
10
|
+
* 3. Try standard TypeScript source candidates
|
|
11
|
+
* 4. Return null if no source found (caller should fallback to main)
|
|
12
|
+
*
|
|
13
|
+
* @module resolveSourceEntrypoint
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { existsSync } from 'fs';
|
|
17
|
+
import { join } from 'path';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Package.json fields relevant for source resolution
|
|
21
|
+
*/
|
|
22
|
+
export interface PackageJsonForResolution {
|
|
23
|
+
main?: string;
|
|
24
|
+
source?: string; // Used by bundlers like Parcel
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Standard TypeScript source candidates in priority order.
|
|
29
|
+
*
|
|
30
|
+
* Order rationale:
|
|
31
|
+
* - src/ is the most common convention
|
|
32
|
+
* - lib/ is used by some projects
|
|
33
|
+
* - root-level is fallback
|
|
34
|
+
* - index is more common than main
|
|
35
|
+
* - .ts preferred over .tsx over .mts
|
|
36
|
+
*/
|
|
37
|
+
const TS_SOURCE_CANDIDATES = [
|
|
38
|
+
'src/index.ts',
|
|
39
|
+
'src/index.tsx',
|
|
40
|
+
'src/index.mts',
|
|
41
|
+
'src/main.ts',
|
|
42
|
+
'src/main.tsx',
|
|
43
|
+
'lib/index.ts',
|
|
44
|
+
'lib/index.tsx',
|
|
45
|
+
'index.ts',
|
|
46
|
+
'index.tsx',
|
|
47
|
+
'index.mts',
|
|
48
|
+
'main.ts',
|
|
49
|
+
'main.tsx',
|
|
50
|
+
] as const;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Resolves the source entrypoint for a project, preferring TypeScript source
|
|
54
|
+
* over compiled output.
|
|
55
|
+
*
|
|
56
|
+
* @param projectPath - Absolute path to the project/service directory
|
|
57
|
+
* @param packageJson - Parsed package.json content (only relevant fields needed)
|
|
58
|
+
* @returns Source entrypoint relative to projectPath, or null if not found
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // TypeScript project with src/index.ts
|
|
62
|
+
* resolveSourceEntrypoint('/path/to/project', { main: 'dist/index.js' })
|
|
63
|
+
* // Returns: 'src/index.ts'
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // JavaScript project (no tsconfig.json)
|
|
67
|
+
* resolveSourceEntrypoint('/path/to/project', { main: 'index.js' })
|
|
68
|
+
* // Returns: null
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // TypeScript project with explicit source field
|
|
72
|
+
* resolveSourceEntrypoint('/path/to/project', { main: 'dist/index.js', source: 'lib/entry.ts' })
|
|
73
|
+
* // Returns: 'lib/entry.ts' (if file exists)
|
|
74
|
+
*/
|
|
75
|
+
export function resolveSourceEntrypoint(
|
|
76
|
+
projectPath: string,
|
|
77
|
+
packageJson: PackageJsonForResolution
|
|
78
|
+
): string | null {
|
|
79
|
+
// Step 1: Check for TypeScript project indicator
|
|
80
|
+
const tsconfigPath = join(projectPath, 'tsconfig.json');
|
|
81
|
+
if (!existsSync(tsconfigPath)) {
|
|
82
|
+
return null; // Not a TypeScript project
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Step 2: Check package.json "source" field (explicit source declaration)
|
|
86
|
+
if (packageJson.source) {
|
|
87
|
+
const sourcePath = join(projectPath, packageJson.source);
|
|
88
|
+
if (existsSync(sourcePath)) {
|
|
89
|
+
return packageJson.source;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Step 3: Try standard TypeScript source candidates
|
|
94
|
+
for (const candidate of TS_SOURCE_CANDIDATES) {
|
|
95
|
+
const candidatePath = join(projectPath, candidate);
|
|
96
|
+
if (existsSync(candidatePath)) {
|
|
97
|
+
return candidate;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Step 4: Not found - caller should fallback to main
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Type Detector
|
|
3
|
+
*
|
|
4
|
+
* Detects which workspace system is used in a project by checking
|
|
5
|
+
* for configuration files in priority order: pnpm > npm/yarn > lerna.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { existsSync, readFileSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
|
|
11
|
+
export type WorkspaceType = 'pnpm' | 'npm' | 'yarn' | 'lerna' | null;
|
|
12
|
+
|
|
13
|
+
export interface WorkspaceDetectionResult {
|
|
14
|
+
type: WorkspaceType;
|
|
15
|
+
configPath: string | null;
|
|
16
|
+
rootPath: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Detect workspace type by checking for configuration files.
|
|
21
|
+
* Priority: pnpm > npm/yarn > lerna (most specific first)
|
|
22
|
+
*
|
|
23
|
+
* @param projectPath - Root directory of the project
|
|
24
|
+
* @returns Detection result with type, config path, and root path
|
|
25
|
+
*/
|
|
26
|
+
export function detectWorkspaceType(projectPath: string): WorkspaceDetectionResult {
|
|
27
|
+
// 1. Check for pnpm-workspace.yaml (highest priority)
|
|
28
|
+
const pnpmYaml = join(projectPath, 'pnpm-workspace.yaml');
|
|
29
|
+
const pnpmYml = join(projectPath, 'pnpm-workspace.yml');
|
|
30
|
+
|
|
31
|
+
if (existsSync(pnpmYaml)) {
|
|
32
|
+
return { type: 'pnpm', configPath: pnpmYaml, rootPath: projectPath };
|
|
33
|
+
}
|
|
34
|
+
if (existsSync(pnpmYml)) {
|
|
35
|
+
return { type: 'pnpm', configPath: pnpmYml, rootPath: projectPath };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 2. Check for npm/yarn workspaces in package.json
|
|
39
|
+
const packageJsonPath = join(projectPath, 'package.json');
|
|
40
|
+
if (existsSync(packageJsonPath)) {
|
|
41
|
+
try {
|
|
42
|
+
const content = readFileSync(packageJsonPath, 'utf-8');
|
|
43
|
+
const pkg = JSON.parse(content);
|
|
44
|
+
|
|
45
|
+
if (pkg.workspaces) {
|
|
46
|
+
// Both npm and yarn use package.json workspaces - detect as 'npm'
|
|
47
|
+
// The format is compatible for both
|
|
48
|
+
return { type: 'npm', configPath: packageJsonPath, rootPath: projectPath };
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
// Ignore JSON parse errors
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 3. Check for lerna.json
|
|
56
|
+
const lernaJsonPath = join(projectPath, 'lerna.json');
|
|
57
|
+
if (existsSync(lernaJsonPath)) {
|
|
58
|
+
return { type: 'lerna', configPath: lernaJsonPath, rootPath: projectPath };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// No workspace configuration found
|
|
62
|
+
return { type: null, configPath: null, rootPath: projectPath };
|
|
63
|
+
}
|