Skip to content
Merged
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
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ cmd, _ = translator.BuildCommand("bundler", "add", managers.CommandInput{
| yarn | npm | yarn.lock |
| bun | npm | bun.lock |
| deno | deno | deno.lock |
| bundler | gem | Gemfile.lock |
| gem | gem | - |
| bundler | rubygems | Gemfile.lock |
| gem | rubygems | - |
| cargo | cargo | Cargo.lock |
| gomod | go | go.sum |
| gomod | go | - |
| pip | pypi | requirements.txt |
| uv | pypi | uv.lock |
| poetry | pypi | poetry.lock |
Expand All @@ -65,7 +65,7 @@ cmd, _ = translator.BuildCommand("bundler", "add", managers.CommandInput{
| pub | pub | pubspec.lock |
| cocoapods | cocoapods | Podfile.lock |
| swift | swift | Package.resolved |
| nuget | nuget | packages.lock.json |
| nuget | nuget | packages.lock.json, project.assets.json |
| maven | maven | - |
| gradle | maven | gradle.lockfile |
| sbt | maven | - |
Expand All @@ -77,14 +77,16 @@ cmd, _ = translator.BuildCommand("bundler", "add", managers.CommandInput{
| shards | shards | shard.lock |
| cpanm | cpan | cpanfile.snapshot |
| lein | clojars | - |
| vcpkg | vcpkg | vcpkg.json |
| vcpkg | vcpkg | - |
| conan | conan | conan.lock |
| renv | cran | renv.lock |
| helm | helm | Chart.lock |
| brew | homebrew | - |

Most managers support: install, add, remove, list, outdated, update, resolve. Some also support init, vendor and path. Some managers (maven, gradle, sbt, lein) have limited CLI support for add/remove operations.

Detection-only definitions are available for Julia Pkg, Carthage, Elm, Dub, Haxelib and Nix. These definitions identify project files but do not define commands.

## Installation

```bash
Expand Down Expand Up @@ -132,6 +134,32 @@ func main() {
}
```

### Detecting managers from files

`DetectFS` and `DetectAllFS` accept any `fs.FS`, including an on-disk directory, a Git tree or an in-memory test filesystem. Detection does not execute package manager commands.

```go
detector := managers.NewDetector(translator, runner)
for _, def := range defs {
detector.Register(def)
}

detections, err := detector.DetectAllFS(repoFS, ".", managers.FileDetectOptions{
OnConflict: managers.ConflictUseFirst,
})
```

`GitPkgsFileDetectionPolicy` preserves the filenames, manager priority and result order used by the git-pkgs CLI. Leave `Policy` unset to detect every registered definition.

```go
detections, err := detector.DetectAllFS(repoFS, ".", managers.FileDetectOptions{
OnConflict: managers.ConflictUseFirst,
Policy: managers.GitPkgsFileDetectionPolicy(),
})
```

History scanners can call `AffectedDirectories` for a changed path, then rerun detection only in the returned project directories.

### Command chaining

Some operations require multiple commands. Use `BuildCommands` to get all of them:
Expand Down
1 change: 1 addition & 0 deletions definitions/bun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ detection:
- bun.lockb
manifests:
- package.json
ecosystem_order: 10
priority: 25 # Higher than npm/yarn/pnpm when bun lockfile present

commands:
Expand Down
4 changes: 3 additions & 1 deletion definitions/bundler.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: bundler
ecosystem: gem
ecosystem: rubygems
binary: bundle
version: ">=2.0.0"
status: current
Expand All @@ -11,6 +11,8 @@ detection:
- Gemfile.lock
manifests:
- Gemfile
default: true
ecosystem_order: 20
priority: 10

version_detection:
Expand Down
4 changes: 3 additions & 1 deletion definitions/cabal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ detection:
manifests:
- "*.cabal"
- cabal.project
priority: 10
default: true
ecosystem_order: 140
priority: 20

version_detection:
command: [--version]
Expand Down
2 changes: 2 additions & 0 deletions definitions/cargo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ detection:
- Cargo.lock
manifests:
- Cargo.toml
default: true
ecosystem_order: 30
priority: 10

version_detection:
Expand Down
17 changes: 17 additions & 0 deletions definitions/carthage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: carthage
ecosystem: carthage
binary: carthage
status: detection-only

detection:
lockfiles:
- Cartfile.resolved
manifests:
- Cartfile
- Cartfile.private
default: true
ecosystem_order: 190
priority: 10

commands: {}
capabilities: []
2 changes: 2 additions & 0 deletions definitions/cocoapods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ detection:
- Podfile.lock
manifests:
- Podfile
default: true
ecosystem_order: 90
priority: 10

commands:
Expand Down
2 changes: 2 additions & 0 deletions definitions/composer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ detection:
- composer.lock
manifests:
- composer.json
default: true
ecosystem_order: 60
priority: 10

commands:
Expand Down
2 changes: 2 additions & 0 deletions definitions/conan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ detection:
manifests:
- conanfile.txt
- conanfile.py
default: true
ecosystem_order: 170
priority: 10

version_detection:
Expand Down
2 changes: 2 additions & 0 deletions definitions/conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ detection:
manifests:
- environment.yml
- environment.yaml
default: true
ecosystem_order: 270
priority: 10

version_detection:
Expand Down
2 changes: 2 additions & 0 deletions definitions/cpanm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ detection:
- cpanfile
- Makefile.PL
- Build.PL
default: true
ecosystem_order: 200
priority: 10

version_detection:
Expand Down
2 changes: 2 additions & 0 deletions definitions/deno.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ detection:
manifests:
- deno.json
- deno.jsonc
default: true
ecosystem_order: 130
priority: 10

version_detection:
Expand Down
15 changes: 15 additions & 0 deletions definitions/dub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: dub
ecosystem: dub
binary: dub
status: detection-only

detection:
manifests:
- dub.json
- dub.sdl
default: true
ecosystem_order: 240
priority: 10

commands: {}
capabilities: []
14 changes: 14 additions & 0 deletions definitions/elm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: elm
ecosystem: elm
binary: elm
status: detection-only

detection:
manifests:
- elm.json
default: true
ecosystem_order: 230
priority: 10

commands: {}
capabilities: []
1 change: 1 addition & 0 deletions definitions/gem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ detection:
lockfiles: []
manifests:
- "*.gemspec"
ecosystem_order: 20
priority: 5

version_detection:
Expand Down
6 changes: 3 additions & 3 deletions definitions/gomod.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: gomod
ecosystem: golang
ecosystem: go
binary: go
version: ">=1.18"
status: current
min_tested: "1.18"
max_tested: "1.24.0"

detection:
lockfiles:
- go.sum
manifests:
- go.mod
default: true
ecosystem_order: 40
priority: 10

version_detection:
Expand Down
1 change: 1 addition & 0 deletions definitions/gradle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ detection:
manifests:
- build.gradle
- build.gradle.kts
ecosystem_order: 100
priority: 10

version_detection:
Expand Down
14 changes: 14 additions & 0 deletions definitions/haxelib.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: haxelib
ecosystem: haxelib
binary: haxelib
status: detection-only

detection:
manifests:
- haxelib.json
default: true
ecosystem_order: 250
priority: 10

commands: {}
capabilities: []
2 changes: 2 additions & 0 deletions definitions/lein.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ detection:
lockfiles: []
manifests:
- project.clj
default: true
ecosystem_order: 220
priority: 10

version_detection:
Expand Down
2 changes: 2 additions & 0 deletions definitions/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ detection:
lockfiles: []
manifests:
- pom.xml
default: true
ecosystem_order: 100
priority: 10

version_detection:
Expand Down
2 changes: 2 additions & 0 deletions definitions/mix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ detection:
- mix.lock
manifests:
- mix.exs
default: true
ecosystem_order: 70
priority: 10

commands:
Expand Down
16 changes: 16 additions & 0 deletions definitions/nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: nix
ecosystem: nix
binary: nix
status: detection-only

detection:
lockfiles:
- flake.lock
manifests:
- flake.nix
default: true
ecosystem_order: 260
priority: 10

commands: {}
capabilities: []
2 changes: 2 additions & 0 deletions definitions/npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ detection:
- npm-shrinkwrap.json
manifests:
- package.json
default: true
ecosystem_order: 10
priority: 10

version_detection:
Expand Down
4 changes: 4 additions & 0 deletions definitions/nuget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ version: ">=6.0.0"
detection:
lockfiles:
- packages.lock.json
- project.assets.json
manifests:
- "*.csproj"
- "*.fsproj"
- "*.vbproj"
- packages.config
default: true
ecosystem_order: 110
priority: 10

version_detection:
Expand Down
1 change: 1 addition & 0 deletions definitions/pip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ detection:
- requirements.in
- setup.py
- setup.cfg
ecosystem_order: 50
priority: 5

version_detection:
Expand Down
16 changes: 16 additions & 0 deletions definitions/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pkg
ecosystem: julia
binary: julia
status: detection-only

detection:
lockfiles:
- Manifest.toml
manifests:
- Project.toml
default: true
ecosystem_order: 160
priority: 10

commands: {}
capabilities: []
1 change: 1 addition & 0 deletions definitions/pnpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ detection:
- pnpm-lock.yaml
manifests:
- package.json
ecosystem_order: 10
priority: 20 # higher than npm when pnpm-lock.yaml present

version_detection:
Expand Down
5 changes: 3 additions & 2 deletions definitions/poetry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ detection:
- pyproject.toml
file_checks:
- file: pyproject.toml
contains: "[tool.poetry]"
priority: 20 # Higher than uv for poetry-specific projects
match: '\[tool\.poetry\]'
ecosystem_order: 50
priority: 20

commands:
init:
Expand Down
2 changes: 2 additions & 0 deletions definitions/pub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ detection:
- pubspec.lock
manifests:
- pubspec.yaml
default: true
ecosystem_order: 80
priority: 10

commands:
Expand Down
Loading
Loading