View Source Getting Started
add-uniform-to-mix-exs
Add Uniform to mix.exs
Add :uniform
as a dependency in mix.exs
and wrap your entire dependency
list in # uniform:deps
and # /uniform:deps
comments, like this.
defp deps do
# uniform:deps
[
{:uniform, "~> 0.1.0"},
...
]
# /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
Next, create a Blueprint module. It will contain all
of the details for how mix uniform.eject
should behave whenever you tell it
to eject a specific application.
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
In config/config.exs
put the following line. (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_application_name
Or, if you want to do this manually, you can start with a barebones manifest that contains an empty list.
# lib/my_application_name/uniform.exs
[]
Once you start structuring your project for the Uniform System, 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 uniform.exs Options for an explanation of supported options.
ejecting-an-application
Ejecting an Application
At this point, you should be able to run
mix uniform.eject MyApplicationName
And be able to successfully create an ejected codebase. However, it will probably lack critical code that is needed to run properly.
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.
Since each Elixir application is different, it is up to you to determine
which files need to be ejected to make mix uniform.eject
emit a working
application.
Using Phoenix?
We recommend developers building Phoenix projects read about the Uniform System, then consult the how-to guide for Setting up a Phoenix Project.
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