makit 0.0.68 → 0.0.70

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/makit/apache.rb +32 -32
  3. data/lib/makit/cli/clean.rb +14 -14
  4. data/lib/makit/cli/clone.rb +59 -59
  5. data/lib/makit/cli/init.rb +38 -38
  6. data/lib/makit/cli/main.rb +33 -33
  7. data/lib/makit/cli/make.rb +54 -54
  8. data/lib/makit/cli/new.rb +37 -37
  9. data/lib/makit/cli/nuget_cache.rb +38 -38
  10. data/lib/makit/cli/pull.rb +31 -31
  11. data/lib/makit/cli/setup.rb +71 -71
  12. data/lib/makit/cli/work.rb +21 -21
  13. data/lib/makit/command_runner.rb +404 -404
  14. data/lib/makit/commands.rb +21 -21
  15. data/lib/makit/content/default_gitignore.rb +5 -5
  16. data/lib/makit/content/default_rakefile.rb +11 -11
  17. data/lib/makit/content/gem_rakefile.rb +14 -14
  18. data/lib/makit/data.rb +50 -50
  19. data/lib/makit/directories.rb +143 -143
  20. data/lib/makit/directory.rb +264 -264
  21. data/lib/makit/docs/files.rb +94 -0
  22. data/lib/makit/docs/rake.rb +101 -0
  23. data/lib/makit/dotnet.rb +182 -182
  24. data/lib/makit/environment.rb +127 -127
  25. data/lib/makit/fileinfo.rb +26 -16
  26. data/lib/makit/files.rb +47 -47
  27. data/lib/makit/git.rb +145 -96
  28. data/lib/makit/gitlab_runner.rb +60 -60
  29. data/lib/makit/humanize.rb +129 -129
  30. data/lib/makit/indexer.rb +56 -56
  31. data/lib/makit/logging.rb +106 -106
  32. data/lib/makit/markdown.rb +75 -75
  33. data/lib/makit/mp/basic_object_mp.rb +16 -16
  34. data/lib/makit/mp/command_mp.rb +13 -0
  35. data/lib/makit/mp/command_request.mp.rb +16 -16
  36. data/lib/makit/mp/project_mp.rb +210 -210
  37. data/lib/makit/mp/string_mp.rb +137 -137
  38. data/lib/makit/nuget.rb +62 -62
  39. data/lib/makit/process.rb +26 -26
  40. data/lib/makit/protoc.rb +104 -104
  41. data/lib/makit/secrets.rb +51 -51
  42. data/lib/makit/serializer.rb +115 -115
  43. data/lib/makit/show.rb +110 -110
  44. data/lib/makit/storage.rb +131 -131
  45. data/lib/makit/symbols.rb +149 -149
  46. data/lib/makit/task_info.rb +79 -0
  47. data/lib/makit/tasks.rb +123 -68
  48. data/lib/makit/tree.rb +37 -37
  49. data/lib/makit/v1/makit.v1_pb.rb +34 -34
  50. data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
  51. data/lib/makit/version.rb +65 -65
  52. data/lib/makit/wix.rb +95 -95
  53. data/lib/makit/yaml.rb +17 -17
  54. data/lib/makit/zip.rb +17 -17
  55. data/lib/makit.rb +267 -267
  56. metadata +7 -5
  57. data/lib/generated/makit/v1/makit.v1_pb.rb +0 -35
  58. data/lib/generated/makit/v1/web/link_pb.rb +0 -20
