Skip to content

Commit 2a3d12d

Browse files
committed
fix: build issues
1 parent 0ade3dc commit 2a3d12d

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mcp-framework",
3-
"version": "0.1.11",
3+
"version": "0.1.12",
44
"description": "Framework for building Model Context Protocol (MCP) servers in Typescript",
55
"type": "module",
66
"author": "Alex Andru <[email protected]>",

src/cli/framework/build.ts

+41-11
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { spawnSync } from "child_process";
33
import { readFileSync, writeFileSync } from "fs";
44
import { join } from "path";
55
import { platform } from "os";
6+
import { existsSync } from "fs";
67

78
export function buildFramework() {
8-
runTsc();
9-
addShebang();
10-
console.log("MCP Build complete");
11-
}
12-
13-
function runTsc() {
9+
const tsconfigPath = join(process.cwd(), "tsconfig.json");
10+
if (!existsSync(tsconfigPath)) {
11+
console.error("Error: tsconfig.json not found!");
12+
process.exit(1);
13+
}
14+
console.log("Found tsconfig.json");
1415
const isWindows = platform() === "win32";
1516
const tscPath = join(
1617
process.cwd(),
@@ -19,6 +20,11 @@ function runTsc() {
1920
isWindows ? "tsc.cmd" : "tsc"
2021
);
2122

23+
if (!existsSync(tscPath)) {
24+
console.error("Error: TypeScript compiler not found at:", tscPath);
25+
process.exit(1);
26+
}
27+
2228
const tsc = spawnSync(tscPath, [], {
2329
stdio: "inherit",
2430
shell: true,
@@ -28,24 +34,48 @@ function runTsc() {
2834
},
2935
});
3036

37+
if (tsc.error) {
38+
console.error("TypeScript compilation error:", tsc.error);
39+
}
40+
if (tsc.stderr) {
41+
console.error("TypeScript stderr:", tsc.stderr.toString());
42+
}
43+
3144
if (tsc.status !== 0) {
3245
console.error("TypeScript compilation failed");
3346
process.exit(tsc.status ?? 1);
3447
}
35-
}
3648

37-
function addShebang() {
38-
const indexPath = join(process.cwd(), "dist", "index.js");
3949
try {
50+
const distPath = join(process.cwd(), "dist");
51+
52+
if (!existsSync(distPath)) {
53+
console.error("Error: dist directory not found after compilation!");
54+
process.exit(1);
55+
}
56+
57+
const indexPath = join(process.cwd(), "dist", "index.js");
58+
console.log("Adding shebang to:", indexPath);
59+
60+
if (!existsSync(indexPath)) {
61+
console.error("Error: index.js not found in dist directory!");
62+
process.exit(1);
63+
}
64+
4065
const content = readFileSync(indexPath, "utf8");
4166
const shebang = "#!/usr/bin/env node\n";
4267

4368
if (!content.startsWith(shebang)) {
4469
writeFileSync(indexPath, shebang + content);
45-
console.log("Added shebang to dist/index.js");
4670
}
4771
} catch (error) {
48-
console.error("Error adding shebang:", error);
72+
console.error("Error in shebang process:", error);
4973
process.exit(1);
5074
}
75+
76+
console.log("Build complete!");
77+
}
78+
79+
if (import.meta.url === new URL(import.meta.url).href) {
80+
buildFramework();
5181
}

0 commit comments

Comments
 (0)