Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provision phpcs + wp sniffs via composer #1169

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions provision/phpcs/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "VVV/phpcs",
"type": "project",
"require": {
"oomphinc/composer-installers-extender": "^1.1",
"wp-coding-standards/wpcs": "*"
},
"extra": {
"installer-types": ["library"],
"installer-paths": {
"/srv/www/phpcs/": ["squizlabs/php_codesniffer"],
"/srv/www/phpcs/CodeSniffer/Standards/WordPress/": ["wp-coding-standards/wpcs"]
}
}
}
31 changes: 5 additions & 26 deletions provision/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -596,37 +596,16 @@ wp_cli() {

php_codesniff() {
# PHP_CodeSniffer (for running WordPress-Coding-Standards)
if [[ ! -d "/srv/www/phpcs" ]]; then
echo -e "\nDownloading PHP_CodeSniffer (phpcs), see https://github.com/squizlabs/PHP_CodeSniffer"
git clone -b master "https://github.com/squizlabs/PHP_CodeSniffer.git" "/srv/www/phpcs"
else
cd /srv/www/phpcs
if [[ $(git rev-parse --abbrev-ref HEAD) == 'master' ]]; then
echo -e "\nUpdating PHP_CodeSniffer (phpcs)..."
git pull --no-edit origin master
else
echo -e "\nSkipped updating PHP_CodeSniffer since not on master branch"
fi
fi
# Sniffs WordPress Coding Standards
echo -e "\nInstall/Update PHP_CodeSniffer (phpcs), see https://github.com/squizlabs/PHP_CodeSniffer"
echo -e "\nInstall/Update WordPress-Coding-Standards, sniffs for PHP_CodeSniffer, see https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards"
cd /vagrant/provision/phpcs
composer update --no-autoloader

# Link `phpcbf` and `phpcs` to the `/usr/local/bin` directory
ln -sf "/srv/www/phpcs/scripts/phpcbf" "/usr/local/bin/phpcbf"
ln -sf "/srv/www/phpcs/scripts/phpcs" "/usr/local/bin/phpcs"

# Sniffs WordPress Coding Standards
if [[ ! -d "/srv/www/phpcs/CodeSniffer/Standards/WordPress" ]]; then
echo -e "\nDownloading WordPress-Coding-Standards, sniffs for PHP_CodeSniffer, see https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards"
git clone -b master "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git" "/srv/www/phpcs/CodeSniffer/Standards/WordPress"
else
cd /srv/www/phpcs/CodeSniffer/Standards/WordPress
if [[ $(git rev-parse --abbrev-ref HEAD) == 'master' ]]; then
echo -e "\nUpdating PHP_CodeSniffer WordPress Coding Standards..."
git pull --no-edit origin master
else
echo -e "\nSkipped updating PHPCS WordPress Coding Standards since not on master branch"
fi
fi

# Install the standards in PHPCS
phpcs --config-set installed_paths ./CodeSniffer/Standards/WordPress/
phpcs --config-set default_standard WordPress-Core
Expand Down