makit 0.0.1 → 0.0.3
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 +318 -237
- 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 +153 -120
- data/lib/makit/dotnet.rb +83 -75
- data/lib/makit/environment.rb +123 -123
- data/lib/makit/files.rb +47 -47
- data/lib/makit/git.rb +66 -66
- data/lib/makit/gitlab_runner.rb +60 -60
- data/lib/makit/humanize.rb +89 -89
- 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 +13 -0
- data/lib/makit/mp/project_mp.rb +156 -149
- data/lib/makit/mp/string_mp.rb +107 -101
- data/lib/makit/nuget.rb +57 -57
- data/lib/makit/protoc.rb +61 -61
- data/lib/makit/serializer.rb +115 -70
- data/lib/makit/storage.rb +131 -131
- data/lib/makit/symbols.rb +149 -149
- data/lib/makit/tasks.rb +67 -67
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/makit.v1_pb.rb +5 -5
- 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 +243 -243
- metadata +4 -39
- data/.makit.project.json +0 -4
- data/.makit.project.yml +0 -2
- data/.rubocop.yml +0 -22
- data/.ruby-version +0 -1
- data/CHANGELOG.md +0 -8
- data/CODE_OF_CONDUCT.md +0 -84
- data/LICENSE +0 -21
- data/README.md +0 -119
- data/Rakefile +0 -200
- data/docs/Commands.md +0 -50
- data/docs_/Commands.md +0 -166
- data/docs_/Minitest.Timeouts.md +0 -332
- data/examples/protoc/Rakefile +0 -31
- data/examples/rake_default/Rakefile +0 -6
- data/examples/rubygem-foo/.gitkeep +0 -0
- data/examples/rubygem-foo/Rakefile +0 -3
- data/examples/run_mp/Rakefile +0 -8
- data/exe/makit +0 -5
- data/lib/makit/content/default_gitignore.txt +0 -222
- data/lib/makit/content/ruby_gitlab-ci.yml +0 -15
- data/lib/makit/v1/makit.v1.proto +0 -103
- data/makit.generated.sln +0 -30
- data/makit.sln +0 -69
- data/pages/.gitignore +0 -5
- data/pages/404.html +0 -25
- data/pages/Gemfile +0 -33
- data/pages/Gemfile.lock +0 -88
- data/pages/_config.yml +0 -55
- data/pages/_layouts/default.html +0 -1
- data/pages/_posts/2024-10-05-welcome-to-jekyll.markdown +0 -29
- data/pages/about.markdown +0 -18
- data/pages/index.markdown +0 -6
- data/sig/makit.rbs +0 -4
- data/src/ClassLib/Class1.cs +0 -6
- data/src/ClassLib/ClassLib.csproj +0 -13
data/lib/makit/directory.rb
CHANGED
@@ -1,120 +1,153 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "find"
|
4
|
-
require "pathname"
|
5
|
-
#require "gitignore"
|
6
|
-
|
7
|
-
# This module provides classes for the Makit gem.
|
8
|
-
module Makit
|
9
|
-
# This class provide methods for working with Directories/
|
10
|
-
#
|
11
|
-
# Example:
|
12
|
-
#
|
13
|
-
# Makit::Directory.find_directory_with_pattern("/home/user", "*.rb")
|
14
|
-
#
|
15
|
-
class Directory
|
16
|
-
def self.get_line_count(file)
|
17
|
-
line_count = 0
|
18
|
-
File.foreach(file) { line_count += 1 }
|
19
|
-
line_count
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.find_directory_with_patterns(starting_directory, patterns)
|
23
|
-
patterns.each do |pattern|
|
24
|
-
result = find_directory_with_pattern(starting_directory, pattern)
|
25
|
-
if (Dir.exist?(result))
|
26
|
-
return result
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
nil
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.find_directory_with_pattern(starting_directory, pattern)
|
34
|
-
current_directory = File.expand_path(starting_directory)
|
35
|
-
|
36
|
-
loop do
|
37
|
-
return current_directory if contains_pattern?(current_directory, pattern)
|
38
|
-
|
39
|
-
parent_directory = File.dirname(current_directory)
|
40
|
-
break if parent_directory == current_directory # Reached the root directory
|
41
|
-
|
42
|
-
current_directory = parent_directory
|
43
|
-
end
|
44
|
-
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.contains_pattern?(directory, pattern)
|
49
|
-
Dir.foreach(directory) do |entry|
|
50
|
-
next if [".", ".."].include?(entry)
|
51
|
-
return true if File.fnmatch(pattern, entry)
|
52
|
-
end
|
53
|
-
false
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.get_size(directory)
|
57
|
-
total_size = 0
|
58
|
-
|
59
|
-
Find.find(directory) do |file|
|
60
|
-
total_size += File.size(file) if File.file?(file)
|
61
|
-
end
|
62
|
-
|
63
|
-
total_size
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.get_humanized_size(size_in_bytes, precision = 2)
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.zip_source_files(directory_path, zip_file_name)
|
70
|
-
raise ArgumentError, "Directory path cannot be nil" if directory_path.nil?
|
71
|
-
raise ArgumentError, "Zip file name cannot be nil or empty" if zip_file_name.nil? || zip_file_name.strip.empty?
|
72
|
-
|
73
|
-
unless Dir.exist?(directory_path)
|
74
|
-
raise ArgumentError, "Directory '#{directory_path}' does not exist."
|
75
|
-
end
|
76
|
-
|
77
|
-
tracked_files = get_git_tracked_files(directory_path)
|
78
|
-
|
79
|
-
if tracked_files.empty?
|
80
|
-
raise "No tracked files found in the directory."
|
81
|
-
end
|
82
|
-
|
83
|
-
Zip::File.open(zip_file_name, Zip::File::CREATE) do |zipfile|
|
84
|
-
tracked_files.each do |file|
|
85
|
-
full_path = File.join(directory_path, file)
|
86
|
-
if File.exist?(full_path)
|
87
|
-
zipfile.add(file, full_path)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def self.get_git_tracked_files(directory_path)
|
94
|
-
output, status = Open3.capture2("git ls-files", chdir: directory_path)
|
95
|
-
raise "Failed to list git-tracked files" unless status.success?
|
96
|
-
|
97
|
-
output.split("\n")
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "find"
|
4
|
+
require "pathname"
|
5
|
+
#require "gitignore"
|
6
|
+
|
7
|
+
# This module provides classes for the Makit gem.
|
8
|
+
module Makit
|
9
|
+
# This class provide methods for working with Directories/
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
#
|
13
|
+
# Makit::Directory.find_directory_with_pattern("/home/user", "*.rb")
|
14
|
+
#
|
15
|
+
class Directory
|
16
|
+
def self.get_line_count(file)
|
17
|
+
line_count = 0
|
18
|
+
File.foreach(file) { line_count += 1 }
|
19
|
+
line_count
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.find_directory_with_patterns(starting_directory, patterns)
|
23
|
+
patterns.each do |pattern|
|
24
|
+
result = find_directory_with_pattern(starting_directory, pattern)
|
25
|
+
if (Dir.exist?(result))
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.find_directory_with_pattern(starting_directory, pattern)
|
34
|
+
current_directory = File.expand_path(starting_directory)
|
35
|
+
|
36
|
+
loop do
|
37
|
+
return current_directory if contains_pattern?(current_directory, pattern)
|
38
|
+
|
39
|
+
parent_directory = File.dirname(current_directory)
|
40
|
+
break if parent_directory == current_directory # Reached the root directory
|
41
|
+
|
42
|
+
current_directory = parent_directory
|
43
|
+
end
|
44
|
+
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.contains_pattern?(directory, pattern)
|
49
|
+
Dir.foreach(directory) do |entry|
|
50
|
+
next if [".", ".."].include?(entry)
|
51
|
+
return true if File.fnmatch(pattern, entry)
|
52
|
+
end
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.get_size(directory)
|
57
|
+
total_size = 0
|
58
|
+
|
59
|
+
Find.find(directory) do |file|
|
60
|
+
total_size += File.size(file) if File.file?(file)
|
61
|
+
end
|
62
|
+
|
63
|
+
total_size
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.get_humanized_size(size_in_bytes, precision = 2)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.zip_source_files(directory_path, zip_file_name)
|
70
|
+
raise ArgumentError, "Directory path cannot be nil" if directory_path.nil?
|
71
|
+
raise ArgumentError, "Zip file name cannot be nil or empty" if zip_file_name.nil? || zip_file_name.strip.empty?
|
72
|
+
|
73
|
+
unless Dir.exist?(directory_path)
|
74
|
+
raise ArgumentError, "Directory '#{directory_path}' does not exist."
|
75
|
+
end
|
76
|
+
|
77
|
+
tracked_files = get_git_tracked_files(directory_path)
|
78
|
+
|
79
|
+
if tracked_files.empty?
|
80
|
+
raise "No tracked files found in the directory."
|
81
|
+
end
|
82
|
+
|
83
|
+
Zip::File.open(zip_file_name, Zip::File::CREATE) do |zipfile|
|
84
|
+
tracked_files.each do |file|
|
85
|
+
full_path = File.join(directory_path, file)
|
86
|
+
if File.exist?(full_path)
|
87
|
+
zipfile.add(file, full_path)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.get_git_tracked_files(directory_path)
|
94
|
+
output, status = Open3.capture2("git ls-files", chdir: directory_path)
|
95
|
+
raise "Failed to list git-tracked files" unless status.success?
|
96
|
+
|
97
|
+
output.split("\n")
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.get_newest_git_file(directory_path)
|
101
|
+
get_git_tracked_files(directory_path).select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
|
102
|
+
end
|
103
|
+
|
104
|
+
# Normalize the path by removing any leading or trailing slashes
|
105
|
+
# and replacing any backslashes with forward slashes
|
106
|
+
def self.normalize(path)
|
107
|
+
path = path.gsub("\\", "/")
|
108
|
+
#path = path[1..-1] if path.start_with?("/")
|
109
|
+
path = path[0..-2] if path.end_with?("/")
|
110
|
+
path
|
111
|
+
end
|
112
|
+
|
113
|
+
# for a given path, collect all the subdirectories that match a version pattern.
|
114
|
+
# for example 2.57.0, 2.62, or 2.65.0
|
115
|
+
def self.get_version_directories(path)
|
116
|
+
version_directories = []
|
117
|
+
Dir.foreach(path) do |entry|
|
118
|
+
next if [".", ".."].include?(entry)
|
119
|
+
version_directories << entry if entry.match?(/^\d+\.\d+\.\d+$/)
|
120
|
+
end
|
121
|
+
version_directories
|
122
|
+
end
|
123
|
+
|
124
|
+
# for a given path, get the most recent file change date for any file in the directory
|
125
|
+
def self.get_latest_file_change_date(path)
|
126
|
+
# loop over all files in the directory
|
127
|
+
latest_date = nil
|
128
|
+
Find.find(path) do |file|
|
129
|
+
if File.file?(file)
|
130
|
+
date = File.mtime(file)
|
131
|
+
latest_date = date if latest_date.nil? || date > latest_date
|
132
|
+
end
|
133
|
+
end
|
134
|
+
latest_date
|
135
|
+
end
|
136
|
+
|
137
|
+
# for a given path, return the filename of the most recently modified file
|
138
|
+
def self.get_newest_file(path)
|
139
|
+
newest_file = nil
|
140
|
+
latest_date = nil
|
141
|
+
if (Dir.exist?(path))
|
142
|
+
Find.find(path) do |file|
|
143
|
+
if File.file?(file)
|
144
|
+
date = File.mtime(file)
|
145
|
+
latest_date = date if latest_date.nil? || date > latest_date
|
146
|
+
newest_file = file if date == latest_date
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
newest_file
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
data/lib/makit/dotnet.rb
CHANGED
@@ -1,75 +1,83 @@
|
|
1
|
-
module Makit
|
2
|
-
class DotNet
|
3
|
-
def self.is_installed?
|
4
|
-
File.exist?(Makit::Environment.which("dotnet"))
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.version
|
8
|
-
`dotnet --version`
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.new_project(template, name, output)
|
12
|
-
if Dir.exist? output
|
13
|
-
puts " #{output}".colorize(:green) + " exists.".colorize(:grey)
|
14
|
-
#puts "Directory #{output} already exists".colorize(:yellow)
|
15
|
-
else
|
16
|
-
"dotnet new #{template} --name #{name} --output #{output}".run
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.add_package(project_path, package_name)
|
21
|
-
project_content = File.read(project_path)
|
22
|
-
if (!project_content.include?("\"#{package_name}\""))
|
23
|
-
"dotnet add #{project_path} package #{package_name}".run
|
24
|
-
else
|
25
|
-
puts " package ".colorize(:grey) + "#{package_name}".colorize(:yellow) + " is in ".colorize(:grey) + "#{project_path}".colorize(:yellow)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
project_content
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
#puts "
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
project_dir
|
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
|
-
|
1
|
+
module Makit
|
2
|
+
class DotNet
|
3
|
+
def self.is_installed?
|
4
|
+
File.exist?(Makit::Environment.which("dotnet"))
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.version
|
8
|
+
`dotnet --version`
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.new_project(template, name, output)
|
12
|
+
if Dir.exist? output
|
13
|
+
#puts " #{output}".colorize(:green) + " exists.".colorize(:grey)
|
14
|
+
#puts "Directory #{output} already exists".colorize(:yellow)
|
15
|
+
else
|
16
|
+
"dotnet new #{template} --name #{name} --output #{output}".run
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.add_package(project_path, package_name)
|
21
|
+
project_content = File.read(project_path)
|
22
|
+
if (!project_content.include?("\"#{package_name}\""))
|
23
|
+
"dotnet add #{project_path} package #{package_name}".run
|
24
|
+
else
|
25
|
+
#puts " package ".colorize(:grey) + "#{package_name}".colorize(:yellow) + " is in ".colorize(:grey) + "#{project_path}".colorize(:yellow)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.add_reference(project_path, reference_path)
|
30
|
+
project_content = File.read(project_path)
|
31
|
+
if (project_content.include?("<PackageReference Include=\"#{package}\""))
|
32
|
+
#puts " reference ".colorize(:grey) + "#{reference_path}".colorize(:yellow) + " is in ".colorize(:grey) + "#{project_path}".colorize(:yellow)
|
33
|
+
else
|
34
|
+
"dotnet add #{project_path} reference #{reference_path}".run
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.new_solution(name)
|
39
|
+
if File.exist? "#{name}.sln"
|
40
|
+
#puts "Solution #{name}.sln already exists".colorize(:yellow)
|
41
|
+
#puts " #{name}.sln".colorize(:green) + " exists".colorize(:grey)
|
42
|
+
else
|
43
|
+
"dotnet new sln --name #{name}".run
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.build(project_path, configuration = "Release", output = "artifacts")
|
48
|
+
project_dir = File.dirname(project_path)
|
49
|
+
puts "project_dir: #{project_dir}"
|
50
|
+
newest_file = Makit::Directory::get_newest_file(project_dir)
|
51
|
+
command_request = Makit::RUNNER::parse_command_request("dotnet build #{project_path} --configuration #{configuration} --output #{output}")
|
52
|
+
if newest_file.nil?
|
53
|
+
puts "newest_git_file is nil, assigning a default"
|
54
|
+
# assign a timestamp of now
|
55
|
+
newest_file_date = Time.now
|
56
|
+
RUNNER.cache_run(command_request, newest_file_date)
|
57
|
+
else
|
58
|
+
newest_file_date = File.mtime(newest_file)
|
59
|
+
puts "newest file: #{newest_file}"
|
60
|
+
puts "newest file date: #{newest_file_date}"
|
61
|
+
RUNNER.cache_run(command_request, newest_file_date)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.sln_add_projects(sln_name)
|
66
|
+
if !File.exist? "#{sln_name}.sln"
|
67
|
+
raise "Solution #{sln_name}.sln does not exist"
|
68
|
+
else
|
69
|
+
sln_path = "#{sln_name}.sln"
|
70
|
+
sln_content = File.read(sln_path)
|
71
|
+
Dir.glob("#{sln_path}/**/*.csproj").each do |project_path|
|
72
|
+
project_name = File.basename(project_path, ".csproj")
|
73
|
+
if (sln_content.include?("\"#{project_name}\""))
|
74
|
+
puts " #{project_name}".colorize(:green) + " is in ".colorize(:grey) + "#{sln_path}".colorize(:green)
|
75
|
+
#puts "Project #{project_name} already exists in #{sln_path}".colorize(:yellow)
|
76
|
+
else
|
77
|
+
"dotnet sln #{sln_path} add #{project_path}".run
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end # class DotNet
|
83
|
+
end # module Makit
|