managers

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 9 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 Composer added in v0.2.5

type Composer struct{}

func (*Composer) Binaries added in v0.2.5

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

func (*Composer) FindReal added in v0.2.5

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

func (*Composer) Name added in v0.2.5

func (c *Composer) Name() string

func (*Composer) ParseInstall added in v0.2.5

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

func (*Composer) ResolveVersion added in v0.2.5

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

type GoMod added in v0.2.5

type GoMod struct{}

func (*GoMod) Binaries added in v0.2.5

func (g *GoMod) Binaries() []string

func (*GoMod) FindReal added in v0.2.5

func (g *GoMod) FindReal(shimsDir string) (string, error)

func (*GoMod) Name added in v0.2.5

func (g *GoMod) Name() string

func (*GoMod) ParseInstall added in v0.2.5

func (g *GoMod) ParseInstall(args []string) ([]Pkg, InstallMode, error)

func (*GoMod) ResolveVersion added in v0.2.5

func (g *GoMod) 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.

func ReadLockfile added in v0.2.5

func ReadLockfile(managerName, dir string) ([]Pkg, error)

ReadLockfile reads the lock file for the given manager from dir and returns the full list of pinned packages. Returns nil if no lock file is found — callers should pass through without blocking in that case.

type Pnpm added in v0.2.6

type Pnpm struct{}

func (*Pnpm) Binaries added in v0.2.6

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

func (*Pnpm) FindReal added in v0.2.6

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

func (*Pnpm) Name added in v0.2.6

func (p *Pnpm) Name() string

func (*Pnpm) ParseInstall added in v0.2.6

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

func (*Pnpm) ResolveVersion added in v0.2.6

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

Jump to

Keyboard shortcuts

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