Current section

Files

Jump to
ex_utils mix.exs
Raw

mix.exs

defmodule ExUtils.MixProject do
  use Mix.Project

  @app :ex_utils
  @name "ExUtils"
  @version "3.0.0"
  @github "https://github.com/sheharyarn/#{@app}"

  def project do
    [
      # Project
      app: @app,
      version: @version,
      elixir: "~> 1.14",
      description: description(),
      package: package(),
      aliases: aliases(),
      deps: deps(),
      dialyzer: dialyzer(),

      # ExDoc
      name: @name,
      source_url: @github,
      homepage_url: @github,
      docs: docs()
    ]
  end

  def application do
    [
      env: [
        otp_app: nil,
        testing?: false,
        blanks: [nil, "", [], %{}, check: &ExUtils.Strings.__is_blank__/1]
      ],
      extra_applications: [:crypto, :logger]
    ]
  end

  defp deps do
    [
      {:decimal, "~> 2.0 or ~> 3.0", optional: true},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
      {:ecto, "~> 3.10", optional: true},
      {:ex_doc, ">= 0.0.0", only: :dev},
      {:inch_ex, ">= 0.0.0", only: :docs},
      {:sobelow, "~> 0.16", only: :dev}
    ]
  end

  defp description do
    """
    Elixir utilities, helpers and shortcuts ⚡
    """
  end

  defp aliases do
    [
      sobelow: ["sobelow --strict --skip --exit --no-router"],
      quality: [
        "format --check-formatted",
        "deps.unlock --check-unused",
        "hex.audit",
        "sobelow",
        "dialyzer"
      ]
    ]
  end

  defp package do
    [
      name: @app,
      maintainers: ["Sheharyar Naseer"],
      licenses: ~w[MIT],
      files: ~w(mix.exs lib README.md usage-rules.md),
      links: %{"GitHub" => @github}
    ]
  end

  defp docs do
    separated = ~w[Modules Ecto]
    separated_groups = Enum.map(separated, &{:"ExUtils.#{&1}", ~r/^ExUtils\.#{&1}(?:\.|$)/})
    core_group_regex = ~r/^ExUtils\.(?!(?:#{Enum.join(separated, "|")})(?:\.|$)).+/

    [
      main: "readme",
      source_url: @github,
      source_ref: "v#{@version}",
      canonical: "https://hexdocs.pm/#{@app}",
      extras: [
        "README.md",
        "CHANGELOG.md",
        {"usage-rules.md", title: "Usage Rules for Agents"}
      ],
      skip_undefined_reference_warnings_on: ["CHANGELOG.md"],
      groups_for_modules: [ExUtils: core_group_regex] ++ separated_groups
    ]
  end

  defp dialyzer do
    [
      plt_add_apps: [:ecto, :decimal],
      plt_local_path: "priv/plts",
      plt_core_path: "priv/plts",
      flags: [:error_handling]
    ]
  end
end