From 3f2c43e6d3e560d9a66e77af8d4fb23dc8f09a30 Mon Sep 17 00:00:00 2001 From: Matt Beanland Date: Fri, 8 May 2026 21:15:39 +0930 Subject: [PATCH] igniter --- README.md | 15 +++++-- lib/mix/tasks/diffo.install.ex | 79 ++++++++++++++++++++++++++++++++++ mix.exs | 2 +- 3 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 lib/mix/tasks/diffo.install.ex diff --git a/README.md b/README.md index 0b19036..95dd7da 100644 --- a/README.md +++ b/README.md @@ -34,18 +34,25 @@ Diffo is especially suited for use in organisations with loosely coupled 'entity ## Installation -If [available in Hex](https://hex.pm/docs/publish), the package can be installed -by adding `diffo` to your list of dependencies in `mix.exs`: +The recommended way to install Diffo is with [Igniter](https://hexdocs.pm/igniter): + +```bash +mix igniter.install diffo +``` + +This will add the dependency, configure Neo4j (via `ash_neo4j`), register the custom expression, and set up the Spark formatter. + +Alternatively, add `diffo` to your list of dependencies in `mix.exs` manually: ```elixir def deps do [ - {:diffo, "~> 0.1.6"} + {:diffo, "~> 0.2.1"} ] end ``` -You should need [Neo4j](https://github.com/neo4j/neo4j) available. We recommend the Neo4j Community 5 latest, available at [Neo4j Deploymnent Centre](https://neo4j.com/deployment-center/) which can be installed locally. You can also configure connection to a cloud based database service such as [Neo4j AuraDB](https://neo4j.com/product/auradb/). +You will need [Neo4j](https://github.com/neo4j/neo4j) available. We recommend the Neo4j Community 5 latest, available at [Neo4j Deploymnent Centre](https://neo4j.com/deployment-center/) which can be installed locally. You can also configure connection to a cloud based database service such as [Neo4j AuraDB](https://neo4j.com/product/auradb/). ## Tutorial diff --git a/lib/mix/tasks/diffo.install.ex b/lib/mix/tasks/diffo.install.ex new file mode 100644 index 0000000..11d45a0 --- /dev/null +++ b/lib/mix/tasks/diffo.install.ex @@ -0,0 +1,79 @@ +# SPDX-FileCopyrightText: 2025 diffo contributors +# +# SPDX-License-Identifier: MIT + +defmodule Mix.Tasks.Diffo.Install.Docs do + @moduledoc false + + def short_doc, do: "Installs Diffo" + def example, do: "mix igniter.install diffo" + + def long_doc do + """ + #{short_doc()} + + ## Example + + ```bash + #{example()} + ``` + """ + end +end + +if Code.ensure_loaded?(Igniter) do + defmodule Mix.Tasks.Diffo.Install do + @shortdoc "#{__MODULE__.Docs.short_doc()}" + @moduledoc __MODULE__.Docs.long_doc() + + use Igniter.Mix.Task + + @impl Igniter.Mix.Task + def info(_argv, _composing_task) do + %Igniter.Mix.Task.Info{ + group: :ash, + installs: [{:ash_neo4j, "~> 0.5"}], + example: __MODULE__.Docs.example() + } + end + + @impl Igniter.Mix.Task + def igniter(igniter) do + igniter + |> Igniter.Project.Formatter.import_dep(:diffo) + |> Spark.Igniter.prepend_to_section_order( + :"Ash.Resource", + [:specification, :features, :characteristics] + ) + |> Igniter.Project.Config.configure( + "config.exs", + :ash, + [:custom_expressions], + [Diffo.Unwrap.AshCustomExpression], + updater: fn zipper -> + Igniter.Code.List.prepend_new_to_list( + zipper, + quote(do: Diffo.Unwrap.AshCustomExpression) + ) + end + ) + end + end +else + defmodule Mix.Tasks.Diffo.Install do + @shortdoc "#{__MODULE__.Docs.short_doc()} | Install `igniter` to use" + @moduledoc __MODULE__.Docs.long_doc() + + use Mix.Task + + def run(_argv) do + Mix.shell().error(""" + The task 'diffo.install' requires igniter. Please install igniter and try again. + + For more information, see: https://hexdocs.pm/igniter/readme.html#installation + """) + + exit({:shutdown, 1}) + end + end +end diff --git a/mix.exs b/mix.exs index c719f05..54c61f3 100644 --- a/mix.exs +++ b/mix.exs @@ -99,7 +99,7 @@ defmodule Diffo.MixProject do {:ash_outstanding, "~> 0.2.3"}, {:ash_jason, "~> 3.0"}, {:ash_state_machine, "~> 0.2.12"}, - {:ash_neo4j, ash_neo4j_version("~> 0.4.1")}, + {:ash_neo4j, ash_neo4j_version("~> 0.5")}, {:bolty, ">= 0.0.12"}, {:ash, ash_version("~> 3.0 and >= 3.24.2")}, {:uuid, "~> 1.1"},