raykit 0.0.497 → 0.0.499
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 +20 -20
- data/bin/raykit +6 -6
- data/lib/raykit/auto_setup.rb +69 -69
- data/lib/raykit/command.rb +371 -341
- data/lib/raykit/conan/buildinfo.rb +69 -69
- data/lib/raykit/conanpackage.rb +49 -49
- data/lib/raykit/configuration.rb +48 -0
- data/lib/raykit/console.rb +281 -272
- 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 -109
- 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 +95 -89
- data/lib/raykit/git/repository.rb +278 -244
- 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 -339
- 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 +74 -74
- data/lib/raykit/sourceImports.rb +43 -43
- data/lib/raykit/string.rb +18 -18
- 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 +4 -3
@@ -1,244 +1,278 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
attr_accessor :
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@
|
19
|
-
end
|
20
|
-
|
21
|
-
def
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
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
|
-
end
|
126
|
-
|
127
|
-
def
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
repo
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
Dir.
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
if
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
|
244
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
module Raykit
|
5
|
+
module Git
|
6
|
+
# Functionality to manage a remote git repository
|
7
|
+
class Repository
|
8
|
+
# The url of the remote repository
|
9
|
+
attr_accessor :url
|
10
|
+
attr_accessor :clone_directory, :work_directory
|
11
|
+
|
12
|
+
def initialize(url)
|
13
|
+
if (url.nil? || url.empty?)
|
14
|
+
raise "Raykit::Git::Repository::initialize(url), url is nil or empty!"
|
15
|
+
end
|
16
|
+
@url = url
|
17
|
+
@clone_directory = Raykit::Git::Directory.new(get_dev_dir("clone"))
|
18
|
+
@work_directory = Raykit::Git::Directory.new(get_dev_dir("work"))
|
19
|
+
end
|
20
|
+
|
21
|
+
def short_name()
|
22
|
+
@url.split("/").last.gsub(".git", "")
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_json(*_args)
|
26
|
+
JSON.generate({ "url" => @url })
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.parse(json)
|
30
|
+
hash = JSON.parse(json)
|
31
|
+
Repository.new(hash["url"])
|
32
|
+
end
|
33
|
+
|
34
|
+
# The relative path is a valid local path name derived from the url
|
35
|
+
def relative_path
|
36
|
+
Repository::get_relative_path(@url)
|
37
|
+
#@url.gsub("https://", "").gsub(".git", "").gsub("http://", "")
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.get_relative_path(url)
|
41
|
+
uri = URI.parse(url)
|
42
|
+
|
43
|
+
# Remove top-level domain (e.g., ".com")
|
44
|
+
if (uri.host.nil?)
|
45
|
+
puts "uri.host is nil for #{url}"
|
46
|
+
end
|
47
|
+
host = uri.host.split(".")[0]
|
48
|
+
#host.pop # remove the last element which should be the top-level domain
|
49
|
+
#host = host.join(".")
|
50
|
+
|
51
|
+
# Remove scheme (e.g., "http" or "https")
|
52
|
+
path = host + uri.path
|
53
|
+
|
54
|
+
# Remove top-level domain (e.g., ".com")
|
55
|
+
#path = path.split(".")
|
56
|
+
#path.pop # remove the last element which should be the top-level domain
|
57
|
+
#path = path.join(".")
|
58
|
+
|
59
|
+
# Remove trailing ".git" if present
|
60
|
+
path = path.chomp(".git")
|
61
|
+
|
62
|
+
path
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_dev_dir(dir)
|
66
|
+
dev_dir = Environment.get_dev_dir(dir)
|
67
|
+
Raykit::Environment::normalize_path("#{dev_dir}/#{relative_path}")
|
68
|
+
end
|
69
|
+
|
70
|
+
# Clone the repository to a specific directory
|
71
|
+
def clone(directory, depth = 0)
|
72
|
+
if depth.zero?
|
73
|
+
PROJECT.run("git clone #{@url} #{directory}")
|
74
|
+
else
|
75
|
+
PROJECT.run("git clone #{@url} #{directory} --depth #{depth}")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# default branch
|
80
|
+
def default_branch
|
81
|
+
update_local_clone_directory
|
82
|
+
if Dir.exist?(local_clone_directory)
|
83
|
+
Dir.chdir(local_clone_directory) do
|
84
|
+
# refs/remotes/origin/master
|
85
|
+
default_branch = `git symbolic-ref refs/remotes/origin/HEAD`.split("/").last.strip
|
86
|
+
return default_branch
|
87
|
+
end
|
88
|
+
end
|
89
|
+
"main"
|
90
|
+
end
|
91
|
+
|
92
|
+
# The branches for the git repository
|
93
|
+
def branches
|
94
|
+
results = []
|
95
|
+
update_local_clone_directory
|
96
|
+
if Dir.exist?(local_clone_directory)
|
97
|
+
Dir.chdir(local_clone_directory) do
|
98
|
+
`git branch`.split('\n').each do |line|
|
99
|
+
branch = line.gsub("*", "").strip
|
100
|
+
results.insert(-1, branch) if branch.length.positive?
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
results
|
105
|
+
end
|
106
|
+
|
107
|
+
# The latest commit id for a branch of the repostiory
|
108
|
+
def latest_commit(branch)
|
109
|
+
if checkout_local_clone_directory_branch(branch)
|
110
|
+
update_local_clone_directory
|
111
|
+
Dir.chdir(local_clone_directory) do
|
112
|
+
text = `git log -n 1`
|
113
|
+
scan = text.scan(/commit (\w+)\s/)
|
114
|
+
return scan[0][0].to_s
|
115
|
+
end
|
116
|
+
end
|
117
|
+
""
|
118
|
+
end
|
119
|
+
|
120
|
+
# The latest tag for a branch of the repository
|
121
|
+
def latest_tag(branch)
|
122
|
+
return `git describe --abbrev=0`.strip if checkout_local_clone_directory_branch(branch)
|
123
|
+
|
124
|
+
""
|
125
|
+
end
|
126
|
+
|
127
|
+
private def local_clone_directory
|
128
|
+
clone_dir = "#{Environment.get_dev_dir("clone")}/#{relative_path}"
|
129
|
+
end
|
130
|
+
|
131
|
+
public def update_local_clone_directory
|
132
|
+
if Dir.exist?(local_clone_directory)
|
133
|
+
Dir.chdir(local_clone_directory) do
|
134
|
+
pull = Raykit::Command.new("git pull")
|
135
|
+
pull.run
|
136
|
+
pull
|
137
|
+
# t = `git pull`
|
138
|
+
end
|
139
|
+
else
|
140
|
+
PROJECT.run("git clone #{@url} #{local_clone_directory}")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
private def checkout_local_clone_directory_branch(branch)
|
145
|
+
update_local_clone_directory
|
146
|
+
if Dir.exist?(local_clone_directory)
|
147
|
+
Dir.chdir(local_clone_directory) do
|
148
|
+
check = `git branch`
|
149
|
+
t = `git checkout #{branch}` unless check.include?("* #{branch}")
|
150
|
+
check = `git branch`
|
151
|
+
return check.include?("* #{branch}")
|
152
|
+
end
|
153
|
+
end
|
154
|
+
false
|
155
|
+
end
|
156
|
+
|
157
|
+
def clobber
|
158
|
+
["work", "clone", "make"].each { |d|
|
159
|
+
dir = get_dev_dir(d)
|
160
|
+
if (Dir.exist?(dir))
|
161
|
+
begin
|
162
|
+
puts " deleting #{dir}"
|
163
|
+
FileUtils.rm_rf(dir)
|
164
|
+
FileUtils.rm(dir) if (Dir.exist?(dir))
|
165
|
+
rescue
|
166
|
+
puts " problem while deleting #{dir}"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
}
|
170
|
+
end
|
171
|
+
|
172
|
+
def pull
|
173
|
+
Raykit::Git::Repository::work_pull(url)
|
174
|
+
update_local_clone_directory
|
175
|
+
end
|
176
|
+
|
177
|
+
def work(command, force = false)
|
178
|
+
pull if (!Dir.exist?(get_dev_dir("work")))
|
179
|
+
fcommand = Raykit::FileSystem::replace_invalid_chars(command)
|
180
|
+
filename = "#{Raykit::Environment::log_dir}/work_#{fcommand}_#{relative_path.gsub("/", "-")}.json"
|
181
|
+
if (Raykit::Git::Directory.new(get_dev_dir("work")).outstanding_commit? || force)
|
182
|
+
puts " outstanding commit in #{get_dev_dir("work")}"
|
183
|
+
work_cmd = Raykit::Git::Repository::work_url(url, command)
|
184
|
+
work_cmd.save_as(filename)
|
185
|
+
return work_cmd
|
186
|
+
else
|
187
|
+
if (File.exist?(filename))
|
188
|
+
return Raykit::Command::parse(IO.read(filename))
|
189
|
+
else
|
190
|
+
work_cmd = Raykit::Git::Repository::work_url(url, command)
|
191
|
+
work_cmd.save_as(filename)
|
192
|
+
end
|
193
|
+
#
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def make(command, force = false)
|
198
|
+
commit_id = "#{latest_commit(default_branch)}"
|
199
|
+
make_id = "make_#{relative_path.gsub("/", "-")}_#{commit_id}"
|
200
|
+
fcommand = Raykit::FileSystem::replace_invalid_chars(command)
|
201
|
+
filename = "#{Raykit::Environment::log_dir}/#{make_id}_#{fcommand}.json"
|
202
|
+
if (!force && File.exist?(filename))
|
203
|
+
return Raykit::Command::parse(IO.read(filename))
|
204
|
+
else
|
205
|
+
make_cmd = Raykit::Git::Repository::make_url(url, commit_id, "rake default")
|
206
|
+
make_cmd.save_as(filename)
|
207
|
+
return make_cmd
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.work_pull(url)
|
212
|
+
repo = Raykit::Git::Repository.new(url)
|
213
|
+
work_dir = repo.get_dev_dir("work")
|
214
|
+
repo.clone(work_dir) if !Dir.exist?(work_dir)
|
215
|
+
Dir.chdir(work_dir) do
|
216
|
+
run("git pull")
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.work_integrate(url)
|
221
|
+
repo = Raykit::Git::Repository.new(url)
|
222
|
+
work_dir = repo.get_dev_dir("work")
|
223
|
+
repo.clone(work_dir) if !Dir.exist?(work_dir)
|
224
|
+
Dir.chdir(work_dir) do
|
225
|
+
run("git pull")
|
226
|
+
run("rake integrate")
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def self.work_url(url, cmd)
|
231
|
+
repo = Raykit::Git::Repository.new(url)
|
232
|
+
puts " work #{url} #{cmd}"
|
233
|
+
work_dir = repo.get_dev_dir("work")
|
234
|
+
repo.clone(work_dir) if !Dir.exist?(work_dir)
|
235
|
+
Dir.chdir(work_dir) do
|
236
|
+
run("git pull")
|
237
|
+
cmd = Raykit::Command.new(cmd)
|
238
|
+
cmd = cmd.run().summary()
|
239
|
+
cmd
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def self.make_url(url, commit_id, command)
|
244
|
+
repo = Raykit::Git::Repository.new(url)
|
245
|
+
puts " make #{url} #{commit_id} #{command}"
|
246
|
+
make_dir = Raykit::Environment::normalize_path(repo.get_dev_dir("make") + "/" + commit_id)
|
247
|
+
FileUtils.mkdir_p(repo.get_dev_dir("make")) if !Dir.exist?(repo.get_dev_dir("make"))
|
248
|
+
if (Dir.exist?(make_dir))
|
249
|
+
FileUtils.rm_rf(make_dir)
|
250
|
+
end
|
251
|
+
run("git clone #{url} #{make_dir}")
|
252
|
+
cmd = 0
|
253
|
+
Dir.chdir(make_dir) do
|
254
|
+
run("git reset --hard #{commit_id}")
|
255
|
+
FileUtils.rm_rf(".git")
|
256
|
+
cmd = Raykit::Command.new(command)
|
257
|
+
cmd = cmd.run().summary()
|
258
|
+
end
|
259
|
+
FileUtils.rm_rf(make_dir) if (cmd.exitstatus == 0)
|
260
|
+
cmd
|
261
|
+
end
|
262
|
+
|
263
|
+
def self.backup(url, backup_dir)
|
264
|
+
if (Dir.exist?(backup_dir))
|
265
|
+
Dir.chdir(backup_dir) do
|
266
|
+
run("git pull")
|
267
|
+
end
|
268
|
+
else
|
269
|
+
run("git clone #{url} \"#{backup_dir}\"")
|
270
|
+
end
|
271
|
+
end # def self.backup
|
272
|
+
|
273
|
+
def to_s
|
274
|
+
"Name: #{short_name}\nUrl: #{@url}\nRelative Path: #{relative_path}"
|
275
|
+
end # def to_s
|
276
|
+
end # class Repository
|
277
|
+
end # module Git
|
278
|
+
end # module Raykit
|
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
|