Class: Fastlane::Actions::AnnaiOpenEmulatorsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb

Overview


AnnaiOpenEmulatorsAction


Class Method Summary collapse

Class Method Details

.available_optionsObject


Define Parameters




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
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 54

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :platform,
                                 description: "The platform (:ios or :android)",
                                 is_string: false,
                                 verify_block: proc do |value|
                                    UI.user_error!("Platform must be :ios or :android") unless [:ios, :android].include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :test_spec_file,
                                 description: "Path to the annai test spec configuration file (relative to flutter root). Defaults to standard discovery",
                                 optional: true,
                                 default_value: nil),

    FastlaneCore::ConfigItem.new(key: :emulator,
                                 description: "The specific emulator/device name (as defined in the test spec) to open. If nil, all defined emulators for the platform will be opened.",
                                 optional: true,
                                 type: String,
                                 default_value: nil),
    FastlaneCore::ConfigItem.new(key: :wipe_data,
                                 description: "If true, wipes the emulator data before opening.",
                                 type: Boolean,
                                 default_value: true),
    FastlaneCore::ConfigItem.new(key: :dns_server,
                                 description: "Optional DNS server address for Android emulators (e.g., 8.8.8.8). Ignored for iOS.",
                                 optional: true,
                                 type: String,
                                 default_value: "")
  ].compact
end

.descriptionObject



84
85
86
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 84

def self.description
  "Opens the specified emulators or all emulators defined in the Annai test spec file."
end

.example_codeObject



92
93
94
95
96
97
98
99
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 92

def self.example_code
  'annai_open_emulators(
    platform: :android,
    emulator: "Pixel_5_API_30",
    wipe_data: true,
    dns_server: "8.8.8.8"
  )'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 88

def self.is_supported?(platform)
  [:ios, :android].include?(platform)
end

.run(params) ⇒ Object



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
# File 'lib/fastlane/plugin/ann_flutter_flavor/actions/ann_emulators_action.rb', line 15

def self.run(params)
  platform = params[:platform]
  UI.header("Starting Annai Open Emulators for #{platform}")

  # 1. Determine the necessary paths and managers
  root_folder = FastlaneFlutterFlavor::ProjectUtil.find_flutter_root

  # Resolve the test spec file path
  test_spec_file_input = params[:test_spec_file]
  resolved_test_spec_path = FastlaneFlutterFlavor::ProjectUtil.find_annai_test_spec_path(test_spec_file_input)

  # Status Manager is required by IntegrationTest's constructor, though not strictly needed for open/close
  status_manager = FastlaneFlutterFlavor::StatusManager.new(lane: self)

  # 2. Instantiate IntegrationTest helper
  integration_test = FastlaneFlutterFlavor::IntegrationTest.new(
    lane: self,
    isAndroid: platform == :android,
    isIos: platform == :ios,
    test_spec_file: resolved_test_spec_path,
    statusManager: status_manager,
    root_folder: root_folder
  )

  # 3. Call the openEmulators method
  integration_test.openEmulators(
    options: {
      emulator: params[:emulator],
      wipe_data: params[:wipe_data],
      dns_server: params[:dns_server]
    }
  )

  UI.success("✅ Emulator(s) started successfully for #{platform}.")
end