fastlane-plugin-bugsnag_sourcemaps_upload 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 181d0032cede24be37b56dfbb7974fe7ed61e66e9965492475e7f86cef2e4639
4
- data.tar.gz: c359ea182ae35b65558486b9f019b0bdb304e5c6213034cc6e18673c956f452e
3
+ metadata.gz: 0a6aa2675005a171fe06f6667b361df3f9f73f49cf1dd63b7697c77da1e2d019
4
+ data.tar.gz: 82caee4e3f05b789b541b121330504355828e985ce6677ff15142e40babf45f7
5
5
  SHA512:
6
- metadata.gz: 957b8efdb468c7cd6cbca70206e7e32ef021cdd8901fb12d34fb08098bf9b1a6da0a1e0f9f43cab39cfbf4971a7bb118206d2292e8c04ab8c8d0d8e4396dd0cb
7
- data.tar.gz: d85c0a29bfae11fc0ff8d81ef281781e91a2c0ef8e46dab8718837a123ae28bb4eb1268ef3ad8aba41c4aa0019e74bfab1047df4eca0a60255e0ac37b7748e73
6
+ metadata.gz: f3738e4d74c96ac918a48a109f7c3ff19e78124d2ff6574cc4ec033e2030b05a3b7ec968ca49845573edb461bc149fff089528d1ab0fc2364f01b2f5272293ba
7
+ data.tar.gz: 53e3699c3e634f88e4c4dea6e739f8d503303eb8bce5ebcdb3bf24d79a566a88a913dcdad2258498f1af29f7273cc7b848c32aab39088436725af1c7d42c95d1
data/README.md CHANGED
@@ -13,18 +13,53 @@ fastlane add_plugin bugsnag_sourcemaps_upload
13
13
 
14
14
  ## About bugsnag_sourcemaps_upload
15
15
 
16
- Helps to upload sourcemaps to Bugsnag
16
+ Helps to generate and upload React Native sourcemaps to Bugsnag
17
17
 
18
18
 
19
- ## Example
19
+ ### Example
20
20
 
21
- ```
21
+ ```ruby
22
+ # Generate and upload soucemaps
23
+ bugsnag_sourcemaps_upload(
24
+ api_key: 'YOUR_BUGSNAG_API_KEY',
25
+ app_version: '1.0.0'
26
+ )
27
+
28
+ # Uploading Hermes generated soucemaps
22
29
  bugsnag_sourcemaps_upload(
23
30
  api_key: 'YOUR_BUGSNAG_API_KEY',
24
- os: ['ios', 'android']
31
+ app_version: '1.0.0',
32
+ generate_sourcemaps: false,
33
+ platform: 'android',
34
+ sourcemaps_dir: 'android/app/build/generated',
35
+ sourcemap: 'sourcemaps/react/release/index.android.bundle.map',
36
+ bundle: 'assets/react/release/index.android.bundle'
25
37
  )
