-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
template.rb
97 lines (74 loc) · 2 KB
/
template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
=begin
Template Name: Kickstart application template
Author: Andy Leverenz
Author URI: https://web-crunch.com
Instructions: $ rails new myapp -d <postgresql, mysql, sqlite> -m template.rb
=end
def source_paths
[File.expand_path(File.dirname(__FILE__))]
end
def add_gems
gem 'devise'
gem 'bulma-rails'
gem 'sidekiq'
gem_group :development, :test do
gem 'better_errors'
gem 'guard'
gem 'guard-livereload'
end
end
def set_application_name
# Ask user for application name
application_name = ask("What is the name of your application? Default: Kickoff")
# Checks if application name is empty and add default Jumpstart.
application_name = application_name.present? ? application_name : "Kickoff"
# Add Application Name to Config
environment "config.application_name = '#{application_name}'"
# Announce the user where he can change the application name in the future.
puts "Your application name is #{application_name}. You can change this later on: ./config/application.rb"
end
def add_users
# Install Devise
generate "devise:install"
# Configure Devise
environment "config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }",
env: 'development'
route "root to: 'home#index'"
# Create Devise User
generate :devise, "User", "name"
end
def add_home
end
def remove_app_css
# Remove Application CSS
run "rm app/assets/stylesheets/application.css"
end
def copy_templates
directory "app", force: true
end
def add_sidekiq
environment "config.active_job.queue_adapter = :sidekiq"
insert_into_file "config/routes.rb",
"require 'sidekiq/web'\n\n",
before: "Rails.application.routes.draw do"
end
def init_guardfile
run "guard init livereload"
end
# Main setup
add_gems
after_bundle do
set_application_name
add_home
add_users
remove_app_css
add_sidekiq
init_guardfile
copy_templates
# Migrate
rails_command "db:create"
rails_command "db:migrate"
git :init
git add: "."
git commit: %Q{ -m "Initial commit" }
end