protected function execute(InputInterface $input, OutputInterface $output) { global $root, $config; $new_config = array(); $tab = ' '; $output->writeln("installer"); $output->writeln("...."); $output->writeln("Checking Requirements"); if (\SDK\Util\Command::exists('git')) { $output->writeln("found git"); } else { $output->writeln("cannot find git"); return "GIT_MISSING"; } if (\SDK\Util\Command::exists("composer")) { $output->writeln("found composer"); } else { $output->writeln("cannot find composer"); return "COMPOSER_MISSING"; } if (\SDK\Util\Command::exists("curl")) { $output->writeln("found curl"); } else { $output->writeln("cannot find curl"); return "CURL_MISSING"; } $output->writeln(" "); // get git hub account $readAccount = null; $read = null; while (empty($readAccount)) { while (empty($read)) { $read = readline("Please enter your git hub account: "); } $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $config['git']['url'] . $read . '/SuiteCRM.git'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser $cresponse = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); if (strpos($cresponse, 'error') !== false) { $output->writeln("Cannot find SuiteCRM fork. Please ensure that you have forked https://github.com/salesagility/SuiteCRM.git"); $read = null; } else { $readAccount = $cresponse; $config['git']['projects']['SuiteCRM'] = array("upstream" => $config['git']['url'] . "salesagility/SuiteCRM.git", "origin" => $config['git']['url'] . $read . "/SuiteCRM.git"); file_put_contents('config.php', '<?php' . PHP_EOL . 'global $config; $config = ' . var_export($config, true) . ';' . PHP_EOL); if (!file_exists('instances')) { mkdir('instances'); } } } }
require_once "config.php"; require_once "vendor/autoload.php"; global $root, $config; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ResponseInterface as Response; $app = new \Slim\App(); $app->get('/', function (Request $request, Response $response) { $apiCalls = array('api' => array('githubForkExists', 'getInstances', '/getConfig', '/githubForkExists/{name}', '/getLatestRelease', '/setupConfig/{name}', '/phpmyadmin')); return $response->withHeader('Content-Type', 'application/json')->getBody()->write(json_encode($apiCalls)); }); $app->get('/getDependencies', function (Request $request, Response $response) { $dependancies = array(); $dependancies[] = array('name' => 'git', 'found' => \SDK\Util\Command::exists('git'), 'requirement' => 'required'); $dependancies[] = array('name' => 'composer', 'found' => \SDK\Util\Command::exists('composer'), 'requirement' => 'required'); $dependancies[] = array('name' => 'curl', 'found' => \SDK\Util\Command::exists('curl'), 'requirement' => 'required'); $dependancies[] = array('name' => 'phpunit', 'found' => \SDK\Util\Command::exists('phpunit'), 'requirement' => 'optional'); return $response->withHeader('Content-Type', 'application/json')->getBody()->write(json_encode($dependancies)); }); $app->get('/getConfig', function (Request $request, Response $response) { require_once "config.php"; return $response->withHeader('Content-Type', 'application/json')->getBody()->write(json_encode($config)); }); $app->get('/githubForkExists/{name}', function (Request $request, Response $response) { $name = $request->getAttribute('name'); $exists = \SDK\Util\GitHub::forkExists($name); return $response->withHeader('Content-Type', 'application/json')->getBody()->write(json_encode($exists)); }); $app->get('/getLatestRelease', function (Request $request, Response $response) { $cresponse = \SDK\Util\GitHub::getLatestRelease(); return $response->withHeader('Content-Type', 'application/json')->getBody()->write($cresponse); });
public function testExists() { $this->assertEquals(Command::exists('phpunit'), true); }