81 lines
2.7 KiB
TypeScript
81 lines
2.7 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('readme').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);
|
|
});
|
|
|
|
tsdocCli.addCommand('description').subscribe(async (argvArg) => {
|
|
const aidocInstance = new AiDoc();
|
|
await aidocInstance.start();
|
|
|
|
logger.log('info', `Generating new description and keywords...`);
|
|
logger.log('info', `This may take some time...`);
|
|
await aidocInstance.buildDescription(paths.cwd);
|
|
});
|
|
|
|
tsdocCli.addCommand('commit').subscribe(async (argvArg) => {
|
|
const aidocInstance = new AiDoc();
|
|
await aidocInstance.start();
|
|
|
|
logger.log('info', `Generating commit message...`);
|
|
logger.log('info', `This may take some time...`);
|
|
const commitObject = await aidocInstance.buildNextCommitObject(paths.cwd);
|
|
|
|
logger.log('ok', `Commit message generated:`);
|
|
console.log(JSON.stringify(commitObject, null, 2));
|
|
});
|
|
|
|
tsdocCli.addCommand('test').subscribe((argvArg) => {
|
|
tsdocCli.triggerCommand('typedoc', argvArg);
|
|
process.on('exit', async () => {
|
|
await plugins.fsInstance.directory(paths.publicDir).recursive().delete();
|
|
});
|
|
});
|
|
|
|
tsdocCli.startParse();
|
|
};
|