# `PhxDemo.Env`
[🔗](https://github.com/thenatespack/phoenix_demo/blob/main/lib/phx_demo/env.ex#L1)

Pre-flight checks so a demo fails fast with a clear message instead of
recording a broken page.

Checks:
  1. `:phoenix_test, :base_url` is set
  2. the endpoint answers HTTP at that URL (`server: true` in config/test.exs)
  3. the narration adapter is usable (e.g. Piper installed, API key set)
  4. every `phx-track-static` asset linked from the root page returns 200
     (`mix assets.build` has been run)
  5. camera fixtures declared with `use PhxDemo.Case, camera_fixtures: [...]`
     exist (and ffmpeg is installed if one needs converting). This check
     runs for every demo module, not once per run. See `PhxDemo.Camera`.
  6. when `music:` is a MIDI file, fluidsynth is on PATH and a soundfont
     resolves (per demo module). See `PhxDemo.Midi`.
  7. when `music:` is generated (`%{elevenlabs: "prompt"}`), the setting is
     valid and an ElevenLabs API key is set (per demo module). See
     `PhxDemo.MusicGen`.

`PhxDemo.Case` runs this once per test run. Opt out with
`use PhxDemo.Case, check_env: false`.

# `check!`

# `check_once!`

Runs the checks once per VM. Later calls are free.

# `tracked_assets`

Asset URLs marked `phx-track-static` in an HTML page.

    iex> PhxDemo.Env.tracked_assets(~s(<link phx-track-static rel="stylesheet" href="/assets/app.css"><script defer phx-track-static src="/assets/app.js"></script><script src="/other.js"></script>))
    ["/assets/app.css", "/assets/app.js"]

---

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