raykit 0.0.540 → 0.0.542

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +25 -25
  4. data/bin/raykit +6 -6
  5. data/lib/raykit/auto_setup.rb +69 -69
  6. data/lib/raykit/command.rb +374 -374
  7. data/lib/raykit/conan/buildinfo.rb +69 -69
  8. data/lib/raykit/conanpackage.rb +49 -49
  9. data/lib/raykit/configuration.rb +53 -53
  10. data/lib/raykit/console.rb +310 -310
  11. data/lib/raykit/default_content.rb +8 -8
  12. data/lib/raykit/default_content.txt +219 -219
  13. data/lib/raykit/dir.rb +127 -127
  14. data/lib/raykit/dotnet.rb +174 -174
  15. data/lib/raykit/environment.rb +115 -115
  16. data/lib/raykit/filesystem.rb +34 -34
  17. data/lib/raykit/git/commit.rb +16 -16
  18. data/lib/raykit/git/directory.rb +280 -273
  19. data/lib/raykit/git/files.rb +46 -46
  20. data/lib/raykit/git/repositories.rb +89 -89
  21. data/lib/raykit/git/repository.rb +362 -362
  22. data/lib/raykit/installer.rb +17 -17
  23. data/lib/raykit/log.rb +80 -80
  24. data/lib/raykit/logevent.rb +29 -29
  25. data/lib/raykit/logger.rb +100 -100
  26. data/lib/raykit/logging.rb +57 -57
  27. data/lib/raykit/markdown.rb +21 -21
  28. data/lib/raykit/msbuild.rb +54 -54
  29. data/lib/raykit/nugetpackage.rb +54 -54
  30. data/lib/raykit/nunit.rb +13 -13
  31. data/lib/raykit/project.rb +343 -343
  32. data/lib/raykit/rake.rb +39 -39
  33. data/lib/raykit/runner.rb +42 -42
  34. data/lib/raykit/secrets.rb +38 -38
  35. data/lib/raykit/sourceImport.rb +76 -76
  36. data/lib/raykit/sourceImports.rb +43 -43
  37. data/lib/raykit/string.rb +18 -18
  38. data/lib/raykit/symbols.rb +115 -115
  39. data/lib/raykit/tasks.rb +91 -91
  40. data/lib/raykit/text.rb +32 -32
  41. data/lib/raykit/timer.rb +31 -31
  42. data/lib/raykit/version.rb +95 -95
  43. data/lib/raykit/vstest.rb +24 -24
  44. data/lib/raykit/wix.rb +61 -61
  45. data/lib/raykit/wt.rb +28 -28
  46. data/lib/raykit/zip.rb +73 -73
  47. data/lib/raykit.rb +140 -140
  48. metadata +2 -2
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,76 +1,76 @@
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
- repo = Raykit::Git::Repository.new(remote)
31
- work = repo.get_dev_dir("work")
32
- #work = self["remote"].work_dir
33
- work_parent = File.dirname(work)
34
- FileUtils.mkdir_p(work_parent) unless Dir.exist?(work_parent)
35
- if Dir.exist?(work)
36
- Dir.chdir(work) do
37
- cmd = Command.new("git pull")
38
- end
39
- else
40
- PROJECT.run("git clone #{remote} #{work}")
41
- end
42
-
43
- Dir.chdir(work) do
44
- text = `git log -n 1`
45
- scan = text.scan(/commit (\w+)\s/)
46
- self["commit"] = scan[0][0].to_s
47
- end
48
- end
49
-
50
- def copy
51
- if target.length.zero?
52
- puts "target has not been specified"
53
- else
54
- FileUtils.remove_dir(target) if Dir.exist?(target)
55
- count = 0
56
- source_names = []
57
- work = self["remote"].work_dir
58
- Dir.chdir(work) do
59
- cmd = Command.new("rake clean") if File.exist?("rakefile.rb")
60
- Dir.chdir(source) do
61
- source_names = Dir.glob(self["glob"])
62
- end
63
- end
64
- source_names.each do |source_name|
65
- source_file = "#{work}/#{source}/#{source_name}"
66
- target_name = "#{target}/#{source_name}"
67
- target_parent = File.dirname(target_name)
68
- FileUtils.mkdir_p(target_parent) unless Dir.exist?(target_parent)
69
- FileUtils.copy(source_file, target_name)
70
- count += 1
71
- end
72
- puts " copied #{count} files to #{target}"
73
- end
74
- end
75
- end
76
- 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
+ repo = Raykit::Git::Repository.new(remote)
31
+ work = repo.get_dev_dir("work")
32
+ #work = self["remote"].work_dir
33
+ work_parent = File.dirname(work)
34
+ FileUtils.mkdir_p(work_parent) unless Dir.exist?(work_parent)
35
+ if Dir.exist?(work)
36
+ Dir.chdir(work) do
37
+ cmd = Command.new("git pull")
38
+ end
39
+ else
40
+ PROJECT.run("git clone #{remote} #{work}")
41
+ end
42
+
43
+ Dir.chdir(work) do
44
+ text = `git log -n 1`
45
+ scan = text.scan(/commit (\w+)\s/)
46
+ self["commit"] = scan[0][0].to_s
47
+ end
48
+ end
49
+
50
+ def copy
51
+ if target.length.zero?
52
+ puts "target has not been specified"
53
+ else
54
+ FileUtils.remove_dir(target) if Dir.exist?(target)
55
+ count = 0
56
+ source_names = []
57
+ work = self["remote"].work_dir
58
+ Dir.chdir(work) do
59
+ cmd = Command.new("rake clean") if File.exist?("rakefile.rb")
60
+ Dir.chdir(source) do
61
+ source_names = Dir.glob(self["glob"])
62
+ end
63
+ end
64
+ source_names.each do |source_name|
65
+ source_file = "#{work}/#{source}/#{source_name}"
66
+ target_name = "#{target}/#{source_name}"
67
+ target_parent = File.dirname(target_name)
68
+ FileUtils.mkdir_p(target_parent) unless Dir.exist?(target_parent)
69
+ FileUtils.copy(source_file, target_name)
70
+ count += 1
71
+ end
72
+ puts " copied #{count} files to #{target}"
73
+ end
74
+ end
75
+ end
76
+ 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