Splice tinfoil + Burrito wiring into a mix.exs that was produced
by mix new. The edits are intentionally string-based (not AST
rewrites) so user formatting, comments, and layout are preserved.
The module exports one splicer per concern:
insert_tinfoil_dep/2—{:tinfoil, "~> X", runtime: false}insert_burrito_dep/1—{:burrito, "~> 1.0"}insert_tinfoil_config/2—tinfoil: [ targets: [...] ]inproject/0insert_releases_entry/1—releases: releases()inproject/0insert_releases_block/2—defp releases do ... endfunctioninsert_application_mod/2—mod: {App.Application, []}inapplication/0
Every splicer is idempotent: if the target is already present, the
source is returned unchanged with an :already_present status.
If a splicer can't find its anchor -- typically because the user
customized the file beyond the mix new shape -- the caller gets
{:error, reason} and should print a snippet for manual paste
rather than guessing.
Summary
Functions
Add mod: {<app_module>.Application, []} to the application/0
keyword list, right after the extra_applications: [...] line.
Insert {:burrito, "~> 1.0"} into deps/0.
Back-compat alias for insert_tinfoil_dep/2. Kept because earlier
callers used the shorter name.
Append a defp releases do ... end function with a Burrito
:targets block for the given tinfoil targets. The function is
inserted at the bottom of the module, right before the final end.
The release name matches the app atom so Tinfoil.Burrito picks it
by name.
Insert releases: releases() into project/0 right after the
deps: deps() line.
Insert a minimal :tinfoil config block into project/0, right
after the deps: deps() line.
Insert {:tinfoil, "~> <version>", runtime: false} as the first
element of deps/0.
Types
Functions
@spec insert_application_mod(String.t(), String.t()) :: {:ok, String.t(), status()} | {:error, :application_anchor_not_found}
Add mod: {<app_module>.Application, []} to the application/0
keyword list, right after the extra_applications: [...] line.
@spec insert_burrito_dep(String.t()) :: {:ok, String.t(), status()} | {:error, :deps_anchor_not_found}
Insert {:burrito, "~> 1.0"} into deps/0.
@spec insert_dep(String.t(), String.t()) :: {:ok, String.t(), status()} | {:error, :deps_anchor_not_found}
Back-compat alias for insert_tinfoil_dep/2. Kept because earlier
callers used the shorter name.
@spec insert_releases_block(String.t(), atom(), [atom()]) :: {:ok, String.t(), status()} | {:error, :module_end_not_found}
Append a defp releases do ... end function with a Burrito
:targets block for the given tinfoil targets. The function is
inserted at the bottom of the module, right before the final end.
The release name matches the app atom so Tinfoil.Burrito picks it
by name.
@spec insert_releases_entry(String.t()) :: {:ok, String.t(), status()} | {:error, :project_anchor_not_found}
Insert releases: releases() into project/0 right after the
deps: deps() line.
@spec insert_tinfoil_config(String.t(), [atom()]) :: {:ok, String.t(), status()} | {:error, :project_anchor_not_found}
Insert a minimal :tinfoil config block into project/0, right
after the deps: deps() line.
@spec insert_tinfoil_dep(String.t(), String.t()) :: {:ok, String.t(), status()} | {:error, :deps_anchor_not_found}
Insert {:tinfoil, "~> <version>", runtime: false} as the first
element of deps/0.