Skip to content
Draft
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
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A Go library that wraps package manager CLIs behind a common interface. Part of

## What it does

Translates generic operations (install, add, remove, list, outdated, update, vendor, resolve) into the correct CLI commands for each package manager. Define what you want to do once, and the library figures out the right command for npm, bundler, cargo, go, or any other supported manager.
Translates generic operations (init, install, add, remove, list, outdated, update, vendor, resolve) into the correct CLI commands for each package manager. Define what you want to do once, and the library figures out the right command for npm, bundler, cargo, go, or any other supported manager.

```go
translator := managers.NewTranslator()
Expand Down Expand Up @@ -83,7 +83,7 @@ cmd, _ = translator.BuildCommand("bundler", "add", managers.CommandInput{
| helm | helm | Chart.lock |
| brew | homebrew | - |

Most managers support: install, add, remove, list, outdated, update, resolve. Some also support vendor and path. Some managers (maven, gradle, sbt, lein) have limited CLI support for add/remove operations.
Most managers support: init, install, add, remove, list, outdated, update, resolve. Some also support vendor and path. Some managers (maven, gradle, sbt, lein) have limited CLI support for add/remove operations. A few global installers (brew, gem, cpanm) and managers with interactive-only init (maven, pip, sbt) do not have init support.

## Installation

Expand Down Expand Up @@ -211,6 +211,7 @@ Built-in policies include AllowAllPolicy, DenyAllPolicy, and PackageBlocklistPol

| Operation | Description |
|-----------|-------------|
| `init` | Initialize a new project with manifest file |
| `install` | Install dependencies from lockfile |
| `add` | Add a new dependency |
| `remove` | Remove a dependency |
Expand All @@ -229,6 +230,18 @@ Built-in policies include AllowAllPolicy, DenyAllPolicy, and PackageBlocklistPol
| `frozen` | Fail if lockfile would change (CI mode) |
| `json` | Output in JSON format (where supported) |

### Initializing projects

The `init` operation creates a new project with the package manager's default manifest file. This is useful for creating temporary projects for dependency resolution or scaffolding new projects.

```go
manager, _ := managers.Detect("/path/to/empty/dir")
result, _ := manager.Init(ctx)
// Creates package.json (npm), Gemfile (bundler), Cargo.toml (cargo), etc.
```

**Managers with init support:** npm, pnpm, yarn, bun, bundler, cargo, gomod, uv, poetry, deno, composer, swift, pub, mix, nuget, gradle, helm, conan, conda, stack, lein, rebar3, cabal, cocoapods, nimble, opam, luarocks, shards, vcpkg, renv

### Getting package paths

The `path` operation returns the filesystem path to an installed package, useful for source exploration or editor integration:
Expand Down
7 changes: 7 additions & 0 deletions definitions/bun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ detection:
priority: 25 # Higher than npm/yarn/pnpm when bun lockfile present

commands:
init:
base: [init, -y]
exit_codes:
0: success
1: error

install:
base: [install]
flags:
Expand Down Expand Up @@ -92,6 +98,7 @@ commands:
1: error

capabilities:
- init
- install
- install_frozen
- add
Expand Down
7 changes: 7 additions & 0 deletions definitions/bundler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ version_detection:
pattern: '(\d+\.\d+\.\d+)'

commands:
init:
base: [init]
exit_codes:
0: success
1: error

install:
base: [install]
flags:
Expand Down Expand Up @@ -125,6 +131,7 @@ commands:
1: error

capabilities:
- init
- install
- install_frozen
- add
Expand Down
7 changes: 7 additions & 0 deletions definitions/cabal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ version_detection:
pattern: 'cabal-install version (\d+\.\d+\.\d+)'

commands:
init:
base: [init, -n, -p, resolve-tmp]
exit_codes:
0: success
1: error

install:
base: [build, --only-dependencies]
flags:
Expand Down Expand Up @@ -63,6 +69,7 @@ commands:
1: error

capabilities:
- init
- install
- list
- outdated
Expand Down
7 changes: 7 additions & 0 deletions definitions/cargo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ version_detection:
pattern: 'cargo (\d+\.\d+\.\d+)'

commands:
init:
base: [init, --lib]
exit_codes:
0: success
1: error

# cargo fetch downloads dependencies without building
# cargo build would also work but does more than just install
install:
Expand Down Expand Up @@ -129,6 +135,7 @@ commands:
1: error

capabilities:
- init
- install
- install_frozen
- add
Expand Down
6 changes: 6 additions & 0 deletions definitions/cocoapods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ detection:
priority: 10

commands:
init:
base: [init]
exit_codes:
0: success
1: error

install:
base: [install]
flags:
Expand Down
8 changes: 8 additions & 0 deletions definitions/composer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ detection:
priority: 10

commands:
init:
base: [init, -n]
default_flags: [--name, resolve/tmp]
exit_codes:
0: success
1: error

install:
base: [install]
flags:
Expand Down Expand Up @@ -91,6 +98,7 @@ commands:
1: error

capabilities:
- init
- install
- add
- add_dev
Expand Down
7 changes: 7 additions & 0 deletions definitions/conan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ version_detection:
pattern: 'Conan version (\d+\.\d+\.\d+)'

commands:
init:
base: [new, resolve-tmp, -d, basic]
exit_codes:
0: success
1: error

install:
base: [install, .]
flags:
Expand Down Expand Up @@ -82,6 +88,7 @@ commands:
1: error

capabilities:
- init
- install
- add
- remove
Expand Down
7 changes: 7 additions & 0 deletions definitions/conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ version_detection:
pattern: 'conda (\d+\.\d+\.\d+)'

commands:
init:
base: [create, -n, resolve-tmp, --yes]
exit_codes:
0: success
1: error

install:
base: [install, --yes]
base_overrides:
Expand Down Expand Up @@ -96,6 +102,7 @@ commands:
1: error

capabilities:
- init
- install
- install_frozen
- add
Expand Down
7 changes: 7 additions & 0 deletions definitions/deno.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ version_detection:
pattern: 'deno (\d+\.\d+\.\d+)'

commands:
init:
base: [init]
exit_codes:
0: success
1: error

install:
base: [install]
flags:
Expand Down Expand Up @@ -86,6 +92,7 @@ commands:
1: error

capabilities:
- init
- install
- install_frozen
- add
Expand Down
7 changes: 7 additions & 0 deletions definitions/gomod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ version_detection:
pattern: 'go(\d+\.\d+(?:\.\d+)?)'

commands:
init:
base: [mod, init, resolve-tmp]
exit_codes:
0: success
1: error

# go mod download fetches dependencies
install:
base: [mod, download]
Expand Down Expand Up @@ -124,6 +130,7 @@ commands:
1: error

capabilities:
- init
- install
- add
- remove
Expand Down
7 changes: 7 additions & 0 deletions definitions/gradle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ version_detection:
pattern: 'Gradle (\d+\.\d+(?:\.\d+)?)'

commands:
init:
base: [init, --type, java-library, --dsl, groovy]
exit_codes:
0: success
1: error

install:
base: [dependencies, --write-locks]
flags:
Expand Down Expand Up @@ -77,6 +83,7 @@ commands:
1: error

capabilities:
- init
- install
- list
- resolve
7 changes: 7 additions & 0 deletions definitions/helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ version_detection:
pattern: 'v(\d+\.\d+\.\d+)'

commands:
init:
base: [create, resolve-tmp]
exit_codes:
0: success
1: error

install:
base: [dependency, build]
flags:
Expand Down Expand Up @@ -74,6 +80,7 @@ commands:
1: error

capabilities:
- init
- install
- add
- remove
Expand Down
7 changes: 7 additions & 0 deletions definitions/lein.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ version_detection:
pattern: 'Leiningen (\d+\.\d+\.\d+)'

commands:
init:
base: [new, resolve-tmp]
exit_codes:
0: success
1: error

install:
base: [deps]
exit_codes:
Expand Down Expand Up @@ -67,6 +73,7 @@ commands:
1: error

capabilities:
- init
- install
- list
- resolve
7 changes: 7 additions & 0 deletions definitions/luarocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ version_detection:
pattern: 'LuaRocks (\d+\.\d+\.\d+)'

commands:
init:
base: [init, resolve-tmp]
exit_codes:
0: success
1: error

install:
base: [install, --deps-only, .]
flags:
Expand Down Expand Up @@ -81,6 +87,7 @@ commands:
pattern: 'Installed in:\s+(\S+)'

capabilities:
- init
- install
- add
- remove
Expand Down
7 changes: 7 additions & 0 deletions definitions/mix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ detection:
priority: 10

commands:
init:
base: [new, resolve_tmp]
exit_codes:
0: success
1: error

install:
base: [deps.get]
flags:
Expand Down Expand Up @@ -86,6 +92,7 @@ commands:
1: error

capabilities:
- init
- install
- install_frozen
- list
Expand Down
7 changes: 7 additions & 0 deletions definitions/nimble.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ version_detection:
pattern: 'nimble v(\d+\.\d+\.\d+)'

commands:
init:
base: [init, -y]
exit_codes:
0: success
1: error

install:
base: [install, --depsOnly]
flags:
Expand Down Expand Up @@ -79,6 +85,7 @@ commands:
1: error

capabilities:
- init
- install
- add
- remove
Expand Down
7 changes: 7 additions & 0 deletions definitions/npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ version_detection:
pattern: '(\d+\.\d+\.\d+)'

commands:
init:
base: [init, -y]
exit_codes:
0: success
1: error

install:
base: [install]
base_overrides:
Expand Down Expand Up @@ -100,6 +106,7 @@ commands:
1: partial

capabilities:
- init
- install
- install_frozen
- add
Expand Down
Loading