d1898440448ee27538363f0812b50ee07f6d543b
[yaffs-website] / vendor / consolidation / config / tests / scripts / prep-dependencies
1 #!/bin/bash
2
3 #
4 # This script is called automatically on every `composer update`.
5 # See "post-update-cmd" in the "scripts" section of composer.json.
6 #
7 # This script will create a derived composer.json / composer.lock
8 # pair for every test scenario.  Test scenarios are defined in the
9 # "scenarios" file, which should be customized to suit the needs
10 # of the project.
11 #
12
13 SELF_DIRNAME="`dirname -- "$0"`"
14 source ${SELF_DIRNAME}/scenarios
15
16 echo
17 echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
18 echo "::"
19 echo ":: Update dependencies for the following scenarios:"
20 echo "::"
21 echo "::    ${SCENARIOS}"
22 echo "::"
23 echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
24 echo
25
26 set -ex
27
28 for SCENARIO in ${SCENARIOS} ; do
29
30   dir=dependencies/${SCENARIO}
31
32   # Define indirect variable names
33   stability_variable="stability_${SCENARIO}"
34   requirement_variable="requirement_${SCENARIO}"
35   platform_php_variable="platform_php_${SCENARIO}"
36
37   echo "### Create $dir/composer.json for ${SCENARIO} scenario"
38   mkdir -p $dir
39   cp composer.json $dir
40
41   # Then set our own platform php version if applicable (otherwise unset it)
42   composer -n --working-dir=$dir config platform.php "${!platform_php_variable---unset}"
43
44   # Temporarily set our vendor directory to 'vendor'
45   composer -n --working-dir=$dir config vendor-dir vendor
46
47   # Set an appropriate minimum stability for this version of Symfony
48   composer -n --working-dir=$dir config minimum-stability "${!stability_variable-stable}"
49
50   # Add a constraint to limit the Symfony version
51   composer -n --working-dir=$dir require --dev --no-update "${!requirement_variable}"
52
53   # Create the composer.lock file. Ignore the vendor directory created.
54   composer -n --working-dir=$dir update --no-scripts
55
56   # Set the vendor directory to its final desired location.
57   composer -n --working-dir=$dir config vendor-dir '../../vendor'
58
59   # The 'autoload' section specifies directory paths that are relative
60   # to the composer.json file. We will drop in some symlinks so that
61   # these paths will resolve as if the composer.json were in the root.
62   for target in $AUTOLOAD_DIRECTORIES ; do
63     ln -s -f ../../$target $dir
64   done
65
66 done