Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

.pnpmfile.cjs

49 lines1.9 KB

1const fs = require("node:fs");
2const path = require("node:path");
3​
4// Our forks ship as tarballs in apps/mobile/deps and apps/web/deps. A pnpm patch on one is a
5// second source of truth that the next tarball silently drops, so changes go to the fork (see
6// the README beside each tarball).
7const FORK_APPS = ["apps/mobile", "apps/web"];
8​
9function forkTarballPatches(patchedDependencies) {
10 if (!patchedDependencies) return [];
11 const forks = FORK_APPS.flatMap((app) => {
12 const manifestPath = path.join(__dirname, app, "package.json");
13 // Release staging installs a partial workspace without every app.
14 if (!fs.existsSync(manifestPath)) return [];
15 const { dependencies = {} } = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
16 return Object.keys(dependencies).filter((name) =>
17 String(dependencies[name]).startsWith("file:deps/"),
18 );
19 });
20 return Object.keys(patchedDependencies).filter((key) =>
21 forks.some((name) => key === name || key.startsWith(`${name}@`)),
22 );
24​
25module.exports = {
26 hooks: {
27 updateConfig(config) {
28 const forkPatches = forkTarballPatches(config.patchedDependencies);
29 if (forkPatches.length > 0) {
30 throw new Error(
31 `pnpm-workspace.yaml patches ${forkPatches.join(", ")}, which ships as a fork tarball in ` +
32 "an app's deps directory. Change the fork and replace the tarball instead (deps/README.md).",
33 );
34 }
35 // Windows installs need Linux x64 glibc binaries because WSL shares node_modules.
36 // Keep other platforms native; release scripts set their own architectures.
37 // oxlint-disable-next-line t3code/no-global-process-runtime -- pnpm loads this file before any Effect runtime exists.
38 if (process.platform !== "win32") return config;
39 return {
40 ...config,
41 supportedArchitectures: {
42 os: ["current", "linux"],
43 cpu: ["current", "x64"],
44 libc: ["current", "glibc"],
45 },
46 };
47 },
48 },
49};