typicode / pinst

🍺 dev only postinstall hooks (package.json)
MIT License
259 stars 8 forks source link

Recommendation for Yarn v2+ #16

Closed silvenon closed 2 years ago

silvenon commented 3 years ago

First of all, thank you for pinst and husky, I love these packages so much! ❤️

Regarding my question, as you know from husky, Yarn v2+ has narrower support for lifecycle hooks. Instead of prepublishOnly I think it's ok to use prepack, but postpack seems to be running before publish, so is there a general recommendation for using pinst with Yarn v2+?

typicode commented 3 years ago

Thanks for the kind words.

I don't know, it would need some testing. I've created an issue to discuss prepare support on Yarn Berry repo. But currently, I unfortunately don't have time to do testing or follow this topic :/

silouanwright commented 2 years ago

Would we be ok adding something to the README along the lines of saying that the instructions currently don't accommodate people using Yarn v2+ ? I'm happy to make a PR along those lines.

Also heads up: for all the commands if you're working with the newest version of yarn, you'll want to make sure you preface them with yarn, especially that pinst --disable command, else your CI build will fail, as shown here: https://github.com/cbinsights/form-design-system/runs/4511199232?check_suite_focus=true

typicode commented 2 years ago

I've updated docs. I think prepack and postpack are the best hooks to have pinst running. Thanks for the suggestion :+1:

Enzime commented 2 years ago

When I run yarn pack, the package.json inside of package.tgz was not modified by pinst --disable.

I believe this is due to custom logic in Yarn 2+ which overwrites package.json:

https://github.com/yarnpkg/berry/blob/%40yarnpkg/cli/2.1.0/packages/plugin-pack/sources/packUtils.ts#L119-L120