Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/server/scripts/build-server-bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

import esbuild from 'esbuild';
import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';

Expand Down Expand Up @@ -82,3 +83,14 @@ async function buildBundle(entryPoint, outfile) {

await buildBundle('src/server.ts', 'dist/server.bundle.mjs');
await buildBundle('src/start-local.ts', 'dist/start-local.bundle.mjs');

const connectorsSrc = join(pkgDir, '..', 'connectors', 'src');
const connectorsDest = join(pkgDir, 'dist', 'connectors');
if (existsSync(connectorsSrc)) {
if (existsSync(connectorsDest)) {
rmSync(connectorsDest, { recursive: true, force: true });
}
mkdirSync(dirname(connectorsDest), { recursive: true });
cpSync(connectorsSrc, connectorsDest, { recursive: true });
console.log(`\n=== copied connectors: ${connectorsDest}`);
}
Comment on lines +87 to +96
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fail fast if connector sources are missing instead of silently skipping copy.

Line 89 currently treats a missing connectors/src as success. That can ship a bundle without dist/connectors (or leave stale contents), which is exactly the failure mode this PR is fixing. Make this step deterministic: clear destination first, then throw when source is absent.

Suggested patch
 const connectorsSrc = join(pkgDir, '..', 'connectors', 'src');
 const connectorsDest = join(pkgDir, 'dist', 'connectors');
-if (existsSync(connectorsSrc)) {
-  if (existsSync(connectorsDest)) {
-    rmSync(connectorsDest, { recursive: true, force: true });
-  }
-  mkdirSync(dirname(connectorsDest), { recursive: true });
-  cpSync(connectorsSrc, connectorsDest, { recursive: true });
-  console.log(`\n=== copied connectors: ${connectorsDest}`);
-}
+if (existsSync(connectorsDest)) {
+  rmSync(connectorsDest, { recursive: true, force: true });
+}
+if (!existsSync(connectorsSrc)) {
+  throw new Error(`Missing connector sources at: ${connectorsSrc}`);
+}
+mkdirSync(dirname(connectorsDest), { recursive: true });
+cpSync(connectorsSrc, connectorsDest, { recursive: true });
+console.log(`\n=== copied connectors: ${connectorsDest}`);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/scripts/build-server-bundle.mjs` around lines 87 - 96, Ensure
the copy step fails fast: always remove the destination with
rmSync(connectorsDest, { recursive: true, force: true }) first to avoid stale
files, then check existsSync(connectorsSrc) and throw a descriptive Error when
the source is missing instead of silently skipping; after confirming the source
exists, recreate the parent directory (mkdirSync(dirname(connectorsDest), {
recursive: true })) and use cpSync(connectorsSrc, connectorsDest, { recursive:
true }) and console.log as before. Use the existing symbols connectorsSrc,
connectorsDest, rmSync, existsSync, mkdirSync, and cpSync to locate and update
the logic.

Loading