raykit 0.0.505 → 0.0.507
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.
- checksums.yaml +4 -4
- data/lib/raykit/console.rb +30 -3
- data/lib/raykit/dir.rb +24 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c556f3f822a3fe0fdd1ef67c199d98c0d16e2283c1fd44847d7ff609b3c3646
|
4
|
+
data.tar.gz: 219f1f492e1a0f556f83d33475abe2844a3b9008fb9c5aaa04eed66a5806eb7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7b9a25215834fee39ca14ceac4816cc719701293c0d8abac7dd9c5d2e70e9d7515f8e58eba8e1a2820f2f82af8946a893ad1bd71e5bd4c26ee6b9cd2bdf45b1
|
7
|
+
data.tar.gz: 78a431792525de714b4a00d307e1923ec80e4ebbc67633a16ce0ba6169a9fdf17789d480b20b26d7ce912fb40c0fd9750b5c7eb22d6714a6ef5cf9b134cfed75
|
data/lib/raykit/console.rb
CHANGED
@@ -57,6 +57,8 @@ module Raykit
|
|
57
57
|
import
|
58
58
|
when "clean"
|
59
59
|
clean
|
60
|
+
when "clobber"
|
61
|
+
clobber
|
60
62
|
when "sync_version"
|
61
63
|
sync_version
|
62
64
|
when "copy"
|
@@ -77,6 +79,7 @@ module Raykit
|
|
77
79
|
"work" => "clone and rake a git repository",
|
78
80
|
"import" => "import git urls matching a specific pattern",
|
79
81
|
"clean" => "clean one or more working directories",
|
82
|
+
"clobber" => "clobber one or more working directories",
|
80
83
|
"pull" => "preform git pull on one or more working directories",
|
81
84
|
"sync_version" => "synchronize the version number between two files",
|
82
85
|
"copy" => "copy a file" }
|
@@ -89,6 +92,7 @@ module Raykit
|
|
89
92
|
"work" => "work URL_PATTERN [--task RAKE_TASK]",
|
90
93
|
"import" => "import URL_PATTERN",
|
91
94
|
"clean" => "clean URL_PATTERN",
|
95
|
+
"clobber" => "clobber URL_PATTERN",
|
92
96
|
"pull" => "pull URL_PATTERN",
|
93
97
|
"sync_version" => "sync_version SOURCE_FILENAME DESTINATION_FILENAME",
|
94
98
|
"copy" => "copy SOURCE DESTINATION" }
|
@@ -161,9 +165,9 @@ module Raykit
|
|
161
165
|
pattern = @opts.arguments[1] if @opts.arguments.length > 1
|
162
166
|
logger = Logger.new(STDOUT)
|
163
167
|
# Set the formatter to output just the message
|
164
|
-
logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
165
|
-
|
166
|
-
end
|
168
|
+
#logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
169
|
+
# "#{msg}\n"
|
170
|
+
#end
|
167
171
|
logger.level = Logger::DEBUG
|
168
172
|
logger.debug("work: pattern: #{pattern}")
|
169
173
|
|
@@ -265,6 +269,28 @@ module Raykit
|
|
265
269
|
end
|
266
270
|
|
267
271
|
def clean
|
272
|
+
pattern = ""
|
273
|
+
pattern = @opts.arguments[1] if @opts.arguments.length > 1
|
274
|
+
REPOSITORIES.matches(pattern).each do |url|
|
275
|
+
repo = Raykit::Git::Repository.new(url)
|
276
|
+
work = Raykit::Git::Directory.new(repo.get_dev_dir("work"))
|
277
|
+
next unless Dir.exist?(work.directory)
|
278
|
+
|
279
|
+
# TODO: run a git clean command in the directory
|
280
|
+
puts "cleaning #{work.directory}"
|
281
|
+
Dir.chdir(work.directory) do
|
282
|
+
cmd = Command.new("git clean -xdf")
|
283
|
+
cmd.summary if @opts.verbose?
|
284
|
+
if cmd.exitstatus != 0
|
285
|
+
cmd.details
|
286
|
+
abort Rainbow(cmd.summary).blue.bright if @opts.quit?
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
Dir::remove_empty_directories(Raykit::Environment.get_dev_dir("work"))
|
291
|
+
end
|
292
|
+
|
293
|
+
def clobber
|
268
294
|
pattern = ""
|
269
295
|
pattern = @opts.arguments[1] if @opts.arguments.length > 1
|
270
296
|
REPOSITORIES.matches(pattern).each do |url|
|
@@ -279,6 +305,7 @@ module Raykit
|
|
279
305
|
puts "error removing #{work.directory}"
|
280
306
|
end
|
281
307
|
end
|
308
|
+
Dir::remove_empty_directories(Raykit::Environment.get_dev_dir("work"))
|
282
309
|
end
|
283
310
|
|
284
311
|
def copy
|
data/lib/raykit/dir.rb
CHANGED
@@ -46,4 +46,28 @@ class Dir
|
|
46
46
|
|
47
47
|
Dir.tmpdir
|
48
48
|
end
|
49
|
+
|
50
|
+
require "fileutils"
|
51
|
+
|
52
|
+
def self.remove_empty_directories(dir)
|
53
|
+
# List all entries in the directory except for '.' and '..'
|
54
|
+
Dir.entries(dir).each do |entry|
|
55
|
+
next if entry == "." || entry == ".." # Skip the current and parent directory entries
|
56
|
+
|
57
|
+
path = File.join(dir, entry) # Construct the full path
|
58
|
+
|
59
|
+
if File.directory?(path)
|
60
|
+
remove_empty_directories(path) # Recursively call the method if the entry is a directory
|
61
|
+
# Remove the directory if it's empty after processing its contents
|
62
|
+
Dir.rmdir(path) if Dir.empty?(path)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
rescue Errno::ENOENT
|
66
|
+
# Handle the case where the directory doesn't exist or is removed before rmdir is called
|
67
|
+
puts "Directory not found: #{dir}"
|
68
|
+
end
|
69
|
+
|
70
|
+
# Example usage:
|
71
|
+
# remove_empty_directories('/path/to/directory')
|
72
|
+
|
49
73
|
end
|