Sha256: 52f64e0b7725fe8a2052260ddc33d352f21a5d3f111e616cf09ceda5485d3ed4

Contents?: true

Size: 1.68 KB

Versions: 8

Compression:

Stored size: 1.68 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 "composer install --no-interaction --no-dev --optimize-autoloader --working-dir #{paths.active_release}"
        end

        def composer_selfupdate
          run "composer 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

8 entries across 8 versions & 1 rubygems

Version Path
engineyard-serverside-2.3.7 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.3.6 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.3.5 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.3.4 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.3.3 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.3.2 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.3.1 lib/engineyard-serverside/dependency_manager/composer.rb
engineyard-serverside-2.3.1.pre.archivefix lib/engineyard-serverside/dependency_manager/composer.rb