fix: skip bundled mcp source builds in codex package
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
"@oh-my-opencode/shared-skills": "file:../../shared-skills"
|
"@oh-my-opencode/shared-skills": "file:../../shared-skills"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "bun run --cwd ../../lsp-tools-mcp build && bun run --cwd ../../ast-grep-mcp build && node scripts/sync-skills.mjs && node ../scripts/sync-telemetry-component.mjs && node scripts/build-components.mjs",
|
"build": "node scripts/build-bundled-mcp-runtimes.mjs && node scripts/sync-skills.mjs && node ../scripts/sync-telemetry-component.mjs && node scripts/build-components.mjs",
|
||||||
"check": "npm run build && npm test",
|
"check": "npm run build && npm test",
|
||||||
"sync:skills": "node scripts/sync-skills.mjs",
|
"sync:skills": "node scripts/sync-skills.mjs",
|
||||||
"test": "node --test test/*.test.mjs"
|
"test": "node --test test/*.test.mjs"
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import { spawnSync } from "node:child_process";
|
||||||
|
import { existsSync } from "node:fs";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const pluginRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
||||||
|
const repoPackagesRoot = join(pluginRoot, "..", "..");
|
||||||
|
|
||||||
|
const runtimes = [
|
||||||
|
{
|
||||||
|
label: "lsp-tools-mcp",
|
||||||
|
packageRoot: join(repoPackagesRoot, "lsp-tools-mcp"),
|
||||||
|
requiredOutputs: ["dist/cli.js", "dist/tools.js"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "ast-grep-mcp",
|
||||||
|
packageRoot: join(repoPackagesRoot, "ast-grep-mcp"),
|
||||||
|
requiredOutputs: ["dist/cli.js"],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const runtime of runtimes) {
|
||||||
|
buildRuntime(runtime);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRuntime(runtime) {
|
||||||
|
if (!existsSync(join(runtime.packageRoot, "package.json"))) {
|
||||||
|
assertBundledDist(runtime);
|
||||||
|
console.log(`Using bundled ${runtime.label} dist`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = spawnSync("bun", ["run", "build"], {
|
||||||
|
cwd: runtime.packageRoot,
|
||||||
|
stdio: "inherit",
|
||||||
|
});
|
||||||
|
if (result.error !== undefined) throw result.error;
|
||||||
|
if (result.status !== 0) process.exit(result.status ?? 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertBundledDist(runtime) {
|
||||||
|
const missingOutputs = runtime.requiredOutputs.filter((output) => !existsSync(join(runtime.packageRoot, output)));
|
||||||
|
if (missingOutputs.length === 0) return;
|
||||||
|
console.error(`Missing bundled ${runtime.label} outputs:`);
|
||||||
|
for (const output of missingOutputs) {
|
||||||
|
console.error(` ${join(runtime.packageRoot, output)}`);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
@@ -173,6 +173,7 @@ test("#given aggregate MCP config #when inspected #then code MCPs reference pack
|
|||||||
const packageJson = await readJson("package.json");
|
const packageJson = await readJson("package.json");
|
||||||
const mcp = await readJson(".mcp.json");
|
const mcp = await readJson(".mcp.json");
|
||||||
const lspSources = await readdir(join(root, "components", "lsp", "src"));
|
const lspSources = await readdir(join(root, "components", "lsp", "src"));
|
||||||
|
const bundledMcpBuildScript = await readFile(join(root, "scripts", "build-bundled-mcp-runtimes.mjs"), "utf8");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
const lspServer = mcp.mcpServers.lsp;
|
const lspServer = mcp.mcpServers.lsp;
|
||||||
@@ -187,7 +188,7 @@ test("#given aggregate MCP config #when inspected #then code MCPs reference pack
|
|||||||
assert.equal(packageJson.workspaces.includes("components/lsp/packages/lsp-tools-mcp"), false);
|
assert.equal(packageJson.workspaces.includes("components/lsp/packages/lsp-tools-mcp"), false);
|
||||||
assert.equal(packageJson.workspaces.includes("components/ast-grep/packages/ast-grep-mcp"), false);
|
assert.equal(packageJson.workspaces.includes("components/ast-grep/packages/ast-grep-mcp"), false);
|
||||||
assert.deepEqual(packageJson.dependencies, { "@oh-my-opencode/shared-skills": "file:../../shared-skills" });
|
assert.deepEqual(packageJson.dependencies, { "@oh-my-opencode/shared-skills": "file:../../shared-skills" });
|
||||||
assert.match(packageJson.scripts.build, /ast-grep-mcp/);
|
assert.match(bundledMcpBuildScript, /ast-grep-mcp/);
|
||||||
assert.doesNotMatch(packageJson.scripts.build, /--workspaces/);
|
assert.doesNotMatch(packageJson.scripts.build, /--workspaces/);
|
||||||
assert.equal(lspServer.command, "node");
|
assert.equal(lspServer.command, "node");
|
||||||
assert.deepEqual(lspServer.args, ["../../lsp-tools-mcp/dist/cli.js", "mcp"]);
|
assert.deepEqual(lspServer.args, ["../../lsp-tools-mcp/dist/cli.js", "mcp"]);
|
||||||
@@ -224,7 +225,7 @@ test("#given aggregate plugin build script #when inspected #then telemetry sync
|
|||||||
// then
|
// then
|
||||||
assert.equal(
|
assert.equal(
|
||||||
buildScript,
|
buildScript,
|
||||||
"bun run --cwd ../../lsp-tools-mcp build && bun run --cwd ../../ast-grep-mcp build && node scripts/sync-skills.mjs && node ../scripts/sync-telemetry-component.mjs && node scripts/build-components.mjs",
|
"node scripts/build-bundled-mcp-runtimes.mjs && node scripts/sync-skills.mjs && node ../scripts/sync-telemetry-component.mjs && node scripts/build-components.mjs",
|
||||||
);
|
);
|
||||||
assert.match(telemetrySyncScript, /syncTelemetryComponent/);
|
assert.match(telemetrySyncScript, /syncTelemetryComponent/);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user