fastlane-plugin-wpmreleasetoolkit 13.3.1 → 13.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ace179f7cf145c3a8bc0e2b9fa917eaa4654b93fcc9b329ef44013f227111420
|
4
|
+
data.tar.gz: 1ddd2fe6be0810ec61a6089f44d60ff70599007cb1eb875de32c6df047cbfabe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deba3263e74215fd1b98373940d2eb1b259eda28587e6a730446c596e1559b6a5ad74c3f7260e76d642e6b9ba57d1c5a43f5dd53f64b9d780c4f0400f4c3fc89
|
7
|
+
data.tar.gz: 17bc9286fe256f21bcfa392bbd48a16d78c5130c1cb8191dc0931516695686eed42ba324a42155eb51a1f66eeefe74b8a44c79a8a24c612f7ad584d84af84f7f
|
@@ -33,6 +33,14 @@ module Fastlane
|
|
33
33
|
def to_s
|
34
34
|
"#{@major}.#{@minor}.#{@patch}.#{@build_number}"
|
35
35
|
end
|
36
|
+
|
37
|
+
# Returns an array of the version components.
|
38
|
+
#
|
39
|
+
# @return [Array<Integer>] an array of the version components.
|
40
|
+
#
|
41
|
+
def components
|
42
|
+
[@major, @minor, @patch, @build_number]
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/derived_build_code_formatter.rb
CHANGED
@@ -3,13 +3,35 @@
|
|
3
3
|
module Fastlane
|
4
4
|
module Wpmreleasetoolkit
|
5
5
|
module Versioning
|
6
|
+
# Max total for `*_digits` params, not counting prefix
|
7
|
+
MAX_TOTAL_DIGITS = 8
|
8
|
+
MIN_DIGIT_COUNT = 1
|
9
|
+
MAX_DIGIT_COUNT = 3
|
10
|
+
|
6
11
|
# The `DerivedBuildCodeFormatter` class is a specialized build code formatter for derived build codes.
|
7
12
|
# It takes in an AppVersion object and derives a build code from it.
|
8
13
|
class DerivedBuildCodeFormatter
|
14
|
+
# Initialize the formatter with configurable prefix and digit counts.
|
15
|
+
#
|
16
|
+
# @param [String] prefix The prefix to use for the build code. Must be a single digit (0-9), or empty string / nil.
|
17
|
+
# @param [Integer] major_digits Number of digits for major version. Must be between 1–3. Defaults to 2.
|
18
|
+
# @param [Integer] minor_digits Number of digits for minor version. Must be between 1–3. Defaults to 2.
|
19
|
+
# @param [Integer] patch_digits Number of digits for patch version. Must be between 1–3. Defaults to 2.
|
20
|
+
# @param [Integer] build_digits Number of digits for build number. Must be between 1–3. Defaults to 2.
|
21
|
+
#
|
22
|
+
def initialize(prefix: nil, major_digits: 2, minor_digits: 2, patch_digits: 2, build_digits: 2)
|
23
|
+
validate_prefix!(prefix)
|
24
|
+
@prefix = prefix.to_s
|
25
|
+
|
26
|
+
@digit_counts = [major_digits, minor_digits, patch_digits, build_digits]
|
27
|
+
@digit_counts.each { |d| validate_digit_count!(d) }
|
28
|
+
validate_total_digits!(@digit_counts)
|
29
|
+
end
|
30
|
+
|
9
31
|
# Calculate the next derived build code.
|
10
32
|
#
|
11
|
-
# This method derives a new build code from the given AppVersion object by concatenating the
|
12
|
-
# the major version, the minor version, the patch version, and the build number.
|
33
|
+
# This method derives a new build code from the given AppVersion object by concatenating the configured prefix,
|
34
|
+
# the major version, the minor version, the patch version, and the build number with configurable digit counts.
|
13
35
|
#
|
14
36
|
# @param [AppVersion] version The AppVersion object to derive the next build code from.
|
15
37
|
#
|
@@ -18,16 +40,76 @@ module Fastlane
|
|
18
40
|
#
|
19
41
|
# @return [String] The formatted build code string.
|
20
42
|
#
|
21
|
-
def build_code(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
)
|
43
|
+
def build_code(_build_code = nil, version:)
|
44
|
+
formatted_components = version.components.zip(@digit_counts).map do |value, width|
|
45
|
+
comp = value.to_s.rjust(width, '0')
|
46
|
+
if comp.length > width
|
47
|
+
UI.user_error!("Version component value (#{value}) exceeds maximum allowed width of #{width} characters. " \
|
48
|
+
"Consider increasing the corresponding `*_digits` parameter of your `#{self.class.name}`")
|
49
|
+
end
|
50
|
+
comp
|
51
|
+
end
|
52
|
+
[@prefix, *formatted_components].join.gsub(/^0+/, '')
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# Validates that the prefix is a valid single digit (0-9) or empty string.
|
58
|
+
#
|
59
|
+
# @param [String] prefix The prefix to validate
|
60
|
+
#
|
61
|
+
# @raise [StandardError] If the prefix is invalid
|
62
|
+
#
|
63
|
+
def validate_prefix!(prefix)
|
64
|
+
unless prefix.nil? || prefix.is_a?(String) || prefix.is_a?(Integer)
|
65
|
+
UI.user_error!("Prefix must be a string or integer, got: #{prefix.class}")
|
66
|
+
end
|
67
|
+
|
68
|
+
prefix_str = prefix.to_s
|
69
|
+
|
70
|
+
# Allow empty string
|
71
|
+
return if prefix_str.empty?
|
72
|
+
|
73
|
+
# Check if it's longer than 1 character
|
74
|
+
if prefix_str.length > 1
|
75
|
+
UI.user_error!("Prefix must be a single digit or empty string, got: '#{prefix_str}' (length: #{prefix_str.length})")
|
76
|
+
end
|
77
|
+
|
78
|
+
# Check if it's a valid integer
|
79
|
+
return if ('0'..'9').include?(prefix_str)
|
80
|
+
|
81
|
+
UI.user_error!("Prefix must be an integer digit (0-9) or empty string, got: '#{prefix_str}'")
|
82
|
+
end
|
83
|
+
|
84
|
+
# Validates that the digit count is a valid positive integer within reasonable limits.
|
85
|
+
#
|
86
|
+
# @param [Integer] digit_count The digit count to validate
|
87
|
+
#
|
88
|
+
# @raise [StandardError] If the digit count is invalid
|
89
|
+
#
|
90
|
+
def validate_digit_count!(digit_count)
|
91
|
+
# Check if it's an integer
|
92
|
+
unless digit_count.is_a?(Integer)
|
93
|
+
UI.user_error!("Digit count must be an integer, got: #{digit_count.class}")
|
94
|
+
end
|
95
|
+
|
96
|
+
return if digit_count.between?(MIN_DIGIT_COUNT, MAX_DIGIT_COUNT)
|
97
|
+
|
98
|
+
UI.user_error!("Digit count must be between #{MIN_DIGIT_COUNT} and #{MAX_DIGIT_COUNT} digits, got: #{digit_count}")
|
99
|
+
end
|
100
|
+
|
101
|
+
# Validates that the total number of digits (excluding prefix) doesn't exceed the maximum for multiplatform compatibility.
|
102
|
+
#
|
103
|
+
# Since Google Play's max versionCode is ≈ 2_000_000_000, we want to avoid being too close to the limit
|
104
|
+
# as this would then block us from submitting any updates for that app if we reached it.
|
105
|
+
def validate_total_digits!(digits_list)
|
106
|
+
total_digits = digits_list.sum
|
107
|
+
|
108
|
+
# Limit total digits to 8 (excluding prefix)
|
109
|
+
return if total_digits <= MAX_TOTAL_DIGITS
|
110
|
+
|
111
|
+
UI.user_error!("Total digit count (#{total_digits}) exceeds maximum allowed (#{MAX_TOTAL_DIGITS}). " \
|
112
|
+
"Current config: major(#{digits_list[0]}) + minor(#{digits_list[1]}) + patch(#{digits_list[2]}) + build(#{digits_list[3]}) digits")
|
31
113
|
end
|
32
114
|
end
|
33
115
|
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: 13.
|
4
|
+
version: 13.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Automattic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|