fastlane-plugin-android_version_manager 0.4.0 → 0.4.1

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: b0331fa284ccb5b902af7a6e72a906f86246a1bc6c8de7ad1408a895b3492c32
4
- data.tar.gz: 29d85179e5833586615015a9b1501b8ccbadeb59c0d2c14354eb788fd108bc69
3
+ metadata.gz: 6b1e0dfd8cc3942fb547b66ce72266627f0dc60cb85a7f943dc9751dcaa9297f
4
+ data.tar.gz: 7551c6c16f603d46d4f49020718f7db55e36bb8c41fb7852354a16903d79b0df
5
5
  SHA512:
6
- metadata.gz: 6bc09f990dce0ca847f0b44cc228f4f7063dab59b1f72d7c48f78131132863eb696e7676e314ccdb0c1b3ab9e3feee993d9021fec3bbb10f36d61058d70a7dc1
7
- data.tar.gz: eff9e1d7dd5d50aa376f6d488e6ad59b250ce2953238c561d17757e47566e4672acea69c32fdfef07bc1ff7da5a7e443ee2609933cba48dffd473f04b9e5ef19
6
+ metadata.gz: 107429d92fab3046a9dafe59b57996e85eb24eda8d478f8adfbcc59cfc5fe2014ff34fad8648be74adad15bfd1badbabcc04d6ec9284b14203ff741d2df9affc
7
+ data.tar.gz: 8bbabcef5a2ebf190f91ecd4cd133047f6306f36f33545b52f4dfcdfc4518af1289fafcd6a88d874e04174d86f39887a4716f6f5104f05678c5d1e3a37cbf046
@@ -0,0 +1,34 @@
1
+ require "fastlane/action"
2
+ require_relative "../helper/android_version_manager_helper"
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class AndroidBaseAction < Action
7
+ def self.authors
8
+ ["Jonathan Cardoso", "@_jonathancardos", "JCMais", "Nicolas Verinaud"]
9
+ end
10
+
11
+ def self.is_supported?(platform)
12
+ platform == :android
13
+ end
14
+
15
+ def self.app_project_dir_action
16
+ FastlaneCore::ConfigItem.new(
17
+ key: :app_project_dir,
18
+ env_name: "FL_ANDROID_GET_VERSION_CODE_APP_PROJECT_DIR",
19
+ description: "The path to the application source folder in the Android project (default: android/app)",
20
+ optional: true,
21
+ type: String,
22
+ default_value: "android/app",
23
+ verify_block: proc do |value|
24
+ UI.user_error!("Couldn't find build.gradle or build.gradle.kts file at path '#{value}'") unless Helper::AndroidVersionManagerHelper.build_gradle_exists?(value)
25
+ end
26
+ )
27
+ end
28
+
29
+ def self.find_build_gradle(app_project_dir)
30
+ Helper::AndroidVersionManagerHelper.find_build_gradle(app_project_dir)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,40 +1,24 @@
1
- # This source code is based on this one:
2
- # https://github.com/otkmnb2783/fastlane-plugin-android_versioning/blob/a9dc02d69a8c3a106d00b52ace78d4a763baf6af/lib/fastlane/plugin/android_versioning/actions/get_value_from_build.rb#L1
3
- require "fileutils"
1
+ require_relative 'android_base_action'
2
+ require_relative '../helper/android_version_manager_helper'
4
3
 
5
4
  module Fastlane
6
5
  module Actions
7
- class AndroidGetValueFromBuildAction < Action
6
+ class AndroidGetValueFromBuildAction < AndroidBaseAction
8
7
  def self.run(params)
9
8
  app_project_dir ||= params[:app_project_dir]
10
- value, _line, _line_index = Helper::AndroidVersionManagerHelper.get_key_from_gradle_file("#{app_project_dir}/build.gradle", params[:key])
9
+ file_path = find_build_gradle(app_project_dir)
10
+ value, _line, _line_index = Helper::AndroidVersionManagerHelper.get_key_from_gradle_file(file_path, params[:key])
11
11
  return value
12
12
  end
13
13
 
14
14
  def self.available_options
