install 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. SCENARIO=$1
  3. DEPENDENCIES=${2-install}
  4. # Convert the aliases 'highest', 'lowest' and 'lock' to
  5. # the corresponding composer update command to run.
  6. case $DEPENDENCIES in
  7. highest)
  8. UPDATE_COMMAND=update
  9. ;;
  10. lowest)
  11. UPDATE_COMMAND='update --prefer-lowest'
  12. ;;
  13. lock|default|"")
  14. UPDATE_COMMAND=''
  15. ;;
  16. esac
  17. original_name=scenarios
  18. recommended_name=".scenarios.lock"
  19. base="$original_name"
  20. if [ -d "$recommended_name" ] ; then
  21. base="$recommended_name"
  22. fi
  23. # If scenario is not specified, install the lockfile at
  24. # the root of the project.
  25. dir="$base/${SCENARIO}"
  26. if [ -z "$SCENARIO" ] || [ "$SCENARIO" == "default" ] ; then
  27. SCENARIO=default
  28. dir=.
  29. fi
  30. # Test to make sure that the selected scenario exists.
  31. if [ ! -d "$dir" ] ; then
  32. echo "Requested scenario '${SCENARIO}' does not exist."
  33. exit 1
  34. fi
  35. echo
  36. echo "::"
  37. echo ":: Switch to ${SCENARIO} scenario"
  38. echo "::"
  39. echo
  40. set -ex
  41. composer -n validate --working-dir=$dir --no-check-all --ansi
  42. if [ ! -z "$UPDATE_COMMAND" ] ; then
  43. composer -n --working-dir=$dir ${UPDATE_COMMAND} --prefer-dist --no-scripts
  44. fi
  45. composer -n --working-dir=$dir install --prefer-dist
  46. # If called from a CI context, print out some extra information about
  47. # what we just installed.
  48. if [[ -n "$CI" ]] ; then
  49. composer -n --working-dir=$dir info
  50. fi