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.

Constant Summary collapse

IOS_TARGET =
"ios-arm64"
ANDROID_TARGET =
"android-arm64"

Instance Method Summary collapse

Instance Method Details

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



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/everywhere/commands/dev.rb', line 38

def call(port: "3000", shell_dir: nil, target: nil, desktop: false, ios: false, android: false,
         browser: false, dev_url: nil, **)
  @shell_dir = shell_dir
  @port = port
  @dev_url_override = dev_url
  targets = requested_targets(target, desktop: desktop, ios: ios, android: android, 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