/matter-plugin-boilerplate

a plugin boilerplate for matter.js

Primary LanguageJavaScriptMIT LicenseMIT

matter-plugin-boilerplate

A plugin boilerplate for matter.js

Build Status

This project helps you quickly start a production ready plugin. If you just want to build something quickly, check out the minimal plugin example first.

The wiki articles on Using plugins and Creating plugins contain information on the plugin format and provide some best practices. It can also be useful to study the implementation of existing plugins.

Features

  • a simple plugin example (matter-js)
  • build, develop and release scripts (npm run <x>)
  • a bundler and dev server (webpack)
  • an ES6 transpiler (babel)
  • a linter (eslint)
  • a test suite (mocha and chai)
  • a documentation generator (markdox)
  • a demo runner (matter-tools)
  • continuous integration (travis)

Usage

  1. Import or manually clone this repository
  2. Update package.json
  3. Run npm install && npm run build
  4. Implement your plugin code
  5. Create a examples
  6. Write tests
  7. Document the code
  8. Release your plugin (see commands)
  9. Enable Github Pages to serve the demo
  10. Setup Travis CI (optional)
  11. Update the readme

Notes

Running a build will automatically replace strings commented with PLUGIN_NAME, PLUGIN_VERSION and PLUGIN_REPO_URL with constants pulled directly from package.json. Leave these intact unless you wish to manually keep them up to date.

The included plugin is a very basic example that just sets the friction of all bodies to 0 after creation.

If you add more source files, you will need to update the lint, doc and version scripts in package.json.

Commands

All commands are implemented as npm scripts:

  • npm run build - builds the plugin
  • npm run dev - runs development server
  • npm run test - runs tests
  • npm run lint - runs linter
  • npm run doc - outputs docs to API.md
  • npm run release - lint, test, bump minor, build, doc, commit, tag, push, publish (any will stop all on failure)
  • npm run release-patch - same as above but patch bump