Repository navigation
Commit 6224efd
authored
test(shadcn-registry): ShadCN's temporary directories stay in the consumer project (#9223)
## 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
- [x] No intended public API, product behavior, visual direction, or policy change.
- [x] Product changes discovered during the work were removed or split.
- [x] 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 (#8520).1 parent 0fa0207 commit 6224efd
2 files changed
Lines changed: 27 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | | - | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
82 | 96 | | |
83 | 97 | | |
84 | 98 | | |
| |||
618 | 632 | | |
619 | 633 | | |
620 | 634 | | |
621 | | - | |
| 635 | + | |
622 | 636 | | |
623 | 637 | | |
624 | 638 | | |
| |||
711 | 725 | | |
712 | 726 | | |
713 | 727 | | |
714 | | - | |
| 728 | + | |
715 | 729 | | |
716 | 730 | | |
717 | 731 | | |
| |||
792 | 806 | | |
793 | 807 | | |
794 | 808 | | |
795 | | - | |
| 809 | + | |
796 | 810 | | |
797 | 811 | | |
798 | 812 | | |
| |||
941 | 955 | | |
942 | 956 | | |
943 | 957 | | |
944 | | - | |
| 958 | + | |
945 | 959 | | |
946 | 960 | | |
947 | 961 | | |
| |||
1022 | 1036 | | |
1023 | 1037 | | |
1024 | 1038 | | |
1025 | | - | |
| 1039 | + | |
1026 | 1040 | | |
1027 | 1041 | | |
1028 | 1042 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
449 | 451 | | |
450 | 452 | | |
451 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
452 | 458 | | |
453 | 459 | | |
454 | 460 | | |
455 | 461 | | |
456 | 462 | | |
457 | 463 | | |
458 | | - | |
| 464 | + | |
459 | 465 | | |
460 | 466 | | |
461 | 467 | | |
| |||
0 commit comments