Packages

A client-side store for Phoenix LiveView hooks with a server binding.

Current section

Files

Jump to
live_slice mix.exs
Raw

mix.exs

defmodule LiveSlice.MixProject do
  use Mix.Project

  @version "0.2.1"
  @source_url "https://github.com/CountlinkX-Solutions/live_slice"

  def project do
    [
      app: :live_slice,
      version: @version,
      elixir: "~> 1.16",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      description: "A client-side store for Phoenix LiveView hooks with a server binding.",
      package: package(),
      source_url: @source_url,
      homepage_url: @source_url,
      docs: docs()
    ]
  end

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

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

  defp deps do
    [
      {:phoenix_live_view, "~> 1.2"},
      {:jason, "~> 1.4"},
      # Collaborative keys (LiveSlice.CRDT); apps that use them add y_ex themselves.
      {:y_ex, "~> 0.13", optional: true},
      {:lazy_html, ">= 0.1.0", only: :test},
      {:ex_doc, "~> 0.40", only: :dev, runtime: false}
    ]
  end

  # The JavaScript ships with the Elixir package: package.json exports the entries under
  # assets/js/live_slice, which the esbuild of a Phoenix app resolves from deps/live_slice.
  defp package do
    [
      licenses: ["MIT"],
      links: %{
        "GitHub" => @source_url,
        "Changelog" => "#{@source_url}/blob/main/CHANGELOG.md"
      },
      files:
        ~w(lib assets/js/live_slice package.json mix.exs README.md CHANGELOG.md LICENSE guides)
    ]
  end

  @usage_guides ~w(
    guides/getting-started.md
    guides/patch-and-invalidate.md
    guides/server-actions.md
    guides/persistence.md
    guides/tabs-and-connection.md
  )

  @topic_guides ~w(
    guides/conflicts.md
    guides/collaborative-keys.md
    guides/offline-cold-start.md
    guides/large-data.md
    guides/maplibre.md
    guides/testing.md
  )

  @project_pages ~w(
    guides/demo.md
    guides/upgrading.md
    guides/known-limits.md
    CHANGELOG.md
  )

  defp docs do
    [
      main: "readme",
      source_ref: "v#{@version}",
      extras:
        [{"README.md", title: "Overview"}] ++
          @usage_guides ++ @topic_guides ++ @project_pages ++ [{"LICENSE", title: "License"}],
      groups_for_extras: [
        Usage: @usage_guides,
        Topics: @topic_guides,
        Project: @project_pages ++ ["LICENSE"]
      ],
      # Named in the changelog and the upgrade notes, but documented with its module only.
      skip_code_autolink_to: ["LiveSlice.CRDT.MemoryPersistence.save/4"]
    ]
  end
end