fastlane-plugin-flutter 0.7.1 → 0.8.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: 9c7e965f5f507ca0c826e6bcaeaad6ce8aa2530285029560b602012e9620e62f
4
- data.tar.gz: 1ea5223f9669e03d80947d92fe4fde83e347c78f82949a096faf4128c7a443a3
3
+ metadata.gz: 2a8c5c397684224bab9705b5f8e2980ea3c49704c25b00a189dbd9fe7ae80175
4
+ data.tar.gz: 7e133c3e06a7a9771eebaa86125f26d125c0e20e0dd3b8312133664d396e707c
5
5
  SHA512:
6
- metadata.gz: 9be42ec972dca0347f3c2d9b7fccd645ca0a505a86ab254d2f78be1a3262bb95660f61e789bf3d6cce8f50e706101564607d8a8d58236920e7be55f8dd50c732
7
- data.tar.gz: 42d2827dc366ff98ed910b3e6421e8cf7c40c156a36826e583c616bc0d453c1370343308ce039fffc5c5063d8bba7e7dfa4d30bac184d9bcc464ddee4472e6c2
6
+ metadata.gz: 188f0c619b42b371c8c166d48e709c44c6d6f0d7943df3f4f551f024837284d6d7d7a17317c085b4f42018ee6e0e1d7aaf5cc6189cf1024f1eff23ba83d6dbc0
7
+ data.tar.gz: 65b3c45bb076916775e34e8d6ba34a05477eac7997aaf31a235d01173e79bc69c50b1c759124169818fb082fa890bc9ef79c522ec9fcd56b1c31aa7e3d9071a9
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../base/flutter_action_base'
3
5
  require_relative '../helper/flutter_helper'
@@ -9,7 +11,7 @@ module Fastlane
9
11
 
10
12
  def self.run(params)
11
13
  if params[:capture_stdout]
12
- Helper::FlutterHelper.flutter(*params[:args]) do |status, output|
14
+ Helper::FlutterHelper.flutter(*params[:args]) do |_status, output|
13
15
  output
14
16
  end
15
17
  else
@@ -27,7 +29,7 @@ module Fastlane
27
29
  key: :args,
28
30
  env_name: 'FL_FLUTTER_ARGS',
29
31
  description: 'Arguments to Flutter command',
30
- type: Array,
32
+ type: Array
31
33
  ),
32
34
  FastlaneCore::ConfigItem.new(
33
35
  key: :capture_stdout,
@@ -35,8 +37,8 @@ module Fastlane
35
37
  description: 'Do not print stdout of the command, but return it',
36
38
  optional: true,
37
39
  type: Boolean,
38
- default_value: false,
39
- ),
40
+ default_value: false
41
+ )
40
42
  ]
41
43
  end
42
44
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../base/flutter_action_base'
3
5
  require_relative '../helper/flutter_helper'
@@ -14,7 +16,7 @@ module Fastlane
14
16
  if params[:android_licenses]
15
17
  Helper::FlutterBootstrapHelper.accept_licenses(
16
18
  File.join(android_sdk_root!, 'licenses'),
17
- params[:android_licenses],
19
+ params[:android_licenses]
18
20
  )
19
21
  end
20
22
 
@@ -38,7 +40,7 @@ module Fastlane
38
40
  '--quiet',
39
41
  '--',
40
42
  FLUTTER_REMOTE_REPOSITORY,
41
- flutter_sdk_root,
43
+ flutter_sdk_root
42
44
  )
43
45
  end
44
46
 
@@ -52,19 +54,19 @@ module Fastlane
52
54
 
53
55
  remote_hash = Helper::FlutterHelper.git(
54
56
  'ls-remote', FLUTTER_REMOTE_REPOSITORY, flutter_channel
55
- ) do |status, output, errors_thread|
57
+ ) do |status, output, _errors_thread|
56
58
  output.split[0].strip if status.success?
57
59
  end
58
60
  local_hash = Helper::FlutterHelper.git(
59
61
  '-C', flutter_sdk_root, 'rev-parse', 'HEAD'
60
- ) do |status, output, errors_thread|
62
+ ) do |status, output, _errors_thread|
61
63
  output.strip if status.success?
62
64
  end
63
65
 
64
66
  if !local_hash.nil? && local_hash == remote_hash
