fastlane-plugin-flutter_versioner 0.1.0 → 0.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 428e75ab96b8e51bdcba595c0cdd4c358c226dfe70fb6476d59b474cf1561d17
|
4
|
+
data.tar.gz: 435f99ae6d15d867506bd81be6ef3d68b8925889835421d311948526e9ed3c3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5272be1ec116cb32de12bff07b15a257a3d64f8480f2ceba2ccb630afdbcf77a483f97f7ef41f79d3d9fa0aadcfee4028ec55d178832c8158d08541fb6307f8d
|
7
|
+
data.tar.gz: 9ad3e0612d70d80668e6595549be0631182509dc291d80e92286aab6c87bf6e9a664a84eff1c74aeecfd542e9e5efa3e372a4059099fb024a763b8935dacb116
|
@@ -15,12 +15,11 @@ module Fastlane
|
|
15
15
|
UI.user_error!("The pubspec file path given. Pass the `pubspec_file_path` to the action")
|
16
16
|
else
|
17
17
|
UI.message("The flutter_versioner plugin will use pubspec file at (#{pubspec_file_path})!")
|
18
|
-
version_list =
|
18
|
+
version_list = increment_version(pubspec_file_path, new_value, constant_name, version_component)
|
19
19
|
end
|
20
20
|
|
21
21
|
if version_list.length == 2
|
22
22
|
# Store the version name in the shared hash
|
23
|
-
Actions.lane_context["VERSION_CODE"] = new_value
|
24
23
|
UI.message("Previous Version : #{version_list[0]}")
|
25
24
|
UI.success("Version has been changed to #{version_list[1]}")
|
26
25
|
else
|
@@ -30,7 +29,7 @@ module Fastlane
|
|
30
29
|
return new_value
|
31
30
|
end
|
32
31
|
|
33
|
-
def self.
|
32
|
+
def self.increment_version(path, new_value, constant_name, version_comp = 'version_code')
|
34
33
|
unless File.file?(path)
|
35
34
|
UI.user_error!("No file exist at path: (#{path})!")
|
36
35
|
return -1
|
@@ -42,7 +41,7 @@ module Fastlane
|
|
42
41
|
temp_file = Tempfile.new('fastlaneIncrementVersionCode')
|
43
42
|
File.open(path, 'r') do |file|
|
44
43
|
file.each_line do |line|
|
45
|
-
if line.include?("#{constant_name}:")
|
44
|
+
if line.include?("#{constant_name}:") && found_version_code == "false"
|
46
45
|
|
47
46
|
UI.message(" -> line: (#{line})!")
|
48
47
|
old_version_name = get_version_name(line)
|
@@ -51,10 +50,38 @@ module Fastlane
|
|
51
50
|
new_version_name = old_version_name
|
52
51
|
|
53
52
|
if version_comp == 'version_code'
|
54
|
-
|
53
|
+
if new_value.instance_of?(Integer)
|
54
|
+
new_value = new_value.to_s
|
55
|
+
end
|
56
|
+
if new_value.nil? || (is_int(new_value) && new_value.to_i > 0)
|
57
|
+
new_version_code = increment_version_code(old_version_code, new_value)
|
58
|
+
else
|
59
|
+
UI.user_error!("Invalid version code.\nVersion code should be a positve integer")
|
60
|
+
end
|
55
61
|
|
56
62
|
elsif ['patch', 'major', 'minor'].include?(version_comp)
|
57
|
-
|
63
|
+
if new_value.instance_of?(Integer)
|
64
|
+
new_value = new_value.to_s
|
65
|
+
end
|
66
|
+
if new_value.nil? || (is_int(new_value) && new_value.to_i >= 0)
|
67
|
+
new_version_name = increment_version_name(old_version_name, version_comp, new_value)
|
68
|
+
else
|
69
|
+
UI.user_error!("Invalid value.\nPatch, Minor, Major values should be a positve integer or 0")
|
70
|
+
end
|
71
|
+
|
72
|
+
elsif version_comp == 'version_name'
|
73
|
+
if matches_version_name_pattern?(new_value)
|
74
|
+
new_version_name = new_value
|
75
|
+
else
|
76
|
+
UI.user_error!("Invalid version name.\n Version name mustbe in the from major.minor.patch (eg 1.2.3)")
|
77
|
+
end
|
78
|
+
elsif version_comp == 'version'
|
79
|
+
if matches_version_pattern?(new_value)
|
80
|
+
new_version_name = get_version_name(new_value)
|
81
|
+
new_version_code = get_version_code(new_value)
|
82
|
+
else
|
83
|
+
UI.user_error!("Invalid version.\n Version mustbe in the from major.minor.patch+build_number (eg 1.2.3+1021)")
|
84
|
+
end
|
58
85
|
else
|
59
86
|
UI.user_error!("Invalid version component.\nVersion Component must be any one of these -> version_code, patch, minor,major")
|
60
87
|
end
|
@@ -64,8 +91,9 @@ module Fastlane
|
|
64
91
|
if !!(new_version_code =~ /\A[-+]?[0-9]+\z/)
|
65
92
|
line.replace(line.sub(old_verison, new_version))
|
66
93
|
found_version_code = "true"
|
94
|
+
update_lane_context(new_version)
|
95
|
+
temp_file.puts(line)
|
67
96
|
end
|
68
|
-
temp_file.puts(line)
|
69
97
|
else
|
70
98
|
temp_file.puts(line)
|
71
99
|
end
|
@@ -84,13 +112,38 @@ module Fastlane
|
|
84
112
|
return -1
|
85
113
|
end
|
86
114
|
|
115
|
+
def self.update_lane_context(new_version)
|
116
|
+
version_name = get_version_name(new_version)
|
117
|
+
major, minor, patch = get_patch_minor_major(version_name)
|
118
|
+
Actions.lane_context["VERSION"] = new_version
|
119
|
+
Actions.lane_context["VERSION_NAME"] = version_name
|
120
|
+
Actions.lane_context["VERSION_CODE"] = get_version_code(new_version)
|
121
|
+
Actions.lane_context["PATCH"] = patch
|
122
|
+
Actions.lane_context["MINOR"] = minor
|
123
|
+
Actions.lane_context["MAJOR"] = major
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.matches_version_pattern?(version)
|
127
|
+
pattern = /^\d+\.\d+\.\d+\+\d+$/
|
128
|
+
pattern.match?(version.to_s)
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.matches_version_name_pattern?(version)
|
132
|
+
pattern = /^\d+\.\d+\.\d+$/
|
133
|
+
pattern.match?(version.to_s)
|
134
|
+
end
|
135
|
+
|
87
136
|
def self.get_version_code(line)
|
88
137
|
version_components = line.strip.split('+')
|
89
138
|
return version_components[version_components.length - 1].tr("\"", "")
|
90
139
|
end
|
91
140
|
|
92
|
-
def self.
|
93
|
-
|
141
|
+
def self.get_patch_minor_major(version_name)
|
142
|
+
return version_name.split(".")
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.increment_version_code(version, new_version_code = nil)
|
146
|
+
if new_version_code.nil?
|
94
147
|
new_version_code = version.to_i + 1
|
95
148
|
end
|
96
149
|
return new_version_code.to_s
|
@@ -104,10 +157,7 @@ module Fastlane
|
|
104
157
|
end
|
105
158
|
|
106
159
|
def self.increment_version_name(version_name, version_component = 'patch', new_value)
|
107
|
-
|
108
|
-
new_value = nil
|
109
|
-
end
|
110
|
-
major, minor, patch = version_name.split(".")
|
160
|
+
major, minor, patch = get_patch_minor_major(version_name)
|
111
161
|
if version_component == 'major'
|
112
162
|
major = new_value || (major.to_i + 1)
|
113
163
|
minor = 0
|
@@ -121,6 +171,10 @@ module Fastlane
|
|
121
171
|
return "#{major}.#{minor}.#{patch}"
|
122
172
|
end
|
123
173
|
|
174
|
+
def self.is_int(value)
|
175
|
+
return value.to_i.to_s == value
|
176
|
+
end
|
177
|
+
|
124
178
|
def self.description
|
125
179
|
"Effortlessly manage and update your flutter project version."
|
126
180
|
end
|
@@ -134,7 +188,6 @@ module Fastlane
|
|
134
188
|
end
|
135
189
|
|
136
190
|
def self.details
|
137
|
-
# Optional:
|
138
191
|
"Flutter versioner is a powerful fastlane plugin designed to simplify the management of flutter project version. With this you can easily update project version to any specified major,minor,or patch level as well as adjust the version code/build number."
|
139
192
|
end
|
140
193
|
|
@@ -143,21 +196,21 @@ module Fastlane
|
|
143
196
|
FastlaneCore::ConfigItem.new(key: :version_component,
|
144
197
|
env_name: "FLUTTERVERSIONER_VERSION_COMPONENT",
|
145
198
|
description: "The component of the version to be updated, version format : major.minor.patch+version_code. (default : version_code)",
|
146
|
-
optional:
|
199
|
+
optional: false,
|
147
200
|
type: String,
|
148
201
|
default_value: "version_code"),
|
149
202
|
FastlaneCore::ConfigItem.new(key: :pubspec_file_path,
|
150
203
|
env_name: "FLUTTERVERSIONER_PUBSPEC_FILE_PATH",
|
151
|
-
description: "The relative path to the pubspec file containing the version parameter (default
|
152
|
-
optional:
|
204
|
+
description: "The relative path to the pubspec file containing the version parameter (default:../pubspec.yaml)",
|
205
|
+
optional: false,
|
153
206
|
type: String,
|
154
|
-
default_value:
|
207
|
+
default_value: "../pubspec.yaml"),
|
155
208
|
FastlaneCore::ConfigItem.new(key: :value,
|
156
209
|
env_name: "FLUTTERVERSIONER_VALUE",
|
157
210
|
description: "Change to a specific version (optional)",
|
158
211
|
optional: true,
|
159
|
-
type:
|
160
|
-
default_value:
|
212
|
+
type: String,
|
213
|
+
default_value: nil),
|
161
214
|
FastlaneCore::ConfigItem.new(key: :ext_constant_name,
|
162
215
|
env_name: "FLUTTERVERSIONER_EXT_CONSTANT_NAME",
|
163
216
|
description: "If the version code is set in an ext constant, specify the constant name (optional)",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-flutter_versioner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abhijith K
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: iamabhijith.k@gmail.com
|