diff --git a/README.md b/README.md index adb56b1..76bcc25 100644 --- a/README.md +++ b/README.md @@ -36,26 +36,26 @@ Let Yeoman do the heavy lifting and get your projects scaffold and ready to star * QA utilities configured and integrated into Gulp and Grunt * [PHPUnit](http://phpunit.de/) testing environment already set up and integrated into Gulp and Grunt * PHP syntax linting - * [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) for coding style checking - * [PHPMD](https://phpmd.org/) for code mess detection - * [PHPCPD](https://github.com/sebastianbergmann/phpcpd) - * Composer [outdated](https://getcomposer.org/doc/03-cli.md#outdated) for packages updates available + * [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) for PSR2 coding standard checking + * [PHPMD](https://phpmd.org/) for code mess detection (optional customizable rule set) + * [PHPCPD](https://github.com/sebastianbergmann/phpcpd) for copy/paste detection + * Composer [outdated](https://getcomposer.org/doc/03-cli.md#outdated) for packages updates availability check * Initial documentation structure in Markdown * Basic annotated kickoff code (with tests and coverage report!) * "Free Software" and "Open Source" License selection + * [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) * [BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html) * [BSD-2-Clause](https://spdx.org/licenses/BSD-2-Clause.html) * [BSD-4-Clause](https://spdx.org/licenses/BSD-4-Clause.html) - * [MIT](https://spdx.org/licenses/MIT.html) * [GPL-3.0](https://spdx.org/licenses/GPL-3.0.html) * [LGPL-3.0](https://spdx.org/licenses/LGPL-3.0.html) - * [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) + * [MIT](https://spdx.org/licenses/MIT.html) -> And many, many more to come. Would like to see a tool, library, configuration, ... added to the generator? file an issue with your feature request +> Would you like to see a tool, library, configuration, ... added to the generator? file an issue with your feature request #### Quick assistant / fast mode -As the options and tools configured is getting quite long a quick/fast mode has been introduced. In fast mode only the basics questions will be asked and then the generator will do its best guessing the rest for you to get the environment ready faster. +As the list options and tools configured is getting quite long a quick/fast mode has been introduced. In fast mode only the basics questions will be asked and then the generator will do its best guessing the rest for you to get the environment ready faster. ## Getting Started diff --git a/app/index.js b/app/index.js index 15bb854..840d23d 100644 --- a/app/index.js +++ b/app/index.js @@ -49,7 +49,6 @@ var BarePHP = module.exports = function BarePHP() { controlRepository: true, controlDirs: false, controlLicense: true, - controlCustomPHPCS: false, controlCustomPHPMD: false, controlPackagist: true, controlTravis: true, @@ -256,9 +255,6 @@ BarePHP.prototype.askForRepository = function() { if (!this.config.get('accountScrutinizer')) { this.config.set('accountScrutinizer', accountRepository); } - if (!this.config.get('accountStyleci')) { - this.config.set('accountStyleci', 'XXXXXXXX'); - } var repositoryUrl = 'https://'; switch (props.type.toLowerCase()) { @@ -461,7 +457,7 @@ BarePHP.prototype.askCodeConfig = function() { type: 'list', name: 'phpVersion', message: 'What is the minimum supported PHP version for the project?', - choices: ['5.3', '5.4', '5.5', '5.6', '7.0'/*, '7.1'*/], + choices: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1'], default: this.defaults.project.phpVersion.toFixed(1) }, { @@ -532,16 +528,6 @@ BarePHP.prototype.askForToolsInstall = function() { var done = this.async(); var choiceList = [ - { - value: 'customPHPCS', - name: 'Custom PHPCS ruleset', - checked: this.config.get('controlCustomPHPCS') - }, - { - value: 'customPHPMD', - name: 'Custom PHPMD ruleset', - checked: this.config.get('controlCustomPHPMD') - }, { value: 'packagist', name: 'Packagist', @@ -571,6 +557,11 @@ BarePHP.prototype.askForToolsInstall = function() { value: 'docs', name: 'Initial documentation', checked: this.config.get('controlDocs') + }, + { + value: 'customPHPMD', + name: 'Customizable PHPMD ruleset', + checked: this.config.get('controlCustomPHPMD') } ]; @@ -596,13 +587,12 @@ BarePHP.prototype.askForToolsInstall = function() { this.prompt(prompts, function(props) { var hasMod = function(mod) { return props.tools.indexOf(mod) !== -1; }; - this.config.set('controlCustomPHPCS', hasMod('customPHPCS')); - this.config.set('controlCustomPHPMD', hasMod('customPHPMD')); this.config.set('controlPackagist', hasMod('packagist')); this.config.set('controlTravis', hasMod('travis')); this.config.set('controlCoveralls', hasMod('coveralls')); this.config.set('controlScrutinizer', hasMod('scrutinizer')); this.config.set('controlStyleci', hasMod('styleci')); + this.config.set('controlCustomPHPMD', hasMod('customPHPMD')); this.config.set('controlHomestead', hasMod('homestead')); if (!hasMod('homestead')) { this.config.set('controlPhpMyAdmin', false); @@ -706,7 +696,7 @@ BarePHP.prototype.askForScrutinizerAccount = function() { }; BarePHP.prototype.askForStyleciAccount = function() { - if (this.defaults.quickMode || !this.config.get('controlStyleci')) { + if (this.defaults.quickMode || !this.config.get('controlStyleci') || !this.config.get('controlDocs')) { return; } @@ -720,13 +710,10 @@ BarePHP.prototype.askForStyleciAccount = function() { ]; this.prompt(prompts, function(props) { - var accountStyleci = _.clean(props.account).replace(/\s+/g, '_'); - if (accountStyleci === '') { - accountStyleci = 'XXXXXXXX'; - } + var accountStyleci = _.clean(props.account).replace(/\s+/g, ''); - if (accountStyleci === 'XXXXXXXX') { - console.log(chalk.yellow.bold(' Remember to assign StyleCI repository code on readme file')); + if (accountStyleci === '') { + console.log(chalk.yellow.bold(' Remember to assign StyleCI repository code on README file')); } this.config.set('accountStyleci', accountStyleci); @@ -897,7 +884,6 @@ BarePHP.prototype.writing = { repository: this.config.get('controlRepository'), dirs: this.config.get('controlDirs'), license: this.config.get('controlLicense'), - customPHPCS: this.config.get('controlCustomPHPCS'), customPHPMD: this.config.get('controlCustomPHPMD'), packagist: this.config.get('controlPackagist'), travis: this.config.get('controlTravis'), @@ -981,7 +967,7 @@ BarePHP.prototype.writing = { travis: this.config.get('accountTravis'), coveralls: this.config.get('accountCoveralls'), scrutinizer: this.config.get('accountScrutinizer'), - styleci: this.config.get('accountStyleci') + styleci: this.config.get('accountStyleci') !== '' ? this.config.get('accountStyleci') : 'XXXXXXXX' }; this.homestead = { @@ -1033,9 +1019,6 @@ BarePHP.prototype.writing = { this.template('../../templates/_phpunit.xml', 'phpunit.xml'); - if (this.config.get('controlCustomPHPCS')) { - this.template('../../templates/_phpcs.xml', 'phpcs.xml'); - } if (this.config.get('controlCustomPHPMD')) { this.template('../../templates/_phpmd.xml', 'phpmd.xml'); } @@ -1050,7 +1033,7 @@ BarePHP.prototype.writing = { this.template('../../templates/_Gruntfile.js', 'Gruntfile.js'); this.template('../../templates/grunt/_config.js', 'grunt/config.js'); this.copy('../../templates/grunt/phplint.js', 'grunt/phplint.js'); - this.copy('../../templates/grunt/_phpcs.js', 'grunt/phpcs.js'); + this.copy('../../templates/grunt/phpcs.js', 'grunt/phpcs.js'); this.copy('../../templates/grunt/_phpmd.js', 'grunt/phpmd.js'); this.copy('../../templates/grunt/phpcpd.js', 'grunt/phpcpd.js'); this.copy('../../templates/grunt/phpunit.js', 'grunt/phpunit.js'); @@ -1069,7 +1052,7 @@ BarePHP.prototype.writing = { this.template('../../templates/_gulpfile.js', 'gulpfile.js'); this.template('../../templates/gulp/_config.js', 'gulp/config.js'); this.copy('../../templates/gulp/phplint.js', 'gulp/phplint.js'); - this.copy('../../templates/gulp/_phpcs.js', 'gulp/phpcs.js'); + this.copy('../../templates/gulp/phpcs.js', 'gulp/phpcs.js'); this.copy('../../templates/gulp/_phpmd.js', 'gulp/phpmd.js'); this.copy('../../templates/gulp/phpcpd.js', 'gulp/phpcpd.js'); this.copy('../../templates/gulp/phpunit.js', 'gulp/phpunit.js'); diff --git a/package.json b/package.json index 83d4b9a..b99e508 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generator-barephp", - "version": "0.15.1", + "version": "1.0.0-rc.1", "description": "Barebones PHP project scaffold", "keywords": [ "yeoman-generator", @@ -20,6 +20,7 @@ "styleci", "vagrant", "homestead", + "phpmyadmin", "browsersync" ], "homepage": "https://github.com/juliangut/generator-barephp", diff --git a/templates/_gitattributes b/templates/_gitattributes index 3ae8f50..4276e94 100644 --- a/templates/_gitattributes +++ b/templates/_gitattributes @@ -30,9 +30,6 @@ if (control.taskRunner === 'Gulp') { -%> gulpfile.js export-ignore <% } -%> phpunit.xml export-ignore -<% if (control.customPHPCS) { -%> -phpcs.xml export-ignore -<% } -if (control.customPHPMD) { -%> +<% if (control.customPHPMD) { -%> phpmd.xml export-ignore <% } -%> diff --git a/templates/_phpcs.xml b/templates/_phpcs.xml deleted file mode 100644 index 17b3cdf..0000000 --- a/templates/_phpcs.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - <%= project.name %> rule set - - - - diff --git a/templates/grunt/_phpcs.js b/templates/grunt/phpcs.js similarity index 72% rename from templates/grunt/_phpcs.js rename to templates/grunt/phpcs.js index 1aaaf05..f392b6a 100644 --- a/templates/grunt/_phpcs.js +++ b/templates/grunt/phpcs.js @@ -6,7 +6,7 @@ module.exports.tasks = { phpcs: { options: { bin: 'vendor/bin/phpcs', - standard: <% if (control.customPHPCS) { -%>'phpcs.xml'<% } else { -%>'PSR2'<% } -%> + standard: 'PSR2' }, application: { dir: [ diff --git a/templates/gulp/_phpcs.js b/templates/gulp/phpcs.js similarity index 78% rename from templates/gulp/_phpcs.js rename to templates/gulp/phpcs.js index c7750db..a4911b7 100644 --- a/templates/gulp/_phpcs.js +++ b/templates/gulp/phpcs.js @@ -9,7 +9,7 @@ gulp.task('phpcs', function() { return gulp.src([config.src + '/**/*.php', config.tests + '/**/*.php']) .pipe(phpcs({ bin: 'vendor/bin/phpcs', - standard: <% if (control.customPHPCS) { -%>'phpcs.xml'<% } else { -%>'PSR2'<% } -%>, + standard: 'PSR2', warningSeverity: 0 })) .pipe(phpcs.reporter('log')); diff --git a/templates/tools/_scrutinizer.yml b/templates/tools/_scrutinizer.yml index b2c0f75..061c45f 100644 --- a/templates/tools/_scrutinizer.yml +++ b/templates/tools/_scrutinizer.yml @@ -71,6 +71,9 @@ tools: excluded_dirs: [<%= dir.dist %>, <%= dir.tests %>, vendor] php_mess_detector: enabled: true + config: + ruleset: <% if (control.customPHPMD) { -%>phpmd.xml<% } else { -%>'unusedcode,naming,design,controversial,codesize'<% } -%> + php_loc: enabled: true excluded_dirs: [<%= dir.dist %>, <%= dir.tests %>, vendor] diff --git a/templates/tools/_travis.yml b/templates/tools/_travis.yml index 7b1c90f..ac23f32 100644 --- a/templates/tools/_travis.yml +++ b/templates/tools/_travis.yml @@ -5,18 +5,20 @@ sudo: false php: <% if (project.phpVersion <= 5.3) { -%> - 5.3 -<% } -%> -<% if (project.phpVersion <= 5.4) { -%> +<% } +if (project.phpVersion <= 5.4) { -%> - 5.4 -<% } -%> -<% if (project.phpVersion <= 5.5) { -%> +<% } +if (project.phpVersion <= 5.5) { -%> - 5.5 -<% } -%> -<% if (project.phpVersion <= 5.6) { -%> +<% } +if (project.phpVersion <= 5.6) { -%> - 5.6 -<% } -%> -<% if (project.phpVersion <= 7.0) { -%> +<% } +if (project.phpVersion <= 7.0) { -%> - 7.0 +<% } +if (project.phpVersion <= 7.1) { -%> - 7.1 <% } -%> - hhvm @@ -37,25 +39,18 @@ install: <% } -%> script: -<% if (control.customPHPCS) { -%> - if [[ "$TRAVIS_PHP_VERSION" == "<%= project.testPhpVersion.toFixed(1) %>" ]]; then vendor/bin/phpcs --standard=PSR2 <%= dir.src %> <%= dir.tests %> ; fi +<% if (control.customPHPMD) { -%> + - if [[ "$TRAVIS_PHP_VERSION" == "<%= project.testPhpVersion.toFixed(1) %>" ]]; then vendor/bin/phpmd <%= dir.src %> text phpmd.xml ; fi <% } else { -%> - - if [[ "$TRAVIS_PHP_VERSION" == "<%= project.testPhpVersion.toFixed(1) %>" ]]; then vendor/bin/phpcs --standard=phpcs.xml <%= dir.src %> <%= dir.tests %> ; fi -<% } -if (control.customPHPMD) { -%> - if [[ "$TRAVIS_PHP_VERSION" == "<%= project.testPhpVersion.toFixed(1) %>" ]]; then vendor/bin/phpmd <%= dir.src %> text unusedcode,naming,design,controversial,codesize ; fi -<% } else { -%> - - if [[ "$TRAVIS_PHP_VERSION" == "<%= project.testPhpVersion.toFixed(1) %>" ]]; then vendor/bin/phpmd <%= dir.src %> phpmd.xml ; fi <% } -%> - if [[ "$TRAVIS_PHP_VERSION" == "<%= project.testPhpVersion.toFixed(1) %>" ]]; then vendor/bin/phpcpd <%= dir.src %> ; fi <% if (!control.coveralls) { -%> - vendor/bin/phpunit -<% } -%> -<% if (control.coveralls) { -%> +<% } else { -%> - if [[ "$TRAVIS_PHP_VERSION" == "<%= project.testPhpVersion.toFixed(1) %>" ]]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml ; fi - if [[ "$TRAVIS_PHP_VERSION" != "<%= project.testPhpVersion.toFixed(1) %>" ]]; then vendor/bin/phpunit ; fi -<% } -%> -<% if (control.coveralls) { -%> after_script: - if [[ "$TRAVIS_PHP_VERSION" == "<%= project.testPhpVersion.toFixed(1) %>" ]]; then travis_retry php vendor/bin/coveralls -v ; fi