65
- UI.message("Local and remote Flutter repository hashes match " \
67
+ UI.message('Local and remote Flutter repository hashes match ' \
66
68
  "(#{local_hash}), no upgrade necessary. Keeping Git " \
67
- "index untouched!")
69
+ 'index untouched!')
68
70
  false
69
71
  else
70
72
  UI.message("Local hash (#{local_hash}) of Flutter repository " \
@@ -94,7 +96,7 @@ module Fastlane
94
96
  env_name: 'FL_FLUTTER_CHANNEL',
95
97
  description: 'Flutter SDK channel (keep existing if unset)',
96
98
  optional: true,
97
- type: String,
99
+ type: String
98
100
  ),
99
101
  FastlaneCore::ConfigItem.new(
100
102
  key: :flutter_auto_upgrade,
@@ -102,7 +104,7 @@ module Fastlane
102
104
  description: 'Automatically upgrade Flutter when already installed',
103
105
  default_value: true,
104
106
  optional: true,
105
- is_string: false, # official replacement for "type: Boolean"
107
+ is_string: false # official replacement for "type: Boolean"
106
108
  ),
107
109
  FastlaneCore::ConfigItem.new(
108
110
  key: :android_licenses,
@@ -111,8 +113,8 @@ module Fastlane
111
113
  '$ANDROID_SDK_ROOT/licenses/ on developer workstations. Gradle ' \
112
114
  'will refuse to install SDK unless licenses are accepted',
113
115
  optional: true,
114
- type: Hash,
115
- ),
116
+ type: Hash
117
+ )
116
118
  ]
117
119
  end
118
120
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../base/flutter_action_base'
3
5
  require_relative '../helper/flutter_helper'
@@ -13,8 +15,8 @@ module Fastlane
13
15
 
14
16
  FASTLANE_PLATFORM_TO_BUILD = {
15
17
  ios: 'ios',
16
- android: 'apk',
17
- }
18
+ android: 'apk'
19
+ }.freeze
18
20
 
19
21
  def self.run(params)
20
22
  # "flutter build" args list.
@@ -22,28 +24,24 @@ module Fastlane
22
24
 
23
25
  if params[:build]
24
26
  build_args.push(params[:build])
