docs(cli): describe every command input
This commit is contained in:
@@ -57,6 +57,7 @@ export function cliCommandOptionNames(
|
||||
cli: unknown,
|
||||
name: string,
|
||||
): readonly string[];
|
||||
export function cliCommandDescriptionIssues(cli: unknown): readonly string[];
|
||||
export function serializeProductCatalog(
|
||||
catalog: ProductCatalog,
|
||||
): Promise<string>;
|
||||
|
||||
@@ -79,6 +79,31 @@ export const cliCommandOptionNames = (cli, name) => {
|
||||
);
|
||||
};
|
||||
|
||||
/** Report primary CLI fields whose generated JSON Schema lacks help text. */
|
||||
export const cliCommandDescriptionIssues = (cli) => {
|
||||
const commands = Cli.toCommands.get(cli);
|
||||
if (commands === undefined)
|
||||
throw new Error("Incur did not expose the registered REA CLI commands");
|
||||
const missing = [];
|
||||
for (const [commandName, command] of commands) {
|
||||
if ("_alias" in command) continue;
|
||||
for (const groupName of ["args", "options"]) {
|
||||
if (!(groupName in command) || command[groupName] === undefined) continue;
|
||||
const properties = z.toJSONSchema(command[groupName]).properties ?? {};
|
||||
for (const [propertyName, property] of Object.entries(properties)) {
|
||||
if (
|
||||
typeof property !== "object" ||
|
||||
property === null ||
|
||||
typeof property.description !== "string" ||
|
||||
property.description.trim() === ""
|
||||
)
|
||||
missing.push(`${commandName}.${groupName}.${propertyName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return missing;
|
||||
};
|
||||
|
||||
const assertSameNames = (label, actual, expected) => {
|
||||
const actualSet = new Set(actual);
|
||||
const expectedSet = new Set(expected);
|
||||
|
||||
Reference in New Issue
Block a user