mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
repair doc tools and polish the docs code (#5038)
* set private access modifier * repair doc build tools * fix lit issues * re-generate version index
This commit is contained in:
committed by
Eugenio Romano
parent
3bebc7a18c
commit
2b1250cae7
@@ -1,4 +1,5 @@
|
||||
"use strict";
|
||||
// tslint:disable: no-console
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
@@ -8,27 +9,20 @@ var remark = require("remark");
|
||||
var frontMatter = require("remark-frontmatter");
|
||||
var yaml = require("js-yaml");
|
||||
var moment = require("moment");
|
||||
var Rx_1 = require("rxjs/Rx");
|
||||
var rxjs_1 = require("rxjs");
|
||||
var libsearch = require("./libsearch");
|
||||
var stoplist_1 = require("./stoplist");
|
||||
var adf20StartDate = "2017-11-20";
|
||||
var adf20StartDate = '2017-11-20';
|
||||
var commitWeight = 0.1;
|
||||
var scoreTimeBase = 60;
|
||||
var libFolder = "lib";
|
||||
var stoplistFilePath = path.resolve("tools", "doc", "commitStoplist.json");
|
||||
var libFolder = 'lib';
|
||||
var stoplistFilePath = path.resolve('tools', 'doc', 'commitStoplist.json');
|
||||
var angFilePattern = /(component)|(directive)|(model)|(pipe)|(service)|(widget)/;
|
||||
var srcData = {};
|
||||
var stoplist = new stoplist_1.Stoplist(stoplistFilePath);
|
||||
var docsFolderPath = path.resolve("docs");
|
||||
var libFolders = ["core", "content-services", "extensions", "insights", "process-services", "process-services-cloud"];
|
||||
var docsFolderPath = path.resolve('docs');
|
||||
var libFolders = ['core', 'content-services', 'extensions', 'insights', 'process-services', 'process-services-cloud'];
|
||||
libsearch(srcData, path.resolve(libFolder));
|
||||
/*
|
||||
let keys = Object.keys(srcData);
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
console.log(keys[i]);
|
||||
}
|
||||
*/
|
||||
var authToken = process.env.graphAuthToken;
|
||||
var client = new graphql_request_1.GraphQLClient('https://api.github.com/graphql', {
|
||||
headers: {
|
||||
@@ -37,20 +31,21 @@ var client = new graphql_request_1.GraphQLClient('https://api.github.com/graphql
|
||||
});
|
||||
var query = "query commitHistory($path: String) {\n repository(name: \"alfresco-ng2-components\", owner: \"alfresco\") {\n ref(qualifiedName: \"development\") {\n target {\n ... on Commit {\n history(first: 15, path: $path) {\n nodes {\n pushedDate\n message\n }\n }\n }\n }\n }\n }\n}";
|
||||
var docFiles = getDocFilePaths(docsFolderPath);
|
||||
var docNames = Rx_1.Observable.from(docFiles);
|
||||
var docNames = rxjs_1.of(docFiles);
|
||||
console.log("'Name','Review date','Commits since review','Score'");
|
||||
docNames.subscribe(function (x) {
|
||||
var key = path.basename(x, ".md");
|
||||
if (!srcData[key])
|
||||
var key = path.basename(x, '.md');
|
||||
if (!srcData[key]) {
|
||||
return;
|
||||
}
|
||||
var vars = {
|
||||
"path": "lib/" + srcData[key].path
|
||||
'path': 'lib/' + srcData[key].path
|
||||
};
|
||||
client.request(query, vars).then(function (data) {
|
||||
var nodes = data["repository"].ref.target.history.nodes;
|
||||
var lastReviewDate = getDocReviewDate(x); //(key + ".md");
|
||||
var nodes = data['repository'].ref.target.history.nodes;
|
||||
var lastReviewDate = getDocReviewDate(x); // (key + ".md");
|
||||
var numUsefulCommits = extractCommitInfo(nodes, lastReviewDate, stoplist);
|
||||
var dateString = lastReviewDate.format("YYYY-MM-DD");
|
||||
var dateString = lastReviewDate.format('YYYY-MM-DD');
|
||||
var score = priorityScore(lastReviewDate, numUsefulCommits).toPrecision(3);
|
||||
console.log("'" + key + "','" + dateString + "','" + numUsefulCommits + "','" + score + "'");
|
||||
});
|
||||
@@ -63,12 +58,13 @@ function priorityScore(reviewDate, numCommits) {
|
||||
function getDocReviewDate(docFileName) {
|
||||
var mdFilePath = path.resolve(docsFolderPath, docFileName);
|
||||
var mdText = fs.readFileSync(mdFilePath);
|
||||
var tree = remark().use(frontMatter, ["yaml"]).parse(mdText);
|
||||
var tree = remark().use(frontMatter, ['yaml']).parse(mdText);
|
||||
var lastReviewDate = moment(adf20StartDate);
|
||||
if (tree.children[0].type == "yaml") {
|
||||
if (tree.children[0].type === 'yaml') {
|
||||
var metadata = yaml.load(tree.children[0].value);
|
||||
if (metadata["Last reviewed"])
|
||||
lastReviewDate = moment(metadata["Last reviewed"]);
|
||||
if (metadata['Last reviewed']) {
|
||||
lastReviewDate = moment(metadata['Last reviewed']);
|
||||
}
|
||||
}
|
||||
return lastReviewDate;
|
||||
}
|
||||
@@ -76,7 +72,7 @@ function extractCommitInfo(commitNodes, cutOffDate, stoplist) {
|
||||
var numUsefulCommits = 0;
|
||||
commitNodes.forEach(function (element) {
|
||||
if (!stoplist.isRejected(element.message)) {
|
||||
var abbr = element.message.substr(0, 15);
|
||||
// const abbr = element.message.substr(0, 15);
|
||||
var commitDate = moment(element.pushedDate);
|
||||
if (commitDate.isAfter(cutOffDate)) {
|
||||
numUsefulCommits++;
|
||||
@@ -90,31 +86,18 @@ function getDocFilePaths(folderPath) {
|
||||
libFolders.forEach(function (element) {
|
||||
var libPath = path.resolve(folderPath, element);
|
||||
addItemsRecursively(libPath, result);
|
||||
var items = fs.readdirSync(libPath);
|
||||
/*
|
||||
|
||||
files = files.filter(filename =>
|
||||
(path.extname(filename) === ".md") &&
|
||||
(filename !== "README.md") &&
|
||||
(filename.match(angFilePattern))
|
||||
);
|
||||
|
||||
files.forEach(element => {
|
||||
result.push(path.join(libPath, element));
|
||||
});
|
||||
*/
|
||||
});
|
||||
return result;
|
||||
function addItemsRecursively(folderPath, resultList) {
|
||||
var items = fs.readdirSync(folderPath);
|
||||
function addItemsRecursively(elementPath, resultList) {
|
||||
var items = fs.readdirSync(elementPath);
|
||||
items.forEach(function (item) {
|
||||
var fullItemPath = path.resolve(folderPath, item);
|
||||
var fullItemPath = path.resolve(elementPath, item);
|
||||
var itemInfo = fs.statSync(fullItemPath);
|
||||
if (itemInfo.isDirectory()) {
|
||||
addItemsRecursively(fullItemPath, resultList);
|
||||
}
|
||||
else if ((path.extname(fullItemPath) === ".md") &&
|
||||
(item !== "README.md") &&
|
||||
else if ((path.extname(fullItemPath) === '.md') &&
|
||||
(item !== 'README.md') &&
|
||||
(item.match(angFilePattern))) {
|
||||
resultList.push(fullItemPath);
|
||||
}
|
||||
|
Reference in New Issue
Block a user