Current section

Files

Jump to
Raw

mix.exs

defmodule StatifierUI.MixProject do
  use Mix.Project

  @version "0.11.0"
  @source_url "https://github.com/riddler/statifier-ui"

  def project do
    [
      app: :statifier_ui,
      version: @version,
      elixir: "~> 1.18",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      name: "StatifierUI",
      description: "UI components for authoring, observing, and debugging statifier statecharts",
      source_url: @source_url,
      docs: docs(),
      package: package(),
      test_coverage: [tool: ExCoveralls],
      preferred_cli_env: [
        coveralls: :test,
        "coveralls.detail": :test,
        "coveralls.html": :test
      ]
    ]
  end

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

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_env), do: ["lib"]

  # Hexdocs configuration. These paths are read off the publisher's disk at
  # `mix docs` time - the docs tarball hexdocs hosts is built separately from
  # the package tarball `mix deps.get` fetches. A guide the README links to
  # relatively is also in package()'s files: list, for hex.pm's README page.
  defp docs do
    [
      name: "StatifierUI",
      source_ref: "v#{@version}",
      canonical: "https://hexdocs.pm/statifier_ui",
      source_url: @source_url,
      main: "readme",
      extras: [
        "README.md",
        "CHANGELOG.md",
        "docs/architecture.md",
        "docs/ops-embedding.md",
        "docs/guides/observe-an-execution.md",
        "docs/fixture-bundles.md",
        "docs/wire-format.md",
        "docs/telemetry.md",
        "docs/explanation/why-a-wire-format.md"
      ],
      # Grouped by the kind of page the reader needs, in the family order
      # (Tutorials, How-to guides, Reference, Explanation, Upgrading); a
      # group appears only when it has a page. The README and the CHANGELOG
      # stay ungrouped at the top. Decision records and planning notes are a
      # record for contributors, not extras.
      groups_for_extras: [
        "How-to guides": [
          "docs/ops-embedding.md",
          "docs/guides/observe-an-execution.md"
        ],
        Reference: ["docs/wire-format.md"],
        Explanation: [
          "docs/architecture.md",
          "docs/fixture-bundles.md",
          "docs/telemetry.md",
          "docs/explanation/why-a-wire-format.md"
        ]
      ],
      skip_undefined_reference_warnings_on: ["CHANGELOG.md"]
    ]
  end

  defp package do
    [
      name: "statifier_ui",
      licenses: ["MIT"],
      # `assets` is here because ADR-0009 makes it public API: the JavaScript
      # ships as source and the host's bundler compiles it, so a tarball without
      # it is a package whose documented hook cannot be imported.
      # The docs/ guides are here because hex.pm renders the README from this
      # tarball, so a README relative link answers 404 there unless its target
      # ships; each is also an extra, so the same link works on HexDocs.
      # `test/packaging_test.exs` holds this list against the ADRs and the
      # README's relative links.
      files: ~w(
        lib
        assets
        mix.exs
        README.md
        LICENSE
        CHANGELOG.md
        docs/architecture.md
        docs/ops-embedding.md
        docs/guides/observe-an-execution.md
        docs/fixture-bundles.md
        docs/wire-format.md
        docs/telemetry.md
        docs/explanation/why-a-wire-format.md
      ),
      links: %{
        "GitHub" => @source_url,
        "Changelog" => "#{@source_url}/blob/main/CHANGELOG.md"
      }
    ]
  end

  defp deps do
    [
      statifier_dep(),

      # Declared directly, not left to arrive through statifier, because lib/
      # calls Predicator.* itself: the expectations runner and
      # `StatifierUI.Expression`'s completion source. 9.4 is the floor because
      # `Predicator.Simple.value_kind/1` landed there and
      # `StatifierUI.Expression` asks it what kind a clause value is rather
      # than keeping a table of its own; the `Predicator.Simple` the same
      # module reads for `operators/1` arrived in 9.2 and
      # `Predicator.Vocabulary` (px-15q), which the completion source reads,
      # in 9.1.
      {:predicator, "~> 9.4"},

      # The datamodel document is read here rather than re-parsed: sd owns the
      # document's shape and its path projection
      # (`StatifierDatamodel.Index.path_types/1`), and a second reading of the
      # same document in this package would be the drifting copy the
      # completion source already refuses for the grammar. Pure, no runtime
      # processes, and no dependency of its own (the Hex floor, not
      # a git pin).
      {:statifier_datamodel, "~> 0.4"},

      # Both integrations are optional: the package is a component library, and
      # a Livebook host has no reason to pull LiveView, or the reverse. Anything
      # under lib/ that touches one of these has to tolerate its absence at
      # compile time.
      {:kino, "~> 0.14", optional: true},
      {:phoenix_live_view, "~> 1.0", optional: true},

      # Dev / test
      {:ex_quality, "~> 0.16", only: :dev, runtime: false},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
      {:excoveralls, "~> 0.18", only: :test},
      {:ex_doc, "~> 0.40", only: :dev, runtime: false},
      {:doctor, "~> 0.23", only: :dev, runtime: false}
    ]
  end

  # Export STATIFIER_PATH to point at a local checkout while co-developing a
  # change that spans both repos. It is an env var rather than a mix.exs edit
  # so the override never lands in a commit by accident.
  defp statifier_dep do
    case System.get_env("STATIFIER_PATH") do
      nil -> {:statifier, "~> 2.5"}
      path -> {:statifier, path: path, override: true}
    end
  end
end