raykit 0.0.482 → 0.0.484

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.
Files changed (43) 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 +43 -43
  6. data/lib/raykit/command.rb +341 -341
  7. data/lib/raykit/conan/buildinfo.rb +69 -69
  8. data/lib/raykit/conanpackage.rb +49 -49
  9. data/lib/raykit/console.rb +272 -272
  10. data/lib/raykit/default_content.rb +227 -227
  11. data/lib/raykit/dir.rb +49 -49
  12. data/lib/raykit/dotnet.rb +176 -174
  13. data/lib/raykit/environment.rb +109 -109
  14. data/lib/raykit/filesystem.rb +34 -34
  15. data/lib/raykit/git/commit.rb +16 -16
  16. data/lib/raykit/git/directory.rb +216 -216
  17. data/lib/raykit/git/files.rb +46 -46
  18. data/lib/raykit/git/repositories.rb +89 -89
  19. data/lib/raykit/git/repository.rb +244 -244
  20. data/lib/raykit/installer.rb +17 -17
  21. data/lib/raykit/log.rb +80 -80
  22. data/lib/raykit/logevent.rb +49 -49
  23. data/lib/raykit/logging.rb +57 -57
  24. data/lib/raykit/markdown.rb +21 -21
  25. data/lib/raykit/msbuild.rb +54 -54
  26. data/lib/raykit/nugetpackage.rb +54 -54
  27. data/lib/raykit/nunit.rb +13 -13
  28. data/lib/raykit/project.rb +339 -339
  29. data/lib/raykit/rake.rb +39 -39
  30. data/lib/raykit/runner.rb +42 -42
  31. data/lib/raykit/secrets.rb +38 -38
  32. data/lib/raykit/sourceImport.rb +74 -74
  33. data/lib/raykit/sourceImports.rb +43 -43
  34. data/lib/raykit/string.rb +18 -18
  35. data/lib/raykit/tasks.rb +99 -99
  36. data/lib/raykit/text.rb +32 -32
  37. data/lib/raykit/timer.rb +31 -31
  38. data/lib/raykit/version.rb +103 -103
  39. data/lib/raykit/vstest.rb +24 -24
  40. data/lib/raykit/wt.rb +28 -28
  41. data/lib/raykit/zip.rb +73 -73
  42. data/lib/raykit.rb +125 -125
  43. metadata +2 -2
