Current section

Files

Jump to
espex mix.exs
Raw

mix.exs

defmodule Espex.MixProject do
  use Mix.Project

  @app :espex
  @version "0.12.0"
  @source_url "https://github.com/bbangert/espex"

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

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

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

  defp deps do
    [
      {:thousand_island, "~> 1.5"},
      {:protobuf, "~> 0.12"},
      {:protobuf_generate, "~> 0.2", runtime: false},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
      {:sobelow, "~> 0.14", only: [:dev, :test], runtime: false},
      {:argus_beam, "~> 0.20", only: [:dev, :test], runtime: false},
      {:ex_doc, "~> 0.34", only: :dev, runtime: false},
      # Exercised by the mDNS integration test and the mdns_demo manual
      # script. Not a runtime dep — Espex.Mdns.MdnsLite uses late-binding
      # so espex loads without it for downstream apps that don't need
      # mDNS.
      {:mdns_lite, "~> 0.8", only: [:dev, :test]}
    ]
  end

  defp aliases do
    [
      protobuf: [
        "protobuf.generate --output-path=./lib/espex/proto --include-path=./priv/protos --package-prefix=espex.proto priv/protos/api_options.proto priv/protos/api.proto"
      ]
    ]
  end

  defp argus do
    [
      ignore: [
        # rest_for_one_orphaned_children, inferred: the task supervisor is
        # a runtime name, so argus guesses the top-level listener
        # Task.Supervisor. Each of these starts its tasks under its own
        # Task.Supervisor, which shares a :one_for_all subtree with it
        # (Espex.InfraredQueue.Supervisor, Espex.Dialer.Supervisor).
        findings: [
          {:coupling, {Espex.InfraredQueue, :start, 2}},
          {:coupling, {Espex.Dialer, :start_dial, 1}}
        ]
      ]
    ]
  end

  defp dialyzer do
    [
      plt_add_apps: [:mix, :ex_unit],
      plt_local_path: "priv/plts/project.plt",
      plt_core_path: "priv/plts/core.plt",
      flags: [:error_handling, :unknown, :extra_return, :missing_return]
    ]
  end

  defp description do
    "ESPHome Native API server library for Elixir."
  end

  defp package do
    [
      licenses: ["MIT"],
      links: %{"GitHub" => @source_url},
      files: ~w(lib guides priv/protos .formatter.exs mix.exs README.md LICENSE)
    ]
  end

  defp docs do
    [
      main: "readme",
      source_url: @source_url,
      extras: [
        "README.md",
        "guides/architecture.md",
        "guides/entity_types.md",
        "guides/api/1.15.md": [title: "API 1.15"],
        "guides/api/1.16.md": [title: "API 1.16"],
        "guides/api/1.17.md": [title: "API 1.17"],
        "guides/api/1.18.md": [title: "API 1.18"]
      ],
      # The first matching group wins, so the narrower pattern goes first.
      groups_for_extras: [
        "API versions": ~r"guides/api/.*",
        Guides: ~r"guides/.*"
      ]
    ]
  end
end