version_check v0.1.2 VersionCheck

This module defines an application and a macro to generate alerts about new versions of applications in Hex. The messages are shown using Logger as a warning.

When starting an app using the function or the VersionCheck application you should see something like:

% iex -S mix
Erlang/OTP 19 [erts-8.1] [source-4cc2ce3] [64-bit] [smp:8:8]
[async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.3.2) - press Ctrl+C to exit (type h() ENTER for help)

17:30:42.454 [warn] A new yggdrasil version is available (2.0.8 > 2.0.7)
17:30:42.454 [debug] Using the latest version of :version_check (0.1.0)
iex(1)>

Using VersionCheck

When adding use VersionCheck to a module, the module adds the public function check_version/0. If it is called from inside the start/2 function of the Application behaviour it’ll check the current application version against hex.pm before it starts i.e:

defmodule MyApp do
  use Application
  use VersionCheck, application: :my_app

  def start(_type, _args) do
    import Supervisor.Spec, warn: false

    check_version()

    children = [
      (...)
    ]

    opts = (...)

    Supervisor.start_link(children, opts)
  end
end

VersionCheck App

It is also possible to add VersionCheck to your required applications in your mix.exs file i.e:

def application do
  [applications: [:version_check]]
end

This app will check the version of every application started. That’s why it should be the last application in the list.

Summary

Functions

check_version(app_name)