diff --git a/.gitignore b/.gitignore index 042b5b0..91c0db0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,13 +8,15 @@ pages/ # installs node_modules/ -# caches and builds +# caches .yarn/ .cache/ +.rpt2_cache + +# builds dist/ dist_web/ dist_serve/ dist_ts_web/ -# custom -mkdocs/originalrepo +# custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5d8296b..8321aed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -109,7 +109,7 @@ pages: image: hosttoday/ht-docker-node:npmci stage: metadata script: - - npmci command npm install -g typedoc typescript @gitzone/tsdoc + - npmci command npm install -g typedoc typescript - npmci npm prepare - npmci npm install - npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ diff --git a/npmextra.json b/npmextra.json index ebc741f..86f805b 100644 --- a/npmextra.json +++ b/npmextra.json @@ -14,4 +14,4 @@ "npmGlobalTools": [], "npmAccessLevel": "public" } -} +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c07d438..8949aeb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -271,7 +271,6 @@ "version": "2.0.13", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartshell/-/smartshell-2.0.13.tgz", "integrity": "sha512-jLfAhLxMVKAScKdln1QrQqBI7A7INhMNHIq28fJEBi0BNDUS0eerw4yMAnR4CRmcrh4xFp1z+ju1kaPO3I/4MA==", - "dev": true, "requires": { "@pushrocks/smartpromise": "^2.0.5", "@types/which": "^1.3.1", @@ -281,8 +280,7 @@ "@pushrocks/smartpromise": { "version": "2.0.5", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz", - "integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g==", - "dev": true + "integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g==" } } }, @@ -439,8 +437,7 @@ "@types/which": { "version": "1.3.1", "resolved": "https://verdaccio.lossless.one/@types%2fwhich/-/which-1.3.1.tgz", - "integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ==", - "dev": true + "integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ==" }, "@types/yargs": { "version": "12.0.12", @@ -1613,8 +1610,7 @@ "typescript": { "version": "3.4.5", "resolved": "https://verdaccio.lossless.one/typescript/-/typescript-3.4.5.tgz", - "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==", - "dev": true + "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==" }, "uglify-js": { "version": "3.5.11", diff --git a/package.json b/package.json index 6f31059..309d5a3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "tsdoc": "cli.js" }, "scripts": { - "test": "(tstest test/) && node ./cli.ts.js", + "test": "(tstest test/) && (node ./cli.ts.js) && rm -rf public/", "build": "(tsbuild)", "buildMkdocs": "(cd mkdocs/originalrepo && docker rmi -f mkdocs && docker build -t mkdocs .)", "format": "(gitzone format)" @@ -30,6 +30,8 @@ "@pushrocks/smartfile": "^7.0.2", "@pushrocks/smartlog": "^2.0.19", "@pushrocks/smartlog-destination-local": "^7.0.5", - "typedoc": "^0.14.2" + "@pushrocks/smartshell": "^2.0.13", + "typedoc": "^0.14.2", + "typescript": "^3.4.5" } } diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..45e1daa --- /dev/null +++ b/readme.md @@ -0,0 +1,26 @@ +# @gitzone/tsdoc +a tool for better documentation + +## Availabililty and Links +* [npmjs.org (npm package)](https://www.npmjs.com/package/@gitzone/tsdoc) +* [gitlab.com (source)](https://gitlab.com/gitzone/tsdoc) +* [github.com (source mirror)](https://github.com/gitzone/tsdoc) +* [docs (typedoc)](https://gitzone.gitlab.io/tsdoc/) + +## Status for master +[![build status](https://gitlab.com/gitzone/tsdoc/badges/master/build.svg)](https://gitlab.com/gitzone/tsdoc/commits/master) +[![coverage report](https://gitlab.com/gitzone/tsdoc/badges/master/coverage.svg)](https://gitlab.com/gitzone/tsdoc/commits/master) +[![npm downloads per month](https://img.shields.io/npm/dm/@gitzone/tsdoc.svg)](https://www.npmjs.com/package/@gitzone/tsdoc) +[![Known Vulnerabilities](https://snyk.io/test/npm/@gitzone/tsdoc/badge.svg)](https://snyk.io/test/npm/@gitzone/tsdoc) +[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) + +## Usage + +For further information read the linked docs at the top of this readme. + +> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) +| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) + +[![repo-footer](https://gitzone.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com) diff --git a/ts/tsdoc.classes.mkdocs.ts b/ts/tsdoc.classes.mkdocs.ts index e69de29..81cbade 100644 --- a/ts/tsdoc.classes.mkdocs.ts +++ b/ts/tsdoc.classes.mkdocs.ts @@ -0,0 +1,10 @@ +import * as plugins from './tsdoc.plugins'; + +export class MkDocs { + public static async isMkDocsDir(dirPathArg: string): Promise { + const result = await plugins.smartfile.fs.fileExists( + plugins.path.join(dirPathArg, 'mkdocs.yml') + ); + return !result; + } +} diff --git a/ts/tsdoc.classes.typedoc.ts b/ts/tsdoc.classes.typedoc.ts index 56c7665..4f17fdb 100644 --- a/ts/tsdoc.classes.typedoc.ts +++ b/ts/tsdoc.classes.typedoc.ts @@ -1,2 +1,27 @@ import * as plugins from './tsdoc.plugins'; +import * as paths from './tsdoc.paths'; +export class TypeDoc { + public smartshellInstance = new plugins.smartshell.Smartshell({ + executor: 'bash', + pathDirectories: [paths.binDir] + }); + + // Static + public static async isTypeDocDir(dirPathArg: string): Promise { + const result = await plugins.smartfile.fs.fileExists( + plugins.path.join(dirPathArg, 'mkdocs.yml') + ); + return !result; + } + + // Instance + public typedocDirectory: string; + constructor(dirPathArg) { + this.typedocDirectory = dirPathArg; + } + + 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 5fbbf6c..0fd7e0c 100644 --- a/ts/tsdoc.cli.ts +++ b/ts/tsdoc.cli.ts @@ -1,14 +1,33 @@ import * as plugins from './tsdoc.plugins'; +import * as paths from './tsdoc.paths'; import { logger } from './tsdoc.logging'; +import { TypeDoc } from './tsdoc.classes.typedoc'; +import { MkDocs } from './tsdoc.classes.mkdocs'; + export const run = async () => { const tsdocCli = new plugins.smartcli.Smartcli(); - tsdocCli.addCommand('typedoc').subscribe(async argvArg => {}); + tsdocCli.addCommand('typedoc').subscribe(async argvArg => { + + }); tsdocCli.addCommand('mkdocs').subscribe(async argvArg => {}); tsdocCli.standardTask().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.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}`); + break; + default: + logger.log('error', `Cannot determine docs format at ${paths.cwd}`); + } }); tsdocCli.startParse(); diff --git a/ts/tsdoc.paths.ts b/ts/tsdoc.paths.ts new file mode 100644 index 0000000..3a14a6d --- /dev/null +++ b/ts/tsdoc.paths.ts @@ -0,0 +1,5 @@ +import * as plugins from './tsdoc.plugins'; + +export const packageDir = plugins.path.join(__dirname, '../'); +export const cwd = process.cwd(); +export const binDir = plugins.path.join(packageDir, './node_modules/.bin'); diff --git a/ts/tsdoc.plugins.ts b/ts/tsdoc.plugins.ts index 4fb304a..c94e398 100644 --- a/ts/tsdoc.plugins.ts +++ b/ts/tsdoc.plugins.ts @@ -1,17 +1,18 @@ +// node native +import * as path from 'path'; + +export { path }; + // pushrocks scope import * as smartcli from '@pushrocks/smartcli'; +import * as smartfile from '@pushrocks/smartfile'; import * as smartlog from '@pushrocks/smartlog'; import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local'; +import * as smartshell from '@pushrocks/smartshell'; -export { - smartcli, - smartlog, - smartlogDestinationLocal -}; +export { smartcli, smartfile, smartlog, smartlogDestinationLocal, smartshell }; // third party scope import * as typedoc from 'typedoc'; -export { - typedoc -}; +export { typedoc };