25
- else
26
- if fastlane_platform = (lane_context[SharedValues::PLATFORM_NAME] ||
27
+ elsif (fastlane_platform = lane_context[SharedValues::PLATFORM_NAME] ||
27
28
  lane_context[SharedValues::DEFAULT_PLATFORM])
28
- build_args.push(FASTLANE_PLATFORM_TO_BUILD[fastlane_platform])
29
- else
30
- UI.user_error!('flutter_build action "build" parameter is not ' \
31
- 'specified and cannot be inferred from Fastlane context.')
32
- end
29
+ build_args.push(FASTLANE_PLATFORM_TO_BUILD[fastlane_platform])
30
+ else
31
+ UI.user_error!('flutter_build action "build" parameter is not ' \
32
+ 'specified and cannot be inferred from Fastlane context.')
33
33
  end
34
34
 
35
35
  process_deprecated_params(params, build_args)
36
36
 
37
- if params[:debug]
38
- build_args.push('--debug')
39
- end
37
+ build_args.push('--debug') if params[:debug]
40
38
 
41
- if build_number = (params[:build_number] ||
39
+ if (build_number = params[:build_number] ||
42
40
  lane_context[SharedValues::BUILD_NUMBER])
43
41
  build_args.push('--build-number', build_number.to_s)
44
42
  end
45
43
 
46
- if build_name = (params[:build_name] ||
44
+ if (build_name = params[:build_name] ||
47
45
  lane_context[SharedValues::VERSION_NUMBER])
48
46
  build_args.push('--build-name', build_name.to_s)
49
47
  end
@@ -84,41 +82,41 @@ module Fastlane
84
82
  ENV['GYM_WORKSPACE'] ||= 'ios/Runner.xcworkspace'
85
83
  ENV['GYM_BUILD_PATH'] ||= 'build/ios'
86
84
  ENV['GYM_OUTPUT_DIRECTORY'] ||= 'build'
87
- unless ENV.include?('GYM_SCHEME')
88
- # Do some parsing on args. Is there a less ugly way?
89
- build_args.each.with_index do |arg, index|
90
- if arg.start_with?('--flavor', '-flavor')
91
- if arg.include?('=')
92
- ENV['GYM_SCHEME'] = arg.split('=', 2).last
93
- else
94
- ENV['GYM_SCHEME'] = build_args[index + 1]
95
- end
96
- end
85
+ return if ENV.include?('GYM_SCHEME')
86
+
87
+ # Do some parsing on args. Is there a less ugly way?
88
+ build_args.each.with_index do |arg, index|
89
+ if arg.start_with?('--flavor', '-flavor')
90
+ ENV['GYM_SCHEME'] = if arg.include?('=')
91
+ arg.split('=', 2).last
92
+ else
93
+ build_args[index + 1]
94
+ end
97
95
  end
98
96
  end
99
97
  end
100
98
 
101
99
  def self.process_deprecated_params(params, build_args)
102
- unless params[:codesign].nil?
103
- UI.deprecated(<<-"MESSAGE")
104
- flutter_build parameter "codesign" is deprecated. Use
100
+ return if params[:codesign].nil?
105
101
 
106
- flutter_build(
107
- build_args: ["--#{params[:codesign] == false ? 'no-' : ''}codesign"]
108
- )
102
+ UI.deprecated(<<~"MESSAGE")
103
+ flutter_build parameter "codesign" is deprecated. Use
109
104
 
110
- form instead.
111
- MESSAGE
105
+ flutter_build(
106
+ build_args: ["--#{params[:codesign] == false ? 'no-' : ''}codesign"]
107
+ )
112
108
 
113
- if params[:codesign] == false
114
- build_args.push('--no-codesign')
115
- end
116
- end
109
+ form instead.
110
+ MESSAGE
111
+
112
+ return unless params[:codesign] == false
113
+
114
+ build_args.push('--no-codesign')
117
115
  end
118
116
 
119
117
  def self.process_build_output(output, build_args)
120
- artifacts = output.scan(/Built (.*?)(:? \([^)]*\))?\.$/).
121
- map { |path| File.absolute_path(path[0]) }
118
+ artifacts = output.scan(/Built (.*?)(:? \([^)]*\))?[.]?$/)
119
+ .map { |path| File.absolute_path(path[0]) }
122
120
  if artifacts.size == 1
123
121
  lane_context[SharedValues::FLUTTER_OUTPUT] = artifacts.first
124
122
  elsif artifacts.size > 1
@@ -150,7 +148,7 @@ form instead.
150
148
  env_name: 'FL_FLUTTER_BUILD',
151
149
  description: 'Type of Flutter build (e.g. apk, appbundle, ios)',
152
150
  optional: true,
153
- type: String,
151
+ type: String
154
152
  ),
155
153
  FastlaneCore::ConfigItem.new(
156
154
  key: :debug,
@@ -158,7 +156,7 @@ form instead.
158
156
  description: 'Build a Debug version of the app if true',
159
157
  optional: true,
160
158
  type: Boolean,
161
- default_value: false,
159
+ default_value: false
162
160
  ),
163
161
  FastlaneCore::ConfigItem.new(
164
162
  key: :codesign,
@@ -166,14 +164,14 @@ form instead.
166
164
  description: 'Set to false to skip iOS app signing. This may be ' \
167
165
  'useful e.g. on CI or when signed later by Fastlane "sigh"',
168
166
  optional: true,
169
- type: Boolean,
167
+ type: Boolean
170
168
  ),
171
169
  FastlaneCore::ConfigItem.new(
172
170
  key: :build_number,
173
171
  env_name: 'FL_FLUTTER_BUILD_NUMBER',
174
172
  description: 'Override build number specified in pubspec.yaml',
175
173
  optional: true,
176
- type: Integer,
174
+ type: Integer
177
175
  ),
178
176
  FastlaneCore::ConfigItem.new(
179
177
  key: :build_name,
@@ -183,14 +181,14 @@ form instead.
183
181
  NOTE: for App Store, build name must be in the format of at most 3
184
182
  integeres separated by a dot (".").
185
183
  DESCRIPTION
186
- optional: true,
184
+ optional: true
187
185
  ),
188
186
  FastlaneCore::ConfigItem.new(
189
187
  key: :build_args,
190
188
  description: 'An array of extra arguments for "flutter build"',
191
189
  optional: true,
192
- type: Array,
193
- ),
190
+ type: Array
191
+ )
194
192
  ]
195
193
  end
196
194
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require_relative '../base/flutter_action_base'
3
5
  require_relative '../helper/flutter_helper'
