fastlane-plugin-flutter 0.3.17 → 0.5.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: 6c074866e0966b7ede427c98d5fa61b359d9453d09a0db3ef5e24ee2b1204325
4
- data.tar.gz: 6a8e7b42e826e404a46c5d94744b2b1e4f54b4ef3aa537e9381be93bf7653785
3
+ metadata.gz: e08545073c4e4d3d8f8b4abbf1c8dc35a6aeae562e5fea8f888a5ef562990390
4
+ data.tar.gz: 55e6d48ffd6a7f5d0189f111c31f95c0ff70941078ef7c72dc090d1eeec096c5
5
5
  SHA512:
6
- metadata.gz: 8a3a165a042faa309d277ca9a4d03a48c566849fa935cdee9a7b21fe9c1bfb8229018a715df7ae767a61812ba14284bd6c4b3f94488036c6f5ff41a3f7662b81
7
- data.tar.gz: 9361f891a5720c357da65f92c69ba87340f9e37240c874b9b6b67ae9a674e8cdebd70825bac220695e6125f4d4beb25deea1122e401fe6de4168e5c99831639b
6
+ metadata.gz: 57e28fc3cdf69975601f68d55a35baf2d5346896209e8b64db482f1138ce0f613e4a980512a61280be13c58332f84dd7b9053867ab369415cbe73d2a65ecf93b
7
+ data.tar.gz: b2fa06f9134c563edc33bcb89d2e4d460313977f1212dc7ce2396ee1f9031f8257652e001d896fb053a0b084bd91334a428d94aa2650cc336955ffbeaff1b5a9
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/fastlane-plugin-flutter.svg)](https://badge.fury.io/rb/fastlane-plugin-flutter)
4
4
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-flutter)
5
+ [![codecov](https://codecov.io/gh/dotdoom/fastlane-plugin-flutter/branch/master/graph/badge.svg)](https://codecov.io/gh/dotdoom/fastlane-plugin-flutter)
5
6
  [![Build Status](https://github.com/dotdoom/fastlane-plugin-flutter/workflows/end-to-end%20test/badge.svg?branch=master)](https://github.com/dotdoom/fastlane-plugin-flutter/actions?query=workflow%3A"end-to-end+test"+branch%3Amaster)
6
7
 
7
8
  Automated end-to-end test (download Flutter, create an app, build it) on the
@@ -9,7 +9,9 @@ module Fastlane
9
9
 
10
10
  def self.run(params)
11
11
  if params[:capture_stdout]
12
- Helper::FlutterHelper.flutter(*params[:args]) {}
12
+ Helper::FlutterHelper.flutter(*params[:args]) do |status, output|
13
+ output
14
+ end
13
15
  else
14
16
  Helper::FlutterHelper.flutter(*params[:args])
15
17
  end
@@ -34,13 +34,16 @@ module Fastlane
34
34
  else
35
35
  Helper::FlutterHelper.git(
36
36
  'clone', # no --depth limit to keep Flutter tag-based versioning.
37
- "--branch=#{flutter_channel || 'beta'}",
37
+ "--branch=#{flutter_channel || 'stable'}",
38
38
  '--quiet',
39
39
  '--',
40
40
  FLUTTER_REMOTE_REPOSITORY,
41
41
  flutter_sdk_root,
42
42
  )
43
43
  end
44
+
45
+ # Return installation path of Flutter SDK.
46
+ flutter_sdk_root
44
47
  end
45
48
 
46
49
  def self.need_upgrade_to_channel?(flutter_sdk_root, flutter_channel)
@@ -52,12 +52,7 @@ module Fastlane
52
52
 
53
53
  Helper::FlutterHelper.flutter('build', *build_args) do |status, res|
54
54
  if status.success?
55
- if res =~ /Built (.*?)(:? \([^)]*\))?\.$/
56
- lane_context[SharedValues::FLUTTER_OUTPUT] =
57
- File.absolute_path($1)
58
- else
59
- UI.important('Cannot parse built file path from "flutter build"')
60
- end
55
+ process_build_output(res, build_args)
61
56
  # gym (aka build_ios_app) action call may follow build; let's help
62
57
  # it identify the project, since Flutter project structure is
63
58
  # usually standard.
@@ -71,6 +66,17 @@ module Fastlane
71
66
  false
72
67
  end
73
68
 
69
+ # Fill in some well-known context variables so that next commands may
70
+ # pick them up.
71
+ case params[:build]
72
+ when 'apk'
73
+ lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH] =
74
+ lane_context[SharedValues::FLUTTER_OUTPUT]
75
+ when 'appbundle'
76
+ lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH] =
77
+ lane_context[SharedValues::FLUTTER_OUTPUT]
78
+ end
79
+
74
80
  lane_context[SharedValues::FLUTTER_OUTPUT]
75
81
  end
76
82
 
@@ -110,6 +116,21 @@ form instead.
110
116
  end
111
117
  end
112
118
 
119
+ def self.process_build_output(output, build_args)
120
+ artifacts = output.scan(/Built (.*?)(:? \([^)]*\))?\.$/).
121
+ map { |path| File.absolute_path(path[0]) }
122
+ if artifacts.size == 1
123
+ lane_context[SharedValues::FLUTTER_OUTPUT] = artifacts.first
124
+ elsif artifacts.size > 1
125
+ # Could be the result of "flutter build apk --split-per-abi".
126
+ lane_context[SharedValues::FLUTTER_OUTPUT] = artifacts
127
+ elsif build_args.include?('--config-only')
128
+ UI.message('Config-only "build" detected, no output file name')
129
+ else
130
+ UI.important('Cannot parse built file path from "flutter build"')
131
+ end
132
+ end
133
+
113
134
  def self.description
