3

Typicode's blog - Husky 5

 3 years ago
source link: https://blog.typicode.com/husky-5/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

I’m happy to announce the release of husky 5 🎉 🐶 woof!

During the past years, husky has grown in complexity. With this version, I wanted to go back to something simpler, more flexible and closer to the metal.

Thanks for your support and feedback. I hope you’ll enjoy this release <3

https://github.com/typicode/husky

husky-5-cover.jpg© MWAM (a great band)

Faster and smaller

Husky 5 is closer to Git and has a lot less abstractions. It makes it not only simpler to understand but also very fast and small.

Time spent to run a simple echo "hello world" pre-commit hook:

husky 5: ~0.01s
husky 4: ~0.50s

Installation size with dependencies:

husky 5: ~0.02MB with  0 packages
husky 4: ~1.00MB with 47 packages

Optional install

With husky 4, hooks were automatically installed. With husky 5, you have the choice and it’s explicit.

You can keep the previous behaviour (recommended) by adding a postinstall script:

// package.json
{
  "private": true,
  "scripts": {
    "postinstall": "husky install"
  }
}

If you prefer to manually install husky, just run in your terminal:

# Manual install
$ npx husky install
$ yarn husky install

Config

Previously, hooks were defined in package.json or .huskyrc. Now they’re defined directly in their corresponding hook file. Overhead is reduced and scripting is easier.

# .husky/pre-commit
# ...
yarn lint-staged

They can also be put in any subdirectory. For example in .config:

# .config support
$ husky install .config/husky
$ husky add .config/husky/pre-commit "npm test"

How to migrate

A new doc site has been created with a dedicated section to migrating hooks from husky 4 to 5. There are some caveats so just copying your previous config may not work.

https://typicode.github.io/husky

License

For a limited time, husky 5 will be released under License Zero’s Parity License. It will be MIT again later.

Free for Open Source ❤️

The Parity License is an Open Source friendly license.

So if you’re using husky in an Open Source project, this new license doesn’t affect you.

You’re free to use husky 5 today and I’m glad if it can help you in your day to day work

Early access for Sponsors 🎁

If you’re using husky in a commercial project, your support would be extremely helpful (husky 5 is free to try for 30 days).

That said, if your company can’t or don’t want to sponsor, that’s perfectly fine too. Husky 4 remains free to use in any project and will continue to receive maintainance updates.

You can become a sponsor on GitHub Sponsors or Open Collective.

Thanks

Thanks to everyone who has sponsored me, I’m sincerely grateful!

I also have other ideas for husky and projects. If you’re a sponsor, you’ll be the first to know about them :)

https://github.com/typicode/husky


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK