Sha256: 6bd75358964ad4f36302d31d689ea461783bbfaf5a67fdf75450d0e950436036

Contents?: true

Size: 1.79 KB

Versions: 40

Compression:

Stored size: 1.79 KB

Contents

require 'engineyard-serverside/dependency_manager/base'

module EY
  module Serverside
    class DependencyManager
      class Composer < Base
        def detected?
          composer_lock? || composer_json?
        end

        def check
          unless composer_available?
            raise EY::Serverside::RemoteFailure.new("composer.#{lock_or_json} detected but composer not available!")
          end

          if composer_json? && !composer_lock?
            shell.warning <<-WARN
composer.json found but composer.lock missing!
This may result in different versions of packages
being installed than what you tested with.

To fix this problem, commit your composer.lock to the repository and redeploy.
            WARN
          end
        end

        def install
          shell.status "Checking for composer updates..."
          composer_selfupdate
          shell.status "Installing composer packages (composer.#{lock_or_json} detected)"
          composer_install
        end

        def lock_or_json
          composer_lock? ? 'lock' : 'json'
        end

        def composer_lock?
          paths.composer_lock.exist?
        end

        def composer_json?
          paths.composer_json.exist?
        end

        def composer_install
          run %{export GIT_SSH="#{ENV['GIT_SSH']}" && composer install --no-interaction --no-dev --optimize-autoloader --working-dir #{paths.active_release}}
        end

        def composer_selfupdate
          run "command -v composer | xargs -I composer find composer -user #{config.user} -exec {} self-update \\;"
        end

        def composer_available?
          begin
            run "command -v composer > /dev/null"
            return true
          rescue EY::Serverside::RemoteFailure
            return false
          end
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
engineyard-serverside-3.0.4 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-3.0.3 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.8.0 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.8.0.pre4 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.8.0.pre3 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.8.0.pre2 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.8.0.pre lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.7.0.pre lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.19 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.17 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.16 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.15.alpha1 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.15.cf2 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.15.pre lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.14 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.13 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.12 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.12.prewut5 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.12.prewut4 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.6.12.prewut3 lib/engineyard-serverside/dependency_manager/composer.rb