Skip to content

Commit a3e8edf

Browse files
Merge pull request #116 from diffo-dev/115-igniter
igniter
2 parents 610331c + 3f2c43e commit a3e8edf

3 files changed

Lines changed: 91 additions & 5 deletions

File tree

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,25 @@ Diffo is especially suited for use in organisations with loosely coupled 'entity
3434

3535
## Installation
3636

37-
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
38-
by adding `diffo` to your list of dependencies in `mix.exs`:
37+
The recommended way to install Diffo is with [Igniter](https://hexdocs.pm/igniter):
38+
39+
```bash
40+
mix igniter.install diffo
41+
```
42+
43+
This will add the dependency, configure Neo4j (via `ash_neo4j`), register the custom expression, and set up the Spark formatter.
44+
45+
Alternatively, add `diffo` to your list of dependencies in `mix.exs` manually:
3946

4047
```elixir
4148
def deps do
4249
[
43-
{:diffo, "~> 0.1.6"}
50+
{:diffo, "~> 0.2.1"}
4451
]
4552
end
4653
```
4754

48-
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/).
55+
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/).
4956

5057
## Tutorial
5158

lib/mix/tasks/diffo.install.ex

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# SPDX-FileCopyrightText: 2025 diffo contributors <https://github.com/diffo-dev/diffo/graphs.contributors>
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
defmodule Mix.Tasks.Diffo.Install.Docs do
6+
@moduledoc false
7+
8+
def short_doc, do: "Installs Diffo"
9+
def example, do: "mix igniter.install diffo"
10+
11+
def long_doc do
12+
"""
13+
#{short_doc()}
14+
15+
## Example
16+
17+
```bash
18+
#{example()}
19+
```
20+
"""
21+
end
22+
end
23+
24+
if Code.ensure_loaded?(Igniter) do
25+
defmodule Mix.Tasks.Diffo.Install do
26+
@shortdoc "#{__MODULE__.Docs.short_doc()}"
27+
@moduledoc __MODULE__.Docs.long_doc()
28+
29+
use Igniter.Mix.Task
30+
31+
@impl Igniter.Mix.Task
32+
def info(_argv, _composing_task) do
33+
%Igniter.Mix.Task.Info{
34+
group: :ash,
35+
installs: [{:ash_neo4j, "~> 0.5"}],
36+
example: __MODULE__.Docs.example()
37+
}
38+
end
39+
40+
@impl Igniter.Mix.Task
41+
def igniter(igniter) do
42+
igniter
43+
|> Igniter.Project.Formatter.import_dep(:diffo)
44+
|> Spark.Igniter.prepend_to_section_order(
45+
:"Ash.Resource",
46+
[:specification, :features, :characteristics]
47+
)
48+
|> Igniter.Project.Config.configure(
49+
"config.exs",
50+
:ash,
51+
[:custom_expressions],
52+
[Diffo.Unwrap.AshCustomExpression],
53+
updater: fn zipper ->
54+
Igniter.Code.List.prepend_new_to_list(
55+
zipper,
56+
quote(do: Diffo.Unwrap.AshCustomExpression)
57+
)
58+
end
59+
)
60+
end
61+
end
62+
else
63+
defmodule Mix.Tasks.Diffo.Install do
64+
@shortdoc "#{__MODULE__.Docs.short_doc()} | Install `igniter` to use"
65+
@moduledoc __MODULE__.Docs.long_doc()
66+
67+
use Mix.Task
68+
69+
def run(_argv) do
70+
Mix.shell().error("""
71+
The task 'diffo.install' requires igniter. Please install igniter and try again.
72+
73+
For more information, see: https://hexdocs.pm/igniter/readme.html#installation
74+
""")
75+
76+
exit({:shutdown, 1})
77+
end
78+
end
79+
end

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ defmodule Diffo.MixProject do
9999
{:ash_outstanding, "~> 0.2.3"},
100100
{:ash_jason, "~> 3.0"},
101101
{:ash_state_machine, "~> 0.2.12"},
102-
{:ash_neo4j, ash_neo4j_version("~> 0.4.1")},
102+
{:ash_neo4j, ash_neo4j_version("~> 0.5")},
103103
{:bolty, ">= 0.0.12"},
104104
{:ash, ash_version("~> 3.0 and >= 3.24.2")},
105105
{:uuid, "~> 1.1"},

0 commit comments

Comments
 (0)