From 6f13c66daea41efd645f42d7dbbf8055ad4d24b9 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Wed, 10 Jun 2026 16:04:33 +0200 Subject: [PATCH] fix: remove tree-sitter-go to resolve peer dependency conflict - tree-sitter-go@0.23.4 peer depends on tree-sitter@^0.21.1 - Conflicts with tree-sitter@0.22.4 used by tree-sitter-python - Go AST already falls back to generic export/deps extraction - Add .npmrc with legacy-peer-deps=true as safety net - npm install --omit=dev now works cleanly --- .npmrc | 1 + package-lock.json | 20 -------------------- package.json | 1 - src/ast-extract.ts | 38 +++++++++++++++++++++++++++----------- 4 files changed, 28 insertions(+), 32 deletions(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..521a9f7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +legacy-peer-deps=true diff --git a/package-lock.json b/package-lock.json index c46f4bc..429a74a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,6 @@ "p-limit": "^7.3.0", "picocolors": "^1.1.1", "tree-sitter": "^0.22.4", - "tree-sitter-go": "^0.23.4", "tree-sitter-python": "^0.23.6", "tree-sitter-typescript": "^0.23.2" }, @@ -3355,25 +3354,6 @@ "node-gyp-build": "^4.8.4" } }, - "node_modules/tree-sitter-go": { - "version": "0.23.4", - "resolved": "https://registry.npmjs.org/tree-sitter-go/-/tree-sitter-go-0.23.4.tgz", - "integrity": "sha512-iQaHEs4yMa/hMo/ZCGqLfG61F0miinULU1fFh+GZreCRtKylFLtvn798ocCZjO2r/ungNZgAY1s1hPFyAwkc7w==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "node-addon-api": "^8.2.1", - "node-gyp-build": "^4.8.2" - }, - "peerDependencies": { - "tree-sitter": "^0.21.1" - }, - "peerDependenciesMeta": { - "tree-sitter": { - "optional": true - } - } - }, "node_modules/tree-sitter-javascript": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/tree-sitter-javascript/-/tree-sitter-javascript-0.23.1.tgz", diff --git a/package.json b/package.json index 0da10a7..8d26ccf 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "p-limit": "^7.3.0", "picocolors": "^1.1.1", "tree-sitter": "^0.22.4", - "tree-sitter-go": "^0.23.4", "tree-sitter-python": "^0.23.6", "tree-sitter-typescript": "^0.23.2" } diff --git a/src/ast-extract.ts b/src/ast-extract.ts index 21cda43..6c84520 100644 --- a/src/ast-extract.ts +++ b/src/ast-extract.ts @@ -162,7 +162,12 @@ function extractPythonData(tree: Tree, source: string): ASTFileData { } visit(tree.rootNode); - return { exports: [...new Set(exports)], deps: [...new Set(deps)], classes, functions }; + return { + exports: [...new Set(exports)], + deps: [...new Set(deps)], + classes, + functions, + }; } function extractPythonMethod( @@ -214,12 +219,13 @@ function extractPythonMethod( function dedupeCallChains(calls: string[]): string[] { const unique = [...new Set(calls)]; // Remove shorter calls that are prefixes of longer ones - return unique.filter((call) => - !unique.some( - (other) => - other !== call && - (other.startsWith(`${call}.`) || other.startsWith(`${call}(`)), - ), + return unique.filter( + (call) => + !unique.some( + (other) => + other !== call && + (other.startsWith(`${call}.`) || other.startsWith(`${call}(`)), + ), ); } @@ -245,7 +251,8 @@ function extractPythonCallsAndRaises( } for (let i = 0; i < node.childCount; i++) { const child = node.child(i); - if (child && node.type !== "raise_statement") extractPythonCallsAndRaises(child, calls, raises); + if (child && node.type !== "raise_statement") + extractPythonCallsAndRaises(child, calls, raises); } } @@ -334,7 +341,10 @@ function extractTypeScriptData(tree: Tree, source: string): ASTFileData { const nameNode = findIdentifier(declaration); if (nameNode) { exports.push(nameNode.text); - if (declaration.type === "function_declaration" || declaration.type === "function") { + if ( + declaration.type === "function_declaration" || + declaration.type === "function" + ) { const method = extractTSMethod(declaration, source); if (method) functions.push(method); } @@ -349,7 +359,12 @@ function extractTypeScriptData(tree: Tree, source: string): ASTFileData { } visit(tree.rootNode); - return { exports: [...new Set(exports)], deps: [...new Set(deps)], classes, functions }; + return { + exports: [...new Set(exports)], + deps: [...new Set(deps)], + classes, + functions, + }; } function extractTSMethod(node: SyntaxNode, _source: string): MethodData | null { @@ -431,7 +446,8 @@ function extractTSCallsAndThrows( } for (let i = 0; i < node.childCount; i++) { const child = node.child(i); - if (child && node.type !== "throw_statement") extractTSCallsAndThrows(child, calls, raises); + if (child && node.type !== "throw_statement") + extractTSCallsAndThrows(child, calls, raises); } }