Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for new bun.lock format introduced in Bun v1.2 in BunPackageInstallerLifecycleHook #548

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

r4hulp
Copy link

@r4hulp r4hulp commented Mar 8, 2025

Closes #547

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

Starting from Bun v1.2.0, the default lock file format changed from binary (bun.lockb) to text-based (bun.lock). This PR updates the BunPackageInstallerLifecycleHook to support both formats, ensuring compatibility with both older and newer versions of Bun.

Link to the blog - https://bun.sh/blog/bun-lock-text-lockfile

Changes

  • Added check for both bun.lock and bun.lockb files
  • Updated error messages to reflect support for both formats
  • Added documentation comment explaining the version-specific changes

Before

var lockFilePath = Path.Combine(resource.WorkingDirectory, "bun.lockb");

if (!File.Exists(lockFilePath))
{
    throw new InvalidOperationException($"No bun.lockb file found in {resource.WorkingDirectory}");
}

After

// Bun v1.2 changed the default lockfile format to the text-based bun.lock
var lockbFilePath = Path.Combine(resource.WorkingDirectory, "bun.lockb");
var lockFilePath = Path.Combine(resource.WorkingDirectory, "bun.lock");

if (!(File.Exists(lockbFilePath) || File.Exists(lockFilePath)))
{
    throw new InvalidOperationException($"No bun.lock or bun.lockb file found in {resource.WorkingDirectory}");
}

Testing

  • Tested with projects using Bun < v1.2.0 (bun.lockb)
  • Tested with projects using Bun >= v1.2.0 (bun.lock)
  • Verified error messages are clear when no lock file is present

Related Issues

Fixes #547

r4hulp added 2 commits March 8, 2025 14:41
Modify BunPackageInstallerLifecycleHook to handle both bun.lockb and bun.lock files, reflecting Bun v1.2's change in default lockfile format. Update error messages and file existence checks to support the new text-based lockfile.
@r4hulp
Copy link
Author

r4hulp commented Mar 8, 2025

@dotnet-policy-service agree

@r4hulp r4hulp changed the title feat: Add support for new bun.lock format introduced in Bun v1.2 in BunPackageInstallerLifecycleHook Added support for new bun.lock format introduced in Bun v1.2 in BunPackageInstallerLifecycleHook Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bun Package Installer does not support bun.lock, the new lock file standard for Bun (starting v1.2
1 participant