Go to file
Zach Daniel 279261fa31
Some checks are pending
CI / ash-ci (push) Waiting to run
chore: release version v0.3.10
2024-07-26 13:36:57 -04:00
.github improvement: make module moving much smarter 2024-07-02 23:26:39 -04:00
config improvement: properly find nested modules again 2024-07-02 16:33:08 -04:00
documentation docs: fix a typo misspelling 2024-07-01 21:23:51 -04:00
installer improvement: add positional_args!/1 macro for use in tasks 2024-07-26 13:31:17 -04:00
lib improvement: add positional_args!/1 macro for use in tasks 2024-07-26 13:31:17 -04:00
logos docs: improve logo 2024-06-12 18:36:32 -04:00
test improvement: add positional_args!/1 macro for use in tasks 2024-07-26 13:31:17 -04:00
.check.exs improvement: add CI/build and get it passing locally 2024-05-31 22:59:36 -04:00
.credo.exs fix: fix deps compilation issues by vendoring deps.compile 2024-07-09 16:38:57 -04:00
.formatter.exs improvement: support --with option in igniter.new 2024-06-20 19:25:28 -04:00
.gitignore improvement: better output on missing installers & already present dep 2024-07-25 09:20:38 -04:00
.igniter.exs improvement: make module moving much smarter 2024-07-02 23:26:39 -04:00
.tool-versions fix: properly move to pattern matches in scope 2024-07-19 10:28:36 -04:00
CHANGELOG.md chore: release version v0.3.10 2024-07-26 13:36:57 -04:00
FUNDING.yml improvement: add CI/build and get it passing locally 2024-05-31 22:59:36 -04:00
LICENSE improvement: add CI/build and get it passing locally 2024-05-31 22:59:36 -04:00
mix.exs chore: release version v0.3.10 2024-07-26 13:36:57 -04:00
mix.lock build(deps): bump the production-dependencies group with 2 updates (#59) 2024-07-25 10:41:59 -04:00
README.md docs: Remove only: [:dev] in setup instructions (#41) 2024-07-10 08:03:24 -04:00

Logo Light Logo Dark

CI Hex version badge Hexdocs badge

Igniter

Igniter is a code generation and project patching framework.

For library authors, this is a tool kit for writing smarter generators that can semantically modify existing files, and all sorts of useful tools for doing so.

For end-users, this means mix igniter.install <package>, which will add it to your mix.exs automatically and then run that library's installer if it has one. Even when libraries don't have an installer, or use igniter, this behavior makes it useful to keep around.

State of the project

This project is in early beta. There is so much to add! There are lots of DX/UX things to improve, but it does already provide some great utility. Contributions welcome!

Limitations

Right now, all files that are touched are formatted in their entirety. This may be a deal breaker for some users. I believe that we can solve this without changing the fundemental design of the project, but it is not a high priority in the early stages.

Installation

Igniter can be added to an existing elixir project by adding it to your dependencies:

{:igniter, "~> 0.1"}

You can also generate new projects with igniter preinstalled, and run installers in the same command.

First, install the archive:

mix archive.install hex igniter_new

Then you can run mix igniter.new

mix igniter.new app_name --install ash

Or if you want to use a different project creator, specify the mix task name with the --with flag. Any arguments will be passed through to that task, with the exception of --install and --example.

mix igniter.new app_name --install ash --with phx.new --no-ecto

Patterns

Mix tasks built with igniter are both individually callable, and composable. This means that tasks can call eachother, and also end users can create and customize their own generators composing existing tasks.

Installers

Igniter will look for a task called <your_package>.install when the user runs mix igniter.install <your_package>, and will run it after installing and fetching dependencies.

Generators/Patchers

These can be run like any other mix task, or composed together. For example, lets say that you wanted to have your own Ash.Resource generator, that starts with the default mix ash.gen.resource task, but then adds or modifies files:

# in lib/mix/tasks/my_app.gen.resource.ex
defmodule Mix.Tasks.MyApp.Gen.Resource do
  use Igniter.Mix.Task

  def igniter(igniter, [resource | _] = argv) do
    resource = Igniter.Code.Module.parse(resource)
    my_special_thing = Module.concat([resource, SpecialThing])
    location = Igniter.Code.Module.proper_location(my_special_thing)

    igniter
    |> Igniter.compose_task("ash.gen.resource", argv)
    |> Igniter.create_new_elixir_file(location, """
    defmodule #{inspect(my_special_thing)} do
      # this is the special thing for #{inspect()}
    end
    """)
  end
end