/** * Output messages to the terminal. * * @param string $message * @param string $style * * @return void */ public function out($message, $style = 'info') { switch ($style) { case 'info': $this->cli->blue($message); break; case 'success': $this->cli->green($message); break; case 'error': $this->cli->red($message); break; case 'warning': $this->cli->yellow($message); break; } }
/** * @param array $commands */ public function executeOnRemoteServer(array $commands) { /* * @var \phpseclib\Net\SFTP */ $connection = $this->connection->getAdapter()->getConnection(); if ($this->servers[$this->currentlyDeploying]['scheme'] != 'sftp' || get_class($connection) != \phpseclib\Net\SFTP::class) { $this->cli->yellow()->out("\r\nConnection scheme is not 'sftp' ignoring [pre/post]-deploy-remote"); return; } if (!$connection->isConnected()) { $this->cli->red()->out("\r\nSFTP adapter connection problem skipping '[pre/post]-deploy-remote' commands"); return; } foreach ($commands as $command) { $this->cli->out("Execute remote : <white>{$command}"); $output = $connection->exec($command); $this->cli->out("Result remote: <white>{$output}"); } }
echo PHP_EOL; $climate = new CLImate(); $warnings = $errors = $info = 0; if ($reporter->hasIssues()) { foreach ($reporter->getIssues() as $issue) { /** @var Issue $issue */ if ($issue->getLevel() == Issue::LEVEL_INFO) { (new Process('git add ' . $issue->getSubject()->getName()))->run(); ++$info; } if ($issue->getLevel() == Issue::LEVEL_WARNING) { ++$warnings; } if ($issue->getLevel() == Issue::LEVEL_ERROR) { $climate->backgroundRed($issue->getMessage()); ++$errors; } } } if ($errors > 0) { $climate->backgroundRed('✘ Review has found errors.'); } elseif ($warnings > 0) { $climate->yellow('Review has found warnings.'); } elseif ($info > 0) { $climate->green('Review has found some problems and fixed them manually.'); } else { $climate->green('✔ Looking good. Have you tested everything?'); } // Check if any issues were found. // Exit with a non-zero to block the commit. $errors > 0 ? exit(1) : exit(0);
$review->addReview($codeSniffer); // Review the staged files. $review->files($git->getStagedFiles()); // output any errors or warnings if ($reporter->hasIssues()) { $climate->out('')->out(''); foreach ($reporter->getIssues() as $issue) { switch ($issue->getColour()) { case 'red': $climate->red($issue); break; case 'cyan': $climate->cyan($issue); break; case 'brown': $climate->yellow($issue); break; default: $climate->white($issue); break; } } } // Check if any matching issues were found. if ($reporter->hasErrors()) { $climate->out('')->red('✘ Please fix the errors above.'); exit(1); } else { $climate->out('')->green('✔ No errors. Code looks good.')->white('Have you tested everything?'); exit(0); }