Skip to main content

mix.exs

defmodule Codat.MixProject do
  use Mix.Project

  @version "1.0.0"
  @source_url "https://github.com/iamkanishka/codat.git"

  def project do
    [
      app: :codat,
      version: @version,
      elixir: "~> 1.18",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      description: description(),
      package: package(),
      docs: docs(),
      aliases: aliases(),
      test_coverage: [tool: ExCoveralls],
      preferred_cli_env: [
        coveralls: :test,
        "coveralls.detail": :test,
        "coveralls.post": :test,
        "coveralls.html": :test
      ],
      dialyzer: [
        plt_core_path: "priv/plts",
        plt_add_apps: [:mix],
        flags: [:error_handling, :missing_return, :underspecs]
      ]
    ]
  end

  def application do
    [
      extra_applications: [:logger, :crypto],
      mod: {Codat.Application, []}
    ]
  end

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

  defp deps do
    [
      # HTTP client (modern, composable)
      {:req, "~> 0.5"},
      {:finch, "~> 0.19"},
      # JSON
      {:jason, "~> 1.4"},
      # Config validation
      {:nimble_options, "~> 1.1"},
      # Telemetry
      {:telemetry, "~> 1.2"},
      {:telemetry_metrics, "~> 1.0"},
      # Plug for webhook consumer endpoint
      {:plug, "~> 1.16"},
      # Dev / docs
      {:ex_doc, "~> 0.40", only: :dev, runtime: false},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
      # Test
      {:bypass, "~> 2.1", only: :test},
      {:mox, "~> 1.1", only: :test},
      {:excoveralls, "~> 0.18", only: :test}
    ]
  end

  defp description do
    "Production-grade Elixir client for the Codat API — " <>
      "financial data connectivity for accounting, banking, and commerce platforms."
  end

  defp package do
    [
      name: "codat",
      files: ~w[lib .formatter.exs mix.exs README.md LICENSE CHANGELOG.md],
      licenses: ["MIT"],
      links: %{"GitHub" => @source_url, "Docs" => "https://hexdocs.pm/codat"}
    ]
  end

  defp docs do
    [
      main: "readme",
      source_url: @source_url,
      source_ref: "v#{@version}",
      extras: ["README.md", "CHANGELOG.md", "LICENSE"],
      groups_for_modules: [
        Core: [Codat, Codat.Client, Codat.Config, Codat.Error, Codat.Telemetry],
        Utilities: [Codat.QueryBuilder, Codat.Pagination],
        Platform: [
          Codat.Platform.Companies,
          Codat.Platform.Connections,
          Codat.Platform.APIKeys,
          Codat.Platform.Webhooks,
          Codat.Platform.PushOperations,
          Codat.Platform.DataStatus,
          Codat.Platform.Files
        ],
        Accounting: ~r/^Codat\.Accounting/,
        "Bank Feeds": ~r/^Codat\.BankFeeds/,
        Lending: ~r/^Codat\.Lending/,
        Expenses: ~r/^Codat\.Expenses/,
        "Bill Pay": ~r/^Codat\.BillPay/,
        Webhooks: ~r/^Codat\.Webhooks/,
        Schemas: ~r/^Codat\.Schema/
      ]
    ]
  end

  defp aliases do
    [
      setup: ["deps.get"],
      "test.coverage": ["coveralls.html"],
      check: ["format --check-formatted", "credo --strict", "dialyzer --format dialyxir"]
    ]
  end
end