Skip to main content

mix.exs

defmodule Baton.MixProject do
  use Mix.Project

  @version "0.1.0"
  @source_url "https://github.com/RudeWalrus/baton"

  def project do
    [
      app: :baton,
      version: @version,
      elixir: "~> 1.15",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      aliases: aliases(),
      description: description(),
      package: package(),
      docs: docs(),
      name: "Baton",
      source_url: @source_url,
      dialyzer: [plt_add_apps: [:ex_unit, :mix]]
    ]
  end

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

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

  defp deps do
    [
      # ── Core (required) ──────────────────────────────────────────────────
      {:oban, "~> 2.17"},
      {:ecto_sql, "~> 3.10"},
      {:jason, "~> 1.4"},
      {:nimble_options, "~> 1.0"},
      {:telemetry, "~> 1.2"},

      # ── Optional features ────────────────────────────────────────────────
      # Cost/stats tracking needs Decimal (usually present via Ecto, declared
      # explicitly and optional so a minimal install can skip it).
      # Allow 3.0+, which patches GHSA-rhv4-8758-jx7v (unbounded-exponent DoS in
      # Decimal.new). 2.x is still permitted for hosts pinned to it.
      {:decimal, "~> 2.0 or ~> 3.0", optional: true},
      # Live dashboard + PubSub step events.
      {:phoenix_pubsub, "~> 2.1", optional: true},
      {:phoenix_live_view, "~> 1.0", optional: true},

      # ── Tooling (dev/test only) ──────────────────────────────────────────
      {:postgrex, "~> 0.17", only: [:test]},
      {:ex_doc, "~> 0.34", only: :dev, runtime: false},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev], runtime: false},
      {:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false}
    ]
  end

  defp aliases do
    [
      # The test suite creates storage and runs its own migration module
      # (Baton.Test.Migrations) from test/test_helper.exs, so the only alias
      # step needed here is creating the database.
      test: ["ecto.create --quiet", "test"]
    ]
  end

  defp description do
    "DAG-based job workflows for Oban: dependency ordering, fan-out/synthesis, " <>
      "result passing, retry idempotency, and per-step LLM cost tracking — without Oban Pro."
  end

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

  defp docs do
    [
      main: "readme",
      logo: "guides/assets/baton-mark.svg",
      assets: %{"guides/assets" => "guides/assets"},
      source_ref: "v#{@version}",
      source_url: @source_url,
      extras: [
        "README.md",
        "guides/getting_started.md",
        "guides/building_a_workflow.md",
        "guides/multi_model.md",
        "CHANGELOG.md"
      ],
      groups_for_extras: [
        Guides: ~r/guides\/.*/
      ],
      groups_for_modules: [
        "Building Workflows": [Baton, Baton.MultiModel],
        Execution: [Baton.Worker, Baton.LLMWorker, Baton.Check, Baton.Results],
        Observability: [
          Baton.Telemetry,
          Baton.Events,
          Baton.Stats,
          Baton.Debug,
          Baton.Query
        ],
        Infrastructure: [
          Baton.Plugin,
          Baton.Migration,
          Baton.Retention,
          Baton.Pricing,
          Baton.Config
        ],
        Internals: [
          Baton.DAG,
          Baton.Node,
          Baton.Nodes,
          Baton.Reschedule,
          Baton.Completion
        ]
      ]
    ]
  end
end