Class: Outset::Commands::Doctor

Inherits:
Object
  • Object
show all
Defined in:
lib/outset/commands/doctor.rb

Constant Summary collapse

CHECKS =
[
  {
    name: "Ruby >= 3.1",
    check: -> { RUBY_VERSION >= "3.1.0" },
    fix:   "Install Ruby 3.1+ via rbenv or asdf"
  },
  {
    name: "Rails installed",
    check: -> { system("which rails > /dev/null 2>&1") },
    fix:   "Run: gem install rails"
  },
  {
    name: "Git installed",
    check: -> { system("which git > /dev/null 2>&1") },
    fix:   "Install git from https://git-scm.com"
  },
  {
    name: "Git user.name configured",
    check: -> { !`git config user.name`.strip.empty? rescue false },
    fix:   "Run: git config --global user.name 'Your Name'"
  },
  {
    name: "Git user.email configured",
    check: -> { !`git config user.email`.strip.empty? rescue false },
    fix:   "Run: git config --global user.email '[email protected]'"
  },
  {
    name: "Outset config file",
    check: -> { File.exist?(Config::CONFIG_FILE) },
    fix:   "Run: outset config init"
  }
].freeze

Instance Method Summary collapse

Instance Method Details

#runObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/outset/commands/doctor.rb', line 39

def run
  UI.info("Checking your environment...\n")
  all_passed = true

  CHECKS.each do |check|
    if check[:check].call
      UI.success(check[:name])
    else
      UI.warn("#{check[:name]}  →  #{check[:fix]}")
      all_passed = false
    end
  end

  puts
  if all_passed
    UI.success("All checks passed. You're ready to use outset!")
  else
    UI.warn("Some checks failed. Fix the issues above and run `outset doctor` again.")
  end
end