Example #1
0
 /**
  * Create a new installer instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @return void
  */
 public function __construct($command)
 {
     $this->command = $command;
     $this->command->line('Installing JavaScript & Less Assets: <info>✔</info>');
     $this->command->line('Installing Language Files: <info>✔</info>');
     $this->command->line('Installing Views: <info>✔</info>');
 }
Example #2
0
 /**
  * Create a new installer instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @return void
  */
 public function __construct($command)
 {
     $this->command = $command;
     $this->command->line('Updating Routes File: <info>✔</info>');
     $this->command->line('Updating Controllers: <info>✔</info>');
     $this->command->line('Updating Middleware: <info>✔</info>');
     $this->command->line('Updating HTTP Kernel: <info>✔</info>');
 }
Example #3
0
 /**
  * Clear the settings cache, and backup the databases.
  *
  * @param \Illuminate\Console\Command $command
  *
  * @return void
  */
 public function fire(Command $command)
 {
     $command->line('Clearing settings cache...');
     $this->cache->clear();
     $command->line('Settings cache cleared!');
     $command->line('Backing up database...');
     try {
         $command->call('db:backup', ['--compression' => 'gzip', '--database' => $this->config->get('database.default'), '--destination' => 'local', '--destinationPath' => Carbon::now()->format('Y-m-d H.i.s'), '--no-interaction' => true]);
     } catch (Exception $e) {
         $command->error($e->getMessage());
         $command->line('Backup skipped!');
     }
     $command->line('Backup completed!');
 }
 public function check($release)
 {
     $this->command->line('Lastest version found is <info>' . $release . '</info> 
     Current version is <info>' . $this->getSparkVersion() . '</info>' . PHP_EOL);
     if ($this->supported($release)) {
         $this->command->line('Release ' . $release . ' is Hexavel compatible: <info>✔</info>');
         return true;
     }
     $this->command->line('<error>Version ' . $release . ' is not yet considered Hexavel compatible</error>' . PHP_EOL);
     $this->command->line('This <fg=red;options=bold;>might break your application</> but you can continue at your own risk. If you have not already, try updating Hexavel-Spark via \'composer update\'.');
     if (!$this->command->confirm('Do you wish to still continue? [y|N]')) {
         return false;
     }
     return true;
 }
Example #5
0
 /**
  * Uses the bound Command object to output text to the screen.
  * If there is no Command object bound, it simply does nothing.
  *
  * @param string The string to output
  *
  * @return void
  */
 protected function line($string)
 {
     if (!$this->output) {
         return false;
     }
     $this->output->line($string);
 }
Example #6
0
 /**
  * Run the installation process.
  *
  * @return \Symfony\Component\Process\Process
  */
 public function run()
 {
     $process = $this->getProcess();
     $process->setTimeout($this->timeout);
     if ($this->console instanceof Command) {
         $process->run(function ($type, $line) {
             $this->console->line($line);
         });
     }
     return $process;
 }
Example #7
0
 public function execWithOutput(string $cmd, Command $console)
 {
     // Setup the file descriptors
     $descriptors = [0 => ['pipe', 'w'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
     // Start the script
     $proc = proc_open($cmd, $descriptors, $pipes);
     // Read the stdin
     $stdin = stream_get_contents($pipes[0]);
     fclose($pipes[0]);
     // Read the stdout
     $stdout = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
     // Read the stderr
     $stderr = stream_get_contents($pipes[2]);
     fclose($pipes[2]);
     // Close the script and get the return code
     $return_code = proc_close($proc);
     if ($stdin) {
         $console->line($stdin);
     }
     if ($stdout) {
         $console->line($stdout);
     }
     if ($stderr) {
         $console->line($stderr);
     }
     if (strpos($stdout, 'continue?')) {
         $console->error('A confirmation has been asked during the shell command execution.');
         $console->error('Please manually execute the command "' . $cmd . '" to treat that particular case.');
         return exit;
     }
     if ($return_code) {
         $console->error('Error exit code : ' . $return_code);
         if (!$console->ask('Do you want continue the script execution ? [Y/n]', true)) {
             return exit;
         }
     }
 }
Example #8
0
 /**
  * Publish something.
  */
 public function publish()
 {
     $sourcePath = $this->getSourcePath();
     if (!$this->isDirectory($sourcePath)) {
         return;
     }
     if (!$this->isDirectory($destinationPath = $this->getDestinationPath())) {
         $this->makeDirectory($destinationPath, 0775, true);
     }
     if ($this->copyDirectory($sourcePath, $destinationPath) && $this->showMessage) {
         $this->console->line("<info>Published</info>: {$this->module->getStudlyName()}");
     } else {
         $this->console->error($this->error);
     }
 }
Example #9
0
 /**
  * Publish something.
  */
 public function publish()
 {
     if (!$this->console instanceof Command) {
         $message = "The 'console' property must instance of \\Illuminate\\Console\\Command.";
         throw new \RuntimeException($message);
     }
     if (!$this->getFilesystem()->isDirectory($sourcePath = $this->getSourcePath())) {
         return;
     }
     if (!$this->getFilesystem()->isDirectory($destinationPath = $this->getDestinationPath())) {
         $this->getFilesystem()->makeDirectory($destinationPath, 0775, true);
     }
     if ($this->getFilesystem()->copyDirectory($sourcePath, $destinationPath)) {
         if ($this->showMessage == true) {
             $this->console->line("<info>Published</info>: {$this->module->getStudlyName()}");
         }
     } else {
         $this->console->error($this->error);
     }
 }
/**
 * Present a list of choices to user, return choice
 * @param Command $command The command requesting input
 * @param array $choices List of choices
 * @param int $default Default choice (1-array size), -1 to abort
 * @param string $abort String to tag on end for aborting selection
 * @return int -1 if abort selected, otherwise one greater than $choice index
 *        (in other words, choosing $choice[0] returns 1)
 * @throws InvalidArgumentException If argument is invalid
 */
function pick_from_list(Command $command, $title, array $choices, $default = 0, $abort = null)
{
    if ($abort) {
        $choices[] = $abort;
    }
    $numChoices = count($choices);
    if (!$numChoices) {
        throw new \InvalidArgumentException("Must have at least one choice");
    }
    if ($default == -1 && empty($abort)) {
        throw new \InvalidArgumentException('Cannot use default=-1 without $abort option');
    }
    if (!between($default, -1, $numChoices)) {
        throw new \InvalidArgumentException("Invalid value, default={$default}");
    }
    $question = "Please enter a number between 1-{$numChoices}";
    if ($default > 0) {
        $question .= " (default is {$default})";
    } elseif ($default < 0) {
        $question .= " (enter to abort)";
        $default = $numChoices;
    }
    $question .= ':';
    while (1) {
        $command->line('');
        $command->info($title);
        $command->line('');
        for ($i = 0; $i < $numChoices; $i++) {
            $command->line($i + 1 . ". " . $choices[$i]);
        }
        $command->line('');
        $answer = $command->ask($question);
        if ($answer == '') {
            $answer = $default;
        }
        if (between($answer, 1, $numChoices)) {
            if ($abort and $answer == $numChoices) {
                $answer = -1;
            }
            return (int) $answer;
        }
        // Output wrong choice
        $command->line('');
        $formatter = $command->getHelperSet()->get('formatter');
        $block = $formatter->formatBlock('Invalid entry!', 'error', true);
        $command->line($block);
    }
}
Example #11
0
 /**
  * Create a new installer instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @return void
  */
 public function __construct($command)
 {
     $this->command = $command;
     $this->command->line('Installing Database Migrations: <info>✔</info>');
 }
 /**
  * Display console message
  *
  * @param   string $s the message to display
  *
  * @return  void
  */
 public function writeLine($s)
 {
     if ($this->display) {
         parent::line($s);
     }
 }
Example #13
0
 /**
  * Create a new installer instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @return void
  */
 public function __construct($command)
 {
     $this->command = $command;
     $this->command->line('Installing Eloquent Models: <info>✔</info>');
 }
 /**
  * Display console message
  *
  * @param  string  $string
  * @param  string  $style
  * @param  null|int|string  $verbosity
  *
  * @return  void
  */
 public function line($string, $style = null, $verbosity = null)
 {
     if ($this->display) {
         parent::line($string, $style, $verbosity);
     }
 }
Example #15
0
 /**
  * Create a new installer instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @return void
  */
 public function __construct($command)
 {
     $this->command = $command;
     $this->command->line('Installing Service Providers: <info>✔</info>');
 }
 /**
  * Create a new command instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @param  string  $downloadPath
  * @return void
  */
 public function __construct($command, $downloadPath)
 {
     $this->downloadPath = $downloadPath;
     $command->line('Updating Spark Directory: <info>✔</info>');
 }
 /**
  * Create a new command instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @param  string  $downloadPath
  * @return void
  */
 public function __construct($command)
 {
     $command->line('Removing Temporary Download Directory: <info>✔</info>');
 }
 /**
  * Writes the record down to the log of the implementing handler
  *
  * @param  array $record
  *
  * @return void
  */
 protected function write(array $record)
 {
     $this->command->line((string) trim($record['formatted']));
 }
 /**
  * Create a new installer instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @return void
  */
 public function __construct($command)
 {
     $this->command = $command;
     $this->command->line('Updating Environment File: <info>✔</info>');
 }
Example #20
0
 /**
  * Handle a command.updatecache event.
  *
  * @param \Illuminate\Console\Command $command
  *
  * @return void
  */
 public function onUpdateCache(Command $command)
 {
     $command->line('Regenerating page cache...');
     $this->pagerepository->refresh();
     $command->info('Page cache regenerated!');
 }
Example #21
0
 /**
  * Inform the user that their Spark license is invalid.
  *
  * @return void
  */
 protected function invalidLicense($release)
 {
     $this->command->line('<fg=red>You do not own any licenses for release [' . $release . '].</>');
     exit(1);
 }
 /**
  * Handle a command.updatecache event.
  *
  * @param \Illuminate\Console\Command $command
  *
  * @return void
  */
 public function onUpdateCache(Command $command)
 {
     $command->line('Clearing cache...');
     $command->call('cache:clear');
     $command->info('Cache cleared!');
 }
Example #23
0
 /**
  * Create a new command instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @param  string  $downloadPath
  * @return void
  */
 public function __construct($command, $downloadPath)
 {
     $this->command = $command;
     $this->downloadPath = $downloadPath;
     $this->command->line('Updating Views: <info>✔</info>');
 }
 /**
  * Create a new installer instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @return void
  */
 public function __construct($command)
 {
     $this->command = $command;
     $this->command->line('Updating Configuration Values: <info>✔</info>');
 }
Example #25
0
 /**
  * Create a new installer instance.
  *
  * @param  \Illuminate\Console\Command  $command
  * @return void
  */
 public function __construct($command)
 {
     $this->command = $command;
     $this->command->line('Installing Images: <info>✔</info>');
 }
 public function line($string, $style = null, $verbosity = null)
 {
     parent::line($string, $style, $verbosity);
     $logString = trim($string);
     switch ($style) {
         case 'comment':
         case 'question':
             Log::debug($logString);
             break;
         case 'info':
             Log::info($logString);
             break;
         case 'error':
             Log::error($logString);
             break;
         case 'warning':
             Log::warning($logString);
             break;
         default:
             Log::debug($logString);
             break;
     }
 }