Files
e2e/scripts/check-install-scripts.ts
T
Oskar Kwaśniewski 0d1ed15871 fix(e2e)!: load TypeScript with e2e's own oxc loader, so pnpm 11+ installs pass (#790)
* fix(e2e): load TypeScript with an oxc loader instead of tsx

* fix(e2e): close loader edge cases: sourceless CommonJS, export maps without extensions, unreadable tsconfig, chained source maps, Windows require paths

* fix(e2e): refuse Bun and Deno runtimes, name oxc load failures, follow Yarn PnP export targets

* perf(e2e): skip the syntax check for files whose only @ is in a package import

* fix(e2e): allow type-only exports in .cts, warn from runner only, Bun check first, docs

* fix(e2e): workers warn about tsconfigs runner did not, FILE: urls, foreign infra errors, review tests
2026-10-04 09:22:50 +02:00

30 lines
1.1 KiB
TypeScript

/**
* Fails when installing a published package would run a dependency's
* install script (`install-scripts.ts` says why that breaks pnpm 11 and
* later for every new user).
*
* Usage: `node scripts/check-install-scripts.ts` after `pnpm install`, part
* of `pnpm check`. Exits 1 listing every package that would run one and the
* dependency chain that brings it in.
*/
import { dirname } from 'node:path';
import { findInstallScripts } from './install-scripts.ts';
import { publicPackages } from './public-packages.ts';
const problems: string[] = [];
const checked: string[] = [];
for (const { path, manifest } of publicPackages()) {
checked.push(manifest.name);
for (const { chain, runs } of findInstallScripts(dirname(path))) {
problems.push(`${chain} runs an install script (${runs}); every pnpm 11+ install of ${manifest.name} fails on it`);
}
}
if (problems.length > 0) {
process.stderr.write(`${problems.join('\n')}\n`);
process.exitCode = 1;
} else {
process.stdout.write(`install scripts: none in the dependency trees of ${checked.toSorted().join(', ')}\n`);
}