@diplodoc/cli 4.0.0 → 4.2.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.
Files changed (57) hide show
  1. package/build/app.client.css +2678 -41
  2. package/build/app.client.js +1 -1
  3. package/build/index.js +418 -309
  4. package/build/index.js.map +3 -3
  5. package/build/linter.js +89 -81
  6. package/build/linter.js.map +2 -2
  7. package/package.json +12 -11
  8. package/src/cmd/build/index.ts +29 -15
  9. package/src/cmd/publish/index.ts +1 -6
  10. package/src/cmd/publish/upload.ts +22 -16
  11. package/src/cmd/translate/index.ts +51 -37
  12. package/src/cmd/xliff/compose.ts +16 -7
  13. package/src/cmd/xliff/extract.ts +18 -9
  14. package/src/cmd/xliff/index.ts +4 -1
  15. package/src/constants.ts +24 -24
  16. package/src/index.ts +3 -3
  17. package/src/models.ts +15 -10
  18. package/src/resolvers/lintPage.ts +3 -9
  19. package/src/resolvers/md2html.ts +27 -19
  20. package/src/resolvers/md2md.ts +16 -16
  21. package/src/services/authors.ts +4 -2
  22. package/src/services/contributors.ts +26 -12
  23. package/src/services/includers/batteries/common.ts +14 -2
  24. package/src/services/includers/batteries/generic.ts +27 -9
  25. package/src/services/includers/batteries/sourcedocs.ts +4 -1
  26. package/src/services/includers/batteries/unarchive.ts +8 -4
  27. package/src/services/includers/index.ts +6 -4
  28. package/src/services/leading.ts +24 -27
  29. package/src/services/metadata.ts +35 -10
  30. package/src/services/plugins.ts +1 -1
  31. package/src/services/preset.ts +2 -2
  32. package/src/services/tocs.ts +28 -23
  33. package/src/services/utils.ts +15 -5
  34. package/src/steps/processAssets.ts +2 -8
  35. package/src/steps/processExcludedFiles.ts +11 -20
  36. package/src/steps/processLinter.ts +9 -8
  37. package/src/steps/processLogs.ts +2 -7
  38. package/src/steps/processMapFile.ts +8 -11
  39. package/src/steps/processPages.ts +97 -67
  40. package/src/steps/processServiceFiles.ts +4 -2
  41. package/src/steps/publishFilesToS3.ts +16 -12
  42. package/src/utils/file.ts +5 -1
  43. package/src/utils/glob.ts +1 -3
  44. package/src/utils/logger.ts +1 -1
  45. package/src/utils/markup.ts +28 -13
  46. package/src/utils/singlePage.ts +11 -10
  47. package/src/utils/toc.ts +20 -7
  48. package/src/utils/worker.ts +1 -1
  49. package/src/validator.ts +25 -17
  50. package/src/vcs-connector/client/github.ts +16 -8
  51. package/src/vcs-connector/connector-validator.ts +13 -7
  52. package/src/vcs-connector/github.ts +38 -11
  53. package/src/vcs-connector/index.ts +1 -1
  54. package/src/workers/linter/index.ts +2 -6
  55. package/CHANGELOG.md +0 -785
  56. package/build/lib.js +0 -3374
  57. package/build/lib.js.map +0 -7
