lasertag 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +5 -0
- data/.travis.yml +5 -0
- data/README.md +21 -5
- data/extras/terminal.gif +0 -0
- data/lasertag.gemspec +3 -3
- data/lib/lasertag.rb +77 -34
- data/lib/lasertag/version.rb +1 -1
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9426e016e328362a09deadd681d53319d2ad8a6e
|
4
|
+
data.tar.gz: c6035f6b106dee761e40e24f891314e1d2c8c46b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8823d5eec834807eb5e451acb0cf40cf290e136f5723ecfbe8ffd7e5642bd2238d0880e8d69f2c21c192af2a93981d265b9518e119ae2beea53a6ea7612b628
|
7
|
+
data.tar.gz: 0380b6e3b4a54ebd027970b71629a18643870373861a69d94c5eb4d65ca9a416ef941258e8f2e843c83dc0004ae87dfc1f28412fbe626db060f4f0bc558aa051
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,21 +1,37 @@
|
|
1
1
|
# Lasertag
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/lasertag.svg)](https://badge.fury.io/rb/lasertag) [![Build Status](https://travis-ci.org/cesarferreira/lasertag.svg?branch=master)](https://travis-ci.org/cesarferreira/lasertag) [![security](https://hakiri.io/github/cesarferreira/lasertag/master.svg)](https://hakiri.io/github/cesarferreira/lasertag/master) [![Code Climate](https://codeclimate.com/github/cesarferreira/lasertag/badges/gpa.svg)](https://codeclimate.com/github/cesarferreira/lasertag) [![Inline docs](http://inch-ci.org/github/cesarferreira/lasertag.svg?branch=master)](http://inch-ci.org/github/cesarferreira/lasertag)
|
2
3
|
|
3
|
-
|
4
|
+
> Like most VCSs, Git has the ability to tag specific points in history as being important. Typically people use this functionality to mark release points (v1.0.0, and so on)
|
4
5
|
|
6
|
+
<!-- Match your CVS tags with your android versions with laser speed! -->
|
5
7
|
|
6
|
-
|
8
|
+
<p align="center">
|
9
|
+
<img src="https://raw.githubusercontent.com/cesarferreira/lasertag/master/extras/terminal.gif" width="100%" />
|
10
|
+
</p>
|
7
11
|
|
8
|
-
$ lasertag -m app
|
9
12
|
|
10
|
-
|
13
|
+
## Basic Usage
|
11
14
|
|
12
|
-
$ lasertag --module
|
15
|
+
$ lasertag --module [module_name]
|
16
|
+
|
17
|
+
#### Going deeper
|
18
|
+
|
19
|
+
If you want to specify a flavor:
|
20
|
+
|
21
|
+
$ lasertag --module app --flavor prod
|
13
22
|
|
14
23
|
|
15
24
|
## Installation
|
16
25
|
|
17
26
|
$ gem install lasertag
|
18
27
|
|
28
|
+
## Under the hood
|
29
|
+
|
30
|
+
- Tries to compile the project
|
31
|
+
- Find out the package and the app version
|
32
|
+
- executes git tag -a v[tag_version] -m "tag [tag_name]"
|
33
|
+
- executes git push origin [tag_name]
|
34
|
+
|
19
35
|
|
20
36
|
## License
|
21
37
|
|
data/extras/terminal.gif
ADDED
Binary file
|
data/lasertag.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.authors = ["cesarferreira"]
|
15
15
|
spec.email = ["cesar.manuel.ferreira@gmail.com"]
|
16
16
|
|
17
|
-
spec.summary = %q{
|
18
|
-
spec.description = %q{
|
17
|
+
spec.summary = %q{Automatically map android app version to git tags}
|
18
|
+
spec.description = %q{Automatically map android app version to git tags}
|
19
19
|
spec.homepage = "https://github.com/cesarferreira/lasertag"
|
20
20
|
spec.license = "MIT"
|
21
21
|
|
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency 'bundler', '~> 1.7'
|
34
34
|
spec.add_dependency 'colorize', '~> 0.7'
|
35
35
|
spec.add_dependency 'oga', '~> 1.3.1'
|
36
|
-
spec.add_dependency '
|
36
|
+
spec.add_dependency 'git', '~> 1.2'
|
37
37
|
|
38
38
|
end
|
data/lib/lasertag.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'colorize'
|
3
|
-
require 'hirb'
|
4
3
|
require 'oga'
|
5
4
|
require 'lasertag/version'
|
6
|
-
require '
|
5
|
+
require 'git'
|
7
6
|
|
8
7
|
module Lasertag
|
9
8
|
class MainApp
|
@@ -12,7 +11,7 @@ module Lasertag
|
|
12
11
|
# defaults
|
13
12
|
@app_path = Dir.pwd
|
14
13
|
@app_module = nil
|
15
|
-
@
|
14
|
+
@app_flavor = nil
|
16
15
|
|
17
16
|
@require_analyses = true
|
18
17
|
|
@@ -31,16 +30,16 @@ module Lasertag
|
|
31
30
|
opts.separator ''
|
32
31
|
opts.separator "Options"
|
33
32
|
|
34
|
-
opts.on('-
|
35
|
-
@
|
33
|
+
opts.on('-m', '--module MODULE', 'Specifies the app module') do |app_module|
|
34
|
+
@app_module = app_module
|
36
35
|
end
|
37
36
|
|
38
|
-
opts.on('-f', '--
|
39
|
-
@
|
37
|
+
opts.on('-f', '--flavor FLAVOR', 'Specifies the flavor (e.g. dev, qa, prod)') do |app_flavor|
|
38
|
+
@app_flavor = app_flavor
|
40
39
|
end
|
41
40
|
|
42
|
-
opts.on('-
|
43
|
-
@
|
41
|
+
opts.on('-p PATH', '--path PATH', 'Custom path to android project') do |app_path|
|
42
|
+
@app_path = app_path if @app_path != '.'
|
44
43
|
end
|
45
44
|
|
46
45
|
opts.on('-h', '--help', 'Displays help') do
|
@@ -74,10 +73,6 @@ module Lasertag
|
|
74
73
|
# end
|
75
74
|
end
|
76
75
|
|
77
|
-
if @clear_flag
|
78
|
-
android_project.clear_app_data
|
79
|
-
end
|
80
|
-
|
81
76
|
unless @app_module
|
82
77
|
puts "Please give me an app module name".yellow
|
83
78
|
exit 1
|
@@ -91,8 +86,19 @@ module Lasertag
|
|
91
86
|
|
92
87
|
Dir.chdir @app_path
|
93
88
|
|
89
|
+
### dont let uncommited stuffgit commit
|
90
|
+
if has_uncommited_code
|
91
|
+
puts "You have uncommited code, please commit it first".red
|
92
|
+
exit 1
|
93
|
+
end
|
94
|
+
|
94
95
|
### Assemble
|
95
|
-
system assemble_command
|
96
|
+
is_success = system assemble_command
|
97
|
+
|
98
|
+
unless is_success
|
99
|
+
puts "\n\nSomething went wrong so I stopped all the madness!!\n".red
|
100
|
+
exit 1
|
101
|
+
end
|
96
102
|
|
97
103
|
### Get project properties
|
98
104
|
@hash = project_properties @app_module
|
@@ -102,24 +108,66 @@ module Lasertag
|
|
102
108
|
### Find app info
|
103
109
|
app_info = get_app_info
|
104
110
|
|
105
|
-
puts "For package #{app_info[:package].
|
111
|
+
puts "For package #{app_info[:package].yellow}\n"
|
106
112
|
|
107
|
-
###
|
113
|
+
### git tag -a "versionNumber" -m "versionName"
|
108
114
|
|
115
|
+
package = app_info[:package]
|
116
|
+
name = @app_module # not quite correct
|
117
|
+
version = app_info[:versionName]
|
118
|
+
|
119
|
+
builded = "#{@app_module}/build/outputs/apk/#{@app_module}#{"-#{@app_flavor}" if @app_flavor}-release-unsigned.apk"
|
120
|
+
|
121
|
+
puts "#{name} #{version} built to #{builded}.".green
|
122
|
+
|
123
|
+
tag_code "v#{version}"
|
124
|
+
puts "Tagged v#{version}.".green
|
125
|
+
|
126
|
+
#$ git push origin v1.5
|
127
|
+
push_tag "v#{version}"
|
128
|
+
|
129
|
+
puts "Pushed git commits and tags.".green
|
130
|
+
puts "Pushed #{name} #{version} to remote.".green
|
131
|
+
|
132
|
+
end
|
109
133
|
|
110
|
-
### git tag -a "versionNumber" -m "versionName"
|
111
134
|
|
112
|
-
|
113
|
-
|
135
|
+
### HAS UNCOMMITED CODE?
|
136
|
+
def has_uncommited_code
|
137
|
+
g = Git.open(Dir.pwd)
|
138
|
+
g.status.changed.size > 0
|
139
|
+
end
|
114
140
|
|
115
|
-
|
141
|
+
### PUSH TAG
|
142
|
+
def push_tag(version)
|
143
|
+
g = Git.open(Dir.pwd)
|
144
|
+
begin
|
145
|
+
g.push(g.remote('origin'), version)
|
146
|
+
rescue Exception => e
|
147
|
+
puts "Can't push tag\n reason: #{e.to_s.red}"
|
148
|
+
exit 1
|
149
|
+
end
|
150
|
+
end
|
116
151
|
|
117
|
-
puts "Tagged #{version}\n".green
|
118
152
|
|
153
|
+
### TAG CODE
|
154
|
+
def tag_code(version)
|
155
|
+
g = Git.open(Dir.pwd)
|
156
|
+
begin
|
157
|
+
g.add_tag(version)
|
158
|
+
rescue Exception => e
|
159
|
+
expected = "'#{version}' already exists"
|
160
|
+
if e.to_s.include? expected
|
161
|
+
puts "Error ocurred: #{expected.red}"
|
162
|
+
else
|
163
|
+
puts "Can't tag the code\n reason: #{e.to_s.red}"
|
164
|
+
end
|
119
165
|
|
120
|
-
|
166
|
+
exit 1
|
167
|
+
end
|
121
168
|
end
|
122
169
|
|
170
|
+
### IS THE ANDROID HOME DEFINED?
|
123
171
|
def android_home_is_defined
|
124
172
|
sdk = `echo $ANDROID_HOME`.gsub("\n",'')
|
125
173
|
!sdk.empty?
|
@@ -142,8 +190,7 @@ module Lasertag
|
|
142
190
|
File.exist?(settings_path)
|
143
191
|
end
|
144
192
|
|
145
|
-
|
146
|
-
|
193
|
+
#########################################################
|
147
194
|
|
148
195
|
def convert_values_to_hash (str)
|
149
196
|
hash = Hash.new
|
@@ -167,9 +214,7 @@ module Lasertag
|
|
167
214
|
project = "#{project}:" if project
|
168
215
|
|
169
216
|
result = %x[gradle #{project}properties]
|
170
|
-
|
171
|
-
#puts Hirb::Helpers::AutoTable.render(hash)
|
172
|
-
hash
|
217
|
+
convert_values_to_hash result
|
173
218
|
end
|
174
219
|
|
175
220
|
|
@@ -179,9 +224,6 @@ module Lasertag
|
|
179
224
|
|
180
225
|
parser = Oga.parse_xml(handle)
|
181
226
|
|
182
|
-
# package="com.cesarferreira.testout"
|
183
|
-
# versionCode="10000"
|
184
|
-
# versionName="1.0.0"
|
185
227
|
package = parser.xpath("//manifest").attr('package').last.value
|
186
228
|
versionCode = parser.xpath("//manifest").attr('android:versionCode').last.value
|
187
229
|
versionName = parser.xpath("//manifest").attr('android:versionName').last.value
|
@@ -196,7 +238,7 @@ module Lasertag
|
|
196
238
|
def get_path_to_merged_manifest
|
197
239
|
build_dir = @hash['buildDir']
|
198
240
|
|
199
|
-
flavor = @
|
241
|
+
flavor = @app_flavor ? "/#{@app_flavor}/" : "/"
|
200
242
|
|
201
243
|
path = "#{build_dir}/intermediates/manifests/full"
|
202
244
|
path = "#{path}#{flavor}release/"
|
@@ -206,8 +248,9 @@ module Lasertag
|
|
206
248
|
exists = File.exist?(full_path)
|
207
249
|
|
208
250
|
unless exists
|
209
|
-
puts "
|
210
|
-
puts "Try specifying a Flavor".
|
251
|
+
puts "The merged manifest could not be found\n"
|
252
|
+
puts " Try specifying a Flavor\n".green
|
253
|
+
system("lasertag -h")
|
211
254
|
exit 1
|
212
255
|
end
|
213
256
|
|
@@ -216,7 +259,7 @@ module Lasertag
|
|
216
259
|
end
|
217
260
|
|
218
261
|
def assemble_command
|
219
|
-
"gradle assemble#{(@
|
262
|
+
"gradle :#{@app_module}:assemble#{(@app_flavor or "").capitalize}Release"
|
220
263
|
end
|
221
264
|
|
222
265
|
end
|
data/lib/lasertag/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lasertag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cesarferreira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -95,20 +95,20 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.3.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: git
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1.2'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
111
|
-
description:
|
110
|
+
version: '1.2'
|
111
|
+
description: Automatically map android app version to git tags
|
112
112
|
email:
|
113
113
|
- cesar.manuel.ferreira@gmail.com
|
114
114
|
executables:
|
@@ -117,11 +117,14 @@ extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
119
|
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".travis.yml"
|
120
122
|
- Gemfile
|
121
123
|
- LICENSE.txt
|
122
124
|
- README.md
|
123
125
|
- Rakefile
|
124
126
|
- bin/lasertag
|
127
|
+
- extras/terminal.gif
|
125
128
|
- lasertag.gemspec
|
126
129
|
- lib/lasertag.rb
|
127
130
|
- lib/lasertag/version.rb
|
@@ -148,6 +151,6 @@ rubyforge_project:
|
|
148
151
|
rubygems_version: 2.4.8
|
149
152
|
signing_key:
|
150
153
|
specification_version: 4
|
151
|
-
summary:
|
154
|
+
summary: Automatically map android app version to git tags
|
152
155
|
test_files: []
|
153
156
|
has_rdoc:
|