sources

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 23 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 sources fetches upstream artefacts into the pipeline's working directory and records where they landed.

Index

Constants

View Source
const NpmRegistry = "https://registry.npmjs.org"

NpmRegistry is where a package's tarball is fetched from without npm.

Variables

View Source
var DefaultExtractLimits = ExtractLimits{
	MaxMemberBytes: 256 << 20,
	MaxTotalBytes:  2 << 30,
	MaxEntries:     200_000,
}

DefaultExtractLimits sit well above the largest real upstream (tens of thousands of files, a few hundred MiB) and well below a bomb.

Functions

func ExtractTarGz

func ExtractTarGz(archive, dest string) error

ExtractTarGz unpacks a gzipped tar, refusing any entry that escapes dest.

func ExtractZip

func ExtractZip(archive, dest string) error

ExtractZip unpacks a zip, refusing any entry that escapes dest.

func NpmPackArgs added in v0.1.3

func NpmPackArgs(spec string) []string

NpmPackArgs is the argument list for every `npm pack` this tool runs.

--ignore-scripts is the point (S7). A registry spec does not run lifecycle scripts, but a git or local spec runs `prepare`, and the spec comes from repo config or the token-authenticated local web UI. Both call sites share this so neither can lose the flag.

func SetNpmPath added in v0.1.3

func SetNpmPath(p string)

SetNpmPath sets the npm_path setting: the npm executable to use before ICHAVA_NPM, PATH and the usual install directories are searched. Empty clears it.

Types

type Compound

type Compound struct {
	pipeline.SourceKind
	First, Second pipeline.Source
}

Compound runs two sources in order.

A pipeline takes exactly one source, and the emoji recipe needs both an asset fetch and the CLDR taxonomy. The taxonomy runs first so the asset source owns fetched_path -- reverse them and the categoriser is handed the taxonomy file as its tree.

func (Compound) Execute

func (c Compound) Execute(ctx *pipeline.Context) error

func (Compound) Name

func (c Compound) Name() string

type Downloader

type Downloader interface {
	Download(ctx context.Context, url, dest string, force bool) (string, error)
}

Downloader is the HTTP surface the sources need.

type ExtractLimits added in v0.1.3

type ExtractLimits struct {
	// MaxMemberBytes caps one file.
	MaxMemberBytes int64
	// MaxTotalBytes caps everything written from one archive.
	MaxTotalBytes int64
	// MaxEntries caps members of any type, directories included.
	MaxEntries int
}

ExtractLimits bounds what one archive may expand to (S6).

Zip-slip is stopped by pathguard.Join; a decompression bomb is a different attack and it is the size of the output that matters, not of the archive: gzip and deflate both reach about 1000:1, so a few hundred KiB can ask for hundreds of GiB. The inputs are pinned upstreams, so this needs a compromised one.

type GithubArchive

type GithubArchive struct {
	pipeline.SourceKind

	// ArchiveURL is a template with {version}. When empty it is built from
	// Owner, Repo and Version -- note the built form hardcodes a `v` prefix,
	// which is why a project tagging without one has to supply the template.
	ArchiveURL string
	Owner      string
	Repo       string
	Version    string

	// MaxDownloadBytes raises the download cap for this archive; zero keeps
	// httpx's default. Only read when HTTP is nil.
	MaxDownloadBytes int64

	HTTP Downloader
	Log  *slog.Logger
}

GithubArchive downloads a tagged archive and extracts it.

func (GithubArchive) Execute

func (s GithubArchive) Execute(ctx *pipeline.Context) error

func (GithubArchive) Name

func (GithubArchive) Name() string

func (GithubArchive) URL added in v0.1.3

func (s GithubArchive) URL() string

URL is the archive this source downloads, with {version} filled in.

type NpmSearch added in v0.1.3

type NpmSearch struct {
	Found    string
	Searched []string
}

NpmSearch is where FindNpm looked, in order, for the message when it found nothing and for doctor.

func FindNpm added in v0.1.3

func FindNpm() (NpmSearch, error)

FindNpm resolves the npm executable: the npm_path setting, then ICHAVA_NPM, then PATH, then the directories node version managers and installers use.

A server started from Finder, launchd or a desktop shortcut has none of Homebrew, nvm, Volta or fnm on its PATH, which is why PATH alone is not enough: npm is usually installed and simply not visible.

type NpmTarball

type NpmTarball struct {
	pipeline.SourceKind

	Package string
	Version string
	// Via is "" (the registry, then npm), "registry" or "npm".
	Via  string
	HTTP *httpx.Client
	Log  *slog.Logger
}

NpmTarball fetches a package's npm tarball and extracts it.

It fetches straight from registry.npmjs.org, checking the tarball against the sha512 integrity the registry publishes, so a sync needs no Node.js. npm pack is the fallback, found by FindNpm, for a registry that answers something unexpected.

func (NpmTarball) Execute

func (s NpmTarball) Execute(ctx *pipeline.Context) error

func (NpmTarball) Name

func (NpmTarball) Name() string

type Static

type Static struct {
	pipeline.SourceKind
	Version string
}

Static satisfies the pipeline's "must have a source" rule for a commit-only pipeline, which has nothing to fetch but still has a version to record.

It replaces Python's _NoOpSource, and the difference is a bug fix rather than a rename. Each pipeline gets its own context, so nothing the emoji recipe's three asset pipelines set reaches its trailing commit pipeline. With a source that set nothing, VersionStamp found no fetched_version, logged "skipping" and did nothing -- so icon-sets-twemoji was never stamped at all, and its sync could not converge. That is precisely the V49 failure the vendored-version design exists to prevent, still live in the one recipe that composes several pipelines.

func (Static) Execute

func (s Static) Execute(ctx *pipeline.Context) error

func (Static) Name

func (Static) Name() string

type UnicodeCldr

type UnicodeCldr struct {
	pipeline.SourceKind

	// UnicodeVersion is the emoji release, e.g. "16.0".
	//
	// The default has bitten this project: it ran ahead of what Unicode had
	// published, every fetch 404'd, and the pack shipped a tagged release with
	// zero SVGs. Set it to a version that exists.
	UnicodeVersion string

	HTTP Downloader
	Log  *slog.Logger
}

UnicodeCldr downloads the emoji taxonomy the categoriser needs.

func (UnicodeCldr) Execute

func (s UnicodeCldr) Execute(ctx *pipeline.Context) error

func (UnicodeCldr) Name

func (UnicodeCldr) Name() string

func (UnicodeCldr) URL added in v0.1.3

func (s UnicodeCldr) URL() string

URL is the emoji-test.txt this source downloads.

Unicode stopped publishing new emoji releases under /Public/emoji/<version>/ after 16.0 (17.0 answers 404 there); from 17.0 the file lives under the full version, /Public/17.0.0/emoji/. Releases up to 16.0 keep their old URL, so nothing already fetched changes.

Jump to

Keyboard shortcuts

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