Execute the console command.

@param Installer $installer
@throws \Exception
496321
public function handle(Installer $installer)
    {
        if (!$this->confirm('Do you wish to continue? [y|N]')) {
            return;
        }

        $name      = $this->argument('name');
        $extension = $this->manager->getAvailableExtensions()->findByName($name);

        if ($extension instanceof ExtensionContract) {
            $installer->run($this, $extension, $this->getValidOptions());
        } else {
            $this->error("Unable to find extension [{$name}].");
        }
    }
731466
public function fire(Application $app)
    {
        if (!$this->confirmToProceed()) {
            return;
        }

        $this->output->writeln('<info>Run application migrations ...</info>');
        $this->call('migrate');

        $this->output->writeln('<info>Run modules migrations ...</info>');
        $installer = new ModulesInstaller($app['modules.loader']->getRegisteredModules());

        $installer->cleanOutputMessages();

        if ($this->input->getOption('rollback')) {
            $installer->resetModules();
        }

        $installer->migrateModules();

        foreach ($installer->getOutputMessages() as $message) {
            $this->output->writeln($message);
        }

        // Finally, if the "seed" option has been given, we will re-run the database
        // seed task to re-populate the database, which is convenient when adding
        // a migration and a seed at the same time, as it is only this command.
        if ($this->input->getOption('seed')) {
            $this->call('db:seed');
            $this->call('modules:seed');
        }
    }
750025
public function fire()
    {
        $this->blockMessage('Welcome!', 'Starting the installation process...', 'comment');

        $success = $this->installer->stack([
            \Modules\Core\Console\Installers\Scripts\ProtectInstaller::class,
            \Modules\Core\Console\Installers\Scripts\RequirementsCheck::class,
            \Modules\Core\Console\Installers\Scripts\ResetEnvironment::class,
            \Modules\Core\Console\Installers\Scripts\ConfigureDatabase::class,
            \Modules\Core\Console\Installers\Scripts\SetAppKey::class,
            \Modules\Core\Console\Installers\Scripts\ModuleMigrator::class,
            \Modules\Core\Console\Installers\Scripts\ModuleSeeders::class,
            \Modules\Core\Console\Installers\Scripts\ModuleAssets::class,
            \Modules\Core\Console\Installers\Scripts\ThemeAssets::class,
            \Modules\Core\Console\Installers\Scripts\AdminUserInstaller::class,
            \Modules\Core\Console\Installers\Scripts\UnignoreComposerLock::class,
            \Modules\Core\Console\Installers\Scripts\SocietyIsInstalled::class,
        ])->install($this);

        if ($success) {
            $this->blockMessage(
                'SocietyCMS is ready',
                'You can now login with your username and password at /backend',
                'fg=black;bg=green;options=bold'
            );
        }
    }
415138
public function handle(ConfigurationProvider $provider, Migrator $migrator)
    {
        if (!$this->confirmToProceed()) {
            return;
        }

        $configuration = $provider->getForConnection(
            $this->option('connection') ?: null
        );

        try {
            $migration = new Migration(
                $configuration,
                $this->argument('version')
            );
        } catch (MigrationVersionException $e) {
            $this->error($e->getMessage());
        }

        try {
            $migration->checkIfNotExecutedUnavailableMigrations();
        } catch (ExecutedUnavailableMigrationsException $e) {
            $this->handleExecutedUnavailableMigrationsException($e, $configuration);
        }

        if ($path = $this->option('write-sql')) {
            $migrator->migrateToFile($migration, $path);
        } else {
            $migrator->migrate(
                $migration,
                $this->option('dry-run') ? true : false,
                $this->option('query-time') ? true : false,
                $this->option('allow-no-migration') ? true : false
            );
        }

        foreach ($migrator->getNotes() as $note) {
            $this->line($note);
        }
    }
