Class: Porous::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/porous/cli/dev.rb,
lib/porous/cli/new.rb,
lib/porous/cli/build.rb,
lib/porous/cli/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/porous/cli/build.rb', line 11

def self.exit_on_failure?
  true
end

.source_rootObject



27
28
29
# File 'lib/porous/cli/new.rb', line 27

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#build(env = :development) ⇒ Object



16
17
18
19
# File 'lib/porous/cli/build.rb', line 16

def build(env = :development)
  empty_directory 'static', verbose: false, force: options[:force]
  Porous::Server::Builder.new(env.to_sym).build
end

#devObject

rubocop:todo Metrics/MethodLength



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/porous/cli/dev.rb', line 10

def dev # rubocop:todo Metrics/MethodLength
  empty_directory 'static/dist', verbose: false, force: options[:force]

  Agoo::Log.configure(
    dir: '',
    console: true,
    classic: true,
    colorize: true,
    states: {
      INFO: true,
      DEBUG: false,
      connect: false,
      request: true,
      response: false,
      eval: false,
      push: false
    }
  )

  Agoo::Server.init 9292, 'static', thread_count: 1, root_first: true
  Agoo::Server.use Rack::ContentLength
  Agoo::Server.use Rack::ShowExceptions

  # Socket Communication
  $socket ||= Porous::Server::Socket.new
  Agoo::Server.handle nil, '/connect', Porous::Server::Connect.new
  # Server-Side Rendering
  Agoo::Server.handle nil, '**', Porous::Server::Application.new
  Agoo::Server.start
  # Live Reload Builder
  Server::Builder.new.build.start
end

#new(project_dir) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/porous/cli/new.rb', line 19

def new(project_dir)
  directory('template', project_dir, project_name: project_dir)

  inside project_dir do
    # run 'bundle install'
  end
end

#serverObject

rubocop:todo Metrics/MethodLength



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/porous/cli/server.rb', line 10

def server # rubocop:todo Metrics/MethodLength
  Agoo::Log.configure(dir: '',
                      console: true,
                      classic: true,
                      colorize: true,
                      states: {
                        INFO: true,
                        DEBUG: false,
                        connect: true,
                        request: true,
                        response: false,
                        eval: false,
                        push: false
                      })

  Agoo::Server.init(
    0, 'static',
    root_first: true,
    thread_count: 0,
    ssl_cert: 'ssl/cert.pem',
    ssl_key: 'ssl/key.pem',
    bind: 'https://:443'
  )
  Agoo::Server.use Rack::ContentLength

  # Socket Communication
  $socket ||= Porous::Server::Socket.new
  Agoo::Server.handle nil, '/connect', Porous::Server::Connect.new
  # Server-Side Rendering
  Agoo::Server.handle nil, '**', Porous::Server::Application.new

  Agoo::Server.start
end