Skip to content
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

chore(setup): update Husky usage #199

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

merrywhether
Copy link

@merrywhether merrywhether commented May 20, 2024

Proposed Changes

Found while working on #197, pulled out to not force coupling.

  • Updates to using new Husky v9 commands
    Deprecated install and add commands were causing lifecycle events to fail. Verified that hooks are still installed and functional after these changes.

  • Adds packageManager entry to package.json to enable Corepack compatibility
    References same version as referenced in setup/env. For Corepack users this will prompt automatic installation of the correct version, and will be noop for everyone else.

Comment on lines +16 to +19
"husky-setup": "path-exists .husky/commit-msg || (husky init && pnpm husky-setup:commit-msg && pnpm husky-setup:post-merge && pnpm husky-setup:pre-commit)",
"husky-setup:commit-msg": "echo 'pnpm run commit-msg' > .husky/commit-msg",
"husky-setup:post-merge": "echo 'pnpm run setup' > .husky/post-merge",
"husky-setup:pre-commit": "echo 'pnpm run pre-commit' > .husky/pre-commit",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes per Husky v9 changelog

"lint": "eslint index.js --fix",
"lint:ci": "eslint index.js",
"pre-commit": "pnpm lint && pnpm test",
"prepare": "is-ci || pnpm husky-setup",
"prepare": "husky",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically updated by husky init

Copy link
Owner

@yowainwright yowainwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Besides the corepack update. Looks like that causes CI to fail. What are thoughts?

@merrywhether merrywhether changed the title chore(setup): update Husky usage & add packageManager entry chore(setup): update Husky usage Jun 13, 2024
@merrywhether
Copy link
Author

merrywhether commented Jun 13, 2024

@yowainwright I've removed the corepack config addition from this branch in order to make the Husky changes easily mergable. I'm going to poke at corepack solutions a bit since I'm curious about the best options for supporting both types of users. Without the entry, anything that triggers pnpm has this immediate side effect:

! The local project doesn't define a 'packageManager' field. Corepack will now add one referencing pnpm@8.15.7+sha256.50783dd0fa303852de2dd1557cd4b9f07cb5b018154a6e76d0f40635d6cee019.

(picking the current default version in my default mise node version apparently)

We're in a weird limbo were people are starting to enable corepack as the default on their systems, but Node hasn't made it on by default quite yet more broadly.

If there's a corepack config that works and you like, there's an interesting question of moving the source of the pnpm version in the setup script (for those not using corepack) to reading from package json, though reading JSON without jq is never as fun... 🙄

@yowainwright
Copy link
Owner

Great work!

@yowainwright yowainwright merged commit faa556e into yowainwright:main Jun 13, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants