fix(detection): support bun.lock text format for Bun 1.2.0+ (#525)
Bun 1.2.0 changed the default lockfile from bun.lockb (binary) to bun.lock (text format). Projects using newer Bun versions were being incorrectly detected as npm because only bun.lockb was checked. Updated 4 detection locations to check for both lockfile formats: - project/stack_detector.py - analysis/analyzers/framework_analyzer.py - analysis/test_discovery.py - core/workspace/git_utils.py (LOCK_FILES set) Added test for bun.lock detection.
This commit is contained in:
@@ -408,6 +408,6 @@ class FrameworkAnalyzer(BaseAnalyzer):
|
||||
return "pnpm"
|
||||
elif self._exists("yarn.lock"):
|
||||
return "yarn"
|
||||
elif self._exists("bun.lockb"):
|
||||
elif self._exists("bun.lockb") or self._exists("bun.lock"):
|
||||
return "bun"
|
||||
return "npm"
|
||||
|
||||
@@ -275,7 +275,7 @@ class TestDiscovery:
|
||||
return "yarn"
|
||||
if (project_dir / "package-lock.json").exists():
|
||||
return "npm"
|
||||
if (project_dir / "bun.lockb").exists():
|
||||
if (project_dir / "bun.lockb").exists() or (project_dir / "bun.lock").exists():
|
||||
return "bun"
|
||||
if (project_dir / "uv.lock").exists():
|
||||
return "uv"
|
||||
|
||||
@@ -22,6 +22,7 @@ LOCK_FILES = {
|
||||
"pnpm-lock.yaml",
|
||||
"yarn.lock",
|
||||
"bun.lockb",
|
||||
"bun.lock",
|
||||
"Pipfile.lock",
|
||||
"poetry.lock",
|
||||
"uv.lock",
|
||||
|
||||
@@ -126,7 +126,7 @@ class StackDetector:
|
||||
self.stack.package_managers.append("yarn")
|
||||
if self.parser.file_exists("pnpm-lock.yaml"):
|
||||
self.stack.package_managers.append("pnpm")
|
||||
if self.parser.file_exists("bun.lockb"):
|
||||
if self.parser.file_exists("bun.lockb", "bun.lock"):
|
||||
self.stack.package_managers.append("bun")
|
||||
if self.parser.file_exists("deno.json", "deno.jsonc"):
|
||||
self.stack.package_managers.append("deno")
|
||||
|
||||
@@ -80,6 +80,12 @@ class TestPackageManagerDetection:
|
||||
result = discovery.discover(temp_dir)
|
||||
assert result.package_manager == "bun"
|
||||
|
||||
def test_detect_bun_text_lockfile(self, discovery, temp_dir):
|
||||
"""Test bun detection via bun.lock (text format, Bun 1.2.0+)."""
|
||||
(temp_dir / "bun.lock").write_text("")
|
||||
result = discovery.discover(temp_dir)
|
||||
assert result.package_manager == "bun"
|
||||
|
||||
def test_detect_uv(self, discovery, temp_dir):
|
||||
"""Test uv detection via uv.lock."""
|
||||
(temp_dir / "uv.lock").write_text("")
|
||||
|
||||
Reference in New Issue
Block a user