Skip to main content

mix.exs

defmodule FsNotify.MixProject do
  use Mix.Project

  @version "0.1.2"
  @source_url "https://github.com/fahchen/fs_notify"

  def project do
    [
      app: :fs_notify,
      version: @version,
      elixir: "~> 1.19",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      name: "FsNotify",
      description: description(),
      package: package(),
      source_url: @source_url,
      docs: docs(),
      dialyzer: [
        plt_local_path: "priv/plts/fs_notify.plt",
        plt_core_path: "priv/plts/core.plt",
        plt_add_apps: [:ex_unit, :mix],
        ignore_warnings: ".dialyzer_ignore.exs"
      ],
      aliases: aliases()
    ]
  end

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

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

  defp deps do
    [
      {:rustler_precompiled, "~> 0.9.0"},
      # Only needed to build the NIF from source (force_build / no precompiled
      # artifact for the target). Optional so consumers using precompiled NIFs
      # don't need a Rust toolchain.
      {:rustler, "~> 0.38.0", optional: true},
      {:typed_structor, "~> 0.6.1"},
      {:ex_doc, "~> 0.40.3", only: :dev, runtime: false},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
    ]
  end

  defp description do
    "Cross-platform filesystem watcher for Elixir, backed by notify-rs via Rustler."
  end

  defp package do
    [
      licenses: ["MIT"],
      links: %{"GitHub" => @source_url},
      files: ~w(lib native/fs_notify/src native/fs_notify/Cargo.toml
                native/fs_notify/Cargo.lock checksum-*.exs
                .formatter.exs mix.exs README.md CHANGELOG.md LICENSE)
    ]
  end

  defp docs do
    [
      main: "readme",
      source_ref: "v#{@version}",
      extras: ["README.md", "CHANGELOG.md", "LICENSE"]
    ]
  end

  defp aliases do
    [
      precommit: [
        "compile --warnings-as-errors",
        "deps.unlock --check-unused",
        "format",
        "credo --strict",
        "cmd cargo fmt --manifest-path native/fs_notify/Cargo.toml --check",
        "cmd cargo clippy --manifest-path native/fs_notify/Cargo.toml --all-targets -- -D warnings",
        "dialyzer",
        "test"
      ]
    ]
  end
end