228747
public function handle()
    {
        if (!$this->confirmToProceed()) {
            return;
        }

        $this->prepareDatabase();

        // Next, we will check to see if a path option has been defined. If it has
        // we will use the path relative to the root of this installation folder
        // so that migrations may be run for any path within the applications.
        $this->migrator->run($this->getMigrationPaths(), [
            'pretend' => $this->option('pretend'),
            'step' => $this->option('step'),
        ]);
		
        // Once the migrator has run we will grab the note output and send it out to
        // the console screen, since the migrator itself functions without having
        // any instances of the OutputInterface contract passed into the class.
        foreach ($this->getMigratorNotes() as $note) {
            $this->output->writeln($note);
        }

        // Finally, if the "seed" option has been given, we will re-run the database
        // seed task to re-populate the database, which is convenient when adding
        // a migration and a seed at the same time, as it is only this command.
        if ($this->option('seed')) {
            $this->call('db:seed', ['--force' => true]);
        }
    }
1030628
public function fire()
    {
        if (is_null($this->argument('name'))) {
            $this->installFromFile();

            return;
        }

        $this->install(
            $this->argument('name'),
            $this->argument('version'),
            $this->option('type'),
            $this->option('tree')
        );
    }
1350171
public function handle()
    {
        $this->line('------------------');
        $this->line('Welcome to TypiCMS');
        $this->line('------------------');

        $this->info('Publishing vendor packages...');
        $this->call('vendor:publish', ['--all' => true]);
        $this->line('------------------');

        $this->laravel['env'] = 'local';

        // Ask for database name
        $this->info('Setting up database...');
        $dbName = $this->ask('Enter a database name', $this->guessDatabaseName());

        // Set database credentials in .env and migrate
        $this->call('typicms:database', ['database' => $dbName]);
        $this->line('------------------');

        // Create a super user
        $this->createSuperUser();

        // Composer install
        if (function_exists('system')) {
            system('chmod 755 $(find storage -type d)');
            $this->info('Directory storage is now writable (755).');
            system('chmod 755 $(find bootstrap/cache -type d)');
            $this->info('Directory bootstrap/cache is now writable (755).');
            $this->line('------------------');
            $this->info('Running yarn...');
            system('yarn');
            $this->info('npm packages installed.');
        } else {
            $this->line('You can now make /storage, /bootstrap/cache directories writable.');
            $this->line('and run composer install and npm install.');
        }

        // Done
        $this->line('------------------');
        $this->line('Done. Enjoy TypiCMS!');
    }
962664
public function handle()
    {
        $this->line('Starting package template initialization...');
        try {
            $directory = $this->argument('directory');

            if (!$this->files->exists($directory)) {
                $createDirectory = $this->confirm("{$directory} does not exist. Would you like to create it? [YES/no]", true);

                if ($createDirectory) {
                    $this->line("{$directory} was created.");
                    $this->files->makeDirectory($directory);
                }
            }

            if ($this->files->exists($directory) && $this->files->isDirectory($directory)) {
                $fileCount = count($this->files->allFiles($directory));

                if ($fileCount > 0) {
                    $removeFiles = $this->confirm("{$directory} is not empty. Would you like to remove the contents? [yes|NO]", false);

                    if ($removeFiles) {
                        $this->line("The contents in '{$directory}' were cleared.");
                        $this->files->deleteDirectory($directory, true);
                    }
                }
            }

            $this->templateInitializer->setShouldCreateTemplateDirectory(!$this->option('no-template-dir'));

            $packageVendor = Package::parseVendorAndPackage($this->argument('name'));
            $this->templateInitializer->initialize($packageVendor[0], $packageVendor[1], $directory);
            $this->info('Package was successfully initialized!');
        } catch (InvalidPathException $invalidPath) {
            $this->error('There was a problem initializing the package template (most likely due to an invalid path). The error was:');
            $this->error($invalidPath->getMessage());
        } catch (InvalidArgumentException $invalidVendorPackage) {
            $this->error('There was a problem initializing the package template');
            $this->error($invalidVendorPackage->getMessage());
        }
    }
563054
public function handle()
    {
        // Next, we will check to see if a path option has been defined. If it has
        // we will use the path relative to the root of this installation folder
        // so that migrations may be run for any path within the applications.
        $this->deployer->run($this->getDeployPaths(), []);

        // Once the migrator has run we will grab the note output and send it out to
        // the console screen, since the migrator itself functions without having
        // any instances of the OutputInterface contract passed into the class.
        foreach ($this->deployer->getNotes() as $note) {
            $this->output->writeln($note);
        }
    }
