Module: Ruflet::CLI::UpdateCommand
Constant Summary collapse
- VALID_UPDATE_PLATFORMS =
%w[macos linux windows].freeze
Constants included from RunCommand
RunCommand::DEFAULT_BACKEND_PORTS
Instance Method Summary collapse
Methods included from RunCommand
Instance Method Details
#command_update(args) ⇒ Object
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 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 78 79 80 81 82 83 84 85 |
# File 'lib/ruflet/cli/update_command.rb', line 12 def command_update(args) = { web: false, desktop: false, check: false, force: false, platform: nil } parser = OptionParser.new do |o| o.on("--web") { [:web] = true } o.on("--desktop") { [:desktop] = true } o.on("--check") { [:check] = true } o.on("--force") { [:force] = true } o.on("--platform PLATFORM") { |value| [:platform] = value.to_s.downcase } end parser.parse!(args) args.each do |arg| case arg.to_s.downcase when "web" [:web] = true when "desktop" [:desktop] = true when "all" [:web] = true [:desktop] = true when "check" [:check] = true else warn "Unknown update target: #{arg}" return 1 end end platform = [:platform] || host_platform_name if platform.nil? || !VALID_UPDATE_PLATFORMS.include?(platform) warn "Unsupported or missing platform. Use --platform macos|linux|windows." return 1 end if ![:web] && ![:desktop] [:web] = true [:desktop] = true end targets = [] targets << :web if [:web] targets << :desktop if [:desktop] return check_client_updates(targets, platform: platform) if [:check] ensure_cached_ruflet_assets_for_update(force: [:force]) ensure_flutter!("update", client_dir: nil, auto_install: true) if respond_to?(:ensure_flutter!, true) targets.each do |target| root = if target == :web ensure_prebuilt_client(web: true, platform: platform, force: [:force]) else ensure_prebuilt_client(desktop: true, platform: platform, force: [:force]) end unless root warn "Failed to update #{target} client for #{platform}" return 1 end manifest = read_client_manifest(root) release_label = manifest && manifest["release_tag"] ? manifest["release_tag"] : "unknown release" puts "Updated #{target} client for #{platform} at #{root} (#{release_label})" end 0 end |