From f83ae6fe54d32ba2c5997e4275c2a0a87ed95416 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Wed, 31 May 2017 16:45:09 -0400 Subject: [PATCH] Allowing Inspector state to be cleared. (#1559) * Allowing Inspector state to be cleared. * Fixing misleading typo. --- src/Robo/Blt.php | 2 +- src/Robo/Commands/Blt/DoctorCommand.php | 11 +++++--- src/Robo/Commands/Setup/BuildCommand.php | 2 +- src/Robo/Inspector/Inspector.php | 33 +++++++++++++++++------- src/Robo/Wizards/SetupWizard.php | 1 + 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/Robo/Blt.php b/src/Robo/Blt.php index cb2071666..9bdde3192 100644 --- a/src/Robo/Blt.php +++ b/src/Robo/Blt.php @@ -184,7 +184,7 @@ public function configureContainer($container) { $container->add('executor', Executor::class) ->withArgument('builder'); - $container->add('inspector', Inspector::class) + $container->share('inspector', Inspector::class) ->withArgument('executor'); $container->inflector(InspectorAwareInterface::class) diff --git a/src/Robo/Commands/Blt/DoctorCommand.php b/src/Robo/Commands/Blt/DoctorCommand.php index 6f7d94cf3..93d552e8e 100644 --- a/src/Robo/Commands/Blt/DoctorCommand.php +++ b/src/Robo/Commands/Blt/DoctorCommand.php @@ -23,27 +23,28 @@ public function doctor() { && !$this->getInspector()->isVmCli()) { $result = $this->executeDoctorInsideVm(); if ($result->wasSuccessful()) { - return $result; + return $result->getExitCode(); } } // Try BLT doctor with default alias. This might be a Drupal VM alias. $alias = $this->getConfigValue('drush.alias'); + $this->say('Attempting to run doctor on host machine...'); $result = $this->executeDoctorOnHost($alias); // If default alias failed, try again using @self alias. if (!$result->wasSuccessful() && $alias != 'self') { - $this->logger->warning("Unable to run the doctor using @$alias. Trying with @self..."); + $this->logger->warning("Unable to run the doctor using alias '@$alias'. Trying with '@self'..."); $this->executeDoctorOnHost('self'); } // If @self fails, try without any alias. if (!$result->wasSuccessful() && $alias != '') { - $this->logger->warning("Unable to run the doctor using @self. Trying without alias..."); + $this->logger->warning("Unable to run the doctor using alias '@self'. Trying without alias..."); $this->executeDoctorOnHost(''); } - return $result; + return $result->getExitCode(); } /** @@ -73,6 +74,8 @@ protected function executeDoctorOnHost($alias) { ->alias($alias) ->uri("") ->includePath($this->getConfigValue('blt.root') . '/drush') + ->printOutput(FALSE) + ->printMetadata(FALSE) ->run(); return $result; diff --git a/src/Robo/Commands/Setup/BuildCommand.php b/src/Robo/Commands/Setup/BuildCommand.php index 19c1f715b..d2aefebf7 100644 --- a/src/Robo/Commands/Setup/BuildCommand.php +++ b/src/Robo/Commands/Setup/BuildCommand.php @@ -19,7 +19,7 @@ class BuildCommand extends BltTasks { * @aliases setup:all */ public function setup() { - $this->say("Setting up local environment for @{$this->getConfigValue('site')}..."); + $this->say("Setting up local environment for site '{$this->getConfigValue('site')}'..."); $status_code = $this->invokeCommands([ 'setup:build', 'setup:hash-salt', diff --git a/src/Robo/Inspector/Inspector.php b/src/Robo/Inspector/Inspector.php index c92bf2b4e..1b3c660d8 100644 --- a/src/Robo/Inspector/Inspector.php +++ b/src/Robo/Inspector/Inspector.php @@ -33,6 +33,16 @@ class Inspector implements BuilderAwareInterface, ConfigAwareInterface, LoggerAw */ protected $executor; + /** + * @var null + */ + protected $isDrupalInstalled = NULL; + + /** + * @var null + */ + protected $isMySqlAvailable = NULL; + /** * The constructor. * @@ -43,6 +53,11 @@ public function __construct(Executor $executor) { $this->executor = $executor; } + public function clearState() { + $this->isDrupalInstalled = NULL; + $this->isMySqlAvailable = NULL; + } + /** * Determines if the repository root directory exists. * @@ -123,7 +138,7 @@ public function isDrupalSettingsFileValid() { /** * Checks that Drupal is installed, caches result. * - * This method caches its result in state.drupal.installed value. + * This method caches its result in $this->drupalIsInstalled. * * @return bool * TRUE if Drupal is installed. @@ -131,12 +146,11 @@ public function isDrupalSettingsFileValid() { public function isDrupalInstalled() { // This will only run once per command. If Drupal is installed mid-command, // this value needs to be changed. - if (is_null($this->getConfigValue('state.drupal.installed'))) { - $installed = $this->getDrupalInstalled(); - $this->getConfig()->set('state.drupal.installed', $installed); + if (is_null($this->isDrupalInstalled)) { + $this->isDrupalInstalled = $this->getDrupalInstalled(); } - return $this->getConfigValue('state.drupal.installed'); + return $this->isDrupalInstalled; } /** @@ -171,18 +185,17 @@ public function getDrushStatus() { /** * Determines if MySQL is available, caches result. * - * This method caches its result in state.mysql.available config. + * This method caches its result in $this->mySqlAvailable. * * @return bool * TRUE if MySQL is available. */ public function isMySqlAvailable() { - if (is_null($this->getConfigValue('state.mysql.available'))) { - $mysql_available = $this->getMySqlAvailable(); - $this->getConfig()->set('state.mysql.available', $mysql_available); + if (is_null($this->isMySqlAvailable)) { + $this->isMySqlAvailable = $this->getMySqlAvailable(); } - return $this->getConfigValue('state.mysql.available'); + return $this->isMySqlAvailable; } /** diff --git a/src/Robo/Wizards/SetupWizard.php b/src/Robo/Wizards/SetupWizard.php index 6d736b44d..21398ba5f 100644 --- a/src/Robo/Wizards/SetupWizard.php +++ b/src/Robo/Wizards/SetupWizard.php @@ -44,6 +44,7 @@ public function wizardInstallDrupal() { ->execute("$bin/blt setup") ->detectInteractive() ->run(); + $this->getInspector()->clearState(); } } }