mix.exs

defmodule Packmatic.MixProject do
  use Mix.Project

  def project do
    [
      app: :packmatic,
      version: "1.1.1",
      elixir: "~> 1.9",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      package: package(),
      deps: deps(),
      dialyzer: dialyzer(),
      name: "Packmatic",
      description: "Streaming Zip64 archive generation",
      source_url: "https://github.com/evadne/packmatic",
      docs: docs()
    ]
  end

  def application do
    [extra_applications: [:logger]]
  end

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  defp dialyzer do
    [
      plt_add_apps: [:mix, :iex, :ex_unit],
      flags: ~w(error_handling no_opaque race_conditions underspecs unmatched_returns)a,
      ignore_warnings: "dialyzer-ignore-warnings.exs",
      list_unused_filters: true
    ]
  end

  defp deps do
    # iBrowse 4.4.1 is buggy
    # https://github.com/cmullaparthi/ibrowse/issues/162

    [
      {:briefly, "~> 0.3.0", only: :test},
      {:bypass, "~> 2.1.0", only: :test},
      {:dialyxir, "~> 1.1.0", only: :dev, runtime: false},
      {:ex_doc, "~> 0.23.0", only: :dev, runtime: false},
      {:httpotion, "~> 3.1.3"},
      {:ibrowse, "4.4.0"},
      {:mox, "~> 1.0.0", only: :test},
      {:teamcity_formatter, github: "prook/teamcity_formatter", only: [:test], runtime: false},
      {:timex, "~> 3.6.4", only: :test},
      {:stream_data, "~> 0.5.0", only: :test}
    ]
  end

  defp package do
    [
      maintainers: ["Evadne Wu"],
      files: package_files(),
      licenses: ["Apache 2.0"],
      links: %{"GitHub" => "https://github.com/evadne/packmatic"}
    ]
  end

  defp docs do
    [
      main: "readme",
      extras: ["README.md", "CHANGELOG.md"],
      nest_modules_by_prefix: [
        Packmatic.Manifest,
        Packmatic.Source,
        Packmatic.Field,
        Packmatic.Event
      ],
      groups_for_modules: [
        Events: [~r/Packmatic\.Event/],
        "Data Structs": [~r/\.Field/],
        Helpers: [Packmatic.Conn]
      ]
    ]
  end

  defp package_files do
    ~w(
      lib/packmatic/*
      mix.exs
    )
  end
end