View Source Getting Started
add-uniform-to-mix-exs
Add Uniform to mix.exs
Add :uniform
as a dependency in mix.exs
and wrap the deps list in # uniform:deps
and # /uniform:deps
comments, like this.
defp deps do
# uniform:deps
[
{:uniform, "~> 0.1.1"},
...
]
# /uniform:deps
end
run-mix-uniform-init
Run mix uniform.init
After adding :uniform
to mix.exs
and running mix deps.get
, run
mix uniform.init
This will Create a Blueprint module and add Configuration, which you can do manually if you'd rather by following the steps below.
create-a-blueprint-module
Create a Blueprint module
If you opted out of running mix uniform.init
, create a
Blueprint module. This is the central file you'll use
to tell Uniform which files to copy when running mix uniform.eject
.
To start, you can create an empty Blueprint like this.
defmodule MyApp.Uniform.Blueprint do
use Uniform.Blueprint, templates: "lib/my_app/uniform/templates"
end
You can name the module whatever you like, but we suggest putting it in
lib/my_app/uniform/blueprint.ex
and specifying the templates directory
alongside it in lib/my_app/uniform/templates
.
configuration
Configuration
If you opted out of running mix uniform.init
, add the following line to
config/config.exs
. (Changing the blueprint
value to match the name of your
Blueprint module name above.)
config :my_app, Uniform, blueprint: MyApp.Uniform.Blueprint
You can also optionally set a default destination
for ejected apps.
# With optional :destination
config :my_app, Uniform,
blueprint: MyApp.Uniform.Blueprint,
destination: "/Users/me/ejected"
If destination
is ommitted, the default is one level up from the Base
Project's root folder. The --destination
option of mix uniform.eject
takes
precedence and overrides both of these behaviors.
add-uniform-manifests
Add Uniform Manifests
Designate all lib
directories that represent an Ejectable
App by placing an uniform.exs
manifest file into each directory.
You can do so with mix uniform.gen.app
, which creates an empty manifest
containing code comments to help you start.
mix uniform.gen.app my_app_name
Or, if you want to do this manually, you can start with a barebones manifest that contains an empty list.
# lib/my_app_name/uniform.exs
[]
Once you start structuring your project for Uniform, you'll add Lib and Mix Dependencies in this file.
[
lib_deps: [:my_data_source, :utilities],
mix_deps: [:csv, :chromic_pdf]
]
More on uniform.exs
See the Uniform Manifests guide for an explanation of supported options.
ejecting-an-app
Ejecting an App
At this point, you should be able to run
mix uniform.eject my_app_name
And be able to successfully create an ejected codebase. However, it probably won't contain the files needed to run locally or be deployed.
This leads us to the final step of Building a Blueprint.
build-the-blueprint
Build the Blueprint
Read the documentation for Uniform.Blueprint for the full range of features to build out your Blueprint module.
The Blueprint module is central for configuring
which files are ejected during mix uniform.eject
.
Since each Elixir project is different, it is up to you to determine which files need to be ejected to emit a working application.
Are you building Phoenix apps?
The Setting up a Phoenix project guide contains details and examples for building your Blueprint.
An example barebones Blueprint might look like this.
defmodule MyApp.Uniform.Blueprint do
use Uniform.Blueprint
base_files do
file "lib/my_app/application.ex"
file "lib/my_app_web/endpoint.ex"
cp_r "assets"
template "config/runtime.exs"
end
deps do
always do
mix :phoenix
mix :phoenix_html
lib :utilities
end
lib :my_data_graph do
mix_deps [:absinthe]
end
end
end