graphlens-typescript 0.2.2__tar.gz → 0.3.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: graphlens-typescript
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: TypeScript language adapter for graphlens
5
5
  Requires-Dist: graphlens
6
6
  Requires-Dist: tree-sitter>=0.24
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "graphlens-typescript"
3
- version = "0.2.2"
3
+ version = "0.3.0"
4
4
  description = "TypeScript language adapter for graphlens"
5
5
  requires-python = ">=3.13"
6
6
  dependencies = [
@@ -14,6 +14,7 @@ from graphlens import (
14
14
  RelationKind,
15
15
  )
16
16
  from graphlens.utils import make_node_id
17
+ from graphlens.utils.roots import filter_nested_root_files
17
18
 
18
19
  from graphlens_typescript._deps import (
19
20
  TYPESCRIPT_DEFAULT_DEP_PARSERS,
@@ -109,8 +110,14 @@ class TypescriptAdapter(LanguageAdapter):
109
110
  self._dep_parsers,
110
111
  )
111
112
  else:
112
- for lang_root in find_typescript_roots(project_root):
113
+ lang_roots = find_typescript_roots(project_root)
114
+ for lang_root in lang_roots:
113
115
  root_files = self.collect_files(lang_root)
116
+ root_files = filter_nested_root_files(
117
+ root_files,
118
+ lang_root,
119
+ lang_roots,
120
+ )
114
121
  _analyze_root(
115
122
  graph,
116
123
  project_root,
@@ -6,6 +6,8 @@ import json
6
6
  import re
7
7
  from typing import TYPE_CHECKING
8
8
 
9
+ from graphlens.utils import collect_marker_roots
10
+
9
11
  if TYPE_CHECKING:
10
12
  from pathlib import Path
11
13
 
@@ -42,26 +44,30 @@ def find_typescript_roots(search_root: Path) -> list[Path]:
42
44
  """
43
45
  Find TypeScript project roots within search_root (monorepo support).
44
46
 
45
- Returns [search_root] if search_root itself has markers.
46
- Otherwise walks subdirectories for marker files and returns distinct roots.
47
- Falls back to [search_root] if nothing found.
47
+ A marker at ``search_root`` does not hide nested package roots.
48
+ ``tsconfig`` files inside an existing ``package.json`` root are treated as
49
+ that package's config rather than as independent roots.
48
50
  """
49
- if _has_typescript_markers(search_root):
50
- return [search_root]
51
-
52
- roots: list[Path] = []
53
- for marker in TYPESCRIPT_MARKERS:
54
- for marker_file in sorted(search_root.rglob(marker)):
55
- rel_parts = marker_file.relative_to(search_root).parts
56
- if _EXCLUDED_DIRS & set(rel_parts):
57
- continue
58
- candidate = marker_file.parent
59
- if any(
60
- candidate == r or candidate.is_relative_to(r)
61
- for r in roots
62
- ):
63
- continue
64
- roots.append(candidate)
51
+ package_roots = collect_marker_roots(
52
+ search_root,
53
+ ("package.json",),
54
+ excluded_dirs=_EXCLUDED_DIRS,
55
+ fallback_to_search_root=False,
56
+ )
57
+ tsconfig_roots = collect_marker_roots(
58
+ search_root,
59
+ ("tsconfig.json",),
60
+ excluded_dirs=_EXCLUDED_DIRS,
61
+ fallback_to_search_root=False,
62
+ )
63
+
64
+ roots = list(package_roots)
65
+ for tsconfig_root in tsconfig_roots:
66
+ if tsconfig_root in roots:
67
+ continue
68
+ if any(tsconfig_root.is_relative_to(root) for root in package_roots):
69
+ continue
70
+ roots.append(tsconfig_root)
65
71
 
66
72
  return sorted(roots) if roots else [search_root]
67
73