|
| 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 |
0 commit comments