pub

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package pub validates Dart pub archives and maintains their native index.

Index

Constants

View Source
const (
	MaxArchiveBytes  = 64 << 20
	MaxUnpackedBytes = 128 << 20
	MaxManifestBytes = 1 << 20
	MaxFiles         = 4096
)
View Source
const (
	PropName    = "pub.name"
	PropVersion = "pub.version"
	PropSHA256  = "pub.sha256"
)

Variables

View Source
var (
	ErrArchive = errors.New("pub: invalid dart pub archive")
)

Functions

func ParsePath

func ParsePath(p string) (name, version string, ok bool)

func Path

func Path(name, version string) string

func Serves

func Serves(t repo.PackageType) bool

func ValidName

func ValidName(name string) bool

func ValidVersion

func ValidVersion(version string) bool

Types

type Handler

type Handler struct{ generic.Handler }

func (Handler) Admit

func (Handler) Admit(
	ctx context.Context, env format.Env, c repo.Config, w format.Write,
) (format.Write, error)

func (Handler) Deleted

func (Handler) Deleting

func (Handler) Deployed

func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it types.Item) error

func (Handler) GuardWrite

func (Handler) GuardWrite(
	ctx context.Context, env format.Env, c repo.Config, w format.Write,
) error

A published version is immutable through both pub publish and the generic item route. Deletes and restores still use their normal lifecycle paths.

func (Handler) Inspect

func (Handler) Inspect(
	ctx context.Context, env format.Env, _ repo.Config, w format.Write,
) (any, error)

func (Handler) Reindex

func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error

Reindex reconstructs all package versions from their admitted archives. The item tree, including the remote cache tree, remains authoritative.

type Metadata

type Metadata struct {
	Name    string         `json:"name"`
	Version string         `json:"version"`
	Pubspec map[string]any `json:"pubspec"`
	Path    string         `json:"path"`
	SHA256  string         `json:"sha256"`
}

func ReadArchive

func ReadArchive(r io.Reader, size int64) (Metadata, error)

ReadArchive validates the entire gzip and TAR stream, not only pubspec.yaml. It rejects duplicate and unsafe entries, links, trailing data, oversized decompression, and a manifest whose declared identity is invalid.

Jump to

Keyboard shortcuts

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