Documentation
¶
Overview ¶
Package manifests parses dependency manifest and lockfile formats across package ecosystems.
It supports 40+ ecosystems including npm, gem, pypi, cargo, maven, and more. Each ecosystem uses its PURL type as the identifier.
Basic usage:
result, err := manifests.Parse("package.json", content)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Ecosystem: %s, Kind: %s\n", result.Ecosystem, result.Kind)
for _, dep := range result.Dependencies {
fmt.Printf(" %s %s\n", dep.Name, dep.Version)
}
Index ¶
Constants ¶
View Source
const ( Manifest Kind = core.Manifest Lockfile Kind = core.Lockfile Supplement Kind = core.Supplement Runtime Scope = core.Runtime Development Scope = core.Development Test Scope = core.Test Build Scope = core.Build Optional Scope = core.Optional )
Re-export constants.
Variables ¶
This section is empty.
Functions ¶
func Ecosystems ¶
func Ecosystems() []string
Ecosystems returns a list of all supported PURL ecosystem types.
Types ¶
type Dependency ¶
type Dependency = core.Dependency
Re-export types from internal/core for public API.
type Match ¶
Match represents a file type match.
func IdentifyAll ¶
IdentifyAll returns all matching ecosystems for a filename.
type Options ¶ added in v0.5.1
type Options struct {
// FSRoot, when non-empty, allows parsers that consult neighbouring
// files on disk (currently only pom.xml, for parent <relativePath>
// resolution) to do so within this directory. Paths outside it are
// refused. When empty, parsing is a pure function of content and no
// filesystem access occurs; this is the safe choice for untrusted
// input.
FSRoot string
}
Options configures Parse.
type ParseResult ¶
type ParseResult struct {
Ecosystem string
Kind Kind
// Name is the package's own name as declared in the manifest, when
// the format has one. Empty for lockfiles and for formats that
// only list dependencies (Gemfile, requirements.txt, etc.).
Name string
// Version is the package's own version as declared in the
// manifest, when present.
Version string
// Licenses holds the package's declared license values, verbatim as
// written in the manifest. Empty when the format has no license field
// or none is set. Scalar formats produce a single-element slice.
Licenses []string
// LicenseFile is a manifest-relative path to a license file when the
// format declares one instead of, or as well as, an expression.
LicenseFile string
Dependencies []Dependency
}
ParseResult contains the parsed dependencies from a manifest or lockfile.
type UnknownFileError ¶
type UnknownFileError struct {
Filename string
}
UnknownFileError is returned when a file type is not recognized.
func (*UnknownFileError) Error ¶
func (e *UnknownFileError) Error() string
Click to show internal directories.
Click to hide internal directories.