Repository navigation
test(shadcn-registry): ShadCN's temporary directories stay in the consumer project - #9223
Conversation
…sumer project The pinned ShadCN client (4.19.0) makes an empty temporary directory, mkdtemp(path.join(tmpdir(), "shadcn-")), for each file it transforms during `shadcn add` and never removes it. The registry tests' five `shadcn add` runs left 15 of them in the system temporary directory on every `pnpm test:node`, and the full-catalog verifier one per transformed file; a shared machine collected 187,072. Both callers now give ShadCN a TMPDIR inside the consumer project they already create and remove. The test also removes its no-op package-manager directory after the file; it was made once per run and never removed. With TMPDIR pointed at an empty directory, one run of the test file left 15 shadcn-* directories and 1 astryx-noop-pm-* before, and none after.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
This looks ready to merge once it leaves draft: giving ShadCN a TMPDIR inside each consumer project keeps its scratch directories out of the system temporary directory, and the before/after counts in the description reproduce (15 shadcn-* plus one astryx-noop-pm-* from the test file before, none after) with the tests and the verifier passing exactly as before. No public API or product behaviour changes. CI has not run on this head because the pull request is a draft, so mark it ready for review to get the required checks.
[Automated review]
Maintainer impact
Each run of
internal/shadcn-registry/generate-shadcn-registry.test.mjs, which is part ofpnpm test:node, leaves 16 directories in the system temporary directory.verify-full-catalog.mjsleaves one for every file ShadCN transforms. On a shared machine that runs these often, the temporary directory held 187,072shadcn-*directories, and every tool that reads that directory's listing slowed down (that size is what timed out the analyze-pr test fixed in #9212).Intended invariant
The test and the catalog verifier check what they checked before, and leave nothing behind in the system temporary directory.
Change
The pinned ShadCN client, 4.19.0, makes an empty temporary directory (
mkdtemp(path.join(tmpdir(), "shadcn-"))) for each file it transforms duringshadcn addand never removes it. Both callers now give it aTMPDIRinside the consumer project they already create and remove infinally: the test's fiveshadcn addruns, andrunShadcninverify-full-catalog.mjs. The test also removes its no-op package-manager directory inafterAll; it was made once per run and never removed.Upstream origin: ShadCN's transform step in 4.19.0. 4.22.1, which #8750 bumps to, no longer makes these in its transform step, but its icons step still makes one. This change keeps whatever ShadCN makes inside the project either way. Nothing is filed upstream.
Evidence
TMPDIRpointed at an empty directory, one run of the test file (29 tests pass) left 15shadcn-*directories and 1astryx-noop-pm-*. One run ofverify-full-catalog.mjsover a 12-item catalog (18 installed files per mode, in TypeScript and JavaScript) left 60shadcn-*.node-compile-cachedirectory appears in both runs: a cache Node reuses, not one per run.Scope
Testing
TMPDIR=<empty directory> pnpm exec vitest run --project node internal/shadcn-registry/generate-shadcn-registry.test.mjs, and withTMPDIR=<empty directory> node internal/shadcn-registry/verify-full-catalog.mjsafterpnpm buildandDOCSITE_TARGET=canary node apps/docsite/scripts/generate-data.mjs, as CI runs it. The verifier ran over a 12-item subset of the 1,036-item canary catalog (4 components, 2 hooks, 4 examples, 2 templates;registry.jsoncut to them and restored afterwards), because the whole catalog was too heavy for a shared machine.cache.test.mjslock tests that fail on this machine without the change too (fix(cli): a crashed run's release install is recognized by the Node it ran on, whatever its name #8520).