View Source Uniform.App (Uniform v0.6.0)
A struct representing an app to be ejected. See the type definition for more details.
where-it-s-availabile
Where it's availabile
An app
struct is available in the Blueprint in these callbacks and macros:
Use the app
to make decisions about what to eject or how files should be
modified.
checking-for-dependencies
Checking for dependencies
In the callbacks and macros above, you can use depends_on?
to determine
whether an app depends on a mix or lib dependency.
depends_on?(app, :mix, :norm)
See depends_on?/3
for more information.
Link to this section Summary
Functions
Indicates if an app requires a given dependency.
Link to this section Types
@type t() :: %Uniform.App{ destination: Path.t(), extra: keyword(), internal: term(), name: %{ module: module(), hyphen: String.t(), underscore: String.t(), camel: String.t() } }
An App struct, representing a discrete, self-contained app to be ejected.
example
Example
Note that the extra
key contains everything you put in extra
in
uniform.exs
for the given app. It also contains anything returned by
Uniform.Blueprint.extra/1
. (uniform.exs
has precedence for conflicting
keys.)
#Uniform.App<
extra: [
company: :fake_co,
logo_file: "path/to/some_logo.png",
some_data: "from uniform.exs"
],
name: %{
camel: "Tweeter",
hyphen: "tweeter",
module: Tweeter,
underscore: "tweeter"
},
...
>
Link to this section Functions
Indicates if an app requires a given dependency.
Pass in the app
, the dependency type (either :lib
or :mix
), and the
name of the dependency (like :tesla
or :my_lib_directory
) and the
function will return true
if the dependency will be ejected along with the
app.
examples
Examples
depends_on?(app, :mix, :some_included_mix_dep)
depends_on?(app, :mix, :not_included_dep)
depends_on?(app, :lib, :some_included_lib)
examples-in-context
Examples in Context
base_files do
if depends_on?(app, :mix, :some_hex_dependency) do
file "file_needed_by_some_hex_dependency"
end
end
modify ~r/^test/.+_(test).exs/, fn file, app ->
if depends_on?(app, :lib, :my_data_lib) do
file
else
String.replace(
file,
"use Oban.Testing, repo: MyDataLib.Repo",
"use Oban.Testing, repo: OtherDataLib.Repo"
)
end
end