tsdoc/ts/cli.ts

50 lines
1.6 KiB
TypeScript

import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { logger } from './logging.js';
import { TypeDoc } from './classes.typedoc.js';
import { AiDoc } from './classes.aidoc.js';
export const run = async () => {
const tsdocCli = new plugins.smartcli.Smartcli();
tsdocCli.standardCommand().subscribe(async (argvArg) => {
logger.log('warn', `Auto detecting environment!`);
switch (true) {
case await TypeDoc.isTypeDocDir(paths.cwd):
logger.log('ok', `Detected TypeDoc compliant directory at ${paths.cwd}`);
tsdocCli.triggerCommand('typedoc', argvArg);
break;
default:
logger.log('error', `Cannot determine docs format at ${paths.cwd}`);
}
});
tsdocCli.addCommand('typedoc').subscribe(async (argvArg) => {
const typeDocInstance = new TypeDoc(paths.cwd);
await typeDocInstance.compile({
publicSubdir: argvArg.publicSubdir,
});
});
tsdocCli.addCommand('aidoc').subscribe(async (argvArg) => {
const aidocInstance = new AiDoc();
await aidocInstance.start();
logger.log('info', `Generating new readme...`);
logger.log('info', `This may take some time...`);
await aidocInstance.buildReadme(paths.cwd);
logger.log('info', `Generating new keywords...`);
logger.log('info', `This may take some time...`);
await aidocInstance.buildDescription(paths.cwd);
});
tsdocCli.addCommand('test').subscribe((argvArg) => {
tsdocCli.triggerCommand('typedoc', argvArg);
process.on('exit', async () => {
await plugins.smartfile.fs.remove(paths.publicDir);
});
});
tsdocCli.startParse();
};