Documentation
¶
Overview ¶
Package lockfile reads the package versions a lockfile pins, for `oa check`: composer.lock, npm's package-lock.json, pnpm-lock.yaml, yarn.lock, poetry.lock, uv.lock, pylock.toml (PEP 751), Cargo.lock, Bundler's Gemfile.lock and NuGet's packages.lock.json. It keeps only what a client fetches from a package registry: local, linked, bundled and VCS or file dependencies are left out, since no registry serves them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownLockfile is a file name Parse cannot tell the format of. ErrUnknownLockfile = errors.New("unknown lockfile: expected " + fileList()) // ErrInvalid is a lockfile that is not the document its format expects. ErrInvalid = errors.New("invalid lockfile") )
Functions ¶
func DevRecorded ¶ added in v0.25.0
DevRecorded reports whether a lockfile of kind says which dependencies are development-only, so that leaving them out means something: yarn.lock, Cargo.lock, Gemfile.lock, packages.lock.json and pylock.toml never do, a poetry.lock only when Poetry 2 (or a Poetry before 1.5) wrote it.
func Files ¶ added in v0.25.0
func Files() []string
Files returns the lockfile names `oa check` reads, in a stable order: every name in kindByFile. Aliases such as gems.locked and pylock.<name>.toml are not listed.
func GraphRecorded ¶ added in v0.25.0
GraphRecorded reports whether a lockfile of kind says which locked package requires which, so that a Dep without RequiredBy is one the project requires itself: every format does, except a pylock.toml without dependency lists (what uv export and pip lock write).
Types ¶
type Dep ¶
type Dep struct {
Name string `json:"package"`
Version string `json:"version"`
Dev bool `json:"dev,omitempty"`
RequiredBy []string `json:"required_by,omitempty"`
}
Dep is one package version a lockfile pins. Dev reports that the lockfile marks it as a development dependency (only). RequiredBy names the locked packages that depend on it, sorted; empty when none does (the project requires it itself). A lockfile does not record the project's own requirements, so a dependency with requirers may be direct as well.
type Kind ¶
type Kind string
Kind is the lockfile format.
const ( Composer Kind = "composer" NPM Kind = "npm" PNPM Kind = "pnpm" // Yarn is Yarn 1's yarn.lock or the YAML one of Yarn 2 and later. It does // not record development dependencies: no Dep of it is Dev. Yarn Kind = "yarn" // Poetry and UV are Python lockfiles; their names are normalized (PEP 503). Poetry Kind = "poetry" UV Kind = "uv" // Pylock is PEP 751's pylock.toml (or pylock.<name>.toml), written by // uv export and pip lock. It may record no dependency graph // (GraphRecorded) and records no development dependencies. Pylock Kind = "pylock" // Cargo does not record development dependencies: no Dep of it is Dev. Cargo Kind = "cargo" // Bundler (Gemfile.lock) and NuGet (packages.lock.json) do not record // development dependencies either. Bundler Kind = "bundler" NuGet Kind = "nuget" // GoSum is a Go module's go.sum: module versions only, with neither // requirers (GraphRecorded) nor test-only modules. GoSum Kind = "gosum" )
The lockfile formats Parse reads.