fastlane-plugin-wpmreleasetoolkit 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab2ce164571f692b1378b62adade73faab9e319127ecd08b86a131a490d5185d
4
- data.tar.gz: 3a0eb54e84aeeb1df3d71f5e7d91c586c3427c7055545fd28bc3b7a2cfcdb9cb
3
+ metadata.gz: 858fcaeb7ccaa13b2b3990d36aa1c9aa15f9f9cb90c7ee7bb6941442f2c97847
4
+ data.tar.gz: '067942032d28224600deae4333b427e3eda6af56d65fb83eefb5ef4e3c07b868'
5
5
  SHA512:
6
- metadata.gz: ab32b891a6e254a1406241624dd6117e233ebe541f40b405d614d2cb827e73f904b71afe9e1d1c8cf6f067c1285b05bb452d4137af7b8886ee20793e67e243c7
7
- data.tar.gz: b61749dedc931a5e58cbf3357f6c24fcdf01e5a704648d9b082f51b4ce44b5f0b11457ce593efe684bb2c88eebfcbf70164de13bda199bcc1f988b3dbfbe825e
6
+ metadata.gz: eb6a9f16072c66b7458d4a0787b300cdddd0d87ae99cc886ecc5d64a733d11f046a27c6167b7150fd73c358d9f6c3c85e03b10d4b5c76202fa5273560b5b523e
7
+ data.tar.gz: ca606aef9d929fe6ae3c1f821575e07fc4b672929b61ad7174a1f7e43dea8c2698ed63c696c62506beca226581f726fccadc01930e15b5e8088aa7908e2f0a6c
@@ -19,14 +19,14 @@ module Fastlane
19
19
 
20
20
  params[:locales].each do |loc|
21
21
  if loc.is_a?(Array)
22
- puts "Downloading language: #{loc[1]}"
23
- complete_url = "#{params[:project_url]}#{loc[0]}/default/export-translations?filters[status]=current&format=json"
22
+ UI.message "Downloading language: #{loc[1]}"
23
+ complete_url = "#{params[:project_url]}#{loc[0]}/default/export-translations/?filters[status]=current&format=json"
24
24
  downloader.download(loc[1], complete_url, loc[1] == params[:source_locale])
25
25
  end
26
26
 
27
27
  if loc.is_a?(String)
28
- puts "Downloading language: #{loc}"
29
- complete_url = "#{params[:project_url]}#{loc}/default/export-translations?filters[status]=current&format=json"
28
+ UI.message "Downloading language: #{loc}"
29
+ complete_url = "#{params[:project_url]}#{loc}/default/export-translations/?filters[status]=current&format=json"
30
30
  downloader.download(loc, complete_url, loc == params[:source_locale])
31
31
  end
32
32
  end
@@ -33,7 +33,6 @@ module Fastlane
33
33
  raise
34
34
  end
35
35
 
36
- Action.sh('rake dependencies:pod:clean')
37
36
  other_action.cocoapods()
38
37
  end
39
38
 
@@ -16,12 +16,7 @@ module Fastlane
16
16
  def download(target_locale, glotpress_url, is_source)
17
17
  uri = URI(glotpress_url)
18
18
  response = Net::HTTP.get_response(uri)
19
- response = Net::HTTP.get_response(URI.parse(response.header['location'])) if response.code == '301'
20
-
21
- @alternates.clear
22
- loc_data = JSON.parse(response.body) rescue loc_data = nil
23
- parse_data(target_locale, loc_data, is_source)
24
- reparse_alternates(target_locale, loc_data, is_source) unless @alternates.length == 0
19
+ handle_glotpress_download(response: response, locale: target_locale, is_source: is_source)
25
20
  end
26
21
 
27
22
  # Parse JSON data and update the local files
@@ -100,6 +95,34 @@ module Fastlane
100
95
  def get_target_file_path(locale, file_name)
101
96
  "#{@target_folder}/#{locale}/#{file_name}"
102
97
  end
98
+
99
+ private
100
+
101
+ def handle_glotpress_download(response:, locale:, is_source:)
102
+ case response.code
103
+ when '200'
104
+ # All good, parse the result
105
+ UI.success("Successfully downloaded `#{locale}`.")
106
+ @alternates.clear
107
+ loc_data = JSON.parse(response.body) rescue loc_data = nil
108
+ parse_data(locale, loc_data, is_source)
109
+ reparse_alternates(target_locale, loc_data, is_source) unless @alternates.length == 0
110
+ when '301'
111
+ # Follow the redirect
112
+ UI.message("Received 301 for `#{locale}`. Following redirect...")
113
+ download(locale, response.header['location'], is_source)
114
+ when '429'
115
+ # We got rate-limited, offer to try again
116
+ if UI.confirm("Retry downloading `#{locale}` after receiving 429 from the API?")
117
+ download(locale, response.uri, is_source)
118
+ else
119
+ UI.error("Abandoning `#{locale}` download as requested.")
120
+ end
121
+ else
122
+ message = "Received unexpected #{response.code} from request to URI #{response.uri}."
123
+ UI.abort_with_message!(message) unless UI.confirm("#{message} Continue anyway?")
124
+ end
125
+ end
103
126
  end
104
127
  end
105
128
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Wpmreleasetoolkit
3
- VERSION = '5.4.0'
3
+ VERSION = '5.5.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-wpmreleasetoolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-19 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport