# Igniter - A code generation and project patching framework 

**URL:** <https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181>\
**Category:** Announcing\
**Tags:** library, igniter\
**Created:** [June 13, 2024, 12:56am UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181 "2024-06-13T00:56:19Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![zachdaniel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/32/31980_2.png) [@zachdaniel](https://forum.elixirforum.com/u/zachdaniel)\
**Post date:** [October 15, 2024, 10:37pm UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181/21 "2024-10-15T22:37:03Z")

</div>

`mix igniter.new new_project --install your_generators --components foo,bar,baz` would be a one liner that does it. You’d make an installer task (you can generate one with `mix igniter.gen.task your_generators.install`), and your installer would have a `components` option, and the installer would look something like this:

```elixir
def igniter(igniter, argv) do
  # there is another place where your schema is defined that populates this
  options = options!(argv) 

  Enum.reduce(options[:components], igniter, fn component, igniter ->
    Igniter.compose_task("your_generators.add_component", [component])
  end)
end

```

EDIT if you want a new project using phoenix

```bash
mix igniter.new new_project --with phx.new --install your_generators --components foo,bar,baz

```

---

<div class="post-metadata">

**Author:** ![type1fool](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/type1fool/32/41249_2.png) [@type1fool](https://forum.elixirforum.com/u/type1fool)\
**Post date:** [October 15, 2024, 10:40pm UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181/22 "2024-10-15T22:40:26Z")

</div>

Excellent! This feels like a real Captain Planet situation.

---

<div class="post-metadata">

**Author:** ![type1fool](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/type1fool/32/41249_2.png) [@type1fool](https://forum.elixirforum.com/u/type1fool)\
**Post date:** [October 16, 2024, 3:06pm UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181/23 "2024-10-16T15:06:35Z")

</div>

Ok I’m cooking now, making good progress. One issue I’ve stumbled on is copying HEEx templates, which have EEx tags like `<%= render_slot(@inner_block) %>`. When I call `Igniter.copy_template/5`, the code is executed though it needs to be rendered as-is. I tried wrapping the tag in `<%% ... %>` but Mix/Igniter still attempts to execute the `render_slot/1` function.

Since there’s no `Igniter.copy_file` function, would I need to read the template’s contents and use `Igniter.create_new_file/4`?

PS: Should I break out a separate topic? I realized this one may be intended for updates.

EDIT: This works: `<%%= render_slot(@inner_block) %>` 😅

---

<div class="post-metadata">

**Author:** ![zachdaniel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/32/31980_2.png) [@zachdaniel](https://forum.elixirforum.com/u/zachdaniel)\
**Post date:** [October 16, 2024, 3:26pm UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181/24 "2024-10-16T15:26:06Z")

</div>

Yeah, perhaps from here on we can use a different channel. We also have an igniter channel in the Ash discord if you’d like to use that 🙂 Given that igniter is a tool meant for the wider ecosystem we could also have a channel in the slack/discord for informal chats, etc.

---

<div class="post-metadata">

**Author:** ![type1fool](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/type1fool/32/41249_2.png) [@type1fool](https://forum.elixirforum.com/u/type1fool)\
**Post date:** [October 16, 2024, 3:36pm UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181/25 "2024-10-16T15:36:36Z")

</div>

It’ll be nice to find these posts in 6 months when I’m searching for answers, so I choose this [silo](https://www.zachdaniel.dev/p/silos-in-the-elixir-community). If I run into more hiccups, I’ll open a new topic.

I’ve gotta say, writing Igniter tasks is fun. Looking forward to going deeper with the other modules. 🎉 Good work!

---

<div class="post-metadata">

**Author:** ![zachdaniel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/32/31980_2.png) [@zachdaniel](https://forum.elixirforum.com/u/zachdaniel)\
**Post date:** [October 16, 2024, 3:48pm UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181/26 "2024-10-16T15:48:45Z")

</div>

That is the right choice 😅 I should probably not really suggest the really silo’d platforms if people aren’t explicitly asking for them. I want people to use ElixirForum but I also would rather them participate in a silo than not at all… Its a tricky balance 😆

---

<div class="post-metadata">

**Author:** ![zachdaniel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/32/31980_2.png) [@zachdaniel](https://forum.elixirforum.com/u/zachdaniel)\
**Post date:** [October 19, 2024, 3:25am UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181/27 "2024-10-19T03:25:25Z")

</div>

## Igniter’s first project-wide refactoring tool!

Rename functions everywhere across your project with one command 😎  
This can also be used by library maintainers in their upgrade scripts  
to automatically move users off of deprecated functions.

```bash
mix igniter.refactor.rename_function \
  Igniter.Code.List.list \
  Igniter.Code.List.is_a_list \
  --deprecate hard

```

## Speaking of upgrade scripts…

We just released 🔥 `mix igniter.upgrade` 🔥

This command is a drop in replacement for `mix deps.update`,  
except it hooks into any upgrade scripts provided by libraries  
that use Igniter! We’re still testing it out, but this also ships  
with a `--git-ci` flag and instructions on how to set up dependabot  
to run `mix igniter.upgrade` automatically 🤖. Think Laravel shift  
but free, leveraging our already excellent build tool `mix`!

```bash
mix igniter.upgrade ash 

```

It is still early days, and there will be plenty of rough edges  
to sand down, but I truly believe that igniter can play a massive  
part in improving the DX around building Elixir applications.

Igniter now provides a fit-for-purpose framework for:

- Installers
- Generators
- Refactoring tools
- Custom code patching
- Upgrade scripts

All that is left is for us to spread it into the ecosystem  
Even without adoption, it is useful for end-users as it is today

Happy hacking 😎

---

<div class="post-metadata">

**Author:** ![zachdaniel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/32/31980_2.png) [@zachdaniel](https://forum.elixirforum.com/u/zachdaniel)\
**Post date:** [November 1, 2024, 8:06pm UTC](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181/28 "2024-11-01T20:06:48Z")

</div>

We’ve made an update to igniter in 0.4.x that changes slightly how you write tasks.

It is a very small update, but adds a convenience around dealing with options and arguments.

It’s “soft deprecated” for now, it won’t warn, but eventually it will. Essentially, instead of:

```elixir
def igniter(igniter, argv) do
  {arguments, argv} = positional!(argv)
  options = options!(argv)
end

```

you can now do

```elixir
def igniter(igniter) do
  # positional args are in 
  igniter.args.positional
  # options are in 
  igniter.args.options
  # argv without positional args (for composition) are in 
  igniter.args.argv_flags`
  # raw argue are in 
  igniter.args.argv

  ...
end

```

Additionally, `mix igniter.upgrade` in 0.3.x had some issues that may make it not work, so manual upgrade to 0.4.x will likely be required. More on that in the readme.

[Previous page](https://forum.elixirforum.com/t/igniter-a-code-generation-and-project-patching-framework/64181.md?page=1)
