defmodule Orcasite.Mixfile do
  use Mix.Project

  def project do
    [
      app: :orcasite,
      version: "0.0.1",
      elixir: "~> 1.17",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix_live_view] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps(),
      preferred_cli_env: [
        "test.watch": :test
      ]
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Orcasite.Application, []},
      extra_applications: [
        :logger,
        :runtime_tools,
        :inets,
        :phoenix_pubsub_redis,
        :os_mon
      ]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.8"},
      {:phoenix_pubsub, "~> 2.0"},
      {:phoenix_ecto, "~> 4.4"},
      {:ecto_sql, "~> 3.6"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 4.0"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_view, "~> 1.1"},
      {:lazy_html, ">= 0.0.0", only: :test},
      {:phoenix_live_dashboard, "~> 0.8.0"},
      {:esbuild, "~> 0.7", runtime: Mix.env() == :dev},
      {:tailwind, "~> 0.3.0", runtime: Mix.env() == :dev},
      {:swoosh, "~> 1.16"},
      {:finch, "~> 0.13"},
      {:floki, ">= 0.30.0", only: :test},
      {:gettext, "~> 0.20"},
      {:plug_cowboy, "~> 2.7"},
      {:plug, "~> 1.7"},
      {:absinthe, "~> 1.7"},
      {:absinthe_plug, "~> 1.5"},
      {:absinthe_phoenix, "~> 2.0"},
      # Provides helper functions for easy batching of Ecto associations
      {:dataloader, "~> 2.0"},
      # Algorithm used by Comeonin to hash password
      {:bcrypt_elixir, "~> 3.0"},
      # JSON parser, works with Absinthe out of the box
      {:poison, "~> 6.0"},
      {:logfmt, "~> 3.0"},
      {:geo_postgis, "~> 3.0"},
      {:jason, "~> 1.2"},
      # Reverse proxy for proxying to nextjs app
      {:reverse_proxy_plug, "~> 3.0"},
      {:httpoison, "~> 2.2"},
      {:corsica, "~> 2.1"},
      {:telemetry_metrics, "~> 1.0"},
      {:telemetry_poller, "~> 1.0"},
      {:ash, "~> 3.5.6"},
      {:ash_admin, "~> 0.13.4"},
      {:ash_postgres, "~> 2.2"},
      {:picosat_elixir, "~> 0.2.3"},
      {:heroicons, "~> 0.5"},
      {:oban, "~> 2.14"},
      {:gen_smtp, "~> 1.0"},
      {:ash_authentication, "~> 4.2"},
      {:ash_authentication_phoenix, "~> 2.10.5"},
      {:syn, "~> 3.3"},
      {:mjml, "~> 5.0"},
      {:zappa, github: "skanderm/zappa", branch: "master"},
      {:ash_uuid, "~> 1.1.2"},
      {:ash_graphql, "~> 1.8"},
      {:ash_json_api, "~> 1.2"},
      {:open_api_spex, "~> 3.16"},
      {:redoc_ui_plug, "~> 0.2.1"},
      {:phoenix_pubsub_redis, "~> 3.0.1"},
      {:nebulex, "~> 2.5"},
      {:nebulex_redis_adapter, "~> 2.3"},
      {:hammer_backend_redis, "~> 6.1"},
      {:hammer, "~> 6.0"},
      {:mix_test_watch, "~> 1.0", only: [:dev, :test], runtime: false},
      {:ex_unit_notifier, "~> 1.2", only: :test},
      {:remote_ip, "~> 1.1"},
      {:ex_aws, "~> 2.5.11"},
      {:ex_aws_s3, "~> 2.0"},
      {:ex_aws_lambda, "~> 2.1"},
      {:hackney, "~> 1.9"},
      {:sweet_xml, "~> 0.6"},
      {:configparser_ex, "~> 5.0", only: :dev},
      {:broadway_sqs, "~> 0.7"},
      {:recon, "~> 2.5"},
      {:ecto_psql_extras, "~> 0.6"},
      {:ash_slug, "~> 0.2.1"},
      {:sourceror, "~> 1.7", only: [:dev, :test]},
      {:recase, "~> 0.5"},
      {:igniter, "~> 0.6", only: [:dev, :test]},
      {:ash_oban, "~> 0.4.9"},
      {:faker, "~> 0.19.0-alpha.1", only: :test}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      setup: ["deps.get", "assets.setup", "assets.build", "ecto.setup"],
      "ecto.setup": ["ecto.create", "ecto.migrate --quiet", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate", "test"],
      "assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
      "assets.build": ["tailwind default", "esbuild default"],
      "assets.deploy": ["tailwind default --minify", "esbuild default --minify", "phx.digest"]
    ]
  end
end
