fastlane-plugin-wpmreleasetoolkit 4.1.0 → 4.2.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: ee81192aaa403dc7878821f60017e13f9867c549ba84ba2912d1e3ae0623b7b8
4
- data.tar.gz: a702bfd98e9134e8d3f4303a1bad07705e6b27c107ead1295f5583a78b40384e
3
+ metadata.gz: f87869bd0429895cc6f445950c7e6fca7d778021656483f1b0f4cc232487e2a1
4
+ data.tar.gz: e478fc6f8cd0b3b4baa9431502b7ee6f95e94ab3553bae728d7077e7c9e39adf
5
5
  SHA512:
6
- metadata.gz: 87379c5741f84f94127d0388e24080c9e861a37115c16b5e6116afd7e1e13c143c748624870740ff2c25c82eb450d910219abd9c56bddf9fabfcb5494f826df4
7
- data.tar.gz: 51493b07f6a15c38147e7b25607b63d4f5808ee334ff0ec7a3a65d52f33cf8a4d71a46aa189f680324ca67023d1072f2b9a115899b4cecabe0ad90c92ccdfe91
6
+ metadata.gz: c62ae7d95211059423e61feb22558e79a42da9587f76a1ed0c7c5319de2650a0936d1daeb8f7db9c1a359369bab098b52dc3ea188834e6551bd3f1b479414aab
7
+ data.tar.gz: ed0fc3ef8429091aeb9c83d9e1efeb4909234aa47b733e574546f7297b9c0c7913829889f687cfab55d139f294b00de0eb1f5b4e9064e21c78144697b6683230
@@ -1,4 +1,3 @@
1
- require 'fastlane/action'
2
1
  require_relative '../../helper/metadata_update_helper'
3
2
 
4
3
  module Fastlane
@@ -2,10 +2,20 @@ module Fastlane
2
2
  module Actions
3
3
  class IosLintLocalizationsAction < Action
4
4
  def self.run(params)
5
- violations = {}
5
+ violations = Hash.new([])
6
6
 
7
7
  loop do
8
- violations = self.run_linter(params)
8
+ # If we did `violations = self.run...` we'd lose the default value for missing key being `[]` that we set above with `Hash.new`.
9
+ # We want that default value so that we can use `+=` when adding the duplicate keys violations below.
10
+ violations = violations.merge(self.run_linter(params))
11
+
12
+ if params[:check_duplicate_keys]
13
+ find_duplicated_keys(params).each do |language, duplicates|
14
+ violations[language] += duplicates
15
+ end
16
+ end
17
+
18
+ report(violations: violations, base_lang: params[:base_lang])
9
19
  break unless !violations.empty? && params[:allow_retry] && UI.confirm(RETRY_MESSAGE)
10
20
  end
11
21
 
@@ -22,17 +32,38 @@ module Fastlane
22
32
  install_path: resolve_path(params[:install_path]),
23
33
  version: params[:version]
24
34
  )
25
- all_violations = helper.run(
35
+
36
+ helper.run(
26
37
  input_dir: resolve_path(params[:input_dir]),
27
38
  base_lang: params[:base_lang],
28
39
  only_langs: params[:only_langs]
29
40
  )
41
+ end
42
+
43
+ def self.report(violations:, base_lang:)
44
+ violations.each do |lang, lang_violations|
45
+ UI.error "Inconsistencies found between '#{base_lang}' and '#{lang}':\n\n#{lang_violations.join("\n")}\n"
46
+ end
47
+ end
48
+
49
+ def self.find_duplicated_keys(params)
50
+ duplicate_keys = {}
30
51
 
31
- all_violations.each do |lang, lang_violations|
32
- UI.error "Inconsistencies found between '#{params[:base_lang]}' and '#{lang}':\n\n#{lang_violations.join("\n")}\n"
52
+ files_to_lint = Dir.chdir(params[:input_dir]) do
53
+ Dir.glob('*.lproj/Localizable.strings').map do |file|
54
+ {
55
+ language: File.basename(File.dirname(file), '.lproj'),
56
+ path: File.join(params[:input_dir], file)
57
+ }
58
+ end
33
59
  end
34
60
 
35
- all_violations
61
+ files_to_lint.each do |file|
62
+ duplicates = Fastlane::Helper::Ios::StringsFileValidationHelper.find_duplicated_keys(file: file[:path])
63
+ duplicate_keys[file[:language]] = duplicates.map { |key, value| "`#{key}` was found at multiple lines: #{value.join(', ')}" } unless duplicates.empty?
64
+ end
65
+
66
+ duplicate_keys
36
67
  end
37
68
 
38
69
  RETRY_MESSAGE = <<~MSG
@@ -140,6 +171,14 @@ module Fastlane
140
171
  default_value: false,
141
172
  is_string: false # https://docs.fastlane.tools/advanced/actions/#boolean-parameters
142
173
  ),
