defmodule Dagger.MixProject do
  use Mix.Project

  @version "0.0.0"
  @source_url "https://github.com/dagger/dagger"

  def project do
    [
      app: :dagger,
      version: @version,
      elixir: "~> 1.14",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      package: package(),
      docs: docs(),
      aliases: aliases(),
      elixirc_paths: elixirc_paths(Mix.env())
    ]
  end

  def application do
    [
      extra_applications: [:logger, :public_key, :ssl, :inets]
    ]
  end

  defp deps do
    [
      {:jason, "~> 1.4"},
      {:nimble_options, "~> 1.0"},
      {:nestru, "~> 1.0"},
      {:ex_doc, "~> 0.27", only: :dev, runtime: false},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:req, "~> 0.5", optional: true}
    ]
  end

  defp aliases do
    [
      lint: ["format --check-formatted", "credo"]
    ]
  end

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

  defp package do
    %{
      name: "dagger",
      description: "Dagger SDK for Elixir",
      licenses: ["Apache-2.0"],
      links: %{
        "GitHub" => @source_url,
        "Changelog" => "#{@source_url}/releases/tag/sdk%2Felixir%2Fv#{@version}"
      }
    }
  end

  defp docs do
    [
      source_url_pattern: "#{@source_url}/blob/v#{@version}/sdk/elixir/%{path}#L%{line}",
      main: "Dagger"
    ]
  end
end
