View Source HexSolver (HexSolver v0.1.0)

A version solver.

Link to this section Summary

Functions

Parses or converts a SemVer version or Elixir version requirement to an internal solver constraint that can be returned by the HexSolver.Registry or passed to HexSolver.run/4.

Parses or converts a SemVer version or Elixir version requirement to an internal solver constraint that can be returned by the HexSolver.Registry or passed to HexSolver.run/4.

Link to this section Types

@opaque constraint()
@type dependency() :: {package(), constraint(), optional(), label()}
@type label() :: String.t()
@type locked() :: {package(), Version.t()}
@type optional() :: boolean()
@type package() :: String.t()

Link to this section Functions

Link to this function

parse_constraint!(string)

View Source
@spec parse_constraint!(String.t() | Version.t() | Version.Requirement.t()) ::
  constraint()

Parses or converts a SemVer version or Elixir version requirement to an internal solver constraint that can be returned by the HexSolver.Registry or passed to HexSolver.run/4.

Link to this function

parse_constraint(string)

View Source
@spec parse_constraint(String.t() | Version.t() | Version.Requirement.t()) ::
  {:ok, constraint()} | :error

Parses or converts a SemVer version or Elixir version requirement to an internal solver constraint that can be returned by the HexSolver.Registry or passed to HexSolver.run/4.

Link to this function

run(registry, dependencies, locked, overrides, opts \\ [])

View Source
@spec run(module(), [dependency()], [locked()], [label()], [{:ansi, boolean()}]) ::
  {:ok, %{required(package()) => Version.t()}} | {:error, String.t()}

Runs the version solver.

Takes a HexSolver.Registry implementation, a list of root dependencies, a list of locked package versions, and a list of packages that are overridden by the root dependencies.

Locked dependencies are treated as optional dependencies with a single version as their constraint.

The overrides are a set of labels. If a dependency with a matching label is declared the solver will ignore that dependency unless it's a root dependency.

Returns a map of packages and their selected versions or a human readable explanation of why a solution could not be found.

options

Options

  • :ansi - If true adds ANSI formatting to the failure message (Default: false)