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
@@ -1,109 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Raykit
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
attr_accessor :work_directory
|
4
|
+
module Git
|
5
|
+
# Functionality to manage a remote git repository
|
6
|
+
class Repository
|
7
|
+
# The url of the remote repository
|
8
|
+
attr_accessor :url
|
9
|
+
attr_accessor :clone_directory, :work_directory
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def initialize(url)
|
12
|
+
@url = url
|
13
|
+
@clone_directory = Raykit::Git::Directory.new(get_dev_dir("clone"))
|
14
|
+
@work_directory = Raykit::Git::Directory.new(get_dev_dir("work"))
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def to_json(*_args)
|
18
|
+
JSON.generate({ "url" => @url })
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
21
|
+
def self.parse(json)
|
22
|
+
hash = JSON.parse(json)
|
23
|
+
Repository.new(hash["url"])
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
# The relative path is a valid local path name derived from the url
|
27
|
+
def relative_path
|
28
|
+
@url.gsub("https://", "").gsub(".git", "").gsub("http://", "")
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
def get_dev_dir(dir)
|
32
|
+
dev_dir = Environment.get_dev_dir(dir)
|
33
|
+
"#{dev_dir}/#{relative_path}"
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
# Clone the repository to a specific directory
|
37
|
+
def clone(directory, depth = 0)
|
38
|
+
if depth.zero?
|
39
|
+
PROJECT.run("git clone #{@url} #{directory}")
|
40
|
+
else
|
41
|
+
PROJECT.run("git clone #{@url} #{directory} --depth #{depth}")
|
42
|
+
end
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
end
|
56
|
-
end
|
57
|
-
results
|
45
|
+
# The branches for the git repository
|
46
|
+
def branches
|
47
|
+
results = []
|
48
|
+
update_local_clone_directory
|
49
|
+
if Dir.exist?(local_clone_directory)
|
50
|
+
Dir.chdir(local_clone_directory) do
|
51
|
+
`git branch`.split('\n').each do |line|
|
52
|
+
branch = line.gsub("*", "").strip
|
53
|
+
results.insert(-1, branch) if branch.length.positive?
|
58
54
|
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
results
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
60
|
+
# The latest commit id for a branch of the repostiory
|
61
|
+
def latest_commit(branch)
|
62
|
+
if checkout_local_clone_directory_branch(branch)
|
63
|
+
text = `git log -n 1`
|
64
|
+
scan = text.scan(/commit (\w+)\s/)
|
65
|
+
return scan[0][0].to_s
|
66
|
+
end
|
67
|
+
""
|
68
|
+
end
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
return `git describe --abbrev=0`.strip
|
74
|
-
end
|
75
|
-
''
|
76
|
-
end
|
70
|
+
# The latest tag for a branch of the repository
|
71
|
+
def latest_tag(branch)
|
72
|
+
return `git describe --abbrev=0`.strip if checkout_local_clone_directory_branch(branch)
|
77
73
|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
74
|
+
""
|
75
|
+
end
|
81
76
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
Raykit::Command.new('git pull')
|
86
|
-
#t = `git pull`
|
87
|
-
end
|
88
|
-
else
|
89
|
-
PROJECT.run("git clone #{@url} #{local_clone_directory}")
|
90
|
-
end
|
91
|
-
end
|
77
|
+
private def local_clone_directory
|
78
|
+
clone_dir = "#{Environment.get_dev_dir("clone")}/#{relative_path}"
|
79
|
+
end
|
92
80
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
81
|
+
private def update_local_clone_directory
|
82
|
+
if Dir.exist?(local_clone_directory)
|
83
|
+
Dir.chdir(local_clone_directory) do
|
84
|
+
Raykit::Command.new("git pull")
|
85
|
+
# t = `git pull`
|
86
|
+
end
|
87
|
+
else
|
88
|
+
PROJECT.run("git clone #{@url} #{local_clone_directory}")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private def checkout_local_clone_directory_branch(branch)
|
93
|
+
update_local_clone_directory
|
94
|
+
if Dir.exist?(local_clone_directory)
|
95
|
+
Dir.chdir(local_clone_directory) do
|
96
|
+
check = `git branch`
|
97
|
+
t = `git checkout #{branch}` unless check.include?("* #{branch}")
|
98
|
+
check = `git branch`
|
99
|
+
return check.include?("* #{branch}")
|
100
|
+
end
|
107
101
|
end
|
102
|
+
false
|
103
|
+
end
|
108
104
|
end
|
109
|
-
end
|
105
|
+
end
|
106
|
+
end
|
data/lib/raykit/log.rb
CHANGED
@@ -1,43 +1,45 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
2
5
|
module Raykit
|
3
|
-
|
4
|
-
|
5
|
-
def initialize(filename)
|
6
|
-
@filename=filename
|
7
|
-
dir=File.dirname(@filename)
|
8
|
-
FileUtils.mkdir_p(dir) if(!Dir.exist?(dir))
|
9
|
-
if(File.exist?(@filename))
|
10
|
-
begin
|
11
|
-
data=JSON.parse(File.read(filename))
|
12
|
-
data.each{|k,v|
|
13
|
-
self[k] = v
|
14
|
-
}
|
15
|
-
rescue
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
6
|
+
class Log < Hash
|
7
|
+
@filename
|
19
8
|
|
20
|
-
|
21
|
-
|
9
|
+
def initialize(filename)
|
10
|
+
@filename = filename
|
11
|
+
dir = File.dirname(@filename)
|
12
|
+
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
13
|
+
if File.exist?(@filename)
|
14
|
+
begin
|
15
|
+
data = JSON.parse(File.read(filename))
|
16
|
+
data.each do |k, v|
|
17
|
+
self[k] = v
|
18
|
+
end
|
19
|
+
rescue StandardError
|
22
20
|
end
|
21
|
+
end
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
command_times.delete(command) if(command_times.has_key?(command))
|
28
|
-
command_times[command] = timestamp.iso8601()
|
29
|
-
self["command_times"] = command_times
|
30
|
-
save
|
31
|
-
end
|
24
|
+
def save
|
25
|
+
File.open(@filename, "w") { |f| f.write(JSON.generate(self)) }
|
26
|
+
end
|
32
27
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
28
|
+
def update_command_time(command, timestamp)
|
29
|
+
command_times = {}
|
30
|
+
command_times = self["command_times"] if key?("command_times")
|
31
|
+
command_times.delete(command) if command_times.key?(command)
|
32
|
+
command_times[command] = timestamp.iso8601
|
33
|
+
self["command_times"] = command_times
|
34
|
+
save
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_command_time(command)
|
38
|
+
if key?("command_times")
|
39
|
+
command_times = self["command_times"]
|
40
|
+
return DateTime.parse(command_times[command]) if command_times.key?(command)
|
41
|
+
end
|
42
|
+
nil
|
42
43
|
end
|
43
|
-
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/raykit/logevent.rb
CHANGED
@@ -1,36 +1,38 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
2
5
|
module Raykit
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
# :verbose, :debug, :information, :error, :fatal
|
7
|
+
class LogEvent < Hash
|
8
|
+
def initialize(level, messageTemplate, properties)
|
9
|
+
self["Timestamp"] = DateTime.now.iso8601
|
10
|
+
self["Level"] = level
|
11
|
+
self["Message"] = messageTemplate
|
12
|
+
self["MessageTemplate"] = messageTemplate
|
13
|
+
properties["MachineName"] = Raykit::Environment.machine unless properties.key?("MachineName")
|
14
|
+
properties["UserName"] = Raykit::Environment.user unless properties.key?("UserName")
|
15
|
+
properties["RakeDirectory"] = ::Rake.application.original_dir
|
16
|
+
self["Properties"] = properties
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
24
|
-
#puts '---executing---'
|
25
|
-
#puts cmd_str
|
26
|
-
puts `#{cmd_str}`
|
27
|
-
end
|
19
|
+
def to_seq
|
20
|
+
# puts '---to_seq---'
|
21
|
+
# puts self['Message']
|
22
|
+
unless ENV["SEQ_SERVER"].nil?
|
23
|
+
cmd_str = "seqcli log -m \"#{self["Message"].gsub('"', "")}\" -l #{self["Level"]} -s #{ENV["SEQ_SERVER"]}"
|
24
|
+
self["Properties"].each do |k, v|
|
25
|
+
cmd_str += " -p \"#{k}=#{v}\""
|
28
26
|
end
|
27
|
+
# puts '---executing---'
|
28
|
+
# puts cmd_str
|
29
|
+
puts `#{cmd_str}`
|
30
|
+
end
|
29
31
|
end
|
32
|
+
end
|
30
33
|
end
|
31
34
|
|
32
|
-
|
33
|
-
#{
|
35
|
+
# {
|
34
36
|
# "Timestamp": "2021-10-06T06:09:25.5275817-06:00",
|
35
37
|
# "Level": "Information",
|
36
38
|
# "MessageTemplate": "MachineName {machine}",
|
@@ -44,4 +46,4 @@ end
|
|
44
46
|
# "UserName": "\"loupa\"",
|
45
47
|
# "OS": "Windows_NT"
|
46
48
|
# }
|
47
|
-
#}
|
49
|
+
# }
|
data/lib/raykit/logging.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "logger"
|
3
5
|
|
4
6
|
module Raykit
|
5
|
-
|
6
|
-
|
7
|
+
class Logging
|
8
|
+
attr_accessor :enabled, :loggers
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
# Logger::Severity DEBUG,ERROR,FATAL,INFO,UNKOWN,WARN
|
11
|
+
# defaults to WARN
|
12
|
+
attr_accessor :severity
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
def initialize
|
15
|
+
@enabled = true
|
16
|
+
@loggers = {}
|
17
|
+
@severity = Logger::Severity::WARN
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def set_severity_as_string(severity)
|
21
|
+
@severity = Logger::Severity::DEBUG if severity == "debug"
|
22
|
+
@severity = Logger::Severity::INFO if severity == "info"
|
23
|
+
@severity = Logger::Severity::WARN if severity == "warn"
|
24
|
+
@severity = Logger::Severity::ERROR if severity == "error"
|
25
|
+
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
loggers[context]
|
27
|
+
def get_logger(context)
|
28
|
+
unless loggers.key?(context)
|
29
|
+
Dir.chdir(Environment.get_dev_dir("log")) do
|
30
|
+
# start the log over whenever the log exceeds 100 megabytes in size
|
31
|
+
loggers[context] = Logger.new("#{context}.log", 0, 100 * 1024 * 1024)
|
33
32
|
end
|
33
|
+
end
|
34
|
+
loggers[context]
|
35
|
+
end
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
37
|
+
def log(context, level, message)
|
38
|
+
if @enabled
|
39
|
+
logger = get_logger(context)
|
40
|
+
case level
|
41
|
+
when Logger::Severity::DEBUG
|
42
|
+
logger.debug(message)
|
43
|
+
when Logger::Severity::INFO
|
44
|
+
logger.info(message)
|
45
|
+
when Logger::Severity::WARN
|
46
|
+
logger.warn(message)
|
47
|
+
when Logger::Severity::ERROR
|
48
|
+
logger.error(message)
|
49
|
+
when Logger::Severity::FATAL
|
50
|
+
logger.fatal(message)
|
51
|
+
else
|
52
|
+
logger.unknown(message)
|
53
53
|
end
|
54
|
+
end
|
54
55
|
end
|
55
|
-
|
56
|
-
|
56
|
+
end
|
57
57
|
end
|
58
58
|
|
59
|
-
LOG = Raykit::Logging.new
|
59
|
+
LOG = Raykit::Logging.new
|
data/lib/raykit/msbuild.rb
CHANGED
@@ -1,14 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Raykit
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
class MsBuild
|
5
|
+
def self.msbuild_path
|
6
|
+
["2022/Community/MSBuild/Current/Bin",
|
7
|
+
"2019/Enterprise/MSBuild/Current/Bin",
|
8
|
+
"2019/Professional/MSBuild/Current/Bin",
|
9
|
+
"2019/Community/MSBuild/Current/Bin",
|
10
|
+
"2017/BuildTools/MSBuild/15.0/Bin"].each do |relative_path|
|
11
|
+
["C:/Program Files/Microsoft Visual Studio/",
|
12
|
+
"C:/Program Files (x86)/Microsoft Visual Studio/"].each do |prog_path|
|
13
|
+
path = "#{prog_path}#{relative_path}"
|
14
|
+
return path if Dir.exist?(path)
|
12
15
|
end
|
16
|
+
#path = "C:/Program Files (x86)/Microsoft Visual Studio/#{relative_path}"
|
17
|
+
#return path if Dir.exist?(path)
|
18
|
+
end
|
19
|
+
""
|
13
20
|
end
|
14
|
-
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/raykit/nugetpackage.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module Raykit
|
3
|
-
|
4
|
-
|
5
|
-
attr_accessor :version
|
4
|
+
class NugetPackage
|
5
|
+
attr_accessor :name, :version
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
def initialize(name, version)
|
8
|
+
@name = name
|
9
|
+
@version = version
|
11
10
|
end
|
12
|
-
end
|
11
|
+
end
|
12
|
+
end
|