View Source mix uniform.eject (Uniform v0.6.0)

Ejects an Ejectable App to a standalone code repository.

usage

Usage

$ mix uniform.eject trillo
$ mix uniform.eject tweeter --confirm
$ mix uniform.eject hatmail --confirm --destination ../../new/dir

command-line-options

Command line options

  • --destination – output directory for the ejected code. Read the Configuration section of the Getting Started guide to understand how the destination is chosen if this option is omitted.
  • --confirm – affirm "yes" to the prompt asking you whether you want to eject.

which-files-get-ejected

Which files get ejected

When you run mix uniform.eject my_app, these four rules determine which files are copied.

  1. A few files common to Elixir projects are copied.
  2. All files in the Blueprint's base_files section are copied.
  3. All files in lib/my_app and test/my_app are copied.
  4. For every Lib Dependency of my_app:
    • All files in lib/my_lib_dep and test/my_lib_dep are copied.
    • All associated files tied to the Lib Dependency are copied.

If you need to apply exceptions to these rules, you can use these tools.

  • Files in (lib|test)/my_app (rule 3) are subject to the lib_app_except callback.
  • Lib Dependency files (rule 4) are subject to only and except instructions.

ejection-step-by-step

Ejection step by step

When you eject an app by running mix uniform.eject my_app, the following happens:

  1. The destination directory is created if it doesn't exist.
  2. All files and directories in the destination are deleted, except for .git, _build, deps, and anything in the Blueprint's @preserve.
  3. All files required by the app are copied to the destination. (See Which files get ejected.)
  4. For each file copied, a set of transformations are applied to the file contents – except for files specified with cp and cp_r.
  5. mix deps.clean --unlock --unused is ran on the ejected codebase.
  6. mix format is ran on the ejected codebase.

In step 2, .git is kept to preserve the Git repository and history. deps is kept to avoid having to download all dependencies after ejection. _build is kept to avoid having to recompile the entire project after ejection.

mix deps.clean --unlock --unused removes unused Mix Dependencies from mix.lock in the ejected codebase. This includes deps removed from mix.exs as well as transitive dependencies of those deps.

mix format tidies up things like chains of newlines that may appear from applying Eject Fences. It also prevents you from having to think about code formatting in modify.