Class: Everywhere::Commands::Dev
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Everywhere::Commands::Dev
- 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.
Everything runs concurrently and nothing a shell does can end the session: each build owns a TaskPool thread that catches its own failures, each child's output is relayed through Console tagged with its source, and a Dock keeps the keymap and every target's state pinned to the bottom of the terminal while the logs scroll above it.
Constant Summary collapse
- IOS_TARGET =
"ios-arm64"- ANDROID_TARGET =
"android-arm64"- KEY_FOR =
Key → the target it acts on, for the "press i to try again" hints.
{ ios: "i", android: "a", desktop: "d", web: "r" }.freeze
Instance Method Summary collapse
Instance Method Details
#call(port: "3000", shell_dir: nil, target: nil, desktop: false, ios: false, android: false, mobile: false, browser: false, dev_url: nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/everywhere/commands/dev.rb', line 58 def call(port: "3000", shell_dir: nil, target: nil, desktop: false, ios: false, android: false, mobile: false, browser: false, dev_url: nil, **) @shell_dir = shell_dir @port = port @dev_url_override = dev_url # Children are spawned from pool threads as well as the main one. @pids = {} @relays = {} @children = Mutex.new targets = requested_targets(target, desktop: desktop, ios: ios, android: android, mobile: mobile, browser: browser) @framework, @config = detect_app @pool = TaskPool.new(on_error: method(:report_failure)) @dock = Dock.open(dock_targets(targets), keys: $stdin.tty?) 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 : run_headless rescue Interrupt nil ensure teardown end |