Svelixir.Parse.Base.Template (svelixir v0.2.0)

Copy Markdown

Creates the base project structure using Mix generators.

Runs mix new for OTP projects or mix phx.new for web projects. Validates that the current directory matches the project name, otherwise creates a new directory for the project.

Summary

Functions

Creates the base project structure in the appropriate directory.

Restores .formatter.exs files hidden by execute/1 back to their original path. No-ops if execute/1 never hid anything (type wasn't web, or generation failed before it got that far).

Functions

execute(igniter)

@spec execute(Igniter.t()) :: Igniter.t()

Creates the base project structure in the appropriate directory.

Validates the current directory name against project name:

  • If current dir name == project name: generates in current directory
  • Otherwise: creates project name directory and generates inside it

On success, leaves the process cd'd into target_dir so that later Igniter-based steps (e.g. Docs) resolve their paths against the generated project instead of the directory this was invoked from.

restore_formatter_files!(igniter)

@spec restore_formatter_files!(Igniter.t()) :: :ok

Restores .formatter.exs files hidden by execute/1 back to their original path. No-ops if execute/1 never hid anything (type wasn't web, or generation failed before it got that far).

Must run after the igniter's queued changes have actually been applied to disk (Igniter.do_or_dry_run/2), not just queued -- otherwise that write could still see the hidden file (its absence never having been reverted) and, per Igniter.Project.Config.configure/5's self-healing behavior for a missing .formatter.exs, recreate a bare replacement before the restore runs.