Пример #1
0
 public function transformReadmeMd($readmepathsource, $readmepathdestination)
 {
     if (!File::exists($readmepathsource)) {
         $this->command->error('File ' . $readmepathsource . ' not exist');
         exit;
     }
     $dir = \Padosoft\Workbench\Parameters\Dir::adjustPath(__DIR__) . 'resources/index.html';
     if (!File::exists($dir)) {
         $this->command->error('File ' . $dir . ' not exist');
         exit;
     }
     File::copy($dir, $readmepathdestination);
     $index = file_get_contents($readmepathdestination);
     $index = str_replace('@@@package_name', $this->workbenchSettings->requested['packagename']['valore'], $index);
     $readme = file_get_contents($readmepathsource);
     $converter = new CommonMarkConverter();
     $index = str_replace("@@@readme", $converter->convertToHtml($readme), $index);
     $documentation = "<h1>API Documentation</h1>\n<p>Please see API documentation at http://" . $this->workbenchSettings->requested['organization']['valore'] . ".github.io/" . $this->workbenchSettings->requested['packagename']['valore'] . "</p>";
     $documentation_mod = "<a name=api-documentation ></a>" . "<h1>API Documentation</h1>\n<p>Please see API documentation at <a href ='http://" . $this->workbenchSettings->requested['organization']['valore'] . ".github.io/" . $this->workbenchSettings->requested['packagename']['valore'] . "'>" . $this->workbenchSettings->requested['packagename']['valore'] . "</a></p>";
     $destination = File::dirname($readmepathdestination);
     $list = array_diff(File::directories($destination), array($destination . '\\resources'));
     $list = array_diff($list, array($destination . '/resources'));
     $documentation_mod = $documentation_mod . "<ul>";
     foreach ($list as $tag) {
         $tag = File::basename(\Padosoft\Workbench\Parameters\Dir::adjustPath($tag));
         $documentation_mod = $documentation_mod . "<li><a href = 'https://" . $this->workbenchSettings->requested['organization']['valore'] . ".github.io/" . $this->workbenchSettings->requested['packagename']['valore'] . "/" . $tag . "'>" . $tag . "</a></li>";
     }
     $documentation_mod = $documentation_mod . "</ul>";
     $index = str_replace($documentation, $documentation_mod, $index);
     file_put_contents($readmepathdestination, $index);
 }
Пример #2
0
 /**
  * @param $fileLog
  * @param $tag
  */
 public function writeChangeLog($fileLog, $tag)
 {
     $file = \Padosoft\Workbench\Parameters\Dir::adjustPath($fileLog);
     $changeLog = file_get_contents($fileLog);
     $toSubstitute = "# Changelog\r\n\r\nAll Notable changes to " . $this->workbenchSettings->getRequested()['packagename']['valore'] . " will be documented in this file\r\n\r\n";
     $toAddToFile = $toSubstitute . "## " . $tag . " - " . date("Y-m-d") . "\r\n";
     foreach ($this->changes as $key => $values) {
         if (count($this->changes[$key])) {
             $toAddToFile = $toAddToFile . "\r\n";
             $toAddToFile = $toAddToFile . "### " . ucfirst($key) . "\r\n";
         }
         foreach ($this->changes[$key] as $change) {
             $toAddToFile = $toAddToFile . "- " . $change . "\r\n";
         }
     }
     $toAddToFile = $toAddToFile . "\r\n";
     $newChangeLog = str_replace($toSubstitute, $toAddToFile, $changeLog);
     file_put_contents($fileLog, $newChangeLog);
 }
Пример #3
0
 public function read($silent)
 {
     if ($silent && !$this->requested["dirtype"]["valore-valido"] && !$this->requested["dirtype"]["valore-valido-default"]) {
         $this->exitWork("The type of dir is not correct, choice from 'public' or 'private' ");
     }
     if ($silent && !$this->requested["dirtype"]["valore-valido"] && $this->requested["dirtype"]["valore-valido-default"]) {
         $this->requested["dirtype"]["valore"] = $this->requested["dirtype"]["valore-default"];
         $this->requested["dirtype"]["valore-valido"] = true;
     }
     if (!$silent && !$this->requested["dirtype"]["valore-valido"]) {
         $this->requested["dirtype"]["valore"] = $this->command->choice('What type of dir?', ['public', 'private']);
         $this->requested["dirtype"]["valore-valido"] = true;
     }
     $dirtype = $this->requested["dirtype"]["valore"];
     if (substr($this->requested["type"]['valore'], -7) == 'package') {
         $this->requested["dir"]["valore"] = Dir::adjustPath(Config::get('workbench.diraccess.' . $dirtype . '.packages')) . $this->requested["organization"]["valore"] . '/';
     }
     if (substr($this->requested["type"]['valore'], -7) != 'package') {
         $this->requested["dir"]["valore"] = Dir::adjustPath(Config::get('workbench.diraccess.' . $dirtype . '.local'));
     }
     $this->command->getWorkbenchSettings()->setRequested($this->requested);
 }
