fix(mcp): publish mongo shell dependency

This commit is contained in:
t8y2
2026-07-18 10:30:02 +08:00
parent 423a0eb95c
commit f801ead4ce
5 changed files with 112 additions and 5 deletions
+4
View File
@@ -10,6 +10,9 @@ const PACKAGE_TAG_PREFIX = "packages-v";
const AGENT_TAG_PREFIX = "agents-v";
const APP_TAG_PREFIX = "v";
const PACKAGE_RELEASE_PATHS = [
"packages/mongo-shell/src/",
"packages/mongo-shell/package.json",
"packages/mongo-shell/tsconfig.json",
"packages/node-core/src/",
"packages/node-core/README.md",
"packages/node-core/package.json",
@@ -255,6 +258,7 @@ function getLatestPackageVersion() {
if (tag) return tag.versionText;
const packageVersions = [
"packages/mongo-shell/package.json",
"packages/node-core/package.json",
"packages/cli/package.json",
"packages/mcp-server/package.json",
+48
View File
@@ -0,0 +1,48 @@
import { mkdtempSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, join, resolve } from "node:path";
import { spawnSync } from "node:child_process";
const packageDirectory = resolve(process.argv[2] ?? "/tmp/dbx-pack-check");
const expectedPackages = [
"@dbx-app/mongo-shell",
"@dbx-app/node-core",
"@dbx-app/cli",
"@dbx-app/mcp-server",
];
const tarballs = readdirSync(packageDirectory)
.filter((file) => file.endsWith(".tgz"))
.map((file) => join(packageDirectory, file))
.sort();
if (tarballs.length !== expectedPackages.length) {
throw new Error(
`Expected ${expectedPackages.length} package tarballs, found ${tarballs.length}: ${tarballs.map(basename).join(", ")}`,
);
}
const installDirectory = mkdtempSync(join(tmpdir(), "dbx-package-install-"));
writeFileSync(
join(installDirectory, "package.json"),
`${JSON.stringify({ name: "dbx-package-install-check", private: true }, null, 2)}\n`,
);
// Installing every release tarball together verifies workspace dependencies are publishable and semver-compatible.
const install = spawnSync(
"npm",
["install", "--ignore-scripts", "--no-audit", "--no-fund", ...tarballs],
{ cwd: installDirectory, stdio: "inherit" },
);
if (install.status !== 0) {
process.exit(install.status ?? 1);
}
for (const packageName of expectedPackages) {
const manifestPath = join(installDirectory, "node_modules", packageName, "package.json");
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
if (manifest.name !== packageName) {
throw new Error(`Installed package mismatch at ${manifestPath}: ${manifest.name}`);
}
}
console.log(`Verified clean installation of ${expectedPackages.join(", ")}.`);