Class: DevSystem::NewGenerator

Inherits:
SimpleGenerator show all
Defined in:
lib/dev_system/sub/generator/generators/new_generator.rb

Instance Attribute Summary

Attributes inherited from BaseGenerator

#env

Instance Method Summary collapse

Methods inherited from SimpleGenerator

#add_change, #changes, #copy_examples, #copy_file, #copy_files, #create_controller, #create_file, #create_unit, #inform, #last_change, #name!, #place!, #puts_line, #save

Methods inherited from BaseGenerator

#args, #call, call, #command, get_generator_signatures, #inform, #save

Methods inherited from Generator

get_generator_signatures

Methods inherited from Liza::Controller

color, inherited, on_connected

Methods inherited from Liza::Unit

const_missing, division, part, system, #system, test_class

Instance Method Details

#call_defaultObject



3
4
5
6
7
8
9
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
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/dev_system/sub/generator/generators/new_generator.rb', line 3

def call_default
  log "args = #{args.inspect}"
  # setup

  name = args.shift || "app_1"

  from = "#{Lizarb::APP_DIR}/examples/new"
  log "from: #{from}"
  to = "#{Dir.pwd}/#{name}"

  return log "Directory #{to.light_green} already exists." if Dir.exist? to

  log "Liza Application initializing at `#{to}`"

  # app

  FileUtils.cp_r from, to, verbose: true

  # extra

  puts

  FileShell.gitkeep "#{to}/lib"
  FileShell.gitkeep "#{to}/tmp"

  TextShell.write "#{to}/.gitignore", render(:gitignore, format: :gitignore)
  # TextShell.write "#{to}/Procfile", render(:Procfile, format: :yml)
  TextShell.write "#{to}/.tool-versions", render(:toolversions, format: :txt)

  FileUtils.cp_r "#{Lizarb::APP_DIR}/README.md",
                 "#{to}/README.md",
                 verbose: true
  # FileUtils.cp_r "#{Lizarb::APP_DIR}/web_files",
  #                "#{to}/web_files",
  #                verbose: true

  puts

  KernelShell.call_backticks \
    "cd #{to}; liza generate gemfile +confirm",
    log_level: :normal

  KernelShell.call_backticks \
    "cd #{to}; BUNDLE_GEMFILE=Gemfile bundle install",
    log_level: :normal

  KernelShell.call_backticks \
    "cd #{to}; git init -b main; git add .; git commit -m 'lizarb new app_1 (v#{Lizarb::VERSION})'",
    log_level: :normal

  log "Liza Application initialized at `#{to}`"
end