View Source Bonfire.Common.Extensions (Bonfire v0.9.10-classic-beta.169)

Helpers for managing Bonfire extensions, e.g., enabling/disabling a module or extension, or listing available extensions and their metadata.

Summary

Functions

Retrieves a list of all dependencies.

Extracts the dependency name from a Mix.Dep struct or similar data.

Retrieves the branch name for a dependency.

Constructs a link to the code of a dependency.

Returns a link to the package or repository of a dependency.

Outputs the current version string for a dependency.

Constructs a link to the version of a dependency.

Disables a given extension globally.

Enables a given extension globally.

Retrieves a list of all dependencies in a specific format based on the options provided.

Retrieves a list of all dependency names in a specific format based on the options provided.

Functions

Retrieves a list of all dependencies.

Examples

> Bonfire.Common.Extensions.all_deps()
[%Mix.Dep{...}, %Mix.Dep{...}]

Extracts the dependency name from a Mix.Dep struct or similar data.

Parameters

  • dep: The dependency from which to extract the name.

Examples

iex> Bonfire.Common.Extensions.dep_name(%Mix.Dep{app: :my_app})
:my_app

iex> Bonfire.Common.Extensions.dep_name(:my_app)
:my_app

iex> Bonfire.Common.Extensions.dep_name("my_app")
"my_app"

Retrieves the branch name for a dependency.

Parameters

  • dep: The dependency from which to get the branch.

Examples

iex> Bonfire.Common.Extensions.get_branch(%{git: nil, branch: "main"})
"main"

iex> Bonfire.Common.Extensions.get_branch(%{lock: {:git, nil, nil, [branch: "feature"]}})
"feature"

Constructs a link to the code of a dependency.

Parameters

  • dep: The dependency from which to generate the link.

Examples

iex> Bonfire.Common.Extensions.get_code_link(%{app: "my_app"})
"/settings/extensions/code/my_app"

Returns a link to the package or repository of a dependency.

Parameters

  • dep: The dependency from which to generate the link.

Examples

iex> Bonfire.Common.Extensions.get_link(%{hex: "example_package"})
"https://hex.pm/packages/example_package"

iex> Bonfire.Common.Extensions.get_link(%{git: "https://github.com/user/repo", branch: "main"})
"https://github.com/user/repo/tree/main"

Outputs the current version string for a dependency.

Parameters

  • dep: The dependency from which to get the version.

Examples

iex> Bonfire.Common.Extensions.get_version(%{status: {:ok, "1.0.0"}})
"1.0.0"

iex> Bonfire.Common.Extensions.get_version(%{requirement: ">= 1.0.0"})
">= 1.0.0"

Constructs a link to the version of a dependency.

Parameters

  • dep: The dependency from which to generate the version link.

Examples

iex> Bonfire.Common.Extensions.get_version_link(%{app: "my_app", path: "file.ex"})
"/settings/extensions/diff?app=my_app&local=file.ex"

iex> Bonfire.Common.Extensions.get_version_link(%{lock: {:git, "https://github.com/user/repo", "abc123", [branch: "main"]}})
"https://github.com/user/repo/compare/abc123...main"
Link to this function

global_disable(extension)

View Source

Disables a given extension globally.

Parameters

  • extension: The name of the extension to disable.

Examples

> {:ok, %Bonfire.Data.Identity.Settings{json: %{bonfire: %{my_test_extension: %{modularity: :disabled}}}}} =  Bonfire.Common.Extensions.global_disable(:my_test_extension)
Link to this function

global_enable(extension)

View Source

Enables a given extension globally.

Parameters

  • extension: The name of the extension to enable.

Examples

> {:ok, %Bonfire.Data.Identity.Settings{json: %{bonfire: %{my_test_extension: %{modularity: nil}}}}} = Bonfire.Common.Extensions.global_enable(:my_test_extension)

Retrieves a list of all dependencies in a specific format based on the options provided.

Parameters

  • opts: Options to determine the format, e.g., :flat, :tree_flat, :nested.

Examples

> Bonfire.Common.Extensions.loaded_deps(:flat)
[%Mix.Dep{}, %Mix.Dep{}, ...]

> Bonfire.Common.Extensions.loaded_deps(:tree_flat)
[%Mix.Dep{}, %Mix.Dep{}, ...]
Link to this function

loaded_deps_names(opts \\ [])

View Source

Retrieves a list of all dependency names in a specific format based on the options provided.

Parameters

  • opts: Options to determine the format, e.g., :flat, :tree_flat, :nested.

Examples

> Bonfire.Common.Extensions.loaded_deps_names()
[:dep1, :dep2]