|
| 1 | +import { readFile } from "node:fs/promises"; |
| 2 | +import { describe, expect, it } from "vitest"; |
| 3 | + |
| 4 | +const EXPECTED_TOOL_COUNT = 21; |
| 5 | + |
| 6 | +type PackageMetadata = { |
| 7 | + name: string; |
| 8 | + version: string; |
| 9 | + mcpName: string; |
| 10 | +}; |
| 11 | + |
| 12 | +type ServerMetadata = { |
| 13 | + name: string; |
| 14 | + version: string; |
| 15 | + packages: Array<{ |
| 16 | + identifier: string; |
| 17 | + version: string; |
| 18 | + }>; |
| 19 | +}; |
| 20 | + |
| 21 | +async function readText(relativePath: string): Promise<string> { |
| 22 | + return readFile(new URL(`../${relativePath}`, import.meta.url), "utf-8"); |
| 23 | +} |
| 24 | + |
| 25 | +async function readJson<T>(relativePath: string): Promise<T> { |
| 26 | + return JSON.parse(await readText(relativePath)) as T; |
| 27 | +} |
| 28 | + |
| 29 | +function codeCommanderFamilyRow(readme: string): string { |
| 30 | + const row = readme |
| 31 | + .split(/\r?\n/) |
| 32 | + .find((line) => line.includes("ellmos-codecommander-mcp") && line.includes("CodeCommander") && line.includes("|")); |
| 33 | + |
| 34 | + expect(row, "CodeCommander family row").toBeDefined(); |
| 35 | + return row ?? ""; |
| 36 | +} |
| 37 | + |
| 38 | +describe("project metadata", () => { |
| 39 | + it("keeps package and MCP Registry metadata versions aligned", async () => { |
| 40 | + const pkg = await readJson<PackageMetadata>("package.json"); |
| 41 | + const server = await readJson<ServerMetadata>("server.json"); |
| 42 | + |
| 43 | + expect(server.name).toBe(pkg.mcpName); |
| 44 | + expect(server.version).toBe(pkg.version); |
| 45 | + expect(server.packages[0]?.identifier).toBe(pkg.name); |
| 46 | + expect(server.packages[0]?.version).toBe(pkg.version); |
| 47 | + }); |
| 48 | + |
| 49 | + it("keeps README family tool counts aligned with the current tool surface", async () => { |
| 50 | + for (const fileName of ["README.md", "README_de.md"]) { |
| 51 | + const row = codeCommanderFamilyRow(await readText(fileName)); |
| 52 | + |
| 53 | + expect(row).toContain(`**${EXPECTED_TOOL_COUNT}**`); |
| 54 | + expect(row).not.toContain("**17**"); |
| 55 | + } |
| 56 | + }); |
| 57 | +}); |
0 commit comments