|
6 | 6 |
|
7 | 7 | set('composer_options', '--verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader'); |
8 | 8 |
|
9 | | -/** |
10 | | - * Can be used to choose what composer version to install. |
11 | | - * Valid values are any that are [listed here](https://getcomposer.org/download/). |
12 | | - * |
13 | | - * For example: |
14 | | - * ```php |
15 | | - * set('composer_version', '10.10.15') |
16 | | - * ``` |
17 | | - */ |
18 | | -set('composer_version', null); |
19 | | - |
20 | | -/** |
21 | | - * Set this variable to stable, snapshot, preview, 1 or 2 to select which Composer channel to use |
22 | | - */ |
23 | | -set('composer_channel', null); |
24 | | - |
| 9 | +// Returns Composer binary path in found. Otherwise try to install latest |
| 10 | +// composer version to `.dep/composer.phar`. To use specific composer version |
| 11 | +// download desired phar and place it at `.dep/composer.phar`. |
25 | 12 | set('bin/composer', function () { |
26 | 13 | if (commandExist('composer')) { |
27 | 14 | return '{{bin/php}} ' . locateBinaryPath('composer'); |
|
31 | 18 | return '{{bin/php}} {{deploy_path}}/.dep/composer.phar'; |
32 | 19 | } |
33 | 20 |
|
34 | | - $composerVersionToInstall = get('composer_version', null); |
35 | | - $composerChannel = get('composer_channel', null); |
36 | | - $installCommand = "cd {{release_path}} && curl -sS https://getcomposer.org/installer | {{bin/php}}"; |
37 | | - |
38 | | - if ($composerVersionToInstall) { |
39 | | - $installCommand .= " -- --version=" . $composerVersionToInstall; |
40 | | - } elseif ($composerChannel) { |
41 | | - $composerValidChannels = ['stable', 'snapshot', 'preview', '1', '2',]; |
42 | | - if (!in_array($composerChannel, $composerValidChannels)) { |
43 | | - throw new \Exception('Selected Composer channel ' . $composerChannel . ' is not valid. Valid channels are: ' . implode(', ', $composerValidChannels)); |
44 | | - } |
45 | | - $installCommand .= " -- --" . $composerChannel; |
46 | | - } |
47 | | - |
48 | | - run($installCommand); |
49 | | - run('mv {{release_path}}/composer.phar {{deploy_path}}/.dep/composer.phar'); |
| 21 | + warning("Composer binary didn't found. Installing latest composer to \"{{deploy_path}}/.dep/composer.phar\"."); |
| 22 | + run("cd {{deploy_path}} && curl -sS https://getcomposer.org/installer | {{bin/php}}"); |
| 23 | + run('mv {{deploy_path}}/composer.phar {{deploy_path}}/.dep/composer.phar'); |
50 | 24 | return '{{bin/php}} {{deploy_path}}/.dep/composer.phar'; |
51 | 25 | }); |
52 | 26 |
|
|
0 commit comments