raykit 0.0.497 → 0.0.499

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +20 -20
  4. data/bin/raykit +6 -6
  5. data/lib/raykit/auto_setup.rb +69 -69
  6. data/lib/raykit/command.rb +371 -341
  7. data/lib/raykit/conan/buildinfo.rb +69 -69
  8. data/lib/raykit/conanpackage.rb +49 -49
  9. data/lib/raykit/configuration.rb +48 -0
  10. data/lib/raykit/console.rb +281 -272
  11. data/lib/raykit/default_content.rb +227 -227
  12. data/lib/raykit/dir.rb +49 -49
  13. data/lib/raykit/dotnet.rb +174 -174
  14. data/lib/raykit/environment.rb +114 -109
  15. data/lib/raykit/filesystem.rb +34 -34
  16. data/lib/raykit/git/commit.rb +16 -16
  17. data/lib/raykit/git/directory.rb +216 -216
  18. data/lib/raykit/git/files.rb +46 -46
  19. data/lib/raykit/git/repositories.rb +95 -89
  20. data/lib/raykit/git/repository.rb +278 -244
  21. data/lib/raykit/installer.rb +17 -17
  22. data/lib/raykit/log.rb +80 -80
  23. data/lib/raykit/logevent.rb +49 -49
  24. data/lib/raykit/logging.rb +57 -57
  25. data/lib/raykit/markdown.rb +21 -21
  26. data/lib/raykit/msbuild.rb +54 -54
  27. data/lib/raykit/nugetpackage.rb +54 -54
  28. data/lib/raykit/nunit.rb +13 -13
  29. data/lib/raykit/project.rb +343 -339
  30. data/lib/raykit/rake.rb +39 -39
  31. data/lib/raykit/runner.rb +42 -42
  32. data/lib/raykit/secrets.rb +38 -38
  33. data/lib/raykit/sourceImport.rb +74 -74
  34. data/lib/raykit/sourceImports.rb +43 -43
  35. data/lib/raykit/string.rb +18 -18
  36. data/lib/raykit/tasks.rb +99 -99
  37. data/lib/raykit/text.rb +32 -32
  38. data/lib/raykit/timer.rb +31 -31
  39. data/lib/raykit/version.rb +103 -103
  40. data/lib/raykit/vstest.rb +24 -24
  41. data/lib/raykit/wt.rb +28 -28
  42. data/lib/raykit/zip.rb +73 -73
  43. data/lib/raykit.rb +125 -125
  44. metadata +4 -3
data/lib/raykit/rake.rb CHANGED
@@ -1,39 +1,39 @@
1
- # frozen_string_literal: true
2
-
3
- require "time"
4
-
5
- module Raykit
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
29
- end
30
- end
31
- end
32
-
33
- def self.rake(rakefile, task)
34
- Dir.chdir(File.dirname(rakefile)) do
35
- Raykit::TopLevel.run("rake #{task}", true)
36
- end
37
- end
38
- end
39
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "time"
4
+
5
+ module Raykit
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
29
+ end
30
+ end
31
+ end
32
+
33
+ def self.rake(rakefile, task)
34
+ Dir.chdir(File.dirname(rakefile)) do
35
+ Raykit::TopLevel.run("rake #{task}", true)
36
+ end
37
+ end
38
+ end
39
+ end
data/lib/raykit/runner.rb CHANGED
@@ -1,42 +1,42 @@
1
- # frozen_string_literal: true
2
-
3
- require "yaml"
4
-
5
- module Raykit
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
28
- end
29
- end
30
- FileUtils.rm_rf(local_dir)
31
- commands
32
- end
33
-
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
40
- end
41
- end
42
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+
5
+ module Raykit
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
28
+ end
29
+ end
30
+ FileUtils.rm_rf(local_dir)
31
+ commands
32
+ end
33
+
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
40
+ end
41
+ end
42
+ end
@@ -1,38 +1,38 @@
1
- # frozen_string_literal: true
2
-
3
- require "time"
4
-
5
- module Raykit
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
17
- end
18
- end
19
- end
20
- end
21
- end
22
-
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
-
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
36
- end
37
- end
38
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "time"
4
+
5
+ module Raykit
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
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
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
+
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
36
+ end
37
+ end
38
+ end
@@ -1,74 +1,74 @@
1
- # frozen_string_literal: true
2
-
3
- module Raykit
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
12
-
13
- def remote
14
- self["remote"]
15
- end
16
-
17
- def source
18
- self["source"]
19
- end
20
-
21
- def target
22
- self["target"]
23
- end
24
-
25
- def glob
26
- self["glob"]
27
- end
28
-
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")
36
- end
37
- else
38
- PROJECT.run("git clone #{remote} #{work}")
39
- end
40
-
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
47
-
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
61
- 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
69
- end
70
- puts " copied #{count} files to #{target}"
71
- end
72
- end
73
- end
74
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Raykit
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
12
+
13
+ def remote
14
+ self["remote"]
15
+ end
16
+
17
+ def source
18
+ self["source"]
19
+ end
20
+
21
+ def target
22
+ self["target"]
23
+ end
24
+
25
+ def glob
26
+ self["glob"]
27
+ end
28
+
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")
36
+ end
37
+ else
38
+ PROJECT.run("git clone #{remote} #{work}")
39
+ end
40
+
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
47
+
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
61
+ 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
69
+ end
70
+ puts " copied #{count} files to #{target}"
71
+ end
72
+ end
73
+ end
74
+ end
@@ -1,43 +1,43 @@
1
- # frozen_string_literal: true
2
-
3
- module Raykit
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
-
11
- def update
12
- each(&:update)
13
- end
14
-
15
- def copy
16
- each(&:copy)
17
- end
18
-
19
- def targets_exist?
20
- each do |si|
21
- return false unless Dir.exist?(si.target)
22
- end
23
- true
24
- end
25
-
26
- def save(filename)
27
- File.open(filename, "w") do |f|
28
- f.write(JSON.pretty_generate(self))
29
- end
30
- end
31
-
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
41
- end
42
- end
43
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Raykit
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
+
11
+ def update
12
+ each(&:update)
13
+ end
14
+
15
+ def copy
16
+ each(&:copy)
17
+ end
18
+
19
+ def targets_exist?
20
+ each do |si|
21
+ return false unless Dir.exist?(si.target)
22
+ end
23
+ true
24
+ end
25
+
26
+ def save(filename)
27
+ File.open(filename, "w") do |f|
28
+ f.write(JSON.pretty_generate(self))
29
+ end
30
+ end
31
+
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
41
+ end
42
+ end
43
+ end
data/lib/raykit/string.rb CHANGED
@@ -1,18 +1,18 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("./environment")
4
-
5
- class String
6
- def work_dir
7
- rel_name = sub("https://", "").gsub("http://", "").gsub(".git", "")
8
- "#{Raykit::Environment.get_dev_dir("work")}/#{rel_name}"
9
- end
10
-
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
16
- end
17
- end
18
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative("./environment")
4
+
5
+ class String
6
+ def work_dir
7
+ rel_name = sub("https://", "").gsub("http://", "").gsub(".git", "")
8
+ "#{Raykit::Environment.get_dev_dir("work")}/#{rel_name}"
9
+ end
10
+
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
16
+ end
17
+ end
18
+ end