pkgs

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 11 Imported by: 0 modules, 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 pkgs finds the npm or PyPI package an npx or uvx tool runs, and pins it to an exact version.

`npx -y some-server` runs whatever was published last, every time the agent starts it, with the tool's secrets in its environment. A compromised or broken release would reach you without you doing anything. Pinned, a tool only changes when you run `toolshed upgrade`.

Index

Constants

This section is empty.

Variables

View Source
var ErrNothingToPin = errors.New("nothing to pin")

ErrNothingToPin is returned by PinLatest for entries without a package, or whose package is already pinned to an exact version.

View Source
var Timeout = 10 * time.Second

Timeout bounds one version lookup.

Functions

func Latest

func Latest(ctx context.Context, r Ref) (string, error)

Latest asks the package registry for the newest release. npm uses npm_config_registry when set (as npm does); PyPI can be pointed elsewhere with TOOLSHED_PYPI_URL (it needs PyPI's JSON API).

func PinLatest

func PinLatest(ctx context.Context, e *registry.Entry) (string, error)

PinLatest pins an unpinned npx or uvx entry to the newest release, in place, and returns that version.

Types

type Ref

type Ref struct {
	Kind    string // registry.KindNPX or registry.KindUVX
	Name    string // npm or PyPI package name
	Version string // what it's pinned to; "" when it isn't
	Exact   bool   // Version is one exact release (not a range or tag)
	// contains filtered or unexported fields
}

Ref is the package an npx or uvx entry runs.

func Find

func Find(e *registry.Entry) (Ref, bool)

Find returns the package an entry runs. ok is false for anything that isn't an npx or uvx entry with a registry package (a git URL, a local path, or flags toolshed doesn't know, since it then can't tell which argument is the package).

func (Ref) Pin

func (r Ref) Pin(e *registry.Entry, version string) []string

Pin returns e's arguments with the package pinned to version.

func (Ref) Spec

func (r Ref) Spec(version string) string

Spec is the package argument pinned to version, as npx or uvx takes it.

Jump to

Keyboard shortcuts

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