diff --git a/app/Commands/Host.php b/app/Commands/Host.php index 7709b82..1ec40e2 100644 --- a/app/Commands/Host.php +++ b/app/Commands/Host.php @@ -80,26 +80,34 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->domain = $this->getDomainFromQuestion(); - if($this->useComposer && !empty($this->composerProject)){ - $output->writeln('Creating project..'); - $this->createProject(); - } + $taskConfirmation = $this->getTaskConfirmationFromQuestion(); + + if($taskConfirmation){ + + if($this->useComposer && !empty($this->composerProject)){ + $output->writeln('Creating project..'); + $this->createProject(); + } - $output->writeln('Create host ('.$this->domain.')...'); - $this->updateHostsFile(); + $output->writeln('Create host ('.$this->domain.')...'); + $this->updateHostsFile(); - $output->writeln('Update Vagrant site mapper ('.$this->folder.')'); - $this->updateHomesteadSites(); + $output->writeln('Update Vagrant site mapper ('.$this->folder.')'); + $this->updateHomesteadSites(); - $output->writeln('Update Vagrant database ('.$this->database.')'); - $this->updateHomesteadDatabases(); + $output->writeln('Update Vagrant database ('.$this->database.')'); + $this->updateHomesteadDatabases(); - $output->writeln('Provision Vagrant'); - $this->provisionHomestead(); + $output->writeln('Provision Vagrant'); + $this->provisionHomestead(); - $output->writeln('Complete!'); + $output->writeln('Complete!'); - $output->writeln('Visit: http://' . $this->domain); + $output->writeln('Visit: http://' . $this->domain); + + }else{ + $output->writeln('Tasks cancelled'); + } return; @@ -137,6 +145,28 @@ private function getDomainFromQuestion(){ return $this->questionHelper->ask($this->inputInterface, $this->outputInterface, $question); } + private function getTaskConfirmationFromQuestion(){ + $this->outputInterface->writeln('The following tasks will be executed:'); + if($this->useComposer && !empty($this->composerProject)){ + $this->outputInterface->writeln("- Run Command: cd {$this->folder} && composer create-project {$this->composerProject} {$this->name}"); + } + $this->outputInterface->writeln('- ('.$this->hostPath.') add line: '.$this->hostIP.' '.$this->domain); + $this->outputInterface->writeln('- ('.$this->homesteadPath.') map : '.$this->domain.' to '.$this->homesteadSitesPath.$this->name.$this->folderSuffix); + $this->outputInterface->writeln('- ('.$this->homesteadPath.') add to databases: '.$this->database); + if(!empty($this->homesteadProvisionCommand)){ + $this->outputInterface->writeln('- Run Command: '.$this->homesteadProvisionCommand); + }else{ + $this->outputInterface->writeln('- Run Command: cd '.$this->homesteadBoxPath.' && vagrant provision'); + } + $default = 'Y'; + $question = new Question('Run tasks? ('.$default.'): ', $default); + $response = $this->questionHelper->ask($this->inputInterface, $this->outputInterface, $question); + if(strtoupper($response) == 'Y'){ + return true; + } + return false; + } + private function defaultDatabaseNameFromKey($key){ $key = strtolower($key); $key = str_replace(' ','-',$key);