Repository navigation
test(cli): run the authoring migration's tsc check with node - #11261
Conversation
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.
|
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.
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.
|
/approve-spec 0477c65 |
Maintainer impact
packages/cli/assets/codemods/transforms/v0.3.0/__tests__/authoring-migration.tsc.test.mjscan't pass on Windows. Itstsc()helper runsexecFileSync('pnpm', ['exec', 'tsc', '-p', project]). On Windows pnpm is apnpm.cmdbatch file, andexecFileSynccan't start a batch file without a shell, so the spawn fails before tsc runs. The helper'scatchthen reports that as a type error with empty output: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
tscfor the reasons the codemod exists to fix. Same compiler, same tsconfig, same assertions.Change
Resolve
typescript/bin/tscfrom the repo root withcreateRequire(this is the binarypnpm exec tscran fromREPO_ROOT, typescript 6.0.3 here) and start it withprocess.execPath. Still oneexecFileSynccall, nopnpm, 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 throughcmd.exewould 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
pnpm.cmdon PATH): both cases fail as above.Tests 2 passed (2). The negative control still sees the realCannot find module '@astryxdesign/core/authoring'errors, so it isn't passing vacuously.changeset-coverage.mjs pr --base origin/mainreports it as exempt (test file), so no changeset.One caveat for reproducing it: on a stock Windows setup this file stops even earlier, in
makeLinkedFixture(EPERMonfs.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 totest-utils/linked-fixture.mjsif you want it.Scope
Components: CLI tests (
assets/codemods/transforms/v0.3.0)Testing
pnpm exec eslinton the file: clean.prettier --checkflags the file, but only for lines already onmain(thecompilerOptionsobject and twotoMatchcalls). The added lines are formatted, so I left the existing ones alone.