template.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. "admin:boolean"
  21. # Set admin default to false
  22. in_root do
  23. migration = Dir.glob("db/migrate/*").max_by{ |f| File.mtime(f) }
  24. gsub_file migration, /:admin/, ":admin, default: false"
  25. end
  26. end
  27. def add_bootstrap
  28. gem 'jquery-rails', '~> 4.3.1'
  29. gem 'bootstrap-sass', '~> 3.3.6'
  30. # Remove Application CSS
  31. run "rm app/assets/stylesheets/application.css"
  32. # Add Bootstrap JS
  33. insert_into_file(
  34. "app/assets/javascripts/application.js",
  35. "\n//= require jquery\n//= require bootstrap",
  36. after: "//= require rails-ujs"
  37. )
  38. end
  39. def copy_templates
  40. directory "app", force: true
  41. end
  42. def add_webpack
  43. gem 'webpacker', '~> 1.1'
  44. rails_command 'webpacker:install'
  45. end
  46. def add_sidekiq
  47. gem 'sidekiq', '~> 5.0'
  48. environment "config.active_job.queue_adapter = :sidekiq"
  49. end
  50. def add_foreman
  51. gem 'foreman', '~> 0.84.0'
  52. copy_file "Procfile"
  53. end
  54. # Main setup
  55. add_users
  56. add_bootstrap
  57. copy_templates
  58. add_sidekiq
  59. add_foreman
  60. add_webpack
  61. # Migrate
  62. rails_command "db:create"
  63. rails_command "db:migrate"
  64. after_bundle do
  65. git :init
  66. git add: "."
  67. git commit: %Q{ -m 'Initial commit' }
  68. end