flutter_version_tool 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/fvt +48 -0
- data/lib/flutter_version_tool.rb +131 -102
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1782e84416b5417e0f7906fd83283e00353631e6533afc629e4eddbe73bce69
|
4
|
+
data.tar.gz: 8b85c7cd81d7f7889ecf1e07b1764c2de6dc019792985f06357292a2c158bfdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1449c5956148662132dbb6ab9e636d71bbee328c6f6650ae9f0f66b200affd63facf7fab828f254a3d0f264563fed87c11dded7afd566a09542b445c00aa1d
|
7
|
+
data.tar.gz: a1085aa3c7ba6621bada85118dc60d403549677d0a83915350188893e7ec5af8916a94d5989b7d3b51b7263c8dbae5df5a7aa73da78d9353c6e9cdec841ae92b
|
data/bin/fvt
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'flutter_version_tool'
|
5
|
+
|
6
|
+
class FVTExecutor
|
7
|
+
|
8
|
+
attr_accessor :options, :changingVersion, :changingBuild
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
self.options = {}
|
12
|
+
self.changingVersion = false
|
13
|
+
self.changingBuild = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse
|
17
|
+
OptionParser.new do |parser|
|
18
|
+
parser.banner = "Usage: fvt [options] version [pubspec path]"
|
19
|
+
parser.on("-v VERSION", "versionName value") do |v|
|
20
|
+
self.options[:version] = v
|
21
|
+
self.changingVersion = true
|
22
|
+
end
|
23
|
+
parser.on("-b BUILD", "versionCode value") do |b|
|
24
|
+
self.options[:build] = b
|
25
|
+
self.changingBuild = true
|
26
|
+
end
|
27
|
+
parser.on("--path PATH", "pubspec.yml path") do |p|
|
28
|
+
self.options[:path] = p
|
29
|
+
end
|
30
|
+
end.parse!
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
executor = FVTExecutor.new
|
36
|
+
executor.parse
|
37
|
+
|
38
|
+
fvt = executor.options[:path].nil? ? FlutterVersionTool.new : FlutterVersionTool.new(executor.options[:path])
|
39
|
+
p "Current pubspec app version is " + fvt.vFull
|
40
|
+
|
41
|
+
if executor.changingVersion
|
42
|
+
fvt.changeVersionName(executor.options[:version]);
|
43
|
+
p "New versionName (version): " + executor.options[:version]
|
44
|
+
end
|
45
|
+
if executor.changingBuild
|
46
|
+
fvt.changeVersionCode(executor.options[:build]);
|
47
|
+
p "New versionCode (build): " + executor.options[:build]
|
48
|
+
end
|
data/lib/flutter_version_tool.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
class FlutterVersionTool
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
attr_reader :pubspecPath, :vName, :vCode, :vMajor, :vMinor, :vPatch
|
5
|
+
|
6
|
+
def vFull
|
7
|
+
return "#{@vMajor.to_s}.#{@vMinor.to_s}.#{@vPatch.to_s}+#{@vCode.to_s}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(path = "pubspec.yaml")
|
11
11
|
# Load version from pubspec file
|
12
12
|
#
|
13
13
|
# Example:
|
@@ -16,105 +16,134 @@ class FlutterVersionTool
|
|
16
16
|
# Arguments:
|
17
17
|
# pubspecPath: (String)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
@pubspecPath = path
|
20
|
+
|
21
|
+
begin
|
22
|
+
pubspec = YAML::load_file(@pubspecPath)
|
23
|
+
rescue
|
24
|
+
raise 'Read pubspec.yaml failed'
|
25
|
+
end
|
26
|
+
|
27
|
+
version = pubspec["version"]
|
28
|
+
|
29
|
+
begin
|
30
|
+
if not version.include? "+"
|
31
|
+
raise
|
25
32
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
v_sections = version.split("+")
|
34
|
+
@vName = v_sections[0].to_s
|
35
|
+
@vCode = v_sections[1].to_i
|
36
|
+
rescue
|
37
|
+
@noCode = true
|
38
|
+
@vName = version
|
39
|
+
@vCode = 0
|
40
|
+
end
|
41
|
+
|
42
|
+
parseSemVer(@vName)
|
43
|
+
|
44
|
+
# begin
|
45
|
+
# if not vName.include? "."
|
46
|
+
# raise
|
47
|
+
# end
|
48
|
+
# vName_sections = @vName.split(".")
|
49
|
+
# @vMajor = vName_sections[0].to_i
|
50
|
+
# @vMinor = vName_sections[1].to_i
|
51
|
+
# if (vName_sections.length() > 2)
|
52
|
+
# @vPatch = vName_sections[2].to_i
|
53
|
+
# else
|
54
|
+
# @vPatch = 0
|
55
|
+
# end
|
56
|
+
# rescue
|
57
|
+
# @vMajor = @vName.to_i
|
58
|
+
# @vMinor = 0
|
59
|
+
# @vPatch = 0
|
60
|
+
# end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
private def parseSemVer(pVersion)
|
65
|
+
begin
|
66
|
+
if not pVersion.include? "."
|
67
|
+
raise
|
40
68
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@vMinor = vName_sections[1].to_i
|
49
|
-
if (vName_sections.length() > 2)
|
50
|
-
@vPatch = vName_sections[2].to_i
|
51
|
-
else
|
52
|
-
@vPatch = 0
|
53
|
-
end
|
54
|
-
rescue
|
55
|
-
@vMajor = @vName.to_i
|
56
|
-
@vMinor = 0
|
57
|
-
@vPatch = 0
|
69
|
+
pVersion_sections = pVersion.split(".")
|
70
|
+
@vMajor = pVersion_sections[0].to_i
|
71
|
+
@vMinor = pVersion_sections[1].to_i
|
72
|
+
if (pVersion_sections.length() > 2)
|
73
|
+
@vPatch = pVersion_sections[2].to_i
|
74
|
+
else
|
75
|
+
@vPatch = 0
|
58
76
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
fileString = File.read(@pubspecPath)
|
64
|
-
newFileString = fileString.gsub(/^version:\s.+/, "version: "+self.vFull)
|
65
|
-
File.write(@pubspecPath, newFileString)
|
66
|
-
end
|
67
|
-
|
68
|
-
def changeVersionCode(p_code)
|
69
|
-
# Change version build number directly to any number
|
70
|
-
#
|
71
|
-
# Example:
|
72
|
-
# >> fvt.changeVersionCode(140)
|
73
|
-
# Arguments:
|
74
|
-
# p_code: (Integer)
|
75
|
-
|
76
|
-
@vCode=p_code.to_i
|
77
|
-
commitChanges
|
77
|
+
rescue
|
78
|
+
@vMajor = pVersion.to_i
|
79
|
+
@vMinor = 0
|
80
|
+
@vPatch = 0
|
78
81
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
82
|
+
end
|
83
|
+
|
84
|
+
private def commitChanges
|
85
|
+
fileString = File.read(@pubspecPath)
|
86
|
+
newFileString = fileString.gsub(/^version:\s.+/, "version: " + self.vFull)
|
87
|
+
File.write(@pubspecPath, newFileString)
|
88
|
+
end
|
89
|
+
|
90
|
+
def changeVersionName(p_name)
|
91
|
+
@vName = p_name.to_s
|
92
|
+
parseSemVer(@vName)
|
93
|
+
commitChanges
|
94
|
+
end
|
95
|
+
|
96
|
+
def changeVersionCode(p_code)
|
97
|
+
# Change version build number directly to any number
|
98
|
+
#
|
99
|
+
# Example:
|
100
|
+
# >> fvt.changeVersionCode(140)
|
101
|
+
# Arguments:
|
102
|
+
# p_code: (Integer)
|
103
|
+
|
104
|
+
@vCode = p_code.to_i
|
105
|
+
commitChanges
|
106
|
+
end
|
107
|
+
|
108
|
+
def bumpVersionCode(increment = 1)
|
109
|
+
# Increment version build number (default by +1)
|
110
|
+
#
|
111
|
+
# Example:
|
112
|
+
# >> fvt.bumpVersionCode(1)
|
113
|
+
# Arguments:
|
114
|
+
# increment: (Integer)
|
115
|
+
|
116
|
+
@vCode = @vCode + increment
|
117
|
+
commitChanges
|
118
|
+
end
|
119
|
+
|
120
|
+
def bumpVersionName(level = "major", increment = 1)
|
121
|
+
# Increment version name semantically (default major version by +1)
|
122
|
+
#
|
123
|
+
# Example:
|
124
|
+
# >> fvt.bumpVersionName("patch")
|
125
|
+
# Arguments:
|
126
|
+
# level: ("major","minor","patch")
|
127
|
+
# increment: (Integer)
|
128
|
+
|
129
|
+
case level
|
130
|
+
when "major"
|
131
|
+
@vMajor = @vMajor + increment
|
132
|
+
@vMinor = 0
|
133
|
+
@vPatch = 0
|
134
|
+
puts "Bumping major"
|
135
|
+
when "minor"
|
136
|
+
@vMinor = @vMinor + increment
|
137
|
+
@vPatch = 0
|
138
|
+
puts "Bumping minor"
|
139
|
+
when "patch"
|
140
|
+
@vPatch = @vPatch + increment
|
141
|
+
puts "Bumping patch"
|
142
|
+
else
|
143
|
+
puts "Nope"
|
117
144
|
end
|
118
|
-
|
145
|
+
commitChanges
|
119
146
|
end
|
147
|
+
|
148
|
+
end
|
120
149
|
|
metadata
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flutter_version_tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rim Ganiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A tool for maintaning Flutter project versioning
|
14
14
|
email: cj_rimix@rambler.ru
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- fvt
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- bin/fvt
|
19
21
|
- lib/flutter_version_tool.rb
|
20
22
|
homepage: https://rubygems.org/gems/flutter_version_tool
|
21
23
|
licenses:
|
@@ -36,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
38
|
- !ruby/object:Gem::Version
|
37
39
|
version: '0'
|
38
40
|
requirements: []
|
39
|
-
rubygems_version: 3.
|
41
|
+
rubygems_version: 3.4.6
|
40
42
|
signing_key:
|
41
43
|
specification_version: 4
|
42
44
|
summary: Flutter Version Tool
|