fix(scripts): detect modern bun.lock, ignore stray root lockfiles - #2536
Conversation
Bun switched its default lockfile from the binary bun.lockb to the text-based bun.lock, but detectFromLockFile() only ever checked for bun.lockb — a project using modern Bun would never be detected as using Bun at all. Added bun.lock as the primary lockfile with bun.lockb kept as a recognized legacy alias, so either format is detected correctly. Also ignore stray bun.lock/bun.lockb at the repo root: yarn is this repo's canonical package manager (package.json "packageManager"), so a lockfile from someone running `bun install` locally shouldn't get picked up by git status.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📜 Recent review details⏰ Context from checks skipped due to timeout. (1)
🧰 Additional context used📓 Path-based instructions (16)**/*.{js,ts,jsx,tsx,py,java,cs,go,rb,php,scala,kt}📄 CodeRabbit inference engine (.cursor/rules/common-coding-style.md)
Files:
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,sql}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{js,ts,jsx,tsx,html,php,java,cs,rb,go}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp,properties,yml,yaml,json,env,config}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/typescript-coding-style.md)
Files:
**/*.{test,spec}.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts,jsx,tsx,json,env*}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{jsx,tsx,js,ts}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts,env*}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
{package.json,*.config.js,scripts/**/*.js}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
scripts/**/*.js📄 CodeRabbit inference engine (CLAUDE.md)
Files:
{scripts,bin}/**⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (1)📚 Learning: 2026-07-16T15:23:29.177ZApplied to files:
🪛 ast-grep (0.44.1)tests/lib/package-manager.test.js[warning] 148-148: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use. (detect-non-literal-fs-filename) 🔇 Additional comments (3)
📝 WalkthroughSummary by CodeRabbit
WalkthroughBun lockfile handling now recognizes both ChangesBun lockfile support
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| scripts/lib/package-manager.js | Promotes bun.lock as primary lockFile and adds lockFileAliases for backward-compatible bun.lockb detection; logic is correct and concise. |
| tests/lib/package-manager.test.js | Adds a clean regression test for bun.lock detection; renames the legacy bun.lockb test for clarity. |
| .gitignore | Adds root-anchored /bun.lock and /bun.lockb ignore entries with a clear explanatory comment; functionally correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[detectFromLockFile called] --> B[Iterate DETECTION_PRIORITY\npnpm → bun → yarn → npm]
B --> C[Build lockFileNames array\nlockFile + lockFileAliases]
C --> D{Any lockfile\nexists on disk?}
D -- "bun.lock found (modern)" --> E[return 'bun']
D -- "bun.lockb found (legacy alias)" --> E
D -- "yarn.lock found" --> F[return 'yarn']
D -- "pnpm-lock.yaml found" --> G[return 'pnpm']
D -- "package-lock.json found" --> H[return 'npm']
D -- none found --> I[return null]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[detectFromLockFile called] --> B[Iterate DETECTION_PRIORITY\npnpm → bun → yarn → npm]
B --> C[Build lockFileNames array\nlockFile + lockFileAliases]
C --> D{Any lockfile\nexists on disk?}
D -- "bun.lock found (modern)" --> E[return 'bun']
D -- "bun.lockb found (legacy alias)" --> E
D -- "yarn.lock found" --> F[return 'yarn']
D -- "pnpm-lock.yaml found" --> G[return 'pnpm']
D -- "package-lock.json found" --> H[return 'npm']
D -- none found --> I[return null]
Reviews (1): Last reviewed commit: "fix(scripts): detect modern bun.lock, ig..." | Re-trigger Greptile
daltino
left a comment
There was a problem hiding this comment.
DECISION: APPROVE
This PR makes focused updates to improve lockfile handling for Bun, aligning with its modern lockfile format while retaining compatibility for legacy files. The addition to .gitignore ensures only the canonical package manager's files are tracked. The updates to the detection logic and tests are thorough and well-structured, adhering to the repo's conventions. Well done!
|
Thank you for this! Supporting both the current bun.lock format and the legacy bun.lockb file fixes package-manager detection without changing the existing priority rules. The recorded checks are green, and the combined current-main test run passes in full, so I’m merging it now. We appreciate the careful regression coverage. |
Summary
Bun switched its default lockfile from the binary
bun.lockbto the text-basedbun.lock, butdetectFromLockFile()inscripts/lib/package-manager.jsonly ever checked forbun.lockb— a project using modern Bun would never be detected as using Bun at all.bun.lockthe primary recognized lockfile, keptbun.lockbas a recognized legacy alias via a newlockFileAliasesfield, and updateddetectFromLockFile()to check both./bun.lockand/bun.lockbto.gitignoreat the repo root — yarn is this repo's canonical package manager (package.json"packageManager"), so a lockfile from someone runningbun installlocally against this repo shouldn't show up ingit status.bun.lockpath alongside the existingbun.lockbone.Test plan
node tests/lib/package-manager.test.js— 116/116 pass (was 115, added 1 new test)node tests/run-all.js— 3111/3111 pass