lib/shelly/cli/main.rb in shelly-0.2.21 vs lib/shelly/cli/main.rb in shelly-0.2.22

- old
+ new

@@ -106,20 +106,15 @@ app.organization = options["organization"] || ask_for_organization(app.code_name) end app.zone_name = options["zone"] app.create - if overwrite_remote?(app) - say "Adding remote #{app} #{app.git_url}", :green - app.add_git_remote - else - say "You have to manually add git remote:" - say "`git remote add NAME #{app.git_url}`" - end + git_remote = add_remote(app) say "Creating Cloudfile", :green app.create_cloudfile + if app.credit > 0 || !app.organization_details_present? say_new_line say "Billing information", :green if app.credit > 0 say "#{app.credit.to_i} Euro credit remaining." @@ -129,11 +124,11 @@ say app.edit_billing_url end end info_adding_cloudfile_to_repository - info_deploying_to_shellycloud(app) + info_deploying_to_shellycloud(git_remote) rescue Client::ValidationException => e e.each_error { |error| say_error error, :with_exit => false } say_new_line say_error "Fix erros in the below command and type it again to create your cloud" , :with_exit => false @@ -240,21 +235,21 @@ def setup app = multiple_clouds(options[:cloud], "setup") say "Setting up #{app} cloud", :green app.git_url = app.attributes["git_info"]["repository_url"] if overwrite_remote?(app) - say "git remote add #{app} #{app.git_url}" + say "git remote add shelly #{app.git_url}" app.add_git_remote - say "git fetch #{app}" + say "git fetch shelly" app.git_fetch_remote - say "git checkout -b #{app} --track #{app}/master" + say "git checkout -b shelly --track shelly/master" app.git_add_tracking_branch else say "You have to manually add remote:" - say "`git remote add #{app} #{app.git_url}`" - say "`git fetch production`" - say "`git checkout -b #{app} --track #{app}/master`" + say "`git remote add shelly #{app.git_url}`" + say "`git fetch shelly`" + say "`git checkout -b shelly --track shelly/master`" end say_new_line say "Your application is set up.", :green end @@ -559,13 +554,25 @@ databases.all? { |kind| kinds.include?(kind) } end def overwrite_remote?(app) git_remote = app.git_remote_exist? - !git_remote or (git_remote and yes?("Git remote #{app} exists, overwrite (yes/no): ")) + !git_remote or (git_remote and yes?("Git remote shelly exists, overwrite (yes/no): ")) end + def add_remote(app) + if overwrite_remote?(app) + say "Adding remote shelly #{app.git_url}", :green + app.add_git_remote + "shelly" + else + say "You have to manually add git remote:" + say "`git remote add NAME #{app.git_url}`" + "NAME" + end + end + def ask_for_password(options = {}) options = {:with_confirmation => true}.merge(options) loop do say "Password: " password = echo_disabled { $stdin.gets.strip } @@ -582,12 +589,12 @@ end end end def ask_for_code_name - default_code_name = Shelly::App.guess_code_name - code_name = ask("Cloud code name (#{Shelly::App.guess_code_name} - default):") + default_code_name = Shelly::App.code_name_from_dir_name + code_name = ask("Cloud code name (#{Shelly::App.code_name_from_dir_name} - default):") code_name.blank? ? default_code_name : code_name end def ask_for_databases kinds = Shelly::App::DATABASE_CHOICES @@ -635,10 +642,10 @@ say "Project is now configured for use with Shelly Cloud:", :green say "You can review changes using", :green say " git status" end - def info_deploying_to_shellycloud(remote) + def info_deploying_to_shellycloud(remote = 'shelly') say_new_line say "When you make sure all settings are correct please issue following commands:", :green say " git add ." say ' git commit -m "Application added to Shelly Cloud"' say " git push"