PhoenixKit.Install.RuntimeDetector (phoenix_kit v1.6.16)

View Source

Detects Phoenix runtime configuration patterns and determines appropriate config strategy.

This module analyzes Phoenix project configuration files to determine:

  • Whether the project uses runtime.exs patterns
  • The appropriate configuration file to modify
  • The correct insertion location for PhoenixKit configuration

Summary

Functions

Detects if the project uses runtime configuration patterns.

Checks if dev.exs file exists.

Finds the appropriate insertion point for PhoenixKit configuration.

Finds the appropriate location within runtime.exs for development configuration.

Checks if runtime.exs contains runtime configuration patterns.

Checks if runtime.exs file exists in the project.

Checks if dev.exs file exists and is simple enough to modify.

Functions

detect_config_pattern()

Detects if the project uses runtime configuration patterns.

Returns

  • :runtime - Uses runtime.exs with conditional blocks
  • :dev_exs - Uses simple dev.exs file
  • :config_exs - Uses config.exs with environment variables

Examples

iex> RuntimeDetector.detect_config_pattern()
:runtime

dev_exs_exists?()

Checks if dev.exs file exists.

Returns

true if dev.exs exists, false otherwise.

find_insertion_point()

Finds the appropriate insertion point for PhoenixKit configuration.

Returns

  • {:runtime, line_number} - Insert at specific line in runtime.exs
  • {:dev_exs, line_number} - Insert at end of dev.exs
  • {:config_exs, line_number} - Insert in config.exs with env check

Examples

iex> RuntimeDetector.find_insertion_point()
{:runtime, 76}

find_runtime_insertion_point()

Finds the appropriate location within runtime.exs for development configuration.

Returns

line_number where PhoenixKit config should be inserted.

has_runtime_patterns?()

Checks if runtime.exs contains runtime configuration patterns.

Returns

true if runtime patterns are detected, false otherwise.

runtime_exists?()

Checks if runtime.exs file exists in the project.

Returns

true if runtime.exs exists, false otherwise.

simple_dev_config?()

Checks if dev.exs file exists and is simple enough to modify.

Returns

true if simple dev.exs exists, false otherwise.