-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy path.pnpmfile.cjs
More file actions
39 lines (32 loc) · 1012 Bytes
/
.pnpmfile.cjs
File metadata and controls
39 lines (32 loc) · 1012 Bytes
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
const path = require("path");
const fs = require("fs");
/**
* When A2UI_LOCAL=1, rewrites @a2ui/* dependencies to link against
* locally-built packages from the sibling A2UI repo.
*
* Usage:
* A2UI_LOCAL=1 pnpm install # link to local A2UI packages
* pnpm install # install from npm (default)
*
* Expects:
* /some/path/CopilotKit/ (this repo)
* /some/path/A2UI/ (sibling A2UI repo)
*/
const A2UI_ROOT = path.resolve(__dirname, "..", "A2UI");
const A2UI_PACKAGES = {
"@a2ui/web_core": "renderers/web_core",
"@a2ui/react": "renderers/react",
};
function readPackage(pkg) {
if (!process.env.A2UI_LOCAL) return pkg;
for (const [dep, relPath] of Object.entries(A2UI_PACKAGES)) {
if (pkg.dependencies && pkg.dependencies[dep]) {
const localPath = path.join(A2UI_ROOT, relPath);
if (fs.existsSync(localPath)) {
pkg.dependencies[dep] = `link:${localPath}`;
}
}
}
return pkg;
}
module.exports = { hooks: { readPackage } };