package/build/linter.js CHANGED
@@ -114,7 +114,7 @@ var require_client = __commonJS({
114
114
  // src/workers/linter/index.ts
115
115
  var linter_exports = {};
116
116
  module.exports = __toCommonJS(linter_exports);
117
- var import_log7 = __toESM(require("@doc-tools/transform/lib/log"));
117
+ var import_log7 = __toESM(require("@diplodoc/transform/lib/log"));
118
118
  var import_path19 = require("path");
119
119
  var import_observable = require("threads/observable");
120
120
  var import_threads = require("threads");
@@ -125,15 +125,15 @@ var import_fs3 = require("fs");
125
125
  var import_js_yaml3 = require("js-yaml");
126
126
  var import_shelljs2 = __toESM(require("shelljs"));
127
127
  var import_walk_sync = __toESM(require("walk-sync"));
128
- var import_liquid2 = __toESM(require("@doc-tools/transform/lib/liquid"));
129
- var import_log2 = __toESM(require("@doc-tools/transform/lib/log"));
128
+ var import_liquid2 = __toESM(require("@diplodoc/transform/lib/liquid"));
129
+ var import_log2 = __toESM(require("@diplodoc/transform/lib/log"));
130
130
  var import_chalk2 = require("chalk");
131
131
 
132
132
  // src/services/metadata.ts
133
133
  var import_js_yaml = require("js-yaml");
134
134
 
135
135
  // src/utils/logger.ts
136
- var import_log = __toESM(require("@doc-tools/transform/lib/log"));
136
+ var import_log = __toESM(require("@diplodoc/transform/lib/log"));
137
137
  var import_chalk = require("chalk");
138
138
  function writeLog(msg, fatal = false) {
139
139
  const { quiet } = argv_default.getConfig();
@@ -173,28 +173,28 @@ var import_process = require("process");
173
173
  // src/constants.ts
174
174
  var import_path = require("path");
175
175
  var os = require("os");
176
- var notes = require("@doc-tools/transform/lib/plugins/notes");
177
- var anchors = require("@doc-tools/transform/lib/plugins/anchors");
178
- var code = require("@doc-tools/transform/lib/plugins/code");
179
- var cut = require("@doc-tools/transform/lib/plugins/cut");
180
- var deflist = require("@doc-tools/transform/lib/plugins/deflist");
181
- var imsize = require("@doc-tools/transform/lib/plugins/imsize");
182
- var meta = require("@doc-tools/transform/lib/plugins/meta");
183
- var sup = require("@doc-tools/transform/lib/plugins/sup");
184
- var tabs = require("@doc-tools/transform/lib/plugins/tabs");
185
- var video = require("@doc-tools/transform/lib/plugins/video");
186
- var includes = require("@doc-tools/transform/lib/plugins/includes");
187
- var links = require("@doc-tools/transform/lib/plugins/links");
188
- var images = require("@doc-tools/transform/lib/plugins/images");
189
- var monospace = require("@doc-tools/transform/lib/plugins/monospace");
190
- var table = require("@doc-tools/transform/lib/plugins/table");
191
- var term = require("@doc-tools/transform/lib/plugins/term");
192
- var changelog = require("@doc-tools/transform/lib/plugins/changelog");
176
+ var notes = require("@diplodoc/transform/lib/plugins/notes");
177
+ var anchors = require("@diplodoc/transform/lib/plugins/anchors");
178
+ var code = require("@diplodoc/transform/lib/plugins/code");
179
+ var cut = require("@diplodoc/transform/lib/plugins/cut");
180
+ var deflist = require("@diplodoc/transform/lib/plugins/deflist");
181
+ var imsize = require("@diplodoc/transform/lib/plugins/imsize");
182
+ var meta = require("@diplodoc/transform/lib/plugins/meta");
183
+ var sup = require("@diplodoc/transform/lib/plugins/sup");
184
+ var tabs = require("@diplodoc/transform/lib/plugins/tabs");
185
+ var video = require("@diplodoc/transform/lib/plugins/video");
186
+ var includes = require("@diplodoc/transform/lib/plugins/includes");
187
+ var links = require("@diplodoc/transform/lib/plugins/links");
188
+ var images = require("@diplodoc/transform/lib/plugins/images");
189
+ var monospace = require("@diplodoc/transform/lib/plugins/monospace");
190
+ var table = require("@diplodoc/transform/lib/plugins/table");
191
+ var term = require("@diplodoc/transform/lib/plugins/term");
192
+ var changelog = require("@diplodoc/transform/lib/plugins/changelog");
193
193
  var mermaid = require("@diplodoc/mermaid-extension");
194
194
  var openapi = require("@diplodoc/openapi-extension");
195
- includes.collect = require("@doc-tools/transform/lib/plugins/includes/collect");
196
- images.collect = require("@doc-tools/transform/lib/plugins/images/collect");
197
- changelog.collect = require("@doc-tools/transform/lib/plugins/changelog/collect");
195
+ includes.collect = require("@diplodoc/transform/lib/plugins/includes/collect");
196
+ images.collect = require("@diplodoc/transform/lib/plugins/images/collect");
197
+ changelog.collect = require("@diplodoc/transform/lib/plugins/changelog/collect");
198
198
  var BUILD_FOLDER_PATH = (0, import_path.dirname)(require.resolve("@diplodoc/client"));
199
199
  var YFM_PLUGINS = [
200
200
  meta,
@@ -227,7 +227,7 @@ var metadataBorder = "---";
227
227
  // src/utils/singlePage.ts
228
228
  var import_node_html_parser = require("node-html-parser");
229
229
  var import_path2 = require("path");
230
- var import_utilsFS = require("@doc-tools/transform/lib/utilsFS");
230
+ var import_utilsFS = require("@diplodoc/transform/lib/utilsFS");
231
231
  var import_url = __toESM(require("url"));
232
232
  var import_lodash = __toESM(require("lodash"));
233
233
 
@@ -248,8 +248,8 @@ var import_path3 = require("path");
248
248
  var import_path4 = require("path");
249
249
 
250
250
  // src/services/utils.ts
251
- var import_evaluation = __toESM(require("@doc-tools/transform/lib/liquid/evaluation"));
252
- var import_liquid = __toESM(require("@doc-tools/transform/lib/liquid"));
251
+ var import_evaluation = __toESM(require("@diplodoc/transform/lib/liquid/evaluation"));
252
+ var import_liquid = __toESM(require("@diplodoc/transform/lib/liquid"));
253
253
  function filterFiles(items, itemsKey, vars, options) {
254
254
  if (!Array.isArray(items)) {
255
255
  return [];
@@ -346,11 +346,7 @@ function getVarsPerRelativeFile(filePath) {
346
346
  var import_glob = __toESM(require("glob"));
347
347
  var glob = (pattern, options) => __async(void 0, null, function* () {
348
348
  return new Promise((res, rej) => {
349
- const state = (0, import_glob.default)(
350
- pattern,
351
- options,
352
- (err) => err ? rej(err) : res({ state })
353
- );
349
+ const state = (0, import_glob.default)(pattern, options, (err) => err ? rej(err) : res({ state }));
354
350
  });
355
351
  });
356
352
 
@@ -447,7 +443,14 @@ var MD_GLOB = "**/*.md";
447
443
  function includerFunction(params) {
448
444
  return __async(this, null, function* () {
449
445
  var _a, _b;
450
- const { readBasePath, writeBasePath, tocPath, item, passedParams: { input, leadingPage }, index } = params;
446
+ const {
447
+ readBasePath,
448
+ writeBasePath,
449
+ tocPath,
450
+ item,
451
+ passedParams: { input, leadingPage },
452
+ index
453
+ } = params;
451
454
  if (!(input == null ? void 0 : input.length) || !((_a = item.include) == null ? void 0 : _a.path)) {
452
455
  throw new GenericIncluderError("provide includer with input parameter", tocPath);
453
456
  }
@@ -457,7 +460,9 @@ function includerFunction(params) {
457
460
  const contentPath = index === 0 ? (0, import_path9.join)(writeBasePath, tocDirPath, input) : (0, import_path9.join)(readBasePath, tocDirPath, input);
458
461
  let cache = {};
459
462
  let found = [];
460
- ({ state: { found, cache } } = yield glob(MD_GLOB, {
463
+ ({
464
+ state: { found, cache }
465
+ } = yield glob(MD_GLOB, {
461
466
  cwd: contentPath,
462
467
  nosort: true,
463
468
  nocase: true,
@@ -489,9 +494,14 @@ function createGraphFromPaths(paths) {
489
494
  continue;
490
495
  }
491
496
  const file = chunks.pop();
492
- (0, import_lodash2.updateWith)(graph, chunks, (old) => {
493
- return old ? { files: [...old.files, file] } : { files: [file] };
494
- }, Object);
497
+ (0, import_lodash2.updateWith)(
498
+ graph,
499
+ chunks,
500
+ (old) => {
501
+ return old ? { files: [...old.files, file] } : { files: [file] };
502
+ },
503
+ Object
504
+ );
495
505
  }
496
506
  return graph;
497
507
  }
@@ -533,8 +543,11 @@ var usage = `include:
533
543
  `;
534
544
  function includerFunction2(params) {
535
545
  return __async(this, null, function* () {
536
- logger.warn(params.tocPath, `sourcedocs inlcuder is getting depricated in favor of generic includer
537
- ${usage}`);
546
+ logger.warn(
547
+ params.tocPath,
548
+ `sourcedocs inlcuder is getting depricated in favor of generic includer
549
+ ${usage}`
550
+ );
538
551
  yield generic_default.includerFunction(params);
539
552
  });
540
553
  }
@@ -593,7 +606,13 @@ function pipeline(readPath, writeBasePath) {
593
606
  }
594
607
  function includerFunction3(params) {
595
608
  return __async(this, null, function* () {
596
- const { readBasePath, writeBasePath, tocPath, passedParams: { input, output }, index } = params;
609
+ const {
610
+ readBasePath,
611
+ writeBasePath,
612
+ tocPath,
613
+ passedParams: { input, output },
614
+ index
615
+ } = params;
597
616
  if (!(input == null ? void 0 : input.length) || !(output == null ? void 0 : output.length)) {
598
617
  throw new UnarchiveIncluderError("provide includer with input parameter", tocPath);
599
618
  }
@@ -735,11 +754,9 @@ function add(path) {
735
754
  }
736
755
  const combinedVars = __spreadValues(__spreadValues({}, preset_default.get(pathToDir)), vars);
737
756
  if (parsedToc.title) {
738
- parsedToc.title = firstFilterTextItems(
739
- parsedToc.title,
740
- combinedVars,
741
- { resolveConditions: true }
742
- );
757
+ parsedToc.title = firstFilterTextItems(parsedToc.title, combinedVars, {
758
+ resolveConditions: true
759
+ });
743
760
  }
744
761
  if (typeof parsedToc.title === "string") {
745
762
  parsedToc.title = liquidField(parsedToc.title, combinedVars, path);
@@ -764,10 +781,7 @@ function add(path) {
764
781
  }
765
782
  function processTocItems(path, items, tocDir, sourcesDir, vars) {
766
783
  return __async(this, null, function* () {
767
- const {
768
- resolveConditions,
769
- removeHiddenTocItems
770
- } = argv_default.getConfig();
784
+ const { resolveConditions, removeHiddenTocItems } = argv_default.getConfig();
771
785
  let preparedItems = items;
772
786
  if (resolveConditions || removeHiddenTocItems) {
773
787
  try {
@@ -910,9 +924,19 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
910
924
  addIncludeTocPath(includeTocPath);
911
925
  let includedTocItems = (item.items || []).concat(includeToc.items);
912
926
  const baseTocDir = mode === "link" /* LINK */ ? includeTocDir : tocDir;
913
- includedTocItems = yield processTocItems(path, includedTocItems, baseTocDir, sourcesDir, vars);
927
+ includedTocItems = yield processTocItems(
928
+ path,
929
+ includedTocItems,
930
+ baseTocDir,
931
+ sourcesDir,
932
+ vars
933
+ );
914
934
  if (mode === "link" /* LINK */) {
915
- includedTocItems = _replaceIncludesHrefs(includedTocItems, includeTocDir, tocDir);
935
+ includedTocItems = _replaceIncludesHrefs(
936
+ includedTocItems,
937
+ includeTocDir,
938
+ tocDir
939
+ );
916
940
  }
917
941
  if (item.name) {
918
942
  item.items = includedTocItems;
@@ -920,7 +944,9 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
920
944
  includedInlineItems = includedTocItems;
921
945
  }
922
946
  } catch (err) {
923
- const message = `Error while including toc: ${(0, import_chalk2.bold)(includeTocPath)} to ${(0, import_chalk2.bold)((0, import_path12.join)(tocDir, "toc.yaml"))}`;
947
+ const message = `Error while including toc: ${(0, import_chalk2.bold)(includeTocPath)} to ${(0, import_chalk2.bold)(
948
+ (0, import_path12.join)(tocDir, "toc.yaml")
949
+ )}`;
924
950
  import_log2.default.error(message);
925
951
  continue;
926
952
  } finally {
@@ -1028,7 +1054,7 @@ var argv_default = {
1028
1054
  var import_path15 = require("path");
1029
1055
  var import_fs5 = require("fs");
1030
1056
  var import_js_yaml4 = require("js-yaml");
1031
- var import_log3 = __toESM(require("@doc-tools/transform/lib/log"));
1057
+ var import_log3 = __toESM(require("@diplodoc/transform/lib/log"));
1032
1058
 
1033
1059
  // src/services/plugins.ts
1034
1060
  var plugins_exports = {};
@@ -1103,14 +1129,10 @@ function getDefaultLintConfig() {
1103
1129
  var import_fs6 = require("fs");
1104
1130
  var import_path16 = require("path");
1105
1131
  var import_shelljs3 = __toESM(require("shelljs"));
1106
- var import_log4 = __toESM(require("@doc-tools/transform/lib/log"));
1107
- var import_liquid3 = __toESM(require("@doc-tools/transform/lib/liquid"));
1132
+ var import_log4 = __toESM(require("@diplodoc/transform/lib/log"));
1133
+ var import_liquid3 = __toESM(require("@diplodoc/transform/lib/liquid"));
1108
1134
  function liquidMd2Md(input, vars, path) {
1109
- const {
1110
- applyPresets,
1111
- resolveConditions,
1112
- conditionsInCode
1113
- } = argv_default.getConfig();
1135
+ const { applyPresets, resolveConditions, conditionsInCode } = argv_default.getConfig();
1114
1136
  return (0, import_liquid3.default)(input, vars, path, {
1115
1137
  conditions: resolveConditions,
1116
1138
  substitutions: applyPresets,
@@ -1124,9 +1146,9 @@ function liquidMd2Md(input, vars, path) {
1124
1146
  var import_path17 = require("path");
1125
1147
  var import_fs7 = require("fs");
1126
1148
  var import_js_yaml5 = __toESM(require("js-yaml"));
1127
- var import_transform = __toESM(require("@doc-tools/transform"));
1128
- var import_log5 = __toESM(require("@doc-tools/transform/lib/log"));
1129
- var import_liquid4 = __toESM(require("@doc-tools/transform/lib/liquid"));
1149
+ var import_transform = __toESM(require("@diplodoc/transform"));
1150
+ var import_log5 = __toESM(require("@diplodoc/transform/lib/log"));
1151
+ var import_liquid4 = __toESM(require("@diplodoc/transform/lib/liquid"));
1130
1152
  function liquidMd2Html(input, vars, path) {
1131
1153
  const { conditionsInCode } = argv_default.getConfig();
1132
1154
  return (0, import_liquid4.default)(input, vars, path, {
@@ -1137,8 +1159,8 @@ function liquidMd2Html(input, vars, path) {
1137
1159
 
1138
1160
  // src/resolvers/lintPage.ts
1139
1161
  var import_path18 = require("path");
1140
- var import_log6 = __toESM(require("@doc-tools/transform/lib/log"));
1141
- var import_yfmlint = __toESM(require("@doc-tools/transform/lib/yfmlint"));
1162
+ var import_log6 = __toESM(require("@diplodoc/transform/lib/log"));
1163
+ var import_yfmlint = __toESM(require("@diplodoc/transform/lib/yfmlint"));
1142
1164
  var import_fs8 = require("fs");
1143
1165
  var import_chalk3 = require("chalk");
1144
1166
  var FileLinter = {
@@ -1165,17 +1187,7 @@ function lintPage(options) {
1165
1187
  }
1166
1188
  }
1167
1189
  function MdFileLinter(content, lintOptions) {
1168
- const _a = argv_default.getConfig(), {
1169
- input,
1170
- lintConfig,
1171
- disableLiquid,
1172
- outputFormat
1173
- } = _a, options = __objRest(_a, [
1174
- "input",
1175
- "lintConfig",
1176
- "disableLiquid",
1177
- "outputFormat"
1178
- ]);
1190
+ const _a = argv_default.getConfig(), { input, lintConfig, disableLiquid, outputFormat } = _a, options = __objRest(_a, ["input", "lintConfig", "disableLiquid", "outputFormat"]);
1179
1191
  const { path: filePath } = lintOptions;
1180
1192
  const plugins2 = outputFormat === "md" ? [] : plugins_exports.getPlugins();
1181
1193
  const vars = getVarsPerFile(filePath);
@@ -1227,11 +1239,7 @@ function MdFileLinter(content, lintOptions) {
1227
1239
  // src/workers/linter/index.ts
1228
1240
  var processedPages = new import_observable.Subject();
1229
1241
  function run(_0) {
1230
- return __async(this, arguments, function* ({
1231
- argvConfig,
1232
- presetStorage: presetStorage2,
1233
- navigationPaths: navigationPaths2
1234
- }) {
1242
+ return __async(this, arguments, function* ({ argvConfig, presetStorage: presetStorage2, navigationPaths: navigationPaths2 }) {
1235
1243
  argv_default.set(argvConfig);
1236
1244
  preset_default.setPresetStorage(presetStorage2);
1237
1245
  tocs_default.setNavigationPaths(navigationPaths2);