@diplodoc/cli 4.7.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 CHANGED
@@ -35,9 +35,6 @@ var __objRest = (source, exclude) => {
35
35
  }
36
36
  return target;
37
37
  };
38
- var __commonJS = (cb, mod) => function __require() {
39
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
40
- };
41
38
  var __export = (target, all) => {
42
39
  for (var name4 in all)
43
40
  __defProp(target, name4, { get: all[name4], enumerable: true });
@@ -59,7 +56,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
59
56
  mod
60
57
  ));
61
58
  var __async = (__this, __arguments, generator) => {
62
- return new Promise((resolve17, reject) => {
59
+ return new Promise((resolve18, reject) => {
63
60
  var fulfilled = (value) => {
64
61
  try {
65
62
  step(generator.next(value));
@@ -74,43 +71,11 @@ var __async = (__this, __arguments, generator) => {
74
71
  reject(e);
75
72
  }
76
73
  };
77
- var step = (x) => x.done ? resolve17(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
74
+ var step = (x) => x.done ? resolve18(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
78
75
  step((generator = generator.apply(__this, __arguments)).next());
79
76
  });
80
77
  };
81
78
 
82
- // scripts/client.js
83
- var require_client = __commonJS({
84
- "scripts/client.js"(exports, module2) {
85
- "use strict";
86
- var path = require("path");
87
- var CLIENT_PATH = path.dirname(require.resolve("@diplodoc/client"));
88
- var BUILD_PATH = path.resolve(__dirname, "..", "build");
89
- var BUNDLE_JS_FILENAME = "app.client.js";
90
- var BUNDLE_CSS_FILENAME = "app.client.css";
91
- var src = (target) => path.resolve(CLIENT_PATH, target);
92
- var dst = (target) => path.resolve(BUILD_PATH, target);
93
- module2.exports = {
94
- dst: {
95
- js: dst(BUNDLE_JS_FILENAME),
96
- css: dst(BUNDLE_CSS_FILENAME)
97
- },
98
- src: {
99
- js: src(BUNDLE_JS_FILENAME),
100
- css: src(BUNDLE_CSS_FILENAME)
101
- },
102
- bundle: {
103
- js(bundlePath) {
104
- return path.join(bundlePath, BUNDLE_JS_FILENAME);
105
- },
106
- css(bundlePath) {
107
- return path.join(bundlePath, BUNDLE_CSS_FILENAME);
108
- }
109
- }
110
- };
111
- }
112
- });
113
-
114
79
  // src/index.ts
115
80
  var import_yargs = __toESM(require("yargs"));
116
81
  var import_helpers = require("yargs/helpers");
@@ -139,10 +104,12 @@ var term = require("@diplodoc/transform/lib/plugins/term");
139
104
  var blockAnchor = require("@diplodoc/transform/lib/plugins/block-anchor");
140
105
  var changelog = require("@diplodoc/transform/lib/plugins/changelog");
141
106
  var mermaid = require("@diplodoc/mermaid-extension");
107
+ var latex = require("@diplodoc/latex-extension");
142
108
  var openapi = require("@diplodoc/openapi-extension");
143
109
  includes.collect = require("@diplodoc/transform/lib/plugins/includes/collect");
144
110
  images.collect = require("@diplodoc/transform/lib/plugins/images/collect");
145
111
  changelog.collect = require("@diplodoc/transform/lib/plugins/changelog/collect");
112
+ var ASSETS_FOLDER = (0, import_path.resolve)(__dirname, "../assets");
146
113
  var BUNDLE_FOLDER = "_bundle";
147
114
  var TMP_INPUT_FOLDER = ".tmp_input";
148
115
  var TMP_OUTPUT_FOLDER = ".tmp_output";
@@ -158,7 +125,6 @@ var ResourceType = /* @__PURE__ */ ((ResourceType2) => {
158
125
  ResourceType2["script"] = "script";
159
126
  return ResourceType2;
160
127
  })(ResourceType || {});
161
- var BUILD_FOLDER_PATH = (0, import_path.dirname)(require.resolve("@diplodoc/client"));
162
128
  var YFM_PLUGINS = [
163
129
  meta,
164
130
  deflist,
@@ -178,6 +144,7 @@ var YFM_PLUGINS = [
178
144
  term,
179
145
  openapi.transform(),
180
146
  mermaid.transform(),
147
+ latex.transform(),
181
148
  changelog,
182
149
  blockAnchor
183
150
  ];
@@ -320,10 +287,10 @@ function argvValidator(argv) {
320
287
  }
321
288
 
322
289
  // src/cmd/build/index.ts
323
- var import_path27 = require("path");
290
+ var import_path28 = require("path");
324
291
 
325
292
  // src/services/tocs.ts
326
- var import_path13 = require("path");
293
+ var import_path14 = require("path");
327
294
  var import_fs3 = require("fs");
328
295
  var import_js_yaml4 = require("js-yaml");
329
296
  var import_shelljs2 = __toESM(require("shelljs"));
@@ -371,6 +338,7 @@ var logger = {
371
338
  };
372
339
 
373
340
  // src/utils/markup.ts
341
+ var import_path4 = require("path");
374
342
  var import_process = require("process");
375
343
 
376
344
  // src/utils/singlePage.ts
@@ -378,7 +346,7 @@ var import_node_html_parser = require("node-html-parser");
378
346
  var import_path3 = require("path");
379
347
  var import_utilsFS = require("@diplodoc/transform/lib/utilsFS");
380
348
  var import_url = __toESM(require("url"));
381
- var import_lodash = __toESM(require("lodash"));
349
+ var import_escapeRegExp = __toESM(require("lodash/escapeRegExp"));
382
350
 
383
351
  // src/utils/url.ts
384
352
  function isExternalHref(href) {
@@ -387,6 +355,9 @@ function isExternalHref(href) {
387
355
 
388
356
  // src/utils/singlePage.ts
389
357
  var HEADERS_SELECTOR = "h1, h2, h3, h4, h5, h6";
358
+ function toUrl(path) {
359
+ return path.replace(new RegExp((0, import_escapeRegExp.default)(import_path3.sep), "g"), "/");
360
+ }
390
361
  function getNewNode(options) {
391
362
  const { rawTagName, innerHTML, attrEntries } = options;
392
363
  const nodeNew = (0, import_node_html_parser.parse)(`<html><${rawTagName}></${rawTagName}></html>`).querySelector(
@@ -441,7 +412,7 @@ function replaceLinks(rootEl, options) {
441
412
  preparedHref = getSinglePageAnchorId({ root, currentPath: resolvedPath, hash });
442
413
  }
443
414
  }
444
- node.setAttribute("href", preparedHref);
415
+ node.setAttribute("href", toUrl(preparedHref));
445
416
  });
446
417
  }
447
418
  function replaceImages(rootEl, options) {
@@ -454,7 +425,7 @@ function replaceImages(rootEl, options) {
454
425
  const resolvedPath = (0, import_path3.resolve)(root, path);
455
426
  const linkFullPath = (0, import_utilsFS.resolveRelativePath)(resolvedPath, href);
456
427
  const preparedHref = (0, import_path3.relative)(tocDir, linkFullPath);
457
- node.setAttribute("src", preparedHref);
428
+ node.setAttribute("src", toUrl(preparedHref));
458
429
  });
459
430
  }
460
431
  function prepareAnchorAttr(name4, value, pageId) {
@@ -470,7 +441,7 @@ function prepareAnchorAttr(name4, value, pageId) {
470
441
  function prepareAnchorAttrs(node, pageId) {
471
442
  for (const [name4, value] of Object.entries(node.attributes)) {
472
443
  const preparedValue = prepareAnchorAttr(name4, value, pageId);
473
- node.setAttribute(name4, preparedValue);
444
+ node.setAttribute(name4, toUrl(preparedValue));
474
445
  }
475
446
  }
476
447
  function addPagePrefixToAnchors(rootEl, options) {
@@ -515,7 +486,7 @@ function getSinglePageAnchorId(args) {
515
486
  if (pathname) {
516
487
  resultAnchor = (0, import_utilsFS.resolveRelativePath)(currentPath, pathname);
517
488
  }
518
- resultAnchor = resultAnchor.replace(root, "").replace(/\.(md|ya?ml|html)$/i, "").replace(new RegExp(import_lodash.default.escapeRegExp(import_path3.sep), "gi"), "_");
489
+ resultAnchor = resultAnchor.replace(root, "").replace(/\.(md|ya?ml|html)$/i, "").replace(new RegExp((0, import_escapeRegExp.default)(import_path3.sep), "gi"), "_");
519
490
  if (hash) {
520
491
  resultAnchor = resultAnchor + "_" + hash.slice(1);
521
492
  }
@@ -537,8 +508,9 @@ function preprocessPageHtmlForSinglePage(content, options) {
537
508
  }
538
509
 
539
510
  // src/utils/markup.ts
540
- var import_client = require("@diplodoc/client");
541
- var import_client2 = __toESM(require_client());
511
+ var import_ssr = require("@diplodoc/client/ssr");
512
+ var import_manifest = __toESM(require("@diplodoc/client/manifest"));
513
+ var dst = (bundlePath) => (target) => (0, import_path4.join)(bundlePath, target);
542
514
  function generateStaticMarkup(props, pathToBundle) {
543
515
  const { title: metaTitle, style, script } = props.data.meta || {};
544
516
  const { title: tocTitle } = props.data.toc;
@@ -550,7 +522,7 @@ function generateStaticMarkup(props, pathToBundle) {
550
522
  });
551
523
  const resources = getResources({ style, script });
552
524
  const { staticContent } = argv_default.getConfig();
553
- const html = staticContent ? (0, import_client.render)(props) : "";
525
+ const html = staticContent ? (0, import_ssr.render)(props) : "";
554
526
  return `
555
527
  <!DOCTYPE html>
556
528
  <html lang="${props.lang}">
@@ -564,7 +536,7 @@ function generateStaticMarkup(props, pathToBundle) {
564
536
  height: 100vh;
565
537
  }
566
538
  </style>
567
- <link type="text/css" rel="stylesheet" href="${import_client2.default.bundle.css(pathToBundle)}" />
539
+ ${import_manifest.default.css.map(dst(pathToBundle)).map((src) => `<link type="text/css" rel="stylesheet" href="${src}" />`).join("\n")}
568
540
  ${plugins_exports.getHeadContent()}
569
541
  ${resources}
570
542
  </head>
@@ -574,9 +546,9 @@ function generateStaticMarkup(props, pathToBundle) {
574
546
  window.STATIC_CONTENT = ${staticContent}
575
547
  window.__DATA__ = ${JSON.stringify(props)};
576
548
  </script>
577
- <script type="application/javascript" src="${import_client2.default.bundle.js(
578
- pathToBundle
579
- )}"></script>
549
+ ${import_manifest.default.js.map(dst(pathToBundle)).map(
550
+ (src) => `<script type="application/javascript" src="${src}"></script>`
551
+ ).join("\n")}
580
552
  </body>
581
553
  </html>
582
554
  `;
@@ -618,7 +590,7 @@ function getResources({ style, script }) {
618
590
  }
619
591
  var \u0441arriage = import_process.platform === "win32" /* WINDOWS */ ? "\r\n" : "\n";
620
592
  function joinSinglePageResults(singlePageResults2, root, tocDir) {
621
- const delimeter = `${\u0441arriage}${\u0441arriage}<hr class="yfm-page__delimeter">${\u0441arriage}${\u0441arriage}`;
593
+ const delimeter = `<hr class="yfm-page__delimeter">`;
622
594
  return singlePageResults2.filter(({ content }) => content).map(
623
595
  ({ content, path, title }) => preprocessPageHtmlForSinglePage(content, { root, path, tocDir, title })
624
596
  ).join(delimeter);
@@ -628,9 +600,9 @@ function replaceDoubleToSingleQuotes(str) {
628
600
  }
629
601
 
630
602
  // src/utils/path.ts
631
- var import_path4 = require("path");
603
+ var import_path5 = require("path");
632
604
  function addSlashPrefix(path) {
633
- const slashPrefix = path.startsWith(import_path4.sep) ? "" : import_path4.sep;
605
+ const slashPrefix = path.startsWith(import_path5.sep) ? "" : import_path5.sep;
634
606
  return `${slashPrefix}${path}`;
635
607
  }
636
608
  function convertBackSlashToSlash(path) {
@@ -641,7 +613,7 @@ function convertBackSlashToSlash(path) {
641
613
  }
642
614
 
643
615
  // src/utils/toc.ts
644
- var import_path5 = require("path");
616
+ var import_path6 = require("path");
645
617
 
646
618
  // src/services/utils.ts
647
619
  var import_evaluation = __toESM(require("@diplodoc/transform/lib/liquid/evaluation"));
@@ -767,14 +739,14 @@ function transformToc(toc, pathToFileDirectory) {
767
739
  navigationItemQueue.push(...navigationItem.items);
768
740
  }
769
741
  if (href && !isExternalHref(href)) {
770
- const pathToIndexDirectory = (0, import_path5.relative)(pathToFileDirectory, baseTocPath);
771
- const fileExtension = (0, import_path5.extname)(href);
772
- const filename = (0, import_path5.basename)(href, fileExtension);
773
- const transformedFilename = (0, import_path5.format)({
742
+ const pathToIndexDirectory = (0, import_path6.relative)(pathToFileDirectory, baseTocPath);
743
+ const fileExtension = (0, import_path6.extname)(href);
744
+ const filename = (0, import_path6.basename)(href, fileExtension);
745
+ const transformedFilename = (0, import_path6.format)({
774
746
  name: filename,
775
747
  ext: ".html"
776
748
  });
777
- navigationItem.href = (0, import_path5.join)(pathToIndexDirectory, (0, import_path5.dirname)(href), transformedFilename);
749
+ navigationItem.href = (0, import_path6.join)(pathToIndexDirectory, (0, import_path6.dirname)(href), transformedFilename);
778
750
  }
779
751
  }
780
752
  return localToc;
@@ -811,15 +783,15 @@ function transformTocForSinglePage(toc, options) {
811
783
  }
812
784
 
813
785
  // src/utils/presets.ts
814
- var import_path6 = require("path");
786
+ var import_path7 = require("path");
815
787
  function getVarsPerFile(filePath) {
816
788
  const { vars: argVars } = argv_default.getConfig();
817
- return __spreadValues(__spreadValues({}, preset_default.get((0, import_path6.dirname)(filePath))), argVars);
789
+ return __spreadValues(__spreadValues({}, preset_default.get((0, import_path7.dirname)(filePath))), argVars);
818
790
  }
819
791
  function getVarsPerRelativeFile(filePath) {
820
792
  const { input } = argv_default.getConfig();
821
- const root = (0, import_path6.resolve)(input);
822
- const relativeFilePath = (0, import_path6.relative)(root, filePath);
793
+ const root = (0, import_path7.resolve)(input);
794
+ const relativeFilePath = (0, import_path7.relative)(root, filePath);
823
795
  return getVarsPerFile(relativeFilePath);
824
796
  }
825
797
 
@@ -832,14 +804,14 @@ var glob = (pattern, options) => __async(void 0, null, function* () {
832
804
  });
833
805
 
834
806
  // src/utils/file.ts
835
- var import_path7 = require("path");
807
+ var import_path8 = require("path");
836
808
  var import_shelljs = __toESM(require("shelljs"));
837
809
  function copyFiles(inputFolderPath, outputFolderPath, files) {
838
810
  const dirs = /* @__PURE__ */ new Set();
839
811
  files.forEach((pathToAsset) => {
840
- const outputDir = (0, import_path7.resolve)(outputFolderPath, (0, import_path7.dirname)(pathToAsset));
841
- const from = (0, import_path7.resolve)(inputFolderPath, pathToAsset);
842
- const to = (0, import_path7.resolve)(outputFolderPath, pathToAsset);
812
+ const outputDir = (0, import_path8.resolve)(outputFolderPath, (0, import_path8.dirname)(pathToAsset));
813
+ const from = (0, import_path8.resolve)(inputFolderPath, pathToAsset);
814
+ const to = (0, import_path8.resolve)(outputFolderPath, pathToAsset);
843
815
  if (!dirs.has(outputDir)) {
844
816
  dirs.add(outputDir);
845
817
  import_shelljs.default.mkdir("-p", outputDir);
@@ -895,7 +867,7 @@ function getAuthorDetails(vcsConnector, author) {
895
867
 
896
868
  // src/services/contributors.ts
897
869
  var import_promises = require("fs/promises");
898
- var import_path8 = require("path");
870
+ var import_path9 = require("path");
899
871
  function getFileContributorsMetadata(fileData, vcsConnector) {
900
872
  return __async(this, null, function* () {
901
873
  const contributors = yield getFileContributorsString(fileData, vcsConnector);
@@ -965,8 +937,8 @@ function getRelativeIncludeFilePaths(fileData, includeContents) {
965
937
  const relativeIncludeFilePath = includeContent.match(REGEXP_INCLUDE_FILE_PATH);
966
938
  if (relativeIncludeFilePath && relativeIncludeFilePath.length !== 0) {
967
939
  const relativeIncludeFilePathWithoutHash = relativeIncludeFilePath[0].split("#");
968
- const includeFilePath = (0, import_path8.join)(
969
- (0, import_path8.dirname)(tmpInputFilePath),
940
+ const includeFilePath = (0, import_path9.join)(
941
+ (0, import_path9.dirname)(tmpInputFilePath),
970
942
  relativeIncludeFilePathWithoutHash[0]
971
943
  );
972
944
  relativeIncludeFilePaths.add(includeFilePath);
@@ -974,9 +946,45 @@ function getRelativeIncludeFilePaths(fileData, includeContents) {
974
946
  });
975
947
  return relativeIncludeFilePaths;
976
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
+ }
977
985
 
978
986
  // src/services/metadata.ts
979
- var import_path9 = require("path");
987
+ var import_path10 = require("path");
980
988
  function getContentWithUpdatedMetadata(fileContent, options, systemVars) {
981
989
  return __async(this, null, function* () {
982
990
  var _a;
@@ -1041,6 +1049,10 @@ function getContentWithUpdatedDynamicMetadata(fileContent, options) {
1041
1049
  if (contributorsMetaData) {
1042
1050
  newMetadatas.push(contributorsMetaData);
1043
1051
  }
1052
+ const mtimeMetadata = yield getModifiedTimeMetadataString(options, fileContent);
1053
+ if (mtimeMetadata) {
1054
+ newMetadatas.push(mtimeMetadata);
1055
+ }
1044
1056
  let authorMetadata = "";
1045
1057
  if (fileMetadata) {
1046
1058
  const matchAuthor = fileMetadata.match(REGEXP_AUTHOR);
@@ -1099,6 +1111,28 @@ function getContributorsMetadataString(options, fileContent) {
1099
1111
  return void 0;
1100
1112
  });
1101
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
+ }
1102
1136
  function getUpdatedMetadataString(newMetadatas, defaultMetadata = "") {
1103
1137
  const newMetadata = newMetadatas.join(\u0441arriage) + (newMetadatas.length ? \u0441arriage : "");
1104
1138
  const preparedDefaultMetadata = defaultMetadata.trimRight();
@@ -1147,8 +1181,8 @@ function getSystemVarsMetadataString(systemVars) {
1147
1181
  }
1148
1182
  function getAssetsPublicPath(filePath) {
1149
1183
  const { input } = argv_default.getConfig();
1150
- const path = (0, import_path9.resolve)(input, filePath);
1151
- return (0, import_path9.relative)((0, import_path9.dirname)(path), (0, import_path9.resolve)(input));
1184
+ const path = (0, import_path10.resolve)(input, filePath);
1185
+ return (0, import_path10.relative)((0, import_path10.dirname)(path), (0, import_path10.resolve)(input));
1152
1186
  }
1153
1187
 
1154
1188
  // src/services/includers/index.ts
@@ -1158,8 +1192,8 @@ __export(includers_exports, {
1158
1192
  applyIncluders: () => applyIncluders,
1159
1193
  init: () => init
1160
1194
  });
1161
- var import_path12 = require("path");
1162
- var import_lodash3 = require("lodash");
1195
+ var import_path13 = require("path");
1196
+ var import_lodash2 = require("lodash");
1163
1197
 
1164
1198
  // src/services/includers/batteries/generic.ts
1165
1199
  var generic_exports = {};
@@ -1169,8 +1203,8 @@ __export(generic_exports, {
1169
1203
  name: () => name
1170
1204
  });
1171
1205
  var import_promises2 = require("fs/promises");
1172
- var import_path10 = require("path");
1173
- var import_lodash2 = require("lodash");
1206
+ var import_path11 = require("path");
1207
+ var import_lodash = require("lodash");
1174
1208
  var import_js_yaml3 = require("js-yaml");
1175
1209
  var GenericIncluderError = class extends Error {
1176
1210
  constructor(message, path) {
@@ -1197,8 +1231,8 @@ function includerFunction(params) {
1197
1231
  }
1198
1232
  try {
1199
1233
  const leadingPageName = (_b = leadingPage == null ? void 0 : leadingPage.name) != null ? _b : "Overview";
1200
- const tocDirPath = (0, import_path10.dirname)(tocPath);
1201
- const contentPath = index === 0 ? (0, import_path10.join)(writeBasePath, tocDirPath, input) : (0, import_path10.join)(readBasePath, tocDirPath, input);
1234
+ const tocDirPath = (0, import_path11.dirname)(tocPath);
1235
+ const contentPath = index === 0 ? (0, import_path11.join)(writeBasePath, tocDirPath, input) : (0, import_path11.join)(readBasePath, tocDirPath, input);
1202
1236
  let cache = {};
1203
1237
  let found = [];
1204
1238
  ({
@@ -1209,16 +1243,16 @@ function includerFunction(params) {
1209
1243
  nocase: true,
1210
1244
  cache
1211
1245
  }));
1212
- const writePath = (0, import_path10.join)(writeBasePath, tocDirPath, item.include.path);
1246
+ const writePath = (0, import_path11.join)(writeBasePath, tocDirPath, item.include.path);
1213
1247
  yield (0, import_promises2.mkdir)(writePath, { recursive: true });
1214
1248
  for (const filePath of found) {
1215
- const file = yield (0, import_promises2.readFile)((0, import_path10.join)(contentPath, filePath));
1216
- yield (0, import_promises2.mkdir)((0, import_path10.dirname)((0, import_path10.join)(writePath, filePath)), { recursive: true });
1217
- yield (0, import_promises2.writeFile)((0, import_path10.join)(writePath, filePath), file);
1249
+ const file = yield (0, import_promises2.readFile)((0, import_path11.join)(contentPath, filePath));
1250
+ yield (0, import_promises2.mkdir)((0, import_path11.dirname)((0, import_path11.join)(writePath, filePath)), { recursive: true });
1251
+ yield (0, import_promises2.writeFile)((0, import_path11.join)(writePath, filePath), file);
1218
1252
  }
1219
1253
  const graph = createGraphFromPaths(found);
1220
1254
  const toc = createToc(leadingPageName, item.include.path)(graph, []);
1221
- yield (0, import_promises2.writeFile)((0, import_path10.join)(writePath, "toc.yaml"), (0, import_js_yaml3.dump)(toc));
1255
+ yield (0, import_promises2.writeFile)((0, import_path11.join)(writePath, "toc.yaml"), (0, import_js_yaml3.dump)(toc));
1222
1256
  } catch (err) {
1223
1257
  throw new GenericIncluderError(err.toString(), tocPath);
1224
1258
  }
@@ -1235,7 +1269,7 @@ function createGraphFromPaths(paths) {
1235
1269
  continue;
1236
1270
  }
1237
1271
  const file = chunks.pop();
1238
- (0, import_lodash2.updateWith)(
1272
+ (0, import_lodash.updateWith)(
1239
1273
  graph,
1240
1274
  chunks,
1241
1275
  (old) => {
@@ -1250,8 +1284,8 @@ function createToc(leadingPageName, tocName) {
1250
1284
  return function createTocRec(graph, cursor) {
1251
1285
  var _a, _b;
1252
1286
  const handler6 = (file) => ({
1253
- name: (0, import_path10.parse)(file).name === "index" ? leadingPageName : file,
1254
- href: (0, import_path10.join)(...cursor, file)
1287
+ name: (0, import_path11.parse)(file).name === "index" ? leadingPageName : file,
1288
+ href: (0, import_path11.join)(...cursor, file)
1255
1289
  });
1256
1290
  const recurse = (key) => createTocRec(graph[key], [...cursor, key]);
1257
1291
  const current = {
@@ -1302,7 +1336,7 @@ __export(unarchive_exports, {
1302
1336
  name: () => name3
1303
1337
  });
1304
1338
  var import_fs2 = require("fs");
1305
- var import_path11 = require("path");
1339
+ var import_path12 = require("path");
1306
1340
  var import_tar_stream = require("tar-stream");
1307
1341
  var name3 = "unarchive";
1308
1342
  var UnarchiveIncluderError = class extends Error {
@@ -1325,8 +1359,8 @@ function pipeline(readPath, writeBasePath) {
1325
1359
  (0, import_fs2.mkdirSync)(writeBasePath, { recursive: true });
1326
1360
  extractor2.on("entry", (header, stream, next) => {
1327
1361
  const { type, name: name4 } = header;
1328
- const writePath = (0, import_path11.join)(writeBasePath, name4);
1329
- const writeDirPath = type === "directory" ? writePath : (0, import_path11.dirname)(writePath);
1362
+ const writePath = (0, import_path12.join)(writeBasePath, name4);
1363
+ const writeDirPath = type === "directory" ? writePath : (0, import_path12.dirname)(writePath);
1330
1364
  (0, import_fs2.mkdirSync)(writeDirPath, { recursive: true });
1331
1365
  if (type !== "directory") {
1332
1366
  const writer3 = (0, import_fs2.createWriteStream)(writePath, { flags: "w" });
@@ -1357,8 +1391,8 @@ function includerFunction3(params) {
1357
1391
  if (!(input == null ? void 0 : input.length) || !(output == null ? void 0 : output.length)) {
1358
1392
  throw new UnarchiveIncluderError("provide includer with input parameter", tocPath);
1359
1393
  }
1360
- const contentPath = index === 0 ? (0, import_path11.join)(writeBasePath, input) : (0, import_path11.join)(readBasePath, input);
1361
- const writePath = (0, import_path11.join)(writeBasePath, output);
1394
+ const contentPath = index === 0 ? (0, import_path12.join)(writeBasePath, input) : (0, import_path12.join)(readBasePath, input);
1395
+ const writePath = (0, import_path12.join)(writeBasePath, output);
1362
1396
  try {
1363
1397
  yield pipeline(contentPath, writePath);
1364
1398
  } catch (err) {
@@ -1415,7 +1449,7 @@ function applyIncluders(path, item, vars) {
1415
1449
  const passedParams = __spreadValues({}, rest);
1416
1450
  yield applyIncluder({ path, item, includer, passedParams, index, vars });
1417
1451
  }
1418
- item.include.path = (0, import_path12.join)(item.include.path, "toc.yaml");
1452
+ item.include.path = (0, import_path13.join)(item.include.path, "toc.yaml");
1419
1453
  index++;
1420
1454
  });
1421
1455
  }
@@ -1433,7 +1467,7 @@ function includersValid(includers) {
1433
1467
  return { status: true };
1434
1468
  }
1435
1469
  function includerValid(includer) {
1436
- if ((0, import_lodash3.isObject)(includer)) {
1470
+ if ((0, import_lodash2.isObject)(includer)) {
1437
1471
  if (typeof includer.name !== "string") {
1438
1472
  return {
1439
1473
  status: false,
@@ -1478,6 +1512,7 @@ function applyIncluder(args) {
1478
1512
  var storage = /* @__PURE__ */ new Map();
1479
1513
  var navigationPaths = [];
1480
1514
  var includedTocPaths = /* @__PURE__ */ new Set();
1515
+ var tocFileCopyMap = /* @__PURE__ */ new Map();
1481
1516
  function add(path) {
1482
1517
  return __async(this, null, function* () {
1483
1518
  const {
@@ -1487,8 +1522,8 @@ function add(path) {
1487
1522
  ignoreStage,
1488
1523
  vars
1489
1524
  } = argv_default.getConfig();
1490
- const pathToDir = (0, import_path13.dirname)(path);
1491
- const content = (0, import_fs3.readFileSync)((0, import_path13.resolve)(inputFolderPath, path), "utf8");
1525
+ const pathToDir = (0, import_path14.dirname)(path);
1526
+ const content = (0, import_fs3.readFileSync)((0, import_path14.resolve)(inputFolderPath, path), "utf8");
1492
1527
  const parsedToc = (0, import_js_yaml4.load)(content);
1493
1528
  if (parsedToc.stage === ignoreStage) {
1494
1529
  return;
@@ -1505,16 +1540,16 @@ function add(path) {
1505
1540
  parsedToc.items = yield processTocItems(
1506
1541
  path,
1507
1542
  parsedToc.items,
1508
- (0, import_path13.join)(inputFolderPath, pathToDir),
1509
- (0, import_path13.resolve)(inputFolderPath),
1543
+ (0, import_path14.join)(inputFolderPath, pathToDir),
1544
+ (0, import_path14.resolve)(inputFolderPath),
1510
1545
  combinedVars
1511
1546
  );
1512
1547
  storage.set(path, parsedToc);
1513
1548
  parsedToc.base = pathToDir;
1514
1549
  if (outputFormat === "md") {
1515
- const outputPath = (0, import_path13.resolve)(outputFolderPath, path);
1550
+ const outputPath = (0, import_path14.resolve)(outputFolderPath, path);
1516
1551
  const outputToc = (0, import_js_yaml4.dump)(parsedToc);
1517
- import_shelljs2.default.mkdir("-p", (0, import_path13.dirname)(outputPath));
1552
+ import_shelljs2.default.mkdir("-p", (0, import_path14.dirname)(outputPath));
1518
1553
  (0, import_fs3.writeFileSync)(outputPath, outputToc);
1519
1554
  }
1520
1555
  prepareNavigationPaths(parsedToc, pathToDir);
@@ -1557,7 +1592,7 @@ function prepareNavigationPaths(parsedToc, dirPath) {
1557
1592
  processItems(preparedSubItems, pathToDir);
1558
1593
  }
1559
1594
  if (item.href && !isExternalHref(item.href)) {
1560
- const href = (0, import_path13.join)(pathToDir, item.href);
1595
+ const href = (0, import_path14.join)(pathToDir, item.href);
1561
1596
  storage.set(href, parsedToc);
1562
1597
  const navigationPath = _normalizeHref(href);
1563
1598
  navigationPaths.push(navigationPath);
@@ -1567,32 +1602,32 @@ function prepareNavigationPaths(parsedToc, dirPath) {
1567
1602
  processItems([parsedToc], dirPath);
1568
1603
  }
1569
1604
  function _normalizeHref(href) {
1570
- const preparedHref = (0, import_path13.normalize)(href);
1605
+ const preparedHref = (0, import_path14.normalize)(href);
1571
1606
  if (preparedHref.endsWith(".md") || preparedHref.endsWith(".yaml")) {
1572
1607
  return preparedHref;
1573
1608
  }
1574
- if (preparedHref.endsWith(import_path13.sep)) {
1609
+ if (preparedHref.endsWith(import_path14.sep)) {
1575
1610
  return `${preparedHref}index.yaml`;
1576
1611
  }
1577
1612
  return `${preparedHref}.md`;
1578
1613
  }
1579
1614
  function _copyTocDir(tocPath, destDir) {
1580
1615
  const { input: inputFolderPath } = argv_default.getConfig();
1581
- const { dir: tocDir } = (0, import_path13.parse)(tocPath);
1616
+ const { dir: tocDir } = (0, import_path14.parse)(tocPath);
1582
1617
  const files = (0, import_walk_sync.default)(tocDir, {
1583
1618
  globs: ["**/*.*"],
1584
1619
  ignore: ["**/toc.yaml"],
1585
1620
  directories: false
1586
1621
  });
1587
1622
  files.forEach((relPath) => {
1588
- const from = (0, import_path13.resolve)(tocDir, relPath);
1589
- const to = (0, import_path13.resolve)(destDir, relPath);
1590
- const fileExtension = (0, import_path13.extname)(relPath);
1623
+ const from = (0, import_path14.resolve)(tocDir, relPath);
1624
+ const to = (0, import_path14.resolve)(destDir, relPath);
1625
+ const fileExtension = (0, import_path14.extname)(relPath);
1591
1626
  const isMdFile = fileExtension === ".md";
1592
- import_shelljs2.default.mkdir("-p", (0, import_path13.parse)(to).dir);
1627
+ import_shelljs2.default.mkdir("-p", (0, import_path14.parse)(to).dir);
1593
1628
  if (isMdFile) {
1594
1629
  const fileContent = (0, import_fs3.readFileSync)(from, "utf8");
1595
- const sourcePath = (0, import_path13.relative)(inputFolderPath, from);
1630
+ const sourcePath = (0, import_path14.relative)(inputFolderPath, from);
1596
1631
  const updatedFileContent = getContentWithUpdatedStaticMetadata({
1597
1632
  fileContent,
1598
1633
  sourcePath,
@@ -1602,19 +1637,22 @@ function _copyTocDir(tocPath, destDir) {
1602
1637
  } else {
1603
1638
  import_shelljs2.default.cp(from, to);
1604
1639
  }
1640
+ const relFrom = (0, import_path14.relative)(inputFolderPath, from);
1641
+ const relTo = (0, import_path14.relative)(inputFolderPath, to);
1642
+ tocFileCopyMap.set(relTo, relFrom);
1605
1643
  });
1606
1644
  }
1607
1645
  function _replaceIncludesHrefs(items, includeTocDir, tocDir) {
1608
1646
  return items.reduce((acc, tocItem) => {
1609
1647
  if (tocItem.href) {
1610
- tocItem.href = (0, import_path13.relative)(tocDir, (0, import_path13.resolve)(includeTocDir, tocItem.href));
1648
+ tocItem.href = (0, import_path14.relative)(tocDir, (0, import_path14.resolve)(includeTocDir, tocItem.href));
1611
1649
  }
1612
1650
  if (tocItem.items) {
1613
1651
  tocItem.items = _replaceIncludesHrefs(tocItem.items, includeTocDir, tocDir);
1614
1652
  }
1615
1653
  if (tocItem.include) {
1616
1654
  const { path } = tocItem.include;
1617
- tocItem.include.path = (0, import_path13.relative)(tocDir, (0, import_path13.resolve)(includeTocDir, path));
1655
+ tocItem.include.path = (0, import_path14.relative)(tocDir, (0, import_path14.resolve)(includeTocDir, path));
1618
1656
  }
1619
1657
  return acc.concat(tocItem);
1620
1658
  }, []);
@@ -1638,7 +1676,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
1638
1676
  for (const item of items) {
1639
1677
  let includedInlineItems = null;
1640
1678
  if (item.name) {
1641
- const tocPath = (0, import_path13.join)(tocDir, "toc.yaml");
1679
+ const tocPath = (0, import_path14.join)(tocDir, "toc.yaml");
1642
1680
  item.name = _liquidSubstitutions(item.name, vars, tocPath);
1643
1681
  }
1644
1682
  try {
@@ -1652,8 +1690,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
1652
1690
  }
1653
1691
  if (item.include) {
1654
1692
  const { mode = "root_merge" /* ROOT_MERGE */ } = item.include;
1655
- const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0, import_path13.resolve)(sourcesDir, item.include.path) : (0, import_path13.resolve)(tocDir, item.include.path);
1656
- const includeTocDir = (0, import_path13.dirname)(includeTocPath);
1693
+ const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0, import_path14.resolve)(sourcesDir, item.include.path) : (0, import_path14.resolve)(tocDir, item.include.path);
1694
+ const includeTocDir = (0, import_path14.dirname)(includeTocPath);
1657
1695
  try {
1658
1696
  const includeToc = (0, import_js_yaml4.load)((0, import_fs3.readFileSync)(includeTocPath, "utf8"));
1659
1697
  if (includeToc.stage === "tech-preview" /* TECH_PREVIEW */) {
@@ -1686,7 +1724,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
1686
1724
  }
1687
1725
  } catch (err) {
1688
1726
  const message = `Error while including toc: ${(0, import_chalk2.bold)(includeTocPath)} to ${(0, import_chalk2.bold)(
1689
- (0, import_path13.join)(tocDir, "toc.yaml")
1727
+ (0, import_path14.join)(tocDir, "toc.yaml")
1690
1728
  )}`;
1691
1729
  import_log3.default.error(message);
1692
1730
  continue;
@@ -1707,8 +1745,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
1707
1745
  }
1708
1746
  function getTocDir(pagePath) {
1709
1747
  const { input: inputFolderPath } = argv_default.getConfig();
1710
- const tocDir = (0, import_path13.dirname)(pagePath);
1711
- const tocPath = (0, import_path13.resolve)(tocDir, "toc.yaml");
1748
+ const tocDir = (0, import_path14.dirname)(pagePath);
1749
+ const tocPath = (0, import_path14.resolve)(tocDir, "toc.yaml");
1712
1750
  if (!tocDir.includes(inputFolderPath)) {
1713
1751
  throw new Error("Error while finding toc dir");
1714
1752
  }
@@ -1720,29 +1758,33 @@ function getTocDir(pagePath) {
1720
1758
  function setNavigationPaths(paths) {
1721
1759
  navigationPaths = paths;
1722
1760
  }
1761
+ function getCopyFileMap() {
1762
+ return tocFileCopyMap;
1763
+ }
1723
1764
  var tocs_default = {
1724
1765
  add,
1725
1766
  getForPath,
1726
1767
  getNavigationPaths,
1727
1768
  getTocDir,
1728
1769
  getIncludedTocPaths,
1729
- setNavigationPaths
1770
+ setNavigationPaths,
1771
+ getCopyFileMap
1730
1772
  };
1731
1773
 
1732
1774
  // src/services/preset.ts
1733
- var import_path14 = require("path");
1775
+ var import_path15 = require("path");
1734
1776
  var presetStorage = /* @__PURE__ */ new Map();
1735
1777
  function add2(parsedPreset, path, varsPreset) {
1736
1778
  const combinedValues = __spreadValues(__spreadValues({}, parsedPreset.default || {}), parsedPreset[varsPreset] || {});
1737
- const key = (0, import_path14.dirname)((0, import_path14.normalize)(path));
1779
+ const key = (0, import_path15.dirname)((0, import_path15.normalize)(path));
1738
1780
  presetStorage.set(key, combinedValues);
1739
1781
  }
1740
1782
  function get(path) {
1741
1783
  let combinedValues = {};
1742
- let localPath = (0, import_path14.normalize)(path);
1784
+ let localPath = (0, import_path15.normalize)(path);
1743
1785
  while (localPath !== ".") {
1744
1786
  const presetValues = presetStorage.get(localPath) || {};
1745
- localPath = (0, import_path14.dirname)(localPath);
1787
+ localPath = (0, import_path15.dirname)(localPath);
1746
1788
  combinedValues = __spreadValues(__spreadValues({}, presetValues), combinedValues);
1747
1789
  }
1748
1790
  combinedValues = __spreadValues(__spreadValues({}, presetStorage.get(".")), combinedValues);
@@ -1762,7 +1804,7 @@ var preset_default = {
1762
1804
  };
1763
1805
 
1764
1806
  // src/services/argv.ts
1765
- var import_path15 = require("path");
1807
+ var import_path16 = require("path");
1766
1808
  var import_fs4 = require("fs");
1767
1809
  var _argv;
1768
1810
  function getConfig() {
@@ -1776,7 +1818,7 @@ function init2(argv) {
1776
1818
  _argv.vars = JSON.parse(argv.vars);
1777
1819
  }
1778
1820
  try {
1779
- const ignorefile = (0, import_fs4.readFileSync)((0, import_path15.join)(_argv.rootInput, ".yfmignore"), "utf8");
1821
+ const ignorefile = (0, import_fs4.readFileSync)((0, import_path16.join)(_argv.rootInput, ".yfmignore"), "utf8");
1780
1822
  const ignore = ignorefile.split("\n");
1781
1823
  _argv.ignore = _argv.ignore.concat(ignore);
1782
1824
  } catch (e) {
@@ -1792,15 +1834,15 @@ var argv_default = {
1792
1834
  };
1793
1835
 
1794
1836
  // src/services/leading.ts
1795
- var import_path16 = require("path");
1837
+ var import_path17 = require("path");
1796
1838
  var import_fs5 = require("fs");
1797
1839
  var import_js_yaml5 = require("js-yaml");
1798
1840
  var import_log4 = __toESM(require("@diplodoc/transform/lib/log"));
1799
1841
  function filterFile(path) {
1800
1842
  var _a, _b;
1801
1843
  const { input: inputFolderPath, vars } = argv_default.getConfig();
1802
- const pathToDir = (0, import_path16.dirname)(path);
1803
- const filePath = (0, import_path16.resolve)(inputFolderPath, path);
1844
+ const pathToDir = (0, import_path17.dirname)(path);
1845
+ const filePath = (0, import_path17.resolve)(inputFolderPath, path);
1804
1846
  const content = (0, import_fs5.readFileSync)(filePath, "utf8");
1805
1847
  const parsedIndex = (0, import_js_yaml5.load)(content);
1806
1848
  const combinedVars = __spreadValues(__spreadValues({}, preset_default.get(pathToDir)), vars);
@@ -1928,7 +1970,6 @@ var import_includer = __toESM(require("@diplodoc/openapi-extension/includer"));
1928
1970
  // src/steps/processAssets.ts
1929
1971
  var import_walk_sync2 = __toESM(require("walk-sync"));
1930
1972
  var import_shelljs3 = __toESM(require("shelljs"));
1931
- var import_client3 = __toESM(require_client());
1932
1973
  function processAssets(outputBundlePath) {
1933
1974
  const { input: inputFolderPath, output: outputFolderPath } = argv_default.getConfig();
1934
1975
  const assetFilePath = (0, import_walk_sync2.default)(inputFolderPath, {
@@ -1938,13 +1979,11 @@ function processAssets(outputBundlePath) {
1938
1979
  });
1939
1980
  copyFiles(inputFolderPath, outputFolderPath, assetFilePath);
1940
1981
  import_shelljs3.default.mkdir("-p", outputBundlePath);
1941
- for (const path of Object.values(import_client3.default.dst)) {
1942
- import_shelljs3.default.cp(path, outputBundlePath);
1943
- }
1982
+ import_shelljs3.default.cp(ASSETS_FOLDER + "/*", outputBundlePath);
1944
1983
  }
1945
1984
 
1946
1985
  // src/steps/processExcludedFiles.ts
1947
- var import_path17 = require("path");
1986
+ var import_path18 = require("path");
1948
1987
  var import_walk_sync3 = __toESM(require("walk-sync"));
1949
1988
  var import_shelljs4 = __toESM(require("shelljs"));
1950
1989
  function processExcludedFiles() {
@@ -1957,14 +1996,14 @@ function processExcludedFiles() {
1957
1996
  ignore: ["**/_*/**/*"]
1958
1997
  });
1959
1998
  const navigationPaths2 = tocs_default.getNavigationPaths().map(
1960
- (filePath) => convertBackSlashToSlash((0, import_path17.resolve)(inputFolderPath, filePath))
1999
+ (filePath) => convertBackSlashToSlash((0, import_path18.resolve)(inputFolderPath, filePath))
1961
2000
  );
1962
2001
  const tocSpecifiedFiles = new Set(navigationPaths2);
1963
2002
  const excludedFiles = allContentFiles.filter((filePath) => !tocSpecifiedFiles.has(filePath));
1964
2003
  import_shelljs4.default.rm("-f", excludedFiles);
1965
2004
  const includedTocPaths2 = tocs_default.getIncludedTocPaths().map((filePath) => {
1966
- const relativeTocPath = (0, import_path17.relative)(inputFolderPath, filePath);
1967
- const destTocPath = (0, import_path17.resolve)(outputFolderPath, relativeTocPath);
2005
+ const relativeTocPath = (0, import_path18.relative)(inputFolderPath, filePath);
2006
+ const destTocPath = (0, import_path18.resolve)(outputFolderPath, relativeTocPath);
1968
2007
  return convertBackSlashToSlash(destTocPath);
1969
2008
  });
1970
2009
  import_shelljs4.default.rm("-rf", includedTocPaths2);
@@ -1984,7 +2023,7 @@ function processLogs(inputFolder) {
1984
2023
  }
1985
2024
 
1986
2025
  // src/steps/processPages.ts
1987
- var import_path22 = require("path");
2026
+ var import_path23 = require("path");
1988
2027
  var import_shelljs6 = __toESM(require("shelljs"));
1989
2028
  var import_fs9 = require("fs");
1990
2029
  var import_chalk4 = require("chalk");
@@ -1994,7 +2033,7 @@ var import_log11 = __toESM(require("@diplodoc/transform/lib/log"));
1994
2033
 
1995
2034
  // src/resolvers/md2md.ts
1996
2035
  var import_fs6 = require("fs");
1997
- var import_path18 = require("path");
2036
+ var import_path19 = require("path");
1998
2037
  var import_shelljs5 = __toESM(require("shelljs"));
1999
2038
  var import_log6 = __toESM(require("@diplodoc/transform/lib/log"));
2000
2039
  var import_liquid3 = __toESM(require("@diplodoc/transform/lib/liquid"));
@@ -2002,7 +2041,7 @@ function resolveMd2Md(options) {
2002
2041
  return __async(this, null, function* () {
2003
2042
  const { inputPath, outputPath, metadata } = options;
2004
2043
  const { input, output } = argv_default.getConfig();
2005
- const resolvedInputPath = (0, import_path18.resolve)(input, inputPath);
2044
+ const resolvedInputPath = (0, import_path19.resolve)(input, inputPath);
2006
2045
  const vars = getVarsPerFile(inputPath);
2007
2046
  const content = yield getContentWithUpdatedMetadata(
2008
2047
  (0, import_fs6.readFileSync)(resolvedInputPath, "utf8"),
@@ -2012,8 +2051,8 @@ function resolveMd2Md(options) {
2012
2051
  const { result, changelogs } = transformMd2Md(content, {
2013
2052
  path: resolvedInputPath,
2014
2053
  destPath: outputPath,
2015
- root: (0, import_path18.resolve)(input),
2016
- destRoot: (0, import_path18.resolve)(output),
2054
+ root: (0, import_path19.resolve)(input),
2055
+ destRoot: (0, import_path19.resolve)(output),
2017
2056
  collectOfPlugins: plugins_exports.getCollectOfPlugins(),
2018
2057
  vars,
2019
2058
  log: import_log6.default,
@@ -2021,8 +2060,8 @@ function resolveMd2Md(options) {
2021
2060
  });
2022
2061
  (0, import_fs6.writeFileSync)(outputPath, result);
2023
2062
  if (changelogs == null ? void 0 : changelogs.length) {
2024
- const mdFilename = (0, import_path18.basename)(outputPath, (0, import_path18.extname)(outputPath));
2025
- const outputDir = (0, import_path18.dirname)(outputPath);
2063
+ const mdFilename = (0, import_path19.basename)(outputPath, (0, import_path19.extname)(outputPath));
2064
+ const outputDir = (0, import_path19.dirname)(outputPath);
2026
2065
  changelogs.forEach((changes, index) => {
2027
2066
  let changesName;
2028
2067
  const changesDate = changes.date;
@@ -2039,7 +2078,7 @@ function resolveMd2Md(options) {
2039
2078
  "0"
2040
2079
  )}`;
2041
2080
  }
2042
- const changesPath = (0, import_path18.join)(outputDir, `changes-${changesName}.json`);
2081
+ const changesPath = (0, import_path19.join)(outputDir, `changes-${changesName}.json`);
2043
2082
  if ((0, import_fs6.existsSync)(changesPath)) {
2044
2083
  throw new Error(`Changelog ${changesPath} already exists!`);
2045
2084
  }
@@ -2056,7 +2095,7 @@ function resolveMd2Md(options) {
2056
2095
  });
2057
2096
  }
2058
2097
  function copyFile(targetPath, targetDestPath, options) {
2059
- import_shelljs5.default.mkdir("-p", (0, import_path18.dirname)(targetDestPath));
2098
+ import_shelljs5.default.mkdir("-p", (0, import_path19.dirname)(targetDestPath));
2060
2099
  if (options) {
2061
2100
  const sourceIncludeContent = (0, import_fs6.readFileSync)(targetPath, "utf8");
2062
2101
  const { result } = transformMd2Md(sourceIncludeContent, options);
@@ -2115,7 +2154,7 @@ function transformMd2Md(input, options) {
2115
2154
  }
2116
2155
 
2117
2156
  // src/resolvers/md2html.ts
2118
- var import_path19 = require("path");
2157
+ var import_path20 = require("path");
2119
2158
  var import_fs7 = require("fs");
2120
2159
  var import_js_yaml6 = __toESM(require("js-yaml"));
2121
2160
  var import_transform = __toESM(require("@diplodoc/transform"));
@@ -2126,22 +2165,25 @@ var FileTransformer = {
2126
2165
  ".md": MdFileTransformer
2127
2166
  };
2128
2167
  var fixRelativePath = (relativeTo) => (path) => {
2129
- return (0, import_path19.join)(getAssetsPublicPath(relativeTo), path);
2168
+ return (0, import_path20.join)(getAssetsPublicPath(relativeTo), path);
2130
2169
  };
2131
2170
  function resolveMd2HTML(options) {
2132
2171
  return __async(this, null, function* () {
2133
2172
  var _a;
2134
2173
  const { inputPath, fileExtension, outputPath, outputBundlePath, metadata } = options;
2135
- const pathToDir = (0, import_path19.dirname)(inputPath);
2174
+ const pathToDir = (0, import_path20.dirname)(inputPath);
2136
2175
  const toc = tocs_default.getForPath(inputPath) || null;
2137
2176
  const tocBase = toc && toc.base ? toc.base : "";
2138
- const pathToFileDir = pathToDir === tocBase ? "" : pathToDir.replace(`${tocBase}${import_path19.sep}`, "");
2139
- const relativePathToIndex = (0, import_path19.relative)(pathToDir, `${tocBase}${import_path19.sep}`);
2177
+ const pathToFileDir = pathToDir === tocBase ? "" : pathToDir.replace(`${tocBase}${import_path20.sep}`, "");
2178
+ const relativePathToIndex = (0, import_path20.relative)(pathToDir, `${tocBase}${import_path20.sep}`);
2140
2179
  const { input, lang, allowCustomResources } = argv_default.getConfig();
2141
- const resolvedPath = (0, import_path19.resolve)(input, inputPath);
2180
+ const resolvedPath = (0, import_path20.resolve)(input, inputPath);
2142
2181
  const content = (0, import_fs7.readFileSync)(resolvedPath, "utf8");
2143
2182
  const transformFn = FileTransformer[fileExtension];
2144
2183
  const { result } = transformFn(content, { path: inputPath });
2184
+ if (result.html) {
2185
+ result.html = result.html.replace(/\n+/gm, "");
2186
+ }
2145
2187
  const updatedMetadata = metadata && metadata.isContributorsEnabled ? yield getUpdatedMetadata(metadata, content, result == null ? void 0 : result.meta) : result.meta;
2146
2188
  const fileMeta = fileExtension === ".yaml" ? (_a = result.data.meta) != null ? _a : {} : updatedMetadata;
2147
2189
  if (allowCustomResources) {
@@ -2160,12 +2202,12 @@ function resolveMd2HTML(options) {
2160
2202
  meta: fileMeta
2161
2203
  }),
2162
2204
  router: {
2163
- pathname: (0, import_path19.join)(relativePathToIndex, pathToFileDir, (0, import_path19.basename)(outputPath))
2205
+ pathname: (0, import_path20.join)(relativePathToIndex, pathToFileDir, (0, import_path20.basename)(outputPath))
2164
2206
  },
2165
2207
  lang: lang || "ru" /* RU */
2166
2208
  };
2167
- const outputDir = (0, import_path19.dirname)(outputPath);
2168
- const relativePathToBundle = (0, import_path19.relative)((0, import_path19.resolve)(outputDir), (0, import_path19.resolve)(outputBundlePath));
2209
+ const outputDir = (0, import_path20.dirname)(outputPath);
2210
+ const relativePathToBundle = (0, import_path20.relative)((0, import_path20.resolve)(outputDir), (0, import_path20.resolve)(outputBundlePath));
2169
2211
  const outputFileContent = generateStaticMarkup(props, relativePathToBundle);
2170
2212
  (0, import_fs7.writeFileSync)(outputPath, outputFileContent);
2171
2213
  logger.info(inputPath, PROCESSING_FINISHED);
@@ -2207,8 +2249,8 @@ function MdFileTransformer(content, transformOptions) {
2207
2249
  const { path: filePath } = transformOptions;
2208
2250
  const plugins2 = plugins_exports.getPlugins();
2209
2251
  const vars = getVarsPerFile(filePath);
2210
- const root = (0, import_path19.resolve)(input);
2211
- const path = (0, import_path19.resolve)(input, filePath);
2252
+ const root = (0, import_path20.resolve)(input);
2253
+ const path = (0, import_path20.resolve)(input, filePath);
2212
2254
  return (0, import_transform.default)(content, __spreadProps(__spreadValues({}, options), {
2213
2255
  plugins: plugins2,
2214
2256
  vars,
@@ -2221,7 +2263,7 @@ function MdFileTransformer(content, transformOptions) {
2221
2263
  }
2222
2264
 
2223
2265
  // src/resolvers/lintPage.ts
2224
- var import_path20 = require("path");
2266
+ var import_path21 = require("path");
2225
2267
  var import_log8 = __toESM(require("@diplodoc/transform/lib/log"));
2226
2268
  var import_yfmlint = __toESM(require("@diplodoc/transform/lib/yfmlint"));
2227
2269
  var import_fs8 = require("fs");
@@ -2232,7 +2274,7 @@ var FileLinter = {
2232
2274
  function lintPage(options) {
2233
2275
  const { inputPath, fileExtension, onFinish } = options;
2234
2276
  const { input } = argv_default.getConfig();
2235
- const resolvedPath = (0, import_path20.resolve)(input, inputPath);
2277
+ const resolvedPath = (0, import_path21.resolve)(input, inputPath);
2236
2278
  try {
2237
2279
  const content = (0, import_fs8.readFileSync)(resolvedPath, "utf8");
2238
2280
  const lintFn = FileLinter[fileExtension];
@@ -2254,10 +2296,10 @@ function MdFileLinter(content, lintOptions) {
2254
2296
  const { path: filePath } = lintOptions;
2255
2297
  const plugins2 = outputFormat === "md" ? [] : plugins_exports.getPlugins();
2256
2298
  const vars = getVarsPerFile(filePath);
2257
- const root = (0, import_path20.resolve)(input);
2258
- const path = (0, import_path20.resolve)(input, filePath);
2299
+ const root = (0, import_path21.resolve)(input);
2300
+ const path = (0, import_path21.resolve)(input, filePath);
2259
2301
  let preparedContent = content;
2260
- const assetsPublicPath = (0, import_path20.relative)((0, import_path20.dirname)(path), root);
2302
+ const assetsPublicPath = (0, import_path21.relative)((0, import_path21.dirname)(path), root);
2261
2303
  const lintMarkdown = function lintMarkdown2(opts) {
2262
2304
  const { input: localInput, path: localPath, sourceMap: sourceMap2 } = opts;
2263
2305
  const pluginOptions = __spreadProps(__spreadValues({}, options), {
@@ -2301,7 +2343,7 @@ function MdFileLinter(content, lintOptions) {
2301
2343
 
2302
2344
  // src/vcs-connector/github.ts
2303
2345
  var import_core = require("@octokit/core");
2304
- var import_path21 = require("path");
2346
+ var import_path22 = require("path");
2305
2347
  var import_simple_git = __toESM(require("simple-git"));
2306
2348
  var import_minimatch = require("minimatch");
2307
2349
 
@@ -2451,9 +2493,10 @@ var authorByPath = /* @__PURE__ */ new Map();
2451
2493
  var contributorsByPath = /* @__PURE__ */ new Map();
2452
2494
  var contributorsData = /* @__PURE__ */ new Map();
2453
2495
  var loginUserMap = /* @__PURE__ */ new Map();
2496
+ var pathMTime = /* @__PURE__ */ new Map();
2454
2497
  function getGitHubVCSConnector() {
2455
2498
  return __async(this, null, function* () {
2456
- const { contributors } = argv_default.getConfig();
2499
+ const { contributors, rootInput } = argv_default.getConfig();
2457
2500
  const httpClientByToken = getHttpClientByToken();
2458
2501
  if (!httpClientByToken) {
2459
2502
  return void 0;
@@ -2466,6 +2509,7 @@ function getGitHubVCSConnector() {
2466
2509
  return (_a = authorByPath.get(path)) != null ? _a : null;
2467
2510
  };
2468
2511
  if (contributors) {
2512
+ yield getFilesMTime(rootInput, pathMTime);
2469
2513
  yield getAllContributorsTocFiles(httpClientByToken);
2470
2514
  addNestedContributorsForPath = (path, nestedContributors) => addNestedContributorsForPathFunction(path, nestedContributors);
2471
2515
  getContributorsByPath = (path) => __async(this, null, function* () {
@@ -2476,7 +2520,8 @@ function getGitHubVCSConnector() {
2476
2520
  getExternalAuthorByPath,
2477
2521
  addNestedContributorsForPath,
2478
2522
  getContributorsByPath,
2479
- getUserByLogin: (login) => getUserByLogin(httpClientByToken, login)
2523
+ getUserByLogin: (login) => getUserByLogin(httpClientByToken, login),
2524
+ getModifiedTimeByPath: (filename) => pathMTime.get(filename)
2480
2525
  };
2481
2526
  });
2482
2527
  }
@@ -2515,7 +2560,7 @@ function getAllContributorsTocFiles(httpClientByToken) {
2515
2560
  "origin/master"
2516
2561
  );
2517
2562
  const fullRepoLogString = yield (0, import_simple_git.default)({
2518
- baseDir: (0, import_path21.join)(rootInput, masterDir)
2563
+ baseDir: (0, import_path22.join)(rootInput, masterDir)
2519
2564
  }).raw(
2520
2565
  "log",
2521
2566
  `${FIRST_COMMIT_FROM_ROBOT_IN_GITHUB}..HEAD`,
@@ -2525,7 +2570,7 @@ function getAllContributorsTocFiles(httpClientByToken) {
2525
2570
  const repoLogs = fullRepoLogString.split("\n\n");
2526
2571
  if (import_process2.default.env.ENABLE_EXPERIMANTAL_AUTHORS) {
2527
2572
  const fullAuthorRepoLogString = yield (0, import_simple_git.default)({
2528
- baseDir: (0, import_path21.join)(rootInput, masterDir)
2573
+ baseDir: (0, import_path22.join)(rootInput, masterDir)
2529
2574
  }).raw(
2530
2575
  "log",
2531
2576
  `${FIRST_COMMIT_FROM_ROBOT_IN_GITHUB}..HEAD`,
@@ -2622,7 +2667,7 @@ function getAuthorByPaths(commitInfo, paths, httpClientByToken) {
2622
2667
  if (!path) {
2623
2668
  continue;
2624
2669
  }
2625
- const normalizePath = (0, import_path21.normalize)(addSlashPrefix(path));
2670
+ const normalizePath = (0, import_path22.normalize)(addSlashPrefix(path));
2626
2671
  const { email, hashCommit } = commitInfo;
2627
2672
  let authorToReturn = authorByGitEmail.get(email) || null;
2628
2673
  if (!authorToReturn) {
@@ -2683,7 +2728,7 @@ function addNestedContributorsForPathFunction(path, nestedContributors) {
2683
2728
  }
2684
2729
  function addContributorForPath(paths, newContributor, hasIncludes = false) {
2685
2730
  paths.forEach((path) => {
2686
- const normalizePath = (0, import_path21.normalize)(addSlashPrefix(path));
2731
+ const normalizePath = (0, import_path22.normalize)(addSlashPrefix(path));
2687
2732
  if (!contributorsByPath.has(normalizePath)) {
2688
2733
  contributorsByPath.set(normalizePath, {
2689
2734
  contributors: newContributor,
@@ -2716,6 +2761,44 @@ function shouldAuthorBeIgnored({ email, name: name4 }) {
2716
2761
  }
2717
2762
  return false;
2718
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
+ }
2719
2802
  var github_default2 = getGitHubVCSConnector;
2720
2803
 
2721
2804
  // src/vcs-connector/index.ts
@@ -2778,14 +2861,14 @@ function processPages(outputBundlePath) {
2778
2861
  });
2779
2862
  }
2780
2863
  function getPathData(pathToFile, inputFolderPath, outputFolderPath, outputFormat, outputBundlePath) {
2781
- const pathToDir = (0, import_path22.dirname)(pathToFile);
2782
- const filename = (0, import_path22.basename)(pathToFile);
2783
- const fileExtension = (0, import_path22.extname)(pathToFile);
2784
- const fileBaseName = (0, import_path22.basename)(filename, fileExtension);
2785
- const outputDir = (0, import_path22.resolve)(outputFolderPath, pathToDir);
2864
+ const pathToDir = (0, import_path23.dirname)(pathToFile);
2865
+ const filename = (0, import_path23.basename)(pathToFile);
2866
+ const fileExtension = (0, import_path23.extname)(pathToFile);
2867
+ const fileBaseName = (0, import_path23.basename)(filename, fileExtension);
2868
+ const outputDir = (0, import_path23.resolve)(outputFolderPath, pathToDir);
2786
2869
  const outputFileName = `${fileBaseName}.${outputFormat}`;
2787
- const outputPath = (0, import_path22.resolve)(outputDir, outputFileName);
2788
- const resolvedPathToFile = (0, import_path22.resolve)(inputFolderPath, pathToFile);
2870
+ const outputPath = (0, import_path23.resolve)(outputDir, outputFileName);
2871
+ const resolvedPathToFile = (0, import_path23.resolve)(inputFolderPath, pathToFile);
2789
2872
  const outputTocDir = tocs_default.getTocDir(resolvedPathToFile);
2790
2873
  const pathData = {
2791
2874
  pathToFile,
@@ -2822,11 +2905,11 @@ function saveSinglePages(outputBundlePath) {
2822
2905
  inputFolderPath,
2823
2906
  tocDir
2824
2907
  );
2825
- const tocPath = (0, import_path22.join)((0, import_path22.relative)(inputFolderPath, tocDir), "toc.yaml");
2908
+ const tocPath = (0, import_path23.join)((0, import_path23.relative)(inputFolderPath, tocDir), "toc.yaml");
2826
2909
  const toc = tocs_default.getForPath(tocPath) || null;
2827
2910
  const preparedToc = transformTocForSinglePage(toc, {
2828
2911
  root: inputFolderPath,
2829
- currentPath: (0, import_path22.join)(tocDir, SINGLE_PAGE_FILENAME)
2912
+ currentPath: (0, import_path23.join)(tocDir, SINGLE_PAGE_FILENAME)
2830
2913
  });
2831
2914
  const pageData = {
2832
2915
  data: {
@@ -2841,10 +2924,10 @@ function saveSinglePages(outputBundlePath) {
2841
2924
  },
2842
2925
  lang: lang || "ru" /* RU */
2843
2926
  };
2844
- const outputTocDir = (0, import_path22.resolve)(outputFolderPath, (0, import_path22.relative)(inputFolderPath, tocDir));
2845
- const relativeOutputBundlePath = (0, import_path22.relative)(outputTocDir, outputBundlePath);
2846
- const singlePageFn = (0, import_path22.join)(tocDir, SINGLE_PAGE_FILENAME);
2847
- const singlePageDataFn = (0, import_path22.join)(tocDir, SINGLE_PAGE_DATA_FILENAME);
2927
+ const outputTocDir = (0, import_path23.resolve)(outputFolderPath, (0, import_path23.relative)(inputFolderPath, tocDir));
2928
+ const relativeOutputBundlePath = (0, import_path23.relative)(outputTocDir, outputBundlePath);
2929
+ const singlePageFn = (0, import_path23.join)(tocDir, SINGLE_PAGE_FILENAME);
2930
+ const singlePageDataFn = (0, import_path23.join)(tocDir, SINGLE_PAGE_DATA_FILENAME);
2848
2931
  const singlePageContent = generateStaticMarkup(pageData, relativeOutputBundlePath);
2849
2932
  (0, import_fs9.writeFileSync)(singlePageFn, singlePageContent);
2850
2933
  (0, import_fs9.writeFileSync)(singlePageDataFn, JSON.stringify(pageData));
@@ -2942,17 +3025,17 @@ function preparingPagesByOutputFormat(path, metaDataOptions, resolveConditions,
2942
3025
  }
2943
3026
  function processingYamlFile(path, metaDataOptions) {
2944
3027
  const { pathToFile, outputFolderPath, inputFolderPath } = path;
2945
- const filePath = (0, import_path22.resolve)(inputFolderPath, pathToFile);
3028
+ const filePath = (0, import_path23.resolve)(inputFolderPath, pathToFile);
2946
3029
  const content = (0, import_fs9.readFileSync)(filePath, "utf8");
2947
3030
  const parsedContent = (0, import_js_yaml7.load)(content);
2948
3031
  if (metaDataOptions.resources) {
2949
3032
  parsedContent.meta = __spreadValues(__spreadValues({}, parsedContent.meta), metaDataOptions.resources);
2950
3033
  }
2951
- (0, import_fs9.writeFileSync)((0, import_path22.resolve)(outputFolderPath, pathToFile), (0, import_js_yaml7.dump)(parsedContent));
3034
+ (0, import_fs9.writeFileSync)((0, import_path23.resolve)(outputFolderPath, pathToFile), (0, import_js_yaml7.dump)(parsedContent));
2952
3035
  }
2953
3036
  function copyFileWithoutChanges(resolvedPathToFile, outputDir, filename) {
2954
3037
  const from = resolvedPathToFile;
2955
- const to = (0, import_path22.resolve)(outputDir, filename);
3038
+ const to = (0, import_path23.resolve)(outputDir, filename);
2956
3039
  import_shelljs6.default.cp(from, to);
2957
3040
  }
2958
3041
  function processingFileToMd(path, metaDataOptions) {
@@ -2982,7 +3065,7 @@ function processingFileToHtml(path, metaDataOptions) {
2982
3065
  // src/steps/processLinter.ts
2983
3066
  var import_log12 = __toESM(require("@diplodoc/transform/lib/log"));
2984
3067
  var import_threads = require("threads");
2985
- var import_path23 = require("path");
3068
+ var import_path24 = require("path");
2986
3069
 
2987
3070
  // src/utils/worker.ts
2988
3071
  function splitOnChunks(array, chunkSize = 1e3) {
@@ -3059,7 +3142,7 @@ function lintPagesFallback(navigationPaths2) {
3059
3142
  navigationPaths2.forEach((pathToFile) => {
3060
3143
  lintPage({
3061
3144
  inputPath: pathToFile,
3062
- fileExtension: (0, import_path23.extname)(pathToFile),
3145
+ fileExtension: (0, import_path24.extname)(pathToFile),
3063
3146
  onFinish: () => {
3064
3147
  logger.info(pathToFile, LINTING_FINISHED);
3065
3148
  }
@@ -3068,7 +3151,7 @@ function lintPagesFallback(navigationPaths2) {
3068
3151
  }
3069
3152
 
3070
3153
  // src/steps/processServiceFiles.ts
3071
- var import_path24 = require("path");
3154
+ var import_path25 = require("path");
3072
3155
  var import_walk_sync4 = __toESM(require("walk-sync"));
3073
3156
  var import_fs10 = require("fs");
3074
3157
  var import_js_yaml8 = require("js-yaml");
@@ -3101,7 +3184,7 @@ function preparingPresetFiles(getFilePathsByGlobals) {
3101
3184
  const presetsFilePaths = getFilePathsByGlobals(["**/presets.yaml"]);
3102
3185
  for (const path of presetsFilePaths) {
3103
3186
  logger.proc(path);
3104
- const pathToPresetFile = (0, import_path24.resolve)(inputFolderPath, path);
3187
+ const pathToPresetFile = (0, import_path25.resolve)(inputFolderPath, path);
3105
3188
  const content = (0, import_fs10.readFileSync)(pathToPresetFile, "utf8");
3106
3189
  const parsedPreset = (0, import_js_yaml8.load)(content);
3107
3190
  preset_default.add(parsedPreset, path, varsPreset);
@@ -3116,7 +3199,7 @@ function preparingPresetFiles(getFilePathsByGlobals) {
3116
3199
  }
3117
3200
  function saveFilteredPresets(path, parsedPreset) {
3118
3201
  const { output: outputFolderPath, varsPreset = "" } = argv_default.getConfig();
3119
- const outputPath = (0, import_path24.resolve)(outputFolderPath, path);
3202
+ const outputPath = (0, import_path25.resolve)(outputFolderPath, path);
3120
3203
  const filteredPreset = {
3121
3204
  default: parsedPreset.default
3122
3205
  };
@@ -3126,7 +3209,7 @@ function saveFilteredPresets(path, parsedPreset) {
3126
3209
  const outputPreset = (0, import_js_yaml8.dump)(filteredPreset, {
3127
3210
  lineWidth: 120
3128
3211
  });
3129
- import_shelljs7.default.mkdir("-p", (0, import_path24.dirname)(outputPath));
3212
+ import_shelljs7.default.mkdir("-p", (0, import_path25.dirname)(outputPath));
3130
3213
  (0, import_fs10.writeFileSync)(outputPath, outputPreset);
3131
3214
  }
3132
3215
  function preparingTocFiles(getFilePathsByGlobals) {
@@ -3146,11 +3229,11 @@ function preparingTocFiles(getFilePathsByGlobals) {
3146
3229
 
3147
3230
  // src/steps/processMapFile.ts
3148
3231
  var import_fs11 = require("fs");
3149
- var import_path25 = require("path");
3232
+ var import_path26 = require("path");
3150
3233
  function prepareMapFile() {
3151
3234
  const { output: outputFolderPath } = argv_default.getConfig();
3152
3235
  const navigationPathsWithoutExtensions = tocs_default.getNavigationPaths().map((path) => {
3153
- let preparedPath = convertBackSlashToSlash(path.replace((0, import_path25.extname)(path), ""));
3236
+ let preparedPath = convertBackSlashToSlash(path.replace((0, import_path26.extname)(path), ""));
3154
3237
  if (preparedPath.endsWith("/index")) {
3155
3238
  preparedPath = preparedPath.substring(0, preparedPath.length - 5);
3156
3239
  }
@@ -3158,7 +3241,7 @@ function prepareMapFile() {
3158
3241
  });
3159
3242
  const navigationPaths2 = { files: [...new Set(navigationPathsWithoutExtensions)] };
3160
3243
  const filesMapBuffer = Buffer.from(JSON.stringify(navigationPaths2, null, " "), "utf8");
3161
- const mapFile = (0, import_path25.join)(outputFolderPath, "files.json");
3244
+ const mapFile = (0, import_path26.join)(outputFolderPath, "files.json");
3162
3245
  (0, import_fs11.writeFileSync)(mapFile, filesMapBuffer);
3163
3246
  }
3164
3247
 
@@ -3168,7 +3251,7 @@ var import_shelljs8 = __toESM(require("shelljs"));
3168
3251
  // src/cmd/publish/upload.ts
3169
3252
  var import_fs12 = require("fs");
3170
3253
  var import_walk_sync5 = __toESM(require("walk-sync"));
3171
- var import_path26 = require("path");
3254
+ var import_path27 = require("path");
3172
3255
  var import_client_s3 = require("@aws-sdk/client-s3");
3173
3256
  var import_mime_types = __toESM(require("mime-types"));
3174
3257
  var import_async2 = require("async");
@@ -3189,7 +3272,7 @@ function upload(props) {
3189
3272
  region,
3190
3273
  credentials: { accessKeyId, secretAccessKey }
3191
3274
  });
3192
- const filesToPublish = (0, import_walk_sync5.default)((0, import_path26.resolve)(input), {
3275
+ const filesToPublish = (0, import_walk_sync5.default)((0, import_path27.resolve)(input), {
3193
3276
  directories: false,
3194
3277
  includeBasePath: false,
3195
3278
  ignore
@@ -3205,8 +3288,8 @@ function upload(props) {
3205
3288
  new import_client_s3.PutObjectCommand({
3206
3289
  ContentType: mimeType ? mimeType : void 0,
3207
3290
  Bucket: bucket,
3208
- Key: convertBackSlashToSlash((0, import_path26.join)(prefix, pathToFile)),
3209
- Body: (0, import_fs12.createReadStream)((0, import_path26.resolve)(input, pathToFile))
3291
+ Key: convertBackSlashToSlash((0, import_path27.join)(prefix, pathToFile)),
3292
+ Body: (0, import_fs12.createReadStream)((0, import_path27.resolve)(input, pathToFile))
3210
3293
  })
3211
3294
  );
3212
3295
  } catch (error) {
@@ -3341,9 +3424,9 @@ function builder(argv) {
3341
3424
  function handler(args) {
3342
3425
  return __async(this, null, function* () {
3343
3426
  var _a;
3344
- const userOutputFolder = (0, import_path27.resolve)(args.output);
3345
- const tmpInputFolder = (0, import_path27.resolve)(args.output, TMP_INPUT_FOLDER);
3346
- const tmpOutputFolder = (0, import_path27.resolve)(args.output, TMP_OUTPUT_FOLDER);
3427
+ const userOutputFolder = (0, import_path28.resolve)(args.output);
3428
+ const tmpInputFolder = (0, import_path28.resolve)(args.output, TMP_INPUT_FOLDER);
3429
+ const tmpOutputFolder = (0, import_path28.resolve)(args.output, TMP_OUTPUT_FOLDER);
3347
3430
  try {
3348
3431
  argv_default.init(__spreadProps(__spreadValues({}, args), {
3349
3432
  rootInput: args.input,
@@ -3367,10 +3450,10 @@ function handler(args) {
3367
3450
  if (addMapFile) {
3368
3451
  prepareMapFile();
3369
3452
  }
3370
- const outputBundlePath = (0, import_path27.join)(outputFolderPath, BUNDLE_FOLDER);
3371
- const pathToConfig = args.config || (0, import_path27.join)(args.input, YFM_CONFIG_FILENAME);
3372
- const pathToRedirects = (0, import_path27.join)(args.input, REDIRECTS_FILENAME);
3373
- const pathToLintConfig = (0, import_path27.join)(args.input, LINT_CONFIG_FILENAME);
3453
+ const outputBundlePath = (0, import_path28.join)(outputFolderPath, BUNDLE_FOLDER);
3454
+ const pathToConfig = args.config || (0, import_path28.join)(args.input, YFM_CONFIG_FILENAME);
3455
+ const pathToRedirects = (0, import_path28.join)(args.input, REDIRECTS_FILENAME);
3456
+ const pathToLintConfig = (0, import_path28.join)(args.input, LINT_CONFIG_FILENAME);
3374
3457
  if (!lintDisabled) {
3375
3458
  yield initLinterWorkers();
3376
3459
  }
@@ -3385,9 +3468,9 @@ function handler(args) {
3385
3468
  processAssets(outputBundlePath);
3386
3469
  break;
3387
3470
  case "md": {
3388
- import_shelljs8.default.cp((0, import_path27.resolve)(pathToConfig), tmpOutputFolder);
3389
- import_shelljs8.default.cp((0, import_path27.resolve)(pathToRedirects), tmpOutputFolder);
3390
- import_shelljs8.default.cp((0, import_path27.resolve)(pathToLintConfig), tmpOutputFolder);
3471
+ import_shelljs8.default.cp((0, import_path28.resolve)(pathToConfig), tmpOutputFolder);
3472
+ import_shelljs8.default.cp((0, import_path28.resolve)(pathToRedirects), tmpOutputFolder);
3473
+ import_shelljs8.default.cp((0, import_path28.resolve)(pathToLintConfig), tmpOutputFolder);
3391
3474
  if (resources && allowCustomResources) {
3392
3475
  const resourcePaths = [];
3393
3476
  Object.keys(resources).forEach(
@@ -3405,7 +3488,7 @@ function handler(args) {
3405
3488
  }
3406
3489
  import_shelljs8.default.cp(
3407
3490
  "-r",
3408
- [(0, import_path27.join)(tmpOutputFolder, "*"), (0, import_path27.join)(tmpOutputFolder, ".*")],
3491
+ [(0, import_path28.join)(tmpOutputFolder, "*"), (0, import_path28.join)(tmpOutputFolder, ".*")],
3409
3492
  userOutputFolder
3410
3493
  );
3411
3494
  if (publish2) {
@@ -3458,7 +3541,7 @@ function preparingTemporaryFolders(userOutputFolder) {
3458
3541
  }
3459
3542
 
3460
3543
  // src/cmd/publish/index.ts
3461
- var import_path28 = require("path");
3544
+ var import_path29 = require("path");
3462
3545
  var command = "publish";
3463
3546
  var description = "Upload builded documentation to target S3 bucket";
3464
3547
  var publish = {
@@ -3511,10 +3594,11 @@ function builder2(argv) {
3511
3594
  function handler2(args) {
3512
3595
  return __async(this, null, function* () {
3513
3596
  argv_default.init(__spreadValues({}, args));
3514
- const { input, endpoint, bucket, prefix } = argv_default.getConfig();
3515
- logger.info("", `Upload artifacts from ${input} to ${(0, import_path28.join)(endpoint, bucket, prefix)}`);
3597
+ const config = argv_default.getConfig();
3598
+ const { input, endpoint, bucket, prefix } = config;
3599
+ logger.info("", `Upload artifacts from ${input} to ${(0, import_path29.join)(endpoint, bucket, prefix)}`);
3516
3600
  try {
3517
- yield upload(argv_default.getConfig());
3601
+ yield upload(config);
3518
3602
  } catch (error) {
3519
3603
  logger.error("", error.message);
3520
3604
  }
@@ -3522,7 +3606,7 @@ function handler2(args) {
3522
3606
  }
3523
3607
 
3524
3608
  // src/cmd/xliff/extract.ts
3525
- var import_path29 = require("path");
3609
+ var import_path30 = require("path");
3526
3610
  var import_markdown_translation = __toESM(require("@diplodoc/markdown-translation"));
3527
3611
  var import_async3 = require("async");
3528
3612
  var {
@@ -3585,7 +3669,7 @@ function handler3(args) {
3585
3669
  try {
3586
3670
  ({
3587
3671
  state: { found, cache }
3588
- } = yield glob((0, import_path29.join)(input, MD_GLOB2), {
3672
+ } = yield glob((0, import_path30.join)(input, MD_GLOB2), {
3589
3673
  nosort: true,
3590
3674
  cache
3591
3675
  }));
@@ -3619,9 +3703,9 @@ function pipeline2(params) {
3619
3703
  const { input, output, source, target } = params;
3620
3704
  return (markdownPath) => __async(this, null, function* () {
3621
3705
  const markdown = yield reader({ path: markdownPath });
3622
- const extension = (0, import_path29.extname)(markdownPath);
3706
+ const extension = (0, import_path30.extname)(markdownPath);
3623
3707
  const outputRelativePath = markdownPath.replace(extension, "").slice(input.length);
3624
- const outputPath = (0, import_path29.join)(output, outputRelativePath);
3708
+ const outputPath = (0, import_path30.join)(output, outputRelativePath);
3625
3709
  const xlfPath = outputPath + ".xliff";
3626
3710
  const skeletonPath = outputPath + ".skl.md";
3627
3711
  const extractParameters = {
@@ -3675,7 +3759,7 @@ function writer(params) {
3675
3759
  const { xlfPath, skeletonPath, xlf, skeleton } = params;
3676
3760
  logger.info(params.xlfPath, "writing xliff file");
3677
3761
  logger.info(params.skeletonPath, "writing skeleton file");
3678
- yield mkdir2((0, import_path29.dirname)(xlfPath), { recursive: true });
3762
+ yield mkdir2((0, import_path30.dirname)(xlfPath), { recursive: true });
3679
3763
  yield Promise.all([writeFile2(skeletonPath, skeleton), writeFile2(xlfPath, xlf)]);
3680
3764
  logger.info(params.xlfPath, "finished writing xliff file");
3681
3765
  logger.info(params.skeletonPath, "finished writing skeleton file");
@@ -3683,7 +3767,7 @@ function writer(params) {
3683
3767
  }
3684
3768
 
3685
3769
  // src/cmd/xliff/compose.ts
3686
- var import_path30 = require("path");
3770
+ var import_path31 = require("path");
3687
3771
  var import_markdown_translation2 = __toESM(require("@diplodoc/markdown-translation"));
3688
3772
  var import_async4 = require("async");
3689
3773
  var {
@@ -3723,13 +3807,13 @@ function handler4(args) {
3723
3807
  try {
3724
3808
  ({
3725
3809
  state: { found: skeletonPaths, cache }
3726
- } = yield glob((0, import_path30.join)(input, SKL_MD_GLOB), {
3810
+ } = yield glob((0, import_path31.join)(input, SKL_MD_GLOB), {
3727
3811
  nosort: false,
3728
3812
  cache
3729
3813
  }));
3730
3814
  ({
3731
3815
  state: { found: xliffPaths, cache }
3732
- } = yield glob((0, import_path30.join)(input, XLF_GLOB), {
3816
+ } = yield glob((0, import_path31.join)(input, XLF_GLOB), {
3733
3817
  nosort: false,
3734
3818
  cache
3735
3819
  }));
@@ -3759,7 +3843,7 @@ function handler4(args) {
3759
3843
  function pipeline3(params) {
3760
3844
  const { input, output } = params;
3761
3845
  return (xliffPath) => __async(this, null, function* () {
3762
- const extension = (0, import_path30.extname)(xliffPath);
3846
+ const extension = (0, import_path31.extname)(xliffPath);
3763
3847
  const extensionLessPath = xliffPath.replace(extension, "");
3764
3848
  const skeletonPath = extensionLessPath + ".skl.md";
3765
3849
  const readerParameters = { xliffPath, skeletonPath };
@@ -3770,7 +3854,7 @@ function pipeline3(params) {
3770
3854
  });
3771
3855
  const { markdown } = yield composer(composerParameters);
3772
3856
  const inputRelativePath = extensionLessPath.slice(input.length);
3773
- const markdownPath = (0, import_path30.join)(output, inputRelativePath) + ".md";
3857
+ const markdownPath = (0, import_path31.join)(output, inputRelativePath) + ".md";
3774
3858
  const writerParameters = {
3775
3859
  markdown,
3776
3860
  markdownPath
@@ -3827,7 +3911,7 @@ function writer2(params) {
3827
3911
  const { markdown, markdownPath } = params;
3828
3912
  try {
3829
3913
  logger.info(markdownPath, "writing markdown file");
3830
- yield mkdir3((0, import_path30.dirname)(markdownPath), { recursive: true });
3914
+ yield mkdir3((0, import_path31.dirname)(markdownPath), { recursive: true });
3831
3915
  yield writeFile3(markdownPath, markdown);
3832
3916
  logger.info(markdownPath, "finished writing markdown file");
3833
3917
  } catch (err) {
@@ -3857,7 +3941,7 @@ function builder5(argv) {
3857
3941
 
3858
3942
  // src/cmd/translate/index.ts
3859
3943
  var import_async5 = require("async");
3860
- var import_path32 = require("path");
3944
+ var import_path33 = require("path");
3861
3945
  var import_promises4 = require("fs/promises");
3862
3946
  var import_fast_xml_parser = require("fast-xml-parser");
3863
3947
  var import_session = require("@yandex-cloud/nodejs-sdk/dist/session");
@@ -3869,7 +3953,7 @@ var import_markdown_translation3 = __toESM(require("@diplodoc/markdown-translati
3869
3953
  var import_promises3 = require("fs/promises");
3870
3954
  var import_process3 = require("process");
3871
3955
  var import_os = require("os");
3872
- var import_path31 = require("path");
3956
+ var import_path32 = require("path");
3873
3957
  var YANDEX_OAUTH_TOKEN_FILENAME = ".ya_oauth_token";
3874
3958
  function getYandexOAuthToken() {
3875
3959
  return __async(this, null, function* () {
@@ -3880,7 +3964,7 @@ function getYandexOAuthToken() {
3880
3964
  function getYandexOAuthTokenFromHomeDir() {
3881
3965
  return __async(this, null, function* () {
3882
3966
  const error = "failed reading yandex oauth token";
3883
- const path = (0, import_path31.join)((0, import_os.homedir)(), YANDEX_OAUTH_TOKEN_FILENAME);
3967
+ const path = (0, import_path32.join)((0, import_os.homedir)(), YANDEX_OAUTH_TOKEN_FILENAME);
3884
3968
  let token;
3885
3969
  try {
3886
3970
  token = yield (0, import_promises3.readFile)(path, { encoding: "utf8" });
@@ -3949,7 +4033,7 @@ function handler5(args) {
3949
4033
  let found = [];
3950
4034
  ({
3951
4035
  state: { found }
3952
- } = yield glob((0, import_path32.join)(input, MD_GLOB3), {
4036
+ } = yield glob((0, import_path33.join)(input, MD_GLOB3), {
3953
4037
  nosort: true
3954
4038
  }));
3955
4039
  const oauthToken = yield getYandexOAuthToken();
@@ -3988,8 +4072,8 @@ function translator(params) {
3988
4072
  yandexCloudTranslateGlossaryPairs
3989
4073
  } = params;
3990
4074
  const session = new import_session.Session({ oauthToken });
3991
- const client3 = session.client(import_service_clients.TranslationServiceClient);
3992
- const request = (texts) => () => client3.translate(
4075
+ const client = session.client(import_service_clients.TranslationServiceClient);
4076
+ const request = (texts) => () => client.translate(
3993
4077
  import_translation_service.TranslateRequest.fromPartial({
3994
4078
  texts,
3995
4079
  folderId,
@@ -4006,7 +4090,7 @@ function translator(params) {
4006
4090
  return (mdPath) => __async(this, null, function* () {
4007
4091
  try {
4008
4092
  logger.info(mdPath, "translating");
4009
- const md = yield (0, import_promises4.readFile)((0, import_path32.resolve)(mdPath), { encoding: "utf-8" });
4093
+ const md = yield (0, import_promises4.readFile)((0, import_path33.resolve)(mdPath), { encoding: "utf-8" });
4010
4094
  const { xlf, skeleton } = import_markdown_translation3.default.extract({
4011
4095
  source: {
4012
4096
  language: sourceLanguage,
@@ -4064,7 +4148,7 @@ function translator(params) {
4064
4148
  skeleton
4065
4149
  });
4066
4150
  const outputPath = mdPath.replace(input, output);
4067
- yield (0, import_promises4.mkdir)((0, import_path32.dirname)(outputPath), { recursive: true });
4151
+ yield (0, import_promises4.mkdir)((0, import_path33.dirname)(outputPath), { recursive: true });
4068
4152
  yield (0, import_promises4.writeFile)(outputPath, composed);
4069
4153
  logger.info(outputPath, "finished translating");
4070
4154
  } catch (err) {
@@ -4127,7 +4211,7 @@ import_yargs.default.command(build).command(publish).command(xliff).command(tran
4127
4211
  default: false,
4128
4212
  describe: "Run in quiet mode. Don't write logs to stdout",
4129
4213
  type: "boolean"
4130
- }).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.7.0" : "").help().parse((0, import_helpers.hideBin)(process.argv), {}, (err, { strict }, output) => {
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) => {
4131
4215
  console.timeEnd(MAIN_TIMER_ID);
4132
4216
  if (err) {
4133
4217
  console.error(err);