1188790
public function handle()
    {
        if (ServiceProvider::ideHelperIsInstalled() && ServiceProvider::ideHelperIsAvailable()) {
            try {
                $this->call('ide-helper:generate', []);
            } catch (Exception $e) {
                $this->error($e->getMessage());
            }

            try {
                $this->call('ide-helper:meta', [
                    '--filename' => sprintf(
                        '%s.%s',
                        config('ide-helper.meta_filename', ServiceProvider::META_FILENAME),
                        config('ide-helper.format', ServiceProvider::FILES_FORMAT)
                    ),
                ]);
            } catch (Exception $e) {
                $this->error($e->getMessage());
            }

            try {
                $this->call('ide-helper:models', [
                    '--nowrite'  => true,
                    '--reset'    => true,
                    '--filename' => sprintf(
                        '%s.%s',
                        config('ide-helper.models_filename', ServiceProvider::MODELS_FILENAME),
                        config('ide-helper.format', ServiceProvider::FILES_FORMAT)
                    ),
                ]);
            } catch (Exception $e) {
                $this->error($e->getMessage());
            }
        } else {
            $this->warn('IDE Helper is not ready for running. Skip.');
        }
    }
920883
public function handle()
    {
        // If the package is not installed, abort removal
        if ( ! $this->packageIsInstalled()) {
            return $this->abortRemoval();
        }

        $this->startProgressBar();

        $this->removeConfigArrays();
        $this->replaceRouteServiceProvider();
        $this->removeLanguageMiddleware();
        $this->unregisterLanguageMiddleware();

        $this->stopProgressBar();
    }
396990
public function handle ()
    {
        $configurationPath = __DIR__ . '/templates/config/package.json';
        if (!file_exists ($configurationPath))
            $this->abort ('Missing package configuration file');

        $json = json_decode (file_get_contents ($configurationPath), true);

        $this->createDirectory ('packages');

        $directoryList = [];

        foreach (File::directories ('packages') as $directory)
        {
            $vendorPackages = File::directories ($directory);

            foreach ($vendorPackages as $vendorPackage)
                if (!file_exists($vendorPackage . '/src/app/honeycomb/config.json'))
                    array_push($directoryList, $vendorPackage);
        }

        if($directoryList == null)
            $this->abort('You must create your package directory first');
        
        $packageDirectory = $this->choice ('Please select package directory', $directoryList);
        $packageOfficialName = str_replace ('packages/', '', $packageDirectory);
        $nameSpace = $this->stringOnly (str_replace ('/', '\\', $packageOfficialName));
        $composerNameSpace = str_replace (['\\', '/'], '\\\\', $packageOfficialName . '\\');
        $composerNameSpace = str_replace ('-', '', $composerNameSpace);

        $packageName = $this->ask ('Please enter package name');

        foreach ($json['create_folders'] as $location) {
            $this->info ('Creating folder: ' . $packageDirectory . '/' . $location);
            $this->createDirectory ($packageDirectory . '/' . $location);
        }

        $this->createFileFromTemplate ([
            "destination"         => $packageDirectory . '/src/app/http/helpers.php',
            "templateDestination" => __DIR__ . '/templates/shared/empty.hctpl',
        ]);

        $this->createFileFromTemplate ([
            "destination"         => $packageDirectory . '/src/app/honeycomb/routes.php',
            "templateDestination" => __DIR__ . '/templates/shared/empty.hctpl',
        ]);

        $this->createFileFromTemplate ([
            "destination"         => $packageDirectory . '/src/.gitignore',
            "templateDestination" => __DIR__ . '/templates/package/gitignore.hctpl',
        ]);

        $this->createFileFromTemplate ([
            "destination"         => $packageDirectory . '/src/app/honeycomb/config.json',
            "templateDestination" => __DIR__ . '/templates/shared/hc.config.hctpl',
            "content"             => [
                "serviceProviderNameSpace" => $packageName
            ]
        ]);

        $this->createFileFromTemplate ([
            "destination"         => $packageDirectory . '/composer.json',
            "templateDestination" => __DIR__ . '/templates/package/composer.hctpl',
            "content"             => [
                "packageOfficialName" => $packageOfficialName,
                "packagePath"         => $composerNameSpace,
            ],
        ]);

        $this->createFileFromTemplate ([
            "destination"         => $packageDirectory . '/src/app/providers/' . $packageName . 'ServiceProvider.php',
            "templateDestination" => __DIR__ . '/templates/package/service.provider.hctpl',
            "content"             => [
                "packageName"              => $packageName . 'ServiceProvider',
                "nameSpace"                => $nameSpace . '\app\providers',
                "nameSpaceGeneral"         => $nameSpace . '\app\http\controllers',
                "serviceProviderNameSpace" => $packageName,
            ],
        ]);

        $this->createFileFromTemplate ([
            "destination"         => $packageDirectory . '/src/database/seeds/HoneyCombDatabaseSeeder.php',
            "templateDestination" => __DIR__ . '/templates/package/database.seeder.hctpl',
            "content"             => [
                "nameSpace" => $nameSpace,
                "className" => "HoneyComb"
            ],
        ]);

        $this->comment ('');
        $this->comment ('********************************************************');

        if (App::environment () == 'local') {
            $composer = json_decode (file_get_contents ('composer.json'));

            if (!isset($composer->autoload->{'psr-4'}->{$composerNameSpace}))
                $composer->autoload->{'psr-4'}->{str_replace ('\\\\', '\\', $composerNameSpace)} = $packageDirectory . '/src';

            file_put_contents ('composer.json', json_encode ($composer, JSON_PRETTY_PRINT));
        }

        $this->comment ('Please add to config/app.php under "providers":');
        $this->info ($nameSpace . '\app\providers\\' . $packageName . 'ServiceProvider::class');

        $this->comment ('********************************************************');


    }