@@ -17,7 +19,7 @@ module Fastlane
17
19
  ALL_IMPORTS_TEST_FILE = 'test/all_imports_for_coverage_test.dart'
18
20
 
19
21
  def self.run(params)
20
- Helper::FlutterHelper.flutter(*%w(packages get)) {}
22
+ Helper::FlutterHelper.flutter(*%w[packages get]) {}
21
23
 
22
24
  if params[:coverage_all_imports] && File.exist?(ALL_IMPORTS_TEST_FILE)
23
25
  # This file may somehow confuse codegeneration (e.g. built_value).
@@ -39,37 +41,37 @@ module Fastlane
39
41
  Helper::FlutterGenerateBuildRunnerHelper.build
40
42
  end
41
43
 
42
- if params[:coverage_all_imports]
43
- UI.message("Generating #{ALL_IMPORTS_TEST_FILE} for coverage...")
44
-
45
- dart_file_literals = Dir['lib/**/*.dart'].reject do |file_name|
46
- # ".g.dart" files often are "part of" files and can not be imported
47
- # directly. Commonly coverage for generated files is not that useful
48
- file_name.end_with?('.g.dart')
49
- end.map do |file_name|
50
- Helper::FlutterHelper.
51
- import_path_for_test(file_name, '..').
52
- gsub("'", "\\\\'")
53
- end
54
-
55
- File.write(
56
- ALL_IMPORTS_TEST_FILE,
57
- <<-DART
58
- // This file is autogenerated by fastlane flutter_generate action.
59
- // It imports all files in lib/ so that test coverage in percentage
60
- // of overall project is calculated correctly. Do not modify this
61
- // file manually!
62
-
63
- // ignore_for_file: unused_import, directives_ordering
64
- // ignore_for_file: avoid_relative_lib_imports
65
- // ignore_for_file: lines_longer_than_80_chars
66
-
67
- #{dart_file_literals.map { |fn| "import '#{fn}';" }.sort.join("\n")}
68
-
69
- void main() {}
70
- DART
71
- )
44
+ return unless params[:coverage_all_imports]
45
+
46
+ UI.message("Generating #{ALL_IMPORTS_TEST_FILE} for coverage...")
47
+
48
+ dart_file_literals = Dir['lib/**/*.dart'].reject do |file_name|
49
+ # ".g.dart" files often are "part of" files and can not be imported
50
+ # directly. Commonly coverage for generated files is not that useful
51
+ file_name.end_with?('.g.dart')
52
+ end.map do |file_name|
53
+ Helper::FlutterHelper
54
+ .import_path_for_test(file_name, '..')
55
+ .gsub("'", "\\\\'")
72
56
  end
57
+
58
+ File.write(
59
+ ALL_IMPORTS_TEST_FILE,
60
+ <<~DART
61
+ // This file is autogenerated by fastlane flutter_generate action.
62
+ // It imports all files in lib/ so that test coverage in percentage
63
+ // of overall project is calculated correctly. Do not modify this
64
+ // file manually!
65
+
66
+ // ignore_for_file: unused_import, directives_ordering
67
+ // ignore_for_file: avoid_relative_lib_imports
68
+ // ignore_for_file: lines_longer_than_80_chars
69
+
70
+ #{dart_file_literals.map { |fn| "import '#{fn}';" }.sort.join("\n")}
71
+
72
+ void main() {}
73
+ DART
74
+ )
73
75
  end
74
76
 
75
77
  def self.generate_translation?
@@ -77,15 +79,15 @@ void main() {}
77
79
  end
78
80
 
79
81
  def self.description
80
- "(1) Run `flutter packages get`; " \
81
- "(2) Run `build_runner build` if build_runner is in dev_dependencies;" \
82
- " " \
83
- "(3) According to `package:intl`, take `$strings_file` and generate " \
84
- "`${strings_file.dirname}/arb/intl_messages.arb`, then take all " \
85
- "files matching `${strings_file.dirname}/intl_*.arb`, fix them and " \
86
- "generate .dart files from them. " \
87
- "(4) Generate an empty test importing all files, which would be used " \
88
- "to calculate correct full coverage numbers."
82
+ '(1) Run `flutter packages get`; ' \
83
+ '(2) Run `build_runner build` if build_runner is in dev_dependencies;' \
84
+ ' ' \
85
+ '(3) According to `package:intl`, take `$strings_file` and generate ' \
86
+ '`${strings_file.dirname}/arb/intl_messages.arb`, then take all ' \
87
+ 'files matching `${strings_file.dirname}/intl_*.arb`, fix them and ' \
88
+ 'generate .dart files from them. ' \
89
+ '(4) Generate an empty test importing all files, which would be used ' \
90
+ 'to calculate correct full coverage numbers.'
89
91
  end
