fix(core): update

This commit is contained in:
Philipp Kunz 2019-05-15 21:23:45 +02:00
parent b8678cd808
commit 4fa345d20e
4 changed files with 42 additions and 16 deletions

View File

@ -14,6 +14,18 @@ export class MkDocs {
return result; 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 // Instance
public typedocDirectory: string; public typedocDirectory: string;
constructor(dirPathArg) { constructor(dirPathArg) {
@ -21,18 +33,28 @@ export class MkDocs {
} }
public async update() { public async update() {
await this.smartshellInstance.exec(`docker pull registry.gitlab.com/hosttoday/ht-docker-mkdocs`); await this.smartshellInstance.exec(
`docker pull registry.gitlab.com/hosttoday/ht-docker-mkdocs`
);
} }
public async compile() { public async compile() {
await this.update(); await this.update();
await this.smartshellInstance.exec(`rm -rf public/`); 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`); await this.smartshellInstance.exec(`gitzone commit`);
} }
public async serve() { public async serve() {
await this.update(); 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`
);
} }
} }

View File

@ -22,6 +22,8 @@ export class TypeDoc {
} }
public async compile() { public async compile() {
await this.smartshellInstance.exec(`typedoc --module "commonjs" --target "ES2016" --out public/ ts/`); await this.smartshellInstance.exec(
`typedoc --module "commonjs" --target "ES2016" --out public/ ts/`
);
} }
} }

View File

@ -8,10 +8,13 @@ import { MkDocs } from './tsdoc.classes.mkdocs';
export const run = async () => { export const run = async () => {
const tsdocCli = new plugins.smartcli.Smartcli(); const tsdocCli = new plugins.smartcli.Smartcli();
tsdocCli.addCommand('typedoc').subscribe(async argvArg => { 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 => { tsdocCli.standardTask().subscribe(async argvArg => {
logger.log('warn', `Auto detecting environment!`); logger.log('warn', `Auto detecting environment!`);
@ -19,11 +22,10 @@ export const run = async () => {
case await TypeDoc.isTypeDocDir(paths.cwd): case await TypeDoc.isTypeDocDir(paths.cwd):
logger.log('ok', `Detected TypeDoc compliant directory at ${paths.cwd}`); logger.log('ok', `Detected TypeDoc compliant directory at ${paths.cwd}`);
tsdocCli.trigger('typedoc'); tsdocCli.trigger('typedoc');
const typeDocInstance = new TypeDoc(paths.cwd);
await typeDocInstance.compile();
break; break;
case await MkDocs.isMkDocsDir(paths.cwd): 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; break;
default: default:
logger.log('error', `Cannot determine docs format at ${paths.cwd}`); logger.log('error', `Cannot determine docs format at ${paths.cwd}`);