/** * Make modifiaction and add content. * * @param string $file * @param string $needle * @return string */ public function addContent($value, $needle) { return Modifier::open($this->file)->add($this->parseImport($value), $needle)->save(); }
/** * Elixir setup * @return void */ protected function setUpElixirEnvironment() { $this->describeMethod('Setup elixir-environment'); $this->copyFromStub('package.json', base_path('package.json')); $this->copyFromStub('gulpfile.js', base_path('gulpfile.js')); $report = FileModifier::open(base_path('gulpfile.js'))->replace('[YOUR CUSTOM DOMAIN]', $this->option('domain'))->save(); $this->reportStep("add app domain in gulpfile.js: " . $this->option('domain'), $report); if ($this->option('domain') == 'your-domain.app') { $this->reportHint("Add your custom domain in gulpfile.js."); } }
/** * Adding content after a needle. * * @param string $contentToAdd * @param string $needle * @return string */ private function addContent($contentToAdd, $needle) { return Modifier::open($this->file)->add($contentToAdd, $needle)->save(); }
/** * Add needed NPM Dependecies. * * @return void */ protected function updateNPMDependecies() { $this->describeMethod('Update NPM dependecies'); $packageFile = base_path('package.json'); $report = FileModifier::open($packageFile)->add("\n\t\"material-design-icons\": \"^2.0.0\",", '"dependencies": {')->save(); $this->reportStep('add material-design-icons package', $report); $this->reportHint("Don't forget to 'npm install'."); }
/** @test */ public function it_abort_action_when_content_to_replace_was_not_found() { $report = FileModifier::open($this->exampleFile)->replace('Not existing content', 'New Replaced Content')->save(); $this->assertEquals($report, 'CONTENT_TO_REPLACE_NOT_FOUND'); }
/** * Add service provider to config/app.php. * * @param array $provider */ protected function addServiceProviders($providers) { $this->describeMethod("Add needed Serviceproviders"); $appFile = config_path('app.php'); $modifier = FileModifier::open($appFile); foreach ($providers as $provider) { $report = $modifier->add("\n\t\t{$provider}::class,", 'BasecampServiceProvider::class,')->save(); $this->reportStep("add {$provider}", $report); } }
/** * * Update middleware for authentication tasks. * * @return void */ protected function updateAuthenticateMiddleware() { $this->describeMethod('Update middleware for authentication'); $authenticateFile = app_path('Http/Middleware/Authenticate.php'); $report = FileModifier::open($authenticateFile)->replace("redirect()->guest('login');", "redirect()->guest('einloggen');")->save(); $this->reportStep("change guest redirect target to '/einloggen'", $report); }
/** * Adding a new page import * at the actual assemblerfile. * * @param string $tag HTML-Tag to bind the code. * @param string $viewfile Path to pagefile relative to assemblerfile. * @return string */ public function addPage($tag, $pageFile) { $contentToAdd = "\nVue.component('{$tag}', Vue.extend(require('{$pageFile}')));"; return Modifier::open($this->file)->add($contentToAdd, $this->pageNeedle)->save(); }