Reads dependency and version declarations from mix.exs and mix.lock
without evaluating them.
Recognised shapes: a deps/0 function returning a list literal of
{:name, ...} tuples, @version "..." or version: "...",
elixirc_paths: (see elixirc_paths/2), and the standard
%{"name" => {...}} lockfile map.
Summary
Functions
Dependencies declared by every mix.exs in the tree (umbrella apps included), deduplicated by name.
Package names present in every mix.lock in the tree.
Dependencies declared in mix.exs, or [] if absent or unparseable.
The paths the project at path compiles Elixir from in the :prod
environment, as written in its mix.exs (relative to the project).
Package names present in mix.lock, or [] if absent.
Paths in the tree matching pattern, excluding vendored dependencies and
test fixtures (a mix.exs under test/ describes a fixture project, not
this one).
A pattern matching the Elixir files each project in the tree ships: the
.ex files Mix compiles from the project's elixirc_paths/2, joined to
the project's directory. These are the files a dependent compiles; test
support and fixtures compiled only under MIX_ENV=test are not among
them.
The project version from mix.exs, or nil.
Types
Functions
@spec all_deps(Presubmit.Tree.t()) :: [dep()]
Dependencies declared by every mix.exs in the tree (umbrella apps included), deduplicated by name.
@spec all_locked(Presubmit.Tree.t()) :: [atom()]
Package names present in every mix.lock in the tree.
@spec deps(Presubmit.Tree.t(), String.t()) :: [dep()]
Dependencies declared in mix.exs, or [] if absent or unparseable.
@spec elixirc_paths(Presubmit.Tree.t(), String.t()) :: [String.t()]
The paths the project at path compiles Elixir from in the :prod
environment, as written in its mix.exs (relative to the project).
:prod is the environment a project is compiled in when it is somebody's
dependency, so these are the paths of the code the package ships: test
support and fixtures that elixirc_paths(:test) adds are excluded.
mix.exs is read, not evaluated. The value of elixirc_paths: is
resolved from literal lists of strings joined with ++, Mix.env(),
module attributes, if over comparisons of Mix.env(), and calls to
functions defined in mix.exs whose clauses match on literals or
variables, optionally with ==, !=, in, and, or, or not guards.
That covers the elixirc_paths(Mix.env()) helper Phoenix's generator
writes and the variations on it seen in practice.
Returns [] for an umbrella root (apps_path:), which compiles nothing
itself, and ["lib"], Mix's default, when elixirc_paths: is absent,
when its value is beyond those shapes, or when mix.exs is missing or
does not parse.
@spec locked(Presubmit.Tree.t(), String.t()) :: [atom()]
Package names present in mix.lock, or [] if absent.
@spec project_files(Presubmit.Tree.t(), Regex.t()) :: [String.t()]
Paths in the tree matching pattern, excluding vendored dependencies and
test fixtures (a mix.exs under test/ describes a fixture project, not
this one).
@spec shipped_source(Presubmit.Tree.t()) :: Presubmit.Pattern.t()
A pattern matching the Elixir files each project in the tree ships: the
.ex files Mix compiles from the project's elixirc_paths/2, joined to
the project's directory. These are the files a dependent compiles; test
support and fixtures compiled only under MIX_ENV=test are not among
them.
Every mix.exs that project_files/2 finds is a project, so umbrella
apps and subdirectory projects each contribute their own paths. A tree
with no mix.exs at all is not a Mix project; there the conventional
lib/ directories at any depth stand in.
@spec version(Presubmit.Tree.t(), String.t()) :: String.t() | nil
The project version from mix.exs, or nil.