90
92
 
91
93
  def self.available_options
@@ -96,19 +98,15 @@ void main() {}
96
98
  env_name: 'FL_FLUTTER_INTL_STRINGS_FILE',
97
99
  description: 'Path to source .dart file with Intl.message calls',
98
100
  verify_block: proc do |value|
99
- if generate_translation?
100
- unless File.exist?(value)
101
- UI.user_error!("File `#{value}' does not exist")
102
- end
103
- end
101
+ UI.user_error!("File `#{value}' does not exist") if generate_translation? && !File.exist?(value)
104
102
  end,
105
- default_value: 'lib/intl/intl.dart',
103
+ default_value: 'lib/intl/intl.dart'
106
104
  ),
107
105
  FastlaneCore::ConfigItem.new(
108
106
  key: :intl_strings_locale,
109
107
  env_name: 'FL_FLUTTER_INTL_STRINGS_LOCALE',
110
108
  description: 'Locale of the default data in the strings_file',
111
- optional: true,
109
+ optional: true
112
110
  ),
113
111
  FastlaneCore::ConfigItem.new(
114
112
  key: :coverage_all_imports,
@@ -121,8 +119,8 @@ void main() {}
121
119
  to .gitignore!
122
120
  DESCRIPTION
123
121
  optional: true,
124
- type: Boolean,
125
- ),
122
+ type: Boolean
123
+ )
126
124
  ]
127
125
  end
128
126
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
 
3
5
  module Fastlane
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane_core/ui/ui'
2
4
  require 'fileutils'
3
5
 
@@ -10,6 +12,7 @@ module Fastlane
10
12
  license_file = File.join(licenses_directory, license)
11
13
  next if File.exist?(license_file) &&
12
14
  File.readlines(license_file).map(&:strip).include?(hash)
15
+
13
16
  UI.message("Updating Android SDK license in #{license_file}...")
14
17
  File.open(license_file, 'a') { |f| f.puts('', hash) }
15
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
 
3
5
  module Fastlane
@@ -5,7 +7,7 @@ module Fastlane
5
7
  class FlutterGenerateBuildRunnerHelper
6
8
  def self.build
7
9
  Helper::FlutterHelper.flutter(
8
- *%w(packages pub run build_runner build --delete-conflicting-outputs),
10
+ *%w[packages pub run build_runner build --delete-conflicting-outputs]
9
11
  )
10
12
  end
11
13
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
  require 'json'
3
- require 'set'
4
5
  require 'yaml'
5
6
 
6
7
  require_relative 'flutter_helper'
@@ -10,101 +11,101 @@ module Fastlane
10
11
  end
11
12
  end
12
13
 
13
- class Fastlane::Helper::FlutterGenerateIntlHelper
14
- def self.generate(messages_filename, messages_locale = nil)
15
- dart_files_dirname = File.dirname(messages_filename)
16
- arb_files_dirname = File.join(dart_files_dirname, 'arb')
17
- full_arb_filename = generate_arb_from_dart(
18
- messages_filename, messages_locale, arb_files_dirname
19
- )
14
+ module Fastlane
15
+ module Helper
16
+ class FlutterGenerateIntlHelper
17
+ def self.generate(messages_filename, messages_locale = nil)
18
+ dart_files_dirname = File.dirname(messages_filename)
19
+ arb_files_dirname = File.join(dart_files_dirname, 'arb')
20
+ full_arb_filename = generate_arb_from_dart(
21
+ messages_filename, messages_locale, arb_files_dirname
22
+ )
20
23
 
21
- arb_filenames = amend_arb_files(arb_files_dirname, full_arb_filename)
24
+ arb_filenames = amend_arb_files(arb_files_dirname, full_arb_filename)
22
25
 