1057228
public function handle()
    {
        if (! $this->confirmToProceed()) {
            return;
        }

        $slug = $this->argument('slug');

        if (! empty($slug)) {
            if (! $this->packages->exists($slug)) {
                return $this->error('Package does not exist.');
            }

            return $this->rollback($slug);
        }

        foreach ($this->packages->all() as $package) {
            $this->comment('Rollback the last migration from Package: ' .$package['name']);

            $this->rollback($package['slug']);
        }
    }
60101
public function handle()
    {
        $exportPath = $this->option('path');

        if($exportPath) {
            if(!file_exists($exportPath)) {
                throw new \Exception('Path '.$exportPath. ' does not exists!');
            }
        }else{
            $exportPath = storage_path('app/dumper');

            // create dumper directory
            if(!file_exists($exportPath)) {
                File::makeDirectory($exportPath, 0755);
            }
        }

        $filePath = $exportPath.'/'.date("Ymdhisi").'.sql';
      
        $this->comment("Starting database dump...");

        switch (config('database.default')){
        case 'mysql':
            MySql::create()
                ->setDbName(config('database.connections.mysql.database'))
                ->setHost(config('database.connections.mysql.host'))
                ->setUserName(config('database.connections.mysql.username'))
                ->setPassword(config('database.connections.mysql.password'))
                ->dumpToFile($filePath);
            break;

        case 'pgsql':
            PostgreSql::create()
                ->setDbName(config('database.connections.pgsql.database'))
                ->setUserName(config('database.connections.pgsql.username'))
                ->setPassword(config('database.connections.pgsql.password'))
                ->dumpToFile($filePath);
            break;

        case 'sqlite':
            Sqlite::create()
                ->setDbName(config('database.connections.sqlite.database'))
                ->dumpToFile($filePath);
            break;

        case 'mongodb':
            MongoDb::create()
                ->setDbName(config('database.connections.mongodb.database'))
                ->setUserName(config('database.connections.mongodb.username'))
                ->setPassword(config('database.connections.mongodb.password'))
                ->dumpToFile($filePath);
            break;
        }

        $this->info("Database successfully dumped to ".$filePath);
    }
1219047
public function handle()
    {
        if (!$this->confirmToProceed()) {
            return;
        }

        $this->migrator->setConnection($this->option('database'));
        
        $repository = modules()->location($this->option('location'));
        $paths      = $this->getMigrationPaths($repository);

        $this->migrator->setOutput($this->output)->rollback(
            $paths, ['pretend' => $this->option('pretend'), 'step' => (int)$this->option('step')]
        );
    }