Пример #4
0
 public function read($silent)
 {
     if ($silent && !$this->requested["dir"]["valore-valido"] && !$this->requested["dir"]["valore-valido-default"]) {
         $this->exitWork("Domain's path is not correct.");
     }
     if ($silent && !$this->requested["dir"]["valore-valido"] && $this->requested["dir"]["valore-valido-default"]) {
         $this->requested["dir"]["valore"] = $this->requested["dir"]["valore-default"];
         $this->requested["dir"]["valore-valido"] = true;
     }
     $attemps = Config::get('workbench.attemps');
     $attemp = 0;
     while (!$silent && !$this->requested["dir"]["valore-valido"] && $attemp < $attemps) {
         $this->command->error("This domain path '" . $this->requested["dir"]["valore"] . "' is not valid");
         $this->requested["dir"]["valore"] = Dir::adjustPath($this->command->ask('Path dir for domain, without dir domain folder', $this->requested["dir"]["valore-valido-default"] ? $this->requested["dir"]["valore-default"] : $this->requested["dir"]["valore"]));
         $this->requested["dir"]["valore-valido"] = Dir::isValidValue($this->requested["dir"]["valore"]);
         $attemp++;
         if ($attemp == $attemps) {
             return $this->command->error("Exit for invalid path");
         }
     }
     $this->command->getWorkbenchSettings()->setRequested($this->requested);
 }
Пример #5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $finder = new ExecutableFinder();
     $this->gitBinary = '"' . str_replace("\\", "/", $finder->find('git')) . '"';
     if (!$this->gitBinary) {
         throw new GitException('Unable to find the Git executable.');
     }
     $this->phpBinary = '"' . str_replace("\\", "/", $finder->find('php')) . '"';
     if (!$this->phpBinary) {
         throw new Exception('Unable to find the Php executable.');
     }
     $this->BASE_PATH = $this->argument("dir");
     if (empty($this->argument("dir"))) {
         $this->BASE_PATH = __DIR__;
     }
     $this->BASE_PATH = \Padosoft\Workbench\Parameters\Dir::adjustPath($this->BASE_PATH);
     $this->domain = basename($this->BASE_PATH);
     $this->ORGANIZATION_PATH = \Padosoft\Workbench\Parameters\Dir::adjustPath(substr($this->BASE_PATH, 0, strlen($this->BASE_PATH) - (strlen($this->domain) + 1)));
     $json = json_decode(file_get_contents($this->BASE_PATH . "composer.json"), true);
     $this->organization = explode("/", $json["name"])[0];
     $this->packagename = explode("/", $json["name"])[1];
     $this->type = in_array("public", explode("/", strtolower($this->BASE_PATH))) ? "public" : "private";
     $this->hardWork($this->argument(), $this->option());
 }
Пример #6
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $finder = new ExecutableFinder();
     $this->gitBinary = '"' . str_replace("\\", "/", $finder->find('git')) . '"';
     if (!$this->gitBinary) {
         throw new GitException('Unable to find the Git executable.');
     }
     $this->phpBinary = '"' . str_replace("\\", "/", $finder->find('php')) . '"';
     if (!$this->phpBinary) {
         throw new Exception('Unable to find the Php executable.');
     }
     //$gitWrapper = new GitWrapper();
     /*
             try {
                 $output = $gitWrapper->git("rev-parse --quiet --verify gh-pages","Y:/Public/laravel-packages/www/doc/padosoft/workbench");
             }
             catch (\Exception $e) {
                 $output = "";
                 //dd($e->getMessage() ."\r\n". $e->getTraceAsString());
             }*/
     $this->BASE_PATH = $this->argument("dir");
     if (empty($this->argument("dir"))) {
         $this->BASE_PATH = base_path();
     }
     if (!is_dir($this->BASE_PATH)) {
         if (is_dir(base_path() . '/' . $this->BASE_PATH)) {
             $this->BASE_PATH = base_path() . '/' . $this->BASE_PATH;
         } else {
             exit;
         }
     }
     $this->BASE_PATH = \Padosoft\Workbench\Parameters\Dir::adjustPath($this->BASE_PATH);
     $this->line("Path analyzed: " . $this->BASE_PATH);
     $this->domain = basename($this->BASE_PATH);
     $this->ORGANIZATION_PATH = \Padosoft\Workbench\Parameters\Dir::adjustPath(substr($this->BASE_PATH, 0, strlen($this->BASE_PATH) - (strlen($this->domain) + 1)));
     $json = json_decode(file_get_contents($this->BASE_PATH . "composer.json"), true);
     $this->organization = explode("/", $json["name"])[0];
     $this->packagename = explode("/", $json["name"])[1];
     $this->type = in_array("public", explode("/", strtolower($this->BASE_PATH))) ? "public" : "private";
     $this->hardWork($this->argument(), $this->option());
 }
Пример #7
0
 public function enableScrutinizer()
 {
     if ($this->workbenchSettings->requested["user"]["valore"] == "") {
         return;
     }
     if (substr($this->workbenchSettings->requested["type"]['valore'], -7) != 'package') {
         return;
     }
     $dir = Parameters\Dir::adjustPath($this->workbenchSettings->requested["dir"]['valore'] . $this->workbenchSettings->requested["domain"]['valore']);
     if (!File::exists($dir . ".scrutinizer.yml")) {
         return;
     }
     if (!$this->ask("Do you want enable Scrutinizer?", "Yes")) {
         return;
     }
     $getParam = array();
     $postParam = array();
     $postParam["name"] = $this->workbenchSettings->requested['organization']['valore'] . "/" . $this->workbenchSettings->requested['packagename']['valore'];
     $postParam["organization"] = $this->workbenchSettings->requested['organization']['valore'];
     $response = HttpHelperFacade::sendPostJsonWithAuth("https://scrutinizer-ci.com/api/repositories/g?access_token=" . Config::get('workbench.scrutinizer_token'), $postParam, "", "");
     if ($response->status_code == "201") {
         $this->info("Status code: " . $response->status_code);
     }
     if ($response->status_code != "201") {
         $this->error("Attention!! Status code: " . $response->status_code);
     }
     $this->warn($response->body);
 }