Ejemplo n.º 1
0
 /**
  * Prompt user to provide urls.
  *
  * @return array
  */
 protected function getSourceFromConsole()
 {
     $urls = [];
     while (true) {
         $url = $this->console->input('Please enter the url:')->prompt();
         if (0 === strlen($url)) {
             break;
         } elseif (false === filter_var($url, FILTER_VALIDATE_URL)) {
             $this->console->red('Invalid url, please enter the full url.');
         } else {
             $urls[] = $url;
         }
     }
     return $urls;
 }
Ejemplo n.º 2
0
 /**
  * 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;
     }
 }
Ejemplo n.º 3
0
 /**
  * @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}");
     }
 }
Ejemplo n.º 4
0
}
// Reference the required classes and the reviews you want to use.
use League\CLImate\CLImate;
use StaticReview\Reporter\Reporter;
use StaticReview\Review\Composer\ComposerLintReview;
use StaticReview\Review\General\LineEndingsReview;
use StaticReview\Review\General\NoCommitTagReview;
use StaticReview\Review\PHP\PhpLeadingLineReview;
use StaticReview\Review\PHP\PhpLintReview;
use StaticReview\StaticReview;
use StaticReview\VersionControl\GitVersionControl;
$reporter = new Reporter();
$climate = new CLImate();
$git = new GitVersionControl();
$review = new StaticReview($reporter);
// Add any reviews to the StaticReview instance, supports a fluent interface.
$review->addReview(new LineEndingsReview())->addReview(new PhpLeadingLineReview())->addReview(new NoCommitTagReview())->addReview(new PhpLintReview())->addReview(new ComposerLintReview());
// Review the staged files.
$review->review($git->getStagedFiles());
// Check if any matching issues were found.
if ($reporter->hasIssues()) {
    $climate->out('')->out('');
    foreach ($reporter->getIssues() as $issue) {
        $climate->red($issue);
    }
    $climate->out('')->red('✘ Please fix the errors above.');
    exit(1);
} else {
    $climate->out('')->green('✔ Looking good.')->white('Have you tested everything?');
    exit(0);
}
Ejemplo n.º 5
0
if (empty($pathinfo)) {
    $pathinfo = '--help';
}
// Create our app instance
$app = new SlimController\Slim(['debug' => false, 'controller.class_prefix' => '', 'controller.class_suffix' => '', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => '']);
// Set up the environment so that Slim can route
$app->environment = Slim\Environment::mock(['PATH_INFO' => $pathinfo]);
// Define the help command. If it doesn't have a name it won't include itself
$app->get('--help', function () use($app) {
    $writer = new CLImate();
    $writer->bold()->out('Available commands:');
    foreach ($app->router()->getNamedRoutes() as $route) {
        $writer->green()->out('    ' . $route->getPattern());
    }
});
// CLI-compatible not found error handler
$app->notFound(function () use($app) {
    $writer = new CLImate();
    $command = $app->environment['PATH_INFO'];
    $writer->red()->bold()->out(sprintf('Error: Cannot route to command "%s"', $command));
    $helpRoute = $app->router()->getMatchedRoutes('GET', '--help', true);
    $helpRoute[0]->dispatch();
    $app->stop();
});
// Format errors for CLI
$app->error(function (\Exception $e) use($app) {
    echo $e;
    echo PHP_EOL;
    $app->stop();
});
return $app;