/** * Shows warnings and sets a new settings which overwrites * invalid settings with default values. * * @param \Symfony\Component\Console\Output\OutputInterface $output * @return void */ private function warnAndOverwriteInvalidSettingsWithDefaults($output) { $this->projectNameContainsPhpWarning($output); $license = $this->supportedLicenseWarning($output); $testFramework = $this->testFrameworkWarning($output); $phpVersion = $this->phpVersionWarning($output); $this->settings = new Settings($this->settings->getProjectName(), $testFramework, $license, $this->settings->getNamespace(), $this->settings->withGitInit(), $this->settings->withPhpcsConfiguration(), $this->settings->getComposerKeywords(), $this->settings->withVagrantfile(), $this->settings->withEditorConfig(), $phpVersion, $this->settings->withEnvironmentFiles(), $this->settings->withLgtmConfiguration(), $this->settings->withGithubTemplates(), $this->settings->withCodeOfConduct(), $this->settings->withGithubDocs()); }
/** * Generate composer file. * * @param \JonathanTorres\Construct\Helpers\Git $git The git helper. * * @return void */ protected function composer(Git $git) { $composerFile = 'composer.' . $this->settings->getTestingFramework(); $file = $this->file->get(__DIR__ . '/stubs/composer/' . $composerFile . '.stub'); $user = $git->getUser(); $stubs = ['{project_upper}', '{project_lower}', '{vendor_lower}', '{vendor_upper}', '{testing}', '{testing_version}', '{namespace}', '{license}', '{author_name}', '{author_email}', '{keywords}', '{php_version}']; $values = [$this->projectUpper, $this->projectLower, $this->vendorLower, $this->vendorUpper, $this->settings->getTestingFramework(), $this->testingVersion, $this->createNamespace(true), $this->settings->getLicense(), $user['name'], $user['email'], $this->str->toQuotedKeywords($this->settings->getComposerKeywords()), $this->settings->getPhpVersion()]; $content = str_replace($stubs, $values, $file); if ($this->settings->withEnvironmentFiles()) { $composer = json_decode($content, true); $composer['require-dev']['vlucas/phpdotenv'] = '~2.1'; $content = json_encode($composer, JSON_PRETTY_PRINT); $content .= PHP_EOL; } $this->file->put($this->projectLower . '/' . 'composer.json', $content); }
/** * Generate project. * * @param \JonathanTorres\Construct\Settings $settings The command settings made by the user. * @param \JonathanTorres\Construct\Helpers\Git $git The git helper. * @param \JonathanTorres\Construct\Helpers\Script $script The script helper. * * @return void */ public function generate(Settings $settings, Git $git, Script $script) { $this->settings = $settings; $this->saveNames(); $this->root(); $this->src(); $this->docs(); $this->testing(); if ($this->settings->withPhpcsConfiguration()) { $this->phpcs(); } if ($this->settings->withVagrantFile()) { $this->vagrant(); } if ($this->settings->withEditorConfig()) { $this->editorConfig(); } if ($this->settings->withEnvironmentFiles()) { $this->environmentFiles(); } if ($this->settings->withLgtmConfiguration()) { $this->lgtmFiles(); } if ($this->settings->withGithubTemplates()) { $this->githubTemplates(); } if ($this->settings->withGithubDocs()) { $this->githubDocs(); } if ($this->settings->withCodeOfConduct()) { $this->codeOfConduct(); } $this->travis(); $this->license($git); $this->composer($git); $this->projectClass(); $this->gitignore(); $this->gitmessage(); $this->gitattributes(); if ($this->settings->withGitInit()) { $this->gitInit($git); } $this->composerInstall($script); $this->scripts($script); }