feat: Adds in skeleton recipe pre-commit hook#3500
Conversation
…r current disc items
|
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
…at-skeleton-recipe-commit-hook
Realizing that we need to exclude detection of skeleton changes to files that will be deleted. Updated the script and the README as well.
| }, | ||
| }, | ||
| handler({ files, json }) { | ||
| const affected = getAffectedRecipes(files as string[]); |
There was a problem hiding this comment.
blocking: Once string: true is added to the builder (see comment above), this as string[] assertion can be removed. I want to remove as from this repo because of the type safety issues, so I am also trying not to add any new ones in :)
| const affected = getAffectedRecipes(files as string[]); | |
| const affected = getAffectedRecipes(files); |
|
These findings are in files not modified by this PR and cannot be posted as inline comments.
The Husky hook is chained with npx lint-staged && npm run pre-commit:encrypt && bash cookbook/scripts/pre-commit.shThis means the informational script will never run if Impact: contributors can be prevented from committing locally, especially on Windows/minimal environments, increasing friction and encouraging |
|
🤖 Code Review · #projects-dev-ai for questions ✅ Complete - No issues 📋 History❌ Failed → ✅ No issues |
WHY are these changes introduced?
When modifying skeleton template files, contributors have no automatic signal that cookbook recipes may also need to be updated. This can result in recipes silently drifting out of sync with the skeleton.
WHAT is this pull request doing?
Adds a pre-commit hook and two new cookbook CLI commands to help contributors keep recipes in sync with the skeleton template:
affected-recipes [files..]: given a list of repo-relative skeleton file paths, outputs the names of any cookbook recipes that reference those files (supports --json flag)skeleton-files: lists all skeleton files referenced by recipes (or a specific recipe), with an--existing-onlyflag to filter to files that currently exist on disk.husky/pre-commit hook: when a commit stages changes under templates/skeleton/, the hook runs affected-recipes against the staged files and prints a warning listing which recipes may need regenerating, along with the exact regenerate commands to run. The hook is informational only (always exits 0) and can be bypassed with--no-verify.Supporting this, a dependency-graph library module was added to
cookbook/src/lib/to build the file→recipe mapping by reading all recipe YAML definitions.HOW to test your changes?
git commit— you should see a warning listing affected recipes and regenerate commandsgit commityou can also test the affected recipes runningbash cookbook/scripts/pre-commit.shin the root of projectChecklist