template.rb 1.5 KB

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