makit 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.makit.project.json +4 -0
  3. data/.makit.project.yml +2 -0
  4. data/.rubocop.yml +22 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +8 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/LICENSE +21 -0
  9. data/README.md +119 -0
  10. data/Rakefile +190 -0
  11. data/docs/Commands.md +50 -0
  12. data/docs_/Commands.md +166 -0
  13. data/docs_/Minitest.Timeouts.md +332 -0
  14. data/examples/protoc/Rakefile +31 -0
  15. data/examples/rake_default/Rakefile +5 -0
  16. data/examples/rubygem-foo/.gitkeep +0 -0
  17. data/examples/rubygem-foo/Rakefile +3 -0
  18. data/examples/run_mp/Rakefile +8 -0
  19. data/exe/makit +5 -0
  20. data/lib/makit/apache.rb +32 -0
  21. data/lib/makit/cli/clean.rb +14 -0
  22. data/lib/makit/cli/clone.rb +59 -0
  23. data/lib/makit/cli/init.rb +38 -0
  24. data/lib/makit/cli/main.rb +33 -0
  25. data/lib/makit/cli/make.rb +54 -0
  26. data/lib/makit/cli/new.rb +37 -0
  27. data/lib/makit/cli/nuget_cache.rb +38 -0
  28. data/lib/makit/cli/pull.rb +31 -0
  29. data/lib/makit/cli/setup.rb +71 -0
  30. data/lib/makit/cli/work.rb +21 -0
  31. data/lib/makit/command_runner.rb +237 -0
  32. data/lib/makit/commands.rb +21 -0
  33. data/lib/makit/content/default_gitignore.rb +5 -0
  34. data/lib/makit/content/default_gitignore.txt +222 -0
  35. data/lib/makit/content/default_rakefile.rb +11 -0
  36. data/lib/makit/content/gem_rakefile.rb +14 -0
  37. data/lib/makit/content/ruby_gitlab-ci.yml +15 -0
  38. data/lib/makit/data.rb +50 -0
  39. data/lib/makit/directories.rb +140 -0
  40. data/lib/makit/directory.rb +120 -0
  41. data/lib/makit/dotnet.rb +16 -0
  42. data/lib/makit/environment.rb +123 -0
  43. data/lib/makit/files.rb +47 -0
  44. data/lib/makit/git.rb +66 -0
  45. data/lib/makit/gitlab_runner.rb +60 -0
  46. data/lib/makit/humanize.rb +89 -0
  47. data/lib/makit/logging.rb +96 -0
  48. data/lib/makit/markdown.rb +75 -0
  49. data/lib/makit/mp/basic_object_mp.rb +16 -0
  50. data/lib/makit/mp/project_mp.rb +160 -0
  51. data/lib/makit/mp/string_mp.rb +101 -0
  52. data/lib/makit/nuget.rb +57 -0
  53. data/lib/makit/protoc.rb +61 -0
  54. data/lib/makit/serializer.rb +70 -0
  55. data/lib/makit/storage.rb +131 -0
  56. data/lib/makit/symbols.rb +149 -0
  57. data/lib/makit/tasks.rb +63 -0
  58. data/lib/makit/tree.rb +37 -0
  59. data/lib/makit/v1/makit.v1.proto +103 -0
  60. data/lib/makit/v1/makit.v1_pb.rb +30 -0
  61. data/lib/makit/v1/makit.v1_services_pb.rb +26 -0
  62. data/lib/makit/version.rb +12 -0
  63. data/lib/makit/wix.rb +92 -0
  64. data/lib/makit/zip.rb +17 -0
  65. data/lib/makit.rb +243 -0
  66. data/makit.generated.sln +30 -0
  67. data/makit.sln +69 -0
  68. data/pages/.gitignore +5 -0
  69. data/pages/404.html +25 -0
  70. data/pages/Gemfile +33 -0
  71. data/pages/Gemfile.lock +88 -0
  72. data/pages/_config.yml +55 -0
  73. data/pages/_layouts/default.html +1 -0
  74. data/pages/_posts/2024-10-05-welcome-to-jekyll.markdown +29 -0
  75. data/pages/about.markdown +18 -0
  76. data/pages/index.markdown +6 -0
  77. data/sig/makit.rbs +4 -0
  78. data/src/ClassLib/Class1.cs +6 -0
  79. data/src/ClassLib/ClassLib.csproj +13 -0
  80. metadata +251 -0
