raykit 0.0.77 → 0.0.78
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 +4 -4
- data/bin/raykit +2 -1
- data/lib/raykit.rb +0 -3
- data/lib/raykit/console.rb +120 -64
- data/lib/raykit/git/directory.rb +31 -2
- data/lib/raykit/git/repositories.rb +5 -1
- data/lib/raykit/project.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6f6c226590ce474b86d043126f2f50b8036d96a6ae87fb55adbbfb94108eee0
|
4
|
+
data.tar.gz: 3fc0bc65e376b5fd02c2344c775a4ce8eba54b10b7eaf8bc3fd849d685163b2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dddd10d8afb2965f25625a3eae53891223e4fbac3434aff317c8e15dc996b9eea3182b54949ff1096e8f55899e6f4b4e8396502e175a552fa807fb7371b051b
|
7
|
+
data.tar.gz: 83329ce09fe77124ae251db8e762a03247357c1896dd06605e3126b5eff07081dc71dbfcf89904a3c956aea9d1cff4aa54f9da217d4536e11572cd5ab003351d
|
data/bin/raykit
CHANGED
data/lib/raykit.rb
CHANGED
data/lib/raykit/console.rb
CHANGED
@@ -1,79 +1,84 @@
|
|
1
1
|
require 'optparse'
|
2
|
+
require 'slop'
|
2
3
|
|
3
4
|
module Raykit
|
4
|
-
|
5
|
-
class Parser
|
6
|
-
def self.parse(options)
|
7
|
-
hash=Hash.new
|
8
|
-
opt_parser = OptionParser.new do |opts|
|
9
|
-
opts.banner = "Usage: raykit [options]"
|
10
|
-
opts.on('-l','--list [PATTERN]','list remotes') do |pattern|
|
11
|
-
hash[:verb]="list"
|
12
|
-
hash[:pattern]=pattern
|
13
|
-
return hash
|
14
|
-
end
|
15
|
-
|
16
|
-
opts.on('-i','--import','import remotes') do |import|
|
17
|
-
hash[:verb]="import"
|
18
|
-
return hash
|
19
|
-
end
|
20
|
-
|
21
|
-
opts.on('-r','--rake [PATTERN]','rake [PATTERN]') do |pattern|
|
22
|
-
hash[:verb]="rake"
|
23
|
-
if(pattern.nil?)
|
24
|
-
hash[:pattern] = ''
|
25
|
-
else
|
26
|
-
hash[:pattern]=pattern
|
27
|
-
end
|
28
|
-
return hash
|
29
|
-
end
|
30
|
-
|
31
|
-
opts.on('-w','--work [PATTERN]','work [PATTERN]') do |pattern|
|
32
|
-
hash[:verb]="work"
|
33
|
-
if(pattern.nil?)
|
34
|
-
hash[:pattern] = ''
|
35
|
-
else
|
36
|
-
hash[:pattern]=pattern
|
37
|
-
end
|
38
|
-
return hash
|
39
|
-
end
|
5
|
+
|
40
6
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
7
|
+
# The implementation for the raykit console application
|
8
|
+
class Console
|
9
|
+
attr_accessor :opts
|
10
|
+
def initialize
|
11
|
+
@opts = Slop.parse do |o|
|
12
|
+
o.string '-r', '--remote', 'remote name or substring', default: ''
|
13
|
+
#o.string '-b', '--branch','branch name'
|
14
|
+
o.string '-t','--task','rake task', default: 'default'
|
15
|
+
o.bool '-v', '--verbose', 'enable verbose mode'
|
16
|
+
o.bool '-i','--import','import remotes from work directory'
|
17
|
+
o.bool '-p','--pull','pull work directory'
|
18
|
+
o.bool '-w','--work','rake work directory'
|
19
|
+
o.bool '-m','--make','make latest commit'
|
45
20
|
end
|
46
21
|
|
47
|
-
|
48
|
-
|
22
|
+
if(opts.verbose?)
|
23
|
+
puts "options: " + Rainbow(@opts.to_hash).yellow.bright
|
24
|
+
end
|
49
25
|
end
|
50
|
-
end
|
51
26
|
|
52
|
-
|
53
|
-
class Console
|
54
|
-
def self.run
|
27
|
+
def run
|
55
28
|
if(ARGV.length == 0)
|
56
|
-
|
29
|
+
puts @opts
|
57
30
|
0
|
58
31
|
else
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
when 'rake'
|
68
|
-
rake(hash)
|
69
|
-
when 'work'
|
70
|
-
work(hash)
|
71
|
-
end
|
32
|
+
if(@opts.import?)
|
33
|
+
puts Rainbow('import').yellow.bright
|
34
|
+
puts "scanning #{REPOSITORIES.work_dir} for .git directories"
|
35
|
+
count=REPOSITORIES.length
|
36
|
+
REPOSITORIES.import(@opts[:remote])
|
37
|
+
new_count=REPOSITORIES.length-count
|
38
|
+
puts "imported #{new_count} remotes"
|
39
|
+
return 0
|
72
40
|
end
|
41
|
+
REPOSITORIES.select{|r| r.include?(@opts[:remote])}.each{|remote|
|
42
|
+
repo=Raykit::Git::Repository.new(remote)
|
43
|
+
work=Raykit::Git::Directory.new(repo.get_dev_dir('work'))
|
44
|
+
make=Raykit::Git::Directory.new(repo.get_dev_dir('make'))
|
45
|
+
|
46
|
+
puts Rainbow(remote).green.bright
|
47
|
+
if(@opts.pull?)
|
48
|
+
work.pull
|
49
|
+
end
|
50
|
+
if(@opts.work?)
|
51
|
+
if(!Dir.exist?(make.directory))
|
52
|
+
puts `git clone #{remote} #{work.directory}`
|
53
|
+
end
|
54
|
+
work.rake(@opts[:task])
|
55
|
+
end
|
56
|
+
if(@opts.make?)
|
57
|
+
if(!Dir.exist?(make.directory))
|
58
|
+
puts `git clone #{remote} #{make.directory}`
|
59
|
+
end
|
60
|
+
make.rake(@opts[:task])
|
61
|
+
end
|
62
|
+
}
|
63
|
+
|
64
|
+
#hash = Parser.parse ARGV
|
65
|
+
#if(hash.include?(:verb))
|
66
|
+
# verb = hash[:verb]
|
67
|
+
# case verb
|
68
|
+
# when 'list'
|
69
|
+
# list(hash)
|
70
|
+
# when 'import'
|
71
|
+
# import(hash)
|
72
|
+
# when 'rake'
|
73
|
+
# rake(hash)
|
74
|
+
# when 'work'
|
75
|
+
# work(hash)
|
76
|
+
# end
|
77
|
+
#end
|
73
78
|
end
|
74
79
|
end
|
75
80
|
|
76
|
-
def
|
81
|
+
def list(hash)
|
77
82
|
pattern=''
|
78
83
|
if(hash.include?(:pattern))
|
79
84
|
pattern=hash["pattern"]
|
@@ -87,7 +92,7 @@ module Raykit
|
|
87
92
|
}
|
88
93
|
end
|
89
94
|
|
90
|
-
def
|
95
|
+
def import(hash)
|
91
96
|
pattern=''
|
92
97
|
pattern=hash["pattern"] if(hash.include?("pattern"))
|
93
98
|
puts 'scanning...'
|
@@ -97,7 +102,7 @@ module Raykit
|
|
97
102
|
puts "imported #{new_count} git repositories"
|
98
103
|
end
|
99
104
|
|
100
|
-
def
|
105
|
+
def rake(hash)
|
101
106
|
REPOSITORIES.each{|remote|
|
102
107
|
if(remote.include?(hash[:pattern]))
|
103
108
|
begin
|
@@ -120,7 +125,7 @@ module Raykit
|
|
120
125
|
}
|
121
126
|
end
|
122
127
|
|
123
|
-
def
|
128
|
+
def work(hash)
|
124
129
|
REPOSITORIES.each{|remote|
|
125
130
|
if(remote.include?(hash[:pattern]))
|
126
131
|
puts "remote: #{remote}"
|
@@ -134,5 +139,56 @@ module Raykit
|
|
134
139
|
}
|
135
140
|
end
|
136
141
|
end
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
# Parses the command line arguments for the Raykit console application
|
146
|
+
class Parser
|
147
|
+
def self.parse(options)
|
148
|
+
hash=Hash.new
|
149
|
+
opt_parser = OptionParser.new do |opts|
|
150
|
+
opts.banner = "Usage: raykit [options]"
|
151
|
+
opts.on('-l','--list [PATTERN]','list remotes') do |pattern|
|
152
|
+
hash[:verb]="list"
|
153
|
+
hash[:pattern]=pattern
|
154
|
+
return hash
|
155
|
+
end
|
156
|
+
|
157
|
+
opts.on('-i','--import','import remotes') do |import|
|
158
|
+
hash[:verb]="import"
|
159
|
+
return hash
|
160
|
+
end
|
161
|
+
|
162
|
+
opts.on('-r','--rake [PATTERN]','rake [PATTERN]') do |pattern|
|
163
|
+
hash[:verb]="rake"
|
164
|
+
if(pattern.nil?)
|
165
|
+
hash[:pattern] = ''
|
166
|
+
else
|
167
|
+
hash[:pattern]=pattern
|
168
|
+
end
|
169
|
+
return hash
|
170
|
+
end
|
171
|
+
|
172
|
+
opts.on('-w','--work [PATTERN]','work [PATTERN]') do |pattern|
|
173
|
+
hash[:verb]="work"
|
174
|
+
if(pattern.nil?)
|
175
|
+
hash[:pattern] = ''
|
176
|
+
else
|
177
|
+
hash[:pattern]=pattern
|
178
|
+
end
|
179
|
+
return hash
|
180
|
+
end
|
181
|
+
|
182
|
+
opts.on('-h','--help','help') do
|
183
|
+
puts opts
|
184
|
+
exit
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
opt_parser.parse!(options)
|
189
|
+
hash
|
190
|
+
end
|
191
|
+
end
|
137
192
|
end
|
138
193
|
|
194
|
+
CONSOLE=Raykit::Console.new
|
data/lib/raykit/git/directory.rb
CHANGED
@@ -4,6 +4,7 @@ module Raykit
|
|
4
4
|
class Directory
|
5
5
|
# The directory name of the local repository clone
|
6
6
|
attr_accessor :directory
|
7
|
+
@repository
|
7
8
|
|
8
9
|
def initialize(directory)
|
9
10
|
@directory=directory
|
@@ -26,15 +27,36 @@ module Raykit
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def rake(task)
|
29
|
-
|
30
|
+
sub_dir='work'
|
31
|
+
sub_dir='make' if(@directory.include?('/make/'))
|
32
|
+
rake_log=repository.get_dev_dir('log') + "/#{sub_dir}.rake.#{task}.json"
|
33
|
+
if(File.exist?(rake_log))
|
34
|
+
if(File.mtime(rake_log) > last_modified_time)
|
35
|
+
cmd=Raykit::Command::parse(File.read(rake_log))
|
36
|
+
puts 'up to date'
|
37
|
+
return
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Dir.chdir(@directory) do
|
30
42
|
if(File.exist?('rakefile.rb'))
|
31
|
-
PROJECT.run("rake #{task}")
|
43
|
+
cmd = PROJECT.run("rake #{task}")
|
44
|
+
if(cmd.exitstatus == 0)
|
45
|
+
FileUtils.mkdir_p(File.dirname(rake_log))
|
46
|
+
File.open(rake_log, 'w') {|f| f.write(JSON.generate(cmd.to_hash)) }
|
47
|
+
end
|
32
48
|
else
|
33
49
|
puts 'rakefile.rb not found'
|
34
50
|
end
|
35
51
|
end
|
36
52
|
end
|
37
53
|
|
54
|
+
def last_modified_time
|
55
|
+
Dir.chdir(@directory) do
|
56
|
+
File.mtime(Dir.glob("**/*.*").select{|f| File.file?(f)}.max_by {|f| File.mtime(f)})
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
38
60
|
# The latest tag for a branch of the repository
|
39
61
|
def latest_tag(branch)
|
40
62
|
Dir.chdir(directory) do
|
@@ -65,6 +87,13 @@ module Raykit
|
|
65
87
|
'master'
|
66
88
|
end
|
67
89
|
|
90
|
+
def repository
|
91
|
+
if(@repository.nil?)
|
92
|
+
@repository = Raykit::Git::Repository.new(remote)
|
93
|
+
end
|
94
|
+
@repository
|
95
|
+
end
|
96
|
+
|
68
97
|
def remote
|
69
98
|
if(Dir.exist?(directory))
|
70
99
|
Dir.chdir(directory) do
|
@@ -27,9 +27,13 @@ module Raykit
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
+
def work_dir
|
31
|
+
Environment::get_dev_dir('work')
|
32
|
+
end
|
33
|
+
|
30
34
|
def import(pattern)
|
31
35
|
git_dirs = Array.new
|
32
|
-
Dir.chdir(
|
36
|
+
Dir.chdir(work_dir) do
|
33
37
|
Dir.glob('**/.git'){|git_dir|
|
34
38
|
dir = File.expand_path('..',git_dir)
|
35
39
|
if(dir.length > 0)
|
data/lib/raykit/project.rb
CHANGED
@@ -140,7 +140,7 @@ module Raykit
|
|
140
140
|
elapsed_str = Timer.get_elapsed_str(cmd.elapsed,0)
|
141
141
|
if(cmd.exitstatus == 0)
|
142
142
|
puts elapsed_str + " " + Rainbow(cmd.command).yellow.bright
|
143
|
-
return elapsed_str + " " + cmd.command
|
143
|
+
#return elapsed_str + " " + cmd.command
|
144
144
|
else
|
145
145
|
puts "\r\n" + cmd.command + "\r\n"
|
146
146
|
system(cmd.command)
|
@@ -149,6 +149,7 @@ module Raykit
|
|
149
149
|
abort Rainbow(elapsed_str).red.bright + " " + Rainbow(cmd.command).white
|
150
150
|
end
|
151
151
|
end
|
152
|
+
cmd
|
152
153
|
end
|
153
154
|
end
|
154
155
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raykit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.78
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lou Parslow
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubygems_version: 3.0.
|
98
|
+
rubygems_version: 3.0.6
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: ruby gem to support rake ci/cd tasks
|