DalaDev.EnvSnapshot (dala_dev v0.4.0)

Copy Markdown View Source

One-shot, machine-readable snapshot of the dala development environment.

Answers "what do I have to work with" — toolchain versions, OTP runtime caches, connected devices with their node names and dist ports — in one call. Complements mix dala.doctor (which diagnoses problems); this is the neutral inventory for scripts, CI logs, and bug reports.

Summary

Functions

Collects the snapshot as a plain (JSON-encodable) map. Never raises — missing tools become nil entries. Shells out at most once per known toolchain command.

Collects and JSON-encodes (pretty-printed).

Extracts the adb platform-tools version (e.g. "34.0.5-11300000"). Handles both layouts: Version X on its own line (modern adb) and ... version X on the banner line (older adb). The capital-V pattern runs first so it never grabs the older 1.x client version from line one.

Extracts the version line from emulator -version output, which prints INFO banner lines before it. Returns the trimmed line or nil.

Extracts a version from xcrun --version output (e.g. xcrun version 61.).

Functions

collect()

@spec collect() :: map()

Collects the snapshot as a plain (JSON-encodable) map. Never raises — missing tools become nil entries. Shells out at most once per known toolchain command.

collect_json()

@spec collect_json() :: String.t()

Collects and JSON-encodes (pretty-printed).

parse_adb_version(output)

@spec parse_adb_version(String.t()) :: String.t() | nil

Extracts the adb platform-tools version (e.g. "34.0.5-11300000"). Handles both layouts: Version X on its own line (modern adb) and ... version X on the banner line (older adb). The capital-V pattern runs first so it never grabs the older 1.x client version from line one.

parse_emulator_version(output)

@spec parse_emulator_version(String.t()) :: String.t() | nil

Extracts the version line from emulator -version output, which prints INFO banner lines before it. Returns the trimmed line or nil.

parse_xcrun_version(output)

@spec parse_xcrun_version(String.t()) :: String.t() | nil

Extracts a version from xcrun --version output (e.g. xcrun version 61.).