15
15
  [
16
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
17
- description: "The path to the application source folder in the Android project, the one that contains the build.gradle file (default: android/app)",
18
- optional: true,
19
- type: String,
20
- default_value: "android/app",
21
- verify_block: proc do |value|
22
- # Not using File.exist?("#{value}/build.gradle") because it does not handle globs
23
- UI.user_error!("Couldn't find build.gradle file at path '#{value}'") unless Dir["#{value}/build.gradle"].any?
24
- end),
16
+ app_project_dir_action,
25
17
  FastlaneCore::ConfigItem.new(key: :key,
26
18
  description: "The property key to retrieve the value from",
27
19
  type: String),
28
20
  ]
29
21
  end
30
-
31
- def self.authors
32
- ["Jonathan Cardoso", "@_jonathancardos", "JCMais"]
33
- end
34
-
35
- def self.is_supported?(platform)
36
- platform == :android
37
- end
38
22
  end
39
23
  end
40
24
  end
@@ -1,4 +1,4 @@
1
- require "fastlane/action"
1
+ require_relative 'android_base_action'
2
2
  require_relative "../helper/android_version_manager_helper"
3
3
 
4
4
  module Fastlane
@@ -8,14 +8,15 @@ module Fastlane
8
8
  ANDROID_VERSION_CODE ||= :ANDROID_VERSION_CODE
9
9
  end
10
10
 
11
- class AndroidGetVersionCodeAction < Action
11
+ class AndroidGetVersionCodeAction < AndroidBaseAction
12
12
  def self.run(params)
13
13
  # fastlane will take care of reading in the parameter and fetching the environment variable:
14
14
  UI.message("Parameter app_project_dir: #{params[:app_project_dir]}")
15
15
  UI.message("Parameter key: #{params[:key]}")
16
16
 
17
+ file_path = find_build_gradle(params[:app_project_dir])
17
18
  # We can expect version_code to be an existing and valid version code
18
- version_code = Helper::AndroidVersionManagerHelper.get_version_code_from_gradle_file("#{params[:app_project_dir]}/build.gradle", params[:key])
19
+ version_code = Helper::AndroidVersionManagerHelper.get_version_code_from_gradle_file(file_path, params[:key])
19
20
 
20
21
  Actions.lane_context[Fastlane::Actions::SharedValues::ANDROID_VERSION_CODE] = version_code
21
22
 
@@ -36,16 +37,7 @@ module Fastlane
36
37
 
37
38
  def self.available_options
