fix a couple of issues preventing the deployment of a site

did committed May 18, 2015
commit 7eb5bfd9b12cad6b416703655057c7c8776f46d5
Showing 8 changed files with 58 additions and 140 deletions
locomotive/wagon.rb b/lib/locomotive/wagon.rb +39 -51
@@ @@ -70,22 +70,7 @@ module Locomotive
#
def self.push(env, path, options = {})
require_relative 'wagon/commands/push_command'
- Locomotive::Wagon::PushCommand.generate(env, path, options)
-
- # if reader = self.require_mounter(path, true)
-
- # reader.mounting_point.site.domains = connection_info['domains'] if connection_info['domains']
- # reader.mounting_point.site.subdomain = connection_info['subdomain'] if connection_info['subdomain']
-
- # writer = Locomotive::Mounter::Writer::Api.instance
- # resources = self.validate_resources(options[:resources], writer.writers)
-
- # connection_info[:uri] = "#{connection_info.delete(:host)}/locomotive/api"
-
- # _options = { mounting_point: reader.mounting_point, only: resources, console: true }.merge(options).symbolize_keys
-
- # writer.run!(_options.merge(connection_info).with_indifferent_access)
- # end
+ Locomotive::Wagon::PushCommand.push(env, path, options)
end
# Pull a site from a remote LocomotiveCMS engine described
@@ @@ -96,19 +81,20 @@ module Locomotive
# @param [ Hash ] options The options passed to the pull process
#
def self.pull(path, connection_info, options = {})
- self.require_mounter(path, false, options[:disable_misc])
+ raise 'TODO'
+ # self.require_mounter(path, false, options[:disable_misc])
- connection_info[:uri] = "#{connection_info.delete(:host)}/locomotive/api"
+ # connection_info[:uri] = "#{connection_info.delete(:host)}/locomotive/api"
- _options = { console: true }.merge(options).symbolize_keys
- _options[:only] = _options.delete(:resources)
+ # _options = { console: true }.merge(options).symbolize_keys
+ # _options[:only] = _options.delete(:resources)
- reader = Locomotive::Mounter::Reader::Api.instance
- self.validate_resources(_options[:only], reader.readers)
- reader.run!(_options.merge(connection_info))
+ # reader = Locomotive::Mounter::Reader::Api.instance
+ # self.validate_resources(_options[:only], reader.readers)
+ # reader.run!(_options.merge(connection_info))
- writer = Locomotive::Mounter::Writer::FileSystem.instance
- writer.run!(_options.merge(mounting_point: reader.mounting_point, target_path: path))
+ # writer = Locomotive::Mounter::Writer::FileSystem.instance
+ # writer.run!(_options.merge(mounting_point: reader.mounting_point, target_path: path))
end
# Clone a site from a remote LocomotiveCMS engine.
@@ @@ -119,20 +105,21 @@ module Locomotive
# @param [ Hash ] options The options for the API reader
#
def self.clone(name, path, connection_info, options = {})
- target_path = File.expand_path(File.join(path, name))
+ raise 'TODO'
+ # target_path = File.expand_path(File.join(path, name))
- if File.exists?(target_path)
- puts "Path already exists. If it's an existing site, you might want to pull instead of clone."
- return false
- end
+ # if File.exists?(target_path)
+ # puts "Path already exists. If it's an existing site, you might want to pull instead of clone."
+ # return false
+ # end
- # generate an almost blank site
- require 'locomotive/wagon/generators/site'
- generator = Locomotive::Wagon::Generators::Site::Cloned
- generator.start [name, path, true, connection_info.symbolize_keys]
+ # # generate an almost blank site
+ # require 'locomotive/wagon/generators/site'
+ # generator = Locomotive::Wagon::Generators::Site::Cloned
+ # generator.start [name, path, true, connection_info.symbolize_keys]
- # pull the remote site
- self.pull(target_path, options.merge(connection_info).with_indifferent_access, { disable_misc: true })
+ # # pull the remote site
+ # self.pull(target_path, options.merge(connection_info).with_indifferent_access, { disable_misc: true })
end
# Destroy a remote site
@@ @@ -142,30 +129,31 @@ module Locomotive
# @param [ Hash ] options The options passed to the push process
#
def self.destroy(path, connection_info, options = {})
- self.require_mounter(path)
+ raise 'TODO'
+ # self.require_mounter(path)
- connection_info['uri'] = "#{connection_info.delete('host')}/locomotive/api"
+ # connection_info['uri'] = "#{connection_info.delete('host')}/locomotive/api"
- Locomotive::Mounter::EngineApi.set_token connection_info.symbolize_keys
- Locomotive::Mounter::EngineApi.delete('/current_site.json')
+ # Locomotive::Mounter::EngineApi.set_token connection_info.symbolize_keys
+ # Locomotive::Mounter::EngineApi.delete('/current_site.json')
end
- protected
+ # protected
- def self.validate_resources(resources, writers_or_readers)
- return if resources.nil?
+ # def self.validate_resources(resources, writers_or_readers)
+ # return if resources.nil?
- # FIXME: for an unknown reason, when called from Cocoa, the resources are a string
- resources = resources.map { |resource| resource.split(' ') }.flatten
+ # # FIXME: for an unknown reason, when called from Cocoa, the resources are a string
+ # resources = resources.map { |resource| resource.split(' ') }.flatten
- valid_resources = writers_or_readers.map { |thing| thing.to_s.demodulize.gsub(/Writer$|Reader$/, '').underscore }
+ # valid_resources = writers_or_readers.map { |thing| thing.to_s.demodulize.gsub(/Writer$|Reader$/, '').underscore }
- resources.each do |resource|
- raise ArgumentError, "'#{resource}' resource not recognized. Valid resources are #{valid_resources.join(', ')}." unless valid_resources.include?(resource)
- end
+ # resources.each do |resource|
+ # raise ArgumentError, "'#{resource}' resource not recognized. Valid resources are #{valid_resources.join(', ')}." unless valid_resources.include?(resource)
+ # end
- resources
- end
+ # resources
+ # end
end
end
locomotive/wagon/commands/push_command.rb b/lib/locomotive/wagon/commands/push_command.rb +6 -4
@@ @@ -2,10 +2,12 @@ require 'locomotive/steam'
require_relative 'loggers/push_logger'
- require_relative_all 'concerns'
- require_relative_all '../decorators/concerns'
- require_relative_all '../decorators'
- require_relative_all 'push_sub_commands'
+ require_relative_all 'concerns'
+ require_relative_all '../decorators/concerns'
+ require_relative_all '../decorators'
+
+ require_relative 'push_sub_commands/push_base_command'
+ require_relative_all 'push_sub_commands'
module Locomotive::Wagon
locomotive/wagon/commands/push_sub_commands/push_base_command.rb b/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb +1 -1
@@ @@ -57,7 +57,7 @@ module Locomotive::Wagon
end
def path
- repositories.adapter.options[:path]
+ File.expand_path(repositories.adapter.options[:path])
end
class SkipPersistingException < Exception
locomotive/wagon/commands/push_sub_commands/push_theme_assets_command.rb b/lib/locomotive/wagon/commands/push_sub_commands/push_theme_assets_command.rb +6 -3
@@ @@ -1,4 +1,5 @@
require 'tempfile'
+ require 'pry'
module Locomotive::Wagon
@@ @@ -36,9 +37,7 @@ module Locomotive::Wagon
return unless entity.stylesheet_or_javascript?
Tempfile.new(entity.realname).tap do |file|
- env = Locomotive::Steam::SprocketsEnvironment.new(File.join(path, 'public'), minify: true)
-
- file.write(env[entity.short_relative_url].to_s)
+ file.write(sprockets_env[entity.short_relative_url].to_s)
entity.filepath = file.path
@@ @@ -65,6 +64,10 @@ module Locomotive::Wagon
end
end
+ def sprockets_env
+ @sprockets_env ||= Locomotive::Steam::SprocketsEnvironment.new(File.join(path, 'public'), minify: true)
+ end
+
end
end
locomotive/wagon/decorators/theme_asset_decorator.rb b/lib/locomotive/wagon/decorators/theme_asset_decorator.rb +5 -1
@@ @@ -36,7 +36,11 @@ module Locomotive
def realname
# - memoize it because it will not change even if we change the filepath (or source)
# - we keep the first extension and drop the others (.coffee, .scss, ...etc)
- @realname ||= File.basename(filepath).split('.')[0..1].join('.')
+ @realname ||= if Sprockets.engine_extensions.include?(File.extname(filepath))
+ File.basename(filepath).split('.')[0..1].join('.')
+ else
+ File.basename(filepath)
+ end
end
def filepath
locomotivecms_wagon.gemspec +1 -1
@@ @@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
gem.add_dependency 'rubyzip', '~> 1.1.7'
gem.add_dependency 'netrc', '~> 0.10.3'
- gem.add_dependency 'locomotivecms_coal', '~> 1.0.0-alpha.2'
+ gem.add_dependency 'locomotivecms_coal', '~> 1.0.0-alpha.3'
gem.add_dependency 'locomotivecms_steam', '~> 1.0.0-alpha.1'
gem.add_dependency 'listen', '~> 2.10.0'
spec/integration/cli_spec.rb +0 -25
@@ @@ -14,29 +14,4 @@ describe Locomotive::Wagon::CLI do
end
- # describe '#auth' do
-
- # subject { }
- # expect(capture(:stdout) { A.new.invoke(:two) }).to eq("2\n3\n") }
-
- # it ''
- # let(:output) { }
-
- # end
-
end
-
- # describe Locomotive::Wagon::CLI do
- # it "overrides subdomains and domains in different environments" do
- # clone_site
- # deploy = YAML.load_file('site/config/deploy.yml')
- # deploy["staging"] = deploy["production"].merge("domains" => ["staging.example.com"], "subdomain" => "staging", "host" => "staging.example.com:3000")
- # File.write('site/config/deploy.yml', deploy.to_yaml)
- # VCR.use_cassette("staging") do
- # Locomotive::Wagon::CLI::Main.start(['push', 'staging', 'site', '-f'])
- # end
-
- # WebMock.should_not have_requested(:put, /sites\/.+.json\?auth_token=.+/).with(body: /site\[subdomain\]=sample/)
- # WebMock.should have_requested(:put, /sites\/.+.json\?auth_token=.+/).with(body: /site\[subdomain\]=staging&site\[domains\]\[\]=staging.example.com/).once
- # end
- # end
spec/integration/sites_spec.rb +0 -54
@@ @@ -1,54 +0,0 @@
- # # encoding: utf-8
-
- # require File.dirname(__FILE__) + '/integration_helper'
-
- # describe Locomotive::Wagon do
- # it 'imports' do
- # File.exists?('site/config/site.yml').should be_false
- # clone_site
- # YAML.load_file('site/config/site.yml').should == {
- # 'name' => 'locomotive',
- # 'locales' => ['en', 'es'],
- # 'subdomain' => 'sample',
- # 'domains' => ['sample.example.com'],
- # 'timezone' => 'UTC'
- # }
- # end
-
- # it "pulls the expected data" do
- # clone_site
- # es = YAML.load_file('site/app/views/pages/products.es.liquid')
- # es["seo_title"].should == "Productos SEO"
- # es["meta_description"].should == "Descripción molona de los productos"
- # es["meta_keywords"].should == "palabras, clave, productos"
- # en = YAML.load_file('site/app/views/pages/products.liquid')
- # en["seo_title"].should == "Search friendly products"
- # en["meta_description"].should == "Fancy products description"
- # en["meta_keywords"].should == "fancy, products, keywords"
- # end
-
- # it 'pushes' do
- # clone_site
- # file_name = File.dirname(__FILE__) + '/../../site/app/views/pages/index.liquid'
- # text = File.read(file_name)
- # text.gsub!(/Content of the home page/, 'New content of the home page')
- # File.open(file_name, 'w') { |file| file.puts text}
- # VCR.use_cassette('push') do
- # Locomotive::Wagon.push('site', { host: 'sample.example.com:3000', email: 'admin@locomotivecms.com', password: 'locomotive' })
- # end
- # WebMock.should have_requested(:put, /pages\/.+.json\?auth_token=.+/).with(body: /page\[raw_template\]=New%20content%20of%20the%20home%20page/).once
- # end
-
- # describe "push with unrecognized resources" do
- # subject do
- # lambda do
- # clone_site
- # VCR.use_cassette('push') do
- # Locomotive::Wagon.push('site', { host: 'sample.example.com:3000', email: 'admin@locomotivecms.com', password: 'locomotive' }, {resources: ['all']})
- # end
- # end
- # end
-
- # it { should raise_exception(ArgumentError, /'all' resource not recognized/) }
- # end
- # end