packagist

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package packagist exposes packagist.org as a kit Domain.

A multi-domain host (ant) enables it with a single blank import:

import _ "github.com/tamnd/packagist-cli/packagist"

The same Domain also builds the standalone packagist binary.

Package packagist is the library behind the packagist command line: the HTTP client, request shaping, and the typed data models for packagist.org.

The Client paces requests, sets an honest User-Agent, and retries transient failures (429 and 5xx). No API key is required.

Index

Constants

View Source
const DefaultUserAgent = "packagist/dev (+https://github.com/tamnd/packagist-cli)"

DefaultUserAgent identifies the client to Packagist.

View Source
const Host = "packagist.org"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to Packagist over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Info added in v0.1.1

func (c *Client) Info(ctx context.Context, name string) (Package, error)

Info fetches info for a single package by its vendor/package name.

func (*Client) List added in v0.1.1

func (c *Client) List(ctx context.Context, vendor string, limit int) ([]ListEntry, error)

List returns all package names, optionally filtered by vendor. Pass an empty vendor string to list all packages (may be very large). limit clips the result; 0 means return all.

func (*Client) Search added in v0.1.1

func (c *Client) Search(ctx context.Context, query string, limit int) ([]Package, error)

Search finds packages matching query. It returns at most limit items (pass 0 for default 10).

type Config added in v0.1.1

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig added in v0.1.1

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the packagist driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify maps a package name to (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, hostnames, and binary identity.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the packagist.org page URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and operations onto app.

type ListEntry added in v0.1.1

type ListEntry struct {
	Rank int    `json:"rank"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

ListEntry is one package name from the list endpoint.

type Package added in v0.1.1

type Package struct {
	Rank        int    `json:"rank"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Downloads   int64  `json:"downloads"`
	Favers      int    `json:"favers"`
	Repository  string `json:"repository"`
	URL         string `json:"url"`
}

Package is one Composer package record from packagist.org.

Jump to

Keyboard shortcuts

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