Module: Ruflet::CLI::EnvironmentSetup
- Included in:
- BuildCommand, ExtraCommand
- Defined in:
- lib/ruflet/cli/environment_setup.rb
Overview
Provisions the host so ‘ruflet build` can run: checks (and with `ruflet doctor –fix`, installs) the system tools Flutter requires.
Coverage:
Linux apt (Ubuntu, Debian, Kali, Mint), dnf (Fedora, RHEL),
pacman (Arch, Omarchy, Manjaro), zypper (openSUSE)
macOS Homebrew where available, plus Xcode Command Line Tools and
CocoaPods guidance
Windows winget or Chocolatey
Anything that cannot be installed unattended (Xcode CLT, Visual Studio Build Tools) is reported with the exact command the developer must run.
Defined Under Namespace
Classes: Tool
Constant Summary collapse
- LINUX_PACKAGE_MANAGERS =
[ { id: :apt, probe: "apt-get", install: %w[apt-get install -y], update: %w[apt-get update] }, { id: :dnf, probe: "dnf", install: %w[dnf install -y], update: nil }, { id: :pacman, probe: "pacman", install: %w[pacman -S --noconfirm --needed], update: nil }, { id: :zypper, probe: "zypper", install: %w[zypper --non-interactive install], update: nil }, { id: :apk, probe: "apk", install: %w[apk add], update: nil } ].freeze
Instance Method Summary collapse
- #environment_setup!(fix: false, verbose: false) ⇒ Object
- #required_system_tools ⇒ Object
- #system_package_manager ⇒ Object
Instance Method Details
#environment_setup!(fix: false, verbose: false) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ruflet/cli/environment_setup.rb', line 30 def environment_setup!(fix: false, verbose: false) issues = [] tools = required_system_tools unless flutter_host issues << warn " System: #{}" return issues end manager = system_package_manager missing = tools.reject { |tool| tool_present?(tool) } if missing.empty? puts " System tools: ok (#{tools.map(&:name).join(', ')})" return issues end puts " System tools missing: #{missing.map(&:name).join(', ')}" unless fix missing.each { |tool| warn " #{tool.name}: #{manual_hint_for(tool, manager)}" } warn " Run `ruflet doctor --fix` to install them." return missing.map { |tool| "missing #{tool.name}" } end auto, manual = missing.partition { |tool| installable?(tool, manager) } if auto.any? if manager install_system_packages(manager, auto, verbose: verbose) end still_missing = auto.reject { |tool| tool_present?(tool) } still_missing.each do |tool| issues << "missing #{tool.name}" warn " #{tool.name}: install failed — #{manual_hint_for(tool, manager)}" end installed = auto - still_missing puts " Installed: #{installed.map(&:name).join(', ')}" if installed.any? end manual.each do |tool| issues << "missing #{tool.name}" warn " #{tool.name}: requires a manual step — #{manual_hint_for(tool, manager)}" end issues end |
#required_system_tools ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/ruflet/cli/environment_setup.rb', line 79 def required_system_tools case flutter_host when "linux" then linux_required_tools when "macos", "macos_arm64" then macos_required_tools when "windows" then windows_required_tools else [] end end |
#system_package_manager ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ruflet/cli/environment_setup.rb', line 88 def system_package_manager if windows_host? return { id: :winget, install: %w[winget install --accept-source-agreements --accept-package-agreements -e --id] } if which_command("winget") return { id: :choco, install: %w[choco install -y] } if which_command("choco") return nil end if macos_host? return { id: :brew, install: %w[brew install] } if which_command("brew") return nil end LINUX_PACKAGE_MANAGERS.each do |manager| next unless which_command(manager[:probe]) return manager end nil end |