2019-05-14 15:39:33 +00:00
|
|
|
import * as plugins from './tsdoc.plugins';
|
2019-05-15 19:06:07 +00:00
|
|
|
import * as paths from './tsdoc.paths';
|
2019-05-14 15:39:33 +00:00
|
|
|
|
|
|
|
export class MkDocs {
|
2019-05-15 19:06:07 +00:00
|
|
|
public smartshellInstance = new plugins.smartshell.Smartshell({
|
|
|
|
executor: 'bash',
|
|
|
|
pathDirectories: [paths.binDir]
|
|
|
|
});
|
|
|
|
|
2019-05-14 15:39:33 +00:00
|
|
|
public static async isMkDocsDir(dirPathArg: string): Promise<boolean> {
|
|
|
|
const result = await plugins.smartfile.fs.fileExists(
|
|
|
|
plugins.path.join(dirPathArg, 'mkdocs.yml')
|
|
|
|
);
|
2019-05-15 19:06:07 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-05-15 19:23:45 +00:00
|
|
|
public static async handleCommand(argvArg) {
|
|
|
|
const mkdocsInstance = new MkDocs(paths.cwd);
|
|
|
|
switch (true) {
|
|
|
|
case argvArg.serve:
|
|
|
|
await mkdocsInstance.serve();
|
|
|
|
break;
|
2019-05-15 19:25:02 +00:00
|
|
|
case argvArg.publish:
|
|
|
|
await mkdocsInstance.publish();
|
|
|
|
break;
|
2019-05-15 19:23:45 +00:00
|
|
|
default:
|
|
|
|
await mkdocsInstance.compile();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-15 19:06:07 +00:00
|
|
|
// Instance
|
|
|
|
public typedocDirectory: string;
|
|
|
|
constructor(dirPathArg) {
|
2019-05-15 19:23:45 +00:00
|
|
|
this.typedocDirectory = dirPathArg;
|
2019-05-15 19:06:07 +00:00
|
|
|
}
|
|
|
|
|
2019-05-15 19:23:45 +00:00
|
|
|
public async update() {
|
|
|
|
await this.smartshellInstance.exec(
|
|
|
|
`docker pull registry.gitlab.com/hosttoday/ht-docker-mkdocs`
|
|
|
|
);
|
2019-05-15 19:10:19 +00:00
|
|
|
}
|
|
|
|
|
2019-05-15 19:23:45 +00:00
|
|
|
public async compile() {
|
2019-05-15 19:10:19 +00:00
|
|
|
await this.update();
|
2019-05-15 19:06:07 +00:00
|
|
|
await this.smartshellInstance.exec(`rm -rf public/`);
|
2019-05-15 19:23:45 +00:00
|
|
|
await this.smartshellInstance.exec(
|
|
|
|
`docker run --rm -it -p 8000:8000 -v ${
|
|
|
|
paths.cwd
|
|
|
|
}:/docs registry.gitlab.com/hosttoday/ht-docker-mkdocs build`
|
|
|
|
);
|
2019-05-15 19:06:07 +00:00
|
|
|
await this.smartshellInstance.exec(`gitzone commit`);
|
|
|
|
}
|
|
|
|
|
2019-05-15 19:23:45 +00:00
|
|
|
public async serve() {
|
2019-05-15 19:10:19 +00:00
|
|
|
await this.update();
|
2019-05-15 19:23:45 +00:00
|
|
|
await this.smartshellInstance.exec(
|
|
|
|
`docker run --rm -it -p 8000:8000 -v ${
|
|
|
|
paths.cwd
|
|
|
|
}:/docs registry.gitlab.com/hosttoday/ht-docker-mkdocs`
|
|
|
|
);
|
2019-05-14 15:39:33 +00:00
|
|
|
}
|
2019-05-15 19:25:02 +00:00
|
|
|
|
|
|
|
public async publish() {
|
|
|
|
await this.compile();
|
|
|
|
await this.smartshellInstance.exec(`gitzone commit`);
|
|
|
|
}
|
2019-05-14 15:39:33 +00:00
|
|
|
}
|