atk_toolbox 0.0.142 → 0.0.147
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/atk/atk_info.rb +14 -11
- data/lib/atk/autocomplete.rb +27 -0
- data/lib/atk/commands/project.rb +4 -1
- data/lib/atk/console.rb +7 -2
- data/lib/atk/file_system.rb +56 -7
- data/lib/atk/info.rb +1 -1
- data/lib/atk_toolbox.rb +2 -0
- data/lib/atk_toolbox/version.rb +1 -1
- data/lib/console_colors.rb +1 -1
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b365ad5c0a3d0e928cc4859c67aad51272421286920ee01f9b4e99bd4580ca68
|
4
|
+
data.tar.gz: f96b73a2f8ce0d80d1f5939c939276e8917449015401cc8ba235d6b841a1c8e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 220ed7e0f6b88d723d5fc60ae956c8ff3239bb58b1570869aa1d20727d19d8c606bcaf892da0e719da220bdad4327ce37e23257ba34abd4d49a8a073b1f6247d
|
7
|
+
data.tar.gz: 1ff31f90673bbf9ee64813c14098b85d017a8d7a9b8307c42d5d15d6bbc2140b8bfbbe8b5840840a00b82012878e3fd1f7a370897d477120c9befa8822a9c697
|
data/lib/atk/atk_info.rb
CHANGED
@@ -103,7 +103,7 @@ module Atk
|
|
103
103
|
errors = {}
|
104
104
|
|
105
105
|
# make sure ruby is the corrct version
|
106
|
-
if VERSION_OF_RUBY >= Version.new("
|
106
|
+
if VERSION_OF_RUBY >= Version.new("2.6.0")
|
107
107
|
errors[:ruby_version_too_high] = true
|
108
108
|
elsif VERSION_OF_RUBY < Version.new("2.5")
|
109
109
|
errors[:ruby_version_too_low] = true
|
@@ -138,7 +138,10 @@ module Atk
|
|
138
138
|
#
|
139
139
|
# TODO: talk about any found errors
|
140
140
|
#
|
141
|
-
|
141
|
+
if errors.include?[:ruby_version_too_high]
|
142
|
+
puts "It looks like your ruby version is too high for ATK"
|
143
|
+
puts "some parts of ATK might still work, however expect it to be broken"
|
144
|
+
end
|
142
145
|
end
|
143
146
|
|
144
147
|
def self.setup(package_name, arguments)
|
@@ -398,25 +401,25 @@ class AtkPackage
|
|
398
401
|
|
399
402
|
if @dont_exist[:yaml_file]
|
400
403
|
custom_message += <<-HEREDOC.remove_indent
|
401
|
-
#{bad
|
404
|
+
#{bad["there was no info.yaml for that package"]}
|
402
405
|
and an info.yaml is the location for defining a run action
|
403
406
|
|
404
407
|
HEREDOC
|
405
408
|
elsif @dont_exist[:correctly_formatted_yaml_file]
|
406
409
|
custom_message += <<-HEREDOC.remove_indent
|
407
|
-
#{good
|
408
|
-
#{bad
|
410
|
+
#{good["there was a info.yaml for that package"]}
|
411
|
+
#{bad["the info.yaml is not parseable"]}
|
409
412
|
and an info.yaml is the location for defining a run action
|
410
413
|
|
411
414
|
HEREDOC
|
412
415
|
elsif @dont_exist[:using_atk_version]
|
413
416
|
custom_message += <<-HEREDOC.remove_indent
|
414
|
-
#{good
|
415
|
-
#{good
|
416
|
-
#{@dont_exist[:using_atk_version] && bad
|
417
|
-
#{@dont_exist[:package_info] && bad
|
418
|
-
#{@dont_exist[:actions] && bad
|
419
|
-
#{@dont_exist[:run_action] && bad
|
417
|
+
#{good["there was a info.yaml for that package"]}
|
418
|
+
#{good["the info.yaml was parseable"]}
|
419
|
+
#{@dont_exist[:using_atk_version] && bad["the info.yaml didn't have a (using_atk_version) key"]}
|
420
|
+
#{@dont_exist[:package_info] && bad["the info.yaml didn't have a (package_info) key"]}
|
421
|
+
#{@dont_exist[:actions] && bad["the info.yaml didn't have a (package_info): (actions) key"]}
|
422
|
+
#{@dont_exist[:run_action] && bad["the info.yaml didn't have a (package_info): (actions): (run) key"]}
|
420
423
|
HEREDOC
|
421
424
|
end
|
422
425
|
|
data/lib/atk/autocomplete.rb
CHANGED
@@ -10,4 +10,31 @@ module Atk
|
|
10
10
|
# end
|
11
11
|
# end
|
12
12
|
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# zsh autocomplete
|
16
|
+
#
|
17
|
+
#compdef _
|
18
|
+
|
19
|
+
# _atk()
|
20
|
+
# {
|
21
|
+
# orig_words=( ${words[@]} )
|
22
|
+
# local comp_words="${COMP_WORDS[1]}"
|
23
|
+
# local comp_cword="${COMP_CWORD}"
|
24
|
+
# local mylist="$( ruby -e '
|
25
|
+
# require "yaml"
|
26
|
+
# class Nil ; def [](); end; end;
|
27
|
+
# if ARGV.length == 2
|
28
|
+
# puts YAML.load_file("./info.yaml")["(project)"]["(commands)"].keys.map{|each| each.inspect}
|
29
|
+
# else
|
30
|
+
# # puts `ls`
|
31
|
+
# end
|
32
|
+
# ' $orig_words
|
33
|
+
# )"
|
34
|
+
# COMPREPLY=($(compgen -W $mylist) )
|
35
|
+
# _alternative "arguments:custom arg:(($mylist))"
|
36
|
+
# }
|
37
|
+
|
38
|
+
# complete -F _atk _
|
39
|
+
# compdef _atk _
|
13
40
|
end
|
data/lib/atk/commands/project.rb
CHANGED
@@ -4,6 +4,9 @@ module Atk
|
|
4
4
|
class ExecFailed < Exception
|
5
5
|
end
|
6
6
|
|
7
|
+
class NoSuchCommand < Exception
|
8
|
+
end
|
9
|
+
|
7
10
|
def self.project(args)
|
8
11
|
#
|
9
12
|
# no arguments
|
@@ -143,7 +146,7 @@ module Atk
|
|
143
146
|
elsif command.is_a?(Code)
|
144
147
|
result = command.run(*command_args)
|
145
148
|
elsif command == nil
|
146
|
-
|
149
|
+
raise NoSuchCommand
|
147
150
|
end
|
148
151
|
|
149
152
|
# if command resulted in error then raise an error
|
data/lib/atk/console.rb
CHANGED
@@ -63,7 +63,7 @@ Console = Class.new do
|
|
63
63
|
CACHE::prompt = TTY::Prompt.new
|
64
64
|
end
|
65
65
|
# generate interface for TTY prompt with lazy require
|
66
|
-
for each in [ :ask, :keypress, :multiline, :mask, :yes?, :no?, :select, :multi_select, :enum_select, :expand, :collect, :suggest, :slider, :say, :
|
66
|
+
for each in [ :ask, :keypress, :multiline, :mask, :yes?, :no?, :select, :multi_select, :enum_select, :expand, :collect, :suggest, :slider, :say, :warn, :error ]
|
67
67
|
eval(<<-HEREDOC)
|
68
68
|
def #{each}(*args, **kwargs)
|
69
69
|
self._load_prompt() if CACHE::prompt == nil
|
@@ -78,6 +78,11 @@ Console = Class.new do
|
|
78
78
|
HEREDOC
|
79
79
|
end
|
80
80
|
|
81
|
+
def ok(message)
|
82
|
+
puts message.green + "\n[press enter to continue]".light_black
|
83
|
+
gets
|
84
|
+
end
|
85
|
+
alias :ok? :ok
|
81
86
|
|
82
87
|
attr_accessor :verbose
|
83
88
|
|
@@ -235,7 +240,7 @@ Console = Class.new do
|
|
235
240
|
|
236
241
|
# users are going to have to manually escape things like ^, !, % etc depending on the context they're used in
|
237
242
|
|
238
|
-
simple_char = "[a-zA-Z0-9_
|
243
|
+
simple_char = "[a-zA-Z0-9_.,;`=\\-*?\\/\\[\\]]"
|
239
244
|
|
240
245
|
# if its a simple argument just pass it on
|
241
246
|
if argument =~ /\A(#{simple_char})*\z/
|
data/lib/atk/file_system.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative './remove_indent'
|
|
7
7
|
if OS.is?("unix")
|
8
8
|
HOME = Etc.getpwuid.dir
|
9
9
|
else # windows
|
10
|
-
HOME =
|
10
|
+
HOME = "C:"+`echo %HOMEPATH%`.chomp
|
11
11
|
end
|
12
12
|
|
13
13
|
class String
|
@@ -141,6 +141,52 @@ module FileSystem
|
|
141
141
|
return output
|
142
142
|
end
|
143
143
|
|
144
|
+
def self.merge(from, into: nil, force: true)
|
145
|
+
to = into
|
146
|
+
if !FS.exist?(from)
|
147
|
+
raise <<~HEREDOC
|
148
|
+
|
149
|
+
|
150
|
+
When calling FileSystem.merge(#{from.inspect}, into: #{into.inspect})
|
151
|
+
The path: #{from.inspect}
|
152
|
+
Doesn't exist
|
153
|
+
HEREDOC
|
154
|
+
end
|
155
|
+
|
156
|
+
# recursive case (folder)
|
157
|
+
if FS.is_folder(from)
|
158
|
+
# if theres a target file in the way
|
159
|
+
if FS.exist?(to) && ( !FS.is_folder(to) )
|
160
|
+
if force
|
161
|
+
# remove it
|
162
|
+
FS.delete(to)
|
163
|
+
else
|
164
|
+
# continue with the process
|
165
|
+
return
|
166
|
+
end
|
167
|
+
end
|
168
|
+
# create a folder if needed
|
169
|
+
if !FS.exist?(to)
|
170
|
+
FS.touch_dir(to)
|
171
|
+
end
|
172
|
+
# become recursive for all contents
|
173
|
+
for each in FS.ls(from)
|
174
|
+
FS.merge(from/each, into: to/each, force: force)
|
175
|
+
end
|
176
|
+
# base case (file)
|
177
|
+
else
|
178
|
+
if FS.exist?(to)
|
179
|
+
if force
|
180
|
+
FS.delete(to)
|
181
|
+
else
|
182
|
+
# do nothing
|
183
|
+
return
|
184
|
+
end
|
185
|
+
end
|
186
|
+
FS.copy(from: from, to: FS.dirname(to), new_name: nil)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
144
190
|
def self.copy(from:nil, to:nil, new_name:"", force: true, preserve: false, dereference_root: false)
|
145
191
|
if new_name == ""
|
146
192
|
raise "\n\nFileSystem.copy() needs a new_name: argument\nset new_name:nil if you wish the file/folder to keep the same name\ne.g. FileSystem.copy(from:'place/thing', to:'place', new_name:nil)"
|
@@ -178,12 +224,15 @@ module FileSystem
|
|
178
224
|
HEREDOC
|
179
225
|
end
|
180
226
|
to = FileSystem.dirname(path)/new_name
|
181
|
-
#
|
182
|
-
if
|
183
|
-
|
227
|
+
# if they are different
|
228
|
+
if FS.absolute_path(to) != FS.absolute_path(path)
|
229
|
+
# make sure the path is clear
|
230
|
+
if force
|
231
|
+
FileSystem.delete(to)
|
232
|
+
end
|
233
|
+
# perform the rename
|
234
|
+
return File.rename(path, to)
|
184
235
|
end
|
185
|
-
# perform the rename
|
186
|
-
File.rename(path, to)
|
187
236
|
end
|
188
237
|
|
189
238
|
def self.touch(path)
|
@@ -252,7 +301,7 @@ module FileSystem
|
|
252
301
|
Dir.children(path)
|
253
302
|
end
|
254
303
|
def self.pwd
|
255
|
-
Dir.pwd
|
304
|
+
FS.join(Dir.pwd, "")
|
256
305
|
end
|
257
306
|
def self.cd(*args, verbose: false)
|
258
307
|
if args.size == 0
|
data/lib/atk/info.rb
CHANGED
@@ -210,7 +210,7 @@ class Info
|
|
210
210
|
return @folder
|
211
211
|
end
|
212
212
|
def self.folder()
|
213
|
-
folder = Dir.pwd
|
213
|
+
folder = FileSystem.join(Dir.pwd, "") # join with nothing to fix windows pathing
|
214
214
|
loop do
|
215
215
|
# if the info.yaml exists in that folder
|
216
216
|
if FileSystem.file?( FileSystem.join(folder, "info.yaml"))
|
data/lib/atk_toolbox.rb
CHANGED
data/lib/atk_toolbox/version.rb
CHANGED
data/lib/console_colors.rb
CHANGED
metadata
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atk_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.147
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Hykin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-prompt
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.19.0
|
20
|
-
- - "
|
20
|
+
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.19.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.19.0
|
30
|
-
- - "
|
30
|
+
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.19.0
|
33
33
|
description: ''
|
@@ -58,7 +58,7 @@ homepage: http://github.com//atk-toolbox
|
|
58
58
|
licenses:
|
59
59
|
- CC-BY-ND-4.0
|
60
60
|
metadata: {}
|
61
|
-
post_install_message:
|
61
|
+
post_install_message:
|
62
62
|
rdoc_options: []
|
63
63
|
require_paths:
|
64
64
|
- "./lib"
|
@@ -73,9 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
|
-
|
77
|
-
|
78
|
-
signing_key:
|
76
|
+
rubygems_version: 3.0.3
|
77
|
+
signing_key:
|
79
78
|
specification_version: 4
|
80
79
|
summary: The Ruby gem for all the standard tools ATK uses internally
|
81
80
|
test_files: []
|