26
38
  ```
27
39
 
40
+ ### Available options
41
+
42
+ | Option | Description | Environment variable | Default value |
43
+ | - | - | - | - |
44
+ | api_key* | API key | BUGSNAG_API_KEY | |
45
+ | app_version | Target app version | BUGSNAG_SOURCEMAPS_APP_VERSION | |
46
+ | code_bundle_id | CodePush bundle ID | BUGSNAG_SOURCEMAPS_CODE_BUNDLE | |
47
+ | platform | Target platform | BUGSNAG_SOURCEMAPS_PLATFORM | ios |
48
+ | sourcemaps_dir | Sourcemaps directory | BUGSNAG_SOURCEMAPS_DIR | /tmp |
49
+ | sourcemap | Override path to sourcemaps(relative path to sourcemaps_dir) | BUGSNAG_SOURCEMAPS_NAME | *platform*.bundle.map |
50
+ | bundle | Override path to minified file(relative path to sourcemaps_dir) | BUGSNAG_SOURCEMAPS_BUNDLE_NAME | *platform*.bundle |
51
+ | minified_url | Override minified url| BUGSNAG_SOURCEMAPS_MINIFIED_URL | index.android.bundle *or* main.jsbundle |
52
+ | overwrite | Overwrite sourcemaps in Bugsnag | BUGSNAG_SOURCEMAPS_OVERWRITE | true |
53
+ | strip | Strip root | BUGSNAG_SOURCEMAPS_STRIP_PROJECT_ROOT | true |
54
+ | wildcard_prefix | Add wildcard prefix | BUGSNAG_SOURCEMAPS_WILDCARD_PREFIX | false |
55
+ | generate_sourcemaps | Generate sourcemaps using react-native bundle | BUGSNAG_SOURCEMAPS_GENERATE | true |
56
+ | upload_sources | Upload source files referenced by the source map | BUGSNAG_SOURCEMAPS_UPLOAD_SOURCES | true |
57
+ | upload_modules | Upload dependency files referenced by the source map | BUGSNAG_SOURCEMAPS_UPLOAD_MODULES | false
58
+ | entry_file | React-native app index file path | BUGSNAG_SOURCEMAPS_ENTRY_FILE | index.js |
59
+ | endpoint | Bugsnag endpoint(when using Bugsnag On-premise) | BUGSNAG_SOURCEMAPS_ENDPOINT | |
60
+
61
+ \* - required
62
+
28
63
  ## Run tests for this plugin
29
64
 
30
65
  To run both the tests, and code style validation, run
@@ -5,18 +5,48 @@ module Fastlane
5
5
  module Actions
6
6
  class BugsnagSourcemapsUploadAction < Action
7
7
  def self.run(params)
8
- params[:os].each do |os|
9
- Helper::BugsnagSourcemapsUploadHelper.create_bundle(os)
10
- Helper::BugsnagSourcemapsUploadHelper.upload_bundle(params[:api_key], os)
8
+ api_key = params[:api_key]
9
+ app_version = params[:app_version]
10
+ code_bundle_id = params[:code_bundle_id]
11
+ platform = params[:platform]
12
+ dir = params[:sourcemaps_dir]
13
+ sourcemap = params[:sourcemap]
14
+ bundle = params[:bundle]
15
+ minified_url = params[:minified_url]
16
+ overwrite = params[:overwrite]
17
+ strip = params[:strip]
18
+ wildcard_prefix = params[:wildcard_prefix]
19
+ generate_sourcemaps = params[:generate_sourcemaps]
20
+ upload_sources = params[:upload_sources]
21
+ upload_modules = params[:upload_modules]
22
+ entry_file = params[:entry_file]
23
+ endpoint = params[:endpoint]
24
+
25
+ path = ""
26
+ if sourcemap
27
+ path = "#{dir}/#{sourcemap}".to_s
28
+ else
29
+ path = "#{dir}/#{platform}.bundle.map".to_s
30
+ end
31
+ bundle_path = ""
32
+ if bundle
33
+ bundle_path = "#{dir}/#{bundle}".to_s
34
+ else
35
+ bundle_path = "#{dir}/#{platform}.bundle".to_s
36
+ end
37
+
38
+ if generate_sourcemaps
39
+ Helper::BugsnagSourcemapsUploadHelper.create_bundle(platform, entry_file, path, bundle_path)
11
40
  end
41
+ 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)
12
42
  end
13
43
 
14
44
  def self.description
15
- "Helps to upload sourcemaps to Bugsnag"
45
+ "Upload sourcemaps to Bugsnag"
16
46
  end
17
47
 
18
48
  def self.authors
19
- ["Evgrafov Denis"]
49
+ ["Evgrafov Denis", "Ivan Sokolovskii"]
20
50
  end
21
51
 
22
52
  def self.return_value
@@ -25,33 +55,108 @@ module Fastlane
25
55
 
26
56
  def self.details
27
57
  # Optional:
28
- "Helps to upload sourcemaps to Bugsnag"
58
+ "Helps to generate and upload React-Native sourcemaps to Bugsnag"
29
59
  end
30
60
 
31
61
  def self.available_options
32
62
  [
33
- # FastlaneCore::ConfigItem.new(key: :your_option,
34
- # env_name: "BUGSNAG_SOURCEMAPS_UPLOAD_YOUR_OPTION",
35
- # description: "A description of your option",
36
- # optional: false,
37
- # type: String)
38
63
  FastlaneCore::ConfigItem.new(key: :api_key,
39
- description: "Bugsnag API key",
40
- optional: false,
41
- type: String),
42
- FastlaneCore::ConfigItem.new(key: :os,
43
- description: "OS list",
44
- optional: false,
45
- type: Array)
64
+ env_name: "BUGSNAG_API_KEY",
65
+ description: "Bugsnag API key",
66
+ optional: false,
67
+ verify_block: proc do |value|
68
+ UI.user_error!("No Bugsnag API key given, pass using `api_key: 'key'`") unless value && !value.empty?
69
+ end,
70
+ type: String),
71
+ FastlaneCore::ConfigItem.new(key: :app_version,
72
+ env_name: "BUGSNAG_SOURCEMAPS_APP_VERSION",
73
+ description: "Target app version",
74
+ optional: true,
75
+ type: String),
76
+ FastlaneCore::ConfigItem.new(key: :code_bundle_id,
77
+ env_name: "BUGSNAG_SOURCEMAPS_CODE_BUNDLE",
78
+ description: "Codepush bundle ID",
79
+ optional: true,
80
+ type: String),
81
+ FastlaneCore::ConfigItem.new(key: :platform,
82
+ env_name: "BUGSNAG_SOURCEMAPS_PLATFORM",
83
+ description: "Platform",
84
+ optional: true,
85
+ default_value: 'ios',
86
+ type: String),
87
+ FastlaneCore::ConfigItem.new(key: :sourcemaps_dir,
88
+ env_name: "BUGSNAG_SOURCEMAPS_DIR",
89
+ description: "Bugsnag sourcemaps directory",
90
+ optional: true,
91
+ default_value: "/tmp",
92
+ type: String),
93
+ FastlaneCore::ConfigItem.new(key: :sourcemap,
94
+ env_name: "BUGSNAG_SOURCEMAPS_NAME",
95
+ description: "Override path(relative to sourcemaps_dir) to sourcemaps, default is platform-specific",
96
+ optional: true,
97
+ type: String),
98
+ FastlaneCore::ConfigItem.new(key: :bundle,
99
+ env_name: "BUGSNAG_SOURCEMAPS_BUNDLE_NAME",
100
+ description: "Override path(relative to sourcemaps_dir) bundle to upload, default is platform-specific",
101
+ optional: true,
102
+ type: String),
103
+ FastlaneCore::ConfigItem.new(key: :minified_url,
104
+ env_name: "BUGSNAG_SOURCEMAPS_MINIFIED_URL",
105
+ description: "Override Bugsnag mified url, default is platform specific",
106
+ optional: true,
107
+ type: String),
108
+ FastlaneCore::ConfigItem.new(key: :overwrite,
109
+ env_name: "BUGSNAG_SOURCEMAPS_OVERWRITE",
110
+ description: "Overwrite existing sourcemaps in Bugsnag",
111
+ optional: true,
112
+ default_value: true,
113
+ type: Boolean),
114
+ FastlaneCore::ConfigItem.new(key: :strip,
115
+ env_name: "BUGSNAG_SOURCEMAPS_STRIP_PROJECT_ROOT",
116
+ description: "Strip project root",
117
+ optional: true,
118
+ default_value: true,
119
+ type: Boolean),
120
+ FastlaneCore::ConfigItem.new(key: :wildcard_prefix,
121
+ env_name: "BUGSNAG_SOURCEMAPS_WILDCARD_PREFIX",
122
+ description: "Add wildcard prefix for Bugsnag",
123
+ optional: true,
124
+ default_value: false,
125
+ type: Boolean),
126
+ FastlaneCore::ConfigItem.new(key: :generate_sourcemaps,
127
+ env_name: "BUGSNAG_SOURCEMAPS_GENERATE",
128
+ description: "Generate React-Native sourcemaps",
129
+ optional: true,
130
+ default_value: true,
131
+ type: Boolean),
132
+ FastlaneCore::ConfigItem.new(key: :upload_sources,
133
+ env_name: "BUGSNAG_SOURCEMAPS_UPLOAD_MODULES",
134
+ description: "Upload source files referenced by the source map",
135
+ optional: true,
136
+ default_value: true,
137
+ type: Boolean),
138
+ FastlaneCore::ConfigItem.new(key: :upload_modules,
139
+ env_name: "BUGSNAG_SOURCEMAPS_UPLOAD_MODULES",
140
+ description: "Upload dependency files referenced by the source map",
141
+ optional: true,
142
+ default_value: false,
143
+ type: Boolean),
144
+ FastlaneCore::ConfigItem.new(key: :entry_file,
145
+ env_name: "BUGSNAG_SOURCEMAPS_ENTRY_FILE",
146
+ description: "React Native index file for soucemaps generation",
147
+ optional: true,
148
+ default_value: "index.js",
149
+ type: String),
150
+ FastlaneCore::ConfigItem.new(key: :endpoint,
151
+ env_name: "BUGSNAG_SOURCEMAPS_ENDPOINT",
152
+ description: "Bugsnag endpoint(when using Bugsnag On-premise)",
153
+ optional: true,
154
+ type: String)
46
155
  ]
47
156
  end
48
157
 
49
158
  def self.is_supported?(platform)
50
- # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
51
- # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
52
- #
53
- # [:ios, :mac, :android].include?(platform)
54
- true
159
+ [:ios, :android].include?(platform)
55
160
  end
56
161
  end
57
162
  end
@@ -8,14 +8,53 @@ module Fastlane
8
8
  # class methods that you define here become available in your action
9
9
  # as `Helper::BugsnagSourcemapsUploadHelper.your_method`
10
10
  #
11
- def self.create_bundle(os)
11
+ def self.create_bundle(platform, entry_file, path, bundle_path)
12
12
  UI.message("Creating React Native bundle")
13
- Action.sh("react-native bundle --platform #{os} --dev false --entry-file index.js --bundle-output /tmp/#{os}.bundle --sourcemap-output /tmp/#{os}.bundle.map")
13
+ Action.sh("react-native bundle \
14
+ --dev false \
15
+ --platform #{platform} \
16
+ --bundle-output #{bundle_path} \
17
+ --sourcemap-output #{path} \
18
+ --entry-file #{entry_file}")
14
19
  end
15
20
 
16
- def self.upload_bundle(api_key, os)
21
+ def self.upload_bundle(api_key, platform, app_version, code_bundle_id, path, bundle_path, minified_url, strip, overwrite, wildcard_prefix, upload_sources, upload_modules, endpoint)
22
+ command = "bugsnag-sourcemaps upload --api-key #{api_key} --source-map #{path} --minified-file #{bundle_path} "
23
+ if upload_sources
24
+ command += "--upload-sources "
25
+ end
26
+ if upload_modules
27
+ command += "--upload-node-modules "
28
+ end
29
+ if minified_url
30
+ command += "--minified-url #{minified_url} "
31
+ else
32
+ if platform == "ios"
33
+ command += "--minified-url main.jsbundle "
34
+ else
35
+ command += "--minified-url index.android.bundle "
36
+ end
37
+ end
38
+ if app_version
39
+ command += "--app-version=#{app_version} "
40
+ end
41
+ if code_bundle_id
42
+ command += " --code-bundle-id #{code_bundle_id} "
43
+ end
44
+ if strip
45
+ command += "--strip-project-root "
46
+ end
47
+ if overwrite
48
+ command += "--overwrite "
49
+ end
50
+ if wildcard_prefix
51
+ command += "--add-wildcard-prefix "
52
+ end
53
+ if endpoint
54
+ command += "--endpoint #{endpoint} "
55
+ end
17
56
  UI.message("Uploading React Native bundle to Bugsnag")
18
- Action.sh("bugsnag-sourcemaps upload --api-key #{api_key} --source-map /tmp/#{os}.bundle.map --strip-project-root --minified-file /tmp/#{os}.bundle --minified-url index.#{os}.bundle --upload-sources --overwrite")
57
+ Action.sh(command.to_s)
19
58
  end
20
59
 
21
60
  def self.show_message
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module BugsnagSourcemapsUpload
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-bugsnag_sourcemaps_upload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgrafov Denis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-11 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry