Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func main() {
| brew | Brewfile | Brewfile.lock.json |
| cargo | Cargo.toml | Cargo.lock |
| carthage | Cartfile, Cartfile.private | Cartfile.resolved |
| chef | metadata.rb, metadata.json, Berksfile | |
| clojars | project.clj | |
| cocoapods | Podfile, *.podspec | Podfile.lock |
| composer | composer.json | composer.lock |
Expand Down Expand Up @@ -224,6 +225,10 @@ discarding successful discoveries.

## Types

This module is pre-v1 and exported result structs may gain additive metadata
fields in minor releases. Use keyed composite literals when constructing
`Dependency`, `Declaration`, or `ParseResult` values.

### Dependency

```go
Expand All @@ -235,6 +240,7 @@ type Dependency struct {
Direct bool // True if declared directly, false if transitive
PURL string // Package URL (pkg:ecosystem/name@version)
RegistryURL string // Source registry URL (if non-default)
Source Source // Explicit Git, path, or ecosystem source override
}
```

Expand All @@ -257,6 +263,7 @@ type Declaration struct {
Direct bool // Direct rather than generated or transitive
PURL string // Versionless Package URL
Location string // Opaque parser-defined identity within the manifest
Source Source // Explicit source override as written
}
```

Expand All @@ -272,6 +279,23 @@ ecosystem.
`Direct` distinguishes explicit requirements from generated or transitive
entries when the source format records that distinction, such as `go.mod`.

### Source

```go
type Source struct {
Kind SourceKind // registry, git, path, or github
Value string // Literal URL, path, or ecosystem coordinate
}
```

`Source` records source syntax without claiming that dependency resolution
used that location. Manifest-level source configuration is preserved in
`ParseResult.Sources` in declaration order. An explicit dependency override is
stored on both its `Dependency` and `Declaration`; dependencies with no
override have an empty `Source`. `RegistryURL` remains reserved for resolved or
otherwise attributable package registries and is not used for Git repositories
or local paths.

Parsers that do not preserve source locations leave `Declarations` empty.
Declarations are available for `package.json`, Cargo manifests, `go.mod`, Python
requirements files, `pyproject.toml`, GitHub Actions workflows, `gleam.toml`,
Expand All @@ -292,13 +316,17 @@ type ParseResult struct {
LicenseFile string // manifest-relative path to a declared license file
Dependencies []Dependency
Declarations []Declaration
Sources []Source // Ordered manifest-level source declarations
}
```

`Name` and `Version` are populated for manifest formats that declare their own package identity (Cargo.toml `[package]`, package.json `"name"`, go.mod `module`, `.gemspec`, and so on). They are empty for lockfiles and for dependency-only files like Gemfile or requirements.txt.

`Licenses` contains decoded values as declared by the manifest; it does not normalize them into SPDX expressions. `LicenseFile` is populated when a format explicitly identifies a license file. Both are empty for formats without license metadata.

Chef cookbook PURLs remain empty while `chef` is only a candidate Package URL
type without accepted name and namespace rules.

### Vendor Discovery

```go
Expand Down
3 changes: 3 additions & 0 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var benchmarkFixtures = map[string][]string{
"testdata/npm/deno.lock",
"testdata/npm/bun.lock",
"testdata/vcpkg/vcpkg.json",
"testdata/chef/metadata.json",
},
// YAML parsers
"yaml": {
Expand Down Expand Up @@ -60,6 +61,8 @@ var benchmarkFixtures = map[string][]string{
"testdata/maven/build.gradle",
"testdata/hackage/example.cabal",
"testdata/cpan/cpanfile",
"testdata/chef/metadata.rb",
"testdata/chef/Berksfile",
},
}

Expand Down
1 change: 1 addition & 0 deletions imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
_ "github.com/git-pkgs/manifests/internal/brew"
_ "github.com/git-pkgs/manifests/internal/cargo"
_ "github.com/git-pkgs/manifests/internal/carthage"
_ "github.com/git-pkgs/manifests/internal/chef"
_ "github.com/git-pkgs/manifests/internal/clojure"
_ "github.com/git-pkgs/manifests/internal/cocoapods"
_ "github.com/git-pkgs/manifests/internal/composer"
Expand Down
Loading