mix demo_director.install (DemoDirector v0.1.5)

Copy Markdown View Source

Installs demo_director into a Phoenix application.

Run via:

mix igniter.install demo_director

Assumes the host app already has a working Phoenix LiveView setup (a Phoenix.LiveView.Socket declaration in the endpoint, a router, and the standard layouts). The installer doesn't bootstrap LiveView from scratch.

The task does four things:

  1. Adds import DemoDirector.Router and a demo_director "/demo-director" macro call inside an if Application.compile_env(:my_app, :dev_routes) do ... end block in your router (creating the block if absent). The scope is not piped through :browser because the playback POST endpoint must bypass protect_from_forgery.
  2. Adds a socket "/director/socket", DemoDirector.PlaybackSocket declaration to your endpoint, after the existing Phoenix.LiveView.Socket line.
  3. Adds config :demo_director, pubsub: <OtpApp>.PubSub to config/dev.exs (using the conventional PubSub name from mix phx.new; if your PubSub server is named differently, edit the value after install).
  4. Appends a marked instructions section to AGENTS.md (always) and to CLAUDE.md (only if it already exists, or if a .claude/ directory is present).

One manual step remains — rendering the overlay component in your dev-time root layout — because root layouts are HEEx, not Elixir AST, so editing them programmatically means string-level surgery on a frequently-customized file. The post-install notice prints the exact line to paste.

Sections written to AGENTS.md / CLAUDE.md are wrapped in <!-- BEGIN demo_director --> / <!-- END demo_director --> markers, so re-running the task replaces the section in place rather than appending a duplicate. Router and endpoint edits are similarly idempotent — the task searches for an existing import DemoDirector.Router / DemoDirector.PlaybackSocket before adding.