Class: J1::Commands::Rebuild

Inherits:
J1::Command show all
Defined in:
lib/j1/commands/rebuild.rb

Class Method Summary collapse

Methods inherited from J1::Command

inherited, subclasses

Class Method Details

.init_with_program(prog) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/j1/commands/rebuild.rb', line 9

def init_with_program(prog)
  prog.command(:rebuild) do |c|
    c.description 'Rebuild a J1 Project'
    c.syntax 'rebuild'
    c.action do |args, options|
      J1::Commands::Rebuild.process(args, options)
    end
  end
end

.process(args, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/j1/commands/rebuild.rb', line 19

def process(args, options = {})
  if J1::Utils::is_project?
    if J1::Utils::is_project_setup?
      timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
      J1.logger.info "#{timestamp} - REBUILD: rebuild the projects website .."
      J1.logger.info "#{timestamp} - REBUILD: be patient, this will take a while .."
      process = J1::Utils::Exec2.run('REBUILD','npm', 'run', 'rebuild')
      if process.success?
        J1.logger.info "#{timestamp} - REBUILD: the project has been rebuild successfully."
        J1.logger.info "#{timestamp} - REBUILD: to open the site, run: j1 site"
      else
        raise SystemExit
      end
    else
      raise SystemExit
    end
  else
    raise SystemExit
  end
end