class Fanforce::AppFactory::CLI::Scripts include Fanforce::AppFactory::CLI::Utils require_relative '../lib/env' require_relative '../lib/iron' ###################################################################################################################### def push(environment, command) command = command.to_sym app = Fanforce::CLI::App.load(Fanforce::CLI::DIR) if [:all,:iron].include?(command) if Fanforce::CLI::TYPE == :directory_of_apps confirm("\nYou are about to push iron works for #{Fanforce::CLI::Apps.total_count} apps in this directory.\n"+ 'ARE YOU SURE?', true) Fanforce::CLI::Apps.each do |app, processed_count, total_count| log divider '+-----------------------------------------------------------------------------------------------' log "#{'APP'.format(:bold)} - #{app._id.upcase.gsub('-',' ').format(:bold)} (#{processed_count} of #{total_count})... " push_app_workers(app, environment) end elsif Fanforce::CLI::TYPE == :single_app log divider '+-------------------------------------------------------------------------------------------------' app = Fanforce::CLI::App.load(Fanforce::CLI::DIR) push_app_workers(app, environment) end elsif command.to_s.include?('.worker') log divider '+---------------------------------------------------------------------------------------------------' app = Fanforce::CLI::App.load(Fanforce::CLI::DIR) push_app_worker(app, environment, command.to_s) end log divider '----------------------------------------------------------------------------------------------------++' end def push_app_worker(app, environment, filename) Dir.chdir(app.dir) do Fanforce::AppFactory::CLI::Iron.new(app).upload(environment, filename) end end def push_app_workers(app, environment) Dir.chdir(app.dir) do Fanforce::AppFactory::CLI::Iron.new(app).upload(environment) # if [:all,:bitbucket].include?(command) and config[:bitbucket].present? # if !(`git remote`).split(/\r?\n/).include?('bitbucket') # setup_bitbucket(app) # else # puts "\n#{'Pushing '.format(:green,:bold)}" + "latest commit to Bitbucket (#{$Config[:bitbucket][:user]})..." # Run.command('git push bitbucket --all') # end # end # environments = (environment==:all) ? [:staging,:production] : [environment] # environments.each do |environment| # if [:all,:heroku].include?(command) # remote_name = "#{env(environment)}-heroku" # setup_heroku(app, environment) if !(`git remote`).split(/\r?\n/).include?(remote_name) # # vars = Env.vars_by_app(environment)[app.dir_name] || {} # puts "\n#{"Updating Env Vars".format(:green,:bold)} on Heroku #{environment.to_s.titleize} (#{vars.size} variables)..." # push_env_to(environment, app, vars) # # puts "\n#{'Pushing '.format(:green,:bold)}" + "latest commit to Heroku #{environment.to_s.titleize} (#{remote_name})..." # Run.command("git push #{remote_name} master") # end # # if [:all,:iron].include?(command) # puts '' # upload_iron(app, command, [environment]) # end # end end end end