Class: EY::Serverside::DependencyManager::Composer

Inherits:
Base
  • Object
show all
Defined in:
lib/engineyard-serverside/dependency_manager/composer.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #runner, #servers, #shell

Instance Method Summary collapse

Methods inherited from Base

detect, #initialize, #rails_version, #show_ey_config_instructions, #uses_sqlite3?

Constructor Details

This class inherits a constructor from EY::Serverside::DependencyManager::Base

Instance Method Details

#checkObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 11

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

#composer_available?Boolean

Returns:

  • (Boolean)

54
55
56
57
58
59
60
61
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 54

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

#composer_installObject


46
47
48
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 46

def composer_install
  run "composer install --no-interaction --no-dev --optimize-autoloader --working-dir #{paths.active_release}"
end

#composer_json?Boolean

Returns:

  • (Boolean)

42
43
44
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 42

def composer_json?
  paths.composer_json.exist?
end

#composer_lock?Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 38

def composer_lock?
  paths.composer_lock.exist?
end

#composer_selfupdateObject


50
51
52
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 50

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

#detected?Boolean

Returns:

  • (Boolean)

7
8
9
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 7

def detected?
  composer_lock? || composer_json?
end

#installObject


27
28
29
30
31
32
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 27

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

#lock_or_jsonObject


34
35
36
# File 'lib/engineyard-serverside/dependency_manager/composer.rb', line 34

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