diff --git a/.gitignore b/.gitignore
index 5657f6e..64888e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-vendor
\ No newline at end of file
+vendor
+phpcs.xml
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..05d80f7
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,42 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+This project adheres to [Semantic Versioning](http://semver.org/).
+
+## [0.4.0] - 2015-12-02
+
+* Restore explicit reference to `vendor/bin` (previously removed in [#3]) within the pre-commit Git hook ([#11]). Props @leewillis77.
+* Added `--help` and `--version` options to the `wp-enforcer` command for easier usage (and setting us up for more fun options in the future, [#8]). Props @daveross.
+* Fixed major bug wherein PHP_CodeSniffer was complaining about files not containing any code ([#12]).
+* Added a `--vip` option to the `wp-enforcer` command to use WordPress.com VIP coding standards ([#7]). Props @daveross.
+* Moved the Change Log out of the README and into CHANGELOG.md ([#19]).
+
+
+## [0.3.0] - 2015-11-29
+
+* Remove explicit references to `./vendor/bin/`, as Composer automatically prepends this directory to the user's path ([#3]). Props @johnpbloch, @bswatson.
+* Automatically create a `.git/hooks` directory if it doesn't already exist ([#5]).
+
+
+## [0.2.0] - 2015-11-27
+
+* Restrict the Git hook to only changed files, not the entire codebase ([#1]).
+* Confirmed Windows Compatibility (as Git Bash ships with a version of Cygwin for all the Unix-y goodness needed). Props @EricMann ([#2]).
+
+
+## 0.1.0 - 2015-11-22
+
+* Initial public release.
+
+[0.4.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.3.0...HEAD
+[0.3.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.2.0...v0.3.0
+[0.2.0]: https://github.com/stevegrunwell/wp-enforcer/compare/v0.1.0...v0.2.0
+[#1]: https://github.com/stevegrunwell/wp-enforcer/issues/1
+[#2]: https://github.com/stevegrunwell/wp-enforcer/issues/2
+[#3]: https://github.com/stevegrunwell/wp-enforcer/issues/3
+[#5]: https://github.com/stevegrunwell/wp-enforcer/issues/5
+[#7]: https://github.com/stevegrunwell/wp-enforcer/issues/7
+[#8]: https://github.com/stevegrunwell/wp-enforcer/issues/8
+[#11]: https://github.com/stevegrunwell/wp-enforcer/issues/11
+[#12]: https://github.com/stevegrunwell/wp-enforcer/issues/12
+[#19]: https://github.com/stevegrunwell/wp-enforcer/issues/19
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 48dd2e3..d139388 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,9 +4,9 @@ Thank you for taking an interest in helping enforce coding standards on WordPres
This project is open for anyone to make suggestions, report issues, and contribute code, but please adhere to the following guidelines:
-1. **Keep the code as portable as possible:!** Not everyone is running the same, super-cool setup that you use, so we're targeting code that will run across the largest number of machines. That means Bash scripting that will run on OSX, Linux, and Cygwin for our friends on Windows.
-2. **The code is meant to be a starting point for PHP_CodeSniffer usage.** There are a lot of different configurations for WordPress projects, so the best thing we can do is give developers the tools they need to get started and point them to things like [the PHP_CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml)
+1. **Keep the code as portable as possible!** Not everyone is running the same, super-cool setup that you use, so we're targeting code that will run across the largest number of machines. That means Bash scripting that will run on OSX, Linux, and Cygwin for our friends on Windows.
+2. **The code is meant to be a starting point for PHP_CodeSniffer usage.** There are a lot of different configurations for WordPress projects, so the best thing we can do is give developers the tools they need to get started and point them to things like [the PHP_CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml).
## Branching strategy
-The **master** branch should be considered stable, enabling people to pull from "dev-master" at any time and be sure their projects are safe. Active development happens in the **develop** branch.
+The **master** branch should be considered stable, enabling people to pull from "dev-master" at any time and be sure their projects are safe. Active development happens in the **develop** branch. New branches should fork off of the **develop** branch, as this repository is now following the [Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) as of version 0.4.0.
\ No newline at end of file
diff --git a/README.md b/README.md
index c55115d..ddfc689 100644
--- a/README.md
+++ b/README.md
@@ -5,12 +5,12 @@
When writing for a platform as big as WordPress – especially in a team environment – a consistent set of coding standards is vital. Having multiple developers committing code using a mixture of spaces and tabs, inconsistent formatting, or otherwise varying coding styles can lead to headache-inducing merge conflicts.
-There are a number of great tools available to check against established coding standards (namely [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)), but setting them up on a project can be a pain. WP Enforcer is designed to make this setup a breeze.
+There are a number of great tools available to check against established coding standards (namely [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)), but setting them up on a project can be a pain. WP Enforcer is designed to make this setup a breeze.
## How does it work?
-WP Enforcer uses [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automatically run PHP CodeSniffer every time a developer tries to make a commit; if the code isn't up-to-snuff, the commit will be rejected and the developer will get a message explaining what needs to be fixed.
+WP Enforcer uses [Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automatically run PHP_CodeSniffer every time a developer tries to make a commit; if the code isn't up-to-snuff, the commit will be rejected and the developer will get a message explaining what needs to be fixed.
**Note:** If your project already has messy standards you may not want to make WP Enforcer mandatory until *after* you've cleaned up the codebase or suddenly commits will be quite painful! See [Adding to an Existing Project](#adding-to-an-existing-project) for an easy work-around.
@@ -42,12 +42,22 @@ If you'd like to require WP Enforcer for all developers on your project, you can
]
```
+### Writing for WordPress.com VIP
+
+WP Enforcer includes built-in support for the [WordPress.com VIP coding standards](https://vip.wordpress.com/documentation/developers-guide-to-wordpress-com-vip/), simply add `--vip` when you run the `wp-enforcer` command (including in the post-install and post-update commands).
+
+If you need to switch an existing project to the WordPress.com VIP coding standards, you can add the following to your project's phpcs.xml file (replacing "WordPress-Extra", if it's set):
+
+```xml
+
+```
+
## Configuration
-PHP CodeSniffer allows you to [define a custom, default ruleset by creating a phpcs.xml file in your project root](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). WP Enforcer will automatically create a phpcs.xml file in your project if one doesn't already exist, but you can edit this to exclude certain files/directories, ignore specific rules, or load additional rulesets.
+PHP_CodeSniffer allows you to [define a custom, default ruleset by creating a phpcs.xml file in your project root](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). WP Enforcer will automatically create a phpcs.xml file in your project if one doesn't already exist, but you can edit this to exclude certain files/directories, ignore specific rules, or load additional rulesets.
-For a complete list of configuration options, see [the PHP CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml).
+For a complete list of configuration options, see [the PHP_CodeSniffer ruleset.xml standard](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml).
## Adding to an Existing Project
@@ -59,8 +69,9 @@ If you're adding WP Enforcer to a current project, it's recommended to follow th
```bash
$ rm .git/hooks/pre-commit
```
+> **Reminder:** Use the `rm` command with care; double-check everything you're passing to it before you execute, as we'd hate to see you lose valuable repository information (or worse: your operating system).
-This leaves you with a copy of PHP CodeSniffer, a phpcs.xml file, and the WordPress Coding Standards but removes the "don't commit improperly formatted code" restrictions. While still in your clean-up branch, work through the codebase and clean up coding standards, running PHP CodeSniffer manually as needed:
+This leaves you with a copy of PHP_CodeSniffer, a phpcs.xml file, and the WordPress Coding Standards but removes the "don't commit improperly formatted code" restrictions. While still in your clean-up branch, work through the codebase and clean up coding standards, running PHP_CodeSniffer manually as needed:
```bash
$ ./vendor/bin/phpcs
@@ -73,15 +84,3 @@ $ ./vendor/bin/wp-enforcer
```
Finally, merge your clean-up branch into master, kicking your project's coding standards compliance into high gear.
-
-## Changelog
-
-### 0.3.0 - November 29, 2015
-
-* Remove explicit references to `./vendor/bin/`, as Composer automatically prepends this directory to the user's path ([#3](https://github.com/stevegrunwell/wp-enforcer/issues/3)). Props @johnpbloch, @bswatson.
-* Automatically create a `.git/hooks` directory if it doesn't already exist ([#5](https://github.com/stevegrunwell/wp-enforcer/issues/5)).
-
-### 0.2.0 - November 27, 2015
-
-* Restrict the Git hook to only changed files, not the entire codebase ([#1](https://github.com/stevegrunwell/wp-enforcer/issues/1)).
-* Confirmed Windows Compatibility (as Git Bash ships with a version of Cygwin for all the Unix-y goodness needed). Props @EricMann ([#2](https://github.com/stevegrunwell/wp-enforcer/issues/2)).
diff --git a/bin/hooks/pre-commit b/bin/hooks/pre-commit
index c54ce04..cc6ca3a 100644
--- a/bin/hooks/pre-commit
+++ b/bin/hooks/pre-commit
@@ -11,10 +11,10 @@ else
standard=''
fi
-# Run PHP CodeSniffer
-echo "Running PHP CodeSniffer..."
+# Run PHP_CodeSniffer
+echo "Running PHP_CodeSniffer..."
-git diff --name-only --cached | xargs phpcs $standard
+git diff --name-only --cached | xargs vendor/bin/phpcs $standard
if [ $? != 0 ]
then
echo "Please fix coding standards errors before committing"
diff --git a/bin/wp-enforcer b/bin/wp-enforcer
index 0f9ca99..b6e92ca 100755
--- a/bin/wp-enforcer
+++ b/bin/wp-enforcer
@@ -2,15 +2,17 @@
#
# Copy files for WP Enforcer into the project directory.
+readonly VERSION="0.4.0"
readonly BIN="$(cd "$(dirname "$0")" && pwd -P)"
readonly DIR="$BIN/$(dirname "$(readlink "$0")")"
readonly PROJECT="$(pwd)"
+vip=false
# Define command-line options here.
# Follow -o with a comma-separated list of single-character option names.
# Follow -l with a comma-separated list of long option names.
# Options may be followed by one colon to indicate they have a required argument
-if ! options=$(getopt -o h -l help -- "$@")
+if ! options=$(getopt -o h,v -l help,version,vip -- "$@")
then
# something went wrong, getopt will put out an error message for us
exit 1
@@ -20,11 +22,23 @@ while [ $# -gt 0 ]
do
case $1 in
-h|--help)
- echo "Usage: wp-enforcer [OPTION]...";
- echo "After adding wp-enforcer to a project with Composer, run this script to finish installation.";
- echo "";
- echo " -h, --help display this help and exit";
+ echo "After adding WP Enforcer to a project with Composer, run this script to finish installation."
+ echo ""
+ echo "USAGE:"
+ echo " wp-enforcer [options]"
+ echo ""
+ echo "OPTIONS:"
+ echo " --help, -h Show this help and usage"
+ echo " --version, -v Show the current version of WP Enforcer"
+ echo " --vip Configure the project to use the WordPress.com VIP coding standards"
+ echo ""
exit;;
+ -v|--version)
+ echo "$VERSION"
+ exit;;
+ --vip)
+ vip=true;
+ break;;
# For options with required arguments, an additional shift is required
# -o|--option) myarg="$2" ; shift;;
(--) shift; break;;
@@ -94,13 +108,18 @@ else
copy_hook "pre-commit"
fi
-# Copy the PHP CodeSniffer standards file
+# Copy the PHP_CodeSniffer standards file
if [[ ! -f "$PROJECT"/phpcs.xml ]]; then
- cp "$DIR"/../phpcs.xml.sample "$PROJECT"/phpcs.xml
+ if [ "$vip" = false ]; then
+ sample_file_name="phpcs.xml.sample"
+ else
+ sample_file_name="phpcs-vip.xml.sample"
+ fi
+ cp "$DIR"/../"$sample_file_name" "$PROJECT"/phpcs.xml
echo "Created sample phpcs.xml file"
fi
-# Configure PHP CodeSniffer
+# Configure PHP_CodeSniffer
installed_paths="$("$BIN"/phpcs --config-show | grep "installed_paths:")"
if [[ "$installed_paths" != "installed_paths: ../../wp-coding-standards/wpcs" ]]; then
"$BIN"/phpcs --config-set installed_paths ../../wp-coding-standards/wpcs
diff --git a/composer.json b/composer.json
index 0379b97..b922a4c 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "stevegrunwell/wp-enforcer",
"description": "Git hooks to encourage well-written WordPress.",
- "version": "0.3.0",
+ "version": "0.4.0",
"authors": [
{
"name": "Steve Grunwell",
@@ -14,7 +14,7 @@
"git hooks",
"WordPress",
"coding standards",
- "PHP CodeSniffer"
+ "PHP_CodeSniffer"
],
"require": {
"wp-coding-standards/wpcs": "0.8.0"
diff --git a/phpcs-vip.xml.sample b/phpcs-vip.xml.sample
new file mode 100644
index 0000000..6b2034f
--- /dev/null
+++ b/phpcs-vip.xml.sample
@@ -0,0 +1,24 @@
+
+
+
+ Coding standards from WP Enforcer.
+
+
+
+ */tests/*
+ */vendor/*
+
+
+
+ 0
+
+
+
+
+
diff --git a/phpcs.xml.sample b/phpcs.xml.sample
index 2368528..563f72e 100644
--- a/phpcs.xml.sample
+++ b/phpcs.xml.sample
@@ -1,7 +1,7 @@
Coding standards from WP Enforcer.
@@ -11,6 +11,14 @@
*/tests/*
*/vendor/*
-
-
+
+
+ 0
+
+
+
+
\ No newline at end of file