Current section
Files
Jump to
Current section
Files
mix.exs
defmodule Unity.MixProject do
use Mix.Project
@version "1.2.0"
@source_url "https://github.com/elixir-localize/unity"
def project do
[
app: :unity,
version: @version,
elixir: "~> 1.17",
name: "Unity",
source_url: @source_url,
docs: docs(),
description: description(),
package: package(),
start_permanent: Mix.env() == :prod,
escript: escript(),
deps: deps(),
aliases: aliases(),
dialyzer: [
flags: [
:error_handling,
:unknown,
:underspecs,
:extra_return,
:missing_return
]
]
]
end
defp aliases do
[
test: ["localize.download_locales en de ja", "test"]
]
end
def application do
[
extra_applications: [:logger]
]
end
# Localize reads its data from its `priv` directory, which an escript
# holds only for the applications named here; Localize extracts it into
# the user cache directory at startup.
defp escript do
[main_module: Unity.CLI, include_priv_for: [:localize]]
end
defp description do
"""
An Elixir unit conversion calculator inspired by the Unix `units` utility.
Parses and evaluates unit expressions with locale-aware output powered by Localize.
"""
end
defp package do
[
licenses: ["Apache-2.0"],
links: links(),
# `config` is included for the escript: `mix escript.install hex unity`
# builds the escript inside this package and embeds its configuration.
files: ~w(lib priv config .formatter.exs mix.exs README.md CHANGELOG.md LICENSE.md)
]
end
def links do
%{
"GitHub" => "https://github.com/elixir-localize/unity",
"Readme" => "https://github.com/elixir-localize/unity/blob/v#{@version}/README.md",
"Changelog" => "https://github.com/elixir-localize/unity/blob/v#{@version}/CHANGELOG.md"
}
end
defp docs do
[
main: "readme",
formatters: ["html", "markdown"],
extras: [
"README.md",
"CHANGELOG.md",
"guides/exploring_unity.md",
"guides/conformance.md",
"guides/importing_gnu_units_definitions.md"
],
groups_for_extras: [Guides: ~r/guides\/.*/],
groups_for_modules: [
Evaluation: [
Unity.Parser,
Unity.Interpreter,
Unity.Formatter,
Unity.Aliases,
Unity.Aliases.Plural,
Unity.Error
],
"Command line and REPL": [Unity.CLI, Unity.Repl],
"GNU units import": [
Unity.GnuUnitsImporter,
Unity.GnuUnitsImporter.Parser,
Unity.GnuUnitsImporter.Registrar,
Unity.GnuUnitsImporter.Resolver
],
"Nonlinear conversions": [~r/Unity\.Conversion\..*/]
],
source_ref: "v#{@version}"
]
end
defp deps do
[
{:localize, "~> 1.4"},
# Marcli renders the REPL's markdown through MDEx, a Rust NIF, and the
# REPL renders plain text without it. `optional` keeps it from the
# projects that depend on unity; `only` keeps it, MDEx and their own
# dependencies out of unity's `:prod` builds, which include the
# escript `mix escript.install hex unity` builds. A NIF cannot load
# inside an escript in any case.
{:marcli, "~> 0.3", optional: true, only: [:dev, :test]},
{:nimble_parsec, "~> 1.0"},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.34", only: :release, runtime: false}
] ++ 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
end