Class: Aidp::Setup::Devcontainer::PortManager
- Inherits:
-
Object
- Object
- Aidp::Setup::Devcontainer::PortManager
- Defined in:
- lib/aidp/setup/devcontainer/port_manager.rb
Overview
Manages port configuration for devcontainers and generates documentation
Constant Summary collapse
- STANDARD_PORTS =
Standard port assignments for common services
{ web_app: {number: 3000, label: "Application", protocol: "http"}, remote_terminal: {number: 7681, label: "Remote Terminal (ttyd)", protocol: "http"}, playwright_debug: {number: 9222, label: "Playwright Debug", protocol: "http"}, mcp_server: {number: 8080, label: "MCP Server", protocol: "http"}, postgres: {number: 5432, label: "PostgreSQL", protocol: "tcp"}, redis: {number: 6379, label: "Redis", protocol: "tcp"}, mysql: {number: 3306, label: "MySQL", protocol: "tcp"} }.freeze
Instance Method Summary collapse
-
#detect_required_ports ⇒ Array<Hash>
Detect all required ports based on wizard configuration.
-
#generate_forward_ports ⇒ Array<Integer>
Generate forwardPorts array for devcontainer.json.
-
#generate_port_attributes ⇒ Hash
Generate portsAttributes hash for devcontainer.json.
-
#generate_ports_documentation(output_path = nil) ⇒ String
Generate PORTS.md documentation.
-
#initialize(wizard_config) ⇒ PortManager
constructor
A new instance of PortManager.
Constructor Details
#initialize(wizard_config) ⇒ PortManager
Returns a new instance of PortManager.
19 20 21 22 |
# File 'lib/aidp/setup/devcontainer/port_manager.rb', line 19 def initialize(wizard_config) @wizard_config = wizard_config @detected_ports = [] end |
Instance Method Details
#detect_required_ports ⇒ Array<Hash>
Detect all required ports based on wizard configuration
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aidp/setup/devcontainer/port_manager.rb', line 26 def detect_required_ports return @detected_ports if @detected_ports.any? @detected_ports = [] detect_application_ports detect_tool_ports detect_service_ports add_custom_ports Aidp.log_debug("port_manager", "detected ports", count: @detected_ports.size, ports: @detected_ports.map { |p| p[:number] }) @detected_ports end |
#generate_forward_ports ⇒ Array<Integer>
Generate forwardPorts array for devcontainer.json
45 46 47 |
# File 'lib/aidp/setup/devcontainer/port_manager.rb', line 45 def generate_forward_ports detect_required_ports.map { |p| p[:number] } end |
#generate_port_attributes ⇒ Hash
Generate portsAttributes hash for devcontainer.json
51 52 53 54 55 56 57 58 59 |
# File 'lib/aidp/setup/devcontainer/port_manager.rb', line 51 def generate_port_attributes detect_required_ports.each_with_object({}) do |port, attrs| attrs[port[:number].to_s] = { "label" => port[:label], "protocol" => port[:protocol] || "http", "onAutoForward" => port[:auto_open] ? "notify" : "silent" } end end |
#generate_ports_documentation(output_path = nil) ⇒ String
Generate PORTS.md documentation
64 65 66 67 68 69 70 71 |
# File 'lib/aidp/setup/devcontainer/port_manager.rb', line 64 def generate_ports_documentation(output_path = nil) detect_required_ports content = build_ports_markdown File.write(output_path, content) if output_path content end |