UNPKG

symref

Version:

Static code checker for AI code agents (Windsurf, Cline, etc.)

49 lines 2.37 kB
import { SymbolReferenceAnalyzer } from '../../analyzer/SymbolReferenceAnalyzer.js'; import { CallGraphAnalyzer } from '../../analyzer/CallGraphAnalyzer.js'; import * as path from 'node:path'; /** * Reactコンポーネント間の呼び出しグラフを生成するコマンドクラス */ export class ComponentGraphCommand { /** * コマンドを実行する * @param options オプション * @returns Promiseオブジェクト */ static async execute(options) { try { console.log('Reactコンポーネント間の呼び出しグラフを生成しています...'); // 解析オプションを構築 const analyzerOptions = { basePath: options.dir || '.', tsConfigPath: options.project || 'tsconfig.json', includePatterns: options.include ? options.include.split(',') : undefined, excludePatterns: options.exclude ? options.exclude.split(',') : undefined }; // シンボル参照分析器を初期化 const analyzer = new SymbolReferenceAnalyzer(analyzerOptions); console.log(`プロジェクトを解析中: ${path.resolve(analyzerOptions.basePath)}`); // CallGraphAnalyzerを初期化 const outputDir = options.outputDir || '.symbols'; const project = analyzer.getProject(); const callGraphAnalyzer = new CallGraphAnalyzer(project, outputDir); // 呼び出しグラフを構築 const nodeCount = callGraphAnalyzer.buildCallGraph(); console.log(`呼び出しグラフノード数: ${nodeCount}`); // コンポーネントグラフを生成 const outputFileName = options.outputName || 'react-component-graph'; const outputPath = callGraphAnalyzer.generateComponentGraph(outputFileName); if (outputPath) { console.log(`コンポーネントグラフを生成しました: ${outputPath}`); } else { console.log('Reactコンポーネントが見つかりませんでした。'); } } catch (error) { console.error('エラーが発生しました:', error); process.exit(1); } } } //# sourceMappingURL=ComponentGraphCommand.js.map