drakkon 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +50 -0
- data/bin/drakkon +16 -0
- data/lib/drakkon/build.rb +126 -0
- data/lib/drakkon/cli.rb +64 -0
- data/lib/drakkon/gem/bundle.rb +116 -0
- data/lib/drakkon/gem/cli.rb +46 -0
- data/lib/drakkon/gem/configure.rb +73 -0
- data/lib/drakkon/gem/gem.rb +56 -0
- data/lib/drakkon/gem/helpers/check.rb +110 -0
- data/lib/drakkon/gem/helpers/files.rb +57 -0
- data/lib/drakkon/gem/helpers/general.rb +21 -0
- data/lib/drakkon/gem/helpers/modules.rb +51 -0
- data/lib/drakkon/gem/helpers/source.rb +43 -0
- data/lib/drakkon/gem/install.rb +24 -0
- data/lib/drakkon/init.rb +85 -0
- data/lib/drakkon/lib/hub.rb +112 -0
- data/lib/drakkon/lib/images/biggest.rb +43 -0
- data/lib/drakkon/lib/images/blur.rb +76 -0
- data/lib/drakkon/lib/images/bulk_rename.rb +86 -0
- data/lib/drakkon/lib/images/canvas.rb +74 -0
- data/lib/drakkon/lib/images/cli.rb +78 -0
- data/lib/drakkon/lib/images/desaturate.rb +58 -0
- data/lib/drakkon/lib/images/flip_flop.rb +76 -0
- data/lib/drakkon/lib/images/gif.rb +61 -0
- data/lib/drakkon/lib/images/index.rb +185 -0
- data/lib/drakkon/lib/images/list.rb +56 -0
- data/lib/drakkon/lib/images/modulate.rb +69 -0
- data/lib/drakkon/lib/images/resize.rb +83 -0
- data/lib/drakkon/lib/images/roll.rb +68 -0
- data/lib/drakkon/lib/images/rotate.rb +60 -0
- data/lib/drakkon/lib/images/scale.rb +86 -0
- data/lib/drakkon/lib/images/sepia.rb +64 -0
- data/lib/drakkon/lib/images/shift.rb +89 -0
- data/lib/drakkon/lib/images/split.rb +93 -0
- data/lib/drakkon/lib/images/spritesheet.rb +85 -0
- data/lib/drakkon/lib/images/trim.rb +56 -0
- data/lib/drakkon/lib/images/white.rb +56 -0
- data/lib/drakkon/lib/logbot.rb +86 -0
- data/lib/drakkon/lib/manifest.rb +74 -0
- data/lib/drakkon/lib/pastel.rb +49 -0
- data/lib/drakkon/lib/settings.rb +130 -0
- data/lib/drakkon/lib/shims.rb +8 -0
- data/lib/drakkon/lib/version.rb +79 -0
- data/lib/drakkon/release.rb +3 -0
- data/lib/drakkon/run/commands/images.rb +14 -0
- data/lib/drakkon/run/commands/log.rb +57 -0
- data/lib/drakkon/run/commands/restart.rb +14 -0
- data/lib/drakkon/run/helpers.rb +60 -0
- data/lib/drakkon/run/reader_shim.rb +110 -0
- data/lib/drakkon/run/tty.rb +119 -0
- data/lib/drakkon/run.rb +80 -0
- data/lib/drakkon/setup.rb +31 -0
- data/lib/drakkon/skeleton/cli.rb +46 -0
- data/lib/drakkon/skeleton/deploy.rb +105 -0
- data/lib/drakkon/skeleton/helpers/check.rb +143 -0
- data/lib/drakkon/skeleton/helpers/general.rb +21 -0
- data/lib/drakkon/skeleton/helpers/source.rb +43 -0
- data/lib/drakkon/skeleton/install.rb +31 -0
- data/lib/drakkon/skeleton/template.rb +14 -0
- data/lib/drakkon/web.rb +68 -0
- data/lib/drakkon.rb +43 -0
- metadata +302 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
module Drakkon
|
2
|
+
# Run Command for CLI
|
3
|
+
module Run
|
4
|
+
# Command Processing
|
5
|
+
def self.run
|
6
|
+
return true if @list.empty?
|
7
|
+
|
8
|
+
cmd = @list.shift
|
9
|
+
if index.include? cmd
|
10
|
+
Commands.send("cmd_#{cmd}".to_sym, @list)
|
11
|
+
else
|
12
|
+
puts "Unknown Command: '#{cmd.pastel(:red)}'"
|
13
|
+
puts
|
14
|
+
puts "Available Commands: #{index.join(', ').pastel(:green)}"
|
15
|
+
end
|
16
|
+
rescue StandardError => e
|
17
|
+
LogBot.fatal('CLI Run', e.message)
|
18
|
+
puts e.backtrace[0..4].join("\n").pastel(:red)
|
19
|
+
end
|
20
|
+
|
21
|
+
# CLI Start
|
22
|
+
def self.cli
|
23
|
+
# Initial Log Follow
|
24
|
+
Commands.send(:cmd_tail, [])
|
25
|
+
|
26
|
+
value ||= '' # Empty Start
|
27
|
+
|
28
|
+
loop do
|
29
|
+
line = reader.read_line(readline_notch, value:)
|
30
|
+
value = '' # Remove Afterwards
|
31
|
+
|
32
|
+
if reader.breaker
|
33
|
+
value = line
|
34
|
+
puts ''
|
35
|
+
next
|
36
|
+
end
|
37
|
+
|
38
|
+
break if line =~ /^exit/i
|
39
|
+
|
40
|
+
process
|
41
|
+
run
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.reader
|
46
|
+
@reader ||= reader_setup
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.reader_setup
|
50
|
+
reader = TTY::Reader.new(history_duplicates: false, interrupt: -> { back })
|
51
|
+
|
52
|
+
# Blank?
|
53
|
+
reader.add_to_history ''
|
54
|
+
|
55
|
+
# Remove Line
|
56
|
+
reader.on(:keyctrl_u) do |_event|
|
57
|
+
reader.line.remove reader.line.text.size
|
58
|
+
end
|
59
|
+
|
60
|
+
# Navigate Word Left
|
61
|
+
reader.on(:keyctrl_left) { reader.line.move_word_left }
|
62
|
+
|
63
|
+
# Navigate Word Right
|
64
|
+
reader.on(:keyctrl_right) { reader.line.move_word_right }
|
65
|
+
|
66
|
+
# Navigate Beginning
|
67
|
+
reader.on(:keyctrl_a) { reader.line.move_to_start }
|
68
|
+
|
69
|
+
# Navigate End
|
70
|
+
reader.on(:keyctrl_e) { reader.line.move_to_end }
|
71
|
+
|
72
|
+
reader.on(:keyback_tab) { back }
|
73
|
+
|
74
|
+
# TODO: Keytab?
|
75
|
+
# reader.on(:keytab) do
|
76
|
+
# process
|
77
|
+
# auto
|
78
|
+
# end
|
79
|
+
|
80
|
+
reader.instance_variable_get(:@history)
|
81
|
+
|
82
|
+
# DEBUG PRY
|
83
|
+
reader.on(:keyctrl_p) do |event|
|
84
|
+
binding.pry
|
85
|
+
# rubocop:enable Lint/Debugger
|
86
|
+
end
|
87
|
+
|
88
|
+
reader
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.back
|
92
|
+
# puts 'clear'
|
93
|
+
raise Interrupt
|
94
|
+
end
|
95
|
+
|
96
|
+
# Auto/Run Process - Populate and parse: @list
|
97
|
+
def self.process
|
98
|
+
line = reader.line
|
99
|
+
@list = Shellwords.split line.text
|
100
|
+
rescue StandardError => e
|
101
|
+
puts "#{'Invalid Command'.pastel(:red)}: #{e.message.pastel(:green)}"
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.cursor
|
105
|
+
@cursor ||= TTY::Cursor
|
106
|
+
|
107
|
+
@cursor
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.logs
|
111
|
+
@logs ||= []
|
112
|
+
|
113
|
+
@logs
|
114
|
+
end
|
115
|
+
|
116
|
+
#=======================================================
|
117
|
+
end
|
118
|
+
#=======================================================
|
119
|
+
end
|
data/lib/drakkon/run.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
module Drakkon
|
2
|
+
# Run Command for CLI
|
3
|
+
module Run
|
4
|
+
# General Run
|
5
|
+
def self.go!(raw)
|
6
|
+
Settings.ready?
|
7
|
+
args(raw)
|
8
|
+
|
9
|
+
# Save Current Directory before changing to Version Directory
|
10
|
+
@context = Dir.pwd
|
11
|
+
|
12
|
+
run_setup
|
13
|
+
|
14
|
+
watcher!
|
15
|
+
|
16
|
+
# Yes... Run.run!
|
17
|
+
Dir.chdir(version_dir) do
|
18
|
+
runtime
|
19
|
+
cli
|
20
|
+
end
|
21
|
+
|
22
|
+
# Finish
|
23
|
+
rescue SystemExit, Interrupt
|
24
|
+
LogBot.info('Run', 'Exiting')
|
25
|
+
puts
|
26
|
+
exit
|
27
|
+
ensure
|
28
|
+
Process.kill('TERM', dragonruby&.pid) if dragonruby
|
29
|
+
watcher&.kill
|
30
|
+
end
|
31
|
+
|
32
|
+
# Helper for external access
|
33
|
+
def self.context
|
34
|
+
@context ||= Dir.pwd
|
35
|
+
|
36
|
+
@context
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.watcher!
|
40
|
+
@watcher = Thread.new { watch }
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.watcher
|
44
|
+
@watcher
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.watch
|
48
|
+
# ======================================
|
49
|
+
# Watch for Updates
|
50
|
+
# ======================================
|
51
|
+
# Force the bundle
|
52
|
+
files = Gems::Bundle.collect.values.flatten
|
53
|
+
files.push "#{Run.context}/sprites/" if Settings.image_index?
|
54
|
+
|
55
|
+
Filewatcher.new(files, every: true).watch do |changes|
|
56
|
+
sleep 1 # Sleep to prevent exceptions?
|
57
|
+
Images::Index.run!(force: true, dir: Run.context) if changes.keys.find { |x| x.include? 'sprites/' }
|
58
|
+
Gems::Bundle.build!(['bundle'], @context)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.run_setup
|
63
|
+
Images::Index.run!(force: force_images?) if Settings.image_index?
|
64
|
+
Manifest.run!(force: force_manifest?) if Settings.manifest?
|
65
|
+
Gems::Bundle.build!(args, @context)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.runtime
|
69
|
+
@dragonruby = IO.popen(run_cmd)
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.restart
|
73
|
+
Process.kill('TERM', dragonruby&.pid)
|
74
|
+
runtime
|
75
|
+
end
|
76
|
+
|
77
|
+
#=======================================================
|
78
|
+
end
|
79
|
+
#=======================================================
|
80
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Drakkon
|
2
|
+
# Run Command for CLI
|
3
|
+
module Setup
|
4
|
+
# General Run
|
5
|
+
def self.go!(_raw = nil)
|
6
|
+
Settings.ready?
|
7
|
+
|
8
|
+
loop do
|
9
|
+
Settings.menu_do Settings.menu
|
10
|
+
end
|
11
|
+
rescue SystemExit, Interrupt
|
12
|
+
LogBot.info('Init', 'Exiting')
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.prompt
|
17
|
+
TTY::Prompt.new(active_color: :cyan)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.basic_directories
|
21
|
+
['app', 'fonts', 'metadata', 'fonts', 'sounds', 'sprites', 'app/drakkon'].each do |dir|
|
22
|
+
next if Dir.exist?(dir)
|
23
|
+
|
24
|
+
Dir.mkdir dir
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#=======================================================
|
29
|
+
end
|
30
|
+
#=======================================================
|
31
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Skeleton
|
3
|
+
# Run Command for CLI
|
4
|
+
module CLI
|
5
|
+
def self.args(raw = [])
|
6
|
+
@args ||= raw
|
7
|
+
|
8
|
+
@args
|
9
|
+
end
|
10
|
+
|
11
|
+
# General Run
|
12
|
+
def self.init!(raw)
|
13
|
+
args(raw)
|
14
|
+
cmd = args.shift
|
15
|
+
|
16
|
+
start(cmd&.to_sym)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.start(cmd)
|
20
|
+
case cmd
|
21
|
+
when :install then Skeleton::Install.new(args)
|
22
|
+
when :deploy then Skeleton::Deploy.start(args)
|
23
|
+
|
24
|
+
else
|
25
|
+
start(menu)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.prompt
|
30
|
+
TTY::Prompt.new(active_color: :cyan)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.menu
|
34
|
+
prompt.select('Wat do?', filter: true) do |menu|
|
35
|
+
menu.choice name: 'install (New Templates)', value: :install
|
36
|
+
menu.choice name: 'deploy', value: :deploy if Hub.skeletons?
|
37
|
+
end
|
38
|
+
rescue TTY::Reader::InputInterrupt
|
39
|
+
exit 0
|
40
|
+
end
|
41
|
+
|
42
|
+
#=======================================================
|
43
|
+
end
|
44
|
+
#=======================================================
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Skeleton
|
3
|
+
# Run Command for CLI
|
4
|
+
module Deploy
|
5
|
+
def self.start(args)
|
6
|
+
name = args.shift&.to_sym
|
7
|
+
name = skeleton_select if name.nil?
|
8
|
+
|
9
|
+
template_name = args.shift
|
10
|
+
template = collect_skeleton_templates(name.to_sym).find { |x| x[:name] == template_name } if template_name
|
11
|
+
template = skeleton_template_select(name) if template.nil?
|
12
|
+
|
13
|
+
variables = collect_variables(template)
|
14
|
+
|
15
|
+
template[:files].each do |files|
|
16
|
+
file_src = "#{template[:path]}/#{files[:source]}"
|
17
|
+
raise 'Missing File!' unless File.exist?(file_src)
|
18
|
+
|
19
|
+
src = File.read(file_src)
|
20
|
+
result = process_variables(src, variables)
|
21
|
+
|
22
|
+
# Assume Src is Target Unless specified
|
23
|
+
files[:target] ||= files[:source]
|
24
|
+
|
25
|
+
# Allow for Dynamic Targets
|
26
|
+
target = process_variables(files[:target], variables)
|
27
|
+
|
28
|
+
# Map Names
|
29
|
+
target = target.downcase if files[:downcase]
|
30
|
+
|
31
|
+
# Create Subdirectories as needed
|
32
|
+
FileUtils.mkdir_p File.dirname(target)
|
33
|
+
File.write(target, result)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.process_variables(src, variables)
|
38
|
+
result = src.clone
|
39
|
+
variables.each do |key, value|
|
40
|
+
result.gsub!(/DRAKKON_#{key}/, value)
|
41
|
+
end
|
42
|
+
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.collect_variables(template)
|
47
|
+
variables = {}
|
48
|
+
template[:variables].each do |var|
|
49
|
+
question = var[:prompt] || var[:key]
|
50
|
+
variables[var[:key].to_sym] = prompt.ask(question, **var[:ask])
|
51
|
+
end
|
52
|
+
|
53
|
+
variables
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.skeleton_select
|
57
|
+
prompt.select('Which Skeleton?', filter: true, per_page: 25) do |menu|
|
58
|
+
Hub.skeletons.each_key { |sk| menu.choice name: sk, value: sk }
|
59
|
+
end
|
60
|
+
rescue TTY::Reader::InputInterrupt
|
61
|
+
exit 0
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.collect_skeleton_templates(name)
|
65
|
+
data = Hub.skeletons[name]
|
66
|
+
Hub.skeletons[name][:templates].map do |template_name|
|
67
|
+
template_config_file = case data[:source].to_sym
|
68
|
+
when :local
|
69
|
+
"#{data[:path]}/#{template_name}/skeleton.json"
|
70
|
+
end
|
71
|
+
|
72
|
+
template_config = JSON.parse(File.read(template_config_file), { symbolize_names: true })
|
73
|
+
template_config[:path] = case data[:source].to_sym
|
74
|
+
when :local
|
75
|
+
"#{data[:path]}/#{template_name}"
|
76
|
+
end
|
77
|
+
|
78
|
+
template_config
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.skeleton_template_select(name)
|
83
|
+
templates = collect_skeleton_templates(name)
|
84
|
+
|
85
|
+
prompt.select('Which Template?', filter: true, per_page: 25) do |menu|
|
86
|
+
templates.each do |template|
|
87
|
+
name = template[:name].pastel(:bright_blue)
|
88
|
+
name += " - #{template[:description]}".pastel(:bright_black)
|
89
|
+
|
90
|
+
menu.choice name:, value: template
|
91
|
+
end
|
92
|
+
end
|
93
|
+
rescue TTY::Reader::InputInterrupt
|
94
|
+
exit 0
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.prompt
|
98
|
+
TTY::Prompt.new(active_color: :cyan)
|
99
|
+
end
|
100
|
+
|
101
|
+
#=======================================================
|
102
|
+
end
|
103
|
+
#=======================================================
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Skeleton
|
3
|
+
# General Helpers for Skeleton Class
|
4
|
+
module InstallHelpers
|
5
|
+
def do_the_check
|
6
|
+
unless File.exist? config_file
|
7
|
+
LogBot.fatal('Skeleton', "Drakkon config file not found! #{config_file}")
|
8
|
+
exit 0
|
9
|
+
end
|
10
|
+
|
11
|
+
# Validate Config Structure
|
12
|
+
read_config
|
13
|
+
|
14
|
+
# Valid Structure - Name
|
15
|
+
valid_structure?
|
16
|
+
|
17
|
+
# Validate / Find Valid Templates
|
18
|
+
load_templates
|
19
|
+
|
20
|
+
# TODO: Some other system for dyanmic reloads?
|
21
|
+
# if Hub.config[:skeletons].key?(name)
|
22
|
+
# LogBot.fatal('Skeleton', "Duplicate Skeleton already installed: #{name}")
|
23
|
+
# exit 0
|
24
|
+
# end
|
25
|
+
|
26
|
+
# I hate the other syntax
|
27
|
+
:return
|
28
|
+
end
|
29
|
+
|
30
|
+
def valid_structure?
|
31
|
+
unless config.key? :name
|
32
|
+
LogBot.fatal('Skeleton', 'Name not found!')
|
33
|
+
exit 0
|
34
|
+
end
|
35
|
+
|
36
|
+
@name = config[:name].to_sym
|
37
|
+
|
38
|
+
# Validate Versioning
|
39
|
+
valid_version?
|
40
|
+
end
|
41
|
+
|
42
|
+
def valid_version?
|
43
|
+
unless config.key? :version
|
44
|
+
LogBot.fatal('Skeleton', 'Version not found')
|
45
|
+
exit 0
|
46
|
+
end
|
47
|
+
|
48
|
+
Semantic::Version.new config[:version]
|
49
|
+
rescue StandardError => e
|
50
|
+
LogBot.fatal('Skeleton',
|
51
|
+
"Invalid Version: #{config[:version].pastel.to_s.pastel(:green)}; #{e.message.pastel(:yellow)}")
|
52
|
+
exit 0
|
53
|
+
end
|
54
|
+
|
55
|
+
def load_templates
|
56
|
+
@templates = config[:templates].select do |template|
|
57
|
+
valid_template?(template)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
62
|
+
def valid_template?(template_name)
|
63
|
+
# TODO: Implement other sources
|
64
|
+
template_config_file = case source
|
65
|
+
when :local
|
66
|
+
"#{data[:path]}/#{template_name}/skeleton.json"
|
67
|
+
end
|
68
|
+
|
69
|
+
template_config = JSON.parse(File.read(template_config_file), { symbolize_names: true })
|
70
|
+
|
71
|
+
case source
|
72
|
+
when :local
|
73
|
+
template_config[:path] = "#{data[:path]}/#{template_name}"
|
74
|
+
end
|
75
|
+
|
76
|
+
unless template_config.key?(:name)
|
77
|
+
LogBot.fatal('Skeleton', "Invalid Template. No name found: #{template_name}")
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
|
81
|
+
unless template_config.key?(:description)
|
82
|
+
LogBot.fatal('Skeleton', "Invalid Template. No description found: #{template_name}")
|
83
|
+
return false
|
84
|
+
end
|
85
|
+
|
86
|
+
if template_config.key?(:variables) && template_config[:variables].is_a?(Array)
|
87
|
+
# Preserve Nest cause line is nasty
|
88
|
+
unless template_config[:variables].all? { |x| x.is_a? Hash }
|
89
|
+
LogBot.fatal('Skeleton', "Invalid Template Variables: #{template_name}")
|
90
|
+
return false
|
91
|
+
end
|
92
|
+
|
93
|
+
:do_something_else
|
94
|
+
end
|
95
|
+
|
96
|
+
unless template_config.key?(:files)
|
97
|
+
LogBot.fatal('Skeleton', "Incomplete Template. Files Not Found: #{template_name}")
|
98
|
+
return false
|
99
|
+
end
|
100
|
+
|
101
|
+
if template_config[:files].empty?
|
102
|
+
LogBot.fatal('Skeleton', "Invalid Template. Files Empty: #{template_name}")
|
103
|
+
return false
|
104
|
+
end
|
105
|
+
|
106
|
+
unless template_config[:files].all? { |x| x.is_a?(Hash) }
|
107
|
+
LogBot.fatal('Skeleton', "Invalid Template Files. Should all be hashes: #{template_name}")
|
108
|
+
LogBot.fatal('Skeleton', "Template Details: #{template_config[:files]}")
|
109
|
+
return false
|
110
|
+
end
|
111
|
+
|
112
|
+
# TODO: Potentially Other Validation
|
113
|
+
unless template_config[:files].all? do |file|
|
114
|
+
# Root
|
115
|
+
full_path = "#{template_config[:path]}/#{file[:source]}"
|
116
|
+
|
117
|
+
if File.exist?(full_path)
|
118
|
+
true
|
119
|
+
else
|
120
|
+
LogBot.fatal('Skeleton', "Invalid Template File #{file}. Source File Missing: #{template_name}")
|
121
|
+
false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
LogBot.fatal('Skeleton', "Invalid Template File. Source Files Missing: #{template_name}")
|
126
|
+
return false
|
127
|
+
end
|
128
|
+
|
129
|
+
# TODO: Individual Validate
|
130
|
+
# unless files_exist?(template[:files])
|
131
|
+
# LogBot.warn('Skeleton', "Invalid Template: Not all files found: #{template_name}")
|
132
|
+
# return false
|
133
|
+
# end
|
134
|
+
|
135
|
+
true
|
136
|
+
end
|
137
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
138
|
+
|
139
|
+
# =============================================================
|
140
|
+
end
|
141
|
+
# =============================================================
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Skeleton
|
3
|
+
# General Helpers for Gem Class
|
4
|
+
module InstallHelpers
|
5
|
+
def prompt
|
6
|
+
TTY::Prompt.new(active_color: :cyan)
|
7
|
+
end
|
8
|
+
|
9
|
+
def read_config
|
10
|
+
@config = JSON.parse(File.read(config_file), { symbolize_names: true })
|
11
|
+
end
|
12
|
+
|
13
|
+
def config_file
|
14
|
+
"#{data[:path]}/drakkon.json"
|
15
|
+
end
|
16
|
+
|
17
|
+
# =============================================================
|
18
|
+
end
|
19
|
+
# =============================================================
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Skeleton
|
3
|
+
# General Helpers for Gem Class
|
4
|
+
module InstallHelpers
|
5
|
+
def source_setup
|
6
|
+
@source = source?(args.shift).to_sym
|
7
|
+
|
8
|
+
case source
|
9
|
+
when :local
|
10
|
+
data[:path] = path?(args.shift)
|
11
|
+
# Using Name within package
|
12
|
+
# @id = "#{source}--#{data[:path]}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def source?(source)
|
17
|
+
return source if sources.include?(source)
|
18
|
+
|
19
|
+
prompt.select('Skeleton Source?', sources, filter: true)
|
20
|
+
end
|
21
|
+
|
22
|
+
def sources
|
23
|
+
[
|
24
|
+
'local'
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
def path?(path)
|
29
|
+
return path unless path.nil?
|
30
|
+
|
31
|
+
loop do
|
32
|
+
dir = prompt.ask('Local Path? (e.g. /data/skeleton/location)')
|
33
|
+
|
34
|
+
return dir if File.directory?(dir)
|
35
|
+
|
36
|
+
LogBot.fatal('Gem', "Invalid Directory / Not found! #{dir.pastel(:red)}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
# =============================================================
|
40
|
+
end
|
41
|
+
# =============================================================
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Skeleton
|
3
|
+
# Run Command for CLI
|
4
|
+
class Install
|
5
|
+
include InstallHelpers
|
6
|
+
attr_accessor :args, :source, :data, :config, :name
|
7
|
+
|
8
|
+
def initialize(args = [])
|
9
|
+
@args = args
|
10
|
+
@data = {}
|
11
|
+
source_setup
|
12
|
+
do_the_check
|
13
|
+
save!
|
14
|
+
end
|
15
|
+
|
16
|
+
def save!
|
17
|
+
details = {
|
18
|
+
**data,
|
19
|
+
**config,
|
20
|
+
source:
|
21
|
+
}
|
22
|
+
|
23
|
+
Hub.config.skeletons[name] = details
|
24
|
+
Hub.write
|
25
|
+
end
|
26
|
+
|
27
|
+
#=======================================================
|
28
|
+
end
|
29
|
+
#=======================================================
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Drakkon
|
2
|
+
module Skeleton
|
3
|
+
# Run Command for CLI
|
4
|
+
class Template
|
5
|
+
attr_accessor :opts
|
6
|
+
|
7
|
+
def initialize(opts = {})
|
8
|
+
@opts = opts
|
9
|
+
end
|
10
|
+
#=======================================================
|
11
|
+
end
|
12
|
+
#=======================================================
|
13
|
+
end
|
14
|
+
end
|
data/lib/drakkon/web.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
module Drakkon
|
2
|
+
# Web Helper
|
3
|
+
module Web
|
4
|
+
# Free running
|
5
|
+
def self.run!(_args = [])
|
6
|
+
# Web::Runny.run!
|
7
|
+
|
8
|
+
# Save Current Directory before changing to Version Directory
|
9
|
+
@context = Dir.pwd
|
10
|
+
|
11
|
+
# Yes... Run.run!
|
12
|
+
Dir.chdir(Run.version_dir) do
|
13
|
+
system run_cmd
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.runtime
|
18
|
+
@dragonruby = IO.popen(run_cmd)
|
19
|
+
|
20
|
+
# @dragonruby = Process.spawn run_cmd
|
21
|
+
end
|
22
|
+
|
23
|
+
# Exec skips the weird shell stuff
|
24
|
+
def self.run_cmd
|
25
|
+
"PATH=#{Run.version_dir}:$PATH exec dragonruby-httpd #{@context} 8000"
|
26
|
+
end
|
27
|
+
|
28
|
+
# ==========================================================================
|
29
|
+
end
|
30
|
+
# ==========================================================================
|
31
|
+
end
|
32
|
+
|
33
|
+
# set :port, 4567
|
34
|
+
# set :bind, '0.0.0.0'
|
35
|
+
# set :server, :puma
|
36
|
+
# set :show_exceptions, false
|
37
|
+
# disable :logging # Duplicate Log Entries
|
38
|
+
# set :dump_errors, false # Duplicate Eception Dumping
|
39
|
+
|
40
|
+
# use Rack::CommonLogger
|
41
|
+
|
42
|
+
module Drakkon
|
43
|
+
module Web
|
44
|
+
# WebApp
|
45
|
+
class Runny < Sinatra::Base
|
46
|
+
configure do
|
47
|
+
set :public_folder, Dir.pwd
|
48
|
+
end
|
49
|
+
|
50
|
+
# I hate you Cors
|
51
|
+
enable :cross_origin
|
52
|
+
before do
|
53
|
+
response.headers['Access-Control-Allow-Origin'] = '*'
|
54
|
+
response.headers['Access-Control-Allow-Headers'] = '*'
|
55
|
+
response.headers['Access-Control-Allow-Methods'] = 'GET,PUT,POST,PATCH,DELETE,OPTIONS'
|
56
|
+
|
57
|
+
response.headers['Cross-Origin-Opener-Policy'] = 'same-origin'
|
58
|
+
response.headers['Cross-Origin-Embedder-Policy'] = 'require-corp'
|
59
|
+
end
|
60
|
+
|
61
|
+
get '/' do
|
62
|
+
File.read(File.join(settings.public_folder, 'index.html'))
|
63
|
+
end
|
64
|
+
# ========================================================================
|
65
|
+
end
|
66
|
+
# ==========================================================================
|
67
|
+
end
|
68
|
+
end
|