Class: Everywhere::Commands::Doctor

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

Overview

Check that this machine can build desktop apps.

Instance Method Summary collapse

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/everywhere/commands/doctor.rb', line 12

def call(**)
  ok = true
  ok &= check("rbe-tebako installed") { Shellout.run?("rbe-tebako help > /dev/null 2>&1") }
  ok &= check("cargo installed")    { Shellout.run?("cargo --version > /dev/null 2>&1") }
  ok &= check("homebrew bison")     { !`brew --prefix bison 2>/dev/null`.strip.empty? }

  if RUBY_PLATFORM.include?("darwin") && clang_major >= 21
    ok &= check("Xcode #{clang_major} CXX shim (~/.tebako-shims/clang++)") do
      File.executable?(File.expand_path("~/.tebako-shims/clang++"))
    end
    ok &= check("tebako force_ruby_platform patch") do
      helper = `gem contents rbe-tebako 2>/dev/null`.lines.map(&:strip).find { |l| l.end_with?("deploy_helper.rb") }
      helper.nil? || File.read(helper).include?(%(@force_ruby_platform = "true"
@nokogiri_option = "--no-use-system-libraries"))
    end
    ok &= check("tebako rbconfig warnflags patch") do
      stash = Dir[File.expand_path("~/.tebako/deps/stash_*/lib/ruby/*/**/rbconfig.rb")]
      stash.empty? || stash.all? { |f| File.read(f).include?("default-const-init") }
    end
  end

  puts
  ok ? UI.success("ready to build") : UI.bad("fix the items above (see project docs / memory for recipes)")
  exit(1) unless ok
end