Class: Kaze::Commands::App::HotwireStack

Inherits:
BaseStack
  • Object
show all
Defined in:
lib/kaze/commands/app/hotwire_stack.rb

Instance Method Summary collapse

Instance Method Details

#installObject



2
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
55
56
57
58
59
60
61
62
# File 'lib/kaze/commands/app/hotwire_stack.rb', line 2

def install
  # Gems...
  return unless remove_gems([ 'sprockets-rails', 'stimulus-rails' ])
  return unless install_gems([ 'propshaft', 'view_component', 'tailwindcss-rails', 'turbo-rails', 'dotenv', 'bcrypt' ])
  return unless install_gems([ 'hotwire-livereload' ], 'development')
  return unless install_gems([ 'factory_bot_rails', 'faker' ], 'development, test')

  # Controllers...
  FileUtils.copy_entry("#{stubs_path}/hotwire/app/controllers", "#{Dir.pwd}/app/controllers")

  # Models...
  FileUtils.copy_entry("#{stubs_path}/default/app/models", "#{Dir.pwd}/app/models")

  # Forms...
  ensure_directory_exists("#{Dir.pwd}/app/forms")
  FileUtils.copy_entry("#{stubs_path}/default/app/forms", "#{Dir.pwd}/app/forms")

  # Validators...
  ensure_directory_exists("#{Dir.pwd}/app/validators")
  FileUtils.copy_entry("#{stubs_path}/default/app/validators", "#{Dir.pwd}/app/validators")

  # Mailers...
  ensure_directory_exists("#{Dir.pwd}/app/mailers")
  FileUtils.copy_entry("#{stubs_path}/default/app/mailers", "#{Dir.pwd}/app/mailers")

  # Views...
  ensure_directory_exists("#{Dir.pwd}/app/views/layouts")
  ensure_directory_exists("#{Dir.pwd}/app/views/user_mailer")
  FileUtils.copy_entry("#{stubs_path}/hotwire/app/views", "#{Dir.pwd}/app/views")
  FileUtils.copy_file("#{stubs_path}/default/app/views/layouts/mailer.html.erb", "#{Dir.pwd}/app/views/layouts/mailer.html.erb")
  FileUtils.copy_file("#{stubs_path}/default/app/views/layouts/mailer.text.erb", "#{Dir.pwd}/app/views/layouts/mailer.text.erb")
  FileUtils.copy_entry("#{stubs_path}/default/app/views/user_mailer", "#{Dir.pwd}/app/views/user_mailer")

  # View Components + Alpine...
  ensure_directory_exists("#{Dir.pwd}/app/components")
  FileUtils.copy_entry("#{stubs_path}/hotwire/app/components", "#{Dir.pwd}/app/components")
  ensure_directory_exists("#{Dir.pwd}/app/javascript")
  FileUtils.copy_file("#{stubs_path}/hotwire/app/javascript/application.js", "#{Dir.pwd}/app/javascript/application.js")
  FileUtils.copy_file("#{stubs_path}/hotwire/app/javascript/alpinejs.stub", "#{Dir.pwd}/app/javascript/alpinejs.js")
  FileUtils.copy_file("#{stubs_path}/hotwire/config/importmap.rb", "#{Dir.pwd}/config/importmap.rb")

  # Tests...
  install_tests

  # Routes...
  FileUtils.copy_file("#{stubs_path}/default/config/routes.rb", "#{Dir.pwd}/config/routes.rb")

  # Migrations...
  install_migrations

  # Tailwind...
  FileUtils.copy_file("#{stubs_path}/default/app/assets/stylesheets/application.css", "#{Dir.pwd}/app/assets/stylesheets/application.css")
  FileUtils.copy_file("#{stubs_path}/default/app/assets/stylesheets/application.tailwind.css", "#{Dir.pwd}/app/assets/stylesheets/application.tailwind.css")
  FileUtils.copy_file("#{stubs_path}/hotwire/config/tailwind.config.js", "#{Dir.pwd}/config/tailwind.config.js")
  FileUtils.copy_file("#{stubs_path}/default/bin/dev", "#{Dir.pwd}/bin/dev")
  FileUtils.copy_file("#{stubs_path}/default/Procfile.dev", "#{Dir.pwd}/Procfile.dev")
  run_command("#{Dir.pwd}/bin/rails tailwindcss:build")

  say ''
  say 'Kaze scaffolding installed successfully.', :green
end