@esh-vibe/bun-version-sync
v0.1.2
Published
Sync Bun version from package.json to Dockerfile
Readme
@esh-vibe/bun-version-sync
Sync Bun version from package.json to Dockerfile.
Why?
When using Bun in Docker, you often want to ensure that the version you use in development (specified in package.json via the packageManager field) matches the version used in your Docker image. This tool automates that synchronization.
[!TIP] Use pmm2 to ensure you are automatically using the version of Bun specified in your
package.jsonwhile working locally.
Installation
pnpm add -D @esh-vibe/bun-version-syncOr run it directly using npx:
npx @esh-vibe/bun-version-syncUsage
CLI
By default, it looks for a package.json in the current directory and updates a Dockerfile in the same directory.
# Sync version to Dockerfile
npx bun-version-sync
# Sync version to a specific Dockerfile
npx bun-version-sync docker/Dockerfile.prod
# Check if versions are in sync (useful for CI)
npx bun-version-sync --checkOptions
[dockerfile]: Path to the Dockerfile (default:Dockerfile)--root <path>: Path to the project root containingpackage.json(default: current directory)--check: Check if versions are in sync without updating. Exits with code 1 if not in sync.
Requirements
package.json: Must have a
packageManagerfield specifying Bun.{ "packageManager": "[email protected]" }Dockerfile: Must have an
ARG BUN_VERSIONinstruction.ARG BUN_VERSION=1.0.0 FROM oven/bun:${BUN_VERSION}
API
You can also use the synchronization logic programmatically:
import {
getBunVersionFromPackageJson,
syncBunVersionToDockerfile,
checkBunVersionInDockerfile,
} from "@esh-vibe/bun-version-sync";
const version = getBunVersionFromPackageJson(".");
syncBunVersionToDockerfile("Dockerfile", version);License
MIT
