Documentation
¶
Overview ¶
Package manifest provides functionality for reading and writing manifest files.
Index ¶
- func Overwrite(rw ReadWriter, filename string, p Patch) error
- func SplitNPMAlias(v string) (name, version string)
- type DependencyPatch
- type DependencyWithOrigin
- type Manifest
- type MavenDependencyPatches
- type MavenManifestSpecific
- type MavenPatch
- type MavenPatches
- type MavenPropertyPatches
- type MavenReadWriter
- type NpmReadWriter
- type PackageJSON
- type Patch
- type PropertyWithOrigin
- type ReadWriter
- type RequirementKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Overwrite ¶
func Overwrite(rw ReadWriter, filename string, p Patch) error
Overwrite applies the ManifestPatch to the manifest at filename. Used so as to not have the same file open for reading and writing at the same time.
func SplitNPMAlias ¶
SplitNPMAlias extracts the real package name and version from an alias-specified version.
e.g. "npm:pkg@^1.2.3" -> name: "pkg", version: "^1.2.3"
If the version is not an alias specifier, the name will be empty and the version unchanged.
Types ¶
type DependencyPatch ¶
type DependencyPatch struct {
Pkg resolve.PackageKey // The package this applies to
Type dep.Type // The dependency type
OrigRequire string // The original requirement string e.g. "1.*.*"
NewRequire string // The new requirement string e.g. "2.*.*"
OrigResolved string // The version the original resolves to e.g. "1.2.3" (for display only)
NewResolved string // The version the new resolves to e.g. "2.4.6" (for display only)
}
type DependencyWithOrigin ¶
type DependencyWithOrigin struct {
maven.Dependency
Origin string // Origin indicates where the dependency comes from
}
type Manifest ¶
type Manifest struct {
FilePath string // Path to the manifest file on disk
Root resolve.Version // Version representing this package
Requirements []resolve.RequirementVersion // All direct requirements, including dev
Groups map[RequirementKey][]string // Dependency groups that the imports belong to
LocalManifests []Manifest // manifests of local packages
EcosystemSpecific any // Any ecosystem-specific information needed
}
type MavenDependencyPatches ¶
type MavenDependencyPatches map[string]map[MavenPatch]bool // origin -> patch -> whether from this project
MavenDependencyPatches represent the dependencies to be updated, which is a map of dependency patches of each origin.
type MavenManifestSpecific ¶
type MavenManifestSpecific struct {
Parent maven.Parent
Properties []PropertyWithOrigin // Properties from the base project
OriginalRequirements []DependencyWithOrigin // Dependencies from the base project
RequirementsForUpdates []resolve.RequirementVersion // Requirements that we only need for updates
Repositories []maven.Repository
}
type MavenPatch ¶
type MavenPatch struct {
maven.DependencyKey
NewRequire string
}
type MavenPatches ¶
type MavenPatches struct {
DependencyPatches MavenDependencyPatches
PropertyPatches MavenPropertyPatches
}
type MavenPropertyPatches ¶
MavenPropertyPatches represent the properties to be updated, which is a map of properties of each origin.
type MavenReadWriter ¶
type MavenReadWriter struct {
*datasource.MavenRegistryAPIClient
}
func NewMavenReadWriter ¶
func NewMavenReadWriter(registry string) (MavenReadWriter, error)
func (MavenReadWriter) System ¶
func (MavenReadWriter) System() resolve.System
type NpmReadWriter ¶
type NpmReadWriter struct{}
func (NpmReadWriter) System ¶
func (NpmReadWriter) System() resolve.System
type PackageJSON ¶
type PackageJSON struct {
Name string `json:"name"`
Version string `json:"version"`
// TODO: yarn allows workspaces to be a object OR a list:
// https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
Workspaces []string `json:"workspaces"`
Dependencies map[string]string `json:"dependencies"`
DevDependencies map[string]string `json:"devDependencies"`
OptionalDependencies map[string]string `json:"optionalDependencies"`
// These fields are currently only used when parsing package-lock.json
PeerDependencies map[string]string `json:"peerDependencies"`
}
type Patch ¶
type Patch struct {
Manifest *Manifest // The original manifest
Deps []DependencyPatch // Changed direct dependencies
EcosystemSpecific any // Any ecosystem-specific information
}
type PropertyWithOrigin ¶
type ReadWriter ¶
type ReadWriter interface {
// System returns which ecosystem this ReadWriter is for.
System() resolve.System
// Read parses a manifest file into a Manifest, possibly recursively following references to other local manifest files
Read(file depfile.DepFile) (Manifest, error)
// Write applies the Patch to the manifest, with minimal changes to the file.
// `original` is the original manifest file to read from. The updated manifest is written to `output`.
Write(original depfile.DepFile, output io.Writer, patches Patch) error
}
func GetReadWriter ¶
func GetReadWriter(pathToManifest string, registry string) (ReadWriter, error)
type RequirementKey ¶
type RequirementKey struct {
resolve.PackageKey
EcosystemSpecific any
}
A RequirementKey is a comparable type that uniquely identifies a package dependency in a manifest. It does not include the version specification.
func MakeRequirementKey ¶
func MakeRequirementKey(requirement resolve.RequirementVersion) RequirementKey