16b861d8cc
- Fixed maxTokens extraction in zenmuxModelManagerOptions using max_completion_tokens - Sort providers alphabetically in generated models.json output
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
#!/usr/bin/env bun
|
|
|
|
import * as path from "node:path";
|
|
import { Glob } from "bun";
|
|
|
|
const docsDir = path.resolve(import.meta.dir, "../../../docs");
|
|
const outputPath = path.resolve(import.meta.dir, "../src/internal-urls/docs-index.generated.ts");
|
|
|
|
const glob = new Glob("**/*.md");
|
|
const entries: string[] = [];
|
|
for await (const relativePath of glob.scan(docsDir)) {
|
|
entries.push(relativePath.split(path.sep).join("/"));
|
|
}
|
|
entries.sort();
|
|
|
|
const docsWithContent = await Promise.all(
|
|
entries.map(async relativePath => ({
|
|
relativePath,
|
|
content: await Bun.file(path.join(docsDir, relativePath)).text(),
|
|
})),
|
|
);
|
|
|
|
const filenamesLiteral = JSON.stringify(entries);
|
|
|
|
const mapEntries = docsWithContent
|
|
.map(({ relativePath, content }) => `\t${JSON.stringify(relativePath)}: ${JSON.stringify(content)},`)
|
|
.join("\n");
|
|
const output = [
|
|
"// Auto-generated by scripts/generate-docs-index.ts - DO NOT EDIT",
|
|
"",
|
|
`export const EMBEDDED_DOC_FILENAMES: readonly string[] = ${filenamesLiteral};`,
|
|
"",
|
|
`export const EMBEDDED_DOCS: Readonly<Record<string, string>> = {`,
|
|
`${mapEntries}`,
|
|
`};`,
|
|
"",
|
|
].join("\n");
|
|
|
|
await Bun.write(outputPath, output);
|
|
console.log(`Generated ${path.relative(process.cwd(), outputPath)} (${entries.length} docs)`);
|