114
135
  'Run "flutter build" to build a Flutter application'
115
136
  end
@@ -9,6 +9,13 @@ module Fastlane
9
9
  class FlutterGenerateAction < Action
10
10
  extend FlutterActionBase
11
11
 
12
+ # Although this file is autogenerated, we should not call it ".g.dart",
13
+ # because it is common for coverage configuration to exclude such files.
14
+ # Note that it's also common to configure Dart analyser to exclude these
15
+ # files from checks; this won't match, and we have to use ignore_for_file
16
+ # for all known lint rules that we might be breaking.
17
+ ALL_IMPORTS_TEST_FILE = 'test/all_imports_for_coverage_test.dart'
18
+
12
19
  def self.run(params)
13
20
  Helper::FlutterHelper.flutter(*%w(packages get)) {}
14
21
 
@@ -26,6 +33,38 @@ module Fastlane
26
33
  UI.message('Found build_runner dependency, running build...')
27
34
  Helper::FlutterGenerateBuildRunnerHelper.build
28
35
  end
36
+
37
+ if params[:coverage_all_imports]
38
+ UI.message("Generating #{ALL_IMPORTS_TEST_FILE} for coverage...")
39
+
40
+ dart_file_literals = Dir['lib/**/*.dart'].reject do |file_name|
41
+ # ".g.dart" files often are "part of" files and can not be imported
42
+ # directly. Commonly coverage for generated files is not that useful
43
+ file_name.end_with?('.g.dart')
44
+ end.map do |file_name|
45
+ Helper::FlutterHelper.
46
+ import_path_for_test(file_name, '..').
47
+ gsub("'", "\\\\'")
48
+ end
49
+
50
+ File.write(
51
+ ALL_IMPORTS_TEST_FILE,
52
+ <<-DART
53
+ // This file is autogenerated by fastlane flutter_generate action.
54
+ // It imports all files in lib/ so that test coverage in percentage
55
+ // of overall project is calculated correctly. Do not modify this
56
+ // file manually!
57
+
58
+ // ignore_for_file: unused_import, directives_ordering
59
+ // ignore_for_file: avoid_relative_lib_imports
60
+ // ignore_for_file: lines_longer_than_80_chars
61
+
62
+ #{dart_file_literals.map { |fn| "import '#{fn}';" }.sort.join("\n")}
63
+
64
+ void main() {}
65
+ DART
66
+ )
67
+ end
29
68
  end
30
69
 
31
70
  def self.generate_translation?
@@ -33,11 +72,15 @@ module Fastlane
33
72
  end
34
73
 
35
74
  def self.description
36
- "1. Run `build_runner build` if build_runner is in dev_dependencies\n" \
37
- "2. According to `package:intl`, take `$strings_file` and generate " \
75
+ "(1) Run `flutter packages get`; " \
76
+ "(2) Run `build_runner build` if build_runner is in dev_dependencies;" \
77
+ " " \
78
+ "(3) According to `package:intl`, take `$strings_file` and generate " \
38
79
  "`${strings_file.dirname}/arb/intl_messages.arb`, then take all " \
39
80
  "files matching `${strings_file.dirname}/intl_*.arb`, fix them and " \
40
- "generate .dart files from them"
81
+ "generate .dart files from them. " \
82
+ "(4) Generate an empty test importing all files, which would be used " \
83
+ "to calculate correct full coverage numbers."
41
84
  end
42
85
 
43
86
  def self.available_options
@@ -62,6 +105,19 @@ module Fastlane
62
105
  description: 'Locale of the default data in the strings_file',
63
106
  optional: true,
64
107
  ),
108
+ FastlaneCore::ConfigItem.new(
109
+ key: :coverage_all_imports,
110
+ env_name: 'FL_FLUTTER_COVERAGE_ALL_IMPORTS',
111
+ description: <<-DESCRIPTION,
112
+ Set to true to generate an empty test importing all .dart files in
113
+ lib/, which would allow calculating correct coverage numbers for the
114
+ whole project. NOTE: Don't forget to add
115
+ /#{ALL_IMPORTS_TEST_FILE}
116
+ to .gitignore!
117
+ DESCRIPTION
118
+ optional: true,
119
+ type: Boolean,
120
+ ),
65
121
  ]
66
122
  end
67
123
  end
@@ -45,6 +45,30 @@ module Fastlane
45
45
  (YAML.load_file('pubspec.yaml')['dev_dependencies'] || {}).key?(package)
46
46
  end
47
47
 
48
+ def self.pub_package_name
49
+ YAML.load_file('pubspec.yaml')['name']
50
+ end
51
+
52
+ def self.import_path_for_test(file_to_import, relative_path)
53
+ unless file_to_import.start_with?('lib/')
54
+ return File.join(relative_path, file_to_import)
55
+ end
56
+
57
+ # Import file schema in tests have to match files in lib/ exactly. From
58
+ # Dart perspective, symbols in files imported via relative and
59
+ # "package:" file paths are different symbols.
60
+ package_specification = "package:#{pub_package_name}/"
61
+ if File.read(file_to_import, 4096).include?(package_specification)
62
+ # If there's a package reference in the first few bytes of the file,
63
+ # chances are, it's using "package:..." imports. Indeed, checking the
64
+ # file itself isn't sufficient to explore all of its dependencies, but
65
+ # we expect imports to be consistent in the project.
66
+ "#{package_specification}#{file_to_import['lib/'.size..-1]}"
67
+ else
68
+ File.join(relative_path, file_to_import)
69
+ end
70
+ end
71
+
48
72
  def self.execute(*command)
49
73
  # TODO(dotdoom): make CommandExecutor (and Actions.sh) behave similarly.
50
74
  command = command.shelljoin
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Flutter
3
- VERSION = '0.3.17'
3
+ VERSION = '0.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-flutter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.17
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Sheremet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2021-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: codecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: fastlane
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -174,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
188
  - !ruby/object:Gem::Version
175
189
  version: '0'
176
190
  requirements: []
177
- rubygems_version: 3.0.6
191
+ rubygems_version: 3.0.3
178
192
  signing_key:
179
193
  specification_version: 4
180
194
  summary: Flutter actions plugin for Fastlane