mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-01 12:52:11 +03:00
The wiki has no native generator and drifts each release — it lacked SUPPLY_CHAIN
plus 24 other docs pages, and the cover counts went stale (212+/14/37 vs 226/15/87).
Adds:
- scripts/docs/sync-wiki.mjs — adds docs/ pages missing from the wiki (curated;
internal reports/plans/index excluded) and syncs the four Home.md cover counts.
Matches the hand-curated, non-deterministic wiki page names by a normalized fuzzy
key and writes the EXISTING name, so it never creates duplicate pages. Overwriting
existing-page content is opt-in (--update-existing) and intentionally OFF by
default: several docs sources still carry stale counts (e.g. ARCHITECTURE.md says
"177 providers / 37 MCP tools" while the wiki cover is 226/87), so a blind overwrite
would REGRESS the wiki. Full parity is gated on regenerating those sources — see
docs/ops/DOCUMENTATION_AUDIT_REPORT.md.
- .github/workflows/wiki-sync.yml — runs the sync on every push to main that touches
docs/ (or a count source) + workflow_dispatch, pushing via GITHUB_TOKEN.
- tests/unit/sync-wiki.test.ts — pure-function coverage (8 tests).
The first run already pushed the 25 missing pages to the wiki.
72 lines
3.3 KiB
TypeScript
72 lines
3.3 KiB
TypeScript
// Unit tests for the pure helpers in scripts/docs/sync-wiki.mjs (the GitHub wiki sync).
|
||
import { test } from "node:test";
|
||
import assert from "node:assert/strict";
|
||
|
||
import {
|
||
normKey,
|
||
toWikiName,
|
||
toWikiContent,
|
||
syncHomeCounts,
|
||
parseWikiPage,
|
||
WIKI_BANNER,
|
||
NEW_PAGE_EXCLUDE,
|
||
} from "../../scripts/docs/sync-wiki.mjs";
|
||
|
||
test("normKey: case/separator-insensitive fuzzy key (matches docs basename to curated wiki name)", () => {
|
||
// The wiki names are hand-curated and not deterministic — normKey is what lets us
|
||
// match e.g. FLY_IO_DEPLOYMENT_GUIDE.md to the existing "Fly-io-Deployment-Guide" page.
|
||
assert.equal(normKey("FLY_IO_DEPLOYMENT_GUIDE.md"), normKey("Fly-io-Deployment-Guide"));
|
||
assert.equal(normKey("API_REFERENCE"), normKey("API-Reference"));
|
||
assert.equal(normKey("A2A-SERVER.md"), "a2aserver");
|
||
});
|
||
|
||
test("toWikiName: acronym-aware Title-Case-dashed name for NEW pages", () => {
|
||
assert.equal(toWikiName("SUPPLY_CHAIN.md"), "Supply-Chain");
|
||
assert.equal(toWikiName("API_REFERENCE"), "API-Reference");
|
||
assert.equal(toWikiName("QUOTA_SHARE"), "Quota-Share");
|
||
assert.equal(toWikiName("ACP"), "ACP");
|
||
});
|
||
|
||
test("toWikiContent: strips YAML frontmatter and prepends the language banner", () => {
|
||
const doc = '---\ntitle: "X"\nversion: 3.8.2\n---\n\n# Heading\n\nBody text.\n';
|
||
const out = toWikiContent(doc);
|
||
assert.ok(out.startsWith(WIKI_BANNER), "must start with the wiki language banner");
|
||
assert.ok(!out.includes("version: 3.8.2"), "frontmatter must be removed");
|
||
assert.ok(out.includes("# Heading"), "content body must be preserved");
|
||
assert.ok(out.endsWith("Body text.\n"), "trailing newline normalized");
|
||
});
|
||
|
||
test("toWikiContent: a document without frontmatter is kept intact (plus banner)", () => {
|
||
const doc = "# No Frontmatter\n\nHello.\n";
|
||
const out = toWikiContent(doc);
|
||
assert.equal(out, WIKI_BANNER + "# No Frontmatter\n\nHello.\n");
|
||
});
|
||
|
||
test("syncHomeCounts: rewrites the cover-page provider/strategy counts", () => {
|
||
const home = "Connect every AI tool to 177 providers.\n**177 AI Providers** · **14 Routing Strategies**\n";
|
||
const out = syncHomeCounts(home, { providers: 226, strategies: 15, mcpTools: null, locales: 42 });
|
||
assert.ok(out.includes("226 providers"));
|
||
assert.ok(out.includes("**226 AI Providers**"));
|
||
assert.ok(out.includes("**15 Routing Strategies**"));
|
||
assert.ok(!out.includes("177"));
|
||
});
|
||
|
||
test("syncHomeCounts: leaves text untouched when a count is null (best-effort MCP)", () => {
|
||
const home = "| **MCP Server** | 87 tools |\n";
|
||
const out = syncHomeCounts(home, { providers: null, strategies: null, mcpTools: null, locales: null });
|
||
assert.equal(out, home);
|
||
});
|
||
|
||
test("parseWikiPage: splits the locale prefix (U+2010) from the page name", () => {
|
||
assert.deepEqual(parseWikiPage("Architecture"), { locale: null, name: "Architecture" });
|
||
// U+2010 HYPHEN separator used by the localized mirrors (e.g. "pt-BR‐Architecture").
|
||
assert.deepEqual(parseWikiPage("pt-BR‐Architecture"), { locale: "pt-BR", name: "Architecture" });
|
||
assert.deepEqual(parseWikiPage("phi‐API-Reference"), { locale: "phi", name: "API-Reference" });
|
||
});
|
||
|
||
test("NEW_PAGE_EXCLUDE: internal reports/plans never become public wiki pages", () => {
|
||
assert.ok(NEW_PAGE_EXCLUDE.has("DOCUMENTATION_AUDIT_REPORT"));
|
||
assert.ok(NEW_PAGE_EXCLUDE.has("README"));
|
||
assert.ok(!NEW_PAGE_EXCLUDE.has("SUPPLY_CHAIN"));
|
||
});
|