1369638
public function handle()
    {


        $this->info('Getting directory list');

        // Bare respoitories
        $directory = rtrim(trim($this->argument('directory')), '/') . '/';
        $scanned_directory = array_diff(scandir($directory), array('..', '.'));
        $this->info('Found ' . count($scanned_directory) . ' directories');

        $progresbar = $this->output->createProgressBar(count($scanned_directory));
        $progresbar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %message% ');
        $progresbar->setMessage('Searching...');

        \Swis\GotLaravel\Models\Results::unguard();

        $inspector = new Inspector($this->settings);

        foreach($scanned_directory as $path){
            $this->logVerbose('Inpecting: ' . $path);


            if(null !== $this->option('only') && strcmp($path, $this->option('only')) !== 0){
                $progresbar->advance();
                continue;
            }

            if(null !== $this->option('skippast') && strcmp($path, $this->option('skippast')) <= 0){
                $progresbar->advance();
                continue;
            }

            $repository = $inspector->getRepositoryByPath($directory . $path);


            // Check modified date
            if(null !== $this->option('modified')){
                $modifiedTimestamp = strtotime($this->option('modified'));

                /**
                 * @var $date \DateTime
                 */
                try {
                    $this->logVerbose('Getting commit date');
                    $commitDate = $repository->getHeadCommit()->getCommitterDate();
                } catch(\Gitonomy\Git\Exception\ReferenceNotFoundException $e){
                    $this->error($e->getMessage());
                    $this->error('Error finding reference for ' . $path);
                }

                if($modifiedTimestamp === false || $commitDate->getTimestamp() < $modifiedTimestamp){
                    $progresbar->advance();
                    continue;
                }
                $this->logVerbose('Don\'t skip');
            }


            $repository->setLogger(new ConsoleLogger($this->getOutput()));

            $this->logVerbose('Searching git');

            $resultSet = $inspector->inspectRepository($repository);
            $remote = $resultSet['remote'];

            $this->logVerbose('Found remote ' . $remote);

            if(count($resultSet['results']) > 0){
                $progresbar->setMessage('Found ' . count($resultSet['results']) . ' tests for ' . $remote);
            }
            if(!$this->option('dry-run')) {
                foreach ($resultSet['results'] as $result) {
                    $insert = $result->toArray();
                    $insert['remote'] = $remote;
                    $insert['author_slug'] = Str::slug($result->getAuthor());
                    $insert['created_at'] = Carbon::createFromTimestamp($result->getDate());

                    try {
                        \Swis\GotLaravel\Models\Results::updateOrCreate(
                            array_only($insert, ['remote', 'filename', 'line']),
                            $insert
                        );
                    } catch (\Exception $e) {
                        $this->error('Couldnt insert: ' . $e->getMessage() . PHP_EOL . print_r($insert, 1));
                    }
                }
            }
            $progresbar->advance();


        }

        Artisan::call('got:normalize-names');
    }
727043
public function handle()
    {
        $this->call('laralum:info');

        $this->info('Looking for installed packages...');

        $packages = Packages::all();

        $this->call('laralum:packages');

        $this->line(' ');
        $this->comment('- Found '.count($packages).' packages installed');

        if ($this->confirm('Do you wish to continue?')) {
            $this->info('Publishing packages...');
            $this->line(' ');

            $bar = $this->output->createProgressBar(count($packages));

            foreach ($packages as $package) {
                $provider = Packages::provider($package);
                if ($provider) {
                    if (class_exists('Laralum\\'.ucfirst($package)."\\$provider")) {
                        $pr = 'Laralum\\'.ucfirst($package)."\\$provider";
                    } elseif (class_exists('Laralum\\'.strtoupper($package)."\\$provider")) {
                        $pr = 'Laralum\\'.strtoupper($package)."\\$provider";
                    }

                    if ($pr) {
                        $this->callSilent('vendor:publish', [
                            '--provider' => $pr,
                        ]);
                    }
                }
                $bar->advance();
            }
            $bar->finish();
            $this->line(' ');
            $this->line(' ');
            $this->info('All the packages were published!');
        } else {
            $this->error('Publishing stopped');
        }
    }