/** * Prepare the build directory as a git repository. * * Maybe there's already a git repo in the build folder, but is it pointing to * the correct origin and is it on the correct branch? Instead of checking for * things that might be wrong, we'll just start from scratch. * * @returns GitWorkingCopy * @throws RuntimeException */ protected function prepareRepository() { $config = $this->container['config']; $this->builder->clean($config['build.directory']); // clear out everything, including .git metadata $workingCopy = $this->git->workingCopy($config['build.directory']); $this->doGitInit($workingCopy, $config['deploy.git.url'], $config['deploy.git.branch']); // start again at last commit $this->builder->clean($config['build.directory'], true); // clear the old content but keep .git folder return $workingCopy; }
/** * Build the new site pages. * * @param string $sourceDir * @param string $outputDir */ protected function runBuildTask($sourceDir, $outputDir) { $buildTime = $this->runTimedTask(function () use($sourceDir, $outputDir) { $this->builder->build($sourceDir, $outputDir); }); $this->output->writeln("<comment>PHP built in <time>{$buildTime}ms</time></comment>", OutputInterface::VERBOSITY_VERBOSE); }
/** * Run the build command. * * @return bool */ protected function build() { $container = new Container(); $container->singleton('files', Filesystem::class); $container->bind(Factory::class, function ($app) { return new Factory($app->make(EngineResolver::class), new FileViewFinder($app['files'], ['test/source']), new Dispatcher($app)); }); $container->afterResolving(function (Factory $factory, $app) { $factory->addExtension('php', 'php', function () { return new PhpEngine(); }); $factory->addExtension('blade.php', 'blade', function () use($app) { return new CompilerEngine(new BladeCompiler($app['files'], vfsStream::url('test/.cache'))); }); }); $builder = new Builder($container, [Skip::class . ':_*', Compile::class]); return $builder->build(vfsStream::url('test/source'), vfsStream::url('test/build')); }