data/docs_/Commands.md ADDED
@@ -0,0 +1,166 @@
1
+ # Markdown Examples
2
+
3
+ <details>
4
+ <summary>✓ git --version C:/Users/lparslow/code/work/gitlab/gems-rb/makit</summary>
5
+
6
+ <table><tr><th>output</th></tr><tr><td>
7
+
8
+ ```shell
9
+ git version 2.36.1.windows.1
10
+
11
+ ```
12
+
13
+ </td></tr></table>
14
+
15
+ | exit code | started at | duration | user | device | os | directory |
16
+ | --- | --- | --- | --- | --- | --- | --- |
17
+ | 0 | 2024-06-04 08:27:02 | 0h 0m 0.06s | lparslow | Lou-Parslow | Windows | C:/Users/lparslow/code/work/gitlab/gems-rb/makit |
18
+ </details>
19
+ <details>
20
+ <summary>✓ git --help C:/Users/lparslow/code/work/gitlab/gems-rb/makit</summary>
21
+
22
+ <table><tr><th>output</th></tr><tr><td>
23
+
24
+ ```shell
25
+ usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
26
+ [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
27
+ [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
28
+ [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
29
+ [--super-prefix=<path>] [--config-env=<name>=<envvar>]
30
+ <command> [<args>]
31
+
32
+ These are common Git commands used in various situations:
33
+
34
+ start a working area (see also: git help tutorial)
35
+ clone Clone a repository into a new directory
36
+ init Create an empty Git repository or reinitialize an existing one
37
+
38
+ work on the current change (see also: git help everyday)
39
+ add Add file contents to the index
40
+ mv Move or rename a file, a directory, or a symlink
41
+ restore Restore working tree files
42
+ rm Remove files from the working tree and from the index
43
+
44
+ examine the history and state (see also: git help revisions)
45
+ bisect Use binary search to find the commit that introduced a bug
46
+ diff Show changes between commits, commit and working tree, etc
47
+ grep Print lines matching a pattern
48
+ log Show commit logs
49
+ show Show various types of objects
50
+ status Show the working tree status
51
+
52
+ grow, mark and tweak your common history
53
+ branch List, create, or delete branches
54
+ commit Record changes to the repository
55
+ merge Join two or more development histories together
56
+ rebase Reapply commits on top of another base tip
57
+ reset Reset current HEAD to the specified state
58
+ switch Switch branches
59
+ tag Create, list, delete or verify a tag object signed with GPG
60
+
61
+ collaborate (see also: git help workflows)
62
+ fetch Download objects and refs from another repository
63
+ pull Fetch from and integrate with another repository or a local branch
64
+ push Update remote refs along with associated objects
65
+
66
+ 'git help -a' and 'git help -g' list available subcommands and some
67
+ concept guides. See 'git help <command>' or 'git help <concept>'
68
+ to read about a specific subcommand or concept.
69
+ See 'git help git' for an overview of the system.
70
+
71
+ ```
72
+
73
+ </td></tr></table>
74
+
75
+ | exit code | started at | duration | user | device | os | directory |
76
+ | --- | --- | --- | --- | --- | --- | --- |
77
+ | 0 | 2024-06-04 08:27:02 | 0h 0m 0.08s | lparslow | Lou-Parslow | Windows | C:/Users/lparslow/code/work/gitlab/gems-rb/makit |
78
+ </details>
79
+ <details>
80
+ <summary>✓ ruby --version C:/Users/lparslow/code/work/gitlab/gems-rb/makit</summary>
81
+
82
+ <table><tr><th>output</th></tr><tr><td>
83
+
84
+ ```shell
85
+ ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x64-mingw-ucrt]
86
+
87
+ ```
88
+
89
+ </td></tr></table>
90
+
91
+ | exit code | started at | duration | user | device | os | directory |
92
+ | --- | --- | --- | --- | --- | --- | --- |
93
+ | 0 | 2024-06-04 08:27:02 | 0h 0m 0.05s | lparslow | Lou-Parslow | Windows | C:/Users/lparslow/code/work/gitlab/gems-rb/makit |
94
+ </details>
95
+ <details>
96
+ <summary>✓ ruby --help C:/Users/lparslow/code/work/gitlab/gems-rb/makit</summary>
97
+
98
+ <table><tr><th>output</th></tr><tr><td>
99
+
100
+ ```shell
101
+ Usage: ruby [switches] [--] [programfile] [arguments]
102
+ -0[octal] specify record separator (\0, if no argument)
103
+ -a autosplit mode with -n or -p (splits $_ into $F)
104
+ -c check syntax only
105
+ -Cdirectory cd to directory before executing your script
106
+ -d, --debug set debugging flags (set $DEBUG to true)
107
+ -e 'command' one line of script. Several -e's allowed. Omit [programfile]
108
+ -Eex[:in], --encoding=ex[:in]
109
+ specify the default external and internal character encodings
110
+ -Fpattern split() pattern for autosplit (-a)
111
+ -i[extension] edit ARGV files in place (make backup if extension supplied)
112
+ -Idirectory specify $LOAD_PATH directory (may be used more than once)
113
+ -l enable line ending processing
114
+ -n assume 'while gets(); ... end' loop around your script
115
+ -p assume loop like -n but print line also like sed
116
+ -rlibrary require the library before executing your script
117
+ -s enable some switch parsing for switches after script name
118
+ -S look for the script using PATH environment variable
119
+ -v print the version number, then turn on verbose mode
120
+ -w turn warnings on for your script
121
+ -W[level=2|:category]
122
+ set warning level; 0=silence, 1=medium, 2=verbose
123
+ -x[directory] strip off text before #!ruby line and perhaps cd to directory
124
+ --jit enable JIT for the platform, same as --mjit (experimental)
125
+ --copyright print the copyright
126
+ --dump={insns|parsetree|...}[,...]
127
+ dump debug information. see below for available dump list
128
+ --enable={jit|rubyopt|...}[,...], --disable={jit|rubyopt|...}[,...]
129
+ enable or disable features. see below for available features
130
+ --external-encoding=encoding, --internal-encoding=encoding
131
+ specify the default external or internal character encoding
132
+ --backtrace-limit=num
133
+ limit the maximum length of backtrace
134
+ --verbose turn on verbose mode and disable script from stdin
135
+ --version print the version number, then exit
136
+ --help show this message, -h for short message
137
+ Dump List:
138
+ insns instruction sequences
139
+ insns_without_opt
140
+ instruction sequences compiled with no optimization
141
+ yydebug(+error-tolerant)
142
+ yydebug of yacc parser generator
143
+ parsetree(+error-tolerant)
144
+ AST
145
+ parsetree_with_comment(+error-tolerant)
146
+ AST with comments
147
+ Features:
148
+ gems rubygems (only for debugging, default: enabled)
149
+ error_highlight error_highlight (default: enabled)
150
+ did_you_mean did_you_mean (default: enabled)
151
+ syntax_suggest syntax_suggest (default: enabled)
152
+ rubyopt RUBYOPT environment variable (default: enabled)
153
+ frozen-string-literal
154
+ freeze all string literals (default: disabled)
155
+ Warning categories:
156
+ deprecated deprecated features
157
+ experimental experimental features
158
+
159
+ ```
160
+
161
+ </td></tr></table>
162
+
163
+ | exit code | started at | duration | user | device | os | directory |
164
+ | --- | --- | --- | --- | --- | --- | --- |
165
+ | 0 | 2024-06-04 08:27:02 | 0h 0m 0.05s | lparslow | Lou-Parslow | Windows | C:/Users/lparslow/code/work/gitlab/gems-rb/makit |
166
+ </details>
@@ -0,0 +1,332 @@
1
+ ### **Setting Timeouts on Minitest Tests**
2
+
3
+ To ensure that your tests do not run indefinitely or take too long, you can set timeouts on your Minitest tests. This is particularly useful for catching hanging tests or identifying performance issues.
4
+
5
+ There are several ways to set timeouts in Minitest:
6
+
7
+ 1. **Using Ruby's `Timeout` Module**
8
+ 2. **Using the `minitest-timeout` Gem**
9
+ 3. **Using Custom Assertions**
10
+
11
+ ---
12
+
13
+ #### **1. Using Ruby's `Timeout` Module**
14
+
15
+ The standard Ruby library provides a `Timeout` module that can be used to limit the execution time of code blocks.
16
+
17
+ **Example:**
18
+
19
+ ```ruby
20
+ require 'minitest/autorun'
21
+ require 'timeout'
22
+
23
+ class MyTest < Minitest::Test
24
+ def test_with_timeout
25
+ Timeout.timeout(5) do
26
+ # Test code that should complete within 5 seconds
27
+ long_running_operation
28
+ end
29
+ rescue Timeout::Error
30
+ flunk "Test exceeded time limit and was aborted."
31
+ end
32
+
33
+ private
34
+
35
+ def long_running_operation
36
+ sleep 10 # Simulates a long-running operation
37
+ end
38
+ end
39
+ ```
40
+
41
+ **Explanation:**
42
+
43
+ - **`Timeout.timeout(5) do ... end`**: Executes the block and raises a `Timeout::Error` if it takes more than 5 seconds.
44
+ - **Rescuing `Timeout::Error`**: Captures the timeout exception and marks the test as failed using `flunk`.
45
+
46
+ **Caveats:**
47
+
48
+ - The `Timeout` module uses threads to interrupt the execution, which can be unsafe for certain operations, especially IO operations or code that is not thread-safe.
49
+ - Using `Timeout` can sometimes lead to unexpected behavior or hard-to-debug issues due to the abrupt interruption.
50
+
51
+ ---
52
+
53
+ #### **2. Using the `minitest-timeout` Gem**
54
+
55
+ The `minitest-timeout` gem provides a cleaner and safer way to set timeouts on tests.
56
+
57
+ **Installation:**
58
+
59
+ Add the gem to your `Gemfile`:
60
+
61
+ ```ruby
62
+ gem 'minitest-timeout'
63
+ ```
64
+
65
+ Then run:
66
+
67
+ ```bash
68
+ bundle install
69
+ ```
70
+
71
+ **Usage:**
72
+
73
+ ```ruby
74
+ # test/test_helper.rb
75
+
76
+ require 'minitest/autorun'
77
+ require 'minitest/timeout'
78
+
79
+ # Set a default timeout for all tests (optional)
80
+ Minitest::Timeout.timeout = 5 # seconds
81
+ ```
82
+
83
+ ```ruby
84
+ # test/my_test.rb
85
+
86
+ require_relative 'test_helper'
87
+
88
+ class MyTest < Minitest::Test
89
+ timeout 5 # seconds
90
+
91
+ def test_long_running_operation
92
+ # This test will fail if it runs longer than 5 seconds
93
+ long_running_operation
94
+ end
95
+
96
+ def test_another_operation
97
+ # Override timeout for a specific test
98
+ timeout(2)
99
+ another_long_running_operation
100
+ end
101
+
102
+ private
103
+
104
+ def long_running_operation
105
+ sleep 10
106
+ end
107
+
108
+ def another_long_running_operation
109
+ sleep 3
110
+ end
111
+ end
112
+ ```
113
+
114
+ **Explanation:**
115
+
116
+ - **`timeout 5` at the class level**: Sets a default timeout of 5 seconds for all tests in the class.
117
+ - **`timeout(2)` in a test method**: Overrides the timeout for that specific test.
118
+ - **Global Timeout**: You can set a global timeout in the `test_helper.rb` that applies to all tests.
119
+
120
+ **Benefits:**
121
+
122
+ - **Safe Execution**: The gem ensures that the timeout is handled safely without the drawbacks of the `Timeout` module.
123
+ - **Easy Configuration**: Allows setting timeouts at the test, class, or global level.
124
+ - **Consistent Behavior**: Provides consistent behavior across different types of tests.
125
+
126
+ ---
127
+
128
+ #### **3. Using Custom Assertions**
129
+
130
+ You can create a custom assertion to check the execution time of your tests.
131
+
132
+ **Example:**
133
+
134
+ ```ruby
135
+ require 'minitest/autorun'
136
+
137
+ class MyTest < Minitest::Test
138
+ def test_with_custom_timeout
139
+ assert_execution_time 5 do
140
+ long_running_operation
141
+ end
142
+ end
143
+
144
+ private
145
+
146
+ def assert_execution_time(max_seconds, &block)
147
+ start_time = Time.now
148
+ yield
149
+ end_time = Time.now
150
+ execution_time = end_time - start_time
151
+ assert execution_time <= max_seconds, "Expected execution time to be less than #{max_seconds}s, but was #{execution_time.round(2)}s"
152
+ end
153
+
154
+ def long_running_operation
155
+ sleep 10
156
+ end
157
+ end
158
+ ```
159
+
160
+ **Explanation:**
161
+
162
+ - **`assert_execution_time`**: A custom assertion method that measures the time taken to execute a block.
163
+ - **Usage**: Wrap the code you want to time within the `assert_execution_time` block.
164
+ - **Assertion**: Fails the test if the execution time exceeds the specified maximum.
165
+
166
+ **Caveats:**
167
+
168
+ - This method doesn't interrupt the test if it exceeds the time limit; it only checks after the fact.
169
+ - Not suitable if you need to abort the test execution upon exceeding the time limit.
170
+
171
+ ---
172
+
173
+ ### **Recommendations**
174
+
175
+ For most use cases, using the `minitest-timeout` gem is the most effective and safest way to set timeouts on your Minitest tests.
176
+
177
+ ---
178
+
179
+ ### **Implementing Timeouts in Your Task**
180
+
181
+ Given your existing test setup, here's how you might integrate timeouts.
182
+
183
+ **Step 1: Install `minitest-timeout` Gem**
184
+
185
+ Add to your `Gemfile`:
186
+
187
+ ```ruby
188
+ gem 'minitest-timeout'
189
+ ```
190
+
191
+ Run:
192
+
193
+ ```bash
194
+ bundle install
195
+ ```
196
+
197
+ **Step 2: Configure Timeout in `test_helper.rb`**
198
+
199
+ Create or update your `test_helper.rb`:
200
+
201
+ ```ruby
202
+ # test/test_helper.rb
203
+
204
+ require 'minitest/autorun'
205
+ require 'minitest/timeout'
206
+
207
+ # Set a global timeout for all tests (e.g., 10 seconds)
208
+ Minitest::Timeout.timeout = 10
209
+ ```
210
+
211
+ **Step 3: Update Your Tests**
212
+
213
+ In your test files, you can set timeouts as needed.
214
+
215
+ ```ruby
216
+ require_relative 'test_helper'
217
+
218
+ class WixTest < Minitest::Test
219
+ # Set a class-level timeout (overrides global timeout)
220
+ timeout 15
221
+
222
+ def test_setup_package
223
+ # Individual test code
224
+ end
225
+
226
+ def test_another_method
227
+ # Override timeout for this test
228
+ timeout(5)
229
+ # Test code
230
+ end
231
+ end
232
+ ```
233
+
234
+ **Step 4: Run Your Tests**
235
+
236
+ Run your tests as usual, and they will fail if any test exceeds the specified timeout.
237
+
238
+ ---
239
+
240
+ ### **Handling Timeout Failures**
241
+
242
+ When a test exceeds the timeout, it will fail with a message indicating that the execution time was exceeded.
243
+
244
+ **Example Failure Message:**
245
+
246
+ ```
247
+ Minitest::Timeout::Error: execution of test took longer than 5 seconds.
248
+ ```
249
+
250
+ You can handle or customize this behavior if needed.
251
+
252
+ ---
253
+
254
+ ### **Caveats and Considerations**
255
+
256
+ - **Long-Running Setup or Teardown:** If you have setup or teardown methods that might exceed the timeout, consider adjusting the timeout or refactoring the setup code.
257
+ - **Thread Safety:** Ensure that your code is thread-safe, especially when using gems that manage timeouts internally.
258
+ - **Debugging Timeouts:** If tests fail due to timeouts, investigate whether the code under test is inefficient, has infinite loops, or is waiting on external resources.
259
+
260
+ ---
261
+
262
+ ### **Alternative Approaches**
263
+
264
+ If you prefer not to use external gems, or if you need more control over the timeout behavior, consider the following:
265
+
266
+ #### **Using `Timeout` Module with Care**
267
+
268
+ While the `Timeout` module can be problematic, it may be acceptable for simple tests.
269
+
270
+ **Example:**
271
+
272
+ ```ruby
273
+ def test_with_timeout
274
+ status = :passed
275
+ begin
276
+ Timeout.timeout(5) do
277
+ long_running_operation
278
+ end
279
+ rescue Timeout::Error
280
+ status = :failed
281
+ end
282
+ assert_equal :passed, status, "Test exceeded time limit and was aborted."
283
+ end
284
+ ```
285
+
286
+ #### **Process Forking**
287
+
288
+ For tests that may hang due to external resources or blocking IO, running tests in separate processes can prevent them from affecting the main test suite.
289
+
290
+ **Example:**
291
+
292
+ ```ruby
293
+ def test_with_fork_and_timeout
294
+ pid = fork do
295
+ long_running_operation
296
+ end
297
+ begin
298
+ Timeout.timeout(5) do
299
+ Process.wait(pid)
300
+ end
301
+ rescue Timeout::Error
302
+ Process.kill('TERM', pid)
303
+ flunk "Test exceeded time limit and was aborted."
304
+ end
305
+ end
306
+ ```
307
+
308
+ **Note:** Process forking is not available on Windows platforms.
309
+
310
+ ---
311
+
312
+ ### **Conclusion**
313
+
314
+ Setting timeouts on your Minitest tests helps ensure that they complete within expected time frames and aids in identifying performance issues or hanging tests. By using the `minitest-timeout` gem, you can easily integrate timeouts into your existing test suite with minimal changes.
315
+
316
+ ---
317
+
318
+ ### **References**
319
+
320
+ - [minitest-timeout GitHub Repository](https://github.com/kamui/minitest-timeout)
321
+ - [Ruby Timeout Module Documentation](https://ruby-doc.org/stdlib-2.7.0/libdoc/timeout/rdoc/Timeout.html)
322
+ - [Minitest Documentation](https://github.com/seattlerb/minitest)
323
+
324
+ ---
325
+
326
+ ### **Additional Tips**
327
+
328
+ - **Monitoring Test Performance:** Regularly monitor your test suite's performance to catch any tests that are consistently close to the timeout limit.
329
+ - **CI/CD Integration:** Ensure that timeouts are appropriately set in continuous integration environments, where resources may differ from local development machines.
330
+ - **Adjusting Timeouts:** Be cautious not to set timeouts too low, which could cause false negatives due to variations in execution time.
331
+
332
+ By implementing timeouts effectively, you enhance the reliability and efficiency of your test suite.
@@ -0,0 +1,31 @@
1
+ require_relative "../../lib/makit"
2
+ #require "makit"
3
+
4
+ task :setup do
5
+ # setup the protoc environment
6
+ Makit::Protoc::setup
7
+
8
+ # copy the makit.v1.proto file to the current directory
9
+ FileUtils.cp(File.join("../../lib/makit/v1", "makit.v1.proto"), ".")
10
+
11
+ # create the artifacts directory
12
+ FileUtils.mkdir_p("artifacts") unless Dir.exist?("artifacts")
13
+ end
14
+
15
+ task :generate => [:setup] do
16
+ puts ":generate".colorize(:blue)
17
+
18
+ puts " generating code from makit.v1.proto".colorize(:green)
19
+ "protoc -I . --ruby_out=artifacts makit.v1.proto".run
20
+ #"grpc_tools_ruby_protoc -I . --ruby_out=artifacts --grpc_out=artifacts makit.v1.proto".run
21
+ end
22
+
23
+ task :test do
24
+ runner = Makit::CommandRunner.new
25
+ command = runner.run(runner.parse_command_request("git --version"))
26
+
27
+ puts "command type: #{command.class}"
28
+ puts "command proto name: #{command.name}"
29
+ end
30
+
31
+ task :default => [:setup, :generate]
@@ -0,0 +1,5 @@
1
+ require "makit"
2
+
3
+ task :default do
4
+ puts "default task"
5
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ require_relative "../../lib/makit"
2
+
3
+ task :default
@@ -0,0 +1,8 @@
1
+ require "makit"
2
+
3
+ task :default do
4
+ "git --version".run
5
+ "bogus --version".run({ exit_on_error: false })
6
+ "docker --version".run({ exit_on_error: false })
7
+ "makit --version".run({ exit_on_error: false })
8
+ end
data/exe/makit ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "makit"
5
+ Makit::Cli::MainCommand.run(ARGV)
@@ -0,0 +1,32 @@
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 Apache
8
+ def self.server_root
9
+ os = Makit::Environment::get_os
10
+ if os == "windows"
11
+ "C:\\Apache24"
12
+ elsif os == "linux"
13
+ "/etc/apache2"
14
+ elsif os == "mac"
15
+ "/private/etc/apache2"
16
+ else
17
+ nil
18
+ end
19
+ # default on windows: C:\Apache24
20
+ # default on linux: /etc/apache2
21
+ # default on mac: /private/etc/apache2
22
+ #nil
23
+ end
24
+
25
+ def self.document_root
26
+ # default on windows: C:\Apache24\htdocs
27
+ # default on linux: /var/www/html
28
+ # default on mac: /Library/WebServer/Documents
29
+ nil
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clamp"
4
+
5
+ module Makit
6
+ module Cli
7
+ # Define the 'new' subcommand
8
+ class CleanCommand < Clamp::Command
9
+ def execute
10
+ puts "TODO: implement clean command"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "clamp"
4
+ #require "git"
5
+
6
+ module Makit
7
+ module Cli
8
+ # Define the 'clone' subcommand
9
+ class CloneCommand < Clamp::Command
10
+ parameter "GIT_REPOSITORY", "The git repository url", attribute_name: :git_repository, required: true
11
+
12
+ def execute
13
+ clone_dir = Directories::get_clone_directory(git_repository)
14
+ puts "cloning repository: #{git_repository} to #{clone_dir}"
15
+ begin
16
+ Makit::clone(git_repository)
17
+ if !Dir.exist?(clone_dir)
18
+ summary = "failed to clone repository: #{git_repository} to #{clone_dir}\n"
19
+ summary += "Please check the URL and your network connection.\n"
20
+ summary += "stdout: #{clone.stdout}\n"
21
+ summary += "stderr: #{clone.stderr}\n"
22
+ $stderr.puts summary
23
+ exit 1
24
+ end
25
+ rescue => e
26
+ # $stderr.puts "failed to clone repository: #{git_repository} to #{clone_dir}"
27
+ puts e.message
28
+ exit 1
29
+ end
30
+ #puts "size of clone directory: #{clone_dir} is #{Humanize::get_humanized_size(Directory::get_size(clone_dir))}"
31
+ end
32
+
33
+ #def self.clone(git_repository)
34
+ # make sure a local clone of the repository exists
35
+ # clone_dir = Directories::get_clone_directory(git_repository)
36
+ # raise "clone directory already exists: #{clone_dir}" if Dir.exist?(clone_dir)
37
+ # begin
38
+ # clone_command = Makit::RUNNER.execute("git clone #{git_repository} #{clone_dir}")
39
+ # if !Dir.exist?(clone_dir)
40
+ # summary = "failed to clone repository: #{git_repository} to #{clone_dir}\n"
41
+ # summary += "Please check the URL and your network connection.\n"
42
+ # summary += "stdout: #{clone_command.stdout}\n"
43
+ # summary += "stderr: #{clone_command.stderr}\n"
44
+ # raise Makit::Error, summary
45
+ # end
46
+ #raise "failed to clone repository: #{git_repository} to #{clone_dir}" unless clone_command.success?
47
+ #Git.clone(git_repository, clone_dir)
48
+ # rescue => e
49
+ # summary = "=" * 80 + "\n"
50
+ # summary += "failed to clone repository: #{git_repository} to #{clone_dir}\n\n"
51
+ # summary += "Please check the URL and your network connection.\n"
52
+ # summary += "#{e.message}\n\n"
53
+ # summary += "=" * 80 + "\n"
54
+ # raise Makit::Error, summary
55
+ # end
56
+ #end
57
+ end
58
+ end
59
+ end