-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.rb
246 lines (151 loc) · 5.23 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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#WARNING: this is a work in progress, do not use
require 'uri'
require 'net/http'
# initial commit
git :init
git add: "."
git commit: %Q{ -m 'initial commit' }
# add standard configuration
environment "config.time_zone = 'Singapore'"
environment "config.active_record.default_timezone = :local"
environment <<-CODE
config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: true,
controller_specs: true,
request_specs: false
g.fixture_replacement :factory_girl, dir: "spec/factories"
g.helper false
g.stylesheets false
g.javascripts false
end
CODE
run "cp config/database.yml config/database.yml.sample"
#TODO: remove database.yml from repo
git add: "."
git commit: %Q{ -m 'add standard configuration' }
# add standard gems
gem 'slim-rails'
gem_group :development, :test do
gem 'factory_girl_rails', '~> 4.0'
gem 'rspec-rails', '~> 3.0.0'
gem 'dotenv-rails'
end
file '.env', <<-CODE
CODE
file '.env.sample', <<-CODE
CODE
run "echo '#{@app_name}' >> .ruby-gemset"
run "echo '#{RUBY_VERSION}' >> .ruby-version"
run "bundle install"
get "https://raw.githubusercontent.com/tinkerbox/environment/master/src/factories_spec.rb", "spec/models/factories_spec.rb"
generate "rspec:install"
run "echo '.env' >> .gitignore"
run "echo --format documentation >> .rspec"
git add: "."
git commit: %Q{ -m 'add standard gems' }
# add app signal
if yes? "Add appsignal?"
gem 'appsignal'
run "bundle install"
api_key = ask("Enter appsignal API key:")
generate :appsignal, api_key
git add: "."
git commit: %Q{ -m 'install and configure appsignal' }
end
# add new relic
if yes? "Add New Relic?"
gem 'newrelic_rpm'
run "bundle install"
api_key = ask("Enter New Relic API key:")
get "https://raw.githubusercontent.com/tinkerbox/environment/master/src/newrelic.yml", "config/newrelic.yml"
run "echo NEW_RELIC_LICENSE_KEY=#{api_key} >> .env"
run "echo NEW_RELIC_LICENSE_KEY=#{api_key} >> .env.sample"
git add: "."
git commit: %Q{ -m 'install and configure new relic' }
end
# configure for Heroku deployment
if yes? "Will this app be deployed to Heroku?"
gem 'unicorn'
gem_group :production do
gem 'heroku-deflater'
gem 'rails_12factor'
end
run "echo '$stdout.sync = true' >> config.ru"
run "echo 'web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb' >> Procfile"
run "echo PORT=3000 >> .env"
run "echo PORT=3000 >> .env.sample"
run "bundle install"
git add: "."
git commit: %Q{ -m 'configure for heroku deployment' }
get "https://raw.githubusercontent.com/tinkerbox/environment/master/src/unicorn.rb", "config/unicorn.rb"
#TODO: ask for existing heroku apps, or create them
end
# configure development & test environments
gem_group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'guard'
gem 'guard-rspec', require: false
gem 'pry-rails'
gem 'pry-remote'
gem 'quiet_assets'
gem 'rb-fchange', require: false
gem 'rb-fsevent', require: false
gem 'rb-inotify', require: false
gem 'rb-readline', require: false
end
gem_group :test do
gem 'capybara'
gem 'database_cleaner' # more config required
gem 'selenium-webdriver' # more config required
gem 'shoulda-matchers', require: false
gem 'terminal-notifier-guard' # for OSX
end
run "bundle install"
run "bundle exec guard init"
run "guard init rspec"
run "rm spec/spec_helper.rb"
run "echo 'require \"capybara/rails\"' | cat - spec/rails_helper.rb > temp && mv temp spec/rails_helper.rb"
run "echo 'require \"shoulda/matchers\"' | cat - spec/rails_helper.rb > temp && mv temp spec/rails_helper.rb"
gsub_file "spec/rails_helper.rb", "# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures", <<-CODE
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
CODE
gsub_file 'spec/rails_helper.rb', 'config.fixture_path = "#{::Rails.root}/spec/fixtures"', ''
git add: "."
git commit: %Q{ -m 'configure development and test environments' }
if yes? "Configure for code climate?"
gem_group :test do
gem "codeclimate-test-reporter", require: nil
end
run "echo 'CodeClimate::TestReporter.start' | cat - spec/rails_helper.rb > temp && mv temp spec/rails_helper.rb"
run "echo 'require \"codeclimate-test-reporter\"' | cat - spec/rails_helper.rb > temp && mv temp spec/rails_helper.rb"
run "bundle install"
git add: "."
git commit: %Q{ -m 'configure code coverage scores to be sent to CodeClimate' }
end
if yes? "Generate binstubs?"
run "bundle install --binstubs"
git add: "."
git commit: %Q{ -m 'generate binstubs' }
end
# run "echo '#{@app_name}' >> .ruby-gemset"
# push to GitHub
# if yes? "Initialize GitHub repository?"
# git_uri = `git config remote.origin.url`.strip
# unless git_uri.size == 0
# say "Repository already exists:"
# say "#{git_uri}"
# else
# #TODO: change this for organization repository
# username = ask "What is your GitHub username?"
# run "curl -u #{username} -d '{\"name\":\"#{app_name}\"}' https://api.github.com/user/repos"
# git remote: %Q{ add origin [email protected]:#{username}/#{app_name}.git }
# git push: %Q{ origin master }
# end
# end