raykit 0.0.304 → 0.0.305
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 +4 -2
- data/lib/raykit/command.rb +238 -241
- data/lib/raykit/console.rb +256 -260
- data/lib/raykit/dir.rb +39 -36
- data/lib/raykit/dotnet.rb +90 -90
- data/lib/raykit/environment.rb +77 -77
- data/lib/raykit/git/commit.rb +12 -13
- data/lib/raykit/git/directory.rb +142 -147
- data/lib/raykit/git/files.rb +43 -42
- data/lib/raykit/git/repositories.rb +75 -77
- data/lib/raykit/git/repository.rb +90 -93
- data/lib/raykit/log.rb +39 -37
- data/lib/raykit/logevent.rb +30 -28
- data/lib/raykit/logging.rb +47 -47
- data/lib/raykit/msbuild.rb +19 -11
- data/lib/raykit/nugetpackage.rb +8 -8
- data/lib/raykit/project.rb +261 -274
- data/lib/raykit/rake.rb +29 -31
- data/lib/raykit/runner.rb +37 -37
- data/lib/raykit/secrets.rb +30 -30
- data/lib/raykit/sourceImport.rb +62 -63
- data/lib/raykit/sourceImports.rb +35 -38
- data/lib/raykit/string.rb +14 -12
- data/lib/raykit/tasks.rb +46 -48
- data/lib/raykit/text.rb +24 -22
- data/lib/raykit/timer.rb +24 -22
- data/lib/raykit/version.rb +79 -86
- data/lib/raykit/vstest.rb +17 -15
- data/lib/raykit/zip.rb +35 -37
- data/lib/raykit.rb +14 -14
- metadata +11 -11
data/lib/raykit/project.rb
CHANGED
|
@@ -1,309 +1,296 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rake/clean"
|
|
4
|
+
require "digest"
|
|
5
|
+
RAKE_DIRECTORY = Rake.application.original_dir
|
|
6
|
+
|
|
4
7
|
module Raykit
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
attr_accessor :timer
|
|
8
|
-
attr_accessor :verbose
|
|
9
|
-
@directory
|
|
10
|
-
@version
|
|
11
|
-
@remote
|
|
12
|
-
@repository
|
|
13
|
-
@git_directory
|
|
14
|
-
attr_accessor :target
|
|
15
|
-
#@log
|
|
16
|
-
#@commit_message_filename
|
|
17
|
-
|
|
18
|
-
def initialize()
|
|
19
|
-
@verbose=false
|
|
20
|
-
@timer=Raykit::Timer.new
|
|
21
|
-
@remote=''
|
|
22
|
-
@commit_message_filename="commit_message.tmp"
|
|
23
|
-
if(Dir.exist?(RAKE_DIRECTORY))
|
|
24
|
-
@directory=RAKE_DIRECTORY
|
|
25
|
-
if(Dir.exist?("#{RAKE_DIRECTORY}/.git") && Dir.exist?(@directory))
|
|
26
|
-
@git_directory=Raykit::Git::Directory.new(@directory)
|
|
27
|
-
@remote=@git_directory.remote
|
|
28
|
-
end
|
|
29
|
-
else
|
|
30
|
-
@directory=''
|
|
31
|
-
end
|
|
8
|
+
class Project
|
|
9
|
+
attr_accessor :name, :timer, :verbose, :target
|
|
32
10
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
slns = Dir.glob("*.sln")
|
|
39
|
-
if(slns.length == 1)
|
|
40
|
-
@name=slns[0].gsub('.sln','')
|
|
41
|
-
else
|
|
42
|
-
gemspecs= Dir.glob('*.gemspec')
|
|
43
|
-
if(gemspecs.length == 1)
|
|
44
|
-
@name=gemspecs[0].gsub('.gemspec','')
|
|
45
|
-
else
|
|
46
|
-
remote_parts = @remote.split('/')
|
|
47
|
-
if(remote_parts.length > 0)
|
|
48
|
-
@name=remote_parts[-1].gsub('.git','')
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
@repository=Raykit::Git::Repository.new(@remote)
|
|
54
|
-
end
|
|
11
|
+
@directory
|
|
12
|
+
@version
|
|
13
|
+
@remote
|
|
14
|
+
@repository
|
|
15
|
+
@git_directory
|
|
55
16
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
end
|
|
17
|
+
# @log
|
|
18
|
+
# @commit_message_filename
|
|
59
19
|
|
|
60
|
-
|
|
61
|
-
|
|
20
|
+
def initialize
|
|
21
|
+
@verbose = false
|
|
22
|
+
@timer = Raykit::Timer.new
|
|
23
|
+
@remote = ""
|
|
24
|
+
@commit_message_filename = "commit_message.tmp"
|
|
25
|
+
if Dir.exist?(RAKE_DIRECTORY)
|
|
26
|
+
@directory = RAKE_DIRECTORY
|
|
27
|
+
if Dir.exist?("#{RAKE_DIRECTORY}/.git") && Dir.exist?(@directory)
|
|
28
|
+
@git_directory = Raykit::Git::Directory.new(@directory)
|
|
29
|
+
@remote = @git_directory.remote
|
|
62
30
|
end
|
|
31
|
+
else
|
|
32
|
+
@directory = ""
|
|
33
|
+
end
|
|
63
34
|
|
|
64
|
-
|
|
65
|
-
# @target
|
|
66
|
-
#end
|
|
67
|
-
def target_md5
|
|
68
|
-
if(!target.nil? && File.exist?(target))
|
|
69
|
-
return Digest::MD5.file(target).to_s.strip
|
|
70
|
-
end
|
|
71
|
-
''
|
|
72
|
-
end
|
|
35
|
+
# @log=Log.new("#{RAKE_DIRECTORY}/tmp/raykit.log")
|
|
73
36
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
37
|
+
if defined?(NAME)
|
|
38
|
+
@name = NAME
|
|
39
|
+
else
|
|
40
|
+
slns = Dir.glob("*.sln")
|
|
41
|
+
if slns.length == 1
|
|
42
|
+
@name = slns[0].gsub(".sln", "")
|
|
43
|
+
else
|
|
44
|
+
gemspecs = Dir.glob("*.gemspec")
|
|
45
|
+
if gemspecs.length == 1
|
|
46
|
+
@name = gemspecs[0].gsub(".gemspec", "")
|
|
47
|
+
else
|
|
48
|
+
remote_parts = @remote.split("/")
|
|
49
|
+
@name = remote_parts[-1].gsub(".git", "") if remote_parts.length.positive?
|
|
50
|
+
end
|
|
79
51
|
end
|
|
52
|
+
end
|
|
53
|
+
@repository = Raykit::Git::Repository.new(@remote)
|
|
54
|
+
end
|
|
80
55
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
text=`git log -n 1`
|
|
85
|
-
scan=text.scan(/commit ([\w]+)\s/)
|
|
86
|
-
return scan[0][0].to_s
|
|
87
|
-
end
|
|
88
|
-
end
|
|
56
|
+
def get_dev_dir(subdir)
|
|
57
|
+
Raykit::Environment.get_dev_dir(subdir)
|
|
58
|
+
end
|
|
89
59
|
|
|
90
|
-
|
|
91
|
-
Dir.chdir(@directory) do
|
|
92
|
-
return true if(!`git status`.include?('nothing to commit'))
|
|
93
|
-
end
|
|
94
|
-
false
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def outstanding_tag?
|
|
98
|
-
#puts `git log -n 1`
|
|
99
|
-
#!latest_tag_commit.eql?(latest_commit)
|
|
100
|
-
#commit 2e4cb6d6c0721e16cd06afee85b7cdc27354921b (HEAD -> master, tag: 0.0.180, origin/master, origin/HEAD)
|
|
101
|
-
outstanding_commit? || !`git log -n 1`.include?('tag:')
|
|
102
|
-
end
|
|
60
|
+
attr_reader :log, :directory, :remote
|
|
103
61
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
end
|
|
62
|
+
# def target
|
|
63
|
+
# @target
|
|
64
|
+
# end
|
|
65
|
+
def target_md5
|
|
66
|
+
return Digest::MD5.file(target).to_s.strip if !target.nil? && File.exist?(target)
|
|
110
67
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
#Dir.chdir(@directory) do
|
|
114
|
-
# if(Dir.glob("*.gemspec").length > 0)
|
|
115
|
-
# @version=`bump current`.gsub('Current version:','').strip
|
|
116
|
-
# else
|
|
117
|
-
# @version=Raykit::VersionHelper.detect(@name,@verbose)
|
|
118
|
-
# end
|
|
119
|
-
@version=Raykit::Version.detect(@name,@verbose)
|
|
120
|
-
#end
|
|
121
|
-
end
|
|
122
|
-
@version
|
|
123
|
-
end
|
|
68
|
+
""
|
|
69
|
+
end
|
|
124
70
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
71
|
+
def branch
|
|
72
|
+
@git_directory.branch
|
|
73
|
+
end
|
|
128
74
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
75
|
+
# latest local commit
|
|
76
|
+
def latest_commit
|
|
77
|
+
Dir.chdir(@directory) do
|
|
78
|
+
text = `git log -n 1`
|
|
79
|
+
scan = text.scan(/commit (\w+)\s/)
|
|
80
|
+
return scan[0][0].to_s
|
|
81
|
+
end
|
|
82
|
+
end
|
|
132
83
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
84
|
+
def outstanding_commit?
|
|
85
|
+
Dir.chdir(@directory) do
|
|
86
|
+
return true unless `git status`.include?("nothing to commit")
|
|
87
|
+
end
|
|
88
|
+
false
|
|
89
|
+
end
|
|
136
90
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
''
|
|
144
|
-
end
|
|
91
|
+
def outstanding_tag?
|
|
92
|
+
# puts `git log -n 1`
|
|
93
|
+
# !latest_tag_commit.eql?(latest_commit)
|
|
94
|
+
# commit 2e4cb6d6c0721e16cd06afee85b7cdc27354921b (HEAD -> master, tag: 0.0.180, origin/master, origin/HEAD)
|
|
95
|
+
outstanding_commit? || !`git log -n 1`.include?("tag:")
|
|
96
|
+
end
|
|
145
97
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
98
|
+
def has_diff?(filename)
|
|
99
|
+
Dir.chdir(@directory) do
|
|
100
|
+
text = `git diff #{filename}`.strip
|
|
101
|
+
return true if text.length.positive?
|
|
102
|
+
end
|
|
103
|
+
end
|
|
149
104
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
105
|
+
def version
|
|
106
|
+
if @version.nil?
|
|
107
|
+
# Dir.chdir(@directory) do
|
|
108
|
+
# if(Dir.glob("*.gemspec").length > 0)
|
|
109
|
+
# @version=`bump current`.gsub('Current version:','').strip
|
|
110
|
+
# else
|
|
111
|
+
# @version=Raykit::VersionHelper.detect(@name,@verbose)
|
|
112
|
+
# end
|
|
113
|
+
@version = Raykit::Version.detect(@name, @verbose)
|
|
114
|
+
# end
|
|
115
|
+
end
|
|
116
|
+
@version
|
|
117
|
+
end
|
|
155
118
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if matches = text.match(/size: ([. \w]+)$/)
|
|
160
|
-
matches[1]
|
|
161
|
-
else
|
|
162
|
-
text
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
119
|
+
# def update_version
|
|
120
|
+
# @version=Raykit::Version.detect(@name,@verbose)
|
|
121
|
+
# end
|
|
166
122
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if matches = text.match(/size-pack: ([. \w]+)$/)
|
|
171
|
-
matches[1]
|
|
172
|
-
else
|
|
173
|
-
text
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
end
|
|
123
|
+
def latest_tag
|
|
124
|
+
`git describe --abbrev=0`.strip
|
|
125
|
+
end
|
|
177
126
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
"%.1f" % (@timer.elapsed) + "s"
|
|
182
|
-
else
|
|
183
|
-
"%.0f" % (@timer.elapsed) + "s"
|
|
184
|
-
end
|
|
185
|
-
end
|
|
127
|
+
def latest_tag_commit
|
|
128
|
+
`git show-ref -s #{latest_tag}`.strip
|
|
129
|
+
end
|
|
186
130
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
puts "PROJECT.version".ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
|
|
192
|
-
puts "PROJECT.remote".ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
|
|
193
|
-
puts "PROJECT.branch".ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright
|
|
194
|
-
#puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
|
|
195
|
-
#puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
|
|
196
|
-
puts "PROJECT.latest_tag".ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
|
|
197
|
-
puts "PROJECT.latest_tag_commit".ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
|
|
198
|
-
puts "PROJECT.latest_tag_md5".ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
|
|
199
|
-
puts "PROJECT.latest_commit".ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
|
|
200
|
-
puts "PROJECT.last_modified_filename".ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
|
|
201
|
-
#puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
|
|
202
|
-
puts "PROJECT.size".ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
|
|
203
|
-
puts "PROJECT.size_pack".ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
|
|
204
|
-
puts "PROJECT.outstanding_commit?".ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
|
|
205
|
-
puts "PROJECT.outstanding_tag?".ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
|
|
206
|
-
puts ''
|
|
207
|
-
self
|
|
208
|
-
end
|
|
131
|
+
def latest_tag_md5
|
|
132
|
+
text = `git tag #{latest_tag} -n3`
|
|
133
|
+
scan = text.scan(/md5=(\w{32})/)
|
|
134
|
+
return scan[0][0].to_s.strip if scan.length.positive? && scan[0].length.positive?
|
|
209
135
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
136
|
+
""
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def last_modified_filename
|
|
140
|
+
Dir.chdir(@directory) do
|
|
141
|
+
Dir.glob("**/*.*").select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
|
|
142
|
+
end
|
|
143
|
+
end
|
|
215
144
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
145
|
+
def size
|
|
146
|
+
Dir.chdir(@directory) do
|
|
147
|
+
text = `git count-objects -v -H`
|
|
148
|
+
if matches = text.match(/size: ([. \w]+)$/)
|
|
149
|
+
matches[1]
|
|
150
|
+
else
|
|
151
|
+
text
|
|
219
152
|
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
220
155
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if(GIT_DIRECTORY.outstanding_commit?)
|
|
229
|
-
if(File.exist?(@commit_message_filename))
|
|
230
|
-
run("git commit --file #{@commit_message_filename}")
|
|
231
|
-
File.delete(@commit_message_filename)
|
|
232
|
-
else
|
|
233
|
-
run("git commit -m'#{commit_message}'")
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
else
|
|
238
|
-
puts "warning: .gitignore not found."
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
self
|
|
156
|
+
def size_pack
|
|
157
|
+
Dir.chdir(@directory) do
|
|
158
|
+
text = `git count-objects -v -H`
|
|
159
|
+
if matches = text.match(/size-pack: ([. \w]+)$/)
|
|
160
|
+
matches[1]
|
|
161
|
+
else
|
|
162
|
+
text
|
|
242
163
|
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def elapsed
|
|
168
|
+
elapsed = @timer.elapsed
|
|
169
|
+
if elapsed < 1.0
|
|
170
|
+
"#{format("%.1f", @timer.elapsed)}s"
|
|
171
|
+
else
|
|
172
|
+
"#{format("%.0f", @timer.elapsed)}s"
|
|
173
|
+
end
|
|
174
|
+
end
|
|
243
175
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
176
|
+
def info
|
|
177
|
+
ljust = 35
|
|
178
|
+
puts ""
|
|
179
|
+
puts "PROJECT.name".ljust(ljust) + Rainbow(PROJECT.name).yellow.bright
|
|
180
|
+
puts "PROJECT.version".ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
|
|
181
|
+
puts "PROJECT.remote".ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
|
|
182
|
+
puts "PROJECT.branch".ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright
|
|
183
|
+
# puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
|
|
184
|
+
# puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
|
|
185
|
+
puts "PROJECT.latest_tag".ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
|
|
186
|
+
puts "PROJECT.latest_tag_commit".ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
|
|
187
|
+
puts "PROJECT.latest_tag_md5".ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
|
|
188
|
+
puts "PROJECT.latest_commit".ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
|
|
189
|
+
puts "PROJECT.last_modified_filename".ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
|
|
190
|
+
# puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
|
|
191
|
+
puts "PROJECT.size".ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
|
|
192
|
+
puts "PROJECT.size_pack".ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
|
|
193
|
+
puts "PROJECT.outstanding_commit?".ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
|
|
194
|
+
puts "PROJECT.outstanding_tag?".ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
|
|
195
|
+
puts ""
|
|
196
|
+
self
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def summary
|
|
200
|
+
info if @verbose
|
|
201
|
+
|
|
202
|
+
puts "[#{elapsed}] #{Rainbow(@name).yellow.bright} #{Rainbow(version).yellow.bright}"
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def commit_message_filename
|
|
206
|
+
warn "[DEPRECATION] 'commit_message_filename' is deprectated."
|
|
207
|
+
@commit_message_filename
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def commit(commit_message)
|
|
211
|
+
warn "[DEPRECATION] 'commit_message_filename' is deprectated. Use a run command for better transparency."
|
|
212
|
+
Dir.chdir(@directory) do
|
|
213
|
+
if File.exist?(".gitignore")
|
|
214
|
+
status = `git status`
|
|
215
|
+
if status.include?("Changes not staged for commit:")
|
|
216
|
+
run("git add --all")
|
|
217
|
+
if GIT_DIRECTORY.outstanding_commit?
|
|
218
|
+
if File.exist?(@commit_message_filename)
|
|
219
|
+
run("git commit --file #{@commit_message_filename}")
|
|
220
|
+
File.delete(@commit_message_filename)
|
|
221
|
+
else
|
|
222
|
+
run("git commit -m'#{commit_message}'")
|
|
223
|
+
end
|
|
252
224
|
end
|
|
253
|
-
|
|
225
|
+
end
|
|
226
|
+
else
|
|
227
|
+
puts "warning: .gitignore not found."
|
|
254
228
|
end
|
|
229
|
+
end
|
|
230
|
+
self
|
|
231
|
+
end
|
|
255
232
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
233
|
+
def push
|
|
234
|
+
Dir.chdir(@directory) do
|
|
235
|
+
status = `git status`
|
|
236
|
+
if status.include?('use "git push"')
|
|
237
|
+
run("git push")
|
|
238
|
+
|
|
239
|
+
# run('git push --tags')
|
|
261
240
|
end
|
|
241
|
+
end
|
|
242
|
+
self
|
|
243
|
+
end
|
|
262
244
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
245
|
+
def pull
|
|
246
|
+
Dir.chdir(@directory) do
|
|
247
|
+
run("git pull")
|
|
248
|
+
end
|
|
249
|
+
self
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def tag
|
|
253
|
+
warn "[DEPRECATION] 'tag' is deprecated. Use run command(s) for better transparency."
|
|
254
|
+
Dir.chdir(@directory) do
|
|
255
|
+
specific_tag = `git tag -l #{@version}`.strip
|
|
256
|
+
puts Rainbow("git tag - #{@version}").green if @verbose
|
|
257
|
+
puts `git tag -l #{@version}` if @verbose
|
|
258
|
+
if specific_tag.length.zero?
|
|
259
|
+
puts "tag #{@version} not detected." if @verbose
|
|
260
|
+
tag = `git describe --abbrev=0 --tags`.strip
|
|
261
|
+
if @version != tag
|
|
262
|
+
puts "latest tag #{@tag}" if @verbose
|
|
263
|
+
run("git tag #{@version} -m'#{@version}'")
|
|
264
|
+
run("git push origin #{@version}")
|
|
265
|
+
# push
|
|
266
|
+
end
|
|
267
|
+
elsif @verbose
|
|
268
|
+
puts "already has tag #{specific_tag}"
|
|
283
269
|
end
|
|
270
|
+
end
|
|
271
|
+
self
|
|
272
|
+
end
|
|
284
273
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
end
|
|
309
|
-
end
|
|
274
|
+
def run(command, quit_on_failure = true, success_log_level = Logger::DEBUG)
|
|
275
|
+
if command.is_a?(Array)
|
|
276
|
+
command.each { |subcommand| run(subcommand, quit_on_failure, success_log_level) }
|
|
277
|
+
else
|
|
278
|
+
cmd = Command.new(command, 0, success_log_level)
|
|
279
|
+
cmd.summary
|
|
280
|
+
cmd.save
|
|
281
|
+
elapsed_str = Timer.get_elapsed_str(cmd.elapsed, 0)
|
|
282
|
+
if cmd.exitstatus.zero?
|
|
283
|
+
# puts elapsed_str + " " + Rainbow(cmd.command).yellow.bright
|
|
284
|
+
# return elapsed_str + " " + cmd.command
|
|
285
|
+
else
|
|
286
|
+
# display error details
|
|
287
|
+
puts cmd.output
|
|
288
|
+
puts cmd.error
|
|
289
|
+
puts
|
|
290
|
+
abort "#{Rainbow(elapsed_str).red.bright} #{Rainbow(cmd.command).white}" if quit_on_failure
|
|
291
|
+
end
|
|
292
|
+
cmd
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
data/lib/raykit/rake.rb
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "time"
|
|
2
4
|
|
|
3
5
|
module Raykit
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
File.open(log_filename,'w'){|f|
|
|
28
|
-
f.write(JSON.generate(cmd.to_hash))
|
|
29
|
-
}
|
|
30
|
-
return cmd
|
|
31
|
-
end
|
|
32
|
-
end
|
|
6
|
+
class Rake
|
|
7
|
+
def self.run(remote, branch, task = "default")
|
|
8
|
+
repo = Raykit::Git::Repository.new(remote)
|
|
9
|
+
rel_dir = repo.relative_path
|
|
10
|
+
commit = repo.latest_commit(branch)
|
|
11
|
+
log_filename = "#{Environment.get_dev_dir("log")}/RayKit.Runner/#{rel_dir}/#{branch}/#{commit}.json"
|
|
12
|
+
if File.exist?(log_filename)
|
|
13
|
+
Command.parse(File.read(log_filename))
|
|
14
|
+
else
|
|
15
|
+
run_dir = "#{Environment.get_dev_dir("tmp")}/#{rel_dir}.#{branch}.#{commit}"
|
|
16
|
+
unless Dir.exist?(run_dir)
|
|
17
|
+
parent_dir = File.expand_path("..", run_dir)
|
|
18
|
+
FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
|
|
19
|
+
cmd = Command.new("git clone #{remote} #{run_dir}")
|
|
20
|
+
end
|
|
21
|
+
Dir.chdir(run_dir) do
|
|
22
|
+
cmd = Command.new("rake #{task}")
|
|
23
|
+
parent_dir = File.dirname(log_filename)
|
|
24
|
+
FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
|
|
25
|
+
File.open(log_filename, "w") do |f|
|
|
26
|
+
f.write(JSON.generate(cmd.to_hash))
|
|
27
|
+
end
|
|
28
|
+
return cmd
|
|
33
29
|
end
|
|
30
|
+
end
|
|
34
31
|
end
|
|
35
|
-
end
|
|
32
|
+
end
|
|
33
|
+
end
|