drakkon 0.0.7 → 0.0.10
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/drakkon/build.rb +61 -4
- data/lib/drakkon/cli.rb +3 -1
- data/lib/drakkon/gem/bundle.rb +86 -17
- data/lib/drakkon/gem/cli.rb +2 -0
- data/lib/drakkon/gem/helpers/modules.rb +5 -0
- data/lib/drakkon/init.rb +23 -15
- data/lib/drakkon/lib/fonts/fonts.rb +88 -0
- data/lib/drakkon/lib/hub.rb +4 -3
- data/lib/drakkon/lib/images/biggest.rb +8 -6
- data/lib/drakkon/lib/images/bulk_rename.rb +1 -13
- data/lib/drakkon/lib/images/cli.rb +35 -19
- data/lib/drakkon/lib/images/compress.rb +60 -0
- data/lib/drakkon/lib/images/double.rb +77 -0
- data/lib/drakkon/lib/images/downcase_normalize.rb +70 -0
- data/lib/drakkon/lib/images/hue_modulation.rb +71 -0
- data/lib/drakkon/lib/images/index.rb +43 -20
- data/lib/drakkon/lib/images/layers.rb +55 -0
- data/lib/drakkon/lib/images/resize.rb +3 -2
- data/lib/drakkon/lib/images/split.rb +4 -4
- data/lib/drakkon/lib/images/spritesheet.rb +52 -13
- data/lib/drakkon/lib/images/text.rb +4 -1
- data/lib/drakkon/lib/images/trim.rb +7 -6
- data/lib/drakkon/lib/manifest.rb +24 -16
- data/lib/drakkon/lib/pastel.rb +1 -1
- data/lib/drakkon/lib/platform_compat.rb +27 -0
- data/lib/drakkon/lib/settings.rb +68 -5
- data/lib/drakkon/lib/sounds/sounds.rb +126 -0
- data/lib/drakkon/lib/utils/cli.rb +38 -0
- data/lib/drakkon/lib/utils/rename_normalize.rb +75 -0
- data/lib/drakkon/lib/version.rb +17 -2
- data/lib/drakkon/release.rb +1 -1
- data/lib/drakkon/run/commands/utils.rb +14 -0
- data/lib/drakkon/run/helpers.rb +15 -4
- data/lib/drakkon/run/reader_shim.rb +9 -5
- data/lib/drakkon/run/tty.rb +1 -1
- data/lib/drakkon/run.rb +6 -2
- data/lib/drakkon/skeleton/deploy.rb +4 -1
- data/lib/drakkon/web.rb +16 -44
- data/lib/drakkon.rb +10 -7
- metadata +32 -35
data/lib/drakkon/lib/manifest.rb
CHANGED
@@ -13,17 +13,9 @@ module Drakkon
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.run!(force: false)
|
16
|
-
|
17
|
-
search("#{Dir.pwd}/app")
|
18
|
-
|
19
|
-
# No Dupes please
|
20
|
-
list.reject! { |x| x.include? 'app/drakkon/manifest.rb' }
|
21
|
-
|
22
|
-
list.map! do |file|
|
23
|
-
file.gsub(root_directory, '')
|
24
|
-
end
|
16
|
+
index
|
25
17
|
|
26
|
-
if Settings.config[:manifest_digest] == digest
|
18
|
+
if Settings.config[:manifest_digest] == digest && File.exist?('app/drakkon/manifest.rb')
|
27
19
|
LogBot.info('Manifest', 'Nothing New')
|
28
20
|
return unless force
|
29
21
|
end
|
@@ -34,10 +26,22 @@ module Drakkon
|
|
34
26
|
|
35
27
|
# Make Directory `app/drakkon` if it doesn't exist
|
36
28
|
FileUtils.mkdir_p('app/drakkon') unless File.directory?('app/drakkon')
|
37
|
-
|
38
29
|
File.write('app/drakkon/manifest.rb', required)
|
39
30
|
end
|
40
31
|
|
32
|
+
# Split out | Just collect information
|
33
|
+
def self.index
|
34
|
+
list
|
35
|
+
search("#{Dir.pwd}/app")
|
36
|
+
|
37
|
+
# General Cleanup
|
38
|
+
list.reject! { |x| x.include? 'app/main.rb' }
|
39
|
+
|
40
|
+
list.map! do |file|
|
41
|
+
file.gsub(root_directory, '')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
41
45
|
def self.digest
|
42
46
|
Digest::MD5.hexdigest(list.map { |x| Digest::MD5.file(x).hexdigest }.join)
|
43
47
|
end
|
@@ -49,6 +53,9 @@ module Drakkon
|
|
49
53
|
end
|
50
54
|
|
51
55
|
def self.search(dir)
|
56
|
+
# Skip Drakkon
|
57
|
+
return if dir.include?('app/drakkon')
|
58
|
+
|
52
59
|
@list.concat Dir["#{dir}/*.rb"]
|
53
60
|
|
54
61
|
Dir["#{dir}/*"].each do |file|
|
@@ -61,11 +68,12 @@ module Drakkon
|
|
61
68
|
# Generate Require Statements
|
62
69
|
# Sure there gonna be plenty of opinions on this bad boi
|
63
70
|
def self.required
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
71
|
+
require_strings = ''
|
72
|
+
list.reverse.each do |file|
|
73
|
+
require_strings << "require '#{file}'\n"
|
74
|
+
end
|
75
|
+
|
76
|
+
require_strings
|
69
77
|
end
|
70
78
|
|
71
79
|
# ----------------------
|
data/lib/drakkon/lib/pastel.rb
CHANGED
@@ -3,7 +3,7 @@ module Drakkon
|
|
3
3
|
# Replace Colorize with Pastel Monkey Patch String Shim
|
4
4
|
# https://github.com/piotrmurach/pastel#features
|
5
5
|
|
6
|
-
# Looping in
|
6
|
+
# Looping in to allow disabling of Color
|
7
7
|
module Color
|
8
8
|
def self.pastel
|
9
9
|
@pastel ||= Pastel.new
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Drakkon
|
2
|
+
# Helper to provide platform compatibility
|
3
|
+
module PlatformCompat
|
4
|
+
def run_env
|
5
|
+
{
|
6
|
+
'PATH' => "#{version_dir}#{path_divider}#{ENV.fetch('PATH', nil)}"
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_env
|
11
|
+
run_env # not sure if these will ever be different
|
12
|
+
end
|
13
|
+
|
14
|
+
def windows?
|
15
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def path_divider
|
19
|
+
if windows?
|
20
|
+
';'
|
21
|
+
# Linux uses ':' (same with mac/unix?)
|
22
|
+
else
|
23
|
+
':'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/drakkon/lib/settings.rb
CHANGED
@@ -12,13 +12,24 @@ module Drakkon
|
|
12
12
|
|
13
13
|
# Helper to exit if project isn't ready for drakkon usage
|
14
14
|
def self.ready?
|
15
|
-
return if init?
|
15
|
+
return false if init?
|
16
16
|
|
17
17
|
LogBot.warn('Setup', "Drakkon not configured. Run #{'init'.pastel(:green)} first")
|
18
18
|
|
19
19
|
exit 1
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.check_version!
|
23
|
+
return if Hub.version?(version)
|
24
|
+
|
25
|
+
LogBot.warn('Setup', "DragonRuby #{version} not installed.")
|
26
|
+
LogBot.warn('Setup', 'Select a version to use:')
|
27
|
+
|
28
|
+
Version.set
|
29
|
+
|
30
|
+
exit(1) unless Hub.version?(version)
|
31
|
+
end
|
32
|
+
|
22
33
|
def self.prompt
|
23
34
|
TTY::Prompt.new(active_color: :cyan, interrupt: :exit)
|
24
35
|
end
|
@@ -51,6 +62,22 @@ module Drakkon
|
|
51
62
|
config[:image_index]
|
52
63
|
end
|
53
64
|
|
65
|
+
def self.font_index?
|
66
|
+
config[:font_index]
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.sound_index?
|
70
|
+
config[:sound_index]
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.bundle_compile?
|
74
|
+
config[:bundle_compile]
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.manifest_compile?
|
78
|
+
config[:manifest_compile]
|
79
|
+
end
|
80
|
+
|
54
81
|
def self.manifest?
|
55
82
|
config[:manifest]
|
56
83
|
end
|
@@ -59,12 +86,35 @@ module Drakkon
|
|
59
86
|
"#{Dir.pwd}/.drakkon"
|
60
87
|
end
|
61
88
|
|
89
|
+
def self.image_magick_installed?
|
90
|
+
# Use Minimagick's utilities to check if ImageMagick is installed
|
91
|
+
# https://github.com/minimagick/minimagick/pull/193
|
92
|
+
!MiniMagick::Utilities.which('convert').nil?
|
93
|
+
|
94
|
+
# MiniMagick::Image.open('metadata/icon.png')
|
95
|
+
rescue MiniMagick::Invalid, Errno::ENOENT
|
96
|
+
false
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.enable_image_index?
|
100
|
+
return false unless image_magick_installed?
|
101
|
+
|
102
|
+
# TODO: Determine if this should default to True?
|
103
|
+
return true if config[:image_index].nil?
|
104
|
+
|
105
|
+
config[:image_index]
|
106
|
+
end
|
107
|
+
|
62
108
|
def self.config_defaults
|
63
109
|
# Defaults
|
64
110
|
@config[:platforms] ||= []
|
65
111
|
@config[:version] ||= Hub.version_latest
|
66
|
-
@config[:image_index]
|
67
|
-
@config[:manifest]
|
112
|
+
@config[:image_index] = enable_image_index?
|
113
|
+
@config[:manifest] = true if @config[:manifest].nil?
|
114
|
+
@config[:bundle_compile] = true if @config[:bundle_compile].nil?
|
115
|
+
@config[:manifest_compile] = false if @config[:manifest_compile].nil?
|
116
|
+
@config[:font_index] = true if @config[:font_index].nil?
|
117
|
+
@config[:sound_index] = true if @config[:sound_index].nil?
|
68
118
|
@config[:gems] ||= {}
|
69
119
|
end
|
70
120
|
|
@@ -74,8 +124,8 @@ module Drakkon
|
|
74
124
|
|
75
125
|
if @config.nil?
|
76
126
|
@config ||= JSON.parse(File.read(config_file), { symbolize_names: true })
|
77
|
-
# @config ||= Oj.load File.read(config_file)
|
78
127
|
config_defaults
|
128
|
+
write
|
79
129
|
end
|
80
130
|
|
81
131
|
@config
|
@@ -94,7 +144,6 @@ module Drakkon
|
|
94
144
|
def self.write
|
95
145
|
# LogBot.debug('Settings', "Writing Config: #{config_file}")
|
96
146
|
File.write(config_file, JSON.pretty_generate(config))
|
97
|
-
# File.write(config_file, Oj.dump(config))
|
98
147
|
end
|
99
148
|
|
100
149
|
def self.menu
|
@@ -102,7 +151,11 @@ module Drakkon
|
|
102
151
|
menu.choice name: 'platforms', value: :platforms
|
103
152
|
menu.choice name: 'version', value: :version
|
104
153
|
menu.choice name: 'image_index', value: :image_index
|
154
|
+
menu.choice name: 'font_index', value: :font_index
|
155
|
+
menu.choice name: 'sound_index', value: :sound_index
|
105
156
|
menu.choice name: 'manifest', value: :manifest
|
157
|
+
menu.choice name: 'manifest_compile', value: :manifest_compile
|
158
|
+
menu.choice name: 'bundle_compile', value: :bundle_compile
|
106
159
|
menu.choice name: 'exit', value: :exit
|
107
160
|
end
|
108
161
|
rescue TTY::Reader::InputInterrupt
|
@@ -119,6 +172,16 @@ module Drakkon
|
|
119
172
|
Settings.update(:image_index, prompt.yes?("Index Images? (Enabled: #{image_index?})"))
|
120
173
|
when :manifest
|
121
174
|
Settings.update(:image_index, prompt.yes?("Write Manifest? (Enabled: #{manifest?})"))
|
175
|
+
when :bundle_compile
|
176
|
+
Settings.update(:bundle_compile,
|
177
|
+
prompt.yes?("Create Bundle / Compile Gems? (Enabled: #{config[:bundle_compile]})"))
|
178
|
+
when :manifest_compile
|
179
|
+
Settings.update(:manifest_compile,
|
180
|
+
prompt.yes?("Bundle Manifest On Build? (Enabled: #{config[:manifest_compile]})"))
|
181
|
+
when :font_index
|
182
|
+
Settings.update(:font_index, prompt.yes?("Index Fonts? (Enabled: #{config[:font_index]})"))
|
183
|
+
when :sound_index
|
184
|
+
Settings.update(:font_index, prompt.yes?("Index Sounds? (Enabled: #{config[:sound_index]})"))
|
122
185
|
when :exit
|
123
186
|
exit 0
|
124
187
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Sounds
|
3
|
+
# General Sound Index Helper
|
4
|
+
module Index
|
5
|
+
def self.index
|
6
|
+
@index ||= {}
|
7
|
+
|
8
|
+
@index
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.context
|
12
|
+
@context ||= Dir.pwd
|
13
|
+
|
14
|
+
@context
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.catalog
|
18
|
+
# Better way to do this?
|
19
|
+
@catalog ||= Hash.new { |hash, key| hash[key] = Hash.new(&hash.default_proc) }
|
20
|
+
|
21
|
+
@catalog
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.file_list
|
25
|
+
Dir["#{sounds_directory}/**/*"].select { |file| File.file?(file) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.digest
|
29
|
+
Digest::MD5.hexdigest(file_list.map { |x| Digest::MD5.file(x).hexdigest }.join)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.sounds_directory
|
33
|
+
"#{context}/sounds"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.run!(force: false, dir: nil)
|
37
|
+
@context = dir || Dir.pwd
|
38
|
+
|
39
|
+
# Create Directory if sprites directory is missing
|
40
|
+
FileUtils.mkdir_p(sounds_directory)
|
41
|
+
|
42
|
+
if Settings.config[:sound_digest] == digest && File.exist?("#{context}/app/drakkon/sound_index.rb")
|
43
|
+
LogBot.info('Sounds Index', 'Nothing New')
|
44
|
+
return unless force
|
45
|
+
end
|
46
|
+
|
47
|
+
build_index
|
48
|
+
|
49
|
+
Settings.update(:sound_digest, digest)
|
50
|
+
|
51
|
+
File.write("#{context}/app/drakkon/sound_index.rb", result)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.build_index
|
55
|
+
check sounds_directory
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.result
|
59
|
+
<<~RB
|
60
|
+
module Drakkon
|
61
|
+
module Sounds
|
62
|
+
def self.index
|
63
|
+
#{index.inspect}
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.catalog
|
67
|
+
#{catalog.inspect}
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
RB
|
73
|
+
end
|
74
|
+
|
75
|
+
# Recursively Go through
|
76
|
+
def self.check(dir = nil)
|
77
|
+
LogBot.info('Sound Index', "Check: #{dir}")
|
78
|
+
|
79
|
+
# Collect Sounds
|
80
|
+
list = file_list
|
81
|
+
|
82
|
+
# Ignore Empties
|
83
|
+
return if list.empty?
|
84
|
+
|
85
|
+
# Do other things
|
86
|
+
Dir["#{dir}/*"].each do |file|
|
87
|
+
if File.directory?(file)
|
88
|
+
check(file)
|
89
|
+
next
|
90
|
+
end
|
91
|
+
|
92
|
+
process(file)
|
93
|
+
end
|
94
|
+
|
95
|
+
:done
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.process(file = nil)
|
99
|
+
# Safety
|
100
|
+
return if file.nil?
|
101
|
+
|
102
|
+
full_name = file.gsub(sounds_directory, '')[1..].gsub(File.extname(file), '')
|
103
|
+
|
104
|
+
name = File.basename(file, File.extname(file))
|
105
|
+
path = file.gsub(sounds_directory, '')[1..]
|
106
|
+
index[full_name] = path
|
107
|
+
|
108
|
+
details = { path: full_name }
|
109
|
+
tag = WahWah.open(file)
|
110
|
+
details[:duration_s] = tag.duration
|
111
|
+
details[:duration_tick] = tag.duration * 60
|
112
|
+
|
113
|
+
# Catalog
|
114
|
+
catalog_list = path.split('/')[0..-2]
|
115
|
+
catalog_location = []
|
116
|
+
catalog_list.each do |idx|
|
117
|
+
catalog_location.push idx
|
118
|
+
catalog.dig(*catalog_location)
|
119
|
+
end
|
120
|
+
catalog.dig(*catalog_list)[name] = details
|
121
|
+
end
|
122
|
+
# =========================================================
|
123
|
+
end
|
124
|
+
# =========================================================
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Utils
|
3
|
+
# General Entry Point For Images Subcommand
|
4
|
+
module CLI
|
5
|
+
def self.run!(args = [])
|
6
|
+
args ||= []
|
7
|
+
cmd = if args.empty?
|
8
|
+
nil
|
9
|
+
else
|
10
|
+
args.shift.to_sym
|
11
|
+
end
|
12
|
+
start(cmd, args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.start(cmd, args)
|
16
|
+
case cmd
|
17
|
+
when :normalize then Utils::DowncaseNormalize.run!(args)
|
18
|
+
else
|
19
|
+
start(menu, args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.menu
|
24
|
+
prompt.select('Utilties:', filter: true, per_page: 20) do |menu|
|
25
|
+
menu.choice name: 'Rename Files - Normalize [normalize]', value: :normalize
|
26
|
+
end
|
27
|
+
rescue TTY::Reader::InputInterrupt
|
28
|
+
exit 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.prompt
|
32
|
+
TTY::Prompt.new(active_color: :cyan, interrupt: :exit)
|
33
|
+
end
|
34
|
+
# =========================================================
|
35
|
+
end
|
36
|
+
# =========================================================
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Utils
|
3
|
+
# This downcases all the things
|
4
|
+
module DowncaseNormalize
|
5
|
+
def self.run!(_args = nil)
|
6
|
+
puts <<~HELP
|
7
|
+
Usage: Run in the directory you wish to rename files
|
8
|
+
- Downcase
|
9
|
+
- Normalize
|
10
|
+
- To Underscores:
|
11
|
+
- Space
|
12
|
+
- Perentheses
|
13
|
+
- Dash
|
14
|
+
- Remove Double Underscores
|
15
|
+
- Remove Commas
|
16
|
+
- Delete Final Chars
|
17
|
+
- If Underscore
|
18
|
+
Current Directory;
|
19
|
+
#{Dir.pwd.pastel(:yellow)}
|
20
|
+
|
21
|
+
Files:
|
22
|
+
HELP
|
23
|
+
|
24
|
+
files.each do |img|
|
25
|
+
img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
|
26
|
+
puts " - #{img_s}"
|
27
|
+
end
|
28
|
+
puts
|
29
|
+
|
30
|
+
exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Rename!? #{'(Destructive)'.pastel(:red)}"
|
31
|
+
|
32
|
+
start
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.start
|
36
|
+
files.each do |file|
|
37
|
+
process(file)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Image file name normalization. Downcase and replace spaces with underscore, commas, and double underscores
|
42
|
+
def self.process(file)
|
43
|
+
new_name = File.basename(file).downcase.gsub(' ', '_').gsub('(', '_').gsub(')', '_').gsub('-', '_').gsub(',', '_').gsub('__', '_').gsub(
|
44
|
+
'__', '_'
|
45
|
+
)
|
46
|
+
path = File.dirname(file)
|
47
|
+
|
48
|
+
# Remove Final Underscore last char of basename is an underscore
|
49
|
+
ext = File.extname(new_name)
|
50
|
+
basename = File.basename(new_name, ext)
|
51
|
+
if basename[-1] == '_' && basename.length > 1
|
52
|
+
new_name = basename[0..-2]
|
53
|
+
new_name += ext
|
54
|
+
end
|
55
|
+
|
56
|
+
# Skip if the same
|
57
|
+
return if new_name == File.basename(file)
|
58
|
+
|
59
|
+
LogBot.info('Rename Files Normalize', "Old: #{File.basename(file)}, New: #{new_name}")
|
60
|
+
FileUtils.mv(file, "#{path}/#{new_name}")
|
61
|
+
end
|
62
|
+
|
63
|
+
# Select all local dir files
|
64
|
+
def self.files
|
65
|
+
Dir["#{Dir.pwd}/*"]
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.prompt
|
69
|
+
TTY::Prompt.new(active_color: :cyan, interrupt: :exit)
|
70
|
+
end
|
71
|
+
# =========================================================
|
72
|
+
end
|
73
|
+
# =========================================================
|
74
|
+
end
|
75
|
+
end
|
data/lib/drakkon/lib/version.rb
CHANGED
@@ -37,11 +37,25 @@ module Drakkon
|
|
37
37
|
exit(1)
|
38
38
|
end
|
39
39
|
|
40
|
+
# rubocop:disable Metrics/BlockLength
|
40
41
|
Dir.mktmpdir('drakkon-sauce-') do |tmp|
|
41
42
|
# full_path = "#{Dir.pwd}/#{zip}"
|
42
43
|
|
43
|
-
#
|
44
|
-
|
44
|
+
# Unzip install file
|
45
|
+
Zip::File.open(zip) do |zip_file|
|
46
|
+
zip_file.each do |entry|
|
47
|
+
path = File.join(tmp, entry.name)
|
48
|
+
FileUtils.mkdir_p(File.dirname(path))
|
49
|
+
|
50
|
+
next if File.exist?(path)
|
51
|
+
|
52
|
+
# Extract
|
53
|
+
zip_file.extract(entry, path)
|
54
|
+
|
55
|
+
# Preserve Permissions
|
56
|
+
FileUtils.chmod(entry.unix_perms, path)
|
57
|
+
end
|
58
|
+
end
|
45
59
|
|
46
60
|
# Find Dir
|
47
61
|
dr_dir = Dir["#{tmp}/*"].first
|
@@ -78,6 +92,7 @@ module Drakkon
|
|
78
92
|
# Finish
|
79
93
|
LogBot.info('Version', "#{dr_version} Installed!")
|
80
94
|
end
|
95
|
+
# rubocop:enable Metrics/BlockLength
|
81
96
|
end
|
82
97
|
|
83
98
|
def self.prompt
|
data/lib/drakkon/release.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Drakkon
|
2
|
+
# Run Command for CLI
|
3
|
+
module Run
|
4
|
+
# Runnable Terminal Commands
|
5
|
+
module Commands
|
6
|
+
def self.cmd_utils(_args)
|
7
|
+
Utils::Index.run!(force: true, dir: Run.context)
|
8
|
+
end
|
9
|
+
|
10
|
+
# ========================================================================
|
11
|
+
end
|
12
|
+
# ==========================================================================
|
13
|
+
end
|
14
|
+
end
|
data/lib/drakkon/run/helpers.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Drakkon
|
2
2
|
# Run Command for CLI
|
3
3
|
module Run
|
4
|
+
extend PlatformCompat
|
5
|
+
|
4
6
|
def self.index
|
5
7
|
@index ||= build_index
|
6
8
|
@index
|
@@ -18,13 +20,14 @@ module Drakkon
|
|
18
20
|
|
19
21
|
# Exec skips the weird shell stuff
|
20
22
|
def self.run_cmd
|
21
|
-
|
23
|
+
['./dragonruby', @context, *args]
|
22
24
|
# "PATH=#{version_dir}:$PATH exec dragonruby #{@context} > #{log_file}"
|
23
25
|
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
# No longer used
|
28
|
+
# def self.log_file
|
29
|
+
# "#{Hub.dir}/log.txt"
|
30
|
+
# end
|
28
31
|
|
29
32
|
def self.dragonruby(value = nil)
|
30
33
|
@dragonruby ||= value
|
@@ -50,6 +53,14 @@ module Drakkon
|
|
50
53
|
args.include?('manifest')
|
51
54
|
end
|
52
55
|
|
56
|
+
def self.force_fonts?
|
57
|
+
args.include?('fonts')
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.force_sounds?
|
61
|
+
args.include?('sounds')
|
62
|
+
end
|
63
|
+
|
53
64
|
def self.prompt
|
54
65
|
TTY::Prompt.new(active_color: :cyan, interrupt: :exit)
|
55
66
|
end
|
@@ -15,7 +15,7 @@ module TTY
|
|
15
15
|
attr_accessor :line, :breaker
|
16
16
|
|
17
17
|
def read_line(prompt = '', value: '', echo: true, raw: true, nonblock: false)
|
18
|
-
#
|
18
|
+
# Shim:: Store Line
|
19
19
|
self.breaker = false
|
20
20
|
self.line = Line.new(value, prompt: prompt)
|
21
21
|
screen_width = TTY::Screen.width
|
@@ -27,17 +27,17 @@ module TTY
|
|
27
27
|
(code = codes[0])
|
28
28
|
char = codes.pack('U*')
|
29
29
|
|
30
|
-
#
|
30
|
+
# Shim / Back Tab Down Submodule
|
31
31
|
if [:back_tab, :ctrl_c].include? console.keys[char]
|
32
32
|
clear_display(line, screen_width)
|
33
33
|
trigger_key_event(char, line: line.to_s)
|
34
34
|
break
|
35
35
|
end
|
36
36
|
|
37
|
-
#
|
37
|
+
# Shim
|
38
38
|
if EXIT_KEYS.include?(console.keys[char])
|
39
39
|
trigger_key_event(char, line: line.to_s)
|
40
|
-
raise
|
40
|
+
raise TTY::Reader::InputInterrupt
|
41
41
|
end
|
42
42
|
|
43
43
|
clear_display(line, screen_width) if raw && echo
|
@@ -92,7 +92,7 @@ module TTY
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
#
|
95
|
+
# Shim do things
|
96
96
|
next unless [CARRIAGE_RETURN, NEWLINE].include?(code) || breaker
|
97
97
|
|
98
98
|
buffer = ''
|
@@ -103,7 +103,11 @@ module TTY
|
|
103
103
|
add_to_history(line.text.rstrip) if track_history? && echo
|
104
104
|
|
105
105
|
line.text
|
106
|
+
# ===================================
|
107
|
+
rescue
|
108
|
+
puts 'rescue'
|
106
109
|
end
|
110
|
+
# ===================================
|
107
111
|
end
|
108
112
|
end
|
109
113
|
|
data/lib/drakkon/run/tty.rb
CHANGED
data/lib/drakkon/run.rb
CHANGED
@@ -4,6 +4,8 @@ module Drakkon
|
|
4
4
|
# General Run
|
5
5
|
def self.go!(raw)
|
6
6
|
Settings.ready?
|
7
|
+
Settings.check_version!
|
8
|
+
|
7
9
|
args(raw)
|
8
10
|
|
9
11
|
# Save Current Directory before changing to Version Directory
|
@@ -49,7 +51,7 @@ module Drakkon
|
|
49
51
|
# Watch for Updates
|
50
52
|
# ======================================
|
51
53
|
# Force the bundle
|
52
|
-
files = Gems::Bundle.collect.values.flatten
|
54
|
+
files = Gems::Bundle.collect.values.flatten.map(&:path)
|
53
55
|
files.push "#{Run.context}/sprites/" if Settings.image_index?
|
54
56
|
|
55
57
|
Filewatcher.new(files, every: true).watch do |changes|
|
@@ -62,11 +64,13 @@ module Drakkon
|
|
62
64
|
def self.run_setup
|
63
65
|
Images::Index.run!(force: force_images?) if Settings.image_index?
|
64
66
|
Manifest.run!(force: force_manifest?) if Settings.manifest?
|
67
|
+
Fonts::Index.run!(force: force_fonts?) if Settings.font_index?
|
68
|
+
Sounds::Index.run!(force: force_sounds?) if Settings.sound_index?
|
65
69
|
Gems::Bundle.build!(args, @context)
|
66
70
|
end
|
67
71
|
|
68
72
|
def self.runtime
|
69
|
-
@dragonruby = IO.popen(run_cmd)
|
73
|
+
@dragonruby = IO.popen(run_env, run_cmd)
|
70
74
|
end
|
71
75
|
|
72
76
|
def self.restart
|
@@ -14,7 +14,10 @@ module Drakkon
|
|
14
14
|
|
15
15
|
template[:files].each do |files|
|
16
16
|
file_src = "#{template[:path]}/#{files[:source]}"
|
17
|
-
|
17
|
+
unless File.exist?(file_src)
|
18
|
+
LogBot.fatal('Skeleton', "Missing File! File: #{file_src}")
|
19
|
+
exit 0
|
20
|
+
end
|
18
21
|
|
19
22
|
src = File.read(file_src)
|
20
23
|
result = process_variables(src, variables)
|