Skip to main content

mix.exs

defmodule Marea.MixProject do
  use Mix.Project

  def project do
    [
      app: :marea,
      version: "0.0.1-rc.1",
      elixir: "~> 1.11",
      description: "Elixir CLI for building, packaging and deploying Elixir apps to Kubernetes.",
      package: %{
        licenses: ["Apache-2.0"],
        links: %{"GitHub" => "https://github.com/kalta/marea"},
        files: ~w(lib priv/templates .formatter.exs mix.exs README.md LICENSE.md)
      },
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      escript: [main_module: Marea, name: :marea],
      docs: docs(),
      dialyzer: [
        plt_add_apps: [:mix]
      ]
    ]
  end

  def application do
    [
      extra_applications: [:logger, :eex]
    ]
  end

  defp deps do
    [
      # {:httpoison, "~> 2.0"},
      {:jason, "~> 1.4"},
      {:yaml_elixir, "~> 2.9"},
      {:ymlr, "~> 5.1"},
      # https://github.com/funbox/optimus
      {:optimus, "~> 0.6.1"},

      # Cowrie.demo()
      # {:cowrie, "~> 0.5.0"},

      # muy sofisticado tablas,
      # https://github.com/fuelen/owl
      # https://hexdocs.pm/owl
      # {:owl, "~> 0.13.0"},

      # https://github.com/behind-design/ex_prompt
      # {:ex_prompt, "~> 0.2.0"},

      # https://github.com/djm/table_rex
      {:table_rex, "~> 4.1"},
      {:zoi, "~> 0.17"},
      {:igniter, "~> 0.7"},
      malla_dep(),
      {:ex_doc, "~> 0.40", only: :dev, runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev], runtime: false}
    ]
  end

  # Use the local checkout when co-developing Malla (set MALLA_PATH=../malla);
  # otherwise pull the published pre-release from hex so the package is publishable.
  defp malla_dep do
    case System.get_env("MALLA_PATH") do
      nil -> {:malla, "~> 0.0.1-rc.2"}
      path -> {:malla, path: path}
    end
  end

  defp docs do
    [
      main: "introduction",
      name: "Marea",
      source_ref: "main",
      source_url: "https://github.com/kalta/marea",
      homepage_url: "https://github.com/kalta/marea",
      extras: extras(),
      groups_for_extras: groups_for_extras(),
      groups_for_modules: groups_for_modules(),
      before_closing_body_tag: &before_closing_body_tag/1
    ]
  end

  defp before_closing_body_tag(:html) do
    """
    <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
    <script>
      document.addEventListener("DOMContentLoaded", function () {
        mermaid.initialize({ startOnLoad: false });
        let id = 0;
        for (const codeEl of document.querySelectorAll("pre code.mermaid")) {
          const preEl = codeEl.parentElement;
          const graphDefinition = codeEl.textContent;
          const graphEl = document.createElement("div");
          const graphId = "mermaid-graph-" + id++;
          mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => {
            graphEl.innerHTML = svg;
            bindFunctions?.(graphEl);
            preEl.insertAdjacentElement("afterend", graphEl);
            preEl.remove();
          });
        }
      });
    </script>
    """
  end

  defp before_closing_body_tag(_), do: ""

  defp extras do
    [
      "README.md": [title: "Overview"],
      "guides/01-introduction.md": [title: "Introduction", filename: "introduction"],
      "guides/02-installation.md": [title: "Installation"],
      "guides/03-quick-start.md": [title: "Quick Start"],
      "guides/04-marea-yaml.md": [title: "marea.yaml Reference"],
      "guides/05-architecture.md": [title: "Architecture", filename: "architecture"],
      "guides/06-plugin-development.md": [title: "Plugin Development"],
      "guides/07-operations.md": [title: "Operations"],
      "guides/08-commands.md": [title: "Commands Reference"],
      "guides/plugins/base.md": [title: "Base Plugin"],
      "guides/plugins/setup.md": [title: "Setup Plugin"],
      "guides/plugins/build.md": [title: "Build Plugin"],
      "guides/plugins/run.md": [title: "Run Plugin"],
      "guides/plugins/mcp.md": [title: "MCP Plugin"],
      "guides/plugins/docker.md": [title: "Docker Plugin"],
      "guides/plugins/helm.md": [title: "Helm Plugin"],
      "guides/plugins/docker-python.md": [title: "Docker / Python Plugin"],
      "guides/plugins/k8s.md": [title: "K8s Plugin"],
      "guides/plugins/aws.md": [title: "AWS Plugin"]
    ]
  end

  defp groups_for_extras do
    [
      "Getting Started": [
        "guides/01-introduction.md",
        "guides/02-installation.md",
        "guides/03-quick-start.md"
      ],
      "Core Concepts": [
        "guides/04-marea-yaml.md",
        "guides/05-architecture.md",
        "guides/06-plugin-development.md",
        "guides/07-operations.md",
        "guides/08-commands.md"
      ],
      "Base Plugins": [
        "guides/plugins/base.md",
        "guides/plugins/setup.md",
        "guides/plugins/build.md",
        "guides/plugins/run.md",
        "guides/plugins/mcp.md"
      ],
      "Optional Plugins": [
        "guides/plugins/docker.md",
        "guides/plugins/helm.md",
        "guides/plugins/docker-python.md",
        "guides/plugins/k8s.md",
        "guides/plugins/aws.md"
      ]
    ]
  end

  defp groups_for_modules do
    [
      Core: [
        Marea,
        Marea.Service,
        Marea.Config,
        Marea.Lib
      ],
      Config: [
        Marea.Config.Args,
        Marea.Config.Schema,
        Marea.Config.Yaml
      ],
      Plugins: [
        Marea.Plugins.Base,
        Marea.Plugins.Setup,
        Marea.Plugins.Build,
        Marea.Plugins.Run,
        Marea.Plugins.Mcp,
        Marea.Plugins.Docker,
        Marea.Plugins.Helm,
        Marea.Plugins.Docker.Python,
        Marea.Plugins.K8s,
        Marea.Plugins.Aws
      ],
      MCP: [
        Marea.Mcp.Server,
        Marea.Mcp.Tools,
        Marea.Mcp.Runner,
        Marea.Stop
      ],
      Templates: [
        Marea.Templates
      ],
      "Mix Tasks": [
        Mix.Tasks.Marea,
        Mix.Tasks.Marea.Build
      ]
    ]
  end
end