fix(pre-commit): enforce BunnyCDN registry URLs in yarn.lock#34818
Draft
fix(pre-commit): enforce BunnyCDN registry URLs in yarn.lock#34818
Conversation
Adds a check_yarn_lock_registry() function to the pre-commit hook that blocks commits where yarn.lock contains entries pointing to registry.yarnpkg.com or registry.npmjs.org instead of the project's BunnyCDN cache (dotcms-npm.b-cdn.net). This prevents developers with a global registry override (set via `yarn config set registry` or `npm config set registry`) from silently poisoning the lockfile. Yarn 1.x does not reliably honour the project-level .yarnrc when a global config is present, so the hook acts as the enforcement layer. The check fires only when yarn.lock is staged, keeping it a zero-cost no-op for every other commit. On failure, it prints the exact commands the developer needs to diagnose and fix the issue. Closes #34619 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
check_yarn_lock_registry()function to the pre-commit hook (core-web/.husky/pre-commit) that blocks commits whereyarn.lockcontains wrong registry URLs (registry.yarnpkg.comorregistry.npmjs.org) instead of the project's BunnyCDN cache (dotcms-npm.b-cdn.net).Background
This is a recurrence of the issue fixed in #34676. When the Lara Theme / Angular 21 upgrade (#34531) was merged, the developer who regenerated
yarn.lockhad a global registry override set locally. Yarn 1.x does not reliably honour the project-level.yarnrcwhen a global config is present —npm config set registrysilently takes higher priority, causing the lockfile to be regenerated with the wrong registry URLs and breaking CI/CD reliability.Root cause
core-web/.yarnrccorrectly points tohttps://dotcms-npm.b-cdn.netyarn config set registryornpm config set registrysilently overrides thisyarn installregeneratesyarn.lockwith upstream registry URLs (3,455+ affected entries)What this PR does
check_yarn_lock_registry()to.husky/pre-commityarn installstagesyarn.lockregistry.yarnpkg.comorregistry.npmjs.orgentriesyarn.lockis actually stagedWhat this PR does NOT do
yarn.lockonmain— that requires a separate PR where someone with no global registry override regenerates it correctlyTest plan
yarn config set registry https://registry.npmjs.orgyarn installincore-web/core-web/yarn.lockand attempt to commit — hook should block with a clear error messageyarn config delete registryyarn install, re-stage, re-commit — hook should passRelated
🤖 Generated with Claude Code