Copies source (no node_modules, dist, .tasks, .wiki, __pycache__) for: - projects-meta-mcp v2.25.0 (TypeScript/Node) - wiki-graph v0.3.1 (TypeScript/Node) - interns-mcp v0.3.3 (Python/FastMCP) .gitignore: exclude lib build artefacts (node_modules, dist, .venv, __pycache__, *.pyc) bootstrap.ps1: add MCP build step — npm install+build for TS servers, venv+pip for Python Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import { mkdtemp, mkdir, writeFile } from 'node:fs/promises';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { loadWiki } from '../../src/lib/wiki-index.js';
|
|
|
|
let root: string;
|
|
|
|
beforeEach(async () => {
|
|
root = await mkdtemp(join(tmpdir(), 'wiki-'));
|
|
await mkdir(join(root, 'node'), { recursive: true });
|
|
await mkdir(join(root, 'cross'), { recursive: true });
|
|
|
|
await writeFile(join(root, 'CLAUDE.md'), 'should be skipped');
|
|
await writeFile(join(root, 'README.md'), 'should be skipped');
|
|
|
|
await writeFile(
|
|
join(root, 'node', 'windows-yarn-exec.md'),
|
|
[
|
|
'---',
|
|
'title: Windows yarn requires exec()',
|
|
'domain: node',
|
|
'tags: [windows, yarn]',
|
|
'---',
|
|
'',
|
|
'## Why',
|
|
'Windows is special.',
|
|
].join('\n'),
|
|
);
|
|
|
|
await writeFile(
|
|
join(root, 'cross', 'git-tips.md'),
|
|
['---', 'title: Git tips', 'domain: cross', 'tags: [git]', '---', '', 'body'].join('\n'),
|
|
);
|
|
|
|
await writeFile(
|
|
join(root, 'cross', 'no-fm.md'),
|
|
'just a body, no frontmatter',
|
|
);
|
|
});
|
|
|
|
describe('loadWiki', () => {
|
|
it('skips top-level meta files', async () => {
|
|
const pages = await loadWiki(root);
|
|
expect(pages.find((p) => p.slug === 'CLAUDE')).toBeUndefined();
|
|
expect(pages.find((p) => p.slug === 'README')).toBeUndefined();
|
|
});
|
|
|
|
it('loads pages with frontmatter', async () => {
|
|
const pages = await loadWiki(root);
|
|
const yarn = pages.find((p) => p.slug === 'node/windows-yarn-exec');
|
|
expect(yarn).toBeDefined();
|
|
expect(yarn!.title).toBe('Windows yarn requires exec()');
|
|
expect(yarn!.domain).toBe('node');
|
|
expect(yarn!.tags).toEqual(['windows', 'yarn']);
|
|
expect(yarn!.body).toContain('Windows is special.');
|
|
});
|
|
|
|
it('marks frontmatterless pages as unknown domain', async () => {
|
|
const pages = await loadWiki(root);
|
|
const fm = pages.find((p) => p.slug === 'cross/no-fm');
|
|
expect(fm).toBeDefined();
|
|
expect(fm!.domain).toBe('unknown');
|
|
});
|
|
|
|
it('returns empty array if root missing', async () => {
|
|
const pages = await loadWiki(join(root, 'does-not-exist'));
|
|
expect(pages).toEqual([]);
|
|
});
|
|
});
|