Documentation
¶
Overview ¶
Package permits gathers the verbatim license text of every dependency a project resolves. It scans lockfiles (pnpm-lock.yaml, go.sum) and retrieves raw license files from the npm registry and the Go module cache/proxy.
The library is usable on its own: build a Collector and call Collector.Collect. The command in ./cmd/permits is a thin wrapper around this package. New dependency ecosystems are added by registering a provider.Scanner and provider.Fetcher in a *provider.Registry — no changes to the collector.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRegistry ¶
DefaultRegistry returns a registry with the built-in npm and Go providers wired up using opts.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector orchestrates scanning and fetching against a registry.
func NewCollector ¶
NewCollector returns a Collector backed by reg. Register additional providers in reg before calling to support more ecosystems.
func (*Collector) Collect ¶
func (c *Collector) Collect(ctx context.Context, files ...string) (model.Summary, []model.LicenseArtifact, error)
Collect scans every input file into a deduplicated dependency set, fetches license artifacts concurrently, and returns the run model.Summary together with the flat list of every artifact. A per-dependency failure does not abort the run; it is recorded in the model.Summary.
type Options ¶
type Options struct {
// Concurrency is the number of dependencies fetched in parallel (min 1).
Concurrency int
// Timeout is the per-request timeout for network fetches.
Timeout time.Duration
// Strict, when true, makes the run report failure if any dependency yields
// no license. The collector still returns full results; callers decide.
Strict bool
// DirectOnly restricts scanning to direct (top-level) dependencies,
// excluding transitive ones. Requires each matched scanner to implement
// [provider.DirectScanner]; otherwise [Collector.Collect] returns an
// error.
DirectOnly bool
// NpmRegistry overrides the npm registry base URL.
NpmRegistry string
// NodeModulesDirs are local node_modules roots checked before the npm
// registry (cache-first, like the Go module cache).
NodeModulesDirs []string
// GoProxy overrides the GOPROXY list.
GoProxy string
// GoCacheDir overrides the Go module cache location.
GoCacheDir string
// Logf, if set, receives progress messages.
Logf func(format string, args ...any)
}
Options configures a collection run and the default providers.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
permits
command
Command permits scans pnpm-lock.yaml and go.sum files and gathers the verbatim license text of every resolved dependency from the npm registry and the Go module cache/proxy.
|
Command permits scans pnpm-lock.yaml and go.sum files and gathers the verbatim license text of every resolved dependency from the npm registry and the Go module cache/proxy. |
|
internal
|
|
|
httpx
Package httpx is an internal helper: a shared HTTP client with a per-request timeout and bounded exponential-backoff retries on transient failures (5xx, 429, and network errors).
|
Package httpx is an internal helper: a shared HTTP client with a per-request timeout and bounded exponential-backoff retries on transient failures (5xx, 429, and network errors). |
|
Package licenses provides ecosystem-agnostic detection of license files by filename.
|
Package licenses provides ecosystem-agnostic detection of license files by filename. |
|
Package model holds the public data types shared across the permits library: the dependencies discovered in lockfiles, the raw license artifacts gathered for them, and the run summary.
|
Package model holds the public data types shared across the permits library: the dependencies discovered in lockfiles, the raw license artifacts gathered for them, and the run summary. |
|
Package output writes a collection run to disk: a machine-readable summary.json plus one Markdown file per license artifact, laid out as <ecosystem>/<name>/<version>/<spdx-or-original>.md with YAML frontmatter followed by the verbatim license text.
|
Package output writes a collection run to disk: a machine-readable summary.json plus one Markdown file per license artifact, laid out as <ecosystem>/<name>/<version>/<spdx-or-original>.md with YAML frontmatter followed by the verbatim license text. |
|
Package provider defines the extension point of the permits library.
|
Package provider defines the extension point of the permits library. |
|
gomod
Package gomod implements the permits provider for the Go module ecosystem: a Scanner for go.sum and a Fetcher that reads raw license text from the local module cache, falling back to the Go module proxy when the module is not cached.
|
Package gomod implements the permits provider for the Go module ecosystem: a Scanner for go.sum and a Fetcher that reads raw license text from the local module cache, falling back to the Go module proxy when the module is not cached. |
|
npm
Package npm implements the permits provider for the npm ecosystem: a Scanner for pnpm-lock.yaml (lockfileVersion 5, 6 and 9) and a Fetcher that resolves raw license text from the package tarball published to the npm registry.
|
Package npm implements the permits provider for the npm ecosystem: a Scanner for pnpm-lock.yaml (lockfileVersion 5, 6 and 9) and a Fetcher that resolves raw license text from the package tarball published to the npm registry. |