Documentation
¶
Overview ¶
Package metadata defines a metadata struct for Javascript packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToProto ¶
func ToProto(m *JavascriptPackageMetadata) *pb.JavascriptPackageJSONMetadata
ToProto converts the Metadata struct to a JavascriptPackageJSONMetadata proto.
Types ¶
type JavascriptPackageJSONMetadata ¶
type JavascriptPackageJSONMetadata = JavascriptPackageMetadata
JavascriptPackageJSONMetadata is an alias for JavascriptPackageMetadata for compatibility.
type JavascriptPackageMetadata ¶
type JavascriptPackageMetadata struct {
Author *Person `json:"author,omitempty"`
Maintainers []*Person `json:"maintainers,omitempty"`
Contributors []*Person `json:"contributors,omitempty"`
// Source indicates whether this package's dependency was resolved from the official
// NPM registry, a local path, git repository, or private registry.
Source NPMPackageSource `json:"source,omitempty"`
// Dependencies maps direct dependencies to version constraints.
Dependencies map[string]string `json:"dependencies,omitempty"`
// DepGroupVals stores the dependency groups (e.g. "dev", "prod") the package belongs to.
DepGroupVals []string `json:"dep_groups,omitempty"`
}
JavascriptPackageMetadata holds metadata information for JavaScript packages across package.json and various lockfile formats.
func ToStruct ¶
func ToStruct(m *pb.JavascriptPackageJSONMetadata) *JavascriptPackageMetadata
ToStruct converts the JavascriptPackageJSONMetadata proto to a Metadata struct.
func (*JavascriptPackageMetadata) DepGroups ¶
func (m *JavascriptPackageMetadata) DepGroups() []string
DepGroups returns the dependency groups property in the metadata.
func (*JavascriptPackageMetadata) IsProtoable ¶
func (m *JavascriptPackageMetadata) IsProtoable()
IsProtoable marks the struct as a metadata type.
func (*JavascriptPackageMetadata) PackageSource ¶
func (m *JavascriptPackageMetadata) PackageSource() NPMPackageSource
PackageSource returns the NPMPackageSource of the package.
type NPMPackageSource ¶
type NPMPackageSource string
NPMPackageSource is the source of the NPM package.
const ( // Unknown is when the source of the NPM package is unknown because the lockfile was not found. Unknown NPMPackageSource = "UNKNOWN" // PublicRegistry is the public NPM registry. PublicRegistry NPMPackageSource = "PUBLIC_REGISTRY" // Other is any other remote or private source (e.g. GitHub). // This is used for packages that are not found in the public NPM registry. Other NPMPackageSource = "OTHER" // Local is the local filesystem that stores the package versions. // This is used for when the package is locally-developed or -installed. Local NPMPackageSource = "LOCAL" )
func (NPMPackageSource) ToProto ¶
func (source NPMPackageSource) ToProto() pb.PackageSource
ToProto converts the NPMPackageSource to the proto enum.
type Person ¶
type Person struct {
Name string `json:"name"`
Email string `json:"email"`
URL string `json:"url"`
}
Person represents a person field in a javascript package.json file.
func PersonFromString ¶
PersonFromString parses a string of the form "name <email> (url)" into a Person struct.
func (*Person) PersonString ¶
PersonString produces a string format of Person struct in the format of "name <email> (url)"
func (*Person) UnmarshalJSON ¶
UnmarshalJSON parses a JSON object or string into a Person struct.