implement bun pm pkg (#21046)

This commit is contained in:
Michael H
2025-07-16 15:14:00 +10:00
committed by GitHub
parent 1cef9399e4
commit 20db4b636e
6 changed files with 1978 additions and 1 deletions

View File

@@ -248,3 +248,38 @@ v1.0.1
```
Supports `patch`, `minor`, `major`, `premajor`, `preminor`, `prepatch`, `prerelease`, `from-git`, or specific versions like `1.2.3`. By default creates git commit and tag unless `--no-git-tag-version` was used to skip.
## pkg
Manage `package.json` data with get, set, delete, and fix operations.
All commands support dot and bracket notation:
```bash
scripts.build # dot notation
contributors[0] # array access
workspaces.0 # dot with numeric index
scripts[test:watch] # bracket for special chars
```
Examples:
```bash
# set
$ bun pm pkg get name # single property
$ bun pm pkg get name version # multiple properties
$ bun pm pkg get # entire package.json
$ bun pm pkg get scripts.build # nested property
# set
$ bun pm pkg set name="my-package" # simple property
$ bun pm pkg set scripts.test="jest" version=2.0.0 # multiple properties
$ bun pm pkg set {"private":"true"} --json # JSON values with --json flag
# delete
$ bun pm pkg delete description # single property
$ bun pm pkg delete scripts.test contributors[0] # multiple/nested
# fix
$ bun pm pkg fix # auto-fix common issues
```