Documentation
¶
Index ¶
- Variables
- func EcosystemForManager(manager string) (string, bool)
- func HasDirParser(manager string) bool
- func MakePURL(ecosystem, name, version string) string
- func Managers() []string
- func Register(manager, ecosystem string, fn func([]byte) ([]*Dep, error))
- func RegisterDir(manager, ecosystem string, fn func(string) ([]*Dep, error))
- func TabContentParser(content string) (string, string, bool)
- type Dep
- type InputDep
- type Result
- type TreeLine
- type TreeOptions
Constants ¶
This section is empty.
Variables ¶
var ErrResolveNotSupported = errors.New("manager does not support resolve")
ErrResolveNotSupported is returned when the manager does not support the resolve operation.
var ErrUnsupportedManager = errors.New("unsupported manager")
ErrUnsupportedManager is returned when Parse is called with an unknown manager name.
Functions ¶
func EcosystemForManager ¶
EcosystemForManager returns the ecosystem name for a registered manager.
func HasDirParser ¶
HasDirParser reports whether manager registered a directory-based parser.
func Managers ¶
func Managers() []string
Managers returns the list of manager names that have registered parsers.
func RegisterDir ¶
RegisterDir adds a parser that reads files from the project directory rather than command stdout. Used for managers whose lockfile is the canonical resolved-graph source (e.g. composer.lock).
Types ¶
type Dep ¶
type Dep struct {
PURL string // pkg:npm/%40scope/name@1.0.0
Name string // ecosystem-native name (@scope/name)
Version string // resolved version (1.0.0)
Deps []*Dep // transitive deps; nil for flat-list managers
}
Dep is a single resolved dependency.
func BuildTree ¶
func BuildTree(lines []TreeLine, ecosystem string, contentParser func(string) (string, string, bool)) []*Dep
BuildTree takes tree lines and a content-parser function, and builds a []*Dep tree. The contentParser receives the content string and returns (name, version, deps-placeholder). Deps is set to non-nil empty slice to indicate tree structure is available.
type InputDep ¶
type InputDep struct {
Name string // package name in ecosystem-native format
Version string // version constraint (optional)
}
InputDep describes a dependency to add to the generated project.
type Result ¶
type Result struct {
Manager string // "npm", "cargo", etc.
Ecosystem string // "npm", "cargo", "golang", etc.
Direct []*Dep // top-level dependencies
}
Result is the parsed dependency graph for one manager invocation.
func ParseDir ¶
ParseDir dispatches to a directory-based parser. The parser reads whatever files it needs (manifest, lockfile) from dir.
func ResolveDeps ¶
ResolveDeps creates a temporary project, adds the given dependencies using the specified package manager, runs resolution, and parses the output into a dependency graph.
The package manager CLI must be installed and available on PATH.
type TreeLine ¶
TreeLine is a parsed line from a text tree.
func ParseTreeLines ¶
func ParseTreeLines(lines []string, opts TreeOptions) []TreeLine
ParseTreeLines reads indented tree output and returns depth + content for each line.
type TreeOptions ¶
type TreeOptions struct {
// Prefixes are the tree-drawing characters that indicate a child node.
// e.g. "├── ", "└── ", "+- ", "\- "
Prefixes []string
// Continuations are the tree-drawing characters that indicate depth continuation.
// e.g. "│ ", "| ", "│ "
Continuations []string
}
TreeOptions configures how tree lines are parsed.
func BoxDrawingOptions ¶
func BoxDrawingOptions() TreeOptions
BoxDrawingOptions returns TreeOptions for Unicode box-drawing trees (├── └── │).