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/git/directory.rb
CHANGED
@@ -1,150 +1,145 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Raykit
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
def remote
|
139
|
-
if(Dir.exist?(directory))
|
140
|
-
Dir.chdir(directory) do
|
141
|
-
if(Dir.exist?('.git'))
|
142
|
-
return Command.new('git config --get remote.origin.url').output.strip
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
""
|
147
|
-
end
|
4
|
+
module Git
|
5
|
+
# Functionality to manage a local clone of a git repository
|
6
|
+
class Directory
|
7
|
+
# The directory name of the local repository clone
|
8
|
+
attr_accessor :directory
|
9
|
+
|
10
|
+
@repository
|
11
|
+
|
12
|
+
def initialize(directory)
|
13
|
+
@directory = directory
|
14
|
+
end
|
15
|
+
|
16
|
+
def outstanding_commit?
|
17
|
+
Dir.chdir(directory) do
|
18
|
+
if user_can_commit
|
19
|
+
return !`git status`.include?("nothing to commit,")
|
20
|
+
else
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def detached?
|
27
|
+
Dir.chdir(directory) do
|
28
|
+
status = `git status`.strip
|
29
|
+
if status.include?("detached")
|
30
|
+
true
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def pull
|
38
|
+
Dir.chdir(directory) do
|
39
|
+
diff = `git diff`.strip
|
40
|
+
status = `git status`.strip
|
41
|
+
PROJECT.run("git pull", false) if diff.length.zero? && status.include?("nothing to commit")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def rake(task)
|
46
|
+
unless Dir.exist?(@directory)
|
47
|
+
puts "directory not found."
|
48
|
+
return 1
|
49
|
+
end
|
50
|
+
debug = false
|
51
|
+
sub_dir = "work"
|
52
|
+
sub_dir = "make" if @directory.include?("/make/")
|
53
|
+
rake_log = repository.get_dev_dir("log") + "/#{sub_dir}.rake.#{task}.json"
|
54
|
+
|
55
|
+
puts "log filename #{rake_log}" if debug
|
56
|
+
if File.exist?(rake_log) && (File.mtime(rake_log) > last_modified_time)
|
57
|
+
puts "using logged data" if debug
|
58
|
+
cmd = Raykit::Command.parse(File.read(rake_log))
|
59
|
+
cmd.summary
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
Dir.chdir(@directory) do
|
64
|
+
if File.exist?("rakefile.rb")
|
65
|
+
cmd = Raykit::Command.new("rake #{task}")
|
66
|
+
cmd.summary
|
67
|
+
FileUtils.mkdir_p(File.dirname(rake_log))
|
68
|
+
File.open(rake_log, "w") { |f| f.write(JSON.generate(cmd.to_hash)) }
|
69
|
+
else
|
70
|
+
puts "rakefile.rb not found"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def last_modified_time
|
76
|
+
Dir.chdir(@directory) do
|
77
|
+
File.mtime(Dir.glob("**/*.*").select { |f| File.file?(f) }.max_by { |f| File.mtime(f) })
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# The latest tag for a branch of the repository
|
82
|
+
def latest_tag(_branch)
|
83
|
+
Dir.chdir(directory) do
|
84
|
+
return `git describe --abbrev=0`.strip
|
85
|
+
end
|
86
|
+
""
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_tag_commit_id(name)
|
90
|
+
cmd = Raykit::Command.new("git rev-parse \"#{name}\"", 0, nil, false)
|
91
|
+
if !cmd.output.include?("fatal") && !cmd.error.include?("fatal")
|
92
|
+
cmd.output.strip
|
93
|
+
else
|
94
|
+
""
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_sha(filename)
|
99
|
+
if File.exist?(filename)
|
100
|
+
Digest::SHA256.file(filename).hexdigest.to_s
|
101
|
+
else
|
102
|
+
"#{filename} not found"
|
103
|
+
end
|
104
|
+
# ''
|
105
|
+
end
|
106
|
+
|
107
|
+
def user_name
|
108
|
+
`git config --get user.name`.strip
|
109
|
+
end
|
110
|
+
|
111
|
+
def user_email
|
112
|
+
`git config --get user.email`.strip
|
113
|
+
end
|
114
|
+
|
115
|
+
def user_can_commit
|
116
|
+
return false if user_name.length.zero?
|
117
|
+
return false if user_email.length.zero?
|
118
|
+
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
def branch
|
123
|
+
Dir.chdir(directory) do
|
124
|
+
scan = `git branch`.scan(/\*\s([\w.-]+)/)
|
125
|
+
return scan[0][0].to_s if !scan.nil? && scan.length.positive? && scan[0].length.positive?
|
126
|
+
end
|
127
|
+
"master"
|
128
|
+
end
|
129
|
+
|
130
|
+
def repository
|
131
|
+
@repository = Raykit::Git::Repository.new(remote) if @repository.nil?
|
132
|
+
@repository
|
133
|
+
end
|
134
|
+
|
135
|
+
def remote
|
136
|
+
if Dir.exist?(directory)
|
137
|
+
Dir.chdir(directory) do
|
138
|
+
return Command.new("git config --get remote.origin.url").output.strip if Dir.exist?(".git")
|
139
|
+
end
|
148
140
|
end
|
141
|
+
""
|
142
|
+
end
|
149
143
|
end
|
150
|
-
end
|
144
|
+
end
|
145
|
+
end
|
data/lib/raykit/git/files.rb
CHANGED
@@ -1,45 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Raykit
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
if File.exists?(filename(name))
|
31
|
-
return filename(name)
|
32
|
-
end
|
33
|
-
''
|
34
|
-
end
|
35
|
-
|
36
|
-
def commit_path
|
37
|
-
Dir.tmpdir() + File::SEPARATOR + 'Raykit.Git.Files' + File::SEPARATOR + @url.gsub('://','.') + File::SEPARATOR + @commit_id
|
38
|
-
end
|
39
|
-
|
40
|
-
def filename(name)
|
41
|
-
commit_path() + File::SEPARATOR + name
|
42
|
-
end
|
4
|
+
module Git
|
5
|
+
# Functionality to manage a local clone of a git repository
|
6
|
+
class Files
|
7
|
+
@url
|
8
|
+
@commit_id
|
9
|
+
|
10
|
+
def initialize(url, commit_id)
|
11
|
+
@url = url
|
12
|
+
@commit_id = commit_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def clean
|
16
|
+
FileUtils.rm_rf(commit_path) if Dir.exist?(commit_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(name)
|
20
|
+
puts "commit_path(): #{commit_path}"
|
21
|
+
unless Dir.exist?(commit_path)
|
22
|
+
puts "cloning commit path..."
|
23
|
+
clone = Raykit::Command.new("git clone #{@url} #{commit_path}")
|
24
|
+
puts clone.output
|
25
|
+
puts clone.error
|
26
|
+
Dir.chdir(commit_path) do
|
27
|
+
checkout = Raykit::Command.new("git checkout #{@commit_id}")
|
28
|
+
end
|
43
29
|
end
|
30
|
+
|
31
|
+
return filename(name) if File.exist?(filename(name))
|
32
|
+
|
33
|
+
""
|
34
|
+
end
|
35
|
+
|
36
|
+
def commit_path
|
37
|
+
Dir.tmpdir + File::SEPARATOR + "Raykit.Git.Files" + File::SEPARATOR + @url.gsub("://",
|
38
|
+
".") + File::SEPARATOR + @commit_id
|
39
|
+
end
|
40
|
+
|
41
|
+
def filename(name)
|
42
|
+
commit_path + File::SEPARATOR + name
|
43
|
+
end
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,93 +1,91 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative("./directory")
|
2
4
|
|
3
5
|
module Raykit
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
module Git
|
7
|
+
# Functionality to manage a remote git repository
|
8
|
+
class Repositories < Array
|
9
|
+
attr_accessor :filename
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def initialize(filename)
|
12
|
+
@filename = filename
|
13
|
+
open(@filename)
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def open(filename)
|
17
|
+
if File.exist?(filename)
|
18
|
+
JSON.parse(File.read(filename)).each do |url|
|
19
|
+
insert(-1, url)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
# puts "filename #{filename} does not exist"
|
23
|
+
end
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def save(_filename)
|
27
|
+
File.open(@filename, "w") do |f|
|
28
|
+
# json = JSON.pretty_generate(self)
|
29
|
+
f.write(JSON.pretty_generate(self))
|
30
|
+
# f.write(self.to_json)
|
31
|
+
end
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
def work_dir
|
35
|
+
Environment.get_dev_dir("work")
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
false
|
40
|
-
end
|
38
|
+
def is_remote_url(pattern)
|
39
|
+
return true if pattern.include?("http://")
|
40
|
+
return true if pattern.include?("https://")
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
self.delete(url)
|
45
|
-
save(@filename)
|
46
|
-
end
|
47
|
-
end
|
42
|
+
false
|
43
|
+
end
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
imported.insert(-1,remote)
|
56
|
-
end
|
57
|
-
else
|
58
|
-
git_dirs = Array.new
|
59
|
-
Dir.chdir(work_dir) do
|
60
|
-
Dir.glob('**/.git'){|git_dir|
|
61
|
-
dir = File.expand_path('..',git_dir)
|
62
|
-
if(dir.length > 0)
|
63
|
-
git_dirs.insert(0,dir)
|
64
|
-
end
|
65
|
-
}
|
66
|
-
end
|
45
|
+
def remove(url)
|
46
|
+
if include?(url)
|
47
|
+
delete(url)
|
48
|
+
save(@filename)
|
49
|
+
end
|
50
|
+
end
|
67
51
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
52
|
+
def import(pattern)
|
53
|
+
imported = []
|
54
|
+
if is_remote_url(pattern)
|
55
|
+
remote = pattern
|
56
|
+
unless include?(remote)
|
57
|
+
insert(-1, remote)
|
58
|
+
imported.insert(-1, remote)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
git_dirs = []
|
62
|
+
Dir.chdir(work_dir) do
|
63
|
+
Dir.glob("**/.git") do |git_dir|
|
64
|
+
dir = File.expand_path("..", git_dir)
|
65
|
+
git_dirs.insert(0, dir) if dir.length.positive?
|
79
66
|
end
|
67
|
+
end
|
80
68
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}
|
88
|
-
matches
|
69
|
+
git_dirs.each do |git_dir|
|
70
|
+
dir = Raykit::Git::Directory.new(git_dir)
|
71
|
+
remote = dir.remote
|
72
|
+
if remote.include?(pattern) && !include?(remote)
|
73
|
+
insert(-1, remote)
|
74
|
+
imported.insert(-1, remote)
|
89
75
|
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
save(@filename)
|
79
|
+
imported
|
80
|
+
end
|
81
|
+
|
82
|
+
def matches(pattern)
|
83
|
+
matches = []
|
84
|
+
REPOSITORIES.each do |url|
|
85
|
+
matches << url if url.include?(pattern)
|
90
86
|
end
|
87
|
+
matches
|
88
|
+
end
|
91
89
|
end
|
90
|
+
end
|
92
91
|
end
|
93
|
-
|