/** * Runs the generator. */ public function generate() { $this->createModulesDir(); $this->createFolders(); $this->createFiles(); $this->console->info("Your module [{$this->name}] has been generated."); }
/** * Create the specified folder. * * @param $folder * @param $success * @param $error */ protected function createFolder($folder, $success, $error) { if (!is_dir($folder)) { $this->files->makeDirectory($folder); return $this->console->info($success); } return $this->console->comment($error); }
/** * Handle the command. * * @param Markdown $markdown */ public function handle(Markdown $markdown) { $this->command->info(strip_tags($markdown->transform(file_get_contents(base_path('LICENSE.md'))))); if (!$this->command->confirm('Do you agree to the provided license and terms of service?')) { $this->command->error('You must agree to the license and terms of service before continuing.'); exit; } }
/** * Handle the command. * * @param Filesystem $filesystem * @param Application $application * @return string */ public function handle(Filesystem $filesystem, Application $application) { $destination = $application->getResourcesPath('streams/lang'); if (is_dir($destination) && !$this->command->option('force')) { return $this->command->error("{$destination} already exists."); } $filesystem->copyDirectory(__DIR__ . '/../../../../resources/lang', $destination); $this->command->info("Published {$destination}"); }
/** * Handle the command. * * @param Filesystem $filesystem * @param Application $application * @return string */ public function handle(Filesystem $filesystem, Application $application) { $destination = $application->getResourcesPath('addons/' . $this->addon->getVendor() . '/' . $this->addon->getSlug() . '-' . $this->addon->getType() . '/views'); if (is_dir($destination) && !$this->command->option('force')) { $this->command->error("{$destination} already exists."); return; } $filesystem->copyDirectory($this->addon->getPath('resources/views'), $destination); $this->command->info("Published {$destination}"); }
/** * Fire off the handler. * * @param \Illuminate\Console\Command $console * @param string $slug * @param string $class * @return bool */ public function fire(Command $console, $slug, $class) { $this->console = $console; $this->moduleName = Str::studly($slug); $this->className = studly_case($class); if ($this->module->exists($slug)) { $this->makeFile(); return $this->console->info("Created Module Controller: [{$slug}] " . $this->getFilename()); } return $this->console->info("Module [{$slug}] does not exist."); }
/** * Fire off the handler. * * @param \Illuminate\Console\Command $console * @param string $slug * @param string $class * @return bool */ public function fire(Command $console, $slug, $name, $type) { $this->console = $console; $this->moduleName = studly_case($slug); $this->emailName = snake_case($name); $this->type = $type; if ($this->module->exists($this->moduleName)) { $this->makeFile(); return $this->console->info("Created Module Email View: [{$this->moduleName}] " . $this->getFilename()); } return $this->console->info("Module [{$this->moduleName}] does not exist."); }
/** * Handle the command. * * @param Filesystem $filesystem * @param Application $application * @return string */ public function handle(Filesystem $filesystem, Application $application) { $destination = $application->getResourcesPath('.env'); if (!is_dir(dirname($destination))) { $filesystem->makeDirectory(dirname($destination), 0777, true, true); } if (is_file($destination) && !$this->command->option('force')) { return $this->command->error("{$destination} already exists."); } $filesystem->put($destination, '#EXAMPLE=foo'); $this->command->info("Published {$destination}"); }
/** * Handle the command. * * @param Filesystem $filesystem * @param Application $application * @return string */ public function handle(Filesystem $filesystem, Application $application) { $destination = $application->getResourcesPath('routes.php'); if (!is_dir(dirname($destination))) { $filesystem->makeDirectory(dirname($destination), 0777, true, true); } if (is_file($destination) && !$this->command->option('force')) { return $this->command->error("{$destination} already exists."); } $content = "<?php\n\n// Route::get('/', function () {\n// return view('welcome');\n// });\n"; $filesystem->put($destination, $content); $this->command->info("Published {$destination}"); }
/** * Handle the command. * * @param Container $container */ public function handle(Container $container) { $step = 1; $total = $this->installers->count(); /* @var Installer $installer */ while ($installer = $this->installers->shift()) { if ($this->command) { $this->command->info("{$step}/{$total} " . trans($installer->getMessage())); } $container->call($installer->getTask()); $step++; } }
/** * Fire off the handler. * * @param \Aindong\Pluggables\Console\PluggableMakeMigrationCommand $console * @param string $slug * * @return string */ public function fire(Command $console, $slug, $table) { $this->console = $console; $this->pluggableName = Str::studly($slug); $this->table = strtolower($table); $this->migrationName = snake_case($this->table); $this->className = studly_case($this->migrationName); if ($this->pluggable->exists($this->pluggableName)) { $this->makeFile(); $this->console->info("Created Pluggable Migration: [{$this->pluggableName}] " . $this->getFilename()); return exec('composer dump-autoload'); } return $this->console->info("Pluggable [{$this->pluggableName}] does not exist."); }
/** * @param Command $console * @param $module */ public function fire(Command $console, $module) { $moduleName = Str::studly($module); if (!empty($moduleName)) { foreach ($this->module->all() as $module) { $this->publish($module); } return $console->info("All assets from all modules has been published successfully."); } if ($this->module->exists($moduleName)) { $this->publish($moduleName); return $console->info("Assets from module [{$moduleName}] has been published successfully."); } return $console->info("Module [{$moduleName}] does not exists."); }
public function fire($arguments, $options) { $instanceId = array_get($arguments, CommandRules::INSTANCE_ID); $logFile = array_get($arguments, CommandRules::LOGFILE); $user = array_get($options, CommandRules::USER); $keyFile = array_get($options, CommandRules::KEY_FILE); $host = $this->aws->getPublicDNSFromInstanceId($instanceId); if (is_null($host)) { $this->command->error('Error: Could not find Host from Instance ID. Please try again.'); } else { $connection = $this->connectionFactory->createConnection($instanceId, $host, $user, $keyFile); $connection->run(array('tail -f ' . $logFile), function ($line) { $this->command->info($line); }); } }
/** * Display info message with date and message, and log it * @param string $message info message to display & log */ public function info($message) { // Log message $this->log($message, 'info'); // Display message parent::info(date($this->timestampFormat) . ' ' . $message); }
/** * Fire off the handler. * * @param \C5\AppKit\Console\ModuleMakeMigrationCommand $console * @param string $slug * @return string */ public function fire(Command $console, $slug, $table) { $this->console = $console; $this->moduleName = studly_case($slug); $this->table = str_plural(strtolower($table)); $this->model = str_singular(studly_case($table)); $this->migrationName = 'create_' . snake_case($this->table) . '_table'; $this->className = studly_case($this->migrationName); if ($this->module->exists($this->moduleName)) { $this->makeMigration(); $this->makeModel(); $this->console->info("Created Module Migration: [{$this->moduleName}] " . $this->getFilename()); return exec('composer dump-autoload'); } return $this->console->info("Module [{$this->moduleName}] does not exist."); }
/** * Generate pluggable folders and files. * * @param \Aindong\Pluggables\Console\PluggableMakeCommand $console * * @return bool */ public function generate(Command $console) { $this->generateFolders(); $this->generateGitkeep(); $this->generateFiles(); $console->info("Pluggable [{$this->name}] has been created successfully."); return true; }
/** * Generate the files. */ public function generateFiles() { foreach ($this->getFiles() as $stub => $file) { $path = $this->module->getModulePath($this->getName()) . $file; $this->filesystem->put($path, $this->getStubContents($stub)); $this->console->info("Created : {$path}"); } }
/** * @param Command $console * @return bool */ protected function generate(Command $console) { $this->generateFolders(); $this->generateFiles(); $console->call('module:seed-make', array('module' => $this->name, 'name' => $this->Name, '--master')); $console->call('module:controller', array('module' => $this->name, 'controller' => $this->Name . 'Controller')); $console->info("Module [{$this->Name}] has been created successfully."); return true; }
/** * Publish assets form the specified module. * * @param $module */ protected function publishFromModule($module) { if (!$this->module->has($module)) { $this->console->error("Module [{$module}] does not exist."); exit; } $this->filesystem->copyDirectory($this->getPublishingPath($module), $this->getDestinationPath($module)); $this->console->info("Assets published from module : {$module}"); }
/** * Append new route. * * @return void */ public function appendRouteServiceProvider() { if (!$this->confirm('Do you want to append new route-service provider?')) { return; } $contents = $this->laravel['files']->get($path = app_path('Providers/RouteServiceProvider.php')); $contents = str_replace('//scaffolded routes will appear here [do not remove]', '//scaffolded routes will appear here [do not remove]' . PHP_EOL . PHP_EOL . ' $router->model(\'' . $this->getEntities() . '\', \'App\\Repositories\\' . $this->getModelName() . '\');', $contents); $this->laravel['files']->put($path, $contents); $this->console->info("RouteServiceProvider appended successfully."); }
/** * Append new route. */ public function appendRoute() { if (!$this->confirm('Do you want to append new route?')) { return; } $contents = $this->laravel['files']->get($path = app_path('Http/routes.php')); $contents .= PHP_EOL . "Route::resource('{$this->getRouteName()}', '{$this->getControllerName()}');"; $this->laravel['files']->put($path, $contents); $this->console->info('Route appended successfully.'); }
/** * Generate the files. */ public function generateFiles() { foreach ($this->getFiles() as $stub => $file) { $path = $this->module->getModulePath($this->getName()) . $file; if (!$this->filesystem->isDirectory($dir = dirname($path))) { $this->filesystem->makeDirectory($dir, 0775, true); } $this->filesystem->put($path, $this->getStubContents($stub)); $this->console->info("Created : {$path}"); } }
/** * Fire the install script * @param Command $command * @return mixed */ public function fire(Command $command) { $this->command = $command; $host = $this->askDatabaseHost(); $name = $this->askDatabaseName(); $user = $this->askDatabaseUsername(); $password = $this->askDatabasePassword(); $this->setLaravelConfiguration($name, $user, $password, $host); $this->env->write($name, $user, $password, $host); $command->info('Database successfully configured'); }
/** * Metodo de atalho para execução padronizada dos metodos dessa classse * * @param bool $startCondition * @param callable $rollbackMethod * @param callable $afterCallBack * @param Command $command * @param string $message */ public static function executeRollbackMethod($startCondition = true, callable $rollbackMethod, callable $afterCallBack = null, Command $command = null, $message = null) { if ($startCondition && $rollbackMethod != null) { if ($command != null && $message != null) { $command->info($message); } $result = $rollbackMethod(); if ($afterCallBack != null) { $afterCallBack($result); } } }
public function fire($arguments, $options) { $envName = array_get($arguments, CommandRules::ENV); $logFile = array_get($arguments, CommandRules::LOGFILE); $user = array_get($options, CommandRules::USER); $keyFile = array_get($options, CommandRules::KEY_FILE); $hosts = $this->aws->getPublicDNSFromEBEnvironmentName($envName); if (count($hosts) === 0) { $this->command->error('Error: Could not find instances associated with environment'); } else { $connections = array(); foreach ($hosts as $host) { $connections[] = $this->connectionFactory->createConnection($host, $host, $user, $keyFile); } foreach ($connections as $connection) { $connection->run(array('tail -f ' . $logFile), function ($line) { $this->command->info($line); }); } } }
/** * Append new route. */ public function appendRoutes() { if (!$this->confirm('Do you want to append new routes?')) { return; } foreach ($this->getMainTables() as $table) { $contents = $this->laravel['files']->get($path = app_path('Http/routes.php')); $contents .= PHP_EOL . "Route::resource('{$this->getRouteName($table)}', '{$this->getControllerName($table)}');"; $this->laravel['files']->put($path, $contents); $this->console->info("Route for {$this->getEntity($table)} appended successfully."); } }
/** * Present a list of choices to user, return choice * @param Command $command The command requesting input * @param array $choices List of choices * @param int $default Default choice (1-array size), -1 to abort * @param string $abort String to tag on end for aborting selection * @return int -1 if abort selected, otherwise one greater than $choice index * (in other words, choosing $choice[0] returns 1) * @throws InvalidArgumentException If argument is invalid */ function pick_from_list(Command $command, $title, array $choices, $default = 0, $abort = null) { if ($abort) { $choices[] = $abort; } $numChoices = count($choices); if (!$numChoices) { throw new \InvalidArgumentException("Must have at least one choice"); } if ($default == -1 && empty($abort)) { throw new \InvalidArgumentException('Cannot use default=-1 without $abort option'); } if (!between($default, -1, $numChoices)) { throw new \InvalidArgumentException("Invalid value, default={$default}"); } $question = "Please enter a number between 1-{$numChoices}"; if ($default > 0) { $question .= " (default is {$default})"; } elseif ($default < 0) { $question .= " (enter to abort)"; $default = $numChoices; } $question .= ':'; while (1) { $command->line(''); $command->info($title); $command->line(''); for ($i = 0; $i < $numChoices; $i++) { $command->line($i + 1 . ". " . $choices[$i]); } $command->line(''); $answer = $command->ask($question); if ($answer == '') { $answer = $default; } if (between($answer, 1, $numChoices)) { if ($abort and $answer == $numChoices) { $answer = -1; } return (int) $answer; } // Output wrong choice $command->line(''); $formatter = $command->getHelperSet()->get('formatter'); $block = $formatter->formatBlock('Invalid entry!', 'error', true); $command->line($block); } }
/** * Will run the parser, create necessary folders and files * * @param string $name */ protected function createFile($name = null) { if ($name === null) { $name = $this->name; } $file = $this->filename($name); $content = $this->parser->stub($this->stub())->name($name)->setClassNamespace($this->detectNamespace())->setData($this->data)->parse(); if ($this->filesystem->exists($file)) { $this->console->error("The file {$file} already exists."); return; } // Make folders if necessary $this->makeFolders(); // Create the file $this->filesystem->put($file, $content); $this->console->info("Generated {$file}"); }
/** * Fire the install script. * * @param Command $command * * @return mixed */ public function fire(Command $command) { $this->command = $command; $connected = false; while (!$connected) { $host = $this->askDatabaseHost(); $name = $this->askDatabaseName(); $user = $this->askDatabaseUsername(); $password = $this->askDatabasePassword(); $this->setLaravelConfiguration($name, $user, $password, $host); if ($this->databaseConnectionIsValid()) { $connected = true; } else { $command->error('Please ensure your database credentials are valid.'); } } $this->env->write($name, $user, $password, $host); $command->info('Database successfully configured'); }
/** * Initialize. * * @param \C5\AppKit\Console\InitCommand $console * @return boolean */ public function init(Command $console) { $this->deleteHttpFiles(); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => 'http']); $this->deleteDefaultFiles(); $this->deleteDefaultFolders(); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => 'config']); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => 'database']); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => 'models']); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => 'views']); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => 'modules']); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => $this->assets]); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => 'coffee']); $console->callsilent('vendor:publish', ['--provider' => 'C5\\AppKit\\AppKitServiceProvider', '--tag' => 'public']); $this->updateConfig($this->name); $this->updateGulpFile($this->assets); exec('composer dump-autoload'); exec('gulp'); $console->info('AppKit [ ' . $this->name . ' ] has been initialized.'); return true; }