@diplodoc/cli 4.8.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +115 -4
- package/build/index.js.map +3 -3
- package/build/linter.js +9 -1
- package/build/linter.js.map +2 -2
- package/package.json +2 -2
- package/src/models.ts +1 -0
- package/src/services/contributors.ts +46 -2
- package/src/services/metadata.ts +42 -2
- package/src/services/tocs.ts +10 -0
- package/src/vcs-connector/connector-models.ts +2 -0
- package/src/vcs-connector/github.ts +42 -1
package/build/index.js
CHANGED
|
@@ -946,6 +946,42 @@ function getRelativeIncludeFilePaths(fileData, includeContents) {
|
|
|
946
946
|
});
|
|
947
947
|
return relativeIncludeFilePaths;
|
|
948
948
|
}
|
|
949
|
+
function getFileIncludes(fileData) {
|
|
950
|
+
return __async(this, null, function* () {
|
|
951
|
+
const { fileContent, tmpInputFilePath, inputFolderPathLength } = fileData;
|
|
952
|
+
const results = /* @__PURE__ */ new Set();
|
|
953
|
+
const includeContents = fileContent.match(REGEXP_INCLUDE_CONTENTS);
|
|
954
|
+
if (!includeContents || includeContents.length === 0) {
|
|
955
|
+
return [];
|
|
956
|
+
}
|
|
957
|
+
const relativeIncludeFilePaths = getRelativeIncludeFilePaths(
|
|
958
|
+
{ tmpInputFilePath },
|
|
959
|
+
includeContents
|
|
960
|
+
);
|
|
961
|
+
for (const relativeIncludeFilePath of relativeIncludeFilePaths.values()) {
|
|
962
|
+
const relativeFilePath = relativeIncludeFilePath.substring(inputFolderPathLength + 1);
|
|
963
|
+
if (results.has(relativeFilePath))
|
|
964
|
+
continue;
|
|
965
|
+
results.add(relativeFilePath);
|
|
966
|
+
let contentIncludeFile;
|
|
967
|
+
try {
|
|
968
|
+
contentIncludeFile = yield (0, import_promises.readFile)(relativeIncludeFilePath, "utf8");
|
|
969
|
+
} catch (err) {
|
|
970
|
+
if (err.code === "ENOENT") {
|
|
971
|
+
continue;
|
|
972
|
+
}
|
|
973
|
+
throw err;
|
|
974
|
+
}
|
|
975
|
+
const includedPaths = yield getFileIncludes({
|
|
976
|
+
inputFolderPathLength,
|
|
977
|
+
fileContent: contentIncludeFile,
|
|
978
|
+
tmpInputFilePath: relativeIncludeFilePath
|
|
979
|
+
});
|
|
980
|
+
includedPaths.forEach((path) => results.add(path));
|
|
981
|
+
}
|
|
982
|
+
return Array.from(results.values());
|
|
983
|
+
});
|
|
984
|
+
}
|
|
949
985
|
|
|
950
986
|
// src/services/metadata.ts
|
|
951
987
|
var import_path10 = require("path");
|
|
@@ -1013,6 +1049,10 @@ function getContentWithUpdatedDynamicMetadata(fileContent, options) {
|
|
|
1013
1049
|
if (contributorsMetaData) {
|
|
1014
1050
|
newMetadatas.push(contributorsMetaData);
|
|
1015
1051
|
}
|
|
1052
|
+
const mtimeMetadata = yield getModifiedTimeMetadataString(options, fileContent);
|
|
1053
|
+
if (mtimeMetadata) {
|
|
1054
|
+
newMetadatas.push(mtimeMetadata);
|
|
1055
|
+
}
|
|
1016
1056
|
let authorMetadata = "";
|
|
1017
1057
|
if (fileMetadata) {
|
|
1018
1058
|
const matchAuthor = fileMetadata.match(REGEXP_AUTHOR);
|
|
@@ -1071,6 +1111,28 @@ function getContributorsMetadataString(options, fileContent) {
|
|
|
1071
1111
|
return void 0;
|
|
1072
1112
|
});
|
|
1073
1113
|
}
|
|
1114
|
+
function getModifiedTimeMetadataString(options, fileContent) {
|
|
1115
|
+
return __async(this, null, function* () {
|
|
1116
|
+
const { isContributorsEnabled, vcsConnector, fileData } = options;
|
|
1117
|
+
const { tmpInputFilePath, inputFolderPathLength } = fileData;
|
|
1118
|
+
const relativeFilePath = tmpInputFilePath.substring(inputFolderPathLength + 1);
|
|
1119
|
+
if (!isContributorsEnabled || !vcsConnector) {
|
|
1120
|
+
return void 0;
|
|
1121
|
+
}
|
|
1122
|
+
const includedFiles = yield getFileIncludes(__spreadProps(__spreadValues({}, fileData), { fileContent }));
|
|
1123
|
+
includedFiles.push(relativeFilePath);
|
|
1124
|
+
const tocCopyFileMap = tocs_default.getCopyFileMap();
|
|
1125
|
+
const mtimeList = includedFiles.map((path) => {
|
|
1126
|
+
const mappedPath = tocCopyFileMap.get(path) || path;
|
|
1127
|
+
return vcsConnector.getModifiedTimeByPath(mappedPath);
|
|
1128
|
+
}).filter((v) => typeof v === "number");
|
|
1129
|
+
if (mtimeList.length) {
|
|
1130
|
+
const mtime = Math.max(...mtimeList);
|
|
1131
|
+
return `updatedAt: ${new Date(mtime * 1e3).toISOString()}`;
|
|
1132
|
+
}
|
|
1133
|
+
return void 0;
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1074
1136
|
function getUpdatedMetadataString(newMetadatas, defaultMetadata = "") {
|
|
1075
1137
|
const newMetadata = newMetadatas.join(\u0441arriage) + (newMetadatas.length ? \u0441arriage : "");
|
|
1076
1138
|
const preparedDefaultMetadata = defaultMetadata.trimRight();
|
|
@@ -1450,6 +1512,7 @@ function applyIncluder(args) {
|
|
|
1450
1512
|
var storage = /* @__PURE__ */ new Map();
|
|
1451
1513
|
var navigationPaths = [];
|
|
1452
1514
|
var includedTocPaths = /* @__PURE__ */ new Set();
|
|
1515
|
+
var tocFileCopyMap = /* @__PURE__ */ new Map();
|
|
1453
1516
|
function add(path) {
|
|
1454
1517
|
return __async(this, null, function* () {
|
|
1455
1518
|
const {
|
|
@@ -1574,6 +1637,9 @@ function _copyTocDir(tocPath, destDir) {
|
|
|
1574
1637
|
} else {
|
|
1575
1638
|
import_shelljs2.default.cp(from, to);
|
|
1576
1639
|
}
|
|
1640
|
+
const relFrom = (0, import_path14.relative)(inputFolderPath, from);
|
|
1641
|
+
const relTo = (0, import_path14.relative)(inputFolderPath, to);
|
|
1642
|
+
tocFileCopyMap.set(relTo, relFrom);
|
|
1577
1643
|
});
|
|
1578
1644
|
}
|
|
1579
1645
|
function _replaceIncludesHrefs(items, includeTocDir, tocDir) {
|
|
@@ -1692,13 +1758,17 @@ function getTocDir(pagePath) {
|
|
|
1692
1758
|
function setNavigationPaths(paths) {
|
|
1693
1759
|
navigationPaths = paths;
|
|
1694
1760
|
}
|
|
1761
|
+
function getCopyFileMap() {
|
|
1762
|
+
return tocFileCopyMap;
|
|
1763
|
+
}
|
|
1695
1764
|
var tocs_default = {
|
|
1696
1765
|
add,
|
|
1697
1766
|
getForPath,
|
|
1698
1767
|
getNavigationPaths,
|
|
1699
1768
|
getTocDir,
|
|
1700
1769
|
getIncludedTocPaths,
|
|
1701
|
-
setNavigationPaths
|
|
1770
|
+
setNavigationPaths,
|
|
1771
|
+
getCopyFileMap
|
|
1702
1772
|
};
|
|
1703
1773
|
|
|
1704
1774
|
// src/services/preset.ts
|
|
@@ -2423,9 +2493,10 @@ var authorByPath = /* @__PURE__ */ new Map();
|
|
|
2423
2493
|
var contributorsByPath = /* @__PURE__ */ new Map();
|
|
2424
2494
|
var contributorsData = /* @__PURE__ */ new Map();
|
|
2425
2495
|
var loginUserMap = /* @__PURE__ */ new Map();
|
|
2496
|
+
var pathMTime = /* @__PURE__ */ new Map();
|
|
2426
2497
|
function getGitHubVCSConnector() {
|
|
2427
2498
|
return __async(this, null, function* () {
|
|
2428
|
-
const { contributors } = argv_default.getConfig();
|
|
2499
|
+
const { contributors, rootInput } = argv_default.getConfig();
|
|
2429
2500
|
const httpClientByToken = getHttpClientByToken();
|
|
2430
2501
|
if (!httpClientByToken) {
|
|
2431
2502
|
return void 0;
|
|
@@ -2438,6 +2509,7 @@ function getGitHubVCSConnector() {
|
|
|
2438
2509
|
return (_a = authorByPath.get(path)) != null ? _a : null;
|
|
2439
2510
|
};
|
|
2440
2511
|
if (contributors) {
|
|
2512
|
+
yield getFilesMTime(rootInput, pathMTime);
|
|
2441
2513
|
yield getAllContributorsTocFiles(httpClientByToken);
|
|
2442
2514
|
addNestedContributorsForPath = (path, nestedContributors) => addNestedContributorsForPathFunction(path, nestedContributors);
|
|
2443
2515
|
getContributorsByPath = (path) => __async(this, null, function* () {
|
|
@@ -2448,7 +2520,8 @@ function getGitHubVCSConnector() {
|
|
|
2448
2520
|
getExternalAuthorByPath,
|
|
2449
2521
|
addNestedContributorsForPath,
|
|
2450
2522
|
getContributorsByPath,
|
|
2451
|
-
getUserByLogin: (login) => getUserByLogin(httpClientByToken, login)
|
|
2523
|
+
getUserByLogin: (login) => getUserByLogin(httpClientByToken, login),
|
|
2524
|
+
getModifiedTimeByPath: (filename) => pathMTime.get(filename)
|
|
2452
2525
|
};
|
|
2453
2526
|
});
|
|
2454
2527
|
}
|
|
@@ -2688,6 +2761,44 @@ function shouldAuthorBeIgnored({ email, name: name4 }) {
|
|
|
2688
2761
|
}
|
|
2689
2762
|
return false;
|
|
2690
2763
|
}
|
|
2764
|
+
function getFilesMTime(repoDir, pathMTime2) {
|
|
2765
|
+
return __async(this, null, function* () {
|
|
2766
|
+
const timeFiles = yield (0, import_simple_git.default)({
|
|
2767
|
+
baseDir: repoDir
|
|
2768
|
+
}).raw(
|
|
2769
|
+
"log",
|
|
2770
|
+
"--reverse",
|
|
2771
|
+
"--before=now",
|
|
2772
|
+
"--diff-filter=ADMR",
|
|
2773
|
+
"--pretty=format:%ct",
|
|
2774
|
+
"--name-status"
|
|
2775
|
+
);
|
|
2776
|
+
const parts = timeFiles.split(/\n\n/);
|
|
2777
|
+
parts.forEach((part) => {
|
|
2778
|
+
const lines = part.trim().split(/\n/);
|
|
2779
|
+
const committerDate = lines.shift();
|
|
2780
|
+
const unixtime = Number(committerDate);
|
|
2781
|
+
lines.forEach((line) => {
|
|
2782
|
+
const [status, from, to] = line.split(/\t/);
|
|
2783
|
+
switch (status[0]) {
|
|
2784
|
+
case "R": {
|
|
2785
|
+
pathMTime2.delete(from);
|
|
2786
|
+
pathMTime2.set(to, unixtime);
|
|
2787
|
+
break;
|
|
2788
|
+
}
|
|
2789
|
+
case "D": {
|
|
2790
|
+
pathMTime2.delete(from);
|
|
2791
|
+
break;
|
|
2792
|
+
}
|
|
2793
|
+
default: {
|
|
2794
|
+
pathMTime2.set(from, unixtime);
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
});
|
|
2798
|
+
});
|
|
2799
|
+
return pathMTime2;
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2691
2802
|
var github_default2 = getGitHubVCSConnector;
|
|
2692
2803
|
|
|
2693
2804
|
// src/vcs-connector/index.ts
|
|
@@ -4100,7 +4211,7 @@ import_yargs.default.command(build).command(publish).command(xliff).command(tran
|
|
|
4100
4211
|
default: false,
|
|
4101
4212
|
describe: "Run in quiet mode. Don't write logs to stdout",
|
|
4102
4213
|
type: "boolean"
|
|
4103
|
-
}).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.
|
|
4214
|
+
}).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.9.0" : "").help().parse((0, import_helpers.hideBin)(process.argv), {}, (err, { strict }, output) => {
|
|
4104
4215
|
console.timeEnd(MAIN_TIMER_ID);
|
|
4105
4216
|
if (err) {
|
|
4106
4217
|
console.error(err);
|