defmodule Imager.Mixfile do
  use Mix.Project

  @description """
  Image transformation proxy service.

  For details check out: <https://github.com/appunite/imager>
  """

  def project do
    [
      app: :imager,
      version: version(),
      elixir: "~> 1.4",
      elixirc_paths: elixirc_paths(Mix.env()),
      elixirc_options: [warnings_as_errors: true],
      compilers: [:phoenix] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      dialyzer: [plt_add_apps: [:erlexec]],
      test_coverage: [tool: ExCoveralls],
      preferred_cli_env: [
        coveralls: :test,
        "coveralls.detail": :test,
        "coveralls.circle": :test,
        "coveralls.html": :test
      ],
      description: @description
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Imager.Application, []},
      extra_applications: [:logger, :inets, :runtime_tools],
      included_applications: [:erlexec]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.4.0"},
      {:phoenix_pubsub, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:plug, "~> 1.7"},
      {:distillery, "~> 2.0"},
      {:prometheus, "~> 4.1"},
      {:prometheus_phoenix, "~> 1.2.0"},
      {:prometheus_process_collector, "~> 1.4.0"},
      {:ex_aws, "~> 2.0"},
      {:ex_aws_s3, "~> 2.0"},
      {:hackney, "~> 1.9"},
      {:sweet_xml, "~> 0.6"},
      {:jason, ">= 0.0.0"},
      {:sentry, "~> 7.0"},
      {:erlexec, "~> 1.9", runtime: false},
      {:jose, "~> 1.8"},
      {:toml, "~> 0.3"},
      {:mockery, "~> 2.2"},
      {:credo, ">= 0.0.0", only: [:dev], runtime: false},
      {:dialyxir, ">= 0.0.0", only: [:dev], runtime: false},
      {:junit_formatter, "~> 3.0", only: [:test]},
      {:excoveralls, "~> 0.10", only: [:test]},
      {:stream_data, "~> 0.1", only: [:test]},
      {:temp, "~> 0.4", only: [:test]},
      {:bypass, "~> 1.0", only: [:test]}
    ]
  end

  defp version do
    case System.cmd("git", ~w(describe)) do
      {vers, 0} -> String.trim(vers)
      _ -> "0.0.0"
    end
  end
end
