public function testExecRunsCommandBuilder()
 {
     $shell = new Exec();
     $command = new CommandBuilder('touch');
     $command->addParam($this->testFile);
     $shell->run($command);
     $this->assertTrue(file_exists($this->testFile), sprintf('%s should have been created', $this->testFile));
 }
 /**
  * {@inheritDoc}
  * 
  * @see \HcpssBanderson\Patcher\PatcherInterface::patch()
  */
 public function patch(array $params)
 {
     list($source, $destination) = $this->resolveParams($params);
     $ds = DIRECTORY_SEPARATOR;
     $shell = new ShellExec();
     $patchCommand = new CommandBuilder('patch');
     $patchCommand->addSubCommand($this->projectBase . $ds . $destination)->addSubCommand($this->configBase . $ds . $source);
     return $shell->run($patchCommand);
 }
 /**
  * Get the output of the body.
  *
  * @access public
  * @param string $type - Either Command::HTML or Command::TEXT
  * @param mixed $body
  * @return string
  */
 public function getOutput($type, $body)
 {
     $command = new CommandBuilder($this->command);
     $tempFileName = $this->getTmpFile($body);
     //Set output type to $type
     $command->addArgument('mode', $type);
     //Add temporary file as parameter
     $command->addParam($tempFileName);
     $shell = new Exec();
     $shell->run($command);
     unlink($tempFileName);
     return implode("\n", $shell->getOutput());
 }
 public function generateTestAndKey()
 {
     //        if($missing = $this->getMissingParams(['title', 'copyright'])) {
     //            return response()->json(['error' => 'Missing params', 'missing' => $missing], 422);
     //        }
     $uniqId = uniqid();
     //        putenv("LANG='en_US.UTF-8'");
     //        putenv("LC_ALL='en_US.UTF-8'");
     $shell = new Exec();
     $cmd = new CommandBuilder(env('RUDI_PATH', './rudi/rudi'));
     $cmd->addArgument('output', './' . $uniqId);
     if (Input::has('title')) {
         $cmd->addArgument('title', Input::get('title'));
     }
     if (Input::has('copyright')) {
         $cmd->addArgument('copyright', Input::get('copyright'));
     }
     foreach ($this->nameToArgument as $name => $arg) {
         if (Input::has($name)) {
             if (Input::has($name . "-count")) {
                 $cmd->addArgument($arg, Input::get($name . "-count"));
             } else {
                 $cmd->addArgument($arg);
             }
         }
     }
     \Log::info($cmd);
     $shell->run($cmd);
     if ($shell->getReturnValue() !== 0) {
         return response()->json($shell->getOutput(), 500);
     }
     $output = '';
     $testString = 'lilypond ' . $uniqId . '.ly ' . $uniqId . '.pdf';
     $keyString = 'lilypond ' . $uniqId . '-key.ly ' . $uniqId . '-key.pdf';
     exec($testString, $output);
     exec($keyString, $output);
     unlink($uniqId . '.ly');
     unlink($uniqId . '-key.ly');
     return ['id' => $uniqId];
 }
 public function transferIBAN($value, $name, $iban, $bic, $subject)
 {
     $name = str_replace('"', '', $name);
     $value = str_replace('.', ',', $value) . ':EUR';
     $transfer_name = date('Y-m-d_H-i') . '_' . $iban;
     $command = new CommandBuilder('aqbanking-cli' . $this->is . ' -P "' . $this->config_dir . '/pinfile" -D "' . $this->config_dir . '/config' . '" sepatransfer --riban=' . $iban . ' --rname="' . $name . '"');
     $command->addFlag('c', $this->config_dir . '/transfer/' . $transfer_name . '.ctx')->addFlag('v', $value)->addFlag('p', $subject);
     $this->shell->run($command);
     return true;
 }
Exemple #6
0
 /**
  * {@inheritDoc}
  * 
  * @see \HcpssBanderson\Provider\ProviderInterface::assemble()
  */
 public function assemble(array $params)
 {
     $params = $this->resolveParams($params);
     $ds = DIRECTORY_SEPARATOR;
     $tempLocation = vsprintf('%s%s%s', [sys_get_temp_dir(), DIRECTORY_SEPARATOR, uniqid($this->getRepoName($params['source']))]);
     $shell = new ShellExec();
     // Clone the repository
     $cloneCommand = new CommandBuilder('git');
     $cloneCommand->addParam('clone')->addParam($params['source'])->addParam($tempLocation);
     $shell->run($cloneCommand);
     // Checkout the branch
     $checkoutCommand = new CommandBuilder('git');
     $checkoutCommand->addFlag('C', $tempLocation)->addParam('checkout')->addParam($params['branch']);
     $shell->run($checkoutCommand);
     // Delete the .git directory
     $ungitCommand = new CommandBuilder('rm');
     $ungitCommand->addFlag('rf')->addParam($tempLocation . $ds . '.git');
     $shell->run($ungitCommand);
     // Create the install location
     $destination = $this->projectBase;
     if ($params['destination']) {
         $destination .= $ds . $params['destination'];
     }
     if (!empty($params['rename'])) {
         $destination .= $ds . $params['rename'];
     }
     if (!file_exists($destination)) {
         $makeDestCmd = new CommandBuilder('mkdir');
         $makeDestCmd->addFlag('p')->addParam($destination);
         $shell->run($makeDestCmd);
     }
     // Move to the install location
     $moveCommand = new Command('mv');
     $moveCommand->addParam(new Param($tempLocation . $ds . '*', false));
     $moveCommand->addParam(new Param($destination, false));
     // Hidden files have to be specially invited
     $moveHiddenCommand = new Command('mv');
     $moveHiddenCommand->addParam(new Param($tempLocation . $ds . '.[!.]*', false));
     $moveHiddenCommand->addParam(new Param($destination, false));
     $shell->run($moveCommand);
     $shell->run($moveHiddenCommand);
     // Remove the old git folder
     $cleanTempCommand = new CommandBuilder('rm');
     $cleanTempCommand->addFlag('rf')->addParam($tempLocation);
     $shell->run($cleanTempCommand);
 }
 public function testCanAddMultipleParams()
 {
     $command = new Command('ls');
     $command->addParam('/srv')->addParam('/var');
     $this->assertEquals("ls '/srv' '/var'", (string) $command, 'Command should have multiple options');
 }
 /**
  * Symlinks the new deploy directory to the webroot.
  *
  * @return bool True if the symlink is successful. False otherwise.
  */
 private function deploy()
 {
     $cmd = new Command('cd');
     $cmd->addParam(dirname($this->webroot))->addSubCommand('&&')->addSubCommand('ln')->addFlag('fs')->addParam($this->installDir)->addParam($this->webroot);
     return $this->ex($cmd);
 }