Skip to content

Template for developing and publishing PostHTML plugins

License

Notifications You must be signed in to change notification settings

metonym/template-posthtml-plugin

Repository files navigation

template-posthtml-plugin

Build Coverage

Template for developing and publishing PostHTML plugins.

Inspired by the posthtml-plugin-boilerplate, this template is used to develop and build PostHTML plugins with TypeScript.

The posthtml-plugin-boilerplate contains an excellent sample README to describe and document a plugin.

Don't forget to update the changelog for each release published to the npm registry.

Available Scripts

yarn test:tdd

Runs all tests in watch mode. Use this command when developing a plugin.

yarn test

Runs Jest and ts-jest and outputs testing coverage.

yarn build

Builds the plugin for production.

Continuous Integration (CI)

Travis CI is used to build and test pushed commits.

language: node_js
node_js: stable
cache: yarn
after_success: npx codecov
# Travis CI executes the `yarn test` script by default
# Test coverage should be printed to the Travis build log

The Travis CI configuration can be modified in .travis.yml.

Other tools

Linters are run in husky hooks to enforce a consistent code and formatting style:

  • Prettier: opinionated code formatter used to lint staged files in the pre-commit husky hook

  • TSLint: extensible TypeScript linter used to lint (and fix) errors in the pre-commit husky hook

  • commitlint: commit message linter used in the commit-msg husky hook to encourage semantic commit messages

Publishing to npm

When publishing your plugin for the first time, be sure to update the homepage, repository and bugs fields in the package.json. Login as your npm user and run the following:

yarn publish
# OR
npm publish

Update the relevant publishing-related fields in package.json.

{
  "repository": {
    "type": "git",
    "url": "https://github.com/{USER}/template-posthtml-plugin.git"
  },
  "homepage": "https://github.com/{USER}/template-posthtml-plugin",
  "keywords": ["posthtml", "posthtml plugin", "plugin"],
  "bugs": "https://github.com/{USER}/template-posthtml-plugin/issues"
}

License

MIT