Skip to content

Build: Install Husky hooks in fresh worktrees#34126

Merged
kasperpeulen merged 3 commits into
storybookjs:nextfrom
kasperpeulen:kasper/fix-husky-worktree-hooks
Mar 13, 2026
Merged

Build: Install Husky hooks in fresh worktrees#34126
kasperpeulen merged 3 commits into
storybookjs:nextfrom
kasperpeulen:kasper/fix-husky-worktree-hooks

Conversation

@kasperpeulen
Copy link
Copy Markdown
Member

@kasperpeulen kasperpeulen commented Mar 13, 2026

Closes #

What I did

Switched the root Husky install script from prepare to postinstall so Yarn installs actually generate .husky/_ in new worktrees.

This follows Husky's Yarn guidance and restores active git hooks after yarn install in fresh worktrees without changing the existing hook commands.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. From the root, run yarn install --immutable and confirm Git hooks are installed into .husky/_.
  2. Confirm git config --get core.hooksPath resolves to .husky/_.
  3. Create a fresh detached worktree from this branch and verify .husky/_ is absent before install, then run yarn install --immutable and confirm .husky/_ is generated there.
  4. In that fresh worktree, run HUSKY=2 SKIP_STORYBOOK_GIT_HOOKS=1 git commit --allow-empty -m "test" and confirm the pre-commit hook executes.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Chores
    • Updated package installation process to optimize script execution timing during dependency setup.

@kasperpeulen kasperpeulen added build Internal-facing build tooling & test updates ci:normal labels Mar 13, 2026
@kasperpeulen kasperpeulen marked this pull request as ready for review March 13, 2026 10:24
@kasperpeulen kasperpeulen merged commit 1f2080f into storybookjs:next Mar 13, 2026
94 of 114 checks passed
@kasperpeulen kasperpeulen deleted the kasper/fix-husky-worktree-hooks branch March 13, 2026 10:25
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dfed298c-5abf-4fe4-b0fa-36c9d894d124

📥 Commits

Reviewing files that changed from the base of the PR and between 28faedc and 7fbd946.

📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

Modified package.json to replace the "prepare" script hook with a "postinstall" script hook, changing when dependency installation tasks are executed during the npm install lifecycle.

Changes

Cohort / File(s) Summary
Lifecycle Script Hook Configuration
package.json
Removed "prepare" script entry and added "postinstall" script entry, shifting hook execution timing during dependency installation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • Build: Upgrade husky from v4 to v9 #34027: Directly modifies package.json lifecycle scripts related to husky hooks (adds "prepare": "husky" for husky v9 compatibility while this PR removes the "prepare" hook in favor of "postinstall").
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant