-
-
Notifications
You must be signed in to change notification settings - Fork 280
/
index.ts
25 lines (22 loc) · 1.01 KB
/
index.ts
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
import fs from "node:fs";
import path from "node:path";
import {cmds} from "../src/cmds/index.js";
import {globalOptions} from "../src/options/index.js";
import {renderCommandPage} from "./markdown.js";
// Script to generate a reference of all CLI commands and options
// Outputs a markdown format ready to be consumed
//
// Usage:
// ts-node packages/cli/docsgen
//
// After generation the resulting .md files, they are written to the path expected
// by the docusaurus index and other existing paths in the documentation
const dirname = path.dirname(new URL(import.meta.url).pathname);
const LODESTAR_COMMAND = "./lodestar";
const DOCS_PAGES_FOLDER = path.join(dirname, "..", "..", "..", "docs", "pages");
for (const cmd of cmds) {
const docstring = renderCommandPage(cmd, globalOptions, LODESTAR_COMMAND);
const folder = path.join(DOCS_PAGES_FOLDER, cmd.docsFolder ?? "");
if (!fs.existsSync(folder)) fs.mkdirSync(folder, {recursive: true});
fs.writeFileSync(path.join(folder, `${cmd.command}-cli.md`), docstring);
}