Module: Ruflet::CLI::BuildCommand

Includes:
FlutterSdk
Included in:
Ruflet::CLI
Defined in:
lib/ruflet/cli/build_command.rb

Constant Summary collapse

CLIENT_EXTENSION_MAP =
{
  "ads" => { package: "flet_ads", alias: "ruflet_ads" },
  "audio" => { package: "flet_audio", alias: "ruflet_audio" },
  "audio_recorder" => { package: "flet_audio_recorder", alias: "ruflet_audio_recorder" },
  "camera" => { package: "flet_camera", alias: "ruflet_camera" },
  "charts" => { package: "flet_charts", alias: "ruflet_charts" },
  "code_editor" => { package: "flet_code_editor", alias: "ruflet_code_editor" },
  "color_pickers" => { package: "flet_color_pickers", alias: "ruflet_color_picker" },
  "datatable2" => { package: "flet_datatable2", alias: "ruflet_datatable2" },
  "flashlight" => { package: "flet_flashlight", alias: "ruflet_flashlight" },
  "geolocator" => { package: "flet_geolocator", alias: "ruflet_geolocator" },
  "lottie" => { package: "flet_lottie", alias: "ruflet_lottie" },
  "map" => { package: "flet_map", alias: "ruflet_map" },
  "permission_handler" => { package: "flet_permission_handler", alias: "ruflet_permission_handler" },
  "secure_storage" => { package: "flet_secure_storage", alias: "ruflet_secure_storage" },
  "video" => { package: "flet_video", alias: "ruflet_video" },
  "webview" => { package: "flet_webview", alias: "ruflet_webview" }
}.freeze

Constants included from FlutterSdk

FlutterSdk::DEFAULT_FLUTTER_CHANNEL, FlutterSdk::RELEASES_BASE

Instance Method Summary collapse

Methods included from FlutterSdk

#ensure_flutter!

Instance Method Details

#command_build(args) ⇒ 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
# File 'lib/ruflet/cli/build_command.rb', line 30

def command_build(args)
  platform = (args.shift || "").downcase
  if platform.empty?
    warn "Usage: ruflet build <apk|android|ios|aab|web|macos|windows|linux>"
    return 1
  end

  flutter_cmd = flutter_build_command(platform)
  unless flutter_cmd
    warn "Unsupported build target: #{platform}"
    return 1
  end

  client_dir = detect_flutter_client_dir
  unless client_dir
    warn "Could not find Flutter client directory."
    warn "Set RUFLET_CLIENT_DIR or place client at ./ruflet_client"
    return 1
  end

  config = load_ruflet_config
  tools = ensure_flutter!("build", client_dir: client_dir)
  ok = prepare_flutter_client(client_dir, tools: tools, config: config)
  return 1 unless ok

  build_args = [*flutter_cmd, *args]
  client_url = configured_client_url(config)
  if client_url
    build_args += ["--dart-define", "RUFLET_CLIENT_URL=#{client_url}"]
  end

  ok = system(tools[:env], tools[:flutter], *build_args, chdir: client_dir)
  ok ? 0 : 1
end