defmodule Hyphen.MixProject do use Mix.Project @source_url "https://github.com/lud/hyphen" @version "0.2.1" def project do [ app: :hyphen, description: "A server-side backend library for building reactive JavaScript frontends over Phoenix Channels.", version: @version, elixir: "~> 1.18", start_permanent: true, elixirc_paths: elixirc_paths(Mix.env()), consolidate_protocols: Mix.env() == :prod, source_url: @source_url, deps: deps(), dialyzer: dialyzer(), aliases: aliases(), modkit: modkit(), package: package(), versioning: versioning() ] end defp elixirc_paths(:test) do ["lib", "test/support"] end defp elixirc_paths(_) do ["lib"] end def application do [ extra_applications: [:logger], mod: {Hyphen.Application, []} ] end defp deps do [ {:jsv, ">= 0.0.0"}, {:oaskit, ">= 0.0.0"}, {:phoenix, "~> 1.0"}, # Dev {:mox, "~> 1.2", only: :test}, {:bandit, "~> 1.0", only: [:dev, :test]}, {:credo, ">= 1.7.12", only: [:dev, :test], runtime: false}, {:dialyxir, ">= 1.4.5", only: [:dev, :test], runtime: false}, {:ex_check, ">= 0.16.0", only: [:dev, :test], runtime: false}, {:ex_doc, ">= 0.38.2", only: [:dev, :test], runtime: false}, {:mix_audit, ">= 2.1.5", only: [:dev, :test], runtime: false}, {:sobelow, ">= 0.14.0", only: [:dev, :test], runtime: false}, {:readmix, "~> 0.7", only: [:dev, :test], runtime: false}, {:quokka, "~> 2.11", only: [:dev, :test], runtime: false}, {:nvir, "~> 0.7", only: [:dev, :test]} ] end defp aliases do [] end defp modkit do [ mount: [ {Hyphen, "lib/hyphen"}, {Mix.Tasks, "lib/mix/tasks", flavor: :mix_task} ] ] end defp package do [ licenses: ["MIT"], links: %{ "Changelog" => "https://github.com/lud/hyphen/blob/main/CHANGELOG.md", "Github" => @source_url } ] end def cli do [ preferred_envs: [ dialyzer: :test ] ] end defp dialyzer do [ flags: [:unmatched_returns, :error_handling, :unknown, :extra_return], list_unused_filters: true, plt_add_deps: :app_tree, plt_add_apps: [:ex_unit, :plug, :phoenix], plt_local_path: "_build/plts" ] end defp versioning do [ annotate: true, before_commit: [ &readmix/1, {:add, "README.md"}, {:add, "guides"}, &gen_changelog/1, {:add, "CHANGELOG.md"} ] ] end def readmix(vsn) do rdmx = Readmix.new(vars: %{app_vsn: vsn}) :ok = Readmix.update_file(rdmx, "README.md") :ok = Enum.each(Path.wildcard("guides/**/*.md"), fn path -> :ok = Readmix.update_file(rdmx, path) end) end defp gen_changelog(vsn) do case System.cmd("git", ["cliff", "--tag", vsn, "-o", "CHANGELOG.md"], stderr_to_stdout: true) do {_, 0} -> IO.puts("Updated CHANGELOG.md with #{vsn}") {out, _} -> {:error, "Could not update CHANGELOG.md:\n\n #{out}"} end end end