@@ -1,127 +1,127 @@
1
- # frozen_string_literal: true
2
-
3
- require "sorted_set"
4
- require_relative "directory"
5
- # This module provides classes for the Makit gem.
6
- module Makit
7
- # This class provide methods for working with the system Environment.
8
- #
9
- class Environment
10
- def self.which(name)
11
- return name if File.exist?(name)
12
-
13
- ["", ".exe", ".bat", ".cmd"].each do |ext|
14
- aname = name + ext
15
- return aname if File.exist?(aname)
16
-
17
- ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
18
- apath = "#{path.gsub("\\", "/")}/#{aname}".gsub("//", "/")
19
- return apath if File.exist?(apath)
20
- end
21
- end
22
- ""
23
- end
24
-
25
- def self.constants_hash
26
- constants = {}
27
- # collect all constants that are all uppercase
28
- Object.constants.each { |c| constants[c] = Object.const_get(c) if c == c.upcase } # puts "#{c} = #{Object.const_get(c)}" }
29
- #Object.constants.each { |c| constants[c] = Object.const_get(c)}# puts "#{c} = #{Object.const_get(c)}" }
30
- constants
31
- end
32
-
33
- def self.rake_file_name
34
- caller_locations.each do |location|
35
- return location.absolute_path if location.absolute_path&.end_with?("Rakefile")
36
- end
37
- nil
38
- end
39
-
40
- def self.gem_data_directory
41
- gem_data_directory = File.join(Dir.home, ".makit")
42
- end
43
-
44
- def self.project_root_directory
45
- if !Makit::Environment.rake_file_name.nil?
46
- File.dirname(Makit::Environment.rake_file_name)
47
- else
48
- Makit::Directory.find_directory_with_pattern(File.dirname(__FILE__), "Rakefile")
49
- # lass Directory
50
- # def self.find_directory_with_pattern(starting_directory, pattern)
51
- # nil
52
- end
53
- end
54
-
55
- def self.get_relative_directory(url)
56
- url = url.gsub("https://", "").gsub("http://", "")
57
- url = url.gsub("gitlab.com", "gitlab")
58
- url
59
- end
60
-
61
- def self.get_code_root
62
- # user home directory + "code"
63
- code_root = File.join(Dir.home, "code")
64
- end
65
-
66
- def self.get_work_directory(url)
67
- raise "invalid url" if !url.include? "https://"
68
- url = url.gsub("https://", "").gsub("http://", "")
69
- #url = url.gsub("gitlab.com","gitlab")
70
- url
71
- end
72
-
73
- def self.is_windows?
74
- RbConfig::CONFIG["host_os"] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
75
- end
76
-
77
- def self.is_mac?
78
- RbConfig::CONFIG["host_os"] =~ /darwin/
79
- end
80
-
81
- def self.get_os
82
- case RbConfig::CONFIG["host_os"]
83
- when /linux/
84
- "Linux"
85
- when /darwin/
86
- "macOS"
87
- when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
88
- "Windows"
89
- else
90
- "Unknown"
91
- end
92
- end
93
-
94
- def self.get_runtime_identifier()
95
- os = RbConfig::CONFIG["host_os"]
96
- cpu = RbConfig::CONFIG["host_cpu"]
97
-
98
- case os
99
- when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
100
- os_rid = "win"
101
- when /darwin|mac os/
102
- os_rid = "osx"
103
- when /linux/
104
- os_rid = "linux"
105
- when /solaris|bsd/
106
- os_rid = "unix"
107
- else
108
- raise "Unknown operating system: host_os=#{os}"
109
- end
110
-
111
- case cpu
112
- when /x86_64|amd64|x64/
113
- arch_rid = "x64"
114
- when /i686|i386/
115
- arch_rid = "x86"
116
- #when /arm/
117
- # arch_rid = "arm"
118
- when /aarch64|arm64/
119
- arch_rid = "arm64"
120
- else
121
- raise "Unknown architecture: host_cpu=#{cpu}"
122
- end
123
-
124
- "#{os_rid}-#{arch_rid}"
125
- end
126
- end
127
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "sorted_set"
4
+ require_relative "directory"
5
+ # This module provides classes for the Makit gem.
6
+ module Makit
7
+ # This class provide methods for working with the system Environment.
8
+ #
9
+ class Environment
10
+ def self.which(name)
11
+ return name if File.exist?(name)
12
+
13
+ ["", ".exe", ".bat", ".cmd"].each do |ext|
14
+ aname = name + ext
15
+ return aname if File.exist?(aname)
16
+
17
+ ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
18
+ apath = "#{path.gsub("\\", "/")}/#{aname}".gsub("//", "/")
19
+ return apath if File.exist?(apath)
20
+ end
21
+ end
22
+ ""
23
+ end
24
+
25
+ def self.constants_hash
26
+ constants = {}
27
+ # collect all constants that are all uppercase
28
+ Object.constants.each { |c| constants[c] = Object.const_get(c) if c == c.upcase } # puts "#{c} = #{Object.const_get(c)}" }
29
+ #Object.constants.each { |c| constants[c] = Object.const_get(c)}# puts "#{c} = #{Object.const_get(c)}" }
30
+ constants
31
+ end
32
+
33
+ def self.rake_file_name
34
+ caller_locations.each do |location|
35
+ return location.absolute_path if location.absolute_path&.end_with?("Rakefile")
36
+ end
37
+ nil
38
+ end
39
+
40
+ def self.gem_data_directory
41
+ gem_data_directory = File.join(Dir.home, ".makit")
42
+ end
43
+
44
+ def self.project_root_directory
45
+ if !Makit::Environment.rake_file_name.nil?
46
+ File.dirname(Makit::Environment.rake_file_name)
47
+ else
48
+ Makit::Directory.find_directory_with_pattern(File.dirname(__FILE__), "Rakefile")
49
+ # lass Directory
50
+ # def self.find_directory_with_pattern(starting_directory, pattern)
51
+ # nil
52
+ end
53
+ end
54
+
55
+ def self.get_relative_directory(url)
56
+ url = url.gsub("https://", "").gsub("http://", "")
57
+ url = url.gsub("gitlab.com", "gitlab")
58
+ url
59
+ end
60
+
61
+ def self.get_code_root
62
+ # user home directory + "code"
63
+ code_root = File.join(Dir.home, "code")
64
+ end
65
+
66
+ def self.get_work_directory(url)
67
+ raise "invalid url" if !url.include? "https://"
68
+ url = url.gsub("https://", "").gsub("http://", "")
69
+ #url = url.gsub("gitlab.com","gitlab")
70
+ url
71
+ end
72
+
73
+ def self.is_windows?
74
+ RbConfig::CONFIG["host_os"] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
75
+ end
76
+
77
+ def self.is_mac?
78
+ RbConfig::CONFIG["host_os"] =~ /darwin/
79
+ end
80
+
81
+ def self.get_os
82
+ case RbConfig::CONFIG["host_os"]
83
+ when /linux/
84
+ "Linux"
85
+ when /darwin/
86
+ "macOS"
87
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
88
+ "Windows"
89
+ else
90
+ "Unknown"
91
+ end
92
+ end
93
+
94
+ def self.get_runtime_identifier()
95
+ os = RbConfig::CONFIG["host_os"]
96
+ cpu = RbConfig::CONFIG["host_cpu"]
97
+
98
+ case os
99
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
100
+ os_rid = "win"
101
+ when /darwin|mac os/
102
+ os_rid = "osx"
103
+ when /linux/
104
+ os_rid = "linux"
105
+ when /solaris|bsd/
106
+ os_rid = "unix"
107
+ else
108
+ raise "Unknown operating system: host_os=#{os}"
109
+ end
110
+
111
+ case cpu
112
+ when /x86_64|amd64|x64/
113
+ arch_rid = "x64"
114
+ when /i686|i386/
115
+ arch_rid = "x86"
116
+ #when /arm/
117
+ # arch_rid = "arm"
118
+ when /aarch64|arm64/
119
+ arch_rid = "arm64"
120
+ else
121
+ raise "Unknown architecture: host_cpu=#{cpu}"
122
+ end
123
+
124
+ "#{os_rid}-#{arch_rid}"
125
+ end
126
+ end
127
+ end
@@ -1,16 +1,26 @@
1
- # frozen_string_literal: true
2
-
3
- # This module provides classes for the Makit gem.
4
- module Makit
5
- # This class provide methods for working with the system Environment.
6
- #
7
- class FileInfo
8
- attr_accessor :name, :mtime, :size
9
-
10
- def initialize(name:, mtime:, size:)
11
- @name = name
12
- @mtime = mtime
13
- @size = size
14
- end
15
- end
16
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module provides classes for the Makit gem.
4
+ module Makit
5
+ # This class provide methods for working with the system Environment.
6
+ #
7
+ class FileInfo
8
+ attr_accessor :name, :mtime, :size
9
+
10
+ def initialize(name:, mtime:, size:)
11
+ @name = name
12
+ @mtime = mtime
13
+ @size = size
14
+ end
15
+
16
+ def self.get_file_infos(filenames)
17
+ filenames.map do |filename|
18
+ begin
19
+ FileInfo.new(name: filename, mtime: File.mtime(filename), size: File.size(filename))
20
+ rescue
21
+ next
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
data/lib/makit/files.rb CHANGED
@@ -1,47 +1,47 @@
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 Files
15
- if (Makit::Directories::PROJECT_ROOT != nil)
16
- Dir.chdir(Makit::Directories::PROJECT_ROOT) do
17
- CSPROJ = Dir.glob("**/*.csproj")
18
- end
19
- else
20
- CSPROJ = Array.new
21
- end
22
-
23
- # show all the files constants in a nicely formatted table format with the name of the constant and the value
24
- def self.show
25
- # Array of constant names (symbols)
26
- constant_names = [:CSPROJ]
27
-
28
- # Find the length of the longest constant name and add 1
29
- max_length = constant_names.map(&:to_s).max_by(&:length).length + 1
30
-
31
- # Iterate through each constant name
32
- constant_names.each do |constant_name|
33
- begin
34
- constant_value = const_get(constant_name) # Fetch the value of the constant
35
- if (constant_value != nil && File.exist?(constant_value))
36
- constant_value = constant_value.colorize(:green)
37
- end
38
- # Print the constant name right justified to the max_length
39
- puts "#{constant_name.to_s.rjust(max_length)} = #{constant_value}"
40
- rescue NameError
41
- # Handle the case where the constant is not defined
42
- puts "#{constant_name.to_s.rjust(max_length)} = [Constant not defined]"
43
- end
44
- end
45
- end
46
- end # module Files
47
- 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 Files
15
+ if (Makit::Directories::PROJECT_ROOT != nil)
16
+ Dir.chdir(Makit::Directories::PROJECT_ROOT) do
17
+ CSPROJ = Dir.glob("**/*.csproj")
18
+ end
19
+ else
20
+ CSPROJ = Array.new
21
+ end
22
+
23
+ # show all the files constants in a nicely formatted table format with the name of the constant and the value
24
+ def self.show
25
+ # Array of constant names (symbols)
26
+ constant_names = [:CSPROJ]
27
+
28
+ # Find the length of the longest constant name and add 1
29
+ max_length = constant_names.map(&:to_s).max_by(&:length).length + 1
30
+
31
+ # Iterate through each constant name
32
+ constant_names.each do |constant_name|
33
+ begin
34
+ constant_value = const_get(constant_name) # Fetch the value of the constant
35
+ if (constant_value != nil && File.exist?(constant_value))
36
+ constant_value = constant_value.colorize(:green)
37
+ end
38
+ # Print the constant name right justified to the max_length
39
+ puts "#{constant_name.to_s.rjust(max_length)} = #{constant_value}"
40
+ rescue NameError
41
+ # Handle the case where the constant is not defined
42
+ puts "#{constant_name.to_s.rjust(max_length)} = [Constant not defined]"
43
+ end
44
+ end
45
+ end
46
+ end # module Files
47
+ end # module Makit
data/lib/makit/git.rb CHANGED
@@ -1,96 +1,145 @@
1
- # frozen_string_literal: true
2
-
3
- # This module provides classes for the Makit gem.
4
- module Makit
5
- # This class provide methods for working with the system Environment.
6
- #
7
- class Git
8
- def self.is_git_repo
9
- Dir.exist? ".git"
10
- end
11
-
12
- def self.detached
13
- `git status`.include?("detached")
14
- end
15
-
16
- def self.is_read_only
17
- !is_git_repo || detached
18
- end
19
-
20
- def self.is_clean
21
- `git status --porcelain`.empty?
22
- end
23
-
24
- def self.integrate
25
- if is_git_repo && !detached
26
- "git add .".run
27
- "git commit -m \"integrate\"".run unless is_clean
28
- end
29
- end
30
-
31
- def self.sync
32
- if is_git_repo && !detached
33
- "git pull".try
34
- "git push origin".try
35
- "git push origin --tags".try
36
- end
37
- end
38
-
39
- def self.pull
40
- if is_git_repo && !detached
41
- "git pull".try
42
- end
43
- end
44
-
45
- def self.zip_source_files(zipfilename)
46
- "git archive --format zip --output #{zipfilename} HEAD".run
47
- end
48
-
49
- def self.get_file_infos()
50
- file_infos = []
51
- command = `git ls-files`
52
- command.split("\n").map do |path|
53
- begin
54
- file_infos << FileInfo.new(name: path, mtime: File.mtime(path), size: File.size(path))
55
- rescue
56
- next
57
- end
58
- end
59
- file_infos.sort_by! { |info| info.mtime }.reverse!
60
- file_infos
61
- end
62
-
63
- def self.branch
64
- `git branch --show-current`.strip
65
- end
66
-
67
- def self.commitsha
68
- `git rev-parse HEAD`.strip
69
- end
70
-
71
- def self.commitmsg
72
- `git log -1 --pretty=%B`.strip
73
- end
74
-
75
- def self.commitdate
76
- `git log -1 --pretty=%cd`.strip
77
- end
78
-
79
- def self.commitauthor
80
- `git log -1 --pretty=%an`.strip
81
- end
82
-
83
- def self.commitemail
84
- `git log -1 --pretty=%ae`.strip
85
- end
86
-
87
- def self.tag(version)
88
- # check if a tag for the current version already exists
89
- if (`git tag -l v#{version}`.strip.length > 0)
90
- puts " tag v#{version} already exists".colorize(:red)
91
- else
92
- "git tag -a v#{version} -m \"version #{version}\"".run
93
- end
94
- end
95
- end
96
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module provides classes for the Makit gem.
4
+ module Makit
5
+ # This class provide methods for working with the system Environment.
6
+ #
7
+ class Git
8
+ def self.is_git_repo
9
+ Dir.exist? ".git"
10
+ end
11
+
12
+ def self.is_ci
13
+ ENV["CI"] == "true"
14
+ end
15
+
16
+ def self.detached
17
+ `git status`.include?("detached")
18
+ end
19
+
20
+ def self.is_read_only
21
+ !is_git_repo || detached
22
+ end
23
+
24
+ def self.is_clean
25
+ `git status --porcelain`.empty?
26
+ end
27
+
28
+ def self.unstaged_files
29
+ `git status --porcelain`.split("\n")
30
+ end
31
+
32
+ def self.untracked_files
33
+ `git ls-files --others --exclude-standard`.split("\n")
34
+ end
35
+
36
+ def self.integrate
37
+ if is_git_repo && !detached
38
+ ## check for unstaged or untracked files
39
+ unstaged_files = `git status --porcelain`.split("\n")
40
+ untracked_files = `git ls-files --others --exclude-standard`.split("\n")
41
+ if unstaged_files.length > 0 || untracked_files.length > 0
42
+ "git add .".run
43
+ "git commit -m \"integrate\"".run unless is_clean
44
+ end
45
+ end
46
+ end
47
+
48
+ def self.sync
49
+ if is_git_repo && !detached
50
+ "git pull".try
51
+ "git push origin".try
52
+ "git push origin --tags".try
53
+ end
54
+ end
55
+
56
+ def self.pull
57
+ if is_git_repo && !detached
58
+ "git pull".try
59
+ end
60
+ end
61
+
62
+ def self.zip_source_files(zipfilename)
63
+ "git archive --format zip --output #{zipfilename} HEAD".run
64
+ end
65
+
66
+ def self.get_file_infos
67
+ file_infos = []
68
+ file_list = `git ls-files`.split("\n")
69
+ # iterate over the filelist and get the file infos
70
+ file_list.each do |file|
71
+ begin
72
+ file_infos << FileInfo.new(name: file, mtime: File.mtime(file), size: File.size(file))
73
+ rescue
74
+ next
75
+ end
76
+ end
77
+ file_infos.sort_by! { |info| info.mtime }.reverse!
78
+ file_infos
79
+ end
80
+
81
+ def self.get_untracked_file_infos
82
+ #Makit::FileInfo::get_file_infos(`git ls-files --others --exclude=standard`.split("\n")).sort_by! { |info| info.mtime }.reverse!
83
+ file_infos = []
84
+ file_list = `git ls-files --others --exclude=standard`.split("\n")
85
+ file_list.each do |file|
86
+ begin
87
+ file_infos << FileInfo.new(name: file, mtime: File.mtime(file), size: File.size(file))
88
+ rescue
89
+ next
90
+ end
91
+ end
92
+ file_infos.sort_by! { |info| info.mtime }.reverse!
93
+ file_infos
94
+ # file_infos << FileInfo.new(name: path, mtime: File.mtime(path), size: File.size(path))
95
+ # rescue
96
+ # next
97
+ #ß end
98
+ #end
99
+ #file_infos.sort_by! { |info| info.mtime }.reverse!
100
+ #file_infos
101
+ end
102
+
103
+ def self.branch
104
+ `git branch --show-current`.strip
105
+ end
106
+
107
+ def self.commitsha
108
+ `git rev-parse HEAD`.strip
109
+ end
110
+
111
+ def self.commitmsg
112
+ `git log -1 --pretty=%B`.strip
113
+ end
114
+
115
+ def self.commitdate
116
+ `git log -1 --pretty=%cd`.strip
117
+ end
118
+
119
+ def self.commitauthor
120
+ `git log -1 --pretty=%an`.strip
121
+ end
122
+
123
+ def self.commitemail
124
+ `git log -1 --pretty=%ae`.strip
125
+ end
126
+
127
+ def self.get_remote_url
128
+ `git remote get-url origin`.strip
129
+ end
130
+
131
+ def self.tag(version)
132
+ # only tag if the repo is not read only
133
+ if is_read_only
134
+ puts " cannot tag a read only repo".colorize(:red)
135
+ return
136
+ end
137
+ # check if a tag for the current version already exists
138
+ if (`git tag -l v#{version}`.strip.length > 0)
139
+ puts " tag v#{version} already exists".colorize(:red)
140
+ else
141
+ "git tag -a v#{version} -m \"version #{version}\"".run
142
+ end
143
+ end
144
+ end
145
+ end