Composer.Runner (composer v0.2.0)

Copy Markdown View Source

Runs a resolved step list against an igniter.

The list comes from Composer.Resolver, already expanded and filtered by flags, so every step here runs. Each step is one of:

  • {:module, module} - compose a step (any Igniter task module)
  • {:module, module, argv} - the same, with arguments
  • {:install, package, opts} - add a package and run its installer
  • {:task, task, argv} - compose an Igniter-aware Mix task by name
  • {:queue, task, argv} - queue a Mix task to run after the changes apply

Steps apply in list order, and every change lands in one diff. The one exception is dependencies: packages to install are added to mix.exs and fetched before any step runs, because their installers have to be on disk to compose. Queued tasks run last, non-interactively with --yes.

The install step

{:install, package, opts} is internal: Composer.Resolver builds it from hex: references, and recipes always write "hex:pkg" or {"hex:pkg", opts}, never {:install, ...}. opts is a canonical keyword list, so two installs with the same options are equal; keys come in this order, and empty ones are left out:

  • argv - arguments for the package's installer
  • source - where the package comes from: [version: requirement], [path: path], or [github: "owner/repo"] / [git: url] followed by git options (ref, branch, tag, sparse, submodules) sorted by key. Without one, the latest Hex version is used.
  • dep - only (a sorted list of atoms) and runtime, merged into the dependency

Every install is added and fetched up front, with one fetch for all of them, then its installer, if it ships one, runs at the step's position with argv plus --yes. A path source adds override: true. The runner trusts its input: given two installs of one package, the first one's dependency wins.

Summary

Functions

Returns the packages steps install, in order.

Runs steps in order.

Types

step()

@type step() ::
  {:module, module()}
  | {:module, module(), [String.t()]}
  | {:install, atom(), keyword()}
  | {:task, String.t(), [String.t()]}
  | {:queue, String.t(), [String.t()]}

Functions

installs(steps)

@spec installs([step()]) :: [atom()]

Returns the packages steps install, in order.

These are added to mix.exs and fetched before any step runs, so this is the set whose dependency changes reach disk ahead of the run's diff.

run(igniter, steps, opts \\ [])

@spec run(Igniter.t(), [step()], keyword()) :: Igniter.t()

Runs steps in order.

Warns when the target app's Phoenix requirement is older than the supported series (1.8).