-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Docs suggestion: use "prepare" instead of "postinstall" #884
Comments
If this change is made to the docs, you'll probably also want to update the migration helper: https://github.com/typicode/husky-4-to-5/blob/30792c918d08c0ebb99e1ef8942d13be91b9dd3e/src/pkg.ts#L65 |
@nathansmith Looks great, thanks a lot for the suggestion and detailed explanation! 👍 |
I've updated docs, it's a better approach for |
I've added a dedicated section to the docs for Yarn v2. Also |
Not required when Husky runs via prepare script (only for postinstall) Amends 76df9bd per typicode/husky#884 Signed-off-by: Roger Sheen <[email protected]>
* refactor: updated husky and pretty-quick dependencies and updated to the new config storage model and removed husky and pretty-quick from packages/core, as this should be possible to get triggered from root * refactor: updated prettier dependency and removed rules "trailingComma": "es5" as this is the new default * fix: added missing comma * refactor: regenerated yarn.lock file * refactor(husky): made additional necessary changes for the installation as well as moved husky to the devDependencies, as defined by the software doc itself * refactor(pinst): remove that solution again see typicode/husky#884 * refactor(code): integrated prettier feedback that was enforced like this by eslint * refactor(husky): updated husky and added pinst Yarn 2 doesn't support prepare lifecycle script, so husky needs to be installed differently (this doesn't apply to Yarn 1 though) * Revert "refactor(husky): updated husky and added pinst" This reverts commit e834b42. * refactor(husky): updated husky Co-authored-by: Josef Bredreck <[email protected]>
There's an important caveat to the use of If you have installed I wouldn't want to resort to simply installing |
I have package A (components library) where I use husky with prepare and I have another repository (Package B) where I use package A (from private git repository) as well as husky with prepare. During yarn install, it looks like yarn tries to install package A because it has a prepare script and also install other deps from package B. It appears both installs happen together and causes issues with overwritting cache. |
I think the best solution to install deps for production, if you run RTFM: https://docs.npmjs.com/cli/v7/commands/npm-ci#ignore-scripts |
I second this, the actual best approach even for Maybe you should make this the recommended setup on the doc. |
Running |
For more information see: - typicode/husky#884
See typicode/husky#884 for context on use of prepare.
* Add CI workflows for PRs and publishing * Do not specify Chromium path - use default (bundled) * Scope npm to public @bbc * Add @bbc scope to package-lock.json * Do not build postinstall as this is done before publishing to npm * Ignore scripts on publish as prepare is only used for dev environment See typicode/husky#884 for context on use of prepare. * Fix typo --------- Co-authored-by: Tom Sadler <[email protected]>
- when installing from a git url, tsc command needs to be in the "prepare" lifecycle script. - [when installing from a git url,] If the package being installed contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed. - https://docs.npmjs.com/cli/v10/commands/npm-install - hexo uses prepare script to install husky git hook - typicode/husky#884 - Revert af212dd - Reapply 844a785
TL;DR = Suggestion for the documentation site
This is not a bug "issue," but I wanted to make a suggestion for the docs.
I think this could alleviate some confusion around
postinstall
and remove the necessity forpinst
entirely.Currently, the Husky v5 documentation reads like this.
Instead, that could be changed to this. Swap out
posinstall
forprepare
.Also,
private
does not matter becauseprepare
runs the same regardless.Longer explanation
I did a writeup for my coworkers, to explain our automated setup for configuring Husky v5.
Basically, this all runs via NPM with the
prepare
command and puts everything into place.If this is helpful for the docs, feel free to repurpose it.
The text was updated successfully, but these errors were encountered: