template.rb 1.5 KB

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