Packages

Elixir bindings to Harper — a fast, offline, privacy-first English grammar and spell checker (Automattic's Harper, in Rust). Spelling, grammar and style lints with suggestions, dialects and a custom dictionary.

Current section

Files

Jump to
harper mix.exs
Raw

mix.exs

defmodule Harper.MixProject do
use Mix.Project
@version "0.1.1"
@source_url "https://git.sr.ht/~sbr/harper"
def project do
[
app: :harper,
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(),
dialyzer: dialyzer(),
source_url: @source_url,
homepage_url: @source_url
]
|> Keyword.merge(umbrella_paths())
end
def application do
[extra_applications: [:logger]]
end
def cli do
[preferred_envs: [precommit: :test]]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
defp deps do
[
{:rustler_precompiled, "~> 0.8"},
# 0.1.0 ships source-only until the precompiled tarballs are uploaded and
# the checksum file committed. `force_build` in Harper.Native (via the
# RUSTLER_PRECOMPILATION_FORCE_BUILD env var) hands compilation to rustler,
# so rustler must actually be present — hence not `optional: true` yet.
{:rustler, "~> 0.38"},
{:ex_doc, "~> 0.34", only: :dev, runtime: false},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
]
end
defp aliases do
[
precommit: [
"format --check-formatted",
"credo",
"deps.audit",
"dialyzer",
"test"
]
]
end
defp dialyzer do
[
plt_add_apps: [:ex_unit, :mix],
flags: [:error_handling, :unknown, :underspecs],
ignore_warnings: ".dialyzer_ignore.exs"
]
end
defp description do
"Elixir bindings to Harper — a fast, offline, privacy-first English " <>
"grammar and spell checker (Automattic's Harper, in Rust). Spelling, " <>
"grammar and style lints with suggestions, dialects and a custom dictionary."
end
defp package do
[
maintainers: ["sbr"],
licenses: ["Apache-2.0"],
links: %{
"Source" => @source_url,
"Changelog" => @source_url <> "/tree/main/item/CHANGELOG.md",
"Harper (upstream Rust)" => "https://github.com/Automattic/harper"
},
# checksum-Elixir.Harper.Native.exs is (re)generated by scripts/deploy.sh
# after each release's artifacts are uploaded to the sr.ht release ref.
files: ~w(
lib
native/harper_nif/Cargo.toml
native/harper_nif/Cargo.lock
native/harper_nif/src
checksum-Elixir.Harper.Native.exs
mix.exs
README.md
CHANGELOG.md
LICENSE
LICENSE-APACHE
)
]
end
defp docs do
[
main: "readme",
extras: ["README.md", "CHANGELOG.md", "LICENSE"],
source_ref: "v#{@version}"
]
end
# When this lib lives inside the 8by3 umbrella (path dep during dev), share
# the parent build/deps dirs. After extraction into its own repo the parent
# dirs don't exist and it builds standalone. Same mix.exs works in both.
defp umbrella_paths do
if File.exists?(Path.expand("../../mix.exs", __DIR__)) do
[
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock"
]
else
[]
end
end
end