38
39
  [
39
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
40
- env_name: "FL_ANDROID_GET_VERSION_CODE_APP_PROJECT_DIR",
41
- description: "The path to the application source folder in the Android project (default: android/app)",
42
- optional: true,
43
- type: String,
44
- default_value: "android/app",
45
- verify_block: proc do |value|
46
- # Not using File.exist?("#{value}/build.gradle") because it does not handle globs
47
- UI.user_error!("Couldn't find build.gradle file at path '#{value}'") unless Dir["#{value}/build.gradle"].any?
48
- end),
40
+ app_project_dir_action,
49
41
  FastlaneCore::ConfigItem.new(key: :key,
50
42
  env_name: "FL_ANDROID_GET_VERSION_CODE_KEY",
51
43
  description: "The property key",
@@ -84,14 +76,6 @@ module Fastlane
84
76
  # https://github.com/fastlane/fastlane/blob/051e5012984d97257571a76627c1261946afb8f8/fastlane/lib/fastlane/action.rb#L23-L30
85
77
  :int
86
78
  end
87
-
88
- def self.authors
89
- ["Jonathan Cardoso", "@_jonathancardos", "JCMais"]
90
- end
91
-
92
- def self.is_supported?(platform)
93
- platform == :android
94
- end
95
79
  end
96
80
  end
97
81
  end
@@ -1,4 +1,4 @@
1
- require "fastlane/action"
1
+ require_relative 'android_base_action'
2
2
  require_relative "../helper/android_version_manager_helper"
3
3
 
4
4
  module Fastlane
@@ -8,14 +8,15 @@ module Fastlane
8
8
  ANDROID_VERSION_NAME ||= :ANDROID_VERSION_NAME
9
9
  end
10
10
 
11
- class AndroidGetVersionNameAction < Action
11
+ class AndroidGetVersionNameAction < AndroidBaseAction
12
12
  def self.run(params)
13
13
  # fastlane will take care of reading in the parameter and fetching the environment variable:
14
14
  UI.message("Parameter app_project_dir: #{params[:app_project_dir]}")
15
15
  UI.message("Parameter key: #{params[:key]}")
16
16
 
17
+ file_path = find_build_gradle(params[:app_project_dir])
17
18
  # We can expect version_name to be an existing and valid semver version name
18
- version_name = Helper::AndroidVersionManagerHelper.get_version_name_from_gradle_file("#{params[:app_project_dir]}/build.gradle", params[:key])
19
+ version_name = Helper::AndroidVersionManagerHelper.get_version_name_from_gradle_file(file_path, params[:key])
19
20
 
20
21
  Actions.lane_context[Fastlane::Actions::SharedValues::ANDROID_VERSION_NAME] = version_name
21
22
 
@@ -36,16 +37,7 @@ module Fastlane
36
37
 
37
38
  def self.available_options
38
39
  [
39
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
40
- env_name: "FL_ANDROID_GET_VERSION_CODE_APP_PROJECT_DIR",
41
- description: "The path to the application source folder in the Android project (default: android/app)",
42
- optional: true,
43
- type: String,
44
- default_value: "android/app",
45
- verify_block: proc do |value|
46
- # Not using File.exist?("#{value}/build.gradle") because it does not handle globs
47
- UI.user_error!("Couldn't find build.gradle file at path '#{value}'") unless Dir["#{value}/build.gradle"].any?
48
- end),
40
+ app_project_dir_action,
49
41
  FastlaneCore::ConfigItem.new(key: :key,
50
42
  env_name: "FL_ANDROID_GET_VERSION_CODE_KEY",
51
43
  description: "The property key",
@@ -84,14 +76,6 @@ module Fastlane
84
76
  # https://github.com/fastlane/fastlane/blob/051e5012984d97257571a76627c1261946afb8f8/fastlane/lib/fastlane/action.rb#L23-L30
85
77
  :int
86
78
  end
87
-
88
- def self.authors
89
- ["Jonathan Cardoso", "@_jonathancardos", "JCMais"]
90
- end
91
-
92
- def self.is_supported?(platform)
93
- platform == :android
94
- end
95
79
  end
96
80
  end
97
81
  end
@@ -1,4 +1,4 @@
1
- require "fastlane/action"
1
+ require_relative 'android_base_action'
2
2
  require_relative "../helper/android_version_manager_helper"
3
3
 
4
4
  module Fastlane
@@ -8,13 +8,13 @@ module Fastlane
8
8
  ANDROID_VERSION_CODE ||= :ANDROID_VERSION_CODE
9
9
  end
10
10
 
11
- class AndroidIncrementVersionCodeAction < Action
11
+ class AndroidIncrementVersionCodeAction < AndroidBaseAction
12
12
  def self.run(params)
13
13
  UI.message("Param app_project_dir: #{params[:app_project_dir]}")
14
14
  UI.message("Param version_code: #{params[:version_code]}")
15
15
  UI.message("Param key: #{params[:key]}")
16
16
 
17
- file_path = "#{params[:app_project_dir]}/build.gradle"
17
+ file_path = find_build_gradle(params[:app_project_dir])
18
18
 
19
19
  # We can expect version_code to be an existing and valid version code
20
20
  version_code = Helper::AndroidVersionManagerHelper.get_version_code_from_gradle_file(file_path, params[:key])
@@ -45,16 +45,7 @@ module Fastlane
45
45
 
46
46
  def self.available_options
47
47
  [
48
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
49
- env_name: "FL_ANDROID_INCREMENT_VERSION_CODE_APP_PROJECT_DIR",
50
- description: "The path to the application source folder in the Android project (default: android/app)",
51
- optional: true,
52
- type: String,
53
- default_value: "android/app",
54
- verify_block: proc do |value|
55
- # Not using File.exist?("#{value}/build.gradle") because it does not handle globs
56
- UI.user_error!("Couldn't find build.gradle file at path '#{value}'") unless Dir["#{value}/build.gradle"].any?
57
- end),
48
+ app_project_dir_action,
58
49
  FastlaneCore::ConfigItem.new(key: :key,
59
50
  env_name: "FL_ANDROID_INCREMENT_VERSION_CODE_KEY",
60
51
  description: "The property key",
@@ -98,14 +89,6 @@ module Fastlane
98
89
  # https://github.com/fastlane/fastlane/blob/051e5012984d97257571a76627c1261946afb8f8/fastlane/lib/fastlane/action.rb#L23-L30
99
90
  :int
100
91
  end
101
-
102
- def self.authors
103
- ["Jonathan Cardoso", "@_jonathancardos", "JCMais"]
104
- end
105
-
106
- def self.is_supported?(platform)
107
- platform == :android
108
- end
109
92
  end
110
93
  end
111
94
  end
@@ -1,6 +1,5 @@
1
- require "fastlane/action"
2
1
  require "semantic"
3
-
2
+ require_relative 'android_base_action'
4
3
  require_relative "../helper/android_version_manager_helper"
5
4
 
6
5
  module Fastlane
@@ -10,14 +9,14 @@ module Fastlane
10
9
  ANDROID_VERSION_NAME ||= :ANDROID_VERSION_NAME
11
10
  end
12
11
 
13
- class AndroidIncrementVersionNameAction < Action
12
+ class AndroidIncrementVersionNameAction < AndroidBaseAction
14
13
  def self.run(params)
15
14
  UI.message("Param app_project_dir: #{params[:app_project_dir]}")
16
15
  UI.message("Param version_name: #{params[:version_name]}")
17
16
  UI.message("Param increment_type: #{params[:increment_type]}")
18
17
  UI.message("Param key: #{params[:key]}")
19
18
 
20
- file_path = "#{params[:app_project_dir]}/build.gradle"
19
+ file_path = find_build_gradle(params[:app_project_dir])
21
20
  increment_type = params[:increment_type].to_sym
22
21
 
23
22
  # We can expect version_code to be an existing and valid version code
@@ -58,16 +57,7 @@ module Fastlane
58
57
 
59
58
  def self.available_options
60
59
  [
61
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
62
- env_name: "FL_ANDROID_INCREMENT_VERSION_NAME_APP_PROJECT_DIR",
63
- description: "The path to the application source folder in the Android project (default: android/app)",
64
- optional: true,
65
- type: String,
66
- default_value: "android/app",
67
- verify_block: proc do |value|
68
- # Not using File.exist?("#{value}/build.gradle") because it does not handle globs
69
- UI.user_error!("Couldn't find build.gradle file at path '#{value}'") unless Dir["#{value}/build.gradle"].any?
70
- end),
60
+ app_project_dir_action,
71
61
  FastlaneCore::ConfigItem.new(key: :key,
72
62
  env_name: "FL_ANDROID_INCREMENT_VERSION_NAME_KEY",
73
63
  description: "The property key",
@@ -120,14 +110,6 @@ module Fastlane
120
110
  # https://github.com/fastlane/fastlane/blob/051e5012984d97257571a76627c1261946afb8f8/fastlane/lib/fastlane/action.rb#L23-L30
121
111
  :int
122
112
  end
123
-
124
- def self.authors
125
- ["Jonathan Cardoso", "@_jonathancardos", "JCMais"]
126
- end
127
-
128
- def self.is_supported?(platform)
129
- platform == :android
130
- end
131
113
  end
132
114
  end
133
115
  end
@@ -1,9 +1,9 @@
1
- require 'fastlane/action'
1
+ require_relative 'android_base_action'
2
2
  require_relative '../helper/android_version_manager_helper'
3
3
 
4
4
  module Fastlane
5
5
  module Actions
6
- class AndroidVersionManagerAction < Action
6
+ class AndroidVersionManagerAction < AndroidBaseAction
7
7
  def self.run(params)
8
8
  UI.message("The android_version_manager plugin is working!")
9
9
  end
@@ -12,10 +12,6 @@ module Fastlane
12
12
  "Android's App Version Managment"
13
13
  end
14
14
 
15
- def self.authors
16
- ["Jonathan Cardoso Machado"]
17
- end
18
-
19
15
  def self.return_value
20
16
  # If your method provides a return value, you can describe here what it does
21
17
  end
@@ -27,22 +23,9 @@ module Fastlane
27
23
 
28
24
  def self.available_options
29
25
  [
30
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
31
- env_name: "ANDROID_VERSIONING_APP_PROJECT_DIR",
32
- description: "The path to the application source folder in the Android project (default: android/app)",
33
- optional: true,
34
- type: String,
35
- default_value: "android/app"),
36
- FastlaneCore::ConfigItem.new(key: :key,
37
- description: "The property key",
38
- type: String)
39
-
26
+ app_project_dir_action
40
27
  ]
41
28
  end
42
-
43
- def self.is_supported?(platform)
44
- platform == :android
45
- end
46
29
  end
47
30
  end
48
31
  end
@@ -9,6 +9,14 @@ module Fastlane
9
9
 
10
10
  module Helper
11
11
  class AndroidVersionManagerHelper
12
+ def self.build_gradle_exists?(app_project_dir)
13
+ return BuildGradleFile.new(app_project_dir).exists?
14
+ end
15
+
16
+ def self.find_build_gradle(app_project_dir)
17
+ return BuildGradleFile.new(app_project_dir).find
18
+ end
19
+
12
20
  # class methods that you define here become available in your action
13
21
  # as `Helper::AndroidVersionManagerHelper.your_method`
14
22
  # Most actions code are here to follow this advice: https://docs.fastlane.tools/advanced/actions/#calling-other-actions
@@ -0,0 +1,38 @@
1
+
2
+ class BuildGradleFile
3
+ def initialize(app_project_dir)
4
+ @app_project_dir = app_project_dir
5
+ end
6
+
7
+ def find
8
+ if kts_exists?
9
+ return kts
10
+ end
11
+ return classic
12
+ end
13
+
14
+ def exists?
15
+ return kts_exists? || classic_exists?
16
+ end
17
+
18
+ def kts_exists?
19
+ return file_exists?(kts)
20
+ end
21
+
22
+ def classic_exists?
23
+ return file_exists?(classic)
24
+ end
25
+
26
+ def kts
27
+ return "#{@app_project_dir}/build.gradle.kts"
28
+ end
29
+
30
+ def classic
31
+ return "#{@app_project_dir}/build.gradle"
32
+ end
33
+
34
+ def file_exists?(path)
35
+ # Not using File.exist? because it does not handle globs
36
+ return Dir[path].any?
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AndroidVersionManager
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-android_version_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Cardoso Machado
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-05 00:00:00.000000000 Z
11
+ date: 2020-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic
@@ -159,6 +159,7 @@ files:
159
159
  - LICENSE
160
160
  - README.md
161
161
  - lib/fastlane/plugin/android_version_manager.rb
162
+ - lib/fastlane/plugin/android_version_manager/actions/android_base_action.rb
162
163
  - lib/fastlane/plugin/android_version_manager/actions/android_get_value_from_build_action.rb
163
164
  - lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb
164
165
  - lib/fastlane/plugin/android_version_manager/actions/android_get_version_name_action.rb
@@ -166,6 +167,7 @@ files:
166
167
  - lib/fastlane/plugin/android_version_manager/actions/android_increment_version_name_action.rb
167
168
  - lib/fastlane/plugin/android_version_manager/actions/android_version_manager_action.rb
168
169
  - lib/fastlane/plugin/android_version_manager/helper/android_version_manager_helper.rb
170
+ - lib/fastlane/plugin/android_version_manager/helper/build_gradle_file.rb
169
171
  - lib/fastlane/plugin/android_version_manager/version.rb
170
172
  homepage: https://github.com/JCMais/fastlane-plugin-android_version_manager
171
173
  licenses: