Class: Granule::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/granule/cli.rb

Constant Summary collapse

DEFAULT_OPTIONS =
'--skip-bundle --skip-webpack-install --skip-test --database=postgresql '\
'--webpack=react'\
"--skip-turbolinks -m #{File.dirname __dir__}/granule/new/base.rb"

Instance Method Summary collapse

Instance Method Details

#feature(name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/granule/cli.rb', line 38

def feature(name)
  service = {
    "semantic-react": Granule::Feature::SemanticReact,
    "semantic-devise": Granule::Feature::DeviseSemantic
  }[name.to_sym]

  return unless service

  service.new.call
end

#new(name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/granule/cli.rb', line 16

def new(name)
  cmd = "rails new #{name} #{DEFAULT_OPTIONS}"

  run(cmd)

  insert_into_file "./#{name}/config/environments/development.rb", after: "Rails.application.configure do\n" do
    <<-RUBY
  # Ignore warnings while in docker environemnts
  config.web_console.whiny_requests = false

    RUBY
  end

  insert_into_file "./#{name}/config/routes.rb", after: "Rails.application.routes.draw do\n" do
    <<-RUBY
  resources :pages

    RUBY
  end
end