template.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. def source_paths
  2. [File.expand_path(File.dirname(__FILE__))]
  3. end
  4. def add_users
  5. # Gemfile
  6. gem 'devise', '~> 4.2.1'
  7. gem 'bootstrap-sass', '~> 3.3.6'
  8. # Install Devise
  9. rails_command "generate devise:install"
  10. # Configure Devise
  11. environment "config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }",
  12. env: 'development'
  13. route "root to: 'home#index'"
  14. # Devise notices are installed via Bootstrap
  15. rails_command "generate devise:views User"
  16. # Create Devise User
  17. generate :devise, "User",
  18. "first_name",
  19. "last_name",
  20. "announcements_last_read_at:datetime"
  21. end
  22. def add_bootstrap
  23. # Rename Application SCSS
  24. run "mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss"
  25. # Insert Bootstrap Styling
  26. insert_into_file(
  27. "app/assets/stylesheets/application.scss",
  28. "@import 'bootstrap-sprockets';\n@import 'bootstrap'\n",
  29. after: " */\n"
  30. )
  31. end
  32. def copy_templates
  33. directory "app", force: true
  34. end
  35. def add_webpack
  36. gem 'webpacker', '~> 1.1'
  37. rails_command 'webpacker:install'
  38. end
  39. def add_sidekiq
  40. gem 'sidekiq', '~> 5.0'
  41. environment "config.active_job.queue_adapter = :sidekiq"
  42. end
  43. def add_foreman
  44. gem 'foreman', '~> 0.84.0'
  45. copy_file "Procfile"
  46. end
  47. # Main setup
  48. add_users
  49. add_bootstrap
  50. copy_templates
  51. add_sidekiq
  52. add_foreman
  53. add_webpack
  54. # Migrate
  55. rails_command "db:create"
  56. rails_command "db:migrate"
  57. after_bundle do
  58. git :init
  59. git add: "."
  60. git commit: %Q{ -m 'Initial commit' }
  61. end