Class: Homesteading::Init
- Defined in:
- lib/homesteading/commands/init.rb
Constant Summary
Constants inherited from Command
Instance Method Summary collapse
- #app_postdeploy(app_file_path) ⇒ Object
- #default(constellation_dir, server: :local, app: nil) ⇒ Object
- #run_app_postdeploy_script(app, app_postdeploy_script, server) ⇒ Object
Methods inherited from Command
Instance Method Details
#app_postdeploy(app_file_path) ⇒ Object
38 39 40 |
# File 'lib/homesteading/commands/init.rb', line 38 def app_postdeploy(app_file_path) JSON.parse(File.read(app_file_path))["scripts"]["postdeploy"] end |
#default(constellation_dir, server: :local, app: nil) ⇒ Object
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 |
# File 'lib/homesteading/commands/init.rb', line 7 def default(constellation_dir, server: :local, app: nil) puts puts "* Running initial setup" unless constellation_dir.nil? constellation_dir = "/#{constellation_dir}" end Dir.glob("#{Dir.pwd}#{constellation_dir}/homesteading-#{app}*/").each do |app_dir| app = app_dir.split("/").last.sub(/homesteading-/, "").downcase app_file_path = app_dir + "app.json" puts "* Setting up: #{app}" if File.exist?(app_file_path) app_postdeploy_script = app_postdeploy(app_file_path) FileUtils.cd app_dir do if File.exist?("#{app_dir}/config/database.example.yml") run_app_postdeploy_script(app, app_postdeploy_script, server) puts end end end puts "* #{server.to_s.capitalize} setup up complete for: #{app}" end puts end |
#run_app_postdeploy_script(app, app_postdeploy_script, server) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/homesteading/commands/init.rb', line 42 def run_app_postdeploy_script(app, app_postdeploy_script, server) unless app_postdeploy_script.nil? || app_postdeploy_script.empty? puts "* Running postdeploy script on #{app}:" if server == :local puts "* Installing gems" system "bundle install" puts "* Copying database config file" system "bundle exec rake hs:db:config" system "rake db:create:all" system app_postdeploy_script else app_postdeploy_script.split("&&").each do |command| remote_command = "#{server.to_s} run #{command}" puts "* Running: #{remote_command}" system remote_command end end end end |