Skip to content

test(cli): run the authoring migration's tsc check with node - #11261

Merged
cixzhang merged 1 commit into
meta:mainfrom
prath47:windows-authoring-migration-pnpm
Nov 12, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
prath47:windows-authoring-migration-pnpm

Conversation

@prath47

@prath47 prath47 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Maintainer impact

packages/cli/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjs can't pass on Windows. Its tsc() helper runs execFileSync('pnpm', ['exec', 'tsc', '-p', project]). On Windows pnpm is a pnpm.cmd batch file, and execFileSync can't start a batch file without a shell, so the spawn fails before tsc runs. The helper's catch then reports that as a type error with empty output:

 × migrated consumer code type-checks against the real authoring types
 × negative control: pre-migration code fails tsc (removed paths + factories)
AssertionError: tsc reported errors on migrated output:
AssertionError: expected '' to match /Cannot find module '@astryxdesig…/core\

The astracat review on #11051 pointed this file out as a follow-up.

Intended invariant

Both cases keep checking what they did: migrated consumer code type-checks against the real authoring types, and the unmigrated code fails tsc for the reasons the codemod exists to fix. Same compiler, same tsconfig, same assertions.

Change

Resolve typescript/bin/tsc from the repo root with createRequire (this is the binary pnpm exec tsc ran from REPO_ROOT, typescript 6.0.3 here) and start it with process.execPath. Still one execFileSync call, no pnpm, no shell.

I didn't reuse the cmd.exe /d /s /c pnpm … routing from #11051 here. This call passes a temp tsconfig path, and going through cmd.exe would mean that path has to survive cmd's quoting rules (a space or & in the user's temp folder). Running node directly sidesteps that, and it also skips a pnpm startup per case.

Evidence

  • Failure before the change (Windows 10, Node 24.22.1, only pnpm.cmd on PATH): both cases fail as above.
  • Success after the change: Tests 2 passed (2). The negative control still sees the real Cannot find module '@astryxdesign/core/authoring' errors, so it isn't passing vacuously.
  • Product/runtime behavior verified unchanged: test file only. changeset-coverage.mjs pr --base origin/main reports it as exempt (test file), so no changeset.
  • CI impact: none. On Linux the same tsc runs on the same tsconfig.

One caveat for reproducing it: on a stock Windows setup this file stops even earlier, in makeLinkedFixture (EPERM on fs.symlinkSync(..., 'dir') without Developer Mode). For the runs above I switched that call to 'junction' locally, and that isn't part of this PR. Directory junctions need no special rights on Windows, so that could be its own small change to test-utils/linked-fixture.mjs if you want it.

Scope

Components: CLI tests (assets/codemods/transforms/v0.3.0)

  • 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

  • Before/after above, on Windows.
  • pnpm exec eslint on the file: clean. prettier --check flags the file, but only for lines already on main (the compilerOptions object and two toMatch calls). The added lines are formatted, so I left the existing ones alone.
  • Pre-commit hook passed. Not run on macOS/Linux here.

The type-level codemod test ran `pnpm exec tsc` through execFileSync. On
Windows pnpm is a pnpm.cmd batch file, which execFileSync can't start
without a shell, so both cases failed before tsc ran: the positive case
on the spawn error, the negative control on its empty output.

Resolve the workspace's typescript/bin/tsc from the repo root, the same
tsc `pnpm exec` ran, and start it with process.execPath. No shell, so the
temp tsconfig path needs no quoting.
@vercel

vercel Bot commented Nov 11, 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 Nov 11, 2026 3:52pm UTC

Request Review

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 11, 2026
@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 11, 2026, 4:00 PM UTC

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

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 0477c65

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.

Approved pending CI: CI has not run on this head yet, so a maintainer needs to add the ci:run label.

Starting the workspace's own tsc with process.execPath removes the pnpm.cmd spawn that failed both cases on Windows, and it matches how the other CLI type-check tests start the compiler. The test passes on Linux even with pnpm off PATH, and the negative control still fails for the real Cannot find module '@astryxdesign/core/authoring' reasons, so it does not pass vacuously.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 0477c65

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 11, 2026
@cixzhang
cixzhang marked this pull request as draft November 11, 2026 19:37
@cixzhang
cixzhang marked this pull request as ready for review November 11, 2026 19:38
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 12, 2026
@cixzhang
cixzhang merged commit bc018a8 into meta:main Nov 12, 2026
124 of 128 checks passed

This branch was successfully deployed

1 active deployment
Preview — 0477c654 Deployed Nov 11, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants