Skip to content

Instantly share code, notes, and snippets.

@jcelliott
Last active August 19, 2024 14:36
Show Gist options
  • Save jcelliott/3e88b66412c2ace2b2d49462aaa3e903 to your computer and use it in GitHub Desktop.
Save jcelliott/3e88b66412c2ace2b2d49462aaa3e903 to your computer and use it in GitHub Desktop.
Mix task to list information about all dependencies
defmodule Mix.Tasks.Deps.Info do
use Mix.Task
@moduledoc """
Prints information for every dependency from Hex
"""
def run(_args) do
Mix.Project.get!
Mix.Dep.loaded([env: :prod])
|> Enum.each(fn(dep) ->
{200, %{"meta" => info, "name" => name}, _api} = Hex.API.Package.get(dep.app)
IO.puts("""
#{name}:
description: #{info["description"]}
licenses: #{info["licenses"] |> format_list}
link: #{info["links"] |> get_one_value}
""")
end)
end
defp format_list(nil), do: ""
defp format_list(list), do: Enum.join(list, " ")
defp get_one_value(nil), do: ""
defp get_one_value(map) do
map |> Map.values |> hd
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment