diff --git a/docker-compose.yml b/docker-compose.yml index 016f5e511..2eddd7c7c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: web: - image: fpfis/httpd-php:8.1-dev + image: registry.fpfis.eu/fpfis/httpd-php:8.1-dev working_dir: ${PWD} volumes: - ${PWD}:${PWD} diff --git a/src/TaskRunner/Commands/BuildCommands.php b/src/TaskRunner/Commands/BuildCommands.php index 4f1a730f9..0c6169ea9 100644 --- a/src/TaskRunner/Commands/BuildCommands.php +++ b/src/TaskRunner/Commands/BuildCommands.php @@ -116,12 +116,18 @@ public function buildDist(array $options = [ $tasks[] = $this->taskWriteToFile($options['dist-root'] . '/' . $options['root'] . '/VERSION.txt')->text($tag); // Copy drush.yml file. - $tk_drush = file_exists('resources/Drush/drush.yml.dist') - ? 'resources/Drush/drush.yml.dist' - : 'vendor/ec-europa/toolkit/resources/Drush/drush.yml.dist'; - if (file_exists($tk_drush)) { + if ($tk_drush = file_exists('resources/Drush/drush.yml.dist')) { $tasks[] = $this->taskFilesystemStack() ->copy($tk_drush, $options['dist-root'] . '/web/sites/all/drush/drush.yml'); + } else { + $vHost = getenv('VIRTUAL_HOST'); + $vHostArray = explode(',', $vHost); + $drush_options['options'] = [ + 'uri' => reset($vHostArray) + ]; + $yaml = new Yaml(); + $this->taskFilesystemStack()->mkdir($options['dist-root'] . '/web/sites/all/drush'); + file_put_contents($options['dist-root'] . '/web/sites/all/drush/drush.yml', $yaml->dump($drush_options)); } // Collect and execute list of commands set on local runner.yml. @@ -185,12 +191,18 @@ public function buildDev(array $options = [ } // Copy drush.yml file. - $tk_drush = file_exists('resources/Drush/drush.yml.dist') - ? 'resources/Drush/drush.yml.dist' - : 'vendor/ec-europa/toolkit/resources/Drush/drush.yml.dist'; - if (file_exists($tk_drush)) { + if ($tk_drush = file_exists('resources/Drush/drush.yml.dist')) { $tasks[] = $this->taskFilesystemStack() - ->copy($tk_drush, "$root/sites/all/drush/drush.yml"); + ->copy($tk_drush, $root . '/sites/all/drush/drush.yml'); + } else { + $vHost = getenv('VIRTUAL_HOST'); + $vHostArray = explode(',', $vHost); + $drush_options['options'] = [ + 'uri' => reset($vHostArray) + ]; + $yaml = new Yaml(); + $this->taskFilesystemStack()->mkdir($root . '/sites/all/drush'); + file_put_contents($root . '/sites/all/drush/drush.yml', $yaml->dump($drush_options)); } // Collect and execute list of commands set on local runner.yml. diff --git a/tests/fixtures/commands/build.yml b/tests/fixtures/commands/build.yml index 473d5cf7b..b19c8e013 100644 --- a/tests/fixtures/commands/build.yml +++ b/tests/fixtures/commands/build.yml @@ -16,7 +16,7 @@ ->exec('mkdir -p web/sites/default/private_files') ->exec('chmod ug=rwx,o= web/sites/default/private_files') [Simulator] Simulating Filesystem\FilesystemStack() - ->copy('resources/Drush/drush.yml.dist', 'web/sites/all/drush/drush.yml') + ->copy(1, 'web/sites/all/drush/drush.yml') - command: 'toolkit:build-dist --root=web --dist-root=dist --tag=1.0.0 --sha=aBcDeF --keep=vendor --remove=CHANGELOG.txt' configuration: @@ -47,7 +47,7 @@ [Simulator] Simulating File\Write('dist/web/VERSION.txt') ->text('1.0.0') [Simulator] Simulating Filesystem\FilesystemStack() - ->copy('resources/Drush/drush.yml.dist', 'dist/web/sites/all/drush/drush.yml') + ->copy(1, 'dist/web/sites/all/drush/drush.yml') [Simulator] Simulating ExecStack() ->exec('find dist -maxdepth 3 -type f \( -name "CHANGELOG.txt" \) -exec rm -rf {} +')