-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspawnpoint.rb
More file actions
205 lines (158 loc) · 4.06 KB
/
spawnpoint.rb
File metadata and controls
205 lines (158 loc) · 4.06 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# spawnpoint
# A starter template for new Rails projects
#
# https://github.com/impraise/spawnpoint
unless Rails::VERSION::MAJOR >= 4
raise "spawnpoint was built for rails 4 and up, please update your rails version"
end
# Gemfile & Gems
remove_file "Gemfile"
file "Gemfile", <<-RUBY
source "https://rubygems.org"
gem "rails", "4.2.6"
gem "bcrypt", "3.1.11"
gem "pg"
gem "oj"
gem "bourbon"
gem "flutie"
gem "haml-rails"
gem "sass", "~> 3.4.14"
gem "sass-rails"
gem "puma", "~> 3.4.0"
gem "foreman", require: false
gem "jquery-rails"
group :development do
gem "spring"
gem "quiet_assets"
gem "better_errors"
gem "binding_of_caller"
end
group :development, :test do
gem "factory_girl_rails"
gem "rspec-rails", "~> 3.4.2"
gem "simplecov", require: false
gem "dotenv-rails"
end
group :development, :doc do
gem "yard"
gem "kramdown"
end
group :test do
gem "shoulda-matchers", "~> 3.1.1", require: false
gem "timecop"
end
group :production, :staging do
gem "rack-timeout"
gem "rails_12factor"
end
RUBY
# Rspec
run "bundle install"
generate "rspec:install"
remove_dir "test"
insert_into_file "spec/rails_helper.rb", "\nrequire 'shoulda/matchers'",
after: "require 'rspec/rails'"
prepend_to_file "spec/spec_helper.rb" do
<<-RUBY
# SimpleCov section added by spawnpoint
if ENV["RUN_SIMPLECOV"]
require "simplecov"
puts "Running Simplecov"
SimpleCov.start "rails"
end
RUBY
end
append_to_file ".gitignore", "/coverage\n"
# Default layout
remove_file "app/views/layouts/application.html.erb"
file "app/views/layouts/application.html.haml", <<-HAML
!!! 5
%html
%head
%meta{charset: "utf-8"}
%title= page_title
= stylesheet_link_tag :application
%body{class: body_class}
= yield
= javascript_include_tag :application
HAML
# Default CSS & JS
remove_file "app/assets/javascripts/application.js"
file "app/assets/javascripts/application.js", <<-JAVASCRIPT
//= require jquery
//= require jquery_ujs
//= require_tree .
// :)
JAVASCRIPT
remove_file "app/assets/stylesheets/application.css"
file "app/assets/stylesheets/application.scss", <<-SASS
@import "bourbon";
// :)
SASS
# Dotenv & configuration files
file ".env.example", <<-SHELL
SECRET_KEY_BASE=#{SecureRandom.hex(32)}
DATABASE_HOST=localhost
DATABASE_POOL_SIZE=5
DATABASE_USERNAME=batman
DATABASE_PASSWORD=hunter2
DATABASE_NAME=#{app_name}_dev
TEST_DATABASE_NAME=#{app_name}_test
SHELL
append_to_file ".gitignore", "/.env\n"
remove_file "config/secrets.yml"
file "config/secrets.yml", <<-YAML
# http://guides.rubyonrails.org/4_1_release_notes.html#config-secrets-yml
development: &default
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
test:
<<: *default
YAML
remove_file "config/database.yml"
file "config/database.yml", <<-YAML
default: &default
adapter: postgresql
encoding: utf8
host: <%= ENV["DATABASE_HOST"] %>
pool: <%= ENV["DATABASE_POOL_SIZE"] %>
username: <%= ENV["DATABASE_USERNAME"] %>
password: <%= ENV["DATABASE_PASSWORD"] %>
database: <%= ENV["DATABASE_NAME"] %>
development:
<<: *default
test:
<<: *default
database: <%= ENV["TEST_DATABASE_NAME"] %>
production:
<<: *default
YAML
# Foreman (Procfile)
file "Procfile.dev.example", <<-YAML
web: spring rails server
YAML
append_to_file ".gitignore", "/Procfile.dev\n"
# Readme
post_install_instructions = <<-WHATNOW
==============================================================================
## What next?
- Take a look at the Gemfile to have an idea what you're working with
- Copy .env.example to .env and change the environment variables,
check out https://github.com/bkeepers/dotenv for help.
- Copy Procfile.dev.example to Procfile.dev and change to your liking
- Get started with: $ foreman start -f Procfile.dev
Built at Impraise
https://github.com/impraise/spawnpoint
https://www.impraise.com
==============================================================================
WHATNOW
remove_file "README.rdoc"
file "README.md", <<-MD
# #{app_name}
#{post_install_instructions}
MD
# Next steps message
after_bundle do
git :init
git add: "."
puts post_install_instructions
end