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/runner.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
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
|
-
end
|
27
|
-
end
|
28
|
-
FileUtils.rm_rf(local_dir)
|
29
|
-
commands
|
6
|
+
class Runner
|
7
|
+
def self.run(git_url)
|
8
|
+
commands = []
|
9
|
+
local_dir = Dir.mktmpdir("runner")
|
10
|
+
puts "local_dir : #{local_dir}"
|
11
|
+
commands << Raykit::Command.new("git clone #{git_url} #{local_dir}")
|
12
|
+
Dir.chdir(local_dir) do
|
13
|
+
commands << Raykit::Command.new("git log -n 1")
|
14
|
+
yaml = get_build_yaml(local_dir)
|
15
|
+
build_hash = YAML.safe_load(yaml)
|
16
|
+
build_commands = Raykit::Command.parse_yaml_commands(yaml)
|
17
|
+
if build_hash.key?("image")
|
18
|
+
image = build_hash["image"]
|
19
|
+
build_commands.insert(0, "cd home")
|
20
|
+
build_commands.insert(1, "git clone #{git_url} build")
|
21
|
+
build_commands.insert(2, "cd build")
|
22
|
+
build_commands_string = build_commands.join(";")
|
23
|
+
commands << Raykit::Command.new("docker run #{image} sh -c \"#{build_commands_string}\"")
|
24
|
+
else
|
25
|
+
build_commands.each do |cmd_string|
|
26
|
+
commands << Rakkit::Command.new(cmd_string)
|
27
|
+
end
|
30
28
|
end
|
29
|
+
end
|
30
|
+
FileUtils.rm_rf(local_dir)
|
31
|
+
commands
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
yaml
|
40
|
-
end
|
34
|
+
def self.get_build_yaml(directory)
|
35
|
+
yaml = ""
|
36
|
+
Dir.chdir(directory) do
|
37
|
+
yaml = File.open(".gitlab-ci.yml").read if File.exist?(".gitlab-ci.yml")
|
38
|
+
end
|
39
|
+
yaml
|
41
40
|
end
|
42
|
-
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/raykit/secrets.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
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
|
-
end
|
17
|
-
end
|
6
|
+
# Provides functionality to record the time execution times
|
7
|
+
class Secrets < Hash
|
8
|
+
def initialize
|
9
|
+
if ENV.key?("RAYKIT_SECRETS_PATH")
|
10
|
+
secrets_file = ENV["RAYKIT_SECRETS_PATH"]
|
11
|
+
if File.exist?(secrets_file)
|
12
|
+
text = IO.read(secrets_file)
|
13
|
+
if text.length > 7
|
14
|
+
data = JSON.parse(text)
|
15
|
+
data.each do |key, value|
|
16
|
+
self[key] = value
|
18
17
|
end
|
18
|
+
end
|
19
19
|
end
|
20
|
+
end
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
hidden
|
29
|
-
end
|
23
|
+
def hide(text)
|
24
|
+
hidden = text
|
25
|
+
each do |_k, v|
|
26
|
+
hidden = hidden.gsub(v, "****") if !v.nil? && v.length.positive?
|
27
|
+
end
|
28
|
+
hidden
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
31
|
+
def save
|
32
|
+
if ENV.key?("RAYKIT_SECRETS_PATH")
|
33
|
+
secrets_file = ENV["RAYKIT_SECRETS_PATH"]
|
34
|
+
File.open(secrets_file, "w") { |f| f.puts to_json }
|
35
|
+
end
|
37
36
|
end
|
37
|
+
end
|
38
38
|
end
|
data/lib/raykit/sourceImport.rb
CHANGED
@@ -1,75 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Raykit
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
class SourceImport < Hash
|
5
|
+
def initialize(url, source, glob, target, commit)
|
6
|
+
self["remote"] = url
|
7
|
+
self["source"] = source
|
8
|
+
self["glob"] = glob
|
9
|
+
self["target"] = target
|
10
|
+
self["commit"] = commit
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def remote
|
14
|
+
self["remote"]
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def source
|
18
|
+
self["source"]
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
def target
|
22
|
+
self["target"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def glob
|
26
|
+
self["glob"]
|
27
|
+
end
|
23
28
|
|
24
|
-
|
25
|
-
|
29
|
+
def update
|
30
|
+
work = self["remote"].work_dir
|
31
|
+
work_parent = File.dirname(work)
|
32
|
+
FileUtils.mkdir_p(work_parent) unless Dir.exist?(work_parent)
|
33
|
+
if Dir.exist?(work)
|
34
|
+
Dir.chdir(work) do
|
35
|
+
cmd = Command.new("git pull")
|
26
36
|
end
|
37
|
+
else
|
38
|
+
PROJECT.run("git clone #{remote} #{work}")
|
39
|
+
end
|
27
40
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
cmd = Command.new('git pull')
|
35
|
-
end
|
36
|
-
else
|
37
|
-
PROJECT.run("git clone #{remote} #{work}")
|
38
|
-
end
|
41
|
+
Dir.chdir(work) do
|
42
|
+
text = `git log -n 1`
|
43
|
+
scan = text.scan(/commit (\w+)\s/)
|
44
|
+
self["commit"] = scan[0][0].to_s
|
45
|
+
end
|
46
|
+
end
|
39
47
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
48
|
+
def copy
|
49
|
+
if target.length.zero?
|
50
|
+
puts "target has not been specified"
|
51
|
+
else
|
52
|
+
FileUtils.remove_dir(target) if Dir.exist?(target)
|
53
|
+
count = 0
|
54
|
+
source_names = []
|
55
|
+
work = self["remote"].work_dir
|
56
|
+
Dir.chdir(work) do
|
57
|
+
cmd = Command.new("rake clean") if File.exist?("rakefile.rb")
|
58
|
+
Dir.chdir(source) do
|
59
|
+
source_names = Dir.glob(self["glob"])
|
60
|
+
end
|
45
61
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
source_names = []
|
54
|
-
work=self['remote'].work_dir
|
55
|
-
Dir.chdir(work) do
|
56
|
-
if(File.exist?('rakefile.rb'))
|
57
|
-
cmd = Command.new('rake clean')
|
58
|
-
end
|
59
|
-
Dir.chdir(self.source) do
|
60
|
-
source_names=Dir.glob(self['glob'])
|
61
|
-
end
|
62
|
-
end
|
63
|
-
source_names.each{|source_name|
|
64
|
-
source_file =work + "/" + self.source + "/" + source_name
|
65
|
-
target_name = target + "/" + source_name
|
66
|
-
target_parent = File.dirname(target_name)
|
67
|
-
FileUtils.mkdir_p(target_parent) if(!Dir.exist?(target_parent))
|
68
|
-
FileUtils.copy(source_file,target_name)
|
69
|
-
count += 1
|
70
|
-
}
|
71
|
-
puts ' copied ' + count.to_s + ' files to ' + target
|
72
|
-
end
|
62
|
+
source_names.each do |source_name|
|
63
|
+
source_file = "#{work}/#{source}/#{source_name}"
|
64
|
+
target_name = "#{target}/#{source_name}"
|
65
|
+
target_parent = File.dirname(target_name)
|
66
|
+
FileUtils.mkdir_p(target_parent) unless Dir.exist?(target_parent)
|
67
|
+
FileUtils.copy(source_file, target_name)
|
68
|
+
count += 1
|
73
69
|
end
|
70
|
+
puts " copied #{count} files to #{target}"
|
71
|
+
end
|
74
72
|
end
|
75
|
-
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/raykit/sourceImports.rb
CHANGED
@@ -1,46 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Raykit
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
4
|
+
class SourceImports < Array
|
5
|
+
def initialize(urls)
|
6
|
+
urls.each do |url|
|
7
|
+
self << SourceImport.new(url, "src", "**/*.cs", "dep", "")
|
8
|
+
end
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
end
|
11
|
+
def update
|
12
|
+
each(&:update)
|
13
|
+
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
21
|
-
end
|
15
|
+
def copy
|
16
|
+
each(&:copy)
|
17
|
+
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
def targets_exist?
|
20
|
+
each do |si|
|
21
|
+
return false unless Dir.exist?(si.target)
|
22
|
+
end
|
23
|
+
true
|
24
|
+
end
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
def save(filename)
|
27
|
+
File.open(filename, "w") do |f|
|
28
|
+
f.write(JSON.pretty_generate(self))
|
29
|
+
end
|
30
|
+
end
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
def self.load(filename)
|
33
|
+
sourceImports = SourceImports.new([])
|
34
|
+
array = JSON.parse(IO.read(filename))
|
35
|
+
array.each do |hash|
|
36
|
+
sourceImport = SourceImport.new(hash["remote"], hash["source"], hash["glob"], hash["target"],
|
37
|
+
hash["commit"])
|
38
|
+
sourceImports << sourceImport
|
39
|
+
end
|
40
|
+
sourceImports
|
45
41
|
end
|
46
|
-
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/raykit/string.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative("./environment")
|
2
4
|
|
3
5
|
class String
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def work_dir
|
7
|
+
rel_name = sub("https://", "").gsub("http://", "").gsub(".git", "")
|
8
|
+
"#{Raykit::Environment.get_dev_dir("work")}/#{rel_name}"
|
9
|
+
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
11
|
+
def latest_commit
|
12
|
+
Dir.chdir(self) do
|
13
|
+
text = `git log -n 1`
|
14
|
+
scan = text.scan(/commit (\w+)\s/)
|
15
|
+
return scan[0][0].to_s
|
15
16
|
end
|
16
|
-
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/raykit/tasks.rb
CHANGED
@@ -1,76 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
desc "Display project information"
|
3
4
|
task :info do
|
4
|
-
|
5
|
+
PROJECT.info
|
5
6
|
end
|
6
7
|
|
7
8
|
desc "integrate changes into the git repository"
|
8
9
|
task :integrate do
|
9
|
-
|
10
|
+
puts Rainbow(":integrate").blue.bright
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
git_dir = Raykit::Git::Directory.new(Rake.application.original_dir)
|
13
|
+
if git_dir.detached?
|
14
|
+
puts "detached head state, skipping integrate operations"
|
15
|
+
else
|
16
|
+
if PROJECT.outstanding_commit?
|
17
|
+
Rake::Task["test"].invoke if Rake::Task.task_defined?("test")
|
14
18
|
else
|
15
|
-
|
16
|
-
|
17
|
-
Rake::Task["test"].invoke
|
18
|
-
end
|
19
|
-
else
|
20
|
-
puts "no outstanding commits detected"
|
21
|
-
end
|
19
|
+
puts "no outstanding commits detected"
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
22
|
+
if !File.exist?(".gitignore")
|
23
|
+
puts "warning: .gitignore does not exist."
|
24
|
+
else
|
25
|
+
PROJECT.run("git add --all")
|
26
|
+
unless `git status`.include?("nothing to commit")
|
27
|
+
# if(PROJECT.outstanding_commit?)
|
28
|
+
commit_message = "integrate"
|
29
|
+
PROJECT.run("git commit -m\"#{commit_message}\"") if PROJECT.outstanding_commit?
|
30
|
+
PROJECT.run("git pull")
|
31
|
+
# PROJECT.run("git push")
|
32
|
+
# PROJECT.run("git push --tags")
|
33
|
+
end
|
37
34
|
end
|
35
|
+
end
|
38
36
|
end
|
39
37
|
|
40
38
|
desc "push changes including tags"
|
41
39
|
task :push do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
git_dir = Raykit::Git::Directory.new(Rake.application.original_dir)
|
41
|
+
if git_dir.detached?
|
42
|
+
puts "detached head state, skipping push operations"
|
43
|
+
else
|
44
|
+
PROJECT.run("git push")
|
45
|
+
PROJECT.run("git push --tags")
|
46
|
+
end
|
49
47
|
end
|
50
48
|
|
51
49
|
desc "clean files not tracked by git"
|
52
50
|
task :clean do
|
53
|
-
|
54
|
-
|
51
|
+
puts Rainbow(":clean").blue.bright
|
52
|
+
PROJECT.run("git clean -dXf")
|
55
53
|
end
|
56
54
|
|
57
55
|
desc "update_source from sourceImports.json"
|
58
56
|
task :update_source do
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
if File.exist?("sourceImports.json")
|
58
|
+
puts Rainbow(":update_source").blue.bright
|
59
|
+
sourceImports = Raykit::SourceImports.load("sourceImports.json")
|
60
|
+
json = sourceImports.to_json
|
61
|
+
sourceImports.update
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
63
|
+
json2 = sourceImports.to_json
|
64
|
+
if json2 != json || !sourceImports.targets_exist?
|
65
|
+
sourceImports.save("sourceImports.json")
|
66
|
+
sourceImports.copy
|
67
|
+
else
|
68
|
+
puts " no update required."
|
72
69
|
end
|
70
|
+
end
|
73
71
|
end
|
74
72
|
|
75
73
|
desc "update source files"
|
76
|
-
task :
|
74
|
+
task update: [:update_source]
|
data/lib/raykit/text.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Raykit
|
2
|
-
|
3
|
-
def self.replace_in_glob(glob,search,replace)
|
4
|
-
|
4
|
+
class Text
|
5
|
+
def self.replace_in_glob(glob, search, replace)
|
6
|
+
Dir.glob(glob).each { |f| replace_in_file(f, search, replace) }
|
5
7
|
end
|
6
|
-
|
7
|
-
def self.replace_in_file(filename,search,replace)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
File.open(filename,"w") { |f| f.puts text2 }
|
8
|
+
|
9
|
+
def self.replace_in_file(filename, search, replace)
|
10
|
+
text1 = IO.read(filename)
|
11
|
+
text2 = text1.gsub(search) { |_str| str = replace }
|
12
|
+
unless text1 == text2
|
13
|
+
File.open(filename, "w") { |f| f.puts text2 }
|
12
14
|
return true
|
13
|
-
|
14
|
-
|
15
|
+
end
|
16
|
+
false
|
15
17
|
end
|
16
18
|
|
17
|
-
def self.copy_if_different(source,destination)
|
18
|
-
|
19
|
+
def self.copy_if_different(source, destination)
|
20
|
+
if !File.exist?(destination)
|
19
21
|
FileUtils.cp source, destination
|
20
|
-
|
21
|
-
source_text=IO.read(source)
|
22
|
-
destination_text=IO.read(destination)
|
23
|
-
if
|
24
|
-
|
25
|
-
|
22
|
+
else
|
23
|
+
source_text = IO.read(source)
|
24
|
+
destination_text = IO.read(destination)
|
25
|
+
if source_text != destination_text
|
26
|
+
FileUtils.rm destination
|
27
|
+
FileUtils.cp source, destination
|
26
28
|
end
|
27
|
-
|
28
|
-
end
|
29
|
+
end
|
29
30
|
end
|
30
|
-
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/raykit/timer.rb
CHANGED
@@ -1,29 +1,31 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "time"
|
2
4
|
|
3
5
|
module Raykit
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
# Provides functionality to record the time execution times
|
7
|
+
class Timer
|
8
|
+
# The time at which start occurred
|
9
|
+
attr_accessor :start_time
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
def initialize
|
12
|
+
@start_time = Time.now
|
13
|
+
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
# The elapsed time, in seconds, since the timer started
|
16
|
+
def elapsed
|
17
|
+
Time.now - @start_time
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
# The elapsed time, in seconds, as a formatted string
|
21
|
+
def elapsed_str(pad = 0)
|
22
|
+
Timer.get_elapsed_str(elapsed, pad)
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
25
|
+
# Converts a time span in seconds to a formatted string
|
26
|
+
def self.get_elapsed_str(elapsed, pad = 0)
|
27
|
+
# "[" + "%.0f" % (elapsed) + "s]".ljust(pad)
|
28
|
+
format("%.0f", elapsed) + "s".ljust(pad)
|
28
29
|
end
|
29
|
-
end
|
30
|
+
end
|
31
|
+
end
|