0.1.1 • Published 2 years ago

@sinchsmb/commit v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

sinchsmb/commit

Shared commitlint configuration for the SinchSMB frontend.\ Based on the @commitlint/config-conventional config.

The config is validated by this json schema.

You can read more about the conventional commits here: https://www.conventionalcommits.org/en/v1.0.0/

It is recommended to use these packages to get a full cycle of consistent commits:

Read more in the docs.

This package also provides a command to automatically setup the above packages.

npx @sinchsmb/commit init

This command will:

  • Install and setup the husky package if it isn't installed
  • Install packages (@commitlint/cli, @commitlint/cz-commitlint, commitizen)
  • Setup hooks (prepare-commit-msg, commit-msg)
  • Create configuration files (.cz.json, .commitlintrc.json)

You can achieve the same result by following the steps below.

Install and setup the husky package

npm install husky --save-dev
npm set-script prepare "husky install"
npm run prepare

Install commitizen, commitlint, commitlint adapter for commitizen, config for commitlint.

npm install @sinchsmb/commit @commitlint/cli @commitlint/cz-commitlint commitizen --save-dev

Setup the prepare-commit-msg hook (commitizen)

npx husky add .husky/prepare-commit-msg "exec < /dev/tty && npx cz --hook || true"
git add .husky/prepare-commit-msg

Setup the commit-msg hook (commitlint)

cat <<EEE > .husky/commit-msg
#!/bin/sh
. "\$(dirname "\$0")/_/husky.sh"

npx --no -- commitlint --edit "\${1}"
EEE

Npx will swallow the "\${1}" string so, please, use the command above.

chmod a+x .husky/commit-msg
git add .husky/commit-msg

Copy .cz.json and .commitlintrc.json from src/config into the project root.

IDE users warning

The prepare-commit-msg hook doesn't work (silently skipped) when run through the IDE. It requires an interactive terminal. However, you can use an IDE plugin to properly format the commit message.