/** * Execute the command. * * @return void */ protected function fire() { $appDir = $this->argument('dir'); //exit is non-absolute path to app directory was given if (!preg_match(Path::ABSOLUTE_PATTERN, $appDir)) { $this->comment("Error", "App directory must be an absolute path", true); exit; } //install a fresh Laravel app (new Laravel($appDir, new ProcessBuilder(), $this))->install(); //get the template $template = new TemplateReader($this->argument('template'), new Filesystem(), $this); //process structural portions of the config $structure = new Structure($appDir, $template->getConfigSection(TemplateReader::STRUCTURE), new Filesystem(), $this); $structure->copy(); $structure->move(); $structure->delete(); $structure->touch(); $structure->mkdirs(); //process composer portions of the config $composer = new Composer($appDir, $template->getConfigSection(TemplateReader::COMPOSER), new Filesystem(), $this); $composer->requirePackages(); $composer->requireDevPackages(); $composer->autoloadClassmap(); $composer->autoloadPsr0(); $composer->autoloadPsr4(); $composer->writeComposerJson(); }
public function testCopy() { $dir = '/path/to/app'; $mFS = m::mock('Illuminate\\Filesystem\\Filesystem'); $mCmd = m::mock('Console\\BuildCommand'); $config = $this->getConfig()['copy']; for ($i = 0; $i < count($config); $i++) { $from = Path::absolute($config[$i]['from'], $dir); $to = Path::absolute($config[$i]['to'], $dir); $mCmd->shouldReceive('comment')->once()->with("Copy", "from {$from} to {$to}"); $mFS->shouldReceive('exists')->once()->with(dirname($to))->andReturn(false); $mFS->shouldReceive('makeDirectory')->once()->with(dirname($to), 0777, true); if ($i < 2) { $mFS->shouldReceive('isDirectory')->once()->with($from)->andReturn(true); $mFS->shouldReceive('isDirectory')->once()->with($to)->andReturn(true); $mFS->shouldReceive('copyDirectory')->once()->with($from, $to); } else { $mFS->shouldReceive('isDirectory')->once()->with($from)->andReturn(false); $mFS->shouldReceive('isDirectory')->with($to)->andReturn(false); $mFS->shouldReceive('copy')->once()->with($from, $to); } } $structure = new Structure($dir, $this->getConfig(), $mFS, $mCmd); $structure->copy(); }