@@ -213,6 +213,15 @@ module Refinery
213
213
exit ( 1 )
214
214
end
215
215
end
216
+
217
+ if @options [ :update ]
218
+ puts "Please ensure you have a backup of your project and its database."
219
+ puts "Type 'yes' to continue (anything other than 'yes' will cancel)"
220
+ unless $stdin. gets . strip == 'yes'
221
+ puts "Cancelling..."
222
+ exit
223
+ end
224
+ end
216
225
end
217
226
218
227
def update!
@@ -236,34 +245,32 @@ module Refinery
236
245
exit ( 1 )
237
246
elsif defined? JRUBY_VERSION
238
247
find_and_replace ( @app_path . join ( 'Gemfile' ) , /['|"]sqlite3['|"]/ , "'activerecord-jdbcsqlite3-adapter'" )
248
+
249
+ # Override username and password
250
+ find_and_replace ( 'config/database.yml' , %r{username:.*} , "username: #{ @options [ :database ] [ :username ] } " )
251
+ find_and_replace ( 'config/database.yml' , %r{password:.*} , "password: #{ @options [ :database ] [ :password ] } " )
252
+
253
+ puts "\n ---------"
254
+ puts "Refinery successfully installed in '#{ @app_path } '!\n \n "
239
255
end
240
256
end
241
257
242
258
def bundle!
243
- # Add refinery gems to the Gemfile
244
- gemfile_contents = Refinery . root . join ( 'Gemfile' ) . read
245
- refinery_gems = gemfile_contents . match ( /# REFINERY CMS =+.*# END REFINERY CMS =+/m ) [ 0 ]
259
+ # Insert the current REFINERY CMS section (you shouldn't put anything in here).
260
+ refinery_gems = Refinery . root . join ( 'Gemfile' ) . read . match ( /# REFINERY CMS =+.*# END REFINERY CMS =+/m ) [ 0 ]
246
261
refinery_gems . gsub! ( "# gem 'refinerycms'" , "gem 'refinerycms'" ) # Enable refinerycms
247
262
refinery_gems . gsub! ( "gem 'refinerycms-testing'" , "# gem 'refinerycms-testing'" ) # Disable testing
248
- refinery_user_defined_gems = gemfile_contents . match ( /# USER DEFINED(.*)# END USER DEFINED/m )
249
- refinery_user_defined_gems = refinery_user_defined_gems [ 1 ] unless refinery_user_defined_gems . nil?
250
- app_gemfile = @app_path . join ( 'Gemfile' )
251
- FileUtils ::cp app_gemfile , "#{ app_gemfile } .backup"
252
263
unless @options [ :update ]
264
+ app_gemfile = @app_path . join ( 'Gemfile' )
265
+ FileUtils ::cp app_gemfile , "#{ app_gemfile } .backup"
253
266
app_gemfile . open ( 'a' ) do |f |
254
267
f . write "\n #{ refinery_gems } \n "
255
- @options [ :gems ] = ( [ refinery_user_defined_gems ] | [ @options [ :gems ] ] ) . flatten . compact
256
-
257
268
f . write "\n # USER DEFINED\n #{ @options [ :gems ] . join ( "\n " ) } \n # END USER DEFINED" if @options [ :gems ] . any?
258
269
end
270
+ else
271
+ find_and_replace ( @app_path . join ( 'Gemfile' ) , /# REFINERY CMS =+.*# END REFINERY CMS =+/m , refinery_gems )
259
272
end
260
273
261
- # Override database username and password
262
- unless @options [ :update ]
263
- # Override username and password
264
- find_and_replace ( 'config/database.yml' , %r{username:.*} , "username: #{ @options [ :database ] [ :username ] } " )
265
- find_and_replace ( 'config/database.yml' , %r{password:.*} , "password: #{ @options [ :database ] [ :password ] } " )
266
- end
267
274
268
275
# Specify the correct version of the Refinery CMS gem (may be git source).
269
276
src = Refinery . version !~ /\. pre$/ ? "'= #{ Refinery . version } '" : ":git => 'git://github.com/resolve/refinerycms'"
@@ -273,15 +280,14 @@ module Refinery
273
280
find_and_replace ( 'Gemfile' , "# gem 'aws-s3', :require => 'aws/s3'" ,
274
281
"gem 'aws-s3', :require => 'aws/s3'" ) if @options [ :heroku ]
275
282
276
- puts "\n ---------"
277
- puts "Refinery successfully installed in '#{ @app_path } '!\n \n "
278
-
279
283
# Automate
280
284
# TODO: Check exit codes to see whether or not these worked
281
285
puts "Installing gem requirements using bundler..\n "
282
286
283
287
# Ensure RefineryCMS is up to date if we're updating
284
- run_command ( "bundle update refinerycms refinerycms-generators" , { :fail => "Unable to update core gems" } ) if @options [ :update ]
288
+ if @options [ :update ]
289
+ run_command ( "bundle update refinerycms refinerycms-generators" , { :fail => "Unable to update core gems" } )
290
+ end
285
291
286
292
# Install!
287
293
run_command ( "bundle install" , { :fail => "Unable to install necessary gems" } )
@@ -328,6 +334,15 @@ module Refinery
328
334
puts "heroku config:add S3_BUCKET=XXXXXXXXX S3_KEY=XXXXXXXXX S3_SECRET=XXXXXXXXXX"
329
335
end
330
336
337
+ puts "\n --- Refinery CMS 0.9.9.1 note ---"
338
+ puts "New 'core' engine called 'refinerycms-testing' which handles RSpec and Cucumber support."
339
+ puts "You will see this disabled in your Gemfile in the '# REFINERY CMS' section."
340
+ puts "To enable it, uncomment the gem line in your Gemfile and run:"
341
+ puts "\n bundle install"
342
+ puts "rails generate refinerycms_testing"
343
+ puts "\n If it prompts you about whether you want to overwrite any files that conflict, choose yes."
344
+ puts "--- End upgrade note ---\n "
345
+
331
346
puts "\n Thanks for installing Refinery, enjoy creating your new application!"
332
347
puts "---------\n \n "
333
348
end
0 commit comments