Class: Everywhere::Commands::Doctor
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Everywhere::Commands::Doctor
- Defined in:
- lib/everywhere/commands/doctor.rb
Overview
Check that this machine can build native apps. Every section always shows, so one run answers "what can this machine build?" — but only the sections the app's build.targets declare (or --target names) gate the exit status: failing doctor over a toolchain the app doesn't use would be a lie, the same reasoning as the cmdline-tools warning below.
Instance Method Summary collapse
Instance Method Details
#call(root: ".", target: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/everywhere/commands/doctor.rb', line 22 def call(root: ".", target: nil, **) ok = config_check(root) @optional_gaps = [] sections = [ ["Desktop", desktop_wanted?(root, target), method(:desktop_checks)], ["iOS", ios_wanted?(root, target), method(:ios_checks)], ["Android", android_wanted?(root, target), method(:android_checks)] ] # The sections that gate the run are the ones the user came to fix, so # they come first; the informational ones read as an appendix. # partition, not sort_by — Ruby's sort isn't stable. required_sections, info_sections = sections.partition { |_, required, _| required } (required_sections + info_sections).each do |name, required, checks| ok &= section(name, required: required) { |req| checks.call(req) } end puts if ok note = @optional_gaps.any? ? " #{UI.dim("(#{@optional_gaps.join(" and ")} would need setup — see above)")}" : "" UI.success("ready to build#{note}") else UI.bad("fix the items above (see https://rubyeverywhere.com/docs/diy/requirements)") end exit(1) unless ok end |