Преглед на файлове

Refactor a bit. Adds Sidekiq, Webpacker, and Foreman.

Chris Oliver преди 7 години
родител
ревизия
b24e7c435b

+ 3 - 0
Procfile

@@ -0,0 +1,3 @@
+web: rails server
+sidekiq: sidekiq
+webpack: bin/webpack-dev-server

+ 4 - 0
app/controllers/home_controller.rb

@@ -0,0 +1,4 @@
+class HomeController < ApplicationController
+  def index
+  end
+end

+ 1 - 0
app/views/home/index.html.erb

@@ -0,0 +1 @@
+<h1>Welcome to Spork!</h1>

+ 0 - 0
views/layouts/application.html.erb → app/views/layouts/application.html.erb


+ 0 - 0
views/shared/_footer.html.erb → app/views/shared/_footer.html.erb


+ 0 - 0
views/shared/_head.html.erb → app/views/shared/_head.html.erb


+ 0 - 0
views/shared/_navbar.html.erb → app/views/shared/_navbar.html.erb


+ 0 - 0
views/shared/_notices.html.erb → app/views/shared/_notices.html.erb


+ 66 - 35
template.rb

@@ -1,40 +1,71 @@
-current_path = File.expand_path(File.dirname(__FILE__))
-
-# Add Devise to Gemfile
-gem "devise", "~> 4.2.1"
-gem "bootstrap-sass", "~> 3.3.6"
-
-# Install Devise
-rails_command "generate devise:install"
-
-# Configure Devise
-environment "config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }",
-            env: 'development'
-route "root to: 'home#index'"
-# Devise notices are installed via Bootstrap
-rails_command "generate devise:views User"
-
-# Create Devise User
-generate :devise, "User",
-         "first_name",
-         "last_name",
-         "announcements_last_read_at:datetime"
-
-# Rename Application SCSS
-run "mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss"
-
-# Insert Bootstrap Styling
-insert_into_file(
-  "app/assets/stylesheets/application.scss",
-  "@import 'bootstrap-sprockets';\n@import 'bootstrap'\n",
-  before: "/*"
-)
-
-# Import Templates
-run "cp #{current_path}/views/layouts/application.html.erb app/views/layouts/application.html.erb"
-run "cp -R #{current_path}/views/shared app/views/shared"
+def source_paths
+  [File.expand_path(File.dirname(__FILE__))]
+end
+
+def add_users
+  # Gemfile
+  gem 'devise', '~> 4.2.1'
+  gem 'bootstrap-sass', '~> 3.3.6'
+
+  # Install Devise
+  rails_command "generate devise:install"
+
+  # Configure Devise
+  environment "config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }",
+              env: 'development'
+  route "root to: 'home#index'"
+
+  # Devise notices are installed via Bootstrap
+  rails_command "generate devise:views User"
+
+  # Create Devise User
+  generate :devise, "User",
+           "first_name",
+           "last_name",
+           "announcements_last_read_at:datetime"
+end
+
+def add_bootstrap
+  # Rename Application SCSS
+  run "mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss"
+
+  # Insert Bootstrap Styling
+  insert_into_file(
+    "app/assets/stylesheets/application.scss",
+    "@import 'bootstrap-sprockets';\n@import 'bootstrap'\n",
+    after: " */\n"
+  )
+end
+
+def copy_templates
+  directory "app", force: true
+end
+
+def add_webpack
+  gem 'webpacker', '~> 1.1'
+  rails_command 'webpacker:install'
+end
+
+def add_sidekiq
+  gem 'sidekiq', '~> 5.0'
+  environment "config.active_job.queue_adapter = :sidekiq"
+end
+
+def add_foreman
+  gem 'foreman', '~> 0.84.0'
+  copy_file "Procfile"
+end
+
+# Main setup
+add_users
+add_bootstrap
+copy_templates
+add_sidekiq
+add_foreman
+add_webpack
 
 # Migrate
+rails_command "db:create"
 rails_command "db:migrate"
 
 after_bundle do