From 4fa345d20ee6643c3bb0f455d31caa67e421a362 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 15 May 2019 21:23:45 +0200 Subject: [PATCH] fix(core): update --- package.json | 2 +- ts/tsdoc.classes.mkdocs.ts | 36 +++++++++++++++++++++++++++++------- ts/tsdoc.classes.typedoc.ts | 8 +++++--- ts/tsdoc.cli.ts | 12 +++++++----- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index b4ca59d..17603b8 100644 --- a/package.json +++ b/package.json @@ -34,4 +34,4 @@ "typedoc": "^0.14.2", "typescript": "^3.4.5" } -} +} \ No newline at end of file diff --git a/ts/tsdoc.classes.mkdocs.ts b/ts/tsdoc.classes.mkdocs.ts index db8ba80..f8a63d2 100644 --- a/ts/tsdoc.classes.mkdocs.ts +++ b/ts/tsdoc.classes.mkdocs.ts @@ -14,25 +14,47 @@ export class MkDocs { return result; } + public static async handleCommand(argvArg) { + const mkdocsInstance = new MkDocs(paths.cwd); + switch (true) { + case argvArg.serve: + await mkdocsInstance.serve(); + break; + default: + await mkdocsInstance.compile(); + break; + } + } + // Instance public typedocDirectory: string; constructor(dirPathArg) { - this.typedocDirectory = dirPathArg; + this.typedocDirectory = dirPathArg; } - public async update () { - await this.smartshellInstance.exec(`docker pull registry.gitlab.com/hosttoday/ht-docker-mkdocs`); + public async update() { + await this.smartshellInstance.exec( + `docker pull registry.gitlab.com/hosttoday/ht-docker-mkdocs` + ); } - public async compile () { + public async compile() { await this.update(); await this.smartshellInstance.exec(`rm -rf public/`); - await this.smartshellInstance.exec(`docker run --rm -it -p 8000:8000 -v ${paths.cwd}:/docs registry.gitlab.com/hosttoday/ht-docker-mkdocs build`); + await this.smartshellInstance.exec( + `docker run --rm -it -p 8000:8000 -v ${ + paths.cwd + }:/docs registry.gitlab.com/hosttoday/ht-docker-mkdocs build` + ); await this.smartshellInstance.exec(`gitzone commit`); } - public async serve () { + public async serve() { await this.update(); - await this.smartshellInstance.exec(`docker run --rm -it -p 8000:8000 -v ${paths.cwd}:/docs registry.gitlab.com/hosttoday/ht-docker-mkdocs`); + await this.smartshellInstance.exec( + `docker run --rm -it -p 8000:8000 -v ${ + paths.cwd + }:/docs registry.gitlab.com/hosttoday/ht-docker-mkdocs` + ); } } diff --git a/ts/tsdoc.classes.typedoc.ts b/ts/tsdoc.classes.typedoc.ts index 4f17fdb..533986c 100644 --- a/ts/tsdoc.classes.typedoc.ts +++ b/ts/tsdoc.classes.typedoc.ts @@ -18,10 +18,12 @@ export class TypeDoc { // Instance public typedocDirectory: string; constructor(dirPathArg) { - this.typedocDirectory = dirPathArg; + this.typedocDirectory = dirPathArg; } - public async compile () { - await this.smartshellInstance.exec(`typedoc --module "commonjs" --target "ES2016" --out public/ ts/`); + public async compile() { + await this.smartshellInstance.exec( + `typedoc --module "commonjs" --target "ES2016" --out public/ ts/` + ); } } diff --git a/ts/tsdoc.cli.ts b/ts/tsdoc.cli.ts index 0fd7e0c..5108c12 100644 --- a/ts/tsdoc.cli.ts +++ b/ts/tsdoc.cli.ts @@ -8,10 +8,13 @@ import { MkDocs } from './tsdoc.classes.mkdocs'; export const run = async () => { const tsdocCli = new plugins.smartcli.Smartcli(); tsdocCli.addCommand('typedoc').subscribe(async argvArg => { - + const typeDocInstance = new TypeDoc(paths.cwd); + await typeDocInstance.compile(); }); - tsdocCli.addCommand('mkdocs').subscribe(async argvArg => {}); + tsdocCli.addCommand('mkdocs').subscribe(async argvArg => { + await MkDocs.handleCommand(argvArg); + }); tsdocCli.standardTask().subscribe(async argvArg => { logger.log('warn', `Auto detecting environment!`); @@ -19,11 +22,10 @@ export const run = async () => { case await TypeDoc.isTypeDocDir(paths.cwd): logger.log('ok', `Detected TypeDoc compliant directory at ${paths.cwd}`); tsdocCli.trigger('typedoc'); - const typeDocInstance = new TypeDoc(paths.cwd); - await typeDocInstance.compile(); break; case await MkDocs.isMkDocsDir(paths.cwd): - logger.log('ok', `Detected MkDocs compliant directory at ${paths.cwd}`); + logger.log('ok', `Detected MkDocs compliant directory at ${paths.cwd}`); + tsdocCli.trigger('mkdocs'); break; default: logger.log('error', `Cannot determine docs format at ${paths.cwd}`);