From 9fb93c5f30cd4bbffefc877ae288934dab3723a1 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Wed, 28 Jun 2017 11:22:38 +0100 Subject: [PATCH] regeneration TOC and add automatic list component generator (#2022) --- ng2-components/README.md | 143 ++++++++++++------ .../custom-loaders/generateListComponent.js | 123 +++++++++++++++ ng2-components/config/webpack.common.js | 3 +- ng2-components/config/webpack.doc.js | 17 +++ ng2-components/ng2-activiti-form/README.md | 1 + .../ng2-activiti-tasklist/README.md | 3 + ng2-components/ng2-alfresco-core/README.md | 1 + ng2-components/package-base.json | 3 +- ng2-components/package.json | 3 +- 9 files changed, 248 insertions(+), 49 deletions(-) create mode 100644 ng2-components/config/custom-loaders/generateListComponent.js create mode 100644 ng2-components/config/webpack.doc.js diff --git a/ng2-components/README.md b/ng2-components/README.md index fbe2fee0f3..b1b15a1c66 100644 --- a/ng2-components/README.md +++ b/ng2-components/README.md @@ -1,63 +1,114 @@ # Alfresco Angular Components -## Base components + -- [Core library](ng2-alfresco-core/README.md) -- [alfresco-viewer](ng2-alfresco-viewer/README.md) + + +- [Core](#core) + * [Components](#components) + * [Directives](#directives) +- [Content service](#content-service) + * [Components](#components-1) +- [Business service](#business-service) + * [components](#components) + + + + + +## Core + +### Components + + +- [adf-card-view](ng2-alfresco-core/README.md) - [adf-accordion-group](ng2-alfresco-core/README.md) - [adf-accordion](ng2-alfresco-core/README.md) +- [adf-toolbar](ng2-alfresco-core/README.md) + + +### Directives + + - [context-menu](ng2-alfresco-core/README.md) - * Context Menu component +- [alfresco-mdl-textfield](ng2-alfresco-core/README.md) +- [alfresco-mdl-menu](ng2-alfresco-core/README.md) +- [alfresco-mdl-button](ng2-alfresco-core/README.md) +- [mdl](ng2-alfresco-core/README.md) +- [adf-upload](ng2-alfresco-core/README.md) -## ECM components +## Content service -- [alfresco-webscript-get](ng2-alfresco-webscript/README.md) -- [alfresco-pagination](ng2-alfresco-datatable/README.md) -- [alfresco-datatable](ng2-alfresco-datatable/README.md) -- [alfresco-login](ng2-alfresco-login/README.md) -- [alfresco-tag-node-actions-list](ng2-alfresco-tag/README.md) -- [alfresco-tag-list](ng2-alfresco-tag/README.md) -- [alfresco-tag-node-list](ng2-alfresco-tag/README.md) -- [alfresco-document-list](ng2-alfresco-documentlist/README.md) -- [alfresco-document-menu-action](ng2-alfresco-documentlist/README.md) -- [alfresco-document-list-breadcrumb](ng2-alfresco-documentlist/README.md) -- [adf-rating](ng2-alfresco-social/README.md) -- [adf-like](ng2-alfresco-social/README.md) -- [alfresco-upload-drag-area](ng2-alfresco-upload/README.md) -- [alfresco-upload-button](ng2-alfresco-upload/README.md) -- [alfresco-file-uploading-list](ng2-alfresco-upload/README.md) -- [alfresco-search](ng2-alfresco-search/README.md) -- [alfresco-search-control](ng2-alfresco-search/README.md) -- [alfresco-search-autocomplete](ng2-alfresco-search/README.md) +### Components + + +- [alfresco-viewer](ng2-alfresco-viewer/README.md) - [ng2-alfresco-userinfo](ng2-alfresco-userinfo/README.md) +- [alfresco-file-uploading-list](ng2-alfresco-upload/README.md) +- [alfresco-upload-button](ng2-alfresco-upload/README.md) +- [alfresco-upload-drag-area](ng2-alfresco-upload/README.md) +- [alfresco-tag-node-list](ng2-alfresco-tag/README.md) +- [alfresco-tag-list](ng2-alfresco-tag/README.md) +- [alfresco-tag-node-actions-list](ng2-alfresco-tag/README.md) +- [adf-like](ng2-alfresco-social/README.md) +- [adf-rating](ng2-alfresco-social/README.md) +- [alfresco-search-autocomplete](ng2-alfresco-search/README.md) +- [alfresco-search-control](ng2-alfresco-search/README.md) +- [alfresco-search](ng2-alfresco-search/README.md) +- [alfresco-login](ng2-alfresco-login/README.md) +- [adf-breadcrumb, alfresco-document-list-breadcrumb](ng2-alfresco-documentlist/README.md) +- [alfresco-document-menu-action](ng2-alfresco-documentlist/README.md) +- [alfresco-document-list](ng2-alfresco-documentlist/README.md) +- [alfresco-datatable-cell](ng2-alfresco-datatable/README.md) +- [alfresco-datatable](ng2-alfresco-datatable/README.md) +- [alfresco-pagination](ng2-alfresco-datatable/README.md) +- [alfresco-webscript-get](ng2-alfresco-webscript/README.md) + -## BPM components -- [activiti-analytics](ng2-activiti-analytics/README.md) -- [activiti-analytics-generator](ng2-activiti-analytics/README.md) -- [activiti-form](ng2-activiti-form/README.md) -- [activiti-content](ng2-activiti-form/README.md) -- [activiti-start-form](ng2-activiti-form/README.md) -- [activiti-process-instance-filters](ng2-activiti-processlist/README.md) -- [activiti-process-instance-list](ng2-activiti-processlist/README.md) -- [activiti-process-instance-details](ng2-activiti-processlist/README.md) -- [activiti-start-process](ng2-activiti-processlist/README.md) -- [activiti-apps](ng2-activiti-tasklist/README.md) -- [activiti-tasklist](ng2-activiti-tasklist/README.md) -- [activiti-checklist](ng2-activiti-tasklist/README.md) -- [adf-task-attachment-list](ng2-activiti-tasklist/README.md) -- [activiti-people](ng2-activiti-tasklist/README.md) -- [activiti-comments](ng2-activiti-tasklist/README.md) -- [activiti-task-header](ng2-activiti-tasklist/README.md) -- [activiti-task-details](ng2-activiti-tasklist/README.md) -- [activiti-start-task](ng2-activiti-tasklist/README.md) -- [activiti-filters](ng2-activiti-tasklist/README.md) -- [activiti-people-search](ng2-activiti-tasklist/README.md) -- [activiti-process-instance-header](ng2-activiti-processlist/README.md) -- [activiti-process-instance-tasks](ng2-activiti-processlist/README.md) + + +## Business service + +### components + + +- [diagram-icon-alfresco-publish-task](ng2-activiti-diagrams/README.md) +- [diagram-alfresco-publish-task](ng2-activiti-diagrams/README.md) - [activiti-process-instance-comments](ng2-activiti-processlist/README.md) - [activiti-process-instance-variables](ng2-activiti-processlist/README.md) +- [activiti-process-instance-tasks](ng2-activiti-processlist/README.md) +- [activiti-process-instance-header](ng2-activiti-processlist/README.md) +- [adf-people-list](ng2-activiti-tasklist/README.md) +- [adf-create-task-attachment](ng2-activiti-tasklist/README.md) +- [activiti-people-search](ng2-activiti-tasklist/README.md) +- [activiti-start-task](ng2-activiti-tasklist/README.md) +- [activiti-task-details](ng2-activiti-tasklist/README.md) +- [activiti-filters](ng2-activiti-tasklist/README.md) +- [activiti-task-header](ng2-activiti-tasklist/README.md) +- [activiti-people](ng2-activiti-tasklist/README.md) +- [adf-task-attachment-list](ng2-activiti-tasklist/README.md) +- [activiti-comments](ng2-activiti-tasklist/README.md) +- [activiti-checklist](ng2-activiti-tasklist/README.md) +- [activiti-tasklist](ng2-activiti-tasklist/README.md) +- [activiti-apps](ng2-activiti-tasklist/README.md) - [activiti-diagram](ng2-activiti-diagrams/README.md) +- [adf-create-process-attachment](ng2-activiti-processlist/README.md) +- [adf-process-attachment-list](ng2-activiti-processlist/README.md) +- [activiti-start-process](ng2-activiti-processlist/README.md) +- [activiti-process-instance-details](ng2-activiti-processlist/README.md) +- [activiti-process-instance-filters](ng2-activiti-processlist/README.md) +- [activiti-process-instance-list](ng2-activiti-processlist/README.md) +- [activiti-analytics-generator](ng2-activiti-analytics/README.md) +- [activiti-analytics](ng2-activiti-analytics/README.md) +- [activiti-start-form](ng2-activiti-form/README.md) +- [activiti-content](ng2-activiti-form/README.md) +- [activiti-form](ng2-activiti-form/README.md) + + + + + You can browse all the components at the following address: diff --git a/ng2-components/config/custom-loaders/generateListComponent.js b/ng2-components/config/custom-loaders/generateListComponent.js new file mode 100644 index 0000000000..db3e56d6a0 --- /dev/null +++ b/ng2-components/config/custom-loaders/generateListComponent.js @@ -0,0 +1,123 @@ +var path = require('path'); +var fs = require('fs'); + +var erase = true; +var readmeContent = null; +var readmeFilePath = ''; + +function isFileEmpty(fileContents) { + return fileContents.toString('utf8').trim() === ''; +} + +function writeFile(file, newValue) { + fs.writeFileSync(file, newValue, 'utf-8'); +} + +function readFile(file) { + return fs.readFileSync(file, 'utf8'); +} + +function eraseContentList() { + if (erase) { + erase = false; + + var businessRegex = /(?:)([\s\S]*?)(?:)/; + var contentRegex = /(?:)([\s\S]*?)(?:)/; + var coreRegex = /(?:)([\s\S]*?)(?:)/; + var businessRegexDirective = /(?:)([\s\S]*?)(?:)/; + var contentRegexDirective = /(?:)([\s\S]*?)(?:)/; + var coreRegexDirective = /(?:)([\s\S]*?)(?:)/; + + readmeContent = readmeContent.replace(businessRegex, ''); + readmeContent = readmeContent.replace(contentRegex, ''); + readmeContent = readmeContent.replace(coreRegex, ''); + + readmeContent = readmeContent.replace(businessRegexDirective, ''); + readmeContent = readmeContent.replace(contentRegexDirective, ''); + readmeContent = readmeContent.replace(coreRegexDirective, ''); + + writeFile(readmeFilePath, readmeContent) + } +} + +function generateListComponent(currentFileContent, webpackInstance) { + if (!isFileEmpty(currentFileContent)) { + + var componentReg = /(@Component)(\s?)\((\s?){(\s?)((.|\n)*)}(\s?)\)/gm; + var componentSection = componentReg.exec(currentFileContent); + + if (componentSection) { + var selectorReg = /(selector)(\s?):(\s?)('|")((.|)*)('|")/gm; + var selector = selectorReg.exec(componentSection[0]); + + + if (selector) { + if (selector[0].indexOf('alfresco') > 0 || selector[0].indexOf('activiti') > 0 || selector[0].indexOf('adf') > 0) { + var selector = selector[0].replace("selector: '[", "").replace("']", '').replace("]", '').replace("selector: '", "").replace("'", ''); + var removeRoot = webpackInstance.resourcePath.substr(webpackInstance.resourcePath.indexOf('/ng2-components') + 16, webpackInstance.resourcePath.length); + var url = removeRoot.substr(0, removeRoot.indexOf('src')) + 'README.md'; + + var link = '- [' + selector + '](' + url + ')'; + + if (webpackInstance.resourcePath.match('ng2-alfresco-core')) { + readmeContent = readmeContent.replace('', '\n' + link); + } else if (webpackInstance.resourcePath.match('ng2-alfresco-')) { + readmeContent = readmeContent.replace('', '\n' + link); + } else if (webpackInstance.resourcePath.match('ng2-activiti-')) { + readmeContent = readmeContent.replace('', '\n' + link); + } + } + } + } + + + var directiveReg = /(@Directive)(\s?)\((\s?){(\s?)((.|\n)*)}(\s?)\)/gm; + var directiveSection = directiveReg.exec(currentFileContent); + + if (directiveSection) { + var selectorReg = /(selector)(\s?):(\s?)('|")((.|)*)('|")/gm; + var selector = selectorReg.exec(directiveSection[0]); + + if (selector) { + var selector = selector[0].replace("selector: '[", "").replace("']", '').replace("]", '').replace("selector: '", "").replace("'", ''); + var removeRoot = webpackInstance.resourcePath.substr(webpackInstance.resourcePath.indexOf('/ng2-components') + 16, webpackInstance.resourcePath.length); + var url = removeRoot.substr(0, removeRoot.indexOf('src')) + 'README.md'; + + var link = '- [' + selector + '](' + url + ')'; + + if (webpackInstance.resourcePath.match('ng2-alfresco-core')) { + readmeContent = readmeContent.replace('', '\n' + link); + } + //else if (webpackInstance.resourcePath.match('ng2-alfresco-')) { + // readmeContent = readmeContent.replace('', '\n' + link); + //} + //else if (webpackInstance.resourcePath.match('ng2-activiti-')) { + // readmeContent = readmeContent.replace('', '\n' + link); + //} + } + } + + writeFile(readmeFilePath, readmeContent); + + return true; + } +} + + +module.exports = function (input, map) { + this.cacheable && this.cacheable(); + var callback = this.async(); + + readmeFilePath = path.resolve(__dirname, '../../README.md'); + + if (!readmeContent) { + readmeContent = readFile(readmeFilePath); + } + + if (readmeContent) { + eraseContentList(); + generateListComponent(input, this); + } + callback(null, input, map); +} + diff --git a/ng2-components/config/webpack.common.js b/ng2-components/config/webpack.common.js index 9f9b8d08ea..a0c890a9f5 100644 --- a/ng2-components/config/webpack.common.js +++ b/ng2-components/config/webpack.common.js @@ -34,7 +34,8 @@ module.exports = { resolveLoader: { alias: { "file-multi-loader": path.resolve(__dirname, "./custom-loaders/file-loader-multi"), - "license-check": path.resolve(__dirname, "./custom-loaders/license-check") + "license-check": path.resolve(__dirname, "./custom-loaders/license-check"), + "generate-list-component-loader": path.resolve(__dirname, "./custom-loaders/generateListComponent") } }, diff --git a/ng2-components/config/webpack.doc.js b/ng2-components/config/webpack.doc.js new file mode 100644 index 0000000000..a68b795d5a --- /dev/null +++ b/ng2-components/config/webpack.doc.js @@ -0,0 +1,17 @@ +const helpers = require('./helpers'); +const webpackMerge = require('webpack-merge'); +const webpackBuild = require('./webpack.build'); + +module.exports = webpackMerge(webpackBuild, { + + module: { + rules: [ + + { + test: /\.ts/, + loader: 'generate-list-component-loader', + exclude: [/node_modules/, /bundles/, /dist/, /demo/] + } + ] + } +}); diff --git a/ng2-components/ng2-activiti-form/README.md b/ng2-components/ng2-activiti-form/README.md index dc8c339051..4e9457898d 100644 --- a/ng2-components/ng2-activiti-form/README.md +++ b/ng2-components/ng2-activiti-form/README.md @@ -22,6 +22,7 @@ * [Methods](#methods) - [Common scenarios](#common-scenarios) * [Changing field value based on another field](#changing-field-value-based-on-another-field) + * [Listen all form Events](#listen-all-form-events) - [See also](#see-also) - [Build from sources](#build-from-sources) - [NPM scripts](#npm-scripts) diff --git a/ng2-components/ng2-activiti-tasklist/README.md b/ng2-components/ng2-activiti-tasklist/README.md index 1621ef1e54..c7c0294b31 100644 --- a/ng2-components/ng2-activiti-tasklist/README.md +++ b/ng2-components/ng2-activiti-tasklist/README.md @@ -36,6 +36,9 @@ * [Properties](#properties-7) * [Events](#events-6) - [TaskDetailsModel](#taskdetailsmodel) +- [Task People Component](#task-people-component) + * [Properties](#properties-8) + + [Events](#events-7) - [Build from sources](#build-from-sources) - [NPM scripts](#npm-scripts) - [Demo](#demo) diff --git a/ng2-components/ng2-alfresco-core/README.md b/ng2-components/ng2-alfresco-core/README.md index c7f650bce1..f9fce23c14 100644 --- a/ng2-components/ng2-alfresco-core/README.md +++ b/ng2-components/ng2-alfresco-core/README.md @@ -17,6 +17,7 @@ * [Styling](#styling) - [Alfresco Api Service](#alfresco-api-service) - [AppConfigService](#appconfigservice) + * [Different configurations based on environment settings](#different-configurations-based-on-environment-settings) - [Notification Service](#notification-service) - [Context Menu directive](#context-menu-directive) - [Accordion Component](#accordion-component) diff --git a/ng2-components/package-base.json b/ng2-components/package-base.json index 6f9cf26244..bbaa7bcf2c 100644 --- a/ng2-components/package-base.json +++ b/ng2-components/package-base.json @@ -9,7 +9,8 @@ "pkg-build": "package-json-merge ng2-alfresco-core/package.json ng2-alfresco-datatable/package.json ng2-activiti-diagrams/package.json ng2-activiti-analytics/package.json ng2-activiti-form/package.json ng2-activiti-tasklist/package.json ng2-activiti-processlist/package.json ng2-alfresco-documentlist/package.json ng2-alfresco-login/package.json ng2-alfresco-search/package.json ng2-alfresco-tag/package.json ng2-alfresco-upload/package.json ng2-alfresco-viewer/package.json ng2-alfresco-webscript/package.json ng2-alfresco-webscript/package.json ng2-alfresco-userinfo/package.json ng2-alfresco-social/package.json package-base.json > package.json", "test": "node node_modules/karma/bin/karma start --reporters mocha,coverage --single-run --component .", "test-browser": "node node_modules/karma/bin/karma start karma.conf.js --reporters kjhtml", - "toc": "markdown-toc -i ng2-alfresco-core/README.md && markdown-toc -i ng2-alfresco-datatable/README.md && markdown-toc -i ng2-activiti-diagrams/README.md && markdown-toc -i ng2-activiti-analytics/README.md && markdown-toc -i ng2-activiti-form/README.md && markdown-toc -i ng2-activiti-tasklist/README.md && markdown-toc -i ng2-activiti-processlist/README.md && markdown-toc -i ng2-alfresco-documentlist/README.md && markdown-toc -i ng2-alfresco-login/README.md && markdown-toc -i ng2-alfresco-search/README.md && markdown-toc -i ng2-alfresco-tag/README.md && markdown-toc -i ng2-alfresco-upload/README.md && markdown-toc -i ng2-alfresco-viewer/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-userinfo/README.md && markdown-toc -i ng2-alfresco-social/README.md", + "toc": "markdown-toc -i ng2-alfresco-core/README.md && markdown-toc -i ng2-alfresco-datatable/README.md && markdown-toc -i ng2-activiti-diagrams/README.md && markdown-toc -i ng2-activiti-analytics/README.md && markdown-toc -i ng2-activiti-form/README.md && markdown-toc -i ng2-activiti-tasklist/README.md && markdown-toc -i ng2-activiti-processlist/README.md && markdown-toc -i ng2-alfresco-documentlist/README.md && markdown-toc -i ng2-alfresco-login/README.md && markdown-toc -i ng2-alfresco-search/README.md && markdown-toc -i ng2-alfresco-tag/README.md && markdown-toc -i ng2-alfresco-upload/README.md && markdown-toc -i ng2-alfresco-viewer/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-userinfo/README.md && markdown-toc -i ng2-alfresco-social/README.md && markdown-toc -i README.md", + "doc": "npm run toc && npm run npm run webpack -- --config config/webpack.doc.js --progress --profile --bail", "tslint": "", "prepublish": "", "tsc": "", diff --git a/ng2-components/package.json b/ng2-components/package.json index 231b281e26..04f286877f 100644 --- a/ng2-components/package.json +++ b/ng2-components/package.json @@ -12,7 +12,8 @@ "coverage": "", "prepublish": "", "pkg-build": "package-json-merge ng2-alfresco-core/package.json ng2-alfresco-datatable/package.json ng2-activiti-diagrams/package.json ng2-activiti-analytics/package.json ng2-activiti-form/package.json ng2-activiti-tasklist/package.json ng2-activiti-processlist/package.json ng2-alfresco-documentlist/package.json ng2-alfresco-login/package.json ng2-alfresco-search/package.json ng2-alfresco-tag/package.json ng2-alfresco-upload/package.json ng2-alfresco-viewer/package.json ng2-alfresco-webscript/package.json ng2-alfresco-webscript/package.json ng2-alfresco-userinfo/package.json ng2-alfresco-social/package.json package-base.json > package.json", - "toc": "markdown-toc -i ng2-alfresco-core/README.md && markdown-toc -i ng2-alfresco-datatable/README.md && markdown-toc -i ng2-activiti-diagrams/README.md && markdown-toc -i ng2-activiti-analytics/README.md && markdown-toc -i ng2-activiti-form/README.md && markdown-toc -i ng2-activiti-tasklist/README.md && markdown-toc -i ng2-activiti-processlist/README.md && markdown-toc -i ng2-alfresco-documentlist/README.md && markdown-toc -i ng2-alfresco-login/README.md && markdown-toc -i ng2-alfresco-search/README.md && markdown-toc -i ng2-alfresco-tag/README.md && markdown-toc -i ng2-alfresco-upload/README.md && markdown-toc -i ng2-alfresco-viewer/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-userinfo/README.md && markdown-toc -i ng2-alfresco-social/README.md", + "toc": "markdown-toc -i ng2-alfresco-core/README.md && markdown-toc -i ng2-alfresco-datatable/README.md && markdown-toc -i ng2-activiti-diagrams/README.md && markdown-toc -i ng2-activiti-analytics/README.md && markdown-toc -i ng2-activiti-form/README.md && markdown-toc -i ng2-activiti-tasklist/README.md && markdown-toc -i ng2-activiti-processlist/README.md && markdown-toc -i ng2-alfresco-documentlist/README.md && markdown-toc -i ng2-alfresco-login/README.md && markdown-toc -i ng2-alfresco-search/README.md && markdown-toc -i ng2-alfresco-tag/README.md && markdown-toc -i ng2-alfresco-upload/README.md && markdown-toc -i ng2-alfresco-viewer/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-userinfo/README.md && markdown-toc -i ng2-alfresco-social/README.md && markdown-toc -i README.md", + "doc": "npm run toc && npm run webpack -- --config config/webpack.doc.js --progress --profile --bail", "tslint": "", "tsc": "", "pretest": "",