lockfile

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func DevRecorded(kind Kind, data []byte) bool

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

func GraphRecorded(kind Kind, data []byte) bool

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.

func Parse

func Parse(kind Kind, data []byte) ([]Dep, error)

Parse reads the dependencies of a lockfile of the given kind, sorted by name then version, each name and version once (a version is Dev only when every occurrence of it is).

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.

func KindOf

func KindOf(path string) (Kind, error)

KindOf returns the format of a lockfile from its file name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL