Last active
August 19, 2024 14:36
-
-
Save jcelliott/3e88b66412c2ace2b2d49462aaa3e903 to your computer and use it in GitHub Desktop.
Mix task to list information about all dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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