managers

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bun

type Bun struct{}

func (*Bun) Binaries

func (b *Bun) Binaries() []string

func (*Bun) FindReal

func (b *Bun) FindReal(shimsDir string) (string, error)

func (*Bun) Name

func (b *Bun) Name() string

func (*Bun) ParseInstall

func (b *Bun) ParseInstall(args []string) ([]Pkg, InstallMode, error)

func (*Bun) ResolveVersion

func (b *Bun) ResolveVersion(name string) (string, error)

type Cargo

type Cargo struct{}

func (*Cargo) Binaries

func (c *Cargo) Binaries() []string

func (*Cargo) FindReal

func (c *Cargo) FindReal(shimsDir string) (string, error)

func (*Cargo) Name

func (c *Cargo) Name() string

func (*Cargo) ParseInstall

func (c *Cargo) ParseInstall(args []string) ([]Pkg, InstallMode, error)

func (*Cargo) ResolveVersion

func (c *Cargo) ResolveVersion(name string) (string, error)

type InstallMode

type InstallMode int

InstallMode describes how a package manager resolves packages from a command.

const (
	// ModeExplicit means package names/versions were given on the command line.
	ModeExplicit InstallMode = iota
	// ModeLockfile means the command installs from a lockfile (npm ci, bun install).
	// Package names must be read from the lock file — not yet implemented.
	ModeLockfile
	// ModePassthrough means the subcommand is not an install (npm run, cargo build).
	// The shim should exec the real binary immediately with no checks.
	ModePassthrough
)

type Manager

type Manager interface {
	// Name returns the canonical name used in CLI output ("npm", "pip", …).
	Name() string

	// Binaries returns the executable names this manager owns.
	// Used to determine which shims to write.
	Binaries() []string

	// FindReal locates the real binary on PATH, skipping the shims directory.
	FindReal(shimsDir string) (string, error)

	// ParseInstall inspects the command-line arguments and returns the list of
	// packages the user intends to install, plus the install mode.
	// It must never return an error for unknown/passthrough subcommands —
	// those should return ModePassthrough with a nil package list.
	ParseInstall(args []string) ([]Pkg, InstallMode, error)

	// ResolveVersion contacts the package registry to find the latest published
	// version for a package whose version was not pinned on the command line.
	// Returns empty string if resolution fails — the shim should proceed
	// without a version check rather than block on a registry error.
	ResolveVersion(name string) (string, error)
}

Manager abstracts a single package manager for the shim intercept layer.

func All

func All() []Manager

All returns every Manager implementation in a consistent order.

func ByName

func ByName(name string) Manager

ByName returns the Manager whose Name() matches, or nil.

type NPM

type NPM struct{}

func (*NPM) Binaries

func (n *NPM) Binaries() []string

func (*NPM) FindReal

func (n *NPM) FindReal(shimsDir string) (string, error)

func (*NPM) Name

func (n *NPM) Name() string

func (*NPM) ParseInstall

func (n *NPM) ParseInstall(args []string) ([]Pkg, InstallMode, error)

func (*NPM) ResolveVersion

func (n *NPM) ResolveVersion(name string) (string, error)

type Pip

type Pip struct{}

func (*Pip) Binaries

func (p *Pip) Binaries() []string

func (*Pip) FindReal

func (p *Pip) FindReal(shimsDir string) (string, error)

func (*Pip) Name

func (p *Pip) Name() string

func (*Pip) ParseInstall

func (p *Pip) ParseInstall(args []string) ([]Pkg, InstallMode, error)

func (*Pip) ResolveVersion

func (p *Pip) ResolveVersion(name string) (string, error)

type Pkg

type Pkg struct {
	Name    string
	Version string // empty = unresolved; shim will resolve via registry
}

Pkg is a package name and optional version extracted from an install command. Version is empty if it was not pinned on the command line.

Jump to

Keyboard shortcuts

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