Skip to content

Commit

Permalink
select min php version
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Feb 10, 2016
1 parent b624dd1 commit 2c9e93a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
14 changes: 14 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var BarePHP = module.exports = function BarePHP() {
type: 'library',
keywords: '',
homepage: '',
phpversion: 5.5,
testphpversion: 5.6,
license: '',
licenseFile: '',
namespace: ''
Expand Down Expand Up @@ -208,6 +210,13 @@ BarePHP.prototype.askForProject = function () {
name: 'keywords',
message: 'What are the project keywords?',
default: this.project.keywords
},
{
type: 'list',
name: 'phpversion',
message: 'What is the minimum supported PHP version for the project?',
choices: ['5.5', '5.6', '7.0'],
default: this.project.phpversion.toString()
}
];

Expand All @@ -218,6 +227,11 @@ BarePHP.prototype.askForProject = function () {
this.project.description = _.trim(props.description);
this.project.type = props.type.toLowerCase();
this.project.keywords = props.keywords.length ? props.keywords.split(' ') : [];
this.project.phpversion = parseFloat(props.phpversion);

if (this.project.phpversion > this.project.testphpversion) {
this.project.testphpversion = this.project.phpversion;
}

this.project.namespace = _.capitalize(_.trim(props.name));

Expand Down
4 changes: 2 additions & 2 deletions app/templates/_composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ if (project.license != '') { -%>
},
<% } -%>
"require": {
"php": ">=5.5",
"php": ">=<%= project.phpversion %>",
"paragonie/random_compat": "^1.1",
"ircmaxell/password-compat": "^1.0",
"nesbot/carbon": "^1.20",
"nesbot/carbon": "^1.20"
},
"require-dev": {
"phpunit/phpunit": "^4.5",
Expand Down
20 changes: 13 additions & 7 deletions app/templates/extra/_travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ language: php
sudo: false

php:
<% if (project.phpversion <= 5.5) { -%>
- 5.5
<% } -%>
<% if (project.phpversion <= 5.6) { -%>
- 5.6
<% } -%>
<% if (project.phpversion <= 7.0) { -%>
- 7.0
<% } -%>
- hhvm

matrix:
Expand All @@ -17,22 +23,22 @@ before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source
<% if (control.coveralls) { -%>
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then travis_retry composer require satooshi/php-coveralls:dev-master --no-interaction ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '<%= project.testphpversion %>' ]]; then travis_retry composer require satooshi/php-coveralls:dev-master --no-interaction ; fi
<% } -%>

script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpcs --standard=PSR2 <%= dirs.src %> <%= dirs.tests %> ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpmd <%= dirs.src %> text unusedcode,naming,design,controversial,codesize ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpcpd <%= dirs.src %> ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '<%= project.testphpversion %>' ]]; then vendor/bin/phpcs --standard=PSR2 <%= dirs.src %> <%= dirs.tests %> ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '<%= project.testphpversion %>' ]]; then vendor/bin/phpmd <%= dirs.src %> text unusedcode,naming,design,controversial,codesize ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '<%= project.testphpversion %>' ]]; then vendor/bin/phpcpd <%= dirs.src %> ; fi
<% if (!control.coveralls) { -%>
- vendor/bin/phpunit
<% } -%>
<% if (control.coveralls) { -%>
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml ; fi
- if [[ "$TRAVIS_PHP_VERSION" != '5.6' ]]; then vendor/bin/phpunit ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '<%= project.testphpversion %>' ]]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml ; fi
- if [[ "$TRAVIS_PHP_VERSION" != '<%= project.testphpversion %>' ]]; then vendor/bin/phpunit ; fi
<% } -%>
<% if (control.coveralls) { -%>

after_script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then php vendor/bin/coveralls -v ; fi
- if [[ "$TRAVIS_PHP_VERSION" == '<%= project.testphpversion %>' ]]; then php vendor/bin/coveralls -v ; fi
<% } -%>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-barephp",
"version": "0.7.0",
"version": "0.8.0",
"description": "Barebones PHP project scaffold Yeoman generator",
"homepage": "https://github.com/juliangut/generator-barephp",
"bugs": "https://github.com/juliangut/generator-barephp/issues",
Expand Down

0 comments on commit 2c9e93a

Please sign in to comment.