174
+ FastlaneCore::ConfigItem.new(
175
+ key: :check_duplicate_keys,
176
+ env_name: 'FL_IOS_LINT_TRANSLATIONS_CHECK_DUPLICATE_KEYS',
177
+ description: 'Checks the input files for duplicate keys',
178
+ optional: true,
179
+ default_value: true,
180
+ is_string: false # https://docs.fastlane.tools/advanced/actions/#boolean-parameters
181
+ ),
143
182
  ]
144
183
  end
145
184
 
@@ -282,9 +282,13 @@ module Fastlane
282
282
  #
283
283
  def self.download_glotpress_export_file(project_url:, locale:, filters:)
284
284
  query_params = filters.transform_keys { |k| "filters[#{k}]" }.merge(format: 'android')
285
- uri = URI.parse("#{project_url.chomp('/')}/#{locale}/default/export-translations?#{URI.encode_www_form(query_params)}")
285
+ uri = URI.parse("#{project_url.chomp('/')}/#{locale}/default/export-translations/?#{URI.encode_www_form(query_params)}")
286
+
287
+ # Set an unambiguous User Agent so GlotPress won't rate-limit us
288
+ options = { 'User-Agent' => Wpmreleasetoolkit::USER_AGENT }
289
+
286
290
  begin
287
- uri.open { |f| Nokogiri::XML(f.read.gsub("\t", ' '), nil, Encoding::UTF_8.to_s) }
291
+ uri.open(options) { |f| Nokogiri::XML(f.read.gsub("\t", ' '), nil, Encoding::UTF_8.to_s) }
288
292
  rescue StandardError => e
289
293
  UI.error "Error downloading #{locale} - #{e.message}"
290
294
  return nil
@@ -143,11 +143,15 @@ module Fastlane
143
143
  #
144
144
  def self.download_glotpress_export_file(project_url:, locale:, filters:, destination:)
145
145
  query_params = (filters || {}).transform_keys { |k| "filters[#{k}]" }.merge(format: 'strings')
146
- uri = URI.parse("#{project_url.chomp('/')}/#{locale}/default/export-translations?#{URI.encode_www_form(query_params)}")
146
+ uri = URI.parse("#{project_url.chomp('/')}/#{locale}/default/export-translations/?#{URI.encode_www_form(query_params)}")
147
+
148
+ # Set an unambiguous User Agent so GlotPress won't rate-limit us
149
+ options = { 'User-Agent' => Wpmreleasetoolkit::USER_AGENT }
150
+
147
151
  begin
148
- IO.copy_stream(uri.open, destination)
152
+ IO.copy_stream(uri.open(options), destination)
149
153
  rescue StandardError => e
150
- UI.error "Error downloading locale `#{locale}` — #{e.message}"
154
+ UI.error "Error downloading locale `#{locale}` — #{e.message} (#{uri})"
151
155
  return nil
152
156
  end
153
157
  end
@@ -234,7 +234,7 @@ module Fastlane
234
234
  begin
235
235
  tempTextFile = Tempfile.new()
236
236
 
237
- sh('drawText', "html=\"#{text}\"", "maxWidth=#{width}", "maxHeight=#{height}", "output=\"#{tempTextFile.path}\"", "fontSize=#{font_size}", "stylesheet=\"#{stylesheet_path}\"", "alignment=\"#{position}\"")
237
+ Action.sh('drawText', "html=#{text}", "maxWidth=#{width}", "maxHeight=#{height}", "output=#{tempTextFile.path}", "fontSize=#{font_size}", "stylesheet=#{stylesheet_path}", "alignment=#{position}")
238
238
 
239
239
  text_content = open_image(tempTextFile.path).trim
240
240
  text_frame = create_image(width, height)
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Wpmreleasetoolkit
3
+ USER_AGENT = 'Automattic App Release Automator; https://github.com/wordpress-mobile/release-toolkit/'.freeze
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Wpmreleasetoolkit
3
- VERSION = '4.1.0'
3
+ VERSION = '4.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-wpmreleasetoolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorenzo Mattei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-21 00:00:00.000000000 Z
11
+ date: 2022-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy
@@ -382,7 +382,7 @@ files:
382
382
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb
383
383
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb
384
384
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb
385
- - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotifx_prechecks.rb
385
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb
386
386
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb
387
387
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb
388
388
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_trigger_build_action.rb
@@ -429,7 +429,7 @@ files:
429
429
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb
430
430
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb
431
431
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_store_app_sizes.rb
432
- - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotifx_prechecks.rb
432
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotfix_prechecks.rb
433
433
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb
434
434
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb
435
435
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_merge_strings_files.rb
@@ -460,6 +460,7 @@ files:
460
460
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb
461
461
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb
462
462
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/release_notes_helper.rb
463
+ - lib/fastlane/plugin/wpmreleasetoolkit/helper/user_agent.rb
463
464
  - lib/fastlane/plugin/wpmreleasetoolkit/models/configuration.rb
464
465
  - lib/fastlane/plugin/wpmreleasetoolkit/models/file_reference.rb
465
466
  - lib/fastlane/plugin/wpmreleasetoolkit/version.rb