raykit 0.0.501 → 0.0.503
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +25 -20
- data/bin/raykit +6 -6
- data/lib/raykit/auto_setup.rb +69 -69
- data/lib/raykit/command.rb +373 -373
- data/lib/raykit/conan/buildinfo.rb +69 -69
- data/lib/raykit/conanpackage.rb +49 -49
- data/lib/raykit/configuration.rb +53 -50
- data/lib/raykit/console.rb +314 -308
- data/lib/raykit/default_content.rb +227 -227
- data/lib/raykit/dir.rb +49 -49
- data/lib/raykit/dotnet.rb +174 -174
- data/lib/raykit/environment.rb +114 -114
- data/lib/raykit/filesystem.rb +34 -34
- data/lib/raykit/git/commit.rb +16 -16
- data/lib/raykit/git/directory.rb +216 -216
- data/lib/raykit/git/files.rb +46 -46
- data/lib/raykit/git/repositories.rb +89 -89
- data/lib/raykit/git/repository.rb +376 -376
- data/lib/raykit/installer.rb +17 -17
- data/lib/raykit/log.rb +80 -80
- data/lib/raykit/logevent.rb +49 -49
- data/lib/raykit/logging.rb +57 -57
- data/lib/raykit/markdown.rb +21 -21
- data/lib/raykit/msbuild.rb +54 -54
- data/lib/raykit/nugetpackage.rb +54 -54
- data/lib/raykit/nunit.rb +13 -13
- data/lib/raykit/project.rb +343 -343
- data/lib/raykit/rake.rb +39 -39
- data/lib/raykit/runner.rb +42 -42
- data/lib/raykit/secrets.rb +38 -38
- data/lib/raykit/sourceImport.rb +76 -76
- data/lib/raykit/sourceImports.rb +43 -43
- data/lib/raykit/string.rb +18 -18
- data/lib/raykit/symbols.rb +16 -16
- data/lib/raykit/tasks.rb +99 -99
- data/lib/raykit/text.rb +32 -32
- data/lib/raykit/timer.rb +31 -31
- data/lib/raykit/version.rb +103 -103
- data/lib/raykit/vstest.rb +24 -24
- data/lib/raykit/wt.rb +28 -28
- data/lib/raykit/zip.rb +73 -73
- data/lib/raykit.rb +125 -125
- metadata +1 -1
data/lib/raykit/installer.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class Installer
|
5
|
-
def self.make_msi(wxs_file, source_dir, msi_filename)
|
6
|
-
name = "#{File.basename(wxs_file, ".wxs")}"
|
7
|
-
FileUtils.cp(wxs_file, "#{source_dir}/#{File.basename(wxs_file)}")
|
8
|
-
Dir.chdir(source_dir) do
|
9
|
-
run("candle #{File.basename(wxs_file)}")
|
10
|
-
run("light #{name}.wixobj")
|
11
|
-
FileUtils.cp("#{name}.msi", msi_filename)
|
12
|
-
raise "#{msi_filename} does not exist" if !File.exist?(msi_filename)
|
13
|
-
File.delete("#{name}.wixobj")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class Installer
|
5
|
+
def self.make_msi(wxs_file, source_dir, msi_filename)
|
6
|
+
name = "#{File.basename(wxs_file, ".wxs")}"
|
7
|
+
FileUtils.cp(wxs_file, "#{source_dir}/#{File.basename(wxs_file)}")
|
8
|
+
Dir.chdir(source_dir) do
|
9
|
+
run("candle #{File.basename(wxs_file)}")
|
10
|
+
run("light #{name}.wixobj")
|
11
|
+
FileUtils.cp("#{name}.msi", msi_filename)
|
12
|
+
raise "#{msi_filename} does not exist" if !File.exist?(msi_filename)
|
13
|
+
File.delete("#{name}.wixobj")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/raykit/log.rb
CHANGED
@@ -1,80 +1,80 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class Log < Hash
|
5
|
-
@filename
|
6
|
-
|
7
|
-
def initialize(filename)
|
8
|
-
@filename = filename
|
9
|
-
dir = File.dirname(@filename)
|
10
|
-
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
11
|
-
if File.exist?(@filename)
|
12
|
-
begin
|
13
|
-
data = JSON.parse(File.read(filename))
|
14
|
-
data.each do |k, v|
|
15
|
-
self[k] = v
|
16
|
-
end
|
17
|
-
rescue StandardError
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def save
|
23
|
-
File.open(@filename, "w") { |f| f.write(JSON.generate(self)) }
|
24
|
-
end
|
25
|
-
|
26
|
-
def update_command_time(command, timestamp)
|
27
|
-
command_times = {}
|
28
|
-
command_times = self["command_times"] if key?("command_times")
|
29
|
-
command_times.delete(command) if command_times.key?(command)
|
30
|
-
command_times[command] = timestamp.iso8601
|
31
|
-
self["command_times"] = command_times
|
32
|
-
save
|
33
|
-
end
|
34
|
-
|
35
|
-
def get_command_time(command)
|
36
|
-
if key?("command_times")
|
37
|
-
command_times = self["command_times"]
|
38
|
-
return DateTime.parse(command_times[command]) if command_times.key?(command)
|
39
|
-
end
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.start_task(task_name)
|
44
|
-
puts Rainbow(": #{task_name}").blue.bright
|
45
|
-
MARKDOWN.puts(": #{task_name}")
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.show_value(name, value)
|
49
|
-
puts " " + Rainbow(name).cyan + " " + Rainbow("#{value}").white.bold
|
50
|
-
MARKDOWN.puts("#{name} #{value}")
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.name_value_pair(symbol, the_binding)
|
54
|
-
[symbol.to_s, eval(symbol.to_s, the_binding)]
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.show_table(symbols)
|
58
|
-
max_name_width = 0
|
59
|
-
max_value_width = 0
|
60
|
-
symbols.each { |s|
|
61
|
-
nvp = name_value_pair(s, binding)
|
62
|
-
name = nvp[0]
|
63
|
-
value = nvp[1]
|
64
|
-
max_name_width = name.length if (name.length > max_name_width)
|
65
|
-
if (!value.nil?)
|
66
|
-
max_value_width = value.length if (value.length > max_value_width)
|
67
|
-
end
|
68
|
-
}
|
69
|
-
header = " =".ljust(max_name_width + max_value_width + 5, "=")
|
70
|
-
puts header
|
71
|
-
symbols.each { |s|
|
72
|
-
nvp = name_value_pair(s, binding)
|
73
|
-
name = nvp[0].rjust(max_name_width, " ")
|
74
|
-
value = nvp[1]
|
75
|
-
puts " " + Rainbow(name).cyan + " | " + Rainbow("#{value}").white.bold
|
76
|
-
}
|
77
|
-
puts header
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class Log < Hash
|
5
|
+
@filename
|
6
|
+
|
7
|
+
def initialize(filename)
|
8
|
+
@filename = filename
|
9
|
+
dir = File.dirname(@filename)
|
10
|
+
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
11
|
+
if File.exist?(@filename)
|
12
|
+
begin
|
13
|
+
data = JSON.parse(File.read(filename))
|
14
|
+
data.each do |k, v|
|
15
|
+
self[k] = v
|
16
|
+
end
|
17
|
+
rescue StandardError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def save
|
23
|
+
File.open(@filename, "w") { |f| f.write(JSON.generate(self)) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_command_time(command, timestamp)
|
27
|
+
command_times = {}
|
28
|
+
command_times = self["command_times"] if key?("command_times")
|
29
|
+
command_times.delete(command) if command_times.key?(command)
|
30
|
+
command_times[command] = timestamp.iso8601
|
31
|
+
self["command_times"] = command_times
|
32
|
+
save
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_command_time(command)
|
36
|
+
if key?("command_times")
|
37
|
+
command_times = self["command_times"]
|
38
|
+
return DateTime.parse(command_times[command]) if command_times.key?(command)
|
39
|
+
end
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.start_task(task_name)
|
44
|
+
puts Rainbow(": #{task_name}").blue.bright
|
45
|
+
MARKDOWN.puts(": #{task_name}")
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.show_value(name, value)
|
49
|
+
puts " " + Rainbow(name).cyan + " " + Rainbow("#{value}").white.bold
|
50
|
+
MARKDOWN.puts("#{name} #{value}")
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.name_value_pair(symbol, the_binding)
|
54
|
+
[symbol.to_s, eval(symbol.to_s, the_binding)]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.show_table(symbols)
|
58
|
+
max_name_width = 0
|
59
|
+
max_value_width = 0
|
60
|
+
symbols.each { |s|
|
61
|
+
nvp = name_value_pair(s, binding)
|
62
|
+
name = nvp[0]
|
63
|
+
value = nvp[1]
|
64
|
+
max_name_width = name.length if (name.length > max_name_width)
|
65
|
+
if (!value.nil?)
|
66
|
+
max_value_width = value.length if (value.length > max_value_width)
|
67
|
+
end
|
68
|
+
}
|
69
|
+
header = " =".ljust(max_name_width + max_value_width + 5, "=")
|
70
|
+
puts header
|
71
|
+
symbols.each { |s|
|
72
|
+
nvp = name_value_pair(s, binding)
|
73
|
+
name = nvp[0].rjust(max_name_width, " ")
|
74
|
+
value = nvp[1]
|
75
|
+
puts " " + Rainbow(name).cyan + " | " + Rainbow("#{value}").white.bold
|
76
|
+
}
|
77
|
+
puts header
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/raykit/logevent.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
|
5
|
-
module Raykit
|
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
|
18
|
-
|
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}\""
|
26
|
-
end
|
27
|
-
# puts '---executing---'
|
28
|
-
# puts cmd_str
|
29
|
-
puts `#{cmd_str}`
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# {
|
36
|
-
# "Timestamp": "2021-10-06T06:09:25.5275817-06:00",
|
37
|
-
# "Level": "Information",
|
38
|
-
# "MessageTemplate": "MachineName {machine}",
|
39
|
-
# "Properties": {
|
40
|
-
# "machine": "BLUEFIN",
|
41
|
-
# "SourceContext": "cslogging.Program",
|
42
|
-
# "ThreadId": 1,
|
43
|
-
# "ProcessId": 16764,
|
44
|
-
# "ProcessName": "cs-logging",
|
45
|
-
# "MachineName": "\"BLUEFIN\"",
|
46
|
-
# "UserName": "\"loupa\"",
|
47
|
-
# "OS": "Windows_NT"
|
48
|
-
# }
|
49
|
-
# }
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Raykit
|
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
|
18
|
+
|
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}\""
|
26
|
+
end
|
27
|
+
# puts '---executing---'
|
28
|
+
# puts cmd_str
|
29
|
+
puts `#{cmd_str}`
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# {
|
36
|
+
# "Timestamp": "2021-10-06T06:09:25.5275817-06:00",
|
37
|
+
# "Level": "Information",
|
38
|
+
# "MessageTemplate": "MachineName {machine}",
|
39
|
+
# "Properties": {
|
40
|
+
# "machine": "BLUEFIN",
|
41
|
+
# "SourceContext": "cslogging.Program",
|
42
|
+
# "ThreadId": 1,
|
43
|
+
# "ProcessId": 16764,
|
44
|
+
# "ProcessName": "cs-logging",
|
45
|
+
# "MachineName": "\"BLUEFIN\"",
|
46
|
+
# "UserName": "\"loupa\"",
|
47
|
+
# "OS": "Windows_NT"
|
48
|
+
# }
|
49
|
+
# }
|
data/lib/raykit/logging.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
require "logger"
|
5
|
-
|
6
|
-
module Raykit
|
7
|
-
class Logging
|
8
|
-
attr_accessor :enabled, :loggers
|
9
|
-
|
10
|
-
# Logger::Severity DEBUG,ERROR,FATAL,INFO,UNKOWN,WARN
|
11
|
-
# defaults to WARN
|
12
|
-
attr_accessor :severity
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
@enabled = true
|
16
|
-
@loggers = {}
|
17
|
-
@severity = Logger::Severity::WARN
|
18
|
-
end
|
19
|
-
|
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
|
26
|
-
|
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)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
loggers[context]
|
35
|
-
end
|
36
|
-
|
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
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "logger"
|
5
|
+
|
6
|
+
module Raykit
|
7
|
+
class Logging
|
8
|
+
attr_accessor :enabled, :loggers
|
9
|
+
|
10
|
+
# Logger::Severity DEBUG,ERROR,FATAL,INFO,UNKOWN,WARN
|
11
|
+
# defaults to WARN
|
12
|
+
attr_accessor :severity
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@enabled = true
|
16
|
+
@loggers = {}
|
17
|
+
@severity = Logger::Severity::WARN
|
18
|
+
end
|
19
|
+
|
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
|
26
|
+
|
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)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
loggers[context]
|
35
|
+
end
|
36
|
+
|
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
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/raykit/markdown.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
module Raykit
|
2
|
-
class Markdown
|
3
|
-
attr_accessor :text
|
4
|
-
|
5
|
-
def initialize()
|
6
|
-
@text = ""
|
7
|
-
end
|
8
|
-
|
9
|
-
def puts(line)
|
10
|
-
@text = @text + "\n" + line
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_s()
|
14
|
-
@text
|
15
|
-
end
|
16
|
-
|
17
|
-
def save_as(filename)
|
18
|
-
File.write("rake.md", @text)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
module Raykit
|
2
|
+
class Markdown
|
3
|
+
attr_accessor :text
|
4
|
+
|
5
|
+
def initialize()
|
6
|
+
@text = ""
|
7
|
+
end
|
8
|
+
|
9
|
+
def puts(line)
|
10
|
+
@text = @text + "\n" + line
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s()
|
14
|
+
@text
|
15
|
+
end
|
16
|
+
|
17
|
+
def save_as(filename)
|
18
|
+
File.write("rake.md", @text)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/raykit/msbuild.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class MsBuild
|
5
|
-
def self.fix_msbuild_path
|
6
|
-
# if msbuild in not in the current path,
|
7
|
-
# attempt to modify the path such that is it
|
8
|
-
has_msbuild = false
|
9
|
-
begin
|
10
|
-
cmd = Raykit::Command.new("msbuild --version").run
|
11
|
-
has_msbuild = true if (cmd.exitstatus != 0)
|
12
|
-
rescue
|
13
|
-
has_msbuild = false
|
14
|
-
end
|
15
|
-
if (!has_msbuild)
|
16
|
-
if (Dir.exist?(msbuild_path))
|
17
|
-
#puts " added #{msbuild_path} to PATH for msbuild"
|
18
|
-
ENV["PATH"] = ENV["PATH"] + ";#{msbuild_path}"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin
|
24
|
-
def self.msbuild_path
|
25
|
-
["2022/Community/Msbuild/Current/Bin",
|
26
|
-
"2022/Professional/Msbuild/Current/Bin",
|
27
|
-
"2022/Enterprise/Msbuild/Current/Bin",
|
28
|
-
"2019/Enterprise/MSBuild/Current/Bin",
|
29
|
-
"2019/Professional/MSBuild/Current/Bin",
|
30
|
-
"2019/Community/MSBuild/Current/Bin",
|
31
|
-
"2017/BuildTools/MSBuild/15.0/Bin"].each do |relative_path|
|
32
|
-
["C:/Program Files/Microsoft Visual Studio/",
|
33
|
-
"C:/Program Files (x86)/Microsoft Visual Studio/"].each do |prog_path|
|
34
|
-
path = "#{prog_path}#{relative_path}"
|
35
|
-
return path if Dir.exist?(path)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
""
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.msbuild_2019_path
|
42
|
-
["2019/Enterprise/MSBuild/Current/Bin",
|
43
|
-
"2019/Professional/MSBuild/Current/Bin",
|
44
|
-
"2019/Community/MSBuild/Current/Bin"].each do |relative_path|
|
45
|
-
["C:/Program Files/Microsoft Visual Studio/",
|
46
|
-
"C:/Program Files (x86)/Microsoft Visual Studio/"].each do |prog_path|
|
47
|
-
path = "#{prog_path}#{relative_path}"
|
48
|
-
return path if Dir.exist?(path)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
""
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class MsBuild
|
5
|
+
def self.fix_msbuild_path
|
6
|
+
# if msbuild in not in the current path,
|
7
|
+
# attempt to modify the path such that is it
|
8
|
+
has_msbuild = false
|
9
|
+
begin
|
10
|
+
cmd = Raykit::Command.new("msbuild --version").run
|
11
|
+
has_msbuild = true if (cmd.exitstatus != 0)
|
12
|
+
rescue
|
13
|
+
has_msbuild = false
|
14
|
+
end
|
15
|
+
if (!has_msbuild)
|
16
|
+
if (Dir.exist?(msbuild_path))
|
17
|
+
#puts " added #{msbuild_path} to PATH for msbuild"
|
18
|
+
ENV["PATH"] = ENV["PATH"] + ";#{msbuild_path}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin
|
24
|
+
def self.msbuild_path
|
25
|
+
["2022/Community/Msbuild/Current/Bin",
|
26
|
+
"2022/Professional/Msbuild/Current/Bin",
|
27
|
+
"2022/Enterprise/Msbuild/Current/Bin",
|
28
|
+
"2019/Enterprise/MSBuild/Current/Bin",
|
29
|
+
"2019/Professional/MSBuild/Current/Bin",
|
30
|
+
"2019/Community/MSBuild/Current/Bin",
|
31
|
+
"2017/BuildTools/MSBuild/15.0/Bin"].each do |relative_path|
|
32
|
+
["C:/Program Files/Microsoft Visual Studio/",
|
33
|
+
"C:/Program Files (x86)/Microsoft Visual Studio/"].each do |prog_path|
|
34
|
+
path = "#{prog_path}#{relative_path}"
|
35
|
+
return path if Dir.exist?(path)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
""
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.msbuild_2019_path
|
42
|
+
["2019/Enterprise/MSBuild/Current/Bin",
|
43
|
+
"2019/Professional/MSBuild/Current/Bin",
|
44
|
+
"2019/Community/MSBuild/Current/Bin"].each do |relative_path|
|
45
|
+
["C:/Program Files/Microsoft Visual Studio/",
|
46
|
+
"C:/Program Files (x86)/Microsoft Visual Studio/"].each do |prog_path|
|
47
|
+
path = "#{prog_path}#{relative_path}"
|
48
|
+
return path if Dir.exist?(path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
""
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/raykit/nugetpackage.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class NuGetPackage
|
5
|
-
attr_accessor :name, :version
|
6
|
-
|
7
|
-
def initialize(name, version)
|
8
|
-
@name = name
|
9
|
-
@version = version
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.get(text, name)
|
13
|
-
Raykit::NugetPackage.new(name, get_version(text, name))
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.get_version(text, name)
|
17
|
-
[/<PackageReference[\s]+Include=\"#{name}\"[\s]+Version=\"([\d\.]+)/,
|
18
|
-
/<Reference[\s]+Include=\"#{name},[\s]+Version=([\d\.]+)/,
|
19
|
-
/<HintPath>[\.\\\/\w\d]+#{name}.([\d\.]+)/].each { |regex|
|
20
|
-
matches = text.scan(regex)
|
21
|
-
if matches.length > 0 && matches[0].length > 0
|
22
|
-
return matches[0][0]
|
23
|
-
end
|
24
|
-
}
|
25
|
-
""
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.set_version(text, name, version)
|
29
|
-
puts "NuGetPackage::set_version"
|
30
|
-
new_text = text
|
31
|
-
[/(<PackageReference[\s]+Include=\"#{name}\"[\s]+Version=\"[\d\.]+)/,
|
32
|
-
/(<Reference[\s]+Include=\"#{name},[\s]+Version=[\d\.]+)/,
|
33
|
-
/(<HintPath>[\.\\\/\w\d]+#{name}.[\d\.]+)/].each { |regex|
|
34
|
-
matches = text.scan(regex)
|
35
|
-
if matches.length > 0 && matches[0].length > 0
|
36
|
-
orig = matches[0][0]
|
37
|
-
oversion = get_version(orig, name)
|
38
|
-
mod = orig.sub(oversion, version)
|
39
|
-
puts "match[0][0] " + matches[0][0]
|
40
|
-
puts "old version " + oversion
|
41
|
-
puts "new version " + version
|
42
|
-
new_text = new_text.gsub(orig, mod)
|
43
|
-
end
|
44
|
-
}
|
45
|
-
new_text
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.set_version_in_file(filename, name, version)
|
49
|
-
text = set_version(IO.read(filename), name, version)
|
50
|
-
orig = IO.read(filename)
|
51
|
-
File.open(filename, "w") { |f| f.puts text } if (text != orig)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class NuGetPackage
|
5
|
+
attr_accessor :name, :version
|
6
|
+
|
7
|
+
def initialize(name, version)
|
8
|
+
@name = name
|
9
|
+
@version = version
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get(text, name)
|
13
|
+
Raykit::NugetPackage.new(name, get_version(text, name))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.get_version(text, name)
|
17
|
+
[/<PackageReference[\s]+Include=\"#{name}\"[\s]+Version=\"([\d\.]+)/,
|
18
|
+
/<Reference[\s]+Include=\"#{name},[\s]+Version=([\d\.]+)/,
|
19
|
+
/<HintPath>[\.\\\/\w\d]+#{name}.([\d\.]+)/].each { |regex|
|
20
|
+
matches = text.scan(regex)
|
21
|
+
if matches.length > 0 && matches[0].length > 0
|
22
|
+
return matches[0][0]
|
23
|
+
end
|
24
|
+
}
|
25
|
+
""
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.set_version(text, name, version)
|
29
|
+
puts "NuGetPackage::set_version"
|
30
|
+
new_text = text
|
31
|
+
[/(<PackageReference[\s]+Include=\"#{name}\"[\s]+Version=\"[\d\.]+)/,
|
32
|
+
/(<Reference[\s]+Include=\"#{name},[\s]+Version=[\d\.]+)/,
|
33
|
+
/(<HintPath>[\.\\\/\w\d]+#{name}.[\d\.]+)/].each { |regex|
|
34
|
+
matches = text.scan(regex)
|
35
|
+
if matches.length > 0 && matches[0].length > 0
|
36
|
+
orig = matches[0][0]
|
37
|
+
oversion = get_version(orig, name)
|
38
|
+
mod = orig.sub(oversion, version)
|
39
|
+
puts "match[0][0] " + matches[0][0]
|
40
|
+
puts "old version " + oversion
|
41
|
+
puts "new version " + version
|
42
|
+
new_text = new_text.gsub(orig, mod)
|
43
|
+
end
|
44
|
+
}
|
45
|
+
new_text
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.set_version_in_file(filename, name, version)
|
49
|
+
text = set_version(IO.read(filename), name, version)
|
50
|
+
orig = IO.read(filename)
|
51
|
+
File.open(filename, "w") { |f| f.puts text } if (text != orig)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|