fix(cli): resolve component and hook names case-exactly on case-insensitive filesystems - #5478
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
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.
Why
Two CLI tests fail on macOS on a clean
origin/main, and pass in CI:hook-discovery.test.mjs→resolves a bare (use-prefix-stripped, case-insensitive) namecomponent.test.mjs→is case-SENSITIVE: a lowercased name is unknownThey are not a matched pair pulling in opposite directions, and no rule changed.
Both are the same defect, and the tests encode the correct behaviour.
findComponentReadme,findComponentSourceandfindHookDocprobe candidatepaths with
fs.existsSync, which answers through the filesystem's own casefolding. On case-insensitive APFS/NTFS,
existsSync('src/button/button.doc.mjs')is
trueagainst the realsrc/Button/Button.doc.mjs. So on a Mac:astryx component buttonsilently answers forButtoninstead of reporting anunknown component with suggestions.
findHookDoc(core, 'mediaquery')returns.../hooks/useMediaquery.doc.mjs— aspelling that exists nowhere. It is read back fine on the Mac that produced it
and breaks anywhere case-sensitive.
Confirmed by running the unmodified resolvers against the same
packages/coretree on a case-sensitive APFS volume and on the Mac's normal one:
findHookDoc(core, 'mediaquery')src/hooks/useMediaQuery.doc.mjssrc/hooks/useMediaquery.doc.mjsfindComponentReadme(core, 'button')nullsrc/button/button.doc.mjsWhat
Adds
existsCaseExact(targetPath, rootDir)tofoundation/fs/paths.mjs: itkeeps the cheap
existsSyncshort-circuit, then verifies every path segmentbelow
rootDiragainst its parent's real directory listing. The three resolversuse it for their name-derived probes.
The deliberate case-insensitive hook lookup is unchanged —
mediaquerystillresolves, it now just returns the file's true casing (step 2 of
findHookDoc,which reads real names off
readdirSync, does the work the foldedexistsSyncwas shadowing).
Risk
Low, and confined to the CLI's name resolution.
Behaviour on Linux is unchanged by construction —
existsSyncalready answeredcase-exactly there, so the added check can only agree. On macOS/Windows, a
lowercase name that used to resolve by accident now takes the normal
unknown-name path (fuzzy suggestions, or
ERR_UNKNOWN_COMPONENT) — the sameanswer Linux and CI have always given.
One cost: on macOS a miss like
component buttonnow pays the full-treefallback scan (~0.5ms → ~50ms), because it stops short-circuiting on a wrong-case
hit. That is the cost every unknown name already pays, and the cost Linux
already paid.
Testing
packages/clinode suite is green(2837/2837). At the default 30s per-test timeout this laptop flakes several
unrelated tests under load —
--testTimeout=180000clears them, on this branchand on
origin/mainalike.existsCaseExactinpaths.test.mjscover basenamecase, a wrong-case directory segment, missing paths, and a target outside the
root. They pass on both filesystem kinds (trivially on Linux, meaningfully on a
Mac).
return byte-identical paths on both filesystems.
astryx component buttonon macOS now printsNo component named "button"with
Button (exact name)/IconButton (keyword "button")suggestions.eslintclean; all fourpackages/clitypecheck projects clean.