Skip to content

Commit db2a323

Browse files
committed
Handle broken symlinks in build copy for Vercel
Updated the build command in @objectdocs/cli to skip broken symlinks during the copy process, preventing ENOENT errors on Vercel deployments. Bumped versions to 0.2.11 for both @objectdocs/cli and @objectdocs/site.
1 parent ea52f9d commit db2a323

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

packages/cli/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @objectdocs/cli
22

3+
## 0.2.11
4+
5+
### Patch Changes
6+
7+
- fix: handle broken symlinks during build copy to prevent ENOENT errors on Vercel
8+
- @objectdocs/site@0.2.11
9+
310
## 0.2.10
411

512
### Patch Changes

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@objectdocs/cli",
3-
"version": "0.2.10",
3+
"version": "0.2.11",
44
"description": "ObjectDocs CLI",
55
"repository": {
66
"type": "git",

packages/cli/src/commands/build.mjs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,29 @@ export function registerBuildCommand(cli) {
9292
}
9393
// Use copy instead of symlink to ensure compatibility with Vercel
9494
// dereference: true ensures we copy the actual files instead of symlinks, preventing broken links
95-
fs.cpSync(srcNext, destNext, { recursive: true, dereference: true });
95+
fs.cpSync(srcNext, destNext, {
96+
recursive: true,
97+
dereference: true,
98+
filter: (source) => {
99+
try {
100+
if (fs.lstatSync(source).isSymbolicLink()) {
101+
try {
102+
fs.statSync(source);
103+
return true;
104+
} catch (e) {
105+
try {
106+
const target = fs.readlinkSync(source);
107+
console.warn(` Warning: Skipping broken symlink: ${path.basename(source)} -> ${target}`);
108+
} catch(err) {}
109+
return false;
110+
}
111+
}
112+
return true;
113+
} catch (e) {
114+
return false;
115+
}
116+
}
117+
});
96118
console.log(`Build successfully copied to: ${destNext}`);
97119
} else {
98120
console.log(`\nNo 'out' directory generated in ${src}.`);

packages/site/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# @objectdocs/site
22

3+
## 0.2.11
4+
35
## 0.2.10
46

57
### Patch Changes

packages/site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@objectdocs/site",
3-
"version": "0.2.10",
3+
"version": "0.2.11",
44
"description": "ObjectDocs Site Template",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)