Class: Fastlane::Actions::CharlesAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



31
32
33
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 31

def self.authors
  ['jakekrog']
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 42

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :app_path,
      env_name: 'FL_CHARLES_APP_PATH',
      description: 'Path to Charles application executable',
      default_value: '/Applications/Charles.app/Contents/MacOS/Charles',
      optional: true,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :config_path,
      env_name: 'FL_CHARLES_CONFIG_PATH',
      description: 'Path to a simplified Charles YAML config (see example/charles.yml), used to generate a Charles .config file at runtime',
      default_value: 'charles.yml',
      optional: true,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :registered_name,
      env_name: 'FL_CHARLES_REGISTERED_NAME',
      description: 'Registered name for your Charles Proxy license',
      optional: true,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :registered_key,
      env_name: 'FL_CHARLES_REGISTERED_KEY',
      description: 'License key for your Charles Proxy registration',
      optional: true,
      sensitive: true,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :ip_ranges,
      env_name: 'FL_CHARLES_IP_RANGES',
      description: 'IP ranges permitted to access the proxy, in CIDR notation or as bare IPs (treated as /32)',
      optional: true,
      type: Array,
      default_value: []
    )
  ]
end

.categoryObject



99
100
101
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 99

def self.category
  :misc
end

.descriptionObject



27
28
29
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 27

def self.description
  'Run Charles HTTP proxy'
end

.detailsObject



38
39
40
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 38

def self.details
  'This action starts Charles Proxy, generating its .config file at runtime from a simplified YAML config (see example/charles.yml). You can specify the path to the Charles application and the YAML config either through command-line arguments or environment variables.'
end

.example_codeObject



90
91
92
93
94
95
96
97
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 90

def self.example_code
  [
    'charles # Use default paths',
    'charles(app_path: "/path/to/Charles.app/Contents/MacOS/Charles")',
    'charles(config_path: "/path/to/charles.yml")',
    'charles(app_path: "/custom/path/to/Charles", config_path: "/custom/path/to/charles.yml")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 86

def self.is_supported?(platform)
  true
end

.return_valueObject



35
36
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 35

def self.return_value
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fastlane/plugin/charles/actions/charles_action.rb', line 9

def self.run(params)
  charles_app_path = params[:app_path]
  yaml_config_path = params[:config_path]
  config_xml = Helper::CharlesHelper.generate_config_xml(
    yaml_config_path,
    registered_name: params[:registered_name],
    registered_key: params[:registered_key],
    ip_ranges: params[:ip_ranges]
  )

  Dir.mktmpdir('fastlane-charles-') do |tmp_dir|
    charles_config_path = File.join(tmp_dir, 'charles.config')
    File.write(charles_config_path, config_xml)

    Actions.sh(charles_app_path, '-config', charles_config_path)
  end
end