Shadix.Registry (shadix v0.0.1)

Copy Markdown View Source

Loads and resolves Shadix component manifests from priv/registry/*.json.

Each manifest describes a component's source files and its dependencies on other components. The registry ships the source inline in the JSON so that Application.app_dir(:shadix, "priv/registry") always works at runtime, even inside a compiled Mix dependency (where lib/*.ex sources are absent).

Summary

Functions

Loads a single manifest by name.

Resolves one or more component names into an ordered, de-duplicated list of manifests.

Functions

load!(name)

@spec load!(String.t()) :: map()

Loads a single manifest by name.

Reads priv/registry/<name>.json from the Shadix application directory and decodes it. Raises a RuntimeError with a clear message if the file is not found.

Example

iex> Shadix.Registry.load!("cn")
%{"name" => "cn", "registry_deps" => [], "files" => [...]}

resolve(name)

@spec resolve(String.t() | [String.t()]) :: [map()]

Resolves one or more component names into an ordered, de-duplicated list of manifests.

Returns manifests in deps-before-dependents order (topological sort). If a name appears multiple times in the input, it is de-duplicated in the result.

Raises RuntimeError if a cycle is detected.

Examples

iex> Shadix.Registry.resolve("button") |> Enum.map(& &1["name"])
["cn", "button"]

iex> Shadix.Registry.resolve(["card", "button"]) |> Enum.map(& &1["name"])
["cn", "card", "button"]