Skip to main content

mix.exs

defmodule Image.Components.MixProject do
  use Mix.Project

  @version "0.1.1"
  @source_url "https://github.com/elixir-image/image_components"

  def project do
    [
      app: :image_components,
      version: @version,
      elixir: "~> 1.17",
      description:
        "Phoenix.Component wrappers and per-CDN URL builders that project a canonical " <>
          "Image.Plug.Pipeline IR onto Cloudflare, Cloudinary, imgix, and ImageKit URL grammars.",
      package: package(),
      docs: docs(),
      deps: deps(),
      start_permanent: Mix.env() == :prod,
      dialyzer: [
        plt_add_apps: [:phoenix_live_view, :ex_unit],
        flags: [:error_handling, :unknown, :extra_return]
      ]
    ]
  end

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

  defp deps do
    [
      {:phoenix_live_view, "~> 1.1"},
      {:image_plug, "~> 0.1"},
      {:image, "~> 0.67"},
      {:ex_doc, "~> 0.34", only: :dev, runtime: false},
      {:dialyxir, "~> 1.4", only: :dev, runtime: false},
      {:stream_data, "~> 1.1", only: :test},
      {:req, "~> 0.5", only: :test}
    ] ++ maybe_json_polyfill()
  end

  defp maybe_json_polyfill do
    if Code.ensure_loaded?(:json) do
      []
    else
      [{:json_polyfill, "~> 0.2 or ~> 1.0"}]
    end
  end

  defp package do
    [
      maintainers: ["Kip Cole"],
      licenses: ["Apache-2.0"],
      links: %{
        "GitHub" => @source_url,
        "Changelog" => "#{@source_url}/blob/v#{@version}/CHANGELOG.md"
      },
      files: ~w(lib guides mix.exs README.md CHANGELOG.md LICENSE.md)
    ]
  end

  defp docs do
    [
      main: "readme",
      source_url: @source_url,
      source_ref: "v#{@version}",
      formatters: ["html", "markdown"],
      extras: [
        "README.md",
        "guides/usage.md",
        "guides/responsive.md",
        "guides/iiif.md",
        "guides/environments.md",
        "CHANGELOG.md",
        "LICENSE.md"
      ],
      groups_for_extras: [
        Guides: ~r{guides/},
        About: ~r/(README|CHANGELOG|LICENSE)\.md/
      ],
      groups_for_modules: [
        Components: [Image.Components],
        "URL builders": [Image.Components.URL]
      ]
    ]
  end
end