ExQuality.Init.VersionResolver (ExQuality v0.5.0)

View Source

Resolves latest package versions from hex.pm.

Uses mix hex.info <package> to fetch version information and parses the recommended version string from the output.

Summary

Functions

Fetches latest versions for the given tools.

Parses version from hex.info output.

Functions

fetch_versions(tools)

@spec fetch_versions([atom()]) :: %{required(atom()) => {atom(), String.t()}}

Fetches latest versions for the given tools.

Returns a map of tool -> {package_name, version_spec}.

Examples

fetch_versions([:credo, :dialyzer])
#=> %{
  credo: {:credo, "~> 1.7"},
  dialyzer: {:dialyxir, "~> 1.4"}
}

parse_version_from_output(output)

@spec parse_version_from_output(String.t()) :: String.t()

Parses version from hex.info output.

Looks for the Config line which contains the recommended version string.

Examples

output = """
Config: {:credo, "~> 1.7"}
Locked version: 1.7.15
Releases: 1.7.15, 1.7.14, ...
"""

parse_version_from_output(output)
#=> "~> 1.7"

Falls back to parsing the Releases line if Config is not found, and uses "~> 0.1" as a last resort.