23
- unless messages_locale
24
- # Don't generate .dart for the ARB generated from original, unless it
25
- # has its own locale.
26
- arb_filenames.delete(full_arb_filename)
27
- end
26
+ unless messages_locale
27
+ # Don't generate .dart for the ARB generated from original, unless it
28
+ # has its own locale.
29
+ arb_filenames.delete(full_arb_filename)
30
+ end
28
31
 
29
- Fastlane::UI.message('Generating .dart files from .arb...')
30
- Fastlane::Helper::FlutterHelper.flutter(
31
- *%W(packages pub run intl_translation:generate_from_arb
32
- --output-dir=#{dart_files_dirname}
33
- --no-use-deferred-loading
34
- #{messages_filename}) + arb_filenames
35
- )
36
- end
32
+ Fastlane::UI.message('Generating .dart files from .arb...')
33
+ Fastlane::Helper::FlutterHelper.flutter(
34
+ *%W[packages pub run intl_translation:generate_from_arb
35
+ --output-dir=#{dart_files_dirname}
36
+ --no-use-deferred-loading
37
+ #{messages_filename}] + arb_filenames
38
+ )
39
+ end
37
40
 
38
- def self.amend_arb_files(arb_files_dirname, full_arb_filename)
39
- full_arb_json = JSON.parse(File.read(full_arb_filename))
40
-
41
- # Sort files for consistency, because generated messages_all.dart will
42
- # have imports ordered as in the command line below.
43
- arb_filenames = Dir.glob(File.join(arb_files_dirname, 'intl_*.arb')).sort
44
- arb_filenames.each do |arb_filename|
45
- arb_json = JSON.parse(File.read(arb_filename))
46
- if arb_filename != full_arb_filename
47
- Fastlane::UI.message("Amending #{arb_filename}...")
48
- full_arb_json.each_pair do |k, v|
49
- # Ignore @@keys. We don't want to copy @@locale over all files, and
50
- # it's often unspecified to be inferred from file name.
51
- arb_json[k] ||= v unless k.start_with?('@@')
41
+ def self.amend_arb_files(arb_files_dirname, full_arb_filename)
42
+ full_arb_json = JSON.parse(File.read(full_arb_filename))
43
+
44
+ # Sort files for consistency, because generated messages_all.dart will
45
+ # have imports ordered as in the command line below.
46
+ arb_filenames = Dir.glob(File.join(arb_files_dirname, 'intl_*.arb')).sort
47
+ arb_filenames.each do |arb_filename|
48
+ arb_json = JSON.parse(File.read(arb_filename))
49
+ if arb_filename != full_arb_filename
50
+ Fastlane::UI.message("Amending #{arb_filename}...")
51
+ full_arb_json.each_pair do |k, v|
52
+ # Ignore @@keys. We don't want to copy @@locale over all files, and
53
+ # it's often unspecified to be inferred from file name.
54
+ arb_json[k] ||= v unless k.start_with?('@@')
55
+ end
56
+ arb_json.keep_if { |k| full_arb_json.key?(k) }
57
+ end
58
+ File.write(arb_filename, "#{JSON.pretty_generate(arb_json)}\n")
52
59
  end
53
- arb_json.keep_if { |k| full_arb_json.key?(k) }
54
60
  end
55
- File.write(arb_filename, JSON.pretty_generate(arb_json) + "\n")
56
- end
57
- end
58
61
 
59
- def self.generate_arb_from_dart(dart_filename, dart_locale, arb_dirname)
60
- arb_filename = File.join(arb_dirname, 'intl_messages.arb')
61
- Fastlane::UI.message("Generating #{arb_filename} from #{dart_filename}...")
62
+ def self.generate_arb_from_dart(dart_filename, dart_locale, arb_dirname)
63
+ arb_filename = File.join(arb_dirname, 'intl_messages.arb')
64
+ Fastlane::UI.message("Generating #{arb_filename} from #{dart_filename}...")
62
65
 
63
- if File.exist?(arb_filename)
64
- arb_file_was = File.read(arb_filename)
65
- else
66
- # The file may not exist on the first run. Then it's also probable that
67
- # the output directory does not exist yet.
68
- FileUtils.mkdir_p(arb_dirname)
69
- end
66
+ if File.exist?(arb_filename)
67
+ arb_file_was = File.read(arb_filename)
68
+ else
69
+ # The file may not exist on the first run. Then it's also probable that
70
+ # the output directory does not exist yet.
71
+ FileUtils.mkdir_p(arb_dirname)
72
+ end
70
73
 
71
- extract_to_arb_options = ["--output-dir=#{arb_dirname}"]
72
- if dart_locale
73
- extract_to_arb_options.push("--locale=#{dart_locale}")
74
- end
74
+ extract_to_arb_options = ["--output-dir=#{arb_dirname}"]
75
+ extract_to_arb_options.push("--locale=#{dart_locale}") if dart_locale
75
76
 
76
- Fastlane::Helper::FlutterHelper.flutter(
77
- *%w(packages pub run intl_translation:extract_to_arb),
78
- *extract_to_arb_options, dart_filename
79
- )
80
-
81
- # intl will update @@last_modified even if there are no updates; this
82
- # leaves Git directory unnecessary dirty. If that's the only change,
83
- # just restore the previous contents.
84
- if arb_file_was
85
- if restore_last_modified(arb_filename, arb_file_was)
86
- Fastlane::UI.message(
87
- "@@last_modified has been restored in #{arb_filename}"
77
+ Fastlane::Helper::FlutterHelper.flutter(
78
+ *%w[packages pub run intl_translation:extract_to_arb],
79
+ *extract_to_arb_options, dart_filename
88
80
  )
81
+
82
+ # intl will update @@last_modified even if there are no updates; this
83
+ # leaves Git directory unnecessary dirty. If that's the only change,
84
+ # just restore the previous contents.
85
+ if arb_file_was && restore_last_modified(arb_filename, arb_file_was)
86
+ Fastlane::UI.message(
87
+ "@@last_modified has been restored in #{arb_filename}"
88
+ )
89
+ end
90
+
91
+ arb_filename
89
92
  end
90
- end
91
93
 
92
- arb_filename
93
- end
94
+ def self.restore_last_modified(filename, old_content)
95
+ new_content_tree = JSON.parse(File.read(filename))
96
+ old_content_tree = JSON.parse(old_content)
97
+ new_content_tree['@@last_modified'] = old_content_tree['@@last_modified']
98
+
99
+ # Use to_json to compare the objects deep and in consistent format.
100
+ if new_content_tree.to_json == old_content_tree.to_json
101
+ # Except for the @@last_modified attribute that we replaced
102
+ # above, the objects are identical. Restore previous timestamp.
103
+ File.write(filename, old_content)
104
+ return true
105
+ end
94
106
 
95
- def self.restore_last_modified(filename, old_content)
96
- new_content_tree = JSON.parse(File.read(filename))
97
- old_content_tree = JSON.parse(old_content)
98
- new_content_tree['@@last_modified'] = old_content_tree['@@last_modified']
99
-
100
- # Use to_json to compare the objects deep and in consistent format.
101
- if new_content_tree.to_json == old_content_tree.to_json
102
- # Except for the @@last_modified attribute that we replaced
103
- # above, the objects are identical. Restore previous timestamp.
104
- File.write(filename, old_content)
105
- return true
107
+ false
108
+ end
106
109
  end
107
-
108
- false
109
110
  end
110
111
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shellwords'
2
4
  require 'yaml'
3
5
 
@@ -28,10 +30,10 @@ module Fastlane
28
30
  elsif ENV.include?('FLUTTER_ROOT')
29
31
  # FLUTTER_ROOT is a standard environment variable from Flutter.
30
32
  UI.message("Determined Flutter location as #{ENV['FLUTTER_ROOT']}" \
31
- " because environment variable FLUTTER_ROOT points there" \
33
+ ' because environment variable FLUTTER_ROOT points there' \
32
34
  " (current directory is #{Dir.pwd}).")
33
35
  ENV['FLUTTER_ROOT']
34
- elsif flutter_binary = FastlaneCore::CommandExecutor.which('flutter')
36
+ elsif (flutter_binary = FastlaneCore::CommandExecutor.which('flutter'))
35
37
  location = File.dirname(File.dirname(flutter_binary))
36
38
  UI.message("Determined Flutter location as #{location} because"\
37
39
  " 'flutter' executable in PATH is located there" \
@@ -39,9 +41,9 @@ module Fastlane
39
41
  location
40
42
  else
41
43
  # Where we'd prefer to install flutter.
42
- UI.message("Determined desired Flutter location as" \
44
+ UI.message('Determined desired Flutter location as' \
43
45
  " #{pinned_flutter_path} because that's where this fastlane" \
44
- " plugin would install Flutter by default.")
46
+ ' plugin would install Flutter by default.')
45
47
  pinned_flutter_path
46
48
  end
47
49
  )
@@ -65,9 +67,7 @@ module Fastlane
65
67
  end
66
68
 
67
69
  def self.import_path_for_test(file_to_import, relative_path)
68
- unless file_to_import.start_with?('lib/')
69
- return File.join(relative_path, file_to_import)
70
- end
70
+ return File.join(relative_path, file_to_import) unless file_to_import.start_with?('lib/')
71
71
 
72
72
  # Import file schema in tests have to match files in lib/ exactly. From
73
73
  # Dart perspective, symbols in files imported via relative and
@@ -78,7 +78,7 @@ module Fastlane
78
78
  # chances are, it's using "package:..." imports. Indeed, checking the
79
79
  # file itself isn't sufficient to explore all of its dependencies, but
80
80
  # we expect imports to be consistent in the project.
81
- "#{package_specification}#{file_to_import['lib/'.size..-1]}"
81
+ "#{package_specification}#{file_to_import['lib/'.size..]}"
82
82
  else
83
83
  File.join(relative_path, file_to_import)
84
84
  end
@@ -102,14 +102,14 @@ module Fastlane
102
102
  end
103
103
 
104
104
  unless wait_thread.value.success? || (ignore_error == true)
105
- UI.shell_error!(<<-ERROR)
106
- The following command has failed:
105
+ UI.shell_error!(<<~ERROR)
106
+ The following command has failed:
107
107
 
108
- $ #{command}
109
- [#{wait_thread.value}]
108
+ $ #{command}
109
+ [#{wait_thread.value}]
110
110
 
111
- #{errors_thread.value}
112
- ERROR
111
+ #{errors_thread.value}
112
+ ERROR
113
113
  end
114
114
 
115
115
  ignore_error
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fastlane
2
4
  module Flutter
3
- VERSION = '0.7.1'
5
+ VERSION = '0.8.0'
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/plugin/flutter/version'
2
4
 
3
5
  module Fastlane
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-flutter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Sheremet
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-01 00:00:00.000000000 Z
11
+ date: 2024-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: pry
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: codecov
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: fastlane
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.91.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.91.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rspec_junit_formatter
70
+ name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,21 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rake
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec_junit_formatter
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -84,18 +112,18 @@ dependencies:
84
112
  name: rubocop
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - '='
115
+ - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: 0.49.1
117
+ version: '1.64'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - '='
122
+ - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: 0.49.1
124
+ version: '1.64'
97
125
  - !ruby/object:Gem::Dependency
98
- name: rubocop-require_tools
126
+ name: rubocop-rake
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - ">="
@@ -109,7 +137,7 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
- name: simplecov
140
+ name: rubocop-require_tools
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ">="
@@ -123,7 +151,7 @@ dependencies:
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
- name: codecov
154
+ name: rubocop-rspec
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
157
  - - ">="
@@ -137,20 +165,20 @@ dependencies:
137
165
  - !ruby/object:Gem::Version
138
166
  version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
- name: fastlane
168
+ name: simplecov
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
171
  - - ">="
144
172
  - !ruby/object:Gem::Version
145
- version: 2.91.0
173
+ version: '0'
146
174
  type: :development
147
175
  prerelease: false
148
176
  version_requirements: !ruby/object:Gem::Requirement
149
177
  requirements:
150
178
  - - ">="
151
179
  - !ruby/object:Gem::Version
152
- version: 2.91.0
153
- description:
180
+ version: '0'
181
+ description:
154
182
  email: artem@sheremet.ch
155
183
  executables: []
156
184
  extensions: []
@@ -173,7 +201,7 @@ homepage: https://github.com/dotdoom/fastlane-plugin-flutter
173
201
  licenses:
174
202
  - MIT
175
203
  metadata: {}
176
- post_install_message:
204
+ post_install_message:
177
205
  rdoc_options: []
178
206
  require_paths:
179
207
  - lib
@@ -188,8 +216,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
216
  - !ruby/object:Gem::Version
189
217
  version: '0'
190
218
  requirements: []
191
- rubygems_version: 3.1.6
192
- signing_key:
219
+ rubygems_version: 3.5.3
220
+ signing_key:
193
221
  specification_version: 4
194
222
  summary: Flutter actions plugin for Fastlane
195
223
  test_files: []