Skip to content

test(shadcn-registry): ShadCN's temporary directories stay in the consumer project - #9223

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:test/shadcn-temp-dirs-in-project
Oct 31, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:test/shadcn-temp-dirs-in-project

Conversation

@vjeux

@vjeux vjeux commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Maintainer impact

Each run of internal/shadcn-registry/generate-shadcn-registry.test.mjs, which is part of pnpm test:node, leaves 16 directories in the system temporary directory. verify-full-catalog.mjs leaves one for every file ShadCN transforms. On a shared machine that runs these often, the temporary directory held 187,072 shadcn-* 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 during shadcn add and never removes it. Both callers now give it a TMPDIR inside the consumer project they already create and remove in finally: the test's five shadcn add runs, and runShadcn in verify-full-catalog.mjs. The test also removes its no-op package-manager directory in afterAll; 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

  • Failure before the change: with TMPDIR pointed at an empty directory, one run of the test file (29 tests pass) left 15 shadcn-* directories and 1 astryx-noop-pm-*. One run of verify-full-catalog.mjs over a 12-item catalog (18 installed files per mode, in TypeScript and JavaScript) left 60 shadcn-*.
  • Success after the change: the same runs left none: 0 and 0 from the test file (29 tests pass), and 0 from the verifier over the same catalog (it passes). Node's own node-compile-cache directory appears in both runs: a cache Node reuses, not one per run.
  • Product/runtime behavior verified unchanged: test and CI verifier only.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Leftovers counted with TMPDIR=<empty directory> pnpm exec vitest run --project node internal/shadcn-registry/generate-shadcn-registry.test.mjs, and with TMPDIR=<empty directory> node internal/shadcn-registry/verify-full-catalog.mjs after pnpm build and DOCSITE_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.json cut to them and restored afterwards), because the whole catalog was too heavy for a shared machine.
  • Local gates at 92ba203 (one commit on main dade717): build, typecheck and repo checks pass; the ShadCN registry tests and the CI contract test for the verifier pass (36); the node suite passes except the two cache.test.mjs lock 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).

…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.
@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 31, 2026 10:16pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 31, 2026, 10:20 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 92ba203

Storybook · Sandbox · built from this PR's head

Package size: no published package changed; no new dependencies.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Oct 31, 2026
@cixzhang
cixzhang marked this pull request as ready for review October 31, 2026 22:48
@cixzhang
cixzhang merged commit 6224efd into meta:main Oct 31, 2026
123 of 130 checks passed
@vjeux
vjeux deleted the test/shadcn-temp-dirs-in-project branch November 1, 2026 00:10

This branch was successfully deployed

1 active deployment
Preview — 92ba2030 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants