Skip to content

resolve

A Go library for parsing raw package manager CLI output into a normalised dependency graph with PURLs. Takes the bytes from a manager’s resolve command (npm ls --json, go mod graph, uv tree) and returns a tree of Dep structs.

import (
    "github.com/git-pkgs/resolve"
    _ "github.com/git-pkgs/resolve/parsers" // register all parsers
)

output, _ := exec.Command("npm", "ls", "--depth", "Infinity", "--json", "--long").Output()

result, err := resolve.Parse("npm", output)
// result.Manager   == "npm"
// result.Ecosystem == "npm"
// result.Direct    == []*Dep{ {PURL: "pkg:npm/express@4.18.2", Name: "express", ...}, ... }

Parse is the only entry point. It dispatches on the manager name and returns ErrUnsupportedManager for unknown ones. Each Dep carries the native package name, resolved version, PURL string, and a Deps slice for transitives. Deps is nil for managers that only emit flat lists (pip, conda, bundler, helm).

This pairs with the resolve operation in managers: managers builds the right command for an ecosystem, resolve parses what comes back.

Supported managers

ManagerEcosystemOutput format
npmnpmJSON tree
pnpmnpmJSON tree
yarnnpmNDJSON tree
bunnpmText tree
cargocargoJSON graph
gomodgolangEdge list
pippypiJSON flat
uvpypiText tree
poetrypypiText tree
condacondaJSON flat
bundlergemText flat
mavenmavenText tree
gradlemavenText tree
composerpackagistText tree
nugetnugetTabular
swiftswiftJSON tree
pubpubText tree
mixhexText tree
rebar3hexText tree
stackhackageJSON flat
leinclojarsText tree
conanconanCustom
denodenoJSON flat
helmhelmTabular

Installation

go get github.com/git-pkgs/resolve

View on GitHub