/** * start code manipulation * @return void */ public function startManipulation() { $core = ConfigurationManager::Get("profiles.{$this->getProfileName()}.coreDirectory"); $public = ConfigurationManager::Get("profiles.{$this->getProfileName()}.publicDirectory"); $manipulations = ConfigurationManager::Get("profiles.{$this->getProfileName()}.manipulations"); # Fixing bootstrap $this->fixBootstrapper($public, $core); # Manipulate Codes foreach ($manipulations as $file => $lines) { $file = Utility::renderTemplate($file, ['{CORE}' => Utility::getCorePath($this->getAlias(), $core), '{PUBLIC}' => Utility::getPublicPath($this->getAlias(), $public)]); $file = Utility::normalizePath($file); if (\file_exists($file)) { Utility::replaceInFile($file, $lines); } } }
/** * 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!</>'); }
/** * get base publish path * @return string the publish root path */ public static function getBasePath() { return self::normalizePath(\base_path(ConfigurationManager::Get('publishRoot'))); }