mix dala.routes (dala_dev v0.0.3)

Copy Markdown View Source

Walks all lib/**/*.ex files and checks that every module passed to push_screen/2, reset_to/2, or pop_to/2 resolves to a loadable module.

Unresolvable destinations are printed as warnings. Use --strict to exit non-zero (for CI).

Examples:

mix dala.routes
mix dala.routes --strict

What is checked

  • Dala.Socket.push_screen(socket, MyApp.SomeScreen)
  • Dala.Socket.push_screen(socket, MyApp.SomeScreen, params)
  • Dala.Socket.reset_to(socket, MyApp.SomeScreen)
  • Dala.Socket.pop_to(socket, MyApp.SomeScreen)
  • Unqualified forms: push_screen(socket, ...), reset_to(...), pop_to(...)

What is NOT checked

  • Dynamic destinations: push_screen(socket, some_variable) — skipped silently.
  • Registered name atoms (e.g. :main) — these require the app to be running to verify against Dala.Nav.Registry; they are skipped with a note.

Under the hood

mix compile   # ensure all modules are compiled before verifying

# For each lib/**/*.ex file:
Code.string_to_quoted(source, file: file)   # parse to AST
Macro.prewalk(ast, ...)                      # find push_screen/reset_to/pop_to calls
Code.ensure_loaded(MyApp.SomeScreen)         # verify module is loadable

This is pure static analysis — it parses the source and checks the compiled modules on disk. No app process is started. Code.ensure_loaded/1 is the same function the BEAM uses internally to check whether a module exists.