Module: Up::CLI
- Defined in:
- lib/up/cli.rb,
lib/up/bun/server_cli.rb,
lib/up/node/server_cli.rb,
lib/up/node/cluster_cli.rb,
lib/up/u_web_socket/server_cli.rb,
lib/up/u_web_socket/cluster_cli.rb
Defined Under Namespace
Classes: Options
Class Method Summary collapse
- .call ⇒ Object
- .get_app(filename = 'config.ru') ⇒ Object
- .get_gems_for_cmd ⇒ Object
- .get_options ⇒ Object
- .stoppable? ⇒ Boolean
- .try_file(filename) ⇒ Object
Instance Method Summary collapse
Class Method Details
.call ⇒ Object
11 12 13 |
# File 'lib/up/bun/server_cli.rb', line 11 def self.call Up::Bun::RackServer.run(get_app, ) end |
.get_app(filename = 'config.ru') ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/up/cli.rb', line 114 def get_app(filename = 'config.ru') app = nil filename ||= 'config.ru' app = try_file(filename) unless app filename = "#{filename}.ru" app = try_file(filename) end raise "Something wrong with #{filename}\n" unless app app end |
.get_gems_for_cmd ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/up/cli.rb', line 95 def get_gems_for_cmd # Opal does not yet support gems, so lets read the Gemfile and simply add each gem # to the Opal load path and require it, works for some gems, fails for others gems = "" if File.exist?("Gemfile") lines = File.readlines('Gemfile') lines.each do |line| m = /gem ['"](\w+)['"]/.match(line) gems << " -g #{m[1]} -r #{m[1]}" if m && m[1] != 'opal-up' end end gems end |
.get_options ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/up/cli.rb', line 86 def = Up::CLI::Options.new .parse! . rescue OptionParser::InvalidOption => e $stderr.puts "#{$0}: #{e.message} (-h will show valid options)" exit 64 end |
.stoppable? ⇒ Boolean
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/up/cli.rb', line 126 def stoppable? sleep 0.1 puts 'deflating request chain links' sleep 0.1 puts 'optimizing response distortion' sleep 0.1 print 'releasing boost pressure: ' 3.times do sleep 0.2 print '.' end 3.times do puts "\n\033[5;31;47mRED ALERT: boost pressure to high, cannot open release valve!1!!!\033[0m" sleep 0.1 print '.' sleep 0.1 end puts 'stopping engines failed, for further help see:' puts 'https://www.youtube.com/watch?v=ecBco63zvas' sleep 0.2 puts "Just kidding :)" true end |
.try_file(filename) ⇒ Object
109 110 111 112 |
# File 'lib/up/cli.rb', line 109 def try_file(filename) return nil unless File.exist? filename ::Rack::Builder.parse_file filename end |
Instance Method Details
#setup_bun ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/up/cli.rb', line 54 def setup_bun bun_cmd = `which bun` if !bun_cmd || bun_cmd.empty? puts "Please install bun first!" exit 2 end true end |
#setup_node ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/up/cli.rb', line 63 def setup_node node_cmd = `which node` if !node_cmd || node_cmd.empty? puts "Please install node first!" exit 2 end true end |
#setup_u_web_socket ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/up/cli.rb', line 72 def setup_u_web_socket setup_node npm_cmd = `which npm` if !npm_cmd || npm_cmd.empty? puts "Please install npm first!" exit 2 end npm_cmd.chop! if npm_cmd.end_with?("\n") have_uws = `npm list|grep uWebSockets.js@20` `npm i uNetworking/uWebSockets.js#v20.41.0` if have_uws.empty? true end |