90 lines
2.5 KiB
JavaScript
90 lines
2.5 KiB
JavaScript
// Probe: which Node APIs does the VS Code Electron binary provide in
|
|
// ELECTRON_RUN_AS_NODE mode? Run with:
|
|
// ELECTRON_RUN_AS_NODE=1 "<Code.exe>" probe.cjs
|
|
const out = {};
|
|
|
|
try {
|
|
out.nodeVersion = process.versions.node;
|
|
out.electronVersion = process.versions.electron ?? null;
|
|
out.isElectronRunAsNode = process.env.ELECTRON_RUN_AS_NODE === "1";
|
|
out.execPath = process.execPath;
|
|
out.platform = process.platform;
|
|
} catch (e) {
|
|
out.baseError = String(e);
|
|
}
|
|
|
|
const modules = [
|
|
"node:fs",
|
|
"node:fs/promises",
|
|
"node:path",
|
|
"node:os",
|
|
"node:http",
|
|
"node:readline",
|
|
"node:zlib",
|
|
"node:crypto",
|
|
"node:util",
|
|
"node:net",
|
|
"node:child_process",
|
|
"node:test",
|
|
"node:assert",
|
|
"node:url",
|
|
"node:events",
|
|
];
|
|
out.modules = {};
|
|
for (const m of modules) {
|
|
try {
|
|
require(m);
|
|
out.modules[m] = "ok";
|
|
} catch (e) {
|
|
out.modules[m] = "FAIL: " + (e && e.code ? e.code : String(e));
|
|
}
|
|
}
|
|
|
|
// The APIs the MCP server actually depends on.
|
|
try {
|
|
const { parseLoadedXml } = require("../out/agent/forwardRefs.js");
|
|
const parsed = parseLoadedXml('<AssetDeclaration xmlns="uri:ea.com:eala:asset"><GameObject id="X"/></AssetDeclaration>');
|
|
out.forwardRefs = "ok: elements=" + parsed.parse.elements.length;
|
|
} catch (e) {
|
|
out.forwardRefs = "FAIL: " + String(e).slice(0, 160);
|
|
}
|
|
|
|
try {
|
|
const { startLocalServer } = require("../out/agent/localServer.js");
|
|
out.localServer = typeof startLocalServer === "function" ? "loadable" : "missing";
|
|
} catch (e) {
|
|
out.localServer = "FAIL: " + String(e).slice(0, 160);
|
|
}
|
|
|
|
// Async smoke test: gzip round-trip + http listen (both used at runtime).
|
|
(async () => {
|
|
try {
|
|
const { gzip, gunzip } = require("node:zlib");
|
|
const { promisify } = require("node:util");
|
|
const buf = await promisify(gzip)(Buffer.from("hello"));
|
|
const back = await promisify(gunzip)(buf);
|
|
out.zlibRoundTrip = back.toString() === "hello" ? "ok" : "mismatch";
|
|
} catch (e) {
|
|
out.zlibRoundTrip = "FAIL: " + String(e).slice(0, 120);
|
|
}
|
|
|
|
try {
|
|
const { startLocalServer } = require("../out/agent/localServer.js");
|
|
const handle = await startLocalServer({
|
|
getIndex: () => null,
|
|
listProjects: () => [],
|
|
token: "probe",
|
|
});
|
|
const res = await fetch(`http://127.0.0.1:${handle.port}/status`, {
|
|
headers: { authorization: "Bearer probe" },
|
|
});
|
|
const body = await res.json();
|
|
out.httpServer = "ok: " + JSON.stringify(body);
|
|
await handle.close();
|
|
} catch (e) {
|
|
out.httpServer = "FAIL: " + String(e).slice(0, 160);
|
|
}
|
|
|
|
console.log(JSON.stringify(out, null, 2));
|
|
})();
|