Current section

Files

Jump to
xqlite mix.exs
Raw

mix.exs

defmodule Xqlite.MixProject do
  use Mix.Project

  @name "Xqlite"

  def project do
    [
      app: :xqlite,
      version: "0.12.2",
      elixir: "~> 1.17",
      name: @name,
      start_permanent: Mix.env() == :prod,
      docs: docs(),
      deps: deps(),
      compilers: Mix.compilers(),
      elixirc_paths: elixirc_paths(Mix.env()),
      elixirc_options: [warnings_as_errors: true],
      aliases: [test: "test --warnings-as-errors"],

      # hex
      description: description(),
      package: package(),

      # testing
      test_coverage: [tool: ExCoveralls],

      # type checking
      dialyzer: dialyzer(Mix.env())
    ]
  end

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

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

  def cli do
    [
      preferred_envs: [
        coveralls: :test,
        "coveralls.detail": :test,
        "coveralls.post": :test,
        "coveralls.html": :test,
        "coveralls.circle": :test,
        "coveralls.github": :test,
        "test.seq": :test
      ]
    ]
  end

  defp deps do
    [
      {:rustler, "~> 0.38.0", optional: true},
      {:rustler_precompiled, "~> 0.8"},
      {:nimble_options, "~> 1.1"},
      {:table, "~> 0.1.0"},
      {:telemetry, "~> 1.0"},
      {:decimal, "~> 2.0 or ~> 3.0", optional: true},

      # dev / test.
      {:benchee, "~> 1.0", only: :dev, runtime: false},
      {:dialyxir, "~> 1.4", only: :dev, runtime: false},
      {:ex_doc, "~> 0.20", only: :dev, runtime: false},
      {:excoveralls, "~> 0.11", only: :test},
      {:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false},
      {:quokka, "~> 2.13", only: [:dev, :test], runtime: false},
      {:sobelow, "~> 0.14", only: [:dev, :test], runtime: false},
      {:stream_data, "~> 1.1", only: [:dev, :test]},
      {:jason, "~> 1.4"}
    ]
  end

  defp docs do
    [
      main: "readme",
      name: "Xqlite",
      source_url: "https://github.com/dimitarvp/xqlite",
      source_ref: "v0.12.2",
      skip_undefined_reference_warnings_on: &(&1 == "CHANGELOG.md"),
      extras: [
        "README.md",
        "CHANGELOG.md",
        "LICENSE.md",
        "guides/security.md",
        "guides/gotchas.md",
        "guides/wiring_telemetry.md",
        "guides/full_text_search.md",
        "guides/spatialite.md"
      ],
      groups_for_modules: [
        "High-Level API": [
          Xqlite,
          Xqlite.Blob,
          Xqlite.Pragma,
          Xqlite.Result,
          Xqlite.ExplainAnalyze
        ],
        "Type Extensions": [
          Xqlite.TypeExtension,
          Xqlite.TypeExtension.Date,
          Xqlite.TypeExtension.DateTime,
          Xqlite.TypeExtension.Decimal,
          Xqlite.TypeExtension.Duration,
          Xqlite.TypeExtension.Instant,
          Xqlite.TypeExtension.JSON,
          Xqlite.TypeExtension.NaiveDateTime,
          Xqlite.TypeExtension.Time,
          Xqlite.TypeExtension.UUID
        ],
        Telemetry: [
          Xqlite.Telemetry,
          Xqlite.Telemetry.Bridge,
          Xqlite.Telemetry.OpenTelemetry
        ],
        "Schema Structs": [
          Xqlite.Schema.ColumnInfo,
          Xqlite.Schema.DatabaseInfo,
          Xqlite.Schema.ForeignKeyInfo,
          Xqlite.Schema.IndexColumnInfo,
          Xqlite.Schema.IndexInfo,
          Xqlite.Schema.SchemaObjectInfo,
          Xqlite.Schema.Types
        ],
        "Low-Level NIFs": [
          XqliteNIF
        ],
        "Internal Helpers": [
          Xqlite.PragmaSpec
        ]
      ]
    ]
  end

  defp description, do: "An Elixir SQLite database library utilising the rusqlite Rust crate"

  defp package do
    [
      licenses: ["MIT"],
      links: %{
        "Github" => "https://github.com/dimitarvp/xqlite",
        "Hexdocs" => "https://hexdocs.pm/xqlite"
      },
      files: [
        "lib",
        "native/xqlitenif/.cargo",
        "native/xqlitenif/src",
        "native/xqlitenif/Cargo.toml",
        "native/xqlitenif/Cargo.lock",
        "checksum-*.exs",
        ".formatter.exs",
        "mix.exs",
        "README.md",
        "CHANGELOG.md",
        "LICENSE.md"
      ],
      exclude_patterns: [~r"^lib/mix/tasks/"]
    ]
  end

  defp dialyzer(_env) do
    [
      # Specifies the directory where core PLTs (OTP, Elixir stdlib) are stored.
      plt_core_path: "priv/plts/",
      # Specifies the path to the final project PLT file, which includes dependencies.
      # Using {:no_warn, ...} suppresses warnings if the file doesn't exist initially.
      plt_file: {:no_warn, "priv/plts/core.plt"},
      plt_add_apps: [:mix]
      # flags: ["-Wunmatched_returns", ...],
    ]
  end
end