GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cli/tools/generate-knowledge-reference.test.ts at main · modelstudioai/cli

Expand file tree

/

generate-knowledge-reference.test.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
50 lines (49 loc) · 2.25 KB
/

generate-knowledge-reference.test.ts

Copy path

File metadata and controls

50 lines (49 loc) · 2.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, expect, test } from "vite-plus/test";
import { commands as blCommands } from "../packages/cli/src/commands.ts";
import { commands as kscliCommands } from "../packages/kscli/src/commands.ts";
import {
knowledgeReferenceSchemas,
writeKnowledgeReferences,
} from "./generate-knowledge-reference.ts";
const directories: string[] = [];
afterEach(async () => {
await Promise.all(
directories.splice(0).map((directory) => rm(directory, { recursive: true, force: true })),
);
});
test("generation selects the actual knowledge scope and retains all kscli utility commands", () => {
const schemas = knowledgeReferenceSchemas();
expect(schemas.bl.scope).toEqual(["knowledge"]);
expect(schemas.bl.commands.map((command) => command.path.join(" "))).toEqual(
Object.keys(blCommands)
.filter((path) => path.startsWith("knowledge "))
.sort(),
);
expect(schemas.kscli.commands.map((command) => command.path.join(" "))).toEqual(
Object.keys(kscliCommands).sort(),
);
expect(schemas.kscli.commands.some((command) => command.path[0] === "config")).toBe(true);
expect(
schemas.bl.commands.find((command) => command.path.join(" ") === "knowledge init")?.preparation,
).toBe("read-only");
});
test("writes exactly three stable reference artifacts and preserves non-generated files", async () => {
const directory = await mkdtemp(join(tmpdir(), "knowledge-reference-"));
directories.push(directory);
writeKnowledgeReferences(directory);
const names = (await readdir(directory)).sort();
expect(names).toEqual(["index.md", "knowledge.md", "kscli.md"]);
const first = await Promise.all(names.map((name) => readFile(join(directory, name), "utf8")));
await writeFile(join(directory, "asset.txt"), "preserve");
writeKnowledgeReferences(directory);
expect(await readFile(join(directory, "asset.txt"), "utf8")).toBe("preserve");
expect(await Promise.all(names.map((name) => readFile(join(directory, name), "utf8")))).toEqual(
first,
);
expect(first[1]).toContain("bl knowledge init");
expect(first[2]).toContain("kscli init");
expect(first[2]).toContain("product utility commands");
});
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.