ReviewOS

also looking at this

craft-native/craft

fix(ci): build the SDK types with the repo's own tsc (and pin the pantry action)

#104
Merged glennmichael123 wants to merge fix/pin-pantry-action into main
29 files +85 -56
packages/typescript/scripts/tsc.tsadded+21-0
Changes to packages/typescript/scripts/tsc.ts
@@ -0,0 +1,21 @@
1/**
2 * Run the `tsc` this package declares, not the one on PATH.
3 *
4 * `bunx tsc` resolves through PATH. In CI the pantry action provisions its own
5 * typescript into `<repo>/pantry` and puts it ahead of `node_modules/.bin`, so
6 * the same command silently ran a different compiler — a dev build the
7 * lockfile never pinned, and one whose linux-x64 platform binary is missing:
8 *
9 * Error: Unable to resolve @typescript/typescript-linux-x64.
10 *
11 * Locally nothing shadows `node_modules/.bin`, which is why the break only
12 * ever showed up in one CI job. Resolving through the module graph instead of
13 * PATH makes both places run the version `bun.lock` says.
14 */
15import { dirname, join } from 'node:path'
16
17const pkgRoot = dirname(dirname(Bun.resolveSync('typescript', import.meta.dir)))
18const tsc = join(pkgRoot, 'bin', 'tsc')
19
20const proc = Bun.spawn(['bun', tsc, ...Bun.argv.slice(2)], { stdio: ['inherit', 'inherit', 'inherit'] })
21process.exit(await proc.exited)