Skip to content

Commit

Permalink
Update deprecated code in custom commands.
Browse files Browse the repository at this point in the history
Change-Id: Ic6ef3fc3db51d0d49b41849c21951064c68df919
  • Loading branch information
Edouard Cunibil committed Oct 8, 2024
1 parent b8183e3 commit 02e0f70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
20 changes: 6 additions & 14 deletions src/Drush/Commands/GenerateEnvironmentDrushCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use Drupal\Component\Serialization\Json;
use DrupalCodeGenerator\Asset\AssetCollection;
use DrupalCodeGenerator\Validator\Chained;
use DrupalCodeGenerator\Validator\Required;
use Drush\Attributes as CLI;

/**
Expand Down Expand Up @@ -148,24 +146,20 @@ protected function interview(array &$vars): void {
if (!isset($vars['build_mode'])) {
$composerData = Json::decode(file_get_contents($this->drupalFinder()->getComposerRoot() . '/composer.json'));
$defaultValue = $composerData['extra']['combawa']['build_mode'] ?? 'install';
$choices = ['install', 'update'];
$choice = $this->io()->choice(
$vars['build_mode'] = $this->io()->select(
'What is your current build mode?',
$choices,
['install', 'update'],
$defaultValue,
);
$vars['build_mode'] = $choices[$choice] ?? $choice;
}

if (!isset($vars['environment'])) {
$defaultValue = $_ENV['COMBAWA_BUILD_ENV'] ?? 'prod';
$choices = ['dev', 'testing', 'prod'];
$choice = $this->io()->choice(
$vars['environment'] = $this->io()->select(
'Which kind of environment is it?',
$choices,
['dev', 'testing', 'prod'],
$defaultValue,
);
$vars['environment'] = $choices[$choice] ?? $choice;
}

if (!isset($vars['webroot'])) {
Expand Down Expand Up @@ -255,13 +249,11 @@ protected function interview(array &$vars): void {

if (!isset($vars['dump_fetch_method'])) {
$defaultValue = $_ENV['COMBAWA_DB_RETRIEVAL_TOOL'] ?? 'scp';
$choices = ['cp', 'scp'];
$choice = $this->io()->choice(
$vars['dump_fetch_method'] = $this->io()->select(
'When updated, what is the tool used to retrieve the reference dump?',
$choices,
['cp', 'scp'],
$defaultValue,
);
$vars['dump_fetch_method'] = $choices[$choice] ?? $choice;
}

if ($vars['dump_fetch_method'] === 'scp') {
Expand Down
6 changes: 2 additions & 4 deletions src/Drush/Commands/InitializeBuildScriptsDrushCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ protected function interview(array &$vars): void {
if (!isset($vars['build_mode'])) {
$composerData = Json::decode(file_get_contents($this->drupalFinder()->getComposerRoot() . '/composer.json'));
$defaultValue = $composerData['extra']['combawa']['build_mode'] ?? 'install';
$choices = ['install', 'update'];
$choice = $this->io()->choice(
$vars['build_mode'] = $this->io()->select(
'What is the build mode to use?',
$choices,
['install', 'update'],
$defaultValue,
);
$vars['build_mode'] = $choices[$choice] ?? $choice;
}

$scriptsDir = $this->drupalFinder()->getComposerRoot() . '/scripts/combawa';
Expand Down

0 comments on commit 02e0f70

Please sign in to comment.