Documentation
¶
Overview ¶
Package npm resolves npm package versions from an npm registry. A package's packument lists every published version and its publication date in a single response, so discovery is one fetch with no pagination; each candidate carries the date the registry supplies and its tarball as an asset, which a sha256 follower can hash. The package key names the package to track, scoped names (@scope/name) included; the dist-tag key narrows the candidates to the version a registry channel pointer names; the deprecated key keeps deprecated versions eligible; the registry key swaps the public registry for any npm-compatible base URL.
Index ¶
- type Option
- type Provider
- func (p *Provider) Color(dark bool) color.Color
- func (p *Provider) Dated()
- func (p *Provider) Describe(r provider.Resource) string
- func (p *Provider) Discover(ctx context.Context, r provider.Resource) ([]model.Candidate, error)
- func (p *Provider) Identify(r provider.Resource) (string, string)
- func (p *Provider) Keys() []provider.Key
- func (p *Provider) Name() string
- func (p *Provider) Resource(d directive.Directive) (provider.Resource, error)
- func (p *Provider) URL(r provider.Resource, c model.Candidate) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Provider)
Option configures a Provider.
func WithTransport ¶
func WithTransport(rt http.RoundTripper) Option
WithTransport overrides the HTTP transport, for tests.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider resolves npm package versions from the public npm registry. A package's packument holds its whole version history in one response, so the provider fetches it once and lets the framework own selection; it only lists candidates and tags each with the publication date the registry returns for free.
func New ¶
New returns the npm provider. The registry is public for reads and publishes no rate-limit headers, so the client is a plain cached one with no ratelimit wrapper or credentials.
func (*Provider) Color ¶ added in v0.3.10
Color is the provider's brand color. See provider.Provider.Color.
func (*Provider) Dated ¶
func (p *Provider) Dated()
Dated marks the listing as date-bearing: the packument's time map dates every version, so cooldown applies.
func (*Provider) Describe ¶
Describe returns a human-readable label for a resource: the npm web host for the public registry, the custom registry's scheme-stripped base otherwise. A tracked dist-tag is appended in npm's own package@tag spelling.
func (*Provider) Discover ¶
Discover lists candidate versions of a package, reading its packument in one fetch. The packument holds the whole version history in a single response - keyed in publish order, not version order - so there is no pagination, nothing is ever left unread, and --deep has no work to do here. Deprecated versions are dropped unless the directive keeps them eligible.
func (*Provider) Identify ¶ added in v0.3.10
Identify returns the package name and its npmjs.com page. A custom registry has no public page, so its id links nowhere - matching URL - rather than to a same-named, unrelated public package.
func (*Provider) URL ¶
URL builds the web page for a resolved candidate: the version's page on npmjs.com. npm versions are bare semver, so the current-version candidate's Version and Ref agree; the ref is still preferred for symmetry with the providers whose upstream form carries a prefix. A scoped name keeps its literal slash, which the web path expects. Empty when the version is unknown or the package lives on a custom registry, whose web UI (if any) is unknown.