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