makit 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/makit/apache.rb +32 -32
- data/lib/makit/cli/clean.rb +14 -14
- data/lib/makit/cli/clone.rb +59 -59
- data/lib/makit/cli/init.rb +38 -38
- data/lib/makit/cli/main.rb +33 -33
- data/lib/makit/cli/make.rb +54 -54
- data/lib/makit/cli/new.rb +37 -37
- data/lib/makit/cli/nuget_cache.rb +38 -38
- data/lib/makit/cli/pull.rb +31 -31
- data/lib/makit/cli/setup.rb +71 -71
- data/lib/makit/cli/work.rb +21 -21
- data/lib/makit/command_runner.rb +343 -343
- data/lib/makit/commands.rb +21 -21
- data/lib/makit/content/default_gitignore.rb +5 -5
- data/lib/makit/content/default_rakefile.rb +11 -11
- data/lib/makit/content/gem_rakefile.rb +14 -14
- data/lib/makit/data.rb +50 -50
- data/lib/makit/directories.rb +140 -140
- data/lib/makit/directory.rb +184 -181
- data/lib/makit/dotnet.rb +104 -104
- data/lib/makit/environment.rb +123 -123
- data/lib/makit/fileinfo.rb +16 -16
- data/lib/makit/files.rb +47 -47
- data/lib/makit/git.rb +80 -80
- data/lib/makit/gitlab_runner.rb +60 -60
- data/lib/makit/humanize.rb +112 -112
- data/lib/makit/logging.rb +96 -96
- data/lib/makit/markdown.rb +75 -75
- data/lib/makit/mp/basic_object_mp.rb +16 -16
- data/lib/makit/mp/command_request.mp.rb +16 -16
- data/lib/makit/mp/project_mp.rb +210 -210
- data/lib/makit/mp/string_mp.rb +117 -117
- data/lib/makit/nuget.rb +57 -57
- data/lib/makit/protoc.rb +87 -61
- data/lib/makit/serializer.rb +115 -115
- data/lib/makit/show.rb +65 -0
- data/lib/makit/storage.rb +131 -131
- data/lib/makit/symbols.rb +149 -149
- data/lib/makit/tasks.rb +55 -55
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/makit.v1_pb.rb +3 -4
- data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
- data/lib/makit/version.rb +12 -12
- data/lib/makit/wix.rb +95 -95
- data/lib/makit/zip.rb +17 -17
- data/lib/makit.rb +254 -254
- metadata +4 -3
data/lib/makit/commands.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "English"
|
4
|
-
require "open3"
|
5
|
-
require "socket"
|
6
|
-
require "etc"
|
7
|
-
require "logger"
|
8
|
-
|
9
|
-
# This module provides classes for the Makit gem.
|
10
|
-
module Makit
|
11
|
-
# This class provide methods running commands.
|
12
|
-
#
|
13
|
-
class Commands < Array
|
14
|
-
|
15
|
-
# Generate the commands based on the current directory.
|
16
|
-
def auto_generate
|
17
|
-
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["install"]) if File.exist?("Gemfile")
|
18
|
-
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["exec", "rake"]) if File.exist?("Rakefile")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "English"
|
4
|
+
require "open3"
|
5
|
+
require "socket"
|
6
|
+
require "etc"
|
7
|
+
require "logger"
|
8
|
+
|
9
|
+
# This module provides classes for the Makit gem.
|
10
|
+
module Makit
|
11
|
+
# This class provide methods running commands.
|
12
|
+
#
|
13
|
+
class Commands < Array
|
14
|
+
|
15
|
+
# Generate the commands based on the current directory.
|
16
|
+
def auto_generate
|
17
|
+
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["install"]) if File.exist?("Gemfile")
|
18
|
+
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["exec", "rake"]) if File.exist?("Rakefile")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Makit
|
2
|
-
module Content
|
3
|
-
GITIGNORE = File.read(File.join(__dir__, "default_gitignore.txt"))
|
4
|
-
end # module Content
|
5
|
-
end # module Makit
|
1
|
+
module Makit
|
2
|
+
module Content
|
3
|
+
GITIGNORE = File.read(File.join(__dir__, "default_gitignore.txt"))
|
4
|
+
end # module Content
|
5
|
+
end # module Makit
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module Makit
|
2
|
-
module Content
|
3
|
-
RAKEFILE = <<~HEREDOC
|
4
|
-
require "makit"
|
5
|
-
|
6
|
-
task :default do
|
7
|
-
end
|
8
|
-
|
9
|
-
HEREDOC
|
10
|
-
end # module Content
|
11
|
-
end # module Makit
|
1
|
+
module Makit
|
2
|
+
module Content
|
3
|
+
RAKEFILE = <<~HEREDOC
|
4
|
+
require "makit"
|
5
|
+
|
6
|
+
task :default do
|
7
|
+
end
|
8
|
+
|
9
|
+
HEREDOC
|
10
|
+
end # module Content
|
11
|
+
end # module Makit
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module Makit
|
2
|
-
module Content
|
3
|
-
GEM_RAKEFILE = <<~HEREDOC
|
4
|
-
require "bundler/gem_tasks" # for build, install and release tasks
|
5
|
-
require "minitest/test_task"
|
6
|
-
Minitest::TestTask.create
|
7
|
-
require "makit"
|
8
|
-
|
9
|
-
task :default => [:build, :install] do
|
10
|
-
end
|
11
|
-
|
12
|
-
HEREDOC
|
13
|
-
end # module Content
|
14
|
-
end # module Makit
|
1
|
+
module Makit
|
2
|
+
module Content
|
3
|
+
GEM_RAKEFILE = <<~HEREDOC
|
4
|
+
require "bundler/gem_tasks" # for build, install and release tasks
|
5
|
+
require "minitest/test_task"
|
6
|
+
Minitest::TestTask.create
|
7
|
+
require "makit"
|
8
|
+
|
9
|
+
task :default => [:build, :install] do
|
10
|
+
end
|
11
|
+
|
12
|
+
HEREDOC
|
13
|
+
end # module Content
|
14
|
+
end # module Makit
|
data/lib/makit/data.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "digest"
|
3
|
-
# This module provides classes for the Makit gem.
|
4
|
-
module Makit
|
5
|
-
# This class provide methods for managing persistent data for the makit gem
|
6
|
-
class Data
|
7
|
-
attr_accessor :directory, :use_jsonks
|
8
|
-
|
9
|
-
def initialize(attributes = {})
|
10
|
-
@directory = attributes[:directory] || File.join(Dir.home, ".makit")
|
11
|
-
@use_json = false
|
12
|
-
attributes.each do |key, value|
|
13
|
-
instance_variable_set("@#{key}", value) if self.class.method_defined?("#{key}=")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# remove all data
|
18
|
-
def clear
|
19
|
-
# remove the data directory
|
20
|
-
FileUtils.rm_rf(@directory) if Dir.exist?(@directory)
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_content_id(item)
|
24
|
-
# get the content id for the item
|
25
|
-
bytes_string = item.to_proto.bytes.pack("C*") # Convert the byte array to a string
|
26
|
-
Digest::SHA256.hexdigest(bytes_string)
|
27
|
-
end
|
28
|
-
|
29
|
-
# save the content
|
30
|
-
# data.save_content(git_version)
|
31
|
-
def save(item)
|
32
|
-
content_id = get_content_id(item)
|
33
|
-
# save the content
|
34
|
-
if @use_json
|
35
|
-
# save the content to a json file
|
36
|
-
File.open(File.join(@directory, "#{content_id}.json"), "w") do |file|
|
37
|
-
file.write(item.to_json)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def get_content(content_id)
|
43
|
-
nil
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.gem_db_filename
|
47
|
-
gem_data_directory = File.join(Dir.home, ".makit", "makit.db")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "digest"
|
3
|
+
# This module provides classes for the Makit gem.
|
4
|
+
module Makit
|
5
|
+
# This class provide methods for managing persistent data for the makit gem
|
6
|
+
class Data
|
7
|
+
attr_accessor :directory, :use_jsonks
|
8
|
+
|
9
|
+
def initialize(attributes = {})
|
10
|
+
@directory = attributes[:directory] || File.join(Dir.home, ".makit")
|
11
|
+
@use_json = false
|
12
|
+
attributes.each do |key, value|
|
13
|
+
instance_variable_set("@#{key}", value) if self.class.method_defined?("#{key}=")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# remove all data
|
18
|
+
def clear
|
19
|
+
# remove the data directory
|
20
|
+
FileUtils.rm_rf(@directory) if Dir.exist?(@directory)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_content_id(item)
|
24
|
+
# get the content id for the item
|
25
|
+
bytes_string = item.to_proto.bytes.pack("C*") # Convert the byte array to a string
|
26
|
+
Digest::SHA256.hexdigest(bytes_string)
|
27
|
+
end
|
28
|
+
|
29
|
+
# save the content
|
30
|
+
# data.save_content(git_version)
|
31
|
+
def save(item)
|
32
|
+
content_id = get_content_id(item)
|
33
|
+
# save the content
|
34
|
+
if @use_json
|
35
|
+
# save the content to a json file
|
36
|
+
File.open(File.join(@directory, "#{content_id}.json"), "w") do |file|
|
37
|
+
file.write(item.to_json)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_content(content_id)
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.gem_db_filename
|
47
|
+
gem_data_directory = File.join(Dir.home, ".makit", "makit.db")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/makit/directories.rb
CHANGED
@@ -1,140 +1,140 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "directory"
|
4
|
-
require_relative "environment"
|
5
|
-
require_relative "protoc"
|
6
|
-
require_relative "nuget"
|
7
|
-
require_relative "version"
|
8
|
-
require "rake"
|
9
|
-
|
10
|
-
# This module provides classes for the Makit gem.
|
11
|
-
module Makit
|
12
|
-
# This class provide methods for working with the system Environment.
|
13
|
-
#
|
14
|
-
module Directories
|
15
|
-
ROOT = File.join(Dir.home, ".makit")
|
16
|
-
CLONE = File.join(Dir.home, ".makit", "clone")
|
17
|
-
MAKE = File.join(Dir.home, ".makit", "make")
|
18
|
-
LOG = File.join(Dir.home, ".makit", "log")
|
19
|
-
WORK = File.join(Dir.home, ".makit", "work")
|
20
|
-
REPOS = File.join(Dir.home, ".makit", "repos")
|
21
|
-
TEMP = File.join(Dir.home, ".makit", "temp")
|
22
|
-
INSTALL = File.join(Dir.home, ".makit", "install")
|
23
|
-
HOME = Makit::Directory.normalize(Dir.home)
|
24
|
-
ONEDRIVE = File.join(Dir.home, "OneDrive")
|
25
|
-
CURRENT = Dir.pwd
|
26
|
-
#Rake.application.init
|
27
|
-
#Rake.application.load_rakefile
|
28
|
-
RAKEDIR = Dir.pwd #File.dirname(Rake.application.rakefile)
|
29
|
-
|
30
|
-
PROJECT_ROOT = Makit::Directory.find_directory_with_patterns(RAKEDIR, ["Rakefile", "rakefile.rb", ".gitignore"])
|
31
|
-
#PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, "Rakefile")
|
32
|
-
#PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, "rakefile.rb")
|
33
|
-
#PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, ".gitignore")
|
34
|
-
if (PROJECT_ROOT.nil?)
|
35
|
-
PROJECT_ARTIFACTS = nil
|
36
|
-
else
|
37
|
-
PROJECT_ARTIFACTS = File.join(PROJECT_ROOT, "artifacts")
|
38
|
-
end
|
39
|
-
LOCAL_NUGET_SOURCE = File.join(Dir.home, ".makit", "nuget")
|
40
|
-
if Makit::Environment::get_os == "Windows"
|
41
|
-
#NUGET_PACKAGE_CACHE = "#{ENV["USERPROFILE"]}\\.nuget\\packages"
|
42
|
-
NUGET_PACKAGE_CACHE = File.join(HOME, ".nuget", "packages")
|
43
|
-
SERVICES = File.join("C:", "Program Files")
|
44
|
-
else
|
45
|
-
NUGET_PACKAGE_CACHE = Makit::Directory.normalize("#{ENV["HOME"]}/.nuget/packages")
|
46
|
-
if Makit::Environment::get_os == "macOS"
|
47
|
-
SERVICES = "/Library/LaunchDaemons"
|
48
|
-
else
|
49
|
-
SERVICES = "/etc/systemd/system"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
if Makit::NuGet::get_latest_version("Grpc.Tools").nil?
|
53
|
-
puts " warning: Grpc.Tools not found in Nuget cache"
|
54
|
-
else
|
55
|
-
GRPC_TOOLS_PATH = File.join(NUGET_PACKAGE_CACHE, "grpc.tools", Makit::Protoc::get_latest_grpc_tools_version)
|
56
|
-
GRPC_CSHARP_PLUGIN_PATH = Makit::Protoc::find_plugin_path("grpc_csharp_plugin")
|
57
|
-
end
|
58
|
-
|
59
|
-
Dir.mkdir(ROOT) unless Dir.exist?(ROOT)
|
60
|
-
Dir.mkdir(CLONE) unless Dir.exist?(CLONE)
|
61
|
-
Dir.mkdir(MAKE) unless Dir.exist?(MAKE)
|
62
|
-
Dir.mkdir(LOG) unless Dir.exist?(LOG)
|
63
|
-
Dir.mkdir(WORK) unless Dir.exist?(WORK)
|
64
|
-
Dir.mkdir(REPOS) unless Dir.exist?(REPOS)
|
65
|
-
Dir.mkdir(TEMP) unless Dir.exist?(TEMP)
|
66
|
-
Dir.mkdir(INSTALL) unless Dir.exist?(INSTALL)
|
67
|
-
if (!Dir.exist?(LOCAL_NUGET_SOURCE))
|
68
|
-
Dir.mkdir(LOCAL_NUGET_SOURCE)
|
69
|
-
system("dotnet nuget add source #{LOCAL_NUGET_SOURCE} --name local")
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.get_project_path(relative_path)
|
73
|
-
File.join(PROJECT_ROOT, relative_path)
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.get_clone_directory(url)
|
77
|
-
File.join(CLONE, get_relative_directory(url))
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.get_work_directory(url)
|
81
|
-
File.join(WORK, get_relative_directory(url))
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.get_make_directory(url)
|
85
|
-
File.join(MAKE, get_relative_directory(url))
|
86
|
-
end
|
87
|
-
|
88
|
-
def self.get_make_commit_directory(url, commit_id)
|
89
|
-
File.join(MAKE, get_relative_directory(url), commit_id)
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.get_log_directory(url)
|
93
|
-
File.join(LOG, get_relative_directory(url))
|
94
|
-
end
|
95
|
-
def self.get_make_commit_log_filename(url, commit_id)
|
96
|
-
File.join(LOG, get_relative_directory(url), commit_id + ".json")
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.get_relative_directory(url)
|
100
|
-
# if url start with Directories::REPOS, then it is a local repository
|
101
|
-
if url.start_with?(REPOS)
|
102
|
-
return url.gsub(REPOS, "")
|
103
|
-
end
|
104
|
-
url = url.gsub("https://", "").gsub("http://", "")
|
105
|
-
url = url.gsub("gitlab.com", "gitlab")
|
106
|
-
url = url.gsub("github.com", "github")
|
107
|
-
|
108
|
-
# if the url ends with .git, remove it
|
109
|
-
url = url.gsub(".git", "") if url.end_with?(".git")
|
110
|
-
url
|
111
|
-
end
|
112
|
-
|
113
|
-
# show all the directory constants in a nicely formatted table format with the name of the constant and the value
|
114
|
-
def self.show
|
115
|
-
# Array of constant names (symbols)
|
116
|
-
constant_names = [:ROOT, :CLONE, :MAKE, :LOG, :WORK, :REPOS, :TEMP, :INSTALL, :HOME, :ONEDRIVE,
|
117
|
-
:CURRENT, :RAKEDIR,
|
118
|
-
:PROJECT_ROOT, :PROJECT_ARTIFACTS, :LOCAL_NUGET_SOURCE, :NUGET_PACKAGE_CACHE, :SERVICES,
|
119
|
-
:GRPC_TOOLS_PATH, :GRPC_CSHARP_PLUGIN_PATH]
|
120
|
-
|
121
|
-
# Find the length of the longest constant name and add 1
|
122
|
-
max_length = constant_names.map(&:to_s).max_by(&:length).length + 1
|
123
|
-
|
124
|
-
# Iterate through each constant name
|
125
|
-
constant_names.each do |constant_name|
|
126
|
-
begin
|
127
|
-
constant_value = const_get(constant_name) # Fetch the value of the constant
|
128
|
-
if (constant_value != nil && Dir.exist?(constant_value))
|
129
|
-
constant_value = constant_value.colorize(:green)
|
130
|
-
end
|
131
|
-
# Print the constant name right justified to the max_length
|
132
|
-
puts "#{constant_name.to_s.rjust(max_length)} = #{constant_value}"
|
133
|
-
rescue NameError
|
134
|
-
# Handle the case where the constant is not defined
|
135
|
-
puts "#{constant_name.to_s.rjust(max_length)} = [Constant not defined]"
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end # end module Directories
|
140
|
-
end # end module Makit
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "directory"
|
4
|
+
require_relative "environment"
|
5
|
+
require_relative "protoc"
|
6
|
+
require_relative "nuget"
|
7
|
+
require_relative "version"
|
8
|
+
require "rake"
|
9
|
+
|
10
|
+
# This module provides classes for the Makit gem.
|
11
|
+
module Makit
|
12
|
+
# This class provide methods for working with the system Environment.
|
13
|
+
#
|
14
|
+
module Directories
|
15
|
+
ROOT = File.join(Dir.home, ".makit")
|
16
|
+
CLONE = File.join(Dir.home, ".makit", "clone")
|
17
|
+
MAKE = File.join(Dir.home, ".makit", "make")
|
18
|
+
LOG = File.join(Dir.home, ".makit", "log")
|
19
|
+
WORK = File.join(Dir.home, ".makit", "work")
|
20
|
+
REPOS = File.join(Dir.home, ".makit", "repos")
|
21
|
+
TEMP = File.join(Dir.home, ".makit", "temp")
|
22
|
+
INSTALL = File.join(Dir.home, ".makit", "install")
|
23
|
+
HOME = Makit::Directory.normalize(Dir.home)
|
24
|
+
ONEDRIVE = File.join(Dir.home, "OneDrive")
|
25
|
+
CURRENT = Dir.pwd
|
26
|
+
#Rake.application.init
|
27
|
+
#Rake.application.load_rakefile
|
28
|
+
RAKEDIR = Dir.pwd #File.dirname(Rake.application.rakefile)
|
29
|
+
|
30
|
+
PROJECT_ROOT = Makit::Directory.find_directory_with_patterns(RAKEDIR, ["Rakefile", "rakefile.rb", ".gitignore"])
|
31
|
+
#PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, "Rakefile")
|
32
|
+
#PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, "rakefile.rb")
|
33
|
+
#PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, ".gitignore")
|
34
|
+
if (PROJECT_ROOT.nil?)
|
35
|
+
PROJECT_ARTIFACTS = nil
|
36
|
+
else
|
37
|
+
PROJECT_ARTIFACTS = File.join(PROJECT_ROOT, "artifacts")
|
38
|
+
end
|
39
|
+
LOCAL_NUGET_SOURCE = File.join(Dir.home, ".makit", "nuget")
|
40
|
+
if Makit::Environment::get_os == "Windows"
|
41
|
+
#NUGET_PACKAGE_CACHE = "#{ENV["USERPROFILE"]}\\.nuget\\packages"
|
42
|
+
NUGET_PACKAGE_CACHE = File.join(HOME, ".nuget", "packages")
|
43
|
+
SERVICES = File.join("C:", "Program Files")
|
44
|
+
else
|
45
|
+
NUGET_PACKAGE_CACHE = Makit::Directory.normalize("#{ENV["HOME"]}/.nuget/packages")
|
46
|
+
if Makit::Environment::get_os == "macOS"
|
47
|
+
SERVICES = "/Library/LaunchDaemons"
|
48
|
+
else
|
49
|
+
SERVICES = "/etc/systemd/system"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
if Makit::NuGet::get_latest_version("Grpc.Tools").nil?
|
53
|
+
puts " warning: Grpc.Tools not found in Nuget cache"
|
54
|
+
else
|
55
|
+
GRPC_TOOLS_PATH = File.join(NUGET_PACKAGE_CACHE, "grpc.tools", Makit::Protoc::get_latest_grpc_tools_version)
|
56
|
+
GRPC_CSHARP_PLUGIN_PATH = Makit::Protoc::find_plugin_path("grpc_csharp_plugin")
|
57
|
+
end
|
58
|
+
|
59
|
+
Dir.mkdir(ROOT) unless Dir.exist?(ROOT)
|
60
|
+
Dir.mkdir(CLONE) unless Dir.exist?(CLONE)
|
61
|
+
Dir.mkdir(MAKE) unless Dir.exist?(MAKE)
|
62
|
+
Dir.mkdir(LOG) unless Dir.exist?(LOG)
|
63
|
+
Dir.mkdir(WORK) unless Dir.exist?(WORK)
|
64
|
+
Dir.mkdir(REPOS) unless Dir.exist?(REPOS)
|
65
|
+
Dir.mkdir(TEMP) unless Dir.exist?(TEMP)
|
66
|
+
Dir.mkdir(INSTALL) unless Dir.exist?(INSTALL)
|
67
|
+
if (!Dir.exist?(LOCAL_NUGET_SOURCE))
|
68
|
+
Dir.mkdir(LOCAL_NUGET_SOURCE)
|
69
|
+
system("dotnet nuget add source #{LOCAL_NUGET_SOURCE} --name local")
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.get_project_path(relative_path)
|
73
|
+
File.join(PROJECT_ROOT, relative_path)
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.get_clone_directory(url)
|
77
|
+
File.join(CLONE, get_relative_directory(url))
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.get_work_directory(url)
|
81
|
+
File.join(WORK, get_relative_directory(url))
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.get_make_directory(url)
|
85
|
+
File.join(MAKE, get_relative_directory(url))
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.get_make_commit_directory(url, commit_id)
|
89
|
+
File.join(MAKE, get_relative_directory(url), commit_id)
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.get_log_directory(url)
|
93
|
+
File.join(LOG, get_relative_directory(url))
|
94
|
+
end
|
95
|
+
def self.get_make_commit_log_filename(url, commit_id)
|
96
|
+
File.join(LOG, get_relative_directory(url), commit_id + ".json")
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.get_relative_directory(url)
|
100
|
+
# if url start with Directories::REPOS, then it is a local repository
|
101
|
+
if url.start_with?(REPOS)
|
102
|
+
return url.gsub(REPOS, "")
|
103
|
+
end
|
104
|
+
url = url.gsub("https://", "").gsub("http://", "")
|
105
|
+
url = url.gsub("gitlab.com", "gitlab")
|
106
|
+
url = url.gsub("github.com", "github")
|
107
|
+
|
108
|
+
# if the url ends with .git, remove it
|
109
|
+
url = url.gsub(".git", "") if url.end_with?(".git")
|
110
|
+
url
|
111
|
+
end
|
112
|
+
|
113
|
+
# show all the directory constants in a nicely formatted table format with the name of the constant and the value
|
114
|
+
def self.show
|
115
|
+
# Array of constant names (symbols)
|
116
|
+
constant_names = [:ROOT, :CLONE, :MAKE, :LOG, :WORK, :REPOS, :TEMP, :INSTALL, :HOME, :ONEDRIVE,
|
117
|
+
:CURRENT, :RAKEDIR,
|
118
|
+
:PROJECT_ROOT, :PROJECT_ARTIFACTS, :LOCAL_NUGET_SOURCE, :NUGET_PACKAGE_CACHE, :SERVICES,
|
119
|
+
:GRPC_TOOLS_PATH, :GRPC_CSHARP_PLUGIN_PATH]
|
120
|
+
|
121
|
+
# Find the length of the longest constant name and add 1
|
122
|
+
max_length = constant_names.map(&:to_s).max_by(&:length).length + 1
|
123
|
+
|
124
|
+
# Iterate through each constant name
|
125
|
+
constant_names.each do |constant_name|
|
126
|
+
begin
|
127
|
+
constant_value = const_get(constant_name) # Fetch the value of the constant
|
128
|
+
if (constant_value != nil && Dir.exist?(constant_value))
|
129
|
+
constant_value = constant_value.colorize(:green)
|
130
|
+
end
|
131
|
+
# Print the constant name right justified to the max_length
|
132
|
+
puts "#{constant_name.to_s.rjust(max_length)} = #{constant_value}"
|
133
|
+
rescue NameError
|
134
|
+
# Handle the case where the constant is not defined
|
135
|
+
puts "#{constant_name.to_s.rjust(max_length)} = [Constant not defined]"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end # end module Directories
|
140
|
+
end # end module Makit
|