forked from lewagon/rails-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devise.rb
141 lines (123 loc) · 4.17 KB
/
devise.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
run "pgrep spring | xargs kill -9"
run "rm Gemfile"
file 'Gemfile', <<-RUBY
source 'https://rubygems.org'
ruby '#{RUBY_VERSION}'
gem 'rails', '#{Rails.version}'
gem 'puma'
gem 'pg'
gem 'figaro'
gem 'jbuilder', '~> 2.0'
gem 'devise'#{Rails.version >= "5" ? ", github: 'plataformatec/devise'" : nil}
gem 'redis'
gem 'sass-rails'
gem 'jquery-rails'
gem 'uglifier'
gem 'bootstrap-sass'
gem 'font-awesome-sass'
gem 'simple_form'#{Rails.version >= "5" ? ", github: 'plataformatec/simple_form'" : nil}
gem 'autoprefixer-rails'
group :development, :test do
gem 'binding_of_caller'
gem 'better_errors'
#{Rails.version >= "5" ? nil : "gem 'quiet_assets'"}
gem 'pry-byebug'
gem 'pry-rails'
gem 'spring'
#{Rails.version >= "5" ? "gem 'listen', '~> 3.0.5'" : nil}
#{Rails.version >= "5" ? "gem 'spring-watcher-listen', '~> 2.0.0'" : nil}
end
group :production do
gem 'rails_12factor'
end
RUBY
file ".ruby-version", RUBY_VERSION
file 'Procfile', <<-YAML
web: bundle exec puma -C config/puma.rb
YAML
if Rails.version < "5"
puma_file_content = <<-RUBY
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
RUBY
file 'config/puma.rb', puma_file_content, force: true
end
run "rm -rf app/assets/stylesheets"
run "curl -L https://github.com/lewagon/stylesheets/archive/master.zip > stylesheets.zip"
run "unzip stylesheets.zip -d app/assets && rm stylesheets.zip && mv app/assets/rails-stylesheets-master app/assets/stylesheets"
run 'rm app/assets/javascripts/application.js'
file 'app/assets/javascripts/application.js', <<-JS
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require_tree .
JS
gsub_file('config/environments/development.rb', /config\.assets\.debug.*/, 'config.assets.debug = false')
run 'rm app/views/layouts/application.html.erb'
file 'app/views/layouts/application.html.erb', <<-HTML
<!DOCTYPE html>
<html>
<head>
<title>TODO</title>
<%= csrf_meta_tags %>
#{Rails.version >= "5" ? "<%= action_cable_meta_tag %>" : nil}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<%= stylesheet_link_tag 'application', media: 'all' %>
</head>
<body>
<%= render 'shared/navbar' %>
<%= render 'shared/flashes' %>
<%= yield %>
<%= javascript_include_tag 'application' %>
</body>
</html>
HTML
file 'app/views/shared/_flashes.html.erb', <<-HTML
<% if notice %>
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<%= notice %>
</div>
<% end %>
<% if alert %>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<%= alert %>
</div>
<% end %>
HTML
run "curl -L https://raw.githubusercontent.com/lewagon/awesome-navbars/master/templates/_navbar_wagon.html.erb > app/views/shared/_navbar.html.erb"
run "rm README.rdoc"
markdown_file_content = <<-MARKDOWN
Rails app generated with [lewagon/rails-templates](https://github.com/lewagon/rails-templates)
MARKDOWN
file 'README.md', markdown_file_content, force: true
after_bundle do
rake 'db:drop db:create db:migrate'
generate('simple_form:install', '--bootstrap')
generate(:controller, 'pages', 'home', '--no-helper', '--no-assets', '--skip-routes')
route "root to: 'pages#home'"
run "rm .gitignore"
file '.gitignore', <<-TXT
.bundle
log/*.log
tmp/**/*
tmp/*
*.swp
.DS_Store
public/assets
TXT
run "bin/figaro install"
generate('devise:install')
generate('devise', 'User')
rake 'db:migrate'
generate('devise:views')
environment 'config.action_mailer.default_url_options = { host: "http://localhost:3000" }', env: 'development'
environment 'config.action_mailer.default_url_options = { host: "http://TODO_PUT_YOUR_DOMAIN_HERE" }', env: 'production'
git :init
git add: "."
git commit: %Q{ -m 'Initial commit with devise template from https://github.com/lewagon/rails-templates' }
end