ComposerNew.Plan (composer_new v0.3.0)

Copy Markdown View Source

Turns mix composer.new argv into the list of commands to run.

build/2 is pure: everything it needs from the outside (the working directory, the home directory, the archive's version) comes in env, so --dry-run prints exactly what a run executes, and the tests check the same lists. The commands, in order ([...] is optional):

rm -rf APP                                              (--reset)
mix igniter.new APP --no-git --yes [--local REL] [--with TASK]
    [--with-args=ARGS] [--install PKG,...]
(in APP) mix igniter.install composer@SRC[,COOKBOOK[@SRC]][,EXTRA,...]
    --only dev,test --yes
(in APP) git init
(in APP) git add -A
(in APP) git commit -m "mix composer.new <argv as typed>"
(in APP) mix composer.recipe.run COOKBOOK:GROUP/RECIPE [FLAGS]
                                         (REF given, no --no-recipe)

igniter.new gets --no-git, so the history starts with the commit above rather than with igniter's own. git init is harmless in a repo the base generator already made, so it is always planned.

path: sources are made absolute, since the install runs inside APP. The commit message keeps the argv as typed.

Summary

Functions

Builds the plan for argv.

Types

env()

@type env() :: %{cwd: Path.t(), home: Path.t(), version: String.t()}

step()

@type step() :: ComposerNew.Command.t() | {:rm_rf, Path.t()}

t()

@type t() :: %ComposerNew.Plan{
  commands: [step()],
  parsed: ComposerNew.Argv.t(),
  summary: map()
}

Functions

build(argv, env)

@spec build([String.t()], env()) :: {:ok, t()} | {:error, String.t()}

Builds the plan for argv.