Module: Ruflet::CLI::BuildCommand
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" }, "rive" => { package: "flet_rive", alias: "ruflet_rive" }, "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
- PROTECTED_SERVICE_EXTENSIONS =
{ "camera" => %w[camera permission_handler], "microphone" => %w[audio_recorder permission_handler], "location" => %w[geolocator permission_handler], "motion" => %w[permission_handler] }.freeze
- ANDROID_SERVICE_PERMISSIONS =
{ "camera" => %w[android.permission.CAMERA], "microphone" => %w[android.permission.RECORD_AUDIO], "location" => %w[android.permission.ACCESS_COARSE_LOCATION android.permission.ACCESS_FINE_LOCATION], "motion" => %w[android.permission.ACTIVITY_RECOGNITION android.permission.HIGH_SAMPLING_RATE_SENSORS] }.freeze
- IOS_SERVICE_USAGE_KEYS =
{ "camera" => "NSCameraUsageDescription", "microphone" => "NSMicrophoneUsageDescription", "location" => "NSLocationWhenInUseUsageDescription", "motion" => "NSMotionUsageDescription" }.freeze
Constants included from FlutterSdk
FlutterSdk::DEFAULT_FLUTTER_CHANNEL, FlutterSdk::RELEASES_BASE
Instance Method Summary collapse
Methods included from FlutterSdk
#ensure_flutter!, #flutter_version_summary
Instance Method Details
#command_build(args) ⇒ Object
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/ruflet/cli/build_command.rb', line 54 def command_build(args) self_contained = args.delete("--self") verbose = args.delete("--verbose") || args.delete("-v") platform = (args.shift || "").downcase if platform.empty? warn "Usage: ruflet build <apk|android|ios|aab|web|macos|windows|linux> [--self] [--verbose]" return 1 end flutter_cmd = flutter_build_command(platform) unless flutter_cmd warn "Unsupported build target: #{platform}" return 1 end ensure_ruflet_build_assets(verbose: !!verbose) client_dir = ensure_flutter_client_dir(verbose: !!verbose) unless client_dir warn "Could not find Flutter client directory." warn "Set RUFLET_CLIENT_DIR or let Ruflet manage the client under ./build/client" return 1 end build_note("Preparing #{platform} build (#{self_contained ? 'self-contained' : 'server-driven'})") config = load_ruflet_config tools = ensure_flutter!("build", client_dir: client_dir) command_env = build_tool_env(tools[:env], platform, client_dir) ok = prepare_flutter_client( client_dir, platform: platform, tools: tools.merge(env: command_env), config: config, self_contained: !!self_contained, verbose: !!verbose ) return 1 unless ok build_args = [*flutter_cmd, *args] build_args << "--codesign" if ios_device_build_needs_codesign_flag?(platform, build_args) target_entrypoint = flutter_target_entrypoint(client_dir, self_contained: !!self_contained) build_args += ["--target", target_entrypoint] if target_entrypoint backend_url = configured_backend_url(config) if self_contained build_args += ["--dart-define", "RUFLET_BACKEND_URL=#{backend_url}"] if backend_url # Pin the embedded project so main.self.dart extracts assets/<name>/ # deterministically instead of inferring from a single main.rb — the # app tree now ships many main.rb files (standalone_apps/*/main.rb). build_args += ["--dart-define", "RUFLET_EMBEDDED_PROJECT=#{self_contained_project_name}"] else unless backend_url warn "build config error: backend_url is required for server-driven builds" warn "Set app.backend_url or backend_url in ruflet.yaml" return 1 end build_args += ["--dart-define", "RUFLET_BACKEND_URL=#{backend_url}"] end build_args << "-v" if verbose build_log(verbose, "mode=#{self_contained ? 'self' : 'server'}") build_log(verbose, "client_dir=#{client_dir}") build_log(verbose, "flutter=#{tools[:flutter]}") build_log(verbose, "dart=#{tools[:dart]}") build_log(verbose, "target=#{target_entrypoint}") if target_entrypoint build_log(verbose, "command=#{([tools[:flutter]] + build_args).join(' ')}") build_note("Running Flutter #{build_args.join(' ')}") ok = run_external_command(command_env, tools[:flutter], *build_args, chdir: client_dir, unbundled: true) export_platform_build_outputs(client_dir, platform, verbose: !!verbose) if ok ok ? 0 : 1 end |
#command_install(args) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/ruflet/cli/build_command.rb', line 125 def command_install(args) verbose = args.delete("--verbose") || args.delete("-v") device_id = extract_option_value!(args, "--device", "-d") client_dir = ensure_flutter_client_dir(verbose: !!verbose) unless client_dir warn "Could not find Flutter client directory." warn "Set RUFLET_CLIENT_DIR or let Ruflet manage the client under ./build/client" return 1 end tools = ensure_flutter!("install", client_dir: client_dir) command_env = install_tool_env(tools[:env], client_dir) install_platform = install_platform_for_device(device_id) unless sync_built_outputs_for_install(client_dir, platform: install_platform, verbose: !!verbose) warn "Could not find built app outputs under ./build" warn "Run `ruflet build ...` first, then `ruflet install`." return 1 end unless validate_install_artifacts(client_dir, platform: install_platform, device_id: device_id) return 1 end install_args = ["install"] install_args += ["-d", device_id] if device_id install_args << "-v" if verbose build_log(verbose, "client_dir=#{client_dir}") build_log(verbose, "flutter=#{tools[:flutter]}") build_log(verbose, "dart=#{tools[:dart]}") build_log(verbose, "install_command=#{([tools[:flutter]] + install_args).join(' ')}") build_note("Installing app#{device_id ? " to device #{device_id}" : ""}") ok = run_external_command(command_env, tools[:flutter], *install_args, chdir: client_dir, unbundled: true) ok ? 0 : 1 end |