Skip to content

docs: update husky to v9 #3875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,93 @@ To make your life easier commitlint is commitizen-friendly and provides the npm
- present tense
- maximum of 100 characters
- message format of `$type($scope): $message`

## Testing

From the project root directory, use the following commands to run the test suite

```sh
yarn clean
yarn install
yarn build
yarn test
```

## Package dependency overview

![commitlint-dependencies](https://user-images.githubusercontent.com/4248851/58385093-34b79780-7feb-11e9-8f27-bffc4aca3eba.png)

(Partly outdated)

## Publishing a release

```sh
npm login
nvm use (if you have nvm installed)
```

- [nvm](https://github.com/nvm-sh/nvm)
- [asdf](https://asdf-vm.com/) is supported as well

```sh
yarn clean
yarn install
yarn build
yarn test
yarn run publish --otp <one-time password>
```

If something in between fails (like a new package was added and needs to be published for the
first time but you forgot) you can use `lerna publish from-package` to publish anything that
has not been published yet.

### Create GitHub release

1. Copy changelog entry for the new version
1. Create release for the new tag: https://github.com/conventional-changelog/commitlint/releases
1. Post in the [commitlint Slack-channel][12]

### Publish a `next` release (or i.e. patch release)

```sh
npm login
nvm use (if you have nvm installed)
```

```sh
yarn clean
yarn install
yarn build
yarn test
npx lerna publish --conventional-commits --dist-tag [`next` | `[PATCH_RELEASE_VERSION]`] --otp <one-time password>
```

If for some reason this stops in between, you can manually publish missing packages like this:

```sh
npm publish <package-name> --tag [`next` | `[PATCH_RELEASE_VERSION]`] --otp <one-time password>
```

#### Publishing (new) packages for the first time

```sh
npm publish [PACKAGE_NAME] --access public
```

From within the folder first i.e. `cd @commitlint/new-packages`.

#### Move `next` to `latest`

```sh
npm login
```

```sh
npx lerna exec --no-bail --no-private --no-sort --stream -- '[ -n "$(npm v . dist-tags.next)" ] && npm dist-tag add ${LERNA_PACKAGE_NAME}@$(npm v . dist-tags.next) latest --otp <one-time password>'
```

Remove next:

```sh
npx lerna exec --no-bail --no-private --no-sort --stream -- '[ -n "$(npm v . dist-tags.next)" ] && npm dist-tag rm ${LERNA_PACKAGE_NAME} next --otp <one-time password>'
```
5 changes: 1 addition & 4 deletions .husky/commit-msg
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

node @commitlint/cli/lib/cli.js --edit $1
node @commitlint/cli/lib/cli.js --edit $1
7 changes: 4 additions & 3 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
yarn lint-staged

yarn lint-staged
# be sure to build with up to date source
# before running pre-commit hook which is using `@commitlint/cli/lib/cli.js`
yarn build
174 changes: 21 additions & 153 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@

## Contents

- [What is commitlint](#what-is-commitlint)
- [Benefits of using commitlint](#benefits-using-commitlint)
- [Getting started](#getting-started)
- [CLI](#cli)
- [Config](#config)
- [Shared configuration](#shared-configuration)
- [API](#api)
- [Tools](#tools)
- [Version Support and Releases](#version-support-and-releases)
- [Related projects](#related-projects)
- [License](#license)
- [Development](#development)
- [Install and run](#install-and-run)
- [Testing](#testing)
- [Publishing a release](#publishing-a-release)
- [Get Started | Website](#get-started--website)
- [Contents](#contents)
- [What is commitlint](#what-is-commitlint)
- [Benefits of using commitlint](#benefits-of-using-commitlint)
- [Getting started](#getting-started)
- [CLI](#cli)
- [Config](#config)
- [Shared configuration](#shared-configuration)
- [Documentation](#documentation)
- [API](#api)
- [Tools](#tools)
- [Roadmap](#roadmap)
- [Version Support and Releases](#version-support-and-releases)
- [Releases](#releases)
- [Related projects](#related-projects)
- [License](#license)
- [Development](#development)
- [Install and run](#install-and-run)

---

Expand All @@ -48,15 +51,15 @@ type(scope?): subject #scope is optional; multiple scopes are supported (curren

Real world examples can look like this:

```
```text
chore: run tests on travis ci
```

```
```text
fix(server): send cors headers
```

```
```text
feat(blog): add comment section
```

Expand All @@ -83,51 +86,6 @@ These can be modified by [your own configuration](#config).

## Getting started

```sh
# Install commitlint cli and conventional config
npm install --save-dev @commitlint/{config-conventional,cli}
# For Windows:
npm install --save-dev @commitlint/config-conventional @commitlint/cli

# Configure commitlint to use conventional config
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
```

To lint commits before they are created you can use Husky's `commit-msg` hook:

```sh
# Install Husky v6
npm install husky --save-dev
# or
yarn add husky --dev

# Activate hooks
npx husky install
# or
yarn husky install
```

### Add hook

> [!WARNING]
> It's necessary that you use **commit-msg** as the name for hook file.
> Read Git hooks [documentation](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) for more info.

```
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'
```

**Or use installed package instead**

```
npm pkg set scripts.commitlint="commitlint --edit"
npx husky add .husky/commit-msg 'npm run commitlint ${1}'
```

Check the [husky documentation](https://typicode.github.io/husky/#/?id=manual) on how you can automatically have Git hooks enabled after install for different `yarn` versions.

**Detailed Setup instructions**

- [Local setup](https://conventional-changelog.github.io/commitlint/#/guides-local-setup) - Lint messages on commit with husky
- [CI setup](https://conventional-changelog.github.io/commitlint/#/guides-ci-setup) - Lint messages during CI builds

Expand Down Expand Up @@ -255,96 +213,6 @@ yarn run commitlint # run CLI

For more information on how to contribute please take a look at our [contribution guide](./.github/CONTRIBUTING.md).

### Testing

From the project root directory, use the following commands to run the test suite

```sh
yarn clean
yarn install
yarn build
yarn test
```

### Package dependency overview

![commitlint-dependencies](https://user-images.githubusercontent.com/4248851/58385093-34b79780-7feb-11e9-8f27-bffc4aca3eba.png)

(Partly outdated)

### Publishing a release

```sh
npm login
nvm use (if you have nvm installed)
```

- [nvm](https://github.com/nvm-sh/nvm)
- [asdf](https://asdf-vm.com/) is supported as well

```sh
yarn clean
yarn install
yarn build
yarn test
yarn run publish --otp <one-time password>
```

If something in between fails (like a new package was added and needs to be published for the
first time but you forgot) you can use `lerna publish from-package` to publish anything that
has not been published yet.

#### Create GitHub release

1. Copy changelog entry for the new version
1. Create release for the new tag: https://github.com/conventional-changelog/commitlint/releases
1. Post in the [commitlint Slack-channel][12]

#### Publish a `next` release (or i.e. patch release)

```sh
npm login
nvm use (if you have nvm installed)
```

```sh
yarn clean
yarn install
yarn build
yarn test
npx lerna publish --conventional-commits --dist-tag [`next` | `[PATCH_RELEASE_VERSION]`] --otp <one-time password>
```

If for some reason this stops in between, you can manually publish missing packages like this:

```sh
npm publish <package-name> --tag [`next` | `[PATCH_RELEASE_VERSION]`] --otp <one-time password>
```

##### Publishing (new) packages for the first time

```sh
npm publish [PACKAGE_NAME] --access public
```

From within the folder first i.e. `cd @commitlint/new-packages`.

##### Move `next` to `latest`

```sh
npm login
```

```sh
npx lerna exec --no-bail --no-private --no-sort --stream -- '[ -n "$(npm v . dist-tags.next)" ] && npm dist-tag add ${LERNA_PACKAGE_NAME}@$(npm v . dist-tags.next) latest --otp <one-time password>'
```

Remove next:

```sh
npx lerna exec --no-bail --no-private --no-sort --stream -- '[ -n "$(npm v . dist-tags.next)" ] && npm dist-tag rm ${LERNA_PACKAGE_NAME} next --otp <one-time password>'
```

[0]: https://img.shields.io/badge/stability-stable-green.svg?style=flat-square
[1]: https://nodejs.org/api/documentation.html#documentation_stability_index
[2]: https://img.shields.io/npm/v/@commitlint/cli.svg?style=flat-square
Expand Down
Loading