Class: Fastlane::Actions::BugsnagSourcemapsUploadAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



48
49
50
# File 'lib/fastlane/plugin/bugsnag_sourcemaps_upload/actions/bugsnag_sourcemaps_upload_action.rb', line 48

def self.authors
  ["Evgrafov Denis", "Ivan Sokolovskii"]
end

.available_optionsObject



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
124
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
# File 'lib/fastlane/plugin/bugsnag_sourcemaps_upload/actions/bugsnag_sourcemaps_upload_action.rb', line 61

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_key,
                            env_name: "BUGSNAG_API_KEY",
                         description: "Bugsnag API key",
                            optional: false,
                        verify_block: proc do |value|
                          UI.user_error!("No Bugsnag API key given, pass using `api_key: 'key'`") unless value && !value.empty?
                        end,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :app_version,
                            env_name: "BUGSNAG_SOURCEMAPS_APP_VERSION",
                         description: "Target app version",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :code_bundle_id,
                            env_name: "BUGSNAG_SOURCEMAPS_CODE_BUNDLE",
                         description: "Codepush bundle ID",
                            optional: true,
                               type: String),
    FastlaneCore::ConfigItem.new(key: :platform,
                            env_name: "BUGSNAG_SOURCEMAPS_PLATFORM",
                         description: "Platform",
                            optional: true,
                       default_value: 'ios',
                                type: String),
    FastlaneCore::ConfigItem.new(key: :sourcemaps_dir,
                            env_name: "BUGSNAG_SOURCEMAPS_DIR",
                         description: "Bugsnag sourcemaps directory",
                            optional: true,
                       default_value: "/tmp",
                                type: String),
    FastlaneCore::ConfigItem.new(key: :sourcemap,
                            env_name: "BUGSNAG_SOURCEMAPS_NAME",
                         description: "Override path(relative to sourcemaps_dir) to sourcemaps, default is platform-specific",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :bundle,
                            env_name: "BUGSNAG_SOURCEMAPS_BUNDLE_NAME",
                         description: "Override path(relative to sourcemaps_dir) bundle to upload, default is platform-specific",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :minified_url,
                            env_name: "BUGSNAG_SOURCEMAPS_MINIFIED_URL",
                         description: "Override Bugsnag mified url, default is platform specific",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :overwrite,
                            env_name: "BUGSNAG_SOURCEMAPS_OVERWRITE",
                         description: "Overwrite existing sourcemaps in Bugsnag",
                            optional: true,
                       default_value: true,
                                type: Boolean),
    FastlaneCore::ConfigItem.new(key: :strip,
                            env_name: "BUGSNAG_SOURCEMAPS_STRIP_PROJECT_ROOT",
                         description: "Strip project root",
                            optional: true,
                       default_value: true,
                                type: Boolean),
    FastlaneCore::ConfigItem.new(key: :wildcard_prefix,
                            env_name: "BUGSNAG_SOURCEMAPS_WILDCARD_PREFIX",
                         description: "Add wildcard prefix for Bugsnag",
                            optional: true,
                       default_value: false,
                                type: Boolean),
    FastlaneCore::ConfigItem.new(key: :generate_sourcemaps,
                            env_name: "BUGSNAG_SOURCEMAPS_GENERATE",
                         description: "Generate React-Native sourcemaps",
                            optional: true,
                       default_value: true,
                                type: Boolean),
    FastlaneCore::ConfigItem.new(key: :upload_sources,
                            env_name: "BUGSNAG_SOURCEMAPS_UPLOAD_MODULES",
                         description: "Upload source files referenced by the source map",
                            optional: true,
                       default_value: true,
                                type: Boolean),
    FastlaneCore::ConfigItem.new(key: :upload_modules,
                            env_name: "BUGSNAG_SOURCEMAPS_UPLOAD_MODULES",
                         description: "Upload dependency files referenced by the source map",
                            optional: true,
                       default_value: false,
                                type: Boolean),
    FastlaneCore::ConfigItem.new(key: :entry_file,
                            env_name: "BUGSNAG_SOURCEMAPS_ENTRY_FILE",
                         description: "React Native index file for soucemaps generation",
                            optional: true,
                       default_value: "index.js",
                                type: String),
    FastlaneCore::ConfigItem.new(key: :endpoint,
                            env_name: "BUGSNAG_SOURCEMAPS_ENDPOINT",
                         description: "Bugsnag endpoint(when using Bugsnag On-premise)",
                            optional: true,
                                type: String)
  ]
end

.descriptionObject



44
45
46
# File 'lib/fastlane/plugin/bugsnag_sourcemaps_upload/actions/bugsnag_sourcemaps_upload_action.rb', line 44

def self.description
  "Upload sourcemaps to Bugsnag"
end

.detailsObject



56
57
58
59
# File 'lib/fastlane/plugin/bugsnag_sourcemaps_upload/actions/bugsnag_sourcemaps_upload_action.rb', line 56

def self.details
  # Optional:
  "Helps to generate and upload React-Native sourcemaps to Bugsnag"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/fastlane/plugin/bugsnag_sourcemaps_upload/actions/bugsnag_sourcemaps_upload_action.rb', line 158

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

.return_valueObject



52
53
54
# File 'lib/fastlane/plugin/bugsnag_sourcemaps_upload/actions/bugsnag_sourcemaps_upload_action.rb', line 52

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



7
8
9
10
11
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
# File 'lib/fastlane/plugin/bugsnag_sourcemaps_upload/actions/bugsnag_sourcemaps_upload_action.rb', line 7

def self.run(params)
  api_key = params[:api_key]
  app_version = params[:app_version]
  code_bundle_id = params[:code_bundle_id]
  platform = params[:platform]
  dir = params[:sourcemaps_dir]
  sourcemap = params[:sourcemap]
  bundle = params[:bundle]
  minified_url = params[:minified_url]
  overwrite = params[:overwrite]
  strip = params[:strip]
  wildcard_prefix = params[:wildcard_prefix]
  generate_sourcemaps = params[:generate_sourcemaps]
  upload_sources = params[:upload_sources]
  upload_modules = params[:upload_modules]
  entry_file = params[:entry_file]
  endpoint = params[:endpoint]

  path = ""
  if sourcemap
    path = "#{dir}/#{sourcemap}".to_s
  else
    path = "#{dir}/#{platform}.bundle.map".to_s
  end
  bundle_path = ""
  if bundle
    bundle_path = "#{dir}/#{bundle}".to_s
  else
    bundle_path = "#{dir}/#{platform}.bundle".to_s
  end

  if generate_sourcemaps
    Helper::BugsnagSourcemapsUploadHelper.create_bundle(platform, entry_file, path, bundle_path)
  end
  Helper::BugsnagSourcemapsUploadHelper.upload_bundle(api_key, platform, app_version, code_bundle_id, path, bundle_path, minified_url, strip, overwrite, wildcard_prefix, upload_sources, upload_modules, endpoint)
end