Skip to content

Instantly share code, notes, and snippets.

@bradleyd
Created July 3, 2017 16:04
Show Gist options
  • Save bradleyd/f07dd1fb0a3278af0660cf57b44c4f37 to your computer and use it in GitHub Desktop.
Save bradleyd/f07dd1fb0a3278af0660cf57b44c4f37 to your computer and use it in GitHub Desktop.
elixir parse mix.lock
%{"amqp": {:hex, :amqp, "0.2.0", "ec41c4327ca7c9b1ac0baabb824d47f77a14754bed89b69bb9d32041642d59a3", [:mix], [{:amqp_client, "~> 3.6.8", [hex: :amqp_client, optional: false]}, {:rabbit_common, "~> 3.6.8", [hex: :rabbit_common, optional: false]}]},
"amqp_client": {:hex, :amqp_client, "3.6.8", "0388e50af78285f370f0b346cd487c96dcf82c66f2196913073ee4d909808c89", [:make, :rebar3], [{:rabbit_common, "3.6.8", [hex: :rabbit_common, optional: false]}]},
"base16": {:hex, :base16, "1.0.0", "283644e2b21bd5915acb7178bed7851fb07c6e5749b8fad68a53c501092176d9", [:rebar3], []},
"binary_protocol": {:git, "[email protected]:Parkifi/binary_protocol.git", "f6d5afe7c7df4d48037680e17c1f824b90b705a9", []},
"certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], []},
"distillery": {:hex, :distillery, "1.3.1", "211231af29ea55c79143d601a2caaf5936cc7b99e73bef25d78a0ff7f321b7fe", [:mix], []},
"eini": {:hex, :eini, "1.2.4", "abd64a0533398a6d714d21219bb85f2d41fdb42665ac4080939b7bfa8e55f386", [:rebar3], []},
"external_config": {:hex, :external_config, "0.1.0", "fd88c535a8b7b7d55fdaabadbb70a0075ccd18507caaeba2ad739638cf443911", [:mix], []},
"hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, optional: false]}, {:idna, "4.0.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
"httpoison": {:hex, :httpoison, "0.11.1", "d06c571274c0e77b6cc50e548db3fd7779f611fbed6681fd60a331f66c143a0b", [:mix], [{:hackney, "~> 1.7.0", [hex: :hackney, optional: false]}]},
"idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], []},
"jsx": {:hex, :jsx, "2.8.0", "749bec6d205c694ae1786d62cea6cc45a390437e24835fd16d12d74f07097727", [:mix, :rebar], []},
"lhttpc": {:hex, :lhttpc, "1.5.3", "f87f1aa17c29ef57994de47f679d2ef43e4cf7bf9a3f476f0b4243f2de541d0a", [:rebar3], []},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
"rabbit_common": {:hex, :rabbit_common, "3.6.8", "43bae839233d6ecdf8a06c1af3a985cfdb5d76232ec6e1cbe7d0469c4e5f03f5", [:make, :rebar3], []},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}}
[%{ssl_verify_fun: %{latest_version: nil, lock_version: "1.1.1",
upgrade_available: false}},
%{rabbit_common: %{latest_version: nil, lock_version: "3.6.8",
upgrade_available: false}},
%{poison: %{latest_version: nil, lock_version: "3.1.0",
upgrade_available: false}},
%{mimerl: %{latest_version: nil, lock_version: "1.0.2",
upgrade_available: false}},
%{metrics: %{latest_version: nil, lock_version: "1.0.1",
upgrade_available: false}},
%{lhttpc: %{latest_version: nil, lock_version: "1.5.3",
upgrade_available: false}},
%{jsx: %{latest_version: nil, lock_version: "2.8.0",
upgrade_available: false}},
%{idna: %{latest_version: nil, lock_version: "4.0.0",
upgrade_available: false}},
%{httpoison: %{latest_version: nil, lock_version: "0.11.1",
upgrade_available: false}},
%{hackney: %{latest_version: nil, lock_version: "1.7.1",
upgrade_available: false}},
%{external_config: %{latest_version: nil, lock_version: "0.1.0",
upgrade_available: false}},
%{eini: %{latest_version: nil, lock_version: "1.2.4",
upgrade_available: false}},
%{distillery: %{latest_version: nil, lock_version: "1.3.1",
upgrade_available: false}},
%{certifi: %{latest_version: nil, lock_version: "1.0.0",
upgrade_available: false}},
%{binary_protocol: %{latest_version: nil, lock_version: :latest,
upgrade_available: false}},
%{base16: %{latest_version: nil, lock_version: "1.0.0",
upgrade_available: false}},
%{amqp_client: %{latest_version: nil, lock_version: "3.6.8",
upgrade_available: false}},
%{amqp: %{latest_version: nil, lock_version: "0.2.0",
upgrade_available: false}}]
{:ok, lockfile} = File.read("./mix.lock")
{lock_deps, _} = lockfile |> Code.eval_string
Enum.reduce(lock_deps, [], fn(i, acc) ->
case i do
{name, {_, _, version, _hash, _, _child_deps}} -> [%{name => %{lock_version: version, latest_version: nil, upgrade_available: false}} | acc ]
{name, {:git, _path, _hash, []}} -> [%{name => %{lock_version: :latest, latest_version: nil, upgrade_available: false}} | acc ]
_ -> acc
end
end)
## TODO
# add http client and parse json
# https://hex.pm/api/packages/poison
# releases latest with version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment