fastlane-plugin-flutter 0.3.18 → 0.6.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: 324cf3f1f840b7c09a1fbe82842e16520a61a2e466830a080efcbef86159a439
4
- data.tar.gz: f0cddd43de933afb6041bf589f473f6bc1540b6d33bc63320c8d5e16f8ab4cc1
3
+ metadata.gz: c0484e466e397f4bacea7891de3becea2e85c5b4bf04684f06a167788d57735b
4
+ data.tar.gz: f9996d24c9a41cc4aec9ce774c41ce8a01e8e1055c3e6a153bd23c08dc701d98
5
5
  SHA512:
6
- metadata.gz: 2b80d40a54281fd23c1c43d41cdc3385e1b105148ed0fb973b516ef34d5b3fc3ef7c04fd0dafc35eb1d79877fbbe3bebcf59af71dc4c06fc18f25084a0afea5d
7
- data.tar.gz: 7bdc04fee452d112d3e7306a0c7d40cd64d4c5b24de5619bd67f7f2bc87eb648c7924e7be83737d1184d819609d0437f88c10b8e3286287167a0c4a807988749
6
+ metadata.gz: 7d580e8ed5bb91a9ad0d3ae87657757ce74b88adfb3eea8dff96bd361c48d69b326913c233339274a7869141d839fe3690f42c24bf74bfa408afdcb2f4feb08a
7
+ data.tar.gz: 731f76c07eb9715b79f6705826204fe580446069b46d85da17c9b8ff14ed5ba80ea76e4cb9622bced34a6d5090db69e0f5bd55a6cd2f0164cb9e8221c1dca29c
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
@@ -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
@@ -14,7 +14,10 @@ module Fastlane
14
14
 
15
15
  def self.flutter_sdk_root
16
16
  @flutter_sdk_root ||= File.expand_path(
17
- if ENV.include?('FLUTTER_SDK_ROOT')
17
+ if File.executable?(File.join(Dir.pwd, '.flutter', 'bin', 'flutter'))
18
+ # Support flutterw and compatible projects.
19
+ File.join(Dir.pwd, '.flutter')
20
+ elsif ENV.include?('FLUTTER_SDK_ROOT')
18
21
  UI.deprecated(
19
22
  'FLUTTER_SDK_ROOT environment variable is deprecated. ' \
20
23
  'To point to a Flutter installation directory, use ' \
@@ -27,6 +30,7 @@ module Fastlane
27
30
  elsif flutter_binary = FastlaneCore::CommandExecutor.which('flutter')
28
31
  File.dirname(File.dirname(flutter_binary))
29
32
  else
33
+ # Where we'd prefer to install flutter.
30
34
  File.join(Dir.pwd, 'vendor', 'flutter')
31
35
  end
32
36
  )
@@ -45,6 +49,30 @@ module Fastlane
45
49
  (YAML.load_file('pubspec.yaml')['dev_dependencies'] || {}).key?(package)
46
50
  end
47
51
 
52
+ def self.pub_package_name
53
+ YAML.load_file('pubspec.yaml')['name']
54
+ end
55
+
56
+ def self.import_path_for_test(file_to_import, relative_path)
57
+ unless file_to_import.start_with?('lib/')
58
+ return File.join(relative_path, file_to_import)
59
+ end
60
+
61
+ # Import file schema in tests have to match files in lib/ exactly. From
62
+ # Dart perspective, symbols in files imported via relative and
63
+ # "package:" file paths are different symbols.
64
+ package_specification = "package:#{pub_package_name}/"
65
+ if File.read(file_to_import, 4096).include?(package_specification)
66
+ # If there's a package reference in the first few bytes of the file,
67
+ # chances are, it's using "package:..." imports. Indeed, checking the
68
+ # file itself isn't sufficient to explore all of its dependencies, but
69
+ # we expect imports to be consistent in the project.
70
+ "#{package_specification}#{file_to_import['lib/'.size..-1]}"
71
+ else
72
+ File.join(relative_path, file_to_import)
73
+ end
74
+ end
75
+
48
76
  def self.execute(*command)
49
77
  # TODO(dotdoom): make CommandExecutor (and Actions.sh) behave similarly.
50
78
  command = command.shelljoin
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Flutter
3
- VERSION = '0.3.18'
3
+ VERSION = '0.6.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.18
4
+ version: 0.6.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-13 00:00:00.000000000 Z
11
+ date: 2021-05-28 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,8 @@ 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
+ rubyforge_project:
192
+ rubygems_version: 2.7.6.2
178
193
  signing_key:
179
194
  specification_version: 4
180
195
  summary: Flutter actions plugin for Fastlane