@@ -1,89 +1,89 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("./directory")
4
-
5
- module Raykit
6
- module Git
7
- # Functionality to manage a remote git repository
8
- class Repositories < Array
9
- attr_accessor :filename
10
-
11
- def initialize(filename)
12
- @filename = filename
13
- open(@filename)
14
- end
15
-
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
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 work_dir
33
- Environment.get_dev_dir("work")
34
- end
35
-
36
- def is_remote_url(pattern)
37
- return true if pattern.include?("http://")
38
- return true if pattern.include?("https://")
39
-
40
- false
41
- end
42
-
43
- def remove(url)
44
- if include?(url)
45
- delete(url)
46
- save(@filename)
47
- end
48
- end
49
-
50
- def import(pattern)
51
- imported = []
52
- if is_remote_url(pattern)
53
- remote = pattern
54
- unless include?(remote)
55
- insert(-1, remote)
56
- imported.insert(-1, remote)
57
- end
58
- else
59
- git_dirs = []
60
- Dir.chdir(work_dir) do
61
- Dir.glob("**/.git") do |git_dir|
62
- dir = File.expand_path("..", git_dir)
63
- git_dirs.insert(0, dir) if dir.length.positive?
64
- end
65
- end
66
-
67
- git_dirs.each do |git_dir|
68
- dir = Raykit::Git::Directory.new(git_dir)
69
- remote = dir.remote
70
- if remote.include?(pattern) && !include?(remote)
71
- insert(-1, remote)
72
- imported.insert(-1, remote)
73
- end
74
- end
75
- end
76
- save(@filename)
77
- imported
78
- end
79
-
80
- def matches(pattern)
81
- matches = []
82
- REPOSITORIES.each do |url|
83
- matches << url if url.include?(pattern)
84
- end
85
- matches
86
- end
87
- end
88
- end
89
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative("./directory")
4
+
5
+ module Raykit
6
+ module Git
7
+ # Functionality to manage a remote git repository
8
+ class Repositories < Array
9
+ attr_accessor :filename
10
+
11
+ def initialize(filename)
12
+ @filename = filename
13
+ open(@filename)
14
+ end
15
+
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
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 work_dir
33
+ Environment.get_dev_dir("work")
34
+ end
35
+
36
+ def is_remote_url(pattern)
37
+ return true if pattern.include?("http://")
38
+ return true if pattern.include?("https://")
39
+
40
+ false
41
+ end
42
+
43
+ def remove(url)
44
+ if include?(url)
45
+ delete(url)
46
+ save(@filename)
47
+ end
48
+ end
49
+
50
+ def import(pattern)
51
+ imported = []
52
+ if is_remote_url(pattern)
53
+ remote = pattern
54
+ unless include?(remote)
55
+ insert(-1, remote)
56
+ imported.insert(-1, remote)
57
+ end
58
+ else
59
+ git_dirs = []
60
+ Dir.chdir(work_dir) do
61
+ Dir.glob("**/.git") do |git_dir|
62
+ dir = File.expand_path("..", git_dir)
63
+ git_dirs.insert(0, dir) if dir.length.positive?
64
+ end
65
+ end
66
+
67
+ git_dirs.each do |git_dir|
68
+ dir = Raykit::Git::Directory.new(git_dir)
69
+ remote = dir.remote
70
+ if remote.include?(pattern) && !include?(remote)
71
+ insert(-1, remote)
72
+ imported.insert(-1, remote)
73
+ end
74
+ end
75
+ end
76
+ save(@filename)
77
+ imported
78
+ end
79
+
80
+ def matches(pattern)
81
+ matches = []
82
+ REPOSITORIES.each do |url|
83
+ matches << url if url.include?(pattern)
84
+ end
85
+ matches
86
+ end
87
+ end
88
+ end
89
+ end
@@ -1,244 +1,244 @@
1
- # frozen_string_literal: true
2
-
3
- module Raykit
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
10
-
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
16
-
17
- def short_name()
18
- @url.split("/").last.gsub(".git", "")
19
- end
20
-
21
- def to_json(*_args)
22
- JSON.generate({ "url" => @url })
23
- end
24
-
25
- def self.parse(json)
26
- hash = JSON.parse(json)
27
- Repository.new(hash["url"])
28
- end
29
-
30
- # The relative path is a valid local path name derived from the url
31
- def relative_path
32
- @url.gsub("https://", "").gsub(".git", "").gsub("http://", "")
33
- end
34
-
35
- def get_dev_dir(dir)
36
- dev_dir = Environment.get_dev_dir(dir)
37
- Raykit::Environment::normalize_path("#{dev_dir}/#{relative_path}")
38
- end
39
-
40
- # Clone the repository to a specific directory
41
- def clone(directory, depth = 0)
42
- if depth.zero?
43
- PROJECT.run("git clone #{@url} #{directory}")
44
- else
45
- PROJECT.run("git clone #{@url} #{directory} --depth #{depth}")
46
- end
47
- end
48
-
49
- # default branch
50
- def default_branch
51
- update_local_clone_directory
52
- if Dir.exist?(local_clone_directory)
53
- Dir.chdir(local_clone_directory) do
54
- # refs/remotes/origin/master
55
- default_branch = `git symbolic-ref refs/remotes/origin/HEAD`.split("/").last.strip
56
- return default_branch
57
- end
58
- end
59
- "main"
60
- end
61
-
62
- # The branches for the git repository
63
- def branches
64
- results = []
65
- update_local_clone_directory
66
- if Dir.exist?(local_clone_directory)
67
- Dir.chdir(local_clone_directory) do
68
- `git branch`.split('\n').each do |line|
69
- branch = line.gsub("*", "").strip
70
- results.insert(-1, branch) if branch.length.positive?
71
- end
72
- end
73
- end
74
- results
75
- end
76
-
77
- # The latest commit id for a branch of the repostiory
78
- def latest_commit(branch)
79
- if checkout_local_clone_directory_branch(branch)
80
- update_local_clone_directory
81
- Dir.chdir(local_clone_directory) do
82
- text = `git log -n 1`
83
- scan = text.scan(/commit (\w+)\s/)
84
- return scan[0][0].to_s
85
- end
86
- end
87
- ""
88
- end
89
-
90
- # The latest tag for a branch of the repository
91
- def latest_tag(branch)
92
- return `git describe --abbrev=0`.strip if checkout_local_clone_directory_branch(branch)
93
-
94
- ""
95
- end
96
-
97
- private def local_clone_directory
98
- clone_dir = "#{Environment.get_dev_dir("clone")}/#{relative_path}"
99
- end
100
-
101
- public def update_local_clone_directory
102
- if Dir.exist?(local_clone_directory)
103
- Dir.chdir(local_clone_directory) do
104
- pull = Raykit::Command.new("git pull")
105
- pull.run
106
- pull
107
- # t = `git pull`
108
- end
109
- else
110
- PROJECT.run("git clone #{@url} #{local_clone_directory}")
111
- end
112
- end
113
-
114
- private def checkout_local_clone_directory_branch(branch)
115
- update_local_clone_directory
116
- if Dir.exist?(local_clone_directory)
117
- Dir.chdir(local_clone_directory) do
118
- check = `git branch`
119
- t = `git checkout #{branch}` unless check.include?("* #{branch}")
120
- check = `git branch`
121
- return check.include?("* #{branch}")
122
- end
123
- end
124
- false
125
- end
126
-
127
- def clobber
128
- ["work", "clone", "make"].each { |d|
129
- dir = get_dev_dir(d)
130
- if (Dir.exist?(dir))
131
- begin
132
- puts " deleting #{dir}"
133
- FileUtils.rm_rf(dir)
134
- FileUtils.rm(dir) if (Dir.exist?(dir))
135
- rescue
136
- puts " problem while deleting #{dir}"
137
- end
138
- end
139
- }
140
- end
141
-
142
- def pull
143
- Raykit::Git::Repository::work_pull(url)
144
- update_local_clone_directory
145
- end
146
-
147
- def work(command, force = false)
148
- pull if (!Dir.exist?(get_dev_dir("work")))
149
- fcommand = Raykit::FileSystem::replace_invalid_chars(command)
150
- filename = "#{Raykit::Environment::log_dir}/work_#{fcommand}_#{relative_path.gsub("/", "-")}.json"
151
- if (Raykit::Git::Directory.new(get_dev_dir("work")).outstanding_commit? || force)
152
- puts " outstanding commit in #{get_dev_dir("work")}"
153
- work_cmd = Raykit::Git::Repository::work_url(url, command)
154
- work_cmd.save_as(filename)
155
- return work_cmd
156
- else
157
- if (File.exist?(filename))
158
- return Raykit::Command::parse(IO.read(filename))
159
- else
160
- work_cmd = Raykit::Git::Repository::work_url(url, command)
161
- work_cmd.save_as(filename)
162
- end
163
- #
164
- end
165
- end
166
-
167
- def make(command, force = false)
168
- commit_id = "#{latest_commit(default_branch)}"
169
- make_id = "make_#{relative_path.gsub("/", "-")}_#{commit_id}"
170
- fcommand = Raykit::FileSystem::replace_invalid_chars(command)
171
- filename = "#{Raykit::Environment::log_dir}/#{make_id}_#{fcommand}.json"
172
- if (!force && File.exist?(filename))
173
- return Raykit::Command::parse(IO.read(filename))
174
- else
175
- make_cmd = Raykit::Git::Repository::make_url(url, commit_id, "rake default")
176
- make_cmd.save_as(filename)
177
- return make_cmd
178
- end
179
- end
180
-
181
- def self.work_pull(url)
182
- repo = Raykit::Git::Repository.new(url)
183
- work_dir = repo.get_dev_dir("work")
184
- repo.clone(work_dir) if !Dir.exist?(work_dir)
185
- Dir.chdir(work_dir) do
186
- run("git pull")
187
- end
188
- end
189
-
190
- def self.work_integrate(url)
191
- repo = Raykit::Git::Repository.new(url)
192
- work_dir = repo.get_dev_dir("work")
193
- repo.clone(work_dir) if !Dir.exist?(work_dir)
194
- Dir.chdir(work_dir) do
195
- run("git pull")
196
- run("rake integrate")
197
- end
198
- end
199
-
200
- def self.work_url(url, cmd)
201
- repo = Raykit::Git::Repository.new(url)
202
- puts " work #{url} #{cmd}"
203
- work_dir = repo.get_dev_dir("work")
204
- repo.clone(work_dir) if !Dir.exist?(work_dir)
205
- Dir.chdir(work_dir) do
206
- run("git pull")
207
- cmd = Raykit::Command.new(cmd)
208
- cmd = cmd.run().summary()
209
- cmd
210
- end
211
- end
212
-
213
- def self.make_url(url, commit_id, command)
214
- repo = Raykit::Git::Repository.new(url)
215
- puts " make #{url} #{commit_id} #{command}"
216
- make_dir = Raykit::Environment::normalize_path(repo.get_dev_dir("make") + "/" + commit_id)
217
- FileUtils.mkdir_p(repo.get_dev_dir("make")) if !Dir.exist?(repo.get_dev_dir("make"))
218
- if (Dir.exist?(make_dir))
219
- FileUtils.rm_rf(make_dir)
220
- end
221
- run("git clone #{url} #{make_dir}")
222
- cmd = 0
223
- Dir.chdir(make_dir) do
224
- run("git reset --hard #{commit_id}")
225
- FileUtils.rm_rf(".git")
226
- cmd = Raykit::Command.new(command)
227
- cmd = cmd.run().summary()
228
- end
229
- FileUtils.rm_rf(make_dir) if (cmd.exitstatus == 0)
230
- cmd
231
- end
232
-
233
- def self.backup(url, backup_dir)
234
- if (Dir.exist?(backup_dir))
235
- Dir.chdir(backup_dir) do
236
- run("git pull")
237
- end
238
- else
239
- run("git clone #{url} \"#{backup_dir}\"")
240
- end
241
- end
242
- end
243
- end
244
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Raykit
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
10
+
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
16
+
17
+ def short_name()
18
+ @url.split("/").last.gsub(".git", "")
19
+ end
20
+
21
+ def to_json(*_args)
22
+ JSON.generate({ "url" => @url })
23
+ end
24
+
25
+ def self.parse(json)
26
+ hash = JSON.parse(json)
27
+ Repository.new(hash["url"])
28
+ end
29
+
30
+ # The relative path is a valid local path name derived from the url
31
+ def relative_path
32
+ @url.gsub("https://", "").gsub(".git", "").gsub("http://", "")
33
+ end
34
+
35
+ def get_dev_dir(dir)
36
+ dev_dir = Environment.get_dev_dir(dir)
37
+ Raykit::Environment::normalize_path("#{dev_dir}/#{relative_path}")
38
+ end
39
+
40
+ # Clone the repository to a specific directory
41
+ def clone(directory, depth = 0)
42
+ if depth.zero?
43
+ PROJECT.run("git clone #{@url} #{directory}")
44
+ else
45
+ PROJECT.run("git clone #{@url} #{directory} --depth #{depth}")
46
+ end
47
+ end
48
+
49
+ # default branch
50
+ def default_branch
51
+ update_local_clone_directory
52
+ if Dir.exist?(local_clone_directory)
53
+ Dir.chdir(local_clone_directory) do
54
+ # refs/remotes/origin/master
55
+ default_branch = `git symbolic-ref refs/remotes/origin/HEAD`.split("/").last.strip
56
+ return default_branch
57
+ end
58
+ end
59
+ "main"
60
+ end
61
+
62
+ # The branches for the git repository
63
+ def branches
64
+ results = []
65
+ update_local_clone_directory
66
+ if Dir.exist?(local_clone_directory)
67
+ Dir.chdir(local_clone_directory) do
68
+ `git branch`.split('\n').each do |line|
69
+ branch = line.gsub("*", "").strip
70
+ results.insert(-1, branch) if branch.length.positive?
71
+ end
72
+ end
73
+ end
74
+ results
75
+ end
76
+
77
+ # The latest commit id for a branch of the repostiory
78
+ def latest_commit(branch)
79
+ if checkout_local_clone_directory_branch(branch)
80
+ update_local_clone_directory
81
+ Dir.chdir(local_clone_directory) do
82
+ text = `git log -n 1`
83
+ scan = text.scan(/commit (\w+)\s/)
84
+ return scan[0][0].to_s
85
+ end
86
+ end
87
+ ""
88
+ end
89
+
90
+ # The latest tag for a branch of the repository
91
+ def latest_tag(branch)
92
+ return `git describe --abbrev=0`.strip if checkout_local_clone_directory_branch(branch)
93
+
94
+ ""
95
+ end
96
+
97
+ private def local_clone_directory
98
+ clone_dir = "#{Environment.get_dev_dir("clone")}/#{relative_path}"
99
+ end
100
+
101
+ public def update_local_clone_directory
102
+ if Dir.exist?(local_clone_directory)
103
+ Dir.chdir(local_clone_directory) do
104
+ pull = Raykit::Command.new("git pull")
105
+ pull.run
106
+ pull
107
+ # t = `git pull`
108
+ end
109
+ else
110
+ PROJECT.run("git clone #{@url} #{local_clone_directory}")
111
+ end
112
+ end
113
+
114
+ private def checkout_local_clone_directory_branch(branch)
115
+ update_local_clone_directory
116
+ if Dir.exist?(local_clone_directory)
117
+ Dir.chdir(local_clone_directory) do
118
+ check = `git branch`
119
+ t = `git checkout #{branch}` unless check.include?("* #{branch}")
120
+ check = `git branch`
121
+ return check.include?("* #{branch}")
122
+ end
123
+ end
124
+ false
125
+ end
126
+
127
+ def clobber
128
+ ["work", "clone", "make"].each { |d|
129
+ dir = get_dev_dir(d)
130
+ if (Dir.exist?(dir))
131
+ begin
132
+ puts " deleting #{dir}"
133
+ FileUtils.rm_rf(dir)
134
+ FileUtils.rm(dir) if (Dir.exist?(dir))
135
+ rescue
136
+ puts " problem while deleting #{dir}"
137
+ end
138
+ end
139
+ }
140
+ end
141
+
142
+ def pull
143
+ Raykit::Git::Repository::work_pull(url)
144
+ update_local_clone_directory
145
+ end
146
+
147
+ def work(command, force = false)
148
+ pull if (!Dir.exist?(get_dev_dir("work")))
149
+ fcommand = Raykit::FileSystem::replace_invalid_chars(command)
150
+ filename = "#{Raykit::Environment::log_dir}/work_#{fcommand}_#{relative_path.gsub("/", "-")}.json"
151
+ if (Raykit::Git::Directory.new(get_dev_dir("work")).outstanding_commit? || force)
152
+ puts " outstanding commit in #{get_dev_dir("work")}"
153
+ work_cmd = Raykit::Git::Repository::work_url(url, command)
154
+ work_cmd.save_as(filename)
155
+ return work_cmd
156
+ else
157
+ if (File.exist?(filename))
158
+ return Raykit::Command::parse(IO.read(filename))
159
+ else
160
+ work_cmd = Raykit::Git::Repository::work_url(url, command)
161
+ work_cmd.save_as(filename)
162
+ end
163
+ #
164
+ end
165
+ end
166
+
167
+ def make(command, force = false)
168
+ commit_id = "#{latest_commit(default_branch)}"
169
+ make_id = "make_#{relative_path.gsub("/", "-")}_#{commit_id}"
170
+ fcommand = Raykit::FileSystem::replace_invalid_chars(command)
171
+ filename = "#{Raykit::Environment::log_dir}/#{make_id}_#{fcommand}.json"
172
+ if (!force && File.exist?(filename))
173
+ return Raykit::Command::parse(IO.read(filename))
174
+ else
175
+ make_cmd = Raykit::Git::Repository::make_url(url, commit_id, "rake default")
176
+ make_cmd.save_as(filename)
177
+ return make_cmd
178
+ end
179
+ end
180
+
181
+ def self.work_pull(url)
182
+ repo = Raykit::Git::Repository.new(url)
183
+ work_dir = repo.get_dev_dir("work")
184
+ repo.clone(work_dir) if !Dir.exist?(work_dir)
185
+ Dir.chdir(work_dir) do
186
+ run("git pull")
187
+ end
188
+ end
189
+
190
+ def self.work_integrate(url)
191
+ repo = Raykit::Git::Repository.new(url)
192
+ work_dir = repo.get_dev_dir("work")
193
+ repo.clone(work_dir) if !Dir.exist?(work_dir)
194
+ Dir.chdir(work_dir) do
195
+ run("git pull")
196
+ run("rake integrate")
197
+ end
198
+ end
199
+
200
+ def self.work_url(url, cmd)
201
+ repo = Raykit::Git::Repository.new(url)
202
+ puts " work #{url} #{cmd}"
203
+ work_dir = repo.get_dev_dir("work")
204
+ repo.clone(work_dir) if !Dir.exist?(work_dir)
205
+ Dir.chdir(work_dir) do
206
+ run("git pull")
207
+ cmd = Raykit::Command.new(cmd)
208
+ cmd = cmd.run().summary()
209
+ cmd
210
+ end
211
+ end
212
+
213
+ def self.make_url(url, commit_id, command)
214
+ repo = Raykit::Git::Repository.new(url)
215
+ puts " make #{url} #{commit_id} #{command}"
216
+ make_dir = Raykit::Environment::normalize_path(repo.get_dev_dir("make") + "/" + commit_id)
217
+ FileUtils.mkdir_p(repo.get_dev_dir("make")) if !Dir.exist?(repo.get_dev_dir("make"))
218
+ if (Dir.exist?(make_dir))
219
+ FileUtils.rm_rf(make_dir)
220
+ end
221
+ run("git clone #{url} #{make_dir}")
222
+ cmd = 0
223
+ Dir.chdir(make_dir) do
224
+ run("git reset --hard #{commit_id}")
225
+ FileUtils.rm_rf(".git")
226
+ cmd = Raykit::Command.new(command)
227
+ cmd = cmd.run().summary()
228
+ end
229
+ FileUtils.rm_rf(make_dir) if (cmd.exitstatus == 0)
230
+ cmd
231
+ end
232
+
233
+ def self.backup(url, backup_dir)
234
+ if (Dir.exist?(backup_dir))
235
+ Dir.chdir(backup_dir) do
236
+ run("git pull")
237
+ end
238
+ else
239
+ run("git clone #{url} \"#{backup_dir}\"")
240
+ end
241
+ end
242
+ end
243
+ end
244
+ end