Composer.Local (composer v0.2.0)

Copy Markdown View Source

Local: your recipes, outside any project.

~/.config/composer/
  recipes/ash.exs       # local:ash/base, local:ash/auth, ...
  recipes/lv.exs        # local:lv/base, ...

Local holds recipe groups only (see Composer.Recipe.Group). Its recipes reference steps from package cookbooks ("core:setup/credo") and other recipes ({:use, "local:ash/base"}, or {:use, "base"} within the same group). Personal steps, and the templates beside them, belong in a small cookbook package added as a path dependency.

A steps/ or templates/ directory here is an error. Any other entry besides recipes/ is left alone (so a later composer can add settings files), and mix composer.cookbook.lint --local reports it. Entries starting with . are ignored.

The directory is found in this order, first match wins:

  1. the -c / --config option of a composer task
  2. the COMPOSER_CONFIG environment variable
  3. $XDG_CONFIG_HOME/composer
  4. ~/.config/composer

A directory given by 1 or 2 must exist. The default directories may be missing, which just means you have no local recipes.

Warning

Group files are Elixir code, evaluated with Code.eval_file/1. Only use recipes you wrote or trust.

Summary

Functions

Builds the local cookbook from the config directory.

Returns the config directory and whether it was given explicitly.

Returns the top-level entries of the config directory other than recipes/, sorted. Entries starting with . are left out.

True for an entry that local rejects outright (steps, templates).

Functions

cookbook(config \\ nil)

@spec cookbook(String.t() | nil) :: {:ok, Composer.Cookbook.t()} | {:error, term()}

Builds the local cookbook from the config directory.

dir(config \\ nil)

@spec dir(String.t() | nil) :: {Path.t(), :explicit | :default}

Returns the config directory and whether it was given explicitly.

entries(dir)

@spec entries(Path.t()) :: [String.t()]

Returns the top-level entries of the config directory other than recipes/, sorted. Entries starting with . are left out.

recipes_only?(entry)

@spec recipes_only?(String.t()) :: boolean()

True for an entry that local rejects outright (steps, templates).