Class: Everywhere::Commands::Dev

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/everywhere/commands/dev.rb

Overview

Run the app's normal dev server and open native shells pointed at it. No packaging: the desktop shell skips the sidecar when NATIVE_DEV_URL is set, and the iOS shell reads EVERYWHERE_DEV_URL at launch — so the edit-refresh loop is untouched Rails/Hanami either way.

Target flags are additive (--desktop --ios --browser opens all three); with no flags the server boots and a key menu launches shells on demand.

Instance Method Summary collapse

Instance Method Details

#call(port: "3000", shell_dir: nil, target: nil, desktop: false, ios: false, browser: false) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/everywhere/commands/dev.rb', line 31

def call(port: "3000", shell_dir: nil, target: nil, desktop: false, ios: false, browser: false, **)
  @shell_dir = shell_dir
  targets = requested_targets(target, desktop: desktop, ios: ios, browser: browser)
  framework, @config = detect_app

  start_server(framework, port)
  @dev_url = if framework
               "http://127.0.0.1:#{port}#{@config.entry_path}"
             else
               "#{@config.remote_url}#{@config.entry_path}"
             end

  # Headless (non-tty) runs can't take keystrokes, so keep the old
  # default of the desktop shell.
  targets << "desktop" if targets.empty? && !$stdin.tty?
  targets.each { |t| launch(t) }

  $stdin.tty? ? interact : wait_for_children
rescue Interrupt
  nil
ensure
  teardown
end