implementing the push command (wip). Wrote the TODO list in the code to create a site if it does not exist

did committed Apr 09, 2015
commit 93b333c58edc5d29f9f17a8e5b687a6bbc2981ba
Showing 5 changed files with 55 additions and 47 deletions
locomotive/wagon.rb b/lib/locomotive/wagon.rb +14 -10
@@ @@ -63,25 +63,29 @@ module Locomotive
# Push a site to a remote LocomotiveCMS engine described
# by the config/deploy.yml file of the site and for a specific environment.
#
+ # @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 [ Hash ] options The options passed to the push process
#
- def self.push(path, connection_info, options = {})
- if reader = self.require_mounter(path, true)
+ def self.push(env, path, options = {})
+ require_relative 'wagon/commands/push_command'
+ Locomotive::Wagon::PushCommand.generate(env, path, options)
- reader.mounting_point.site.domains = connection_info['domains'] if connection_info['domains']
- reader.mounting_point.site.subdomain = connection_info['subdomain'] if connection_info['subdomain']
+ # if reader = self.require_mounter(path, true)
- writer = Locomotive::Mounter::Writer::Api.instance
- resources = self.validate_resources(options[:resources], writer.writers)
+ # reader.mounting_point.site.domains = connection_info['domains'] if connection_info['domains']
+ # reader.mounting_point.site.subdomain = connection_info['subdomain'] if connection_info['subdomain']
- connection_info[:uri] = "#{connection_info.delete(:host)}/locomotive/api"
+ # writer = Locomotive::Mounter::Writer::Api.instance
+ # resources = self.validate_resources(options[:resources], writer.writers)
- _options = { mounting_point: reader.mounting_point, only: resources, console: true }.merge(options).symbolize_keys
+ # connection_info[:uri] = "#{connection_info.delete(:host)}/locomotive/api"
- writer.run!(_options.merge(connection_info).with_indifferent_access)
- end
+ # _options = { mounting_point: reader.mounting_point, only: resources, console: true }.merge(options).symbolize_keys
+
+ # writer.run!(_options.merge(connection_info).with_indifferent_access)
+ # end
end
# Pull a site from a remote LocomotiveCMS engine described
locomotive/wagon/cli.rb b/lib/locomotive/wagon/cli.rb +27 -27
@@ @@ -308,16 +308,16 @@ module Locomotive
force_color_if_asked(options)
if check_path!(path)
- if connection_info = self.retrieve_connection_info(env, path, options[:shell])
+ # if connection_info = self.retrieve_connection_info(env, path, options[:shell])
begin
- Locomotive::Wagon.push(path, connection_info, options)
+ Locomotive::Wagon.push(env, path, options)
rescue Exception => e
self.print_exception(e, options[:verbose])
exit(1)
end
- else
- exit(1)
- end
+ # else
+ # exit(1)
+ # end
end
end
@@ @@ -382,28 +382,28 @@ module Locomotive
end
end
- # From a site specified by a path, retrieve the information of the connection
- # for a environment located in the config/deploy.yml file of the site.
- #
- # @param [ String ] env The environment (development, staging, production, ...etc)
- # @param [ String ] path The path of the local site
- # @param [ Boolean ] use_shell True by default, use it to ask for missing information (subdomain for instance)
- #
- # @return [ Hash ] The information of the connection or nil if errors
- #
- def retrieve_connection_info(env, path, use_shell = true)
- require 'locomotive/wagon/misc/deployment_connection'
-
- begin
- service = Locomotive::Wagon::DeploymentConnection.new(path, use_shell ? shell : nil)
-
- service.get_information(env)
-
- rescue Exception => e
- self.print_exception(e, options[:verbose])
- nil
- end
- end
+ # # From a site specified by a path, retrieve the information of the connection
+ # # for a environment located in the config/deploy.yml file of the site.
+ # #
+ # # @param [ String ] env The environment (development, staging, production, ...etc)
+ # # @param [ String ] path The path of the local site
+ # # @param [ Boolean ] use_shell True by default, use it to ask for missing information (subdomain for instance)
+ # #
+ # # @return [ Hash ] The information of the connection or nil if errors
+ # #
+ # def retrieve_connection_info(env, path, use_shell = true)
+ # require 'locomotive/wagon/misc/deployment_connection'
+
+ # begin
+ # service = Locomotive::Wagon::DeploymentConnection.new(path, use_shell ? shell : nil)
+
+ # service.get_information(env)
+
+ # rescue Exception => e
+ # self.print_exception(e, options[:verbose])
+ # nil
+ # end
+ # end
end
locomotive/wagon/tools/deployment_connection.rb b/lib/locomotive/wagon/tools/deployment_connection.rb +1 -1
@@ @@ -30,7 +30,7 @@ module Locomotive
def get_information(env)
connection_info = read_from_yaml_file(env)
- # is the user owns a hosting account, then use his credentials
+ # if the user owns a hosting account, then use his credentials
# to create a new site.
if connection_info.nil? && env == 'hosting'
connection_info = read_from_hosting
spec/support/helpers.rb +4 -0
@@ @@ -1,6 +1,10 @@
module Spec
module Helpers
+ def default_site_path
+ File.expand_path('../../fixtures/default', __FILE__)
+ end
+
def reset!
FileUtils.rm_rf(File.expand_path('../../../site', __FILE__))
end
spec/support/vcr.rb +9 -9
@@ @@ -1,10 +1,10 @@
- require 'webmock/rspec'
- require 'vcr'
+ # require 'webmock/rspec'
+ # require 'vcr'
- # VCR config
- VCR.configure do |c|
- c.cassette_library_dir = 'spec/fixtures/cassettes'
- c.hook_into :webmock
- c.ignore_hosts 'codeclimate.com'
- c.configure_rspec_metadata!
- end
+ # # VCR config
+ # VCR.configure do |c|
+ # c.cassette_library_dir = 'spec/fixtures/cassettes'
+ # c.hook_into :webmock
+ # c.ignore_hosts 'codeclimate.com'
+ # c.configure_rspec_metadata!
+ # end