<commit_before><?php
/**
 * User: hernan
 * Date: 18/10/2017
 * Time: 11:11
 */

namespace App\Console\Commands;

use App\Services\PluginCreateCompiler;
use Illuminate\Console\Command;

class CreatePlugin extends Command
{
    /**
     * Command to create plugin inside Backend Lortom
     * @var string
     */
    protected $signature = 'lortom-plugin:create {--vendor-name= : Pass the Vendor,Name for your plugin!}';

    protected $description = 'In Order to create a plugin digit --vendor-name=Vendor,Name';

    /**
     * @var \App\Services\PluginCreateCompiler
     */
    protected $compiler;

    public function __construct(PluginCreateCompiler $compiler)
    {
        parent::__construct();
        $this->compiler = $compiler;
    }

    public function handle()
    {
        $VendorName = $this->option('vendor-name');

        $vendor = '';
        $name = '';

        if(is_null($VendorName))
        {
            $vendor = $this->ask('Vendor Name?');
            $name   = $this->ask('Name of Plugin?');
        }
        else
        {
            $vendorName = explode(',',$VendorName);

            if(count($vendorName) != 2)
            {
                $vendor = $this->ask('Vendor Name?');
                $name   = $this->ask('Name of Plugin?');
            }
            else
            {
                $vendor = $vendorName[0];
                $name   = $vendorName[1];
            }
        }

        if($this->confirm("This is the Vendor = {$vendor}, the Name= {$name} of plugin that you choice, Do you wish to continue?"))
        {
            $this->line('Ok, now is time to Create your Plugin!');

            $bar = $this->output->createProgressBar(9);

            $compiler = $this->compiler->setVendorName($vendor,$name);
            $bar->advance();

            $compiler = $compiler->writingDirectory();
            $bar->advance();

            $compiler = $compiler->writingFileComponent();
            $bar->advance();
<commit_msg>Added the control if Vendor/PluginName already exist<commit_after><?php
/**
 * User: hernan
 * Date: 18/10/2017
 * Time: 11:11
 */

namespace App\Console\Commands;

use App\Services\PluginCreateCompiler;
use Illuminate\Console\Command;
use File;

class CreatePlugin extends Command
{
    /**
     * Command to create plugin inside Backend Lortom
     * @var string
     */
    protected $signature = 'lortom-plugin:create {--vendor-name= : Pass the Vendor,Name for your plugin!}';

    protected $description = 'In Order to create a plugin digit --vendor-name=Vendor,Name';

    /**
     * @var \App\Services\PluginCreateCompiler
     */
    protected $compiler;

    public function __construct(PluginCreateCompiler $compiler)
    {
        parent::__construct();
        $this->compiler = $compiler;
    }

    public function handle()
    {
        $VendorName = $this->option('vendor-name');

        $vendor = '';
        $name = '';

        if(is_null($VendorName))
        {
            $vendor = $this->ask('Vendor Name?');
            $name   = $this->ask('Name of Plugin?');
        }
        else
        {
            $vendorName = explode(',',$VendorName);

            if(count($vendorName) != 2)
            {
                $vendor = $this->ask('Vendor Name?');
                $name   = $this->ask('Name of Plugin?');
            }
            else
            {
                $vendor = $vendorName[0];
                $name   = $vendorName[1];
            }
        }

        if($this->confirm("This is the Vendor = {$vendor}, the Name= {$name} of plugin that you choice, Do you wish to continue?"))
        {

            $name = str_replace('-',' ',$name);
            $name = ucwords($name);
            $name = str_replace(' ','',$name);

            $pathPlugin = __DIR__.'/../../../angular-backend/src/plugins/';

            if(File::exists($pathPlugin.$vendor))
            {
                $pathVendor = $pathPlugin.$vendor.'/';

                if(File::exists($pathVendor.$name))
                {
                    $this->info("This Plugin: {$name} in this Vendor: {$vendor} already exist! Please select other Name for your plugin");
                    return;
                }
            }

            $this->line('Ok, now is time to Create your Plugin!');

            $bar = $this->output->createProgressBar(9);

            $compiler = $this->compiler->setVendorName($vendor,$name);
            $bar->advance();

            $compiler = $compiler->writingDirectory();
            $bar->advance();

            $compiler = $compiler->writingFileComponent();
            $bar->advance();

{'fraction_non_alphanumeric': 0.1475622968580715, 'fraction_numerical': 0.006933911159263272, 'mean_word_length': 1.8511426806670785, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, 'https://': 0, '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': '5756272', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1264, 'n_words': 291}