tsdoc/ts/cli.ts

50 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2024-04-03 13:34:26 +02:00
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { logger } from './logging.js';
2019-05-13 19:41:02 +02:00
2024-04-03 13:34:26 +02:00
import { TypeDoc } from './classes.typedoc.js';
import { AiDoc } from './classes.aidoc.js';
2019-05-14 17:39:33 +02:00
2019-05-13 19:41:02 +02:00
export const run = async () => {
const tsdocCli = new plugins.smartcli.Smartcli();
2022-09-16 08:22:57 +02:00
tsdocCli.standardCommand().subscribe(async (argvArg) => {
2019-05-14 08:50:50 +02:00
logger.log('warn', `Auto detecting environment!`);
2019-05-14 17:39:33 +02:00
switch (true) {
case await TypeDoc.isTypeDocDir(paths.cwd):
logger.log('ok', `Detected TypeDoc compliant directory at ${paths.cwd}`);
2022-09-16 08:22:57 +02:00
tsdocCli.triggerCommand('typedoc', argvArg);
2019-05-14 17:39:33 +02:00
break;
default:
logger.log('error', `Cannot determine docs format at ${paths.cwd}`);
}
2019-05-14 08:50:50 +02:00
});
2019-05-13 19:41:02 +02:00
2020-11-24 20:24:30 +00:00
tsdocCli.addCommand('typedoc').subscribe(async (argvArg) => {
const typeDocInstance = new TypeDoc(paths.cwd);
2020-11-27 12:02:57 +00:00
await typeDocInstance.compile({
2021-03-06 19:21:13 +00:00
publicSubdir: argvArg.publicSubdir,
2020-11-27 12:02:57 +00:00
});
2020-11-24 20:24:30 +00:00
});
2024-04-13 16:22:33 +02:00
tsdocCli.addCommand('aidoc').subscribe(async (argvArg) => {
2024-04-14 00:40:57 +02:00
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);
2024-04-12 15:35:09 +02:00
logger.log('info', `Generating new keywords...`);
logger.log('info', `This may take some time...`);
await aidocInstance.buildDescription(paths.cwd);
2024-06-22 13:20:55 +02:00
});
2024-03-31 15:09:30 +02:00
2020-11-24 20:24:30 +00:00
tsdocCli.addCommand('test').subscribe((argvArg) => {
2022-09-16 08:22:57 +02:00
tsdocCli.triggerCommand('typedoc', argvArg);
2019-05-27 16:11:10 +02:00
process.on('exit', async () => {
await plugins.smartfile.fs.remove(paths.publicDir);
});
});
2019-05-14 08:50:50 +02:00
tsdocCli.startParse();
};