# `mix erabi.install`
[🔗](https://github.com/hattoriai/erabi/blob/v0.1.0/lib/mix/tasks/erabi.install.ex#L1)

Sets up Erabi in a Phoenix application.

    $ mix erabi.install
    $ mix erabi.install --dry-run

The task edits three files:

  * `assets/js/app.js` - adds `import { Erabi } from "erabi"` and puts
    `Erabi` in the `hooks` of the `LiveSocket`. When it cannot find the
    `new LiveSocket(...)` call, or its hooks are not an object or a
    variable, it changes nothing and prints the lines to add.
  * `assets/css/app.css` - adds
    `@import "../../deps/erabi/priv/static/erabi.css";`, and the Sumi
    theme import as a comment. The imports follow the deps directory of
    the project (`Mix.Project.deps_path/0`) when it is not `deps/`, as in
    an umbrella child or with `MIX_DEPS_PATH`. For a path dependency
    (`{:erabi, path: "../erabi"}`), which Mix does not copy into
    `deps/`, the imports point at the dependency's directory instead.
  * `lib/my_app_web/endpoint.ex` - serves the emoji of the emoji picker
    (`Erabi.Emoji`), with a `Plug.Static` above the endpoint's own.

Then it prints the esbuild note (the app's esbuild must resolve `erabi`
through `NODE_PATH`: from `deps/`, or, for a path dependency, from the
directory that holds it) and how to start the pickers on a page without
LiveView.

The task is idempotent: it does not add what a file already has, and when
there is nothing to add it says so.

## Options

  * `--dry-run` - prints the changes as a diff and writes nothing.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
