Skip to content

PR: Add Bun Package Helper (bun-package) - #145

Merged
koralowiec merged 1 commit into
devcontainers-extra:mainfrom
trevordcampbell:add-bun-package-helper-features
Sep 21, 2025
Merged

PR: Add Bun Package Helper (bun-package)#145
koralowiec merged 1 commit into
devcontainers-extra:mainfrom
trevordcampbell:add-bun-package-helper-features

Conversation

@trevordcampbell

Copy link
Copy Markdown
Contributor

Summary

  • Add bun-package: Installs a single package globally via Bun.
  • Provide parity with the existing npm-package helper while following Bun best practices.
  • Add tests for Debian / Ubuntu / Alpine installs and a pinned-version scenario.

Motivation

  • Offer first-class package installation helpers for Bun, mirroring the existing npm helper features to streamline internal reuse and user workflows.
  • Keep behavior consistent with repository standards and helper-first patterns, with small layers and clear skip semantics.

Features Added

  • src/bun-package/
    • Purpose: Install a single package globally via Bun.
    • Behavior:
      • Exports BUN_INSTALL=/usr/local so binaries land in /usr/local/bin.
      • Accepts bare names and optional npm:-prefixed names (Bun defaults to npm registry).
      • Skip-if-installed semantics:
        • For latest installs, skips when package already present.
        • For pinned installs, skips only when exact <name>@<version> is present.
      • Supports non-npm specs (git/URL/GitHub shorthand); nameHint assists skip checks when the displayed name differs.
      • Includes basic retry logic around bun add to mitigate transient registry 5xx errors.
      • Requires Bun to be present (via bun feature); installsAfter references bun.
    • Options:
      • package: string (required)
      • version: string (default latest)
      • nameHint: string (optional)

Intended Use

  • bun-package: Helper-oriented, ideal for downstream features to install a single tool or for precise control (incl. non-npm specs using nameHint).

Usage Examples

  • Single package (latest):
"features": {
  "ghcr.io/devcontainers-extra/features/bun:1": {},
  "ghcr.io/devcontainers-extra/features/bun-package:1": {
    "package": "@vercel/turbo"
  }
}
  • Single package (pinned):
"features": {
  "ghcr.io/devcontainers-extra/features/bun:1": {},
  "ghcr.io/devcontainers-extra/features/bun-package:1": {
    "package": "@vercel/turbo",
    "version": "2.5.6"
  }
}

Tests

  • Scenarios (bun-package):
    • Debian/Ubuntu/Alpine TypeScript install (latest)
    • Angular CLI install
    • Pinned install: TypeScript 5.5.4 (asserts reported version)

Note: Existing-package installation testing scenarios for bun-package are deferred for now (difficult to model a preinstalled global package in a clean base image without a published multi-package helper). They can be re-enabled later once a reliable path is available / a future bun-packages multi-package installer feature is available to fill that gap.

Docs

  • Auto-generated README for the feature.
  • NOTES.md for bun-package includes:
    • Optional npm: prefix usage
    • Behavior and skip semantics
    • Non-npm sources and nameHint

Compatibility

  • Coexists with Node / npm helper features.
  • Global installs target /usr/local/bin for consistent PATH.

Security/Robustness

  • nanolayer usage keeps layers small where applicable.
  • No unnecessary PATH / profile mutations; relies on Bun defaults with explicit BUN_INSTALL.
  • Adds retry / backoff around bun add to reduce flakiness from transient registry errors.

Checklist

  • Code matches project style; helpers used where applicable
  • Metadata (devcontainer-feature.json) includes options and installsAfter
  • Tests cover Debian / Ubuntu / Alpine installs and pinned version scenario
  • Lints are clean

Comment thread test/bun-package/test_existing_package_installation.sh Outdated
Comment thread test/bun-package/test_existing_package_installation_different_version.sh Outdated
@trevordcampbell
trevordcampbell force-pushed the add-bun-package-helper-features branch from 6eadb0d to 3d4c898 Compare September 10, 2025 16:56
@koralowiec
koralowiec merged commit 20a669c into devcontainers-extra:main Sep 21, 2025
5 checks passed
@trevordcampbell
trevordcampbell deleted the add-bun-package-helper-features branch September 21, 2025 21:48
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.

2 participants