示例#1
0
 /**
  * fixing laravel bootstrapper
  * @param  string $public alias public directory
  * @param  string $core   alias core directory
  * @return void
  */
 protected function fixBootstrapper($public, $core)
 {
     $_core = Utility::getCorePath($this->getAlias(), $core);
     $_public = Utility::getPublicPath($this->getAlias(), $public);
     $core = Utility::findRelativePath($_public, $_core);
     $indexPath = Utility::combinePath(Utility::getPublicPath($this->getAlias(), $public), 'index.php');
     # Auto Loader
     $autoLoader = \file_get_contents(__DIR__ . '/../Stubs/autoLoader.tpl');
     $autoLoader = Utility::renderTemplate($autoLoader, ['{{CORE_PATH}}' => $core]);
     $autoLoader = Utility::normalizePath($autoLoader);
     # Bootstrap
     $bootstrapper = \file_get_contents(__DIR__ . '/../Stubs/bootstrapper.tpl');
     $bootstrapper = Utility::renderTemplate($bootstrapper, ['{{CORE_PATH}}' => $core]);
     $bootstrapper = Utility::normalizePath($bootstrapper);
     Utility::replaceInFile($indexPath, ['require __DIR__.\'/../bootstrap/autoload.php\';' => $autoLoader, '$app = require_once __DIR__.\'/../bootstrap/app.php\';' => $bootstrapper]);
 }
示例#2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     # Collecting data and initialization
     $alias = $this->argument('name');
     $mMode = $this->option('m');
     $profileName = $this->option('profile');
     $profile = ConfigurationManager::Get("profiles.{$profileName}");
     $publisher = new FilePublisher($profileName, $alias);
     $manipulator = new Manipulator($profileName, $alias);
     # Checking for alias duplicated
     if ($mMode == false) {
         if (\file_exists(Utility::getAliasPath($alias))) {
             switch (ConfigurationManager::Get("profiles.{$profileName}.publishMode")) {
                 case 'clean':
                     $this->line('Alias directory already exist! Cleaning old directory...');
                     Utility::deleteFiles(Utility::getAliasPath($alias));
                     break;
                 case 'nothing':
                     $this->error('Alias directory already exist! publish failed! Please check publishMode configuration for change publish mode.');
                     return;
             }
         }
         # publishing application
         $this->line('Preparing...');
         $publisher->prepare();
         $this->info("copying {$publisher->getFileCount()} files...");
         $progress = $this->output->createProgressBar($publisher->getFileCount());
         $progress->setFormat("%message%<bg=black>(<fg=white>%current%</> OF <fg=yellow>%max%</>)</> <bg=red;fg=white>%percent% %</>");
         $progress->setMessage('Copying Files: ');
         $publisher->startPublish(function () use($progress) {
             $progress->advance();
         }, function () use($progress) {
             $progress->finish();
         });
         $this->line('');
         $this->info('done!');
     }
     $this->line('Manipulating codes...');
     $manipulator->startManipulation();
     $this->info('done!');
     $this->line('<bg=white;fg=blue>Your application ready for publish on web server. enjoy it!</>');
 }
示例#3
0
 /**
  * start publishing
  * @param  function $progressCallback callback function for tracking publish progress
  * @param  function $doneCallback callback function for calling when publish complete
  * @return void
  */
 public function startPublish($progressCallback = null, $doneCallback = null)
 {
     # Copy core files
     $coreDirectoryName = ConfigurationManager::Get("profiles.{$this->getProfileName()}.coreDirectory");
     $coreDirectoryName = Utility::getCorePath($this->getAlias(), $coreDirectoryName);
     $this->ignores[] = 'public';
     Utility::copyFiles(\base_path(), $coreDirectoryName, $progressCallback, $this->getIngoresList());
     $this->ignores = \array_except($this->ignores, ['public']);
     # Copy public files
     $publicDirectoryName = ConfigurationManager::Get("profiles.{$this->getProfileName()}.publicDirectory");
     $publicDirectoryName = Utility::getPublicPath($this->getAlias(), $publicDirectoryName);
     Utility::copyFiles(\base_path('public'), $publicDirectoryName, $progressCallback, $this->getIngoresList());
     # Copy env file
     $envFileName = ConfigurationManager::Get("profiles.{$this->getProfileName()}.env");
     if ($envFileName != null && file_exists(\base_path($envFileName))) {
         @\copy(\base_path($envFileName), Utility::combinePath($coreDirectoryName, '.env'));
     }
     # Completing progress
     if (\is_callable($doneCallback)) {
         \call_user_func($doneCallback);
     }
 }