<commit_before><?php
/**
 * Created by PhpStorm.
 * User: Alessandro
 * Date: 02/09/2016
 * Time: 12:04
 */

namespace Padosoft\Workbench;

use Padosoft\Workbench\WorkbenchSettings;
use Illuminate\Console\Command;
use File;
use Config;
use League\CommonMark\CommonMarkConverter;
use GitWrapper\GitWrapper;

class WorkbenchApiGeneration
{

    private $workbenchSettings;
    private $command;

    public function __construct(WorkbenchSettings $workbenchSettings, Command $command){
        $this->workbenchSettings = $workbenchSettings;
        $this->command = $command;
    }

    public function apigeneration()
    {
        $source = \Padosoft\Workbench\Parameters\Dir::adjustPath($this->workbenchSettings->requested['dir']['valore'].$this->workbenchSettings->requested['domain']['valore']);
        $destination = \Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.diraccess.'.$this->workbenchSettings->requested['dirtype']['valore'].'.doc').$this->workbenchSettings->requested['organization']['valore']).$this->workbenchSettings->requested['domain']['valore'];
        exec(Config::get('workbench.php_path').' '.\Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.common_dev_lib_path')).'apigen.phar generate --source '.$source.' --destination '.$destination.'/dev-master');

        File::copyDirectory($destination.'/dev-master/resources/', $destination.'/resources/');
        $readmepathsource = \Padosoft\Workbench\Parameters\Dir::adjustPath($source).'readme.md';
        $readmepathdestination = \Padosoft\Workbench\Parameters\Dir::adjustPath($destination).'index.html';
        $this->transformReadmeMd($readmepathsource, $readmepathdestination);

        $gitWrapper = new GitWrapper();
        $gitWorkingCopy=$gitWrapper->init($destination,[]);
        $gitWrapper->git("config --global user.name ".$this->workbenchSettings->requested['user']['valore']);
        $gitWrapper->git("config --global user.email ".$this->workbenchSettings->requested['email']['valore']);
        $gitWrapper->git("config --global user.password ".$this->workbenchSettings->requested['password']['valore']);
        $extension = ($this->workbenchSettings->requested["git"]["valore"]==Parameters\Git::BITBUCKET ? "org" : "com");
        $gitWorkingCopy->addRemote('origin',"https://".$this->workbenchSettings->requested['user']['valore'].":".$this->workbenchSettings->requested['password']['valore']."@".$this->workbenchSettings->requested["git"]["valore"].".". $extension ."/".$this->workbenchSettings->requested['organization']['valore']."/".$this->workbenchSettings->requested['packagename']['valore'].".git" );
        $gitWorkingCopy->checkoutNewBranch('gh-pages');
        $gitWorkingCopy->add('.');
        $gitWorkingCopy->commit('Workbench commit');
        $gitWorkingCopy->push('origin','gh-pages');

    }

    public function apiSamiGeneration()
    {

        $source = \Padosoft\Workbench\Parameters\Dir::adjustPath($this->workbenchSettings->requested['dir']['valore'].$this->workbenchSettings->requested['domain']['valore']);
        $destination = \Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.diraccess.'.$this->workbenchSettings->requested['dirtype']['valore'].'.doc').$this->workbenchSettings->requested['organization']['valore']).$this->workbenchSettings->requested['domain']['valore'];
        echo Config::get('workbench.php_path').' '.\Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.common_dev_lib_path')).'sami.phar update '.$source.'sami_config.php';
        exec(Config::get('workbench.php_path').' '.\Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.common_dev_lib_path')).'sami.phar update '.$source.'sami_config.php');

        $readmepathsource = \Padosoft\Workbench\Parameters\Dir::adjustPath($source).'readme.md';
        $readmepathdestination = \Padosoft\Workbench\Parameters\Dir::adjustPath($destination).'index.html';
        $this->transformReadmeMd($readmepathsource, $readmepathdestination);

        $gitWrapper = new GitWrapper();
        $gitWorkingCopy=$gitWrapper->init($destination,[]);
        $gitWrapper->git("config --global user.name ".$this->workbenchSettings->requested['user']['valore']);
        $gitWrapper->git("config --global user.email ".$this->workbenchSettings->requested['email']['valore']);
        $extension = ($this->workbenchSettings->requested["git"]["valore"]==Parameters\Git::BITBUCKET ? "org" : "com");
        $gitWorkingCopy->addRemote('origin',"https://".$this->workbenchSettings->requested['user']['valore'].":".$this->workbenchSettings->requested['password']['valore']."@".$this->workbenchSettings->requested["git"]["valore"].".". $extension ."/".$this->workbenchSettings->requested['organization']['valore']."/".$this->workbenchSettings->requested['packagename']['valore'].".git" );
        $gitWorkingCopy->checkoutNewBranch('gh-pages');
        $gitWorkingCopy->add('.');
        $gitWorkingCopy->commit('Workbench commit');
        $gitWorkingCopy->push('origin','gh-pages');

    }<commit_msg>Test package<commit_after><?php
/**
 * Created by PhpStorm.
 * User: Alessandro
 * Date: 02/09/2016
 * Time: 12:04
 */

namespace Padosoft\Workbench;

use Padosoft\Workbench\WorkbenchSettings;
use Illuminate\Console\Command;
use File;
use Config;
use League\CommonMark\CommonMarkConverter;
use GitWrapper\GitWrapper;

class WorkbenchApiGeneration
{

    private $workbenchSettings;
    private $command;

    public function __construct(WorkbenchSettings $workbenchSettings, Command $command){
        $this->workbenchSettings = $workbenchSettings;
        $this->command = $command;
    }

    public function apigeneration()
    {
        $source = \Padosoft\Workbench\Parameters\Dir::adjustPath($this->workbenchSettings->requested['dir']['valore'].$this->workbenchSettings->requested['domain']['valore']);
        $destination = \Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.diraccess.'.$this->workbenchSettings->requested['dirtype']['valore'].'.doc').$this->workbenchSettings->requested['organization']['valore']).$this->workbenchSettings->requested['domain']['valore'];
        exec(Config::get('workbench.php_path').' '.\Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.common_dev_lib_path')).'apigen.phar generate --source '.$source.' --destination '.$destination.'/dev-master');

        File::copyDirectory($destination.'/dev-master/resources/', $destination.'/resources/');
        $readmepathsource = \Padosoft\Workbench\Parameters\Dir::adjustPath($source).'readme.md';
        $readmepathdestination = \Padosoft\Workbench\Parameters\Dir::adjustPath($destination).'index.html';
        $this->transformReadmeMd($readmepathsource, $readmepathdestination);

        $gitWrapper = new GitWrapper();
        $gitWorkingCopy=$gitWrapper->init($destination,[]);
        $gitWrapper->git("config --global user.name ".$this->workbenchSettings->requested['user']['valore']);
        $gitWrapper->git("config --global user.email ".$this->workbenchSettings->requested['email']['valore']);
        $gitWrapper->git("config --global user.password ".$this->workbenchSettings->requested['password']['<PASSWORD>']);
        $extension = ($this->workbenchSettings->requested["git"]["valore"]==Parameters\Git::BITBUCKET ? "org" : "com");
        $gitWorkingCopy->addRemote('origin',"https://".$this->workbenchSettings->requested['user']['valore'].":".$this->workbenchSettings->requested['password']['valore']."@".$this->workbenchSettings->requested["git"]["valore"].".". $extension ."/".$this->workbenchSettings->requested['organization']['valore']."/".$this->workbenchSettings->requested['packagename']['valore'].".git" );
        $gitWorkingCopy->checkoutNewBranch('gh-pages');
        $gitWorkingCopy->add('.');
        $gitWorkingCopy->commit('Workbench commit');
        $gitWorkingCopy->push('origin','gh-pages');

    }

    public function apiSamiGeneration()
    {

        $source = \Padosoft\Workbench\Parameters\Dir::adjustPath($this->workbenchSettings->requested['dir']['valore'].$this->workbenchSettings->requested['domain']['valore']);
        $destination = \Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.diraccess.'.$this->workbenchSettings->requested['dirtype']['valore'].'.doc').$this->workbenchSettings->requested['organization']['valore']).$this->workbenchSettings->requested['domain']['valore'];
        echo Config::get('workbench.php_path').' '.\Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.common_dev_lib_path')).'sami.phar update '.$source.'sami_config.php';
        exec(Config::get('workbench.php_path').' '.\Padosoft\Workbench\Parameters\Dir::adjustPath(Config::get('workbench.common_dev_lib_path')).'sami.phar update '.$source.'sami_config.php');

        $readmepathsource = \Padosoft\Workbench\Parameters\Dir::adjustPath($source).'readme.md';
        $readmepathdestination = \Padosoft\Workbench\Parameters\Dir::adjustPath($destination).'index.html';
        $this->transformReadmeMd($readmepathsource, $readmepathdestination);

        $gitWrapper = new GitWrapper();
        $gitWorkingCopy=$gitWrapper->init($destination,[]);
        $gitWrapper->git("config --global user.name ".$this->workbenchSettings->requested['user']['valore']);
        $gitWrapper->git("config --global user.email ".$this->workbenchSettings->requested['email']['valore']);
        $extension = ($this->workbenchSettings->requested["git"]["valore"]==Parameters\Git::BITBUCKET ? "org" : "com");
        $gitWorkingCopy->removeRemote('origin');
        $gitWorkingCopy->addRemote('origin',"https://".$this->workbenchSettings->requested['user']['valore'].":".$this->workbenchSettings->requested['password']['valore']."@".$this->workbenchSettings->requested["git"]["valore"].".". $extension ."/".$this->workbenchSettings->requested['organization']['valore']."/".$this->workbenchSettings->requested['packagename']['valore'].".git" );
        $gitWorkingCopy->checkoutNewBranch('gh-pages');
        $gitWorkingCopy->add('.');
        $gitWorkingCopy->commit('Workbench commit');
        $gitWorkingCopy->push('origin','gh-pages');

    }
{'fraction_non_alphanumeric': 0.19988230678697527, 'fraction_numerical': 0.0023538642604943117, 'mean_word_length': 5.453797468354431, 'pattern_counts': {'":': 4, '<': 6, '<?xml version=': 0, '>': 155, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '496504', 'n_tokens_mistral': 3041, 'n_tokens_neox': 2994, 'n_words': 274}