-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy path.pnpmfile.cjs
More file actions
42 lines (36 loc) · 1.86 KB
/
.pnpmfile.cjs
File metadata and controls
42 lines (36 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// When CI artifacts are present, redirect envio dependencies from the
// dev workspace member (packages/envio) to the pre-built artifact in
// .envio-artifacts/envio. Also redirect the platform binary package
// (envio-linux-x64) to its local artifact. In normal dev this is a no-op.
const fs = require("fs");
const path = require("path");
// Resolve relative to this file (workspace root) instead of process.cwd()
// so that pnpm installs invoked from a workspace member (e.g.
// `envio codegen` running pnpm install in scenarios/e2e_test) still see
// the artifact and apply the same redirect. Otherwise the second install
// reinstalls envio from packages/envio without rescript build artifacts,
// dropping new files like src/Bin.res.mjs.
const ARTIFACT_DIR = path.join(__dirname, ".envio-artifacts", "envio");
const PLATFORM_ARTIFACT_DIR = path.join(__dirname, ".envio-artifacts", "envio-linux-x64");
const hooks = {};
if (fs.existsSync(ARTIFACT_DIR)) {
hooks.readPackage = (pkg) => {
// Redirect any file: envio reference to the CI artifact.
// This catches both relative paths (file:../../packages/envio)
// and absolute/pnpm-store paths generated by codegen.
for (const field of ["dependencies", "devDependencies", "optionalDependencies"]) {
const envioSpec = pkg[field]?.envio;
if (envioSpec && (envioSpec.includes("packages/envio") || envioSpec.startsWith("file:"))) {
pkg[field].envio = `file:${ARTIFACT_DIR}`;
}
}
// Redirect envio-linux-x64 in the artifact's optionalDependencies
// to the local platform NAPI addon artifact. The path is relative to
// the envio package directory (.envio-artifacts/envio/).
if (pkg.name === "envio" && pkg.optionalDependencies?.["envio-linux-x64"]) {
pkg.optionalDependencies["envio-linux-x64"] = "file:../envio-linux-x64";
}
return pkg;
};
}
module.exports = { hooks };