Workflows - dotherightthing/wpdtrt-plugin-boilerplate GitHub Wiki

Summary

The DTRT WordPress Plugin Boilerplate system uses Yeoman, Gulp and Travis build systems. Common workflows are outlined below.

Status

  • Stable @ 1.6.1
  • TODO: explain the functionality of the NPM scripts (see #177)

On this page

  1. System requirements
  2. Create a new plugin
  3. Prepare boilerplate or plugin for development
  4. Add new features to the boilerplate
  5. Test changes
  6. Release an update

Usage

System requirements

  1. WordPress
  2. Node.js & NPM
  3. Composer
  4. Yarn
  5. Gulp

Create a new plugin

  1. Install and run the DTRT WordPress Plugin Boilerplate Generator (Yeoman).

Prepare boilerplate or plugin for development

  1. Install (any new) PHP dependencies (Composer)
  2. Install PHP and front-end dependencies which don't have composer.json files (Yarn)
  3. Lint SCSS, PHP and JavaScript code
  4. Generate PHP and JavaScript documentation
  5. Compile SCSS into CSS
  6. Transpile ES6 JS into ES5
$ yarn run build

Add new features to the boilerplate

The boilerplate contains functionality which is accessed by generating and configuring a plugin.

Although each plugin has its own focus, every plugin must use the same structure and conventions in order to be compatible with each version of the boilerplate.

Therefore, when updating the boilerplate, it will usually be necessary to update the Yeoman plugin generator as well.

The resulting releases of both provide a detailed list of changes which must be made to each existing generated plugin, before it can access the new features added to the current version of the boilerplate.

Release 0.7.25

  • Load PHPUnit config from boilerplate (0.7.22)
  • Use WPUnit install script from boilerplate (0.7.22)
  • Refactor JS to generate meaningful JSDoc output (0.7.22)
  • Include repository sources in child plugin (0.7.22)
  • Simplify inclusion of boilerplate dev dependencies (0.7.22)
  • Install WordPress plugin dependencies using WordPress Packagist (0.7.22)
  • Don't suggest other packages during composer install/update (0.7.22)
  • Fix Slack notification (0.7.22)
  • ES6 & JSDoc fixes (0.7.22)
  • Specify at least current version of boilerplate dependency (0.7.23)
  • Increase verbosity of composer install messages (0.7.25)
  • Expose GH_TOKEN to Composer via both Travis and Yeoman (0.7.25)

This complexity is hidden from plugin releases, which need only reference the release versions:

Release 0.1.8

  • Update wpdtrt-plugin-boilerplate to 1.4.38
  • Sync with generator-wpdtrt-plugin-boilerplate 0.7.25

Note: While Travis CI can also verify compatibility between the plugin and boilerplate, it is most efficient to run these tests in the local development environment first. This reduces commit noise and provides a clearer upgrade path for existing generated plugins.

  1. In the generated plugin, replace the boilerplate installed by Composer with a symlink to the local copy:
cd vendor/dotherightthing
rm -r wpdtrt-plugin-boilerplate
ln -s /Volumes/DanBackup/Websites/wpdtrt-plugin-boilerplate
  1. Edit the boilerplate on local dev, commit as appropriate
  2. Test the boilerplate by running the NPM scripts from the boilerplate's package.json
  3. Test plugin code compatibility by running the NPM scripts from the plugin's package.json
  4. When all tests pass, push to Github
  5. When all Travis tests pass, bump the version on local dev, then push to Github again

Note: The above process is recommended as an alternative to updating composer.json to target dev-master. Generated plugins target specific versions of the boilerplate for clarity, and may require other generated plugins for unit testing. Therefore it would be difficult to change all dependencies to use the dev-master version, and attempting to composer update to this version would likely fail.

Test changes

Lint code and run unit tests:

$ yarn run test

If this fails, the test environment may be missing or out of date. Reinstall it first:

$ yarn run install_deps
$ yarn run test

Release an update

Boilerplate

  1. Test changes, on local dev
  2. Commit tested changes
  3. Update canonical boilerplate version in package.json
    # Disable automatic tag creation when yarn version is run
    npm config set version-git-tag false
    
    # Change node version
    n 11.15.0
    
    # Do versioning
    npm run version
    
  4. This automatically runs the script of the same name, to trigger DTRT WordPress Plugin Bump
    # Change node version
    n 11.15.0
    
    # runs automatically
    npm run version
    
  5. Update readme.txt:
    * Fixed issue foo with bar (#123)
    * Added unicorns (#456)
    
  6. Commit with similar message
  7. Push.
  8. If tests pass, and log is clear, tag and push again.
  9. Update Github Release notes

Generated plugin

  1. Test changes, on local dev
  2. Commit tested changes
  3. Update the boilerplate version in composer.json
  4. Download the latest packages and update the autoload file:
    composer update
    
  5. Update canonical plugin version in package.json
    // Disable automatic tag creation when yarn version is run
    yarn config set version-git-tag false
    
    // Do versioning
    
  6. This automatically runs the script of the same name, to trigger DTRT WordPress Plugin Bump
    // runs automatically
    yarn run version
    
  7. Update readme.txt:
    * Update wpdtrt-plugin-boilerplate from n.n.n to n.n.n
    * Sync with generator-wpdtrt-plugin-boilerplate (n.n.n to n.n.n)
    * Other plugin-specific changes..
    
  8. Commit with similar message
  9. Push.
  10. If tests pass, and log is clear, tag and push again.
  11. Update Github Release notes