the Thor shell was not correctly passed to the Push command

did committed May 19, 2015
commit 8184c545bf5ba5e9d1e88b371d3e077d4808b3a3
Showing 4 changed files with 12 additions and 16 deletions
locomotive/wagon.rb b/lib/locomotive/wagon.rb +3 -3
@@ @@ -65,12 +65,12 @@ module Locomotive
#
# @param [ String ] env The environment we deploy the site to
# @param [ String ] path The path of the site
- # @param [ Hash ] connection_info The information to get connected to the remote site
+ # @param [ Object ] shell The Thor shell used to ask for information if needed
# @param [ Hash ] options The options passed to the push process
#
- def self.push(env, path, options = {})
+ def self.push(env, path, options = {}, shell)
require_relative 'wagon/commands/push_command'
- Locomotive::Wagon::PushCommand.push(env, path, options)
+ Locomotive::Wagon::PushCommand.push(env, path, options, shell)
end
# Pull a site from a remote LocomotiveCMS engine described
locomotive/wagon/cli.rb b/lib/locomotive/wagon/cli.rb +2 -2
@@ @@ -300,14 +300,14 @@ module Locomotive
desc 'push ENV [PATH]', 'Push a site to a remote LocomotiveCMS Engine'
method_option :resources, aliases: '-r', type: 'array', default: nil, desc: 'Only push the resource(s) passed in argument'
method_option :data, aliases: '-d', type: 'boolean', default: false, desc: 'Push the content entries and the editable elements (by default, they are not)'
- method_option :shell, type: 'boolean', default: true, desc: 'Use shell to ask for missing connection information like the subdomain (in this case, take a random one)'
+ method_option :shell, type: 'boolean', default: true, desc: 'Use shell to ask for missing connection information like the site handle (in this case, take a random one)'
method_option :verbose, aliases: '-v', type: 'boolean', default: false, desc: 'display the full error stack trace if an error occurs'
def push(env, path = '.')
force_color_if_asked(options)
if check_path!(path)
begin
- Locomotive::Wagon.push(env, path, options)
+ Locomotive::Wagon.push(env, path, options, options[:shell] ? shell : nil)
rescue Exception => e
self.print_exception(e, options[:verbose])
exit(1)
locomotive/wagon/commands/push_command.rb b/lib/locomotive/wagon/commands/push_command.rb +5 -9
@@ @@ -11,7 +11,7 @@ require_relative_all 'push_sub_commands'
module Locomotive::Wagon
- class PushCommand < Struct.new(:env, :path, :options)
+ class PushCommand < Struct.new(:env, :path, :options, :shell)
RESOURCES = %w(content_types content_entries pages snippets theme_assets translations).freeze
@@ @@ -25,8 +25,8 @@ module Locomotive::Wagon
attr_accessor :platform_url, :credentials
- def self.push(env, path, options)
- self.new(env, path, options).push
+ def self.push(env, path, options, shell)
+ self.new(env, path, options, shell).push
end
def push
@@ @@ -80,7 +80,7 @@ module Locomotive::Wagon
# get an instance of the Steam services in order to load the information about the site (SiteRepository)
steam_services.current_site.tap do |site|
# ask for a handle if not found (blank: random one)
- site[:handle] ||= shell.ask "What is the handle of your site?"
+ site[:handle] ||= shell.try(:ask, "What is the handle of your site?")
# create the site
attributes = SiteDecorator.new(site).to_hash
@@ @@ -104,15 +104,11 @@ module Locomotive::Wagon
def ask_for_platform_url
default = ENV['LOCOMOTIVE_PLATFORM_URL'] || DEFAULT_PLATFORM_URL
- url = shell.ask "What is the URL of your platform? (default: #{default})"
+ url = shell.try(:ask, "What is the URL of your platform? (default: #{default})")
self.platform_url = url.blank? ? default : url
end
- def shell
- options[:shell]
- end
-
end
end
spec/integration/commands/push_command_spec.rb +2 -2
@@ @@ -12,8 +12,8 @@ describe Locomotive::Wagon::PushCommand do
let(:env) { 'production' }
let(:path) { default_site_path }
let(:shell) { Thor::Shell::Color.new }
- let(:options) { { shell: shell, data: true, verbose: true } }
- let(:command) { described_class.new(env, path, options) }
+ let(:options) { { data: true, verbose: true } }
+ let(:command) { described_class.new(env, path, options, shell) }
describe '#push' do