Beispiel #1
0
 /**
  * Builds the package template.
  */
 public function build()
 {
     $output = Application::getOutput();
     $input = Application::getInput();
     $this->package->setRendererInstance($this->generator->getRenderer());
     $this->package->setApplication(app(Application::class));
     $this->package->setOutputInstance($output);
     $this->package->setInputInstance($input);
     $this->package->builderLoaded();
     if ($this->getCommonTemplateDirectory() !== null) {
         $this->generator->getRenderer()->addPath($this->getCommonTemplateDirectory());
     }
     $this->generator->setVerbatimExcludePatterns($this->package->getVerbatimExcludePatterns());
     $this->generator->setVerbatimPatterns($this->package->getVerbatimPatterns());
     foreach ($this->package->getTransformPaths() as $pathKey => $processPath) {
         $this->generator->getPathManager()->getCollector()->addFileNames([$this->normalizePath($pathKey) => $this->normalizePath($processPath)]);
     }
     foreach ($this->package->getIgnoredPaths() as $ignoredPath) {
         $this->generator->getPathManager()->getGenerator()->addIgnoredPath($this->normalizePath($ignoredPath));
     }
     foreach ($this->package->getPathsToRemove() as $pathToRemove) {
         $this->generator->getPathManager()->getGenerator()->addAutomaticallyRemovedPath($this->normalizePath($pathToRemove));
     }
     $this->generator->addPaths((array) $this->getTemplateDirectory());
     $this->generator->generateContent($this->outputDirectory);
 }
Beispiel #2
0
use Symfony\Component\Console\Output\ConsoleOutput;
$autoLoader = (require __DIR__ . '/bootstrap/autoload.php');
$app = (require_once __DIR__ . '/bootstrap/app.php');
Application::$loader =& $autoLoader;
ConsoleApplication::setOutput(new ConsoleOutput());
ConsoleApplication::setInput(new \Symfony\Component\Console\Input\ArgvInput());
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make('Illuminate\\Contracts\\Console\\Kernel');
$kernel->bootstrap();
$status = $kernel->handle(ConsoleApplication::getInput(), ConsoleApplication::getOutput());
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running. We will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate(ConsoleApplication::getInput(), $status);
exit($status);
Beispiel #3
0
 /**
  * Gets the package class.
  *
  * @return null|string
  * @throws \NewUp\Exceptions\InvalidPackageTemplateException
  * @throws \NewUp\Exceptions\TemplatePackageMissingException
  */
 private function getPackageClass()
 {
     if ($this->packageClass !== null) {
         return $this->packageClass;
     }
     $includePath = $this->getPackageClassPath();
     if (!file_exists($includePath)) {
         Application::getOutput()->writeln("<comment>{$this->getTemplateName()} is not installed. Attempting to install it now...</comment>");
         $result = app(Kernel::class)->getApplication()->callWithSharedOutput('template:install', ['name' => $this->getTemplateName(), '--confirm' => true]);
         if ($result === Install::INSTALL_FAIL) {
             // Fail angrily.
             throw new TemplatePackageMissingException("The package template {$this->getTemplateName()} is not installed or it cannot be found. The package template must be installed before it can be built.");
         } else {
             Application::getOutput()->writeln('<comment>It looks like everything went well. We will continue building the package template...</comment>');
         }
     }
     scope_include($includePath);
     $this->packageClass = $packageClass = $this->getNamespacedPackageName();
     if (!class_exists($packageClass)) {
         throw new InvalidPackageTemplateException("{$packageClass} class does not exist.");
     }
     return $packageClass;
 }