mix.exs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. defmodule Toy.MixProject do
  2. use Mix.Project
  3. def project do
  4. [
  5. app: :toy,
  6. version: from_file(),
  7. elixir: "~> 1.7",
  8. elixirc_paths: elixirc_paths(Mix.env()),
  9. compilers: [:phoenix, :gettext] ++ Mix.compilers(),
  10. start_permanent: Mix.env() == :prod,
  11. aliases: aliases(),
  12. deps: deps()
  13. ]
  14. end
  15. # Configuration for the OTP application.
  16. #
  17. # Type `mix help compile.app` for more information.
  18. def application do
  19. [
  20. mod: {Toy.Application, []},
  21. extra_applications: [:logger, :runtime_tools]
  22. ]
  23. end
  24. # Specifies which paths to compile per environment.
  25. defp elixirc_paths(:test), do: ["lib", "config", "test/support"]
  26. defp elixirc_paths(_), do: ["lib", "config"]
  27. # Specifies your project dependencies.
  28. #
  29. # Type `mix help deps` for examples and options.
  30. defp deps do
  31. [
  32. {:phoenix, "~> 1.5.9"},
  33. {:phoenix_ecto, "~> 4.1"},
  34. {:ecto_sql, "~> 3.4"},
  35. {:postgrex, ">= 0.0.0"},
  36. {:phoenix_live_view, "~> 0.15.1"},
  37. {:floki, ">= 0.30.0", only: :test},
  38. {:phoenix_html, "~> 2.11"},
  39. {:phoenix_live_reload, "~> 1.2", only: :dev},
  40. {:phoenix_live_dashboard, "~> 0.4"},
  41. {:telemetry_metrics, "~> 0.4"},
  42. {:telemetry_poller, "~> 0.4"},
  43. {:gettext, "~> 0.11"},
  44. {:jason, "~> 1.0"},
  45. {:plug_cowboy, "~> 2.0"}
  46. ]
  47. end
  48. # Aliases are shortcuts or tasks specific to the current project.
  49. # For example, to install project dependencies and perform other setup tasks, run:
  50. #
  51. # $ mix setup
  52. #
  53. # See the documentation for `Mix` for more info on aliases.
  54. defp aliases do
  55. [
  56. setup: ["deps.get", "ecto.setup", "cmd npm install --prefix assets"],
  57. "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
  58. "ecto.reset": ["ecto.drop", "ecto.setup"],
  59. test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
  60. version: ["run -e \"Mix.Project.config[:version] |> IO.puts\""]
  61. ]
  62. end
  63. defp from_file(file \\ "VERSION") do
  64. with {:ok, described} <- File.read(file),
  65. {:ok, version} <- described |> String.trim() |> to_semver_string() do
  66. version
  67. end
  68. end
  69. defp to_semver_string(described) when is_binary(described) do
  70. with {:ok, _} <- described |> Version.parse(), do: {:ok, described}
  71. end
  72. end