summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-03-22 09:37:57 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2018-03-22 09:37:57 +1100
commit36bedfb7f37931a33d9af586296404c02c3ab80e (patch)
tree9ca6e11053aea141c50030cb6e1de04c24b3432f /bin
parent5ae91f323d054341c0d012de85835ef40f1bf9f8 (diff)
downloadgitlab-ce-36bedfb7f37931a33d9af586296404c02c3ab80e.tar.gz
[Rails5] Update files by `rails app:update`blackst0ne-rails5-update-files-by-rails-app-update
Diffstat (limited to 'bin')
-rwxr-xr-xbin/rails15
-rwxr-xr-xbin/rake13
-rwxr-xr-xbin/setup50
-rwxr-xr-xbin/update29
4 files changed, 89 insertions, 18 deletions
diff --git a/bin/rails b/bin/rails
index 0138d79b751..228f812ccaf 100755
--- a/bin/rails
+++ b/bin/rails
@@ -1,9 +1,14 @@
#!/usr/bin/env ruby
-begin
- load File.expand_path('../spring', __FILE__)
-rescue LoadError => e
- raise unless e.message.include?('spring')
+
+# Remove this block when upgraded to rails 5.0.
+unless %w[1 true].include?(ENV["RAILS5"])
+ begin
+ load File.expand_path('../spring', __FILE__)
+ rescue LoadError => e
+ raise unless e.message.include?('spring')
+ end
end
-APP_PATH = File.expand_path('../../config/application', __FILE__)
+
+APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
diff --git a/bin/rake b/bin/rake
index d87d5f57810..b52a8321f1a 100755
--- a/bin/rake
+++ b/bin/rake
@@ -1,9 +1,14 @@
#!/usr/bin/env ruby
-begin
- load File.expand_path('../spring', __FILE__)
-rescue LoadError => e
- raise unless e.message.include?('spring')
+
+# Remove this block when upgraded to rails 5.0.
+unless %w[1 true].include?(ENV["RAILS5"])
+ begin
+ load File.expand_path('../spring', __FILE__)
+ rescue LoadError => e
+ raise unless e.message.include?('spring')
+ end
end
+
require_relative '../config/boot'
require 'rake'
Rake.application.run
diff --git a/bin/setup b/bin/setup
index 6cb2d7f1e3a..c60c1267e06 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,29 +1,61 @@
#!/usr/bin/env ruby
-require 'pathname'
+
+def rails5?
+ %w[1 true].include?(ENV["RAILS5"])
+end
+
+require "pathname"
# path to your application root.
-APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+APP_ROOT = Pathname.new File.expand_path("../../", __FILE__)
+
+if rails5?
+ def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+ end
+end
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
puts "== Installing dependencies =="
- system "gem install bundler --conservative"
- system "bundle check || bundle install"
+
+ if rails5?
+ system! "gem install bundler --conservative"
+ system("bundle check") || system!("bundle install")
+ else
+ system "gem install bundler --conservative"
+ system "bundle check || bundle install"
+ end
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
- # system "cp config/database.yml.sample config/database.yml"
+ # cp "config/database.yml.sample", "config/database.yml"
# end
puts "\n== Preparing database =="
- system "bin/rake db:reset"
+
+ if rails5?
+ system! "bin/rails db:setup"
+ else
+ system "bin/rake db:reset"
+ end
puts "\n== Removing old logs and tempfiles =="
- system "rm -f log/*"
- system "rm -rf tmp/cache"
+
+ if rails5?
+ system! "bin/rails log:clear tmp:clear"
+ else
+ system "rm -f log/*"
+ system "rm -rf tmp/cache"
+ end
puts "\n== Restarting application server =="
- system "touch tmp/restart.txt"
+
+ if rails5?
+ system! "bin/rails restart"
+ else
+ system "touch tmp/restart.txt"
+ end
end
diff --git a/bin/update b/bin/update
new file mode 100755
index 00000000000..a8e4462f203
--- /dev/null
+++ b/bin/update
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'pathname'
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ puts "\n== Updating database =="
+ system! 'bin/rails db:migrate'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end