Class: Fastlane::Actions::SentryUploadSourcemapAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/uninow/sentry/actions/sentry_upload_sourcemap.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



114
115
116
# File 'lib/fastlane/plugin/uninow/sentry/actions/sentry_upload_sourcemap.rb', line 114

def self.authors
  ["wschurman"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/uninow/sentry/actions/sentry_upload_sourcemap.rb', line 62

def self.available_options
  Helper::SentryConfig.common_api_config_items + [
    FastlaneCore::ConfigItem.new(key: :version,
                                 description: "Release version on Sentry"),
    FastlaneCore::ConfigItem.new(key: :dist,
                                 description: "Distribution in release",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :sourcemap,
                                 description: "Path to the sourcemap to upload",
                                 verify_block: proc do |value|
                                   UI.user_error! "Could not find sourcemap at path '#{value}'" unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :rewrite,
                                 description: "Rewrite the sourcemaps before upload",
                                 default_value: false,
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :strip_prefix,
                                 conflicting_options: [:strip_common_prefix],
                                 description: "Chop-off a prefix from uploaded files",
                                 default_value: false,
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :strip_common_prefix,
                                 conflicting_options: [:strip_prefix],
                                 description: "Automatically guess what the common prefix is and chop that one off",
                                 default_value: false,
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :url_prefix,
                                 description: "Sets a URL prefix in front of all files",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :app_identifier,
                                 short_option: "-a",
                                 env_name: "SENTRY_APP_IDENTIFIER",
                                 description: "App Bundle Identifier, prepended to version",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :ignore,
                                 description: "Ignores all files and folders matching the given glob or array of globs",
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :ignore_file,
                                 description: "Ignore all files and folders specified in the given ignore file, e.g. .gitignore",
                                 optional: true)

  ]
end

.descriptionObject



51
52
53
# File 'lib/fastlane/plugin/uninow/sentry/actions/sentry_upload_sourcemap.rb', line 51

def self.description
  "Upload a sourcemap to a release of a project on Sentry"
end

.detailsObject



55
56
57
58
59
60
# File 'lib/fastlane/plugin/uninow/sentry/actions/sentry_upload_sourcemap.rb', line 55

def self.details
  [
    "This action allows you to upload a sourcemap to a release of a project on Sentry.",
    "See https://docs.sentry.io/learn/cli/releases/#upload-sourcemaps for more information."
  ].join(" ")
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/fastlane/plugin/uninow/sentry/actions/sentry_upload_sourcemap.rb', line 118

def self.is_supported?(platform)
  true
end

.return_valueObject



110
111
112
# File 'lib/fastlane/plugin/uninow/sentry/actions/sentry_upload_sourcemap.rb', line 110

def self.return_value
  nil
end

.run(params) ⇒ Object



4
5
6
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
43
44
45
# File 'lib/fastlane/plugin/uninow/sentry/actions/sentry_upload_sourcemap.rb', line 4

def self.run(params)
  require 'shellwords'

  Helper::SentryHelper.check_sentry_cli!
  Helper::SentryConfig.parse_api_params(params)

  version = params[:version]
  sourcemap = params[:sourcemap]

  version = "#{params[:app_identifier]}-#{params[:version]}" if params[:app_identifier]

  command = [
    "sentry-cli",
    "releases",
    "files",
    version,
    "upload-sourcemaps",
    sourcemap.to_s
  ]

  command.push('--rewrite') if params[:rewrite]
  command.push('--no-rewrite') unless params[:rewrite]
  command.push('--strip-prefix') if params[:strip_prefix]
  command.push('--strip-common-prefix') if params[:strip_common_prefix]
  command.push('--url-prefix').push(params[:url_prefix]) unless params[:url_prefix].nil?
  command.push('--dist').push(params[:dist]) unless params[:dist].nil?

  unless params[:ignore].nil?
    # normalize to array
    unless params[:ignore].kind_of?(Enumerable)
      params[:ignore] = [params[:ignore]]
    end
    # no nil or empty strings
    params[:ignore].reject! { |e| e.strip.empty? rescue true }
    command.push('--ignore').push(*params[:ignore]) if params[:ignore].any?
  end

  command.push('--ignore-file').push(params[:ignore_file]) unless params[:ignore_file].nil?

  Helper::SentryHelper.call_sentry_cli(command)
  UI.success("Successfully uploaded files to release: #{version}")
end