Class: Aircana::SystemChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/aircana/system_checker.rb

Constant Summary collapse

REQUIRED_COMMANDS =
{
  "fzf" => {
    purpose: "interactive file selection",
    install: {
      "macOS" => "brew install fzf",
      "Ubuntu/Debian" => "apt install fzf",
      "Fedora/CentOS" => "dnf install fzf",
      "Arch" => "pacman -S fzf",
      "Other" => "https://github.com/junegunn/fzf#installation"
    }
  },
  "git" => {
    purpose: "version control operations",
    install: {
      "macOS" => "brew install git",
      "Ubuntu/Debian" => "apt install git",
      "Fedora/CentOS" => "dnf install git",
      "Arch" => "pacman -S git",
      "Other" => "https://git-scm.com/downloads"
    }
  }
}.freeze
OPTIONAL_COMMANDS =
{
  "aws" => {
    purpose: "SQS notifications via AWS CLI",
    fallback: "SQS notifications will be disabled",
    install: {
      "macOS" => "brew install awscli",
      "Ubuntu/Debian" => "apt install awscli",
      "Fedora/CentOS" => "dnf install awscli",
      "Arch" => "pacman -S aws-cli",
      "Other" => "https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"
    }
  },
  "bat" => {
    purpose: "enhanced file previews",
    fallback: "head/cat for basic previews",
    install: {
      "macOS" => "brew install bat",
      "Ubuntu/Debian" => "apt install bat",
      "Fedora/CentOS" => "dnf install bat",
      "Arch" => "pacman -S bat",
      "Other" => "https://github.com/sharkdp/bat#installation"
    }
  },
  "fd" => {
    purpose: "fast file searching",
    fallback: "find command for basic file listing",
    install: {
      "macOS" => "brew install fd",
      "Ubuntu/Debian" => "apt install fd-find",
      "Fedora/CentOS" => "dnf install fd-find",
      "Arch" => "pacman -S fd",
      "Other" => "https://github.com/sharkdp/fd#installation"
    }
  }
}.freeze

Class Method Summary collapse

Class Method Details

.check_configuration_directoriesObject



98
99
100
101
102
103
104
# File 'lib/aircana/system_checker.rb', line 98

def check_configuration_directories
  {
    global: File.expand_path("~/.aircana"),
    claude_global: File.expand_path("~/.claude"),
    claude_project: File.join(Dir.pwd, ".claude")
  }.transform_values { |path| Dir.exist?(path) }
end

.check_dependencies?(show_optional: false) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/aircana/system_checker.rb', line 66

def check_dependencies?(show_optional: false)
  Aircana.human_logger.info "Checking system dependencies..."

  missing_required = check_required_commands
  missing_optional = check_optional_commands if show_optional

  if missing_required.empty? && (missing_optional.nil? || missing_optional.empty?)
    Aircana.human_logger.success "All dependencies satisfied!"
    return true
  end

  show_installation_help(missing_required, missing_optional)
  missing_required.empty? # Return true if no required dependencies missing
end

.claude_installed?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/aircana/system_checker.rb', line 85

def claude_installed?
  command_available?("claude")
end

.command_available?(command) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/aircana/system_checker.rb', line 81

def command_available?(command)
  system("which #{command}", out: File::NULL, err: File::NULL)
end

.detect_linux_distributionObject



121
122
123
124
125
126
127
# File 'lib/aircana/system_checker.rb', line 121

def detect_linux_distribution
  return "Ubuntu/Debian" if File.exist?("/etc/debian_version")
  return "Fedora/CentOS" if fedora_or_centos?
  return "Arch" if File.exist?("/etc/arch-release")

  "Other"
end

.detect_osObject



106
107
108
109
110
111
# File 'lib/aircana/system_checker.rb', line 106

def detect_os
  return "macOS" if macos?
  return detect_linux_distribution if linux?

  "Other"
end

.fedora_or_centos?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/aircana/system_checker.rb', line 129

def fedora_or_centos?
  File.exist?("/etc/fedora-release") || File.exist?("/etc/centos-release")
end

.linux?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/aircana/system_checker.rb', line 117

def linux?
  RbConfig::CONFIG["host_os"].match?(/linux/)
end

.macos?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/aircana/system_checker.rb', line 113

def macos?
  RbConfig::CONFIG["host_os"].match?(/darwin/)
end

.mcp_jira_installed?Boolean

Returns:

  • (Boolean)


89
90
91
92
93
94
95
96
# File 'lib/aircana/system_checker.rb', line 89

def mcp_jira_installed?
  return false unless claude_installed?

  result = `claude mcp get jira 2>&1`
  $CHILD_STATUS.success? && !result.include?("not found") && !result.include?("error")
rescue StandardError
  false
end