PK

Cpk

A lightweight Corepack alternative that manages the packageManager specification in package.json.

installation

Install the binary with the Go toolchain:

go install github.com/pkcarreno/cpk@latest

other methods

precompiled binaries

Download precompiled archives for Linux, macOS, and Windows from the Releases page. Each release includes a SHA-256 checksum file to verify archive integrity.

mise

Install cpk with the mise Go backend:

mise use -g go:github.com/pkcarreno/cpk@latest

usage

commands

CommandArgumentsBehavior
cpk use<package-manager[@target]>Resolves target version and integrity hash from the registry. Writes the specification to package.json.
cpk up[target]Updates the pinned package manager version in package.json. Preserves Yarn Classic within 1.x when target is omitted.
cpk currentNoneReads package.json locally and displays the active package manager, version, and integrity hash without network requests.
cpk outdatedNoneQueries the registry to check if a newer package manager version is available. Never mutates package.json.
cpk verifyNoneVerifies that the integrity hash in package.json matches published registry metadata. Never mutates package.json.

options

global flags

FlagShortDescription
--registry <url>URL of the npm registry. Overrides NPM_CONFIG_REGISTRY.
--quiet-qDo not write status messages, spinners, or confirmations to stderr.
--verbose-vWrite detailed diagnostic logs and execution timings to stderr.
--no-colorDo not use ANSI color escape codes.

command flags

FlagCommandDescription
--rawcpk currentOutput only the unformatted specification string to stdout.
--fail-on-outdatedcpk outdatedExit with a non-zero status code if an update is available.

environment variables

VariableDescription
NPM_CONFIG_REGISTRYDefault registry URL when --registry is not set.
NO_COLORDisables ANSI color escape codes when set and non-empty.
CIDisables animated spinners and color codes when set to true or 1.

technical overview

surgical manifest modification

cpk updates package.json at the byte level with sjson. Standard JSON formatters reorder object keys and change file indentation. In contrast, cpk mutates only the packageManager value in place. It preserves existing indentation (spaces or tabs), key order, and trailing newlines. This produces a clean, single-line git diff.

security architecture

cpk enforces a strict allowlist of supported package managers (pnpm, yarn, npm). It rejects unsupported tools locally before network requests.

During resolution, cpk converts registry Subresource Integrity (SRI) hashes and legacy shasums into canonical +<algorithm>.<hex> integrity hashes. It validates algorithm prefixes and hex digest lengths for sha512, sha384, sha256, sha224, and sha1.

Manifest inspection runs strictly offline by default. Remote network queries execute only during explicit update and audit requests.


created
updated
tags
cli package-manager