@diplodoc/cli 4.6.3 → 4.7.0-beta-1
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/assets/app.css +4 -0
- package/assets/app.js +2 -0
- package/assets/react.js +3 -0
- package/assets/vendor.css +3534 -0
- package/assets/vendor.js +3 -0
- package/build/app.client.css +65 -53
- package/build/app.client.js +1 -1
- package/build/index.js +184 -218
- package/build/index.js.map +4 -4
- package/build/linter.js +74 -106
- package/build/linter.js.map +4 -4
- package/package.json +13 -40
- package/src/constants.ts +4 -6
- package/src/steps/processAssets.ts +3 -5
- package/src/utils/markup.ts +17 -6
- package/src/steps/publishFilesToS3.ts +0 -51
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((
|
|
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 ?
|
|
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");
|
|
@@ -138,10 +103,12 @@ var table = require("@diplodoc/transform/lib/plugins/table");
|
|
|
138
103
|
var term = require("@diplodoc/transform/lib/plugins/term");
|
|
139
104
|
var changelog = require("@diplodoc/transform/lib/plugins/changelog");
|
|
140
105
|
var mermaid = require("@diplodoc/mermaid-extension");
|
|
106
|
+
var latex = require("@diplodoc/latex-extension");
|
|
141
107
|
var openapi = require("@diplodoc/openapi-extension");
|
|
142
108
|
includes.collect = require("@diplodoc/transform/lib/plugins/includes/collect");
|
|
143
109
|
images.collect = require("@diplodoc/transform/lib/plugins/images/collect");
|
|
144
110
|
changelog.collect = require("@diplodoc/transform/lib/plugins/changelog/collect");
|
|
111
|
+
var ASSETS_FOLDER = (0, import_path.resolve)(__dirname, "../assets");
|
|
145
112
|
var BUNDLE_FOLDER = "_bundle";
|
|
146
113
|
var TMP_INPUT_FOLDER = ".tmp_input";
|
|
147
114
|
var TMP_OUTPUT_FOLDER = ".tmp_output";
|
|
@@ -157,7 +124,6 @@ var ResourceType = /* @__PURE__ */ ((ResourceType2) => {
|
|
|
157
124
|
ResourceType2["script"] = "script";
|
|
158
125
|
return ResourceType2;
|
|
159
126
|
})(ResourceType || {});
|
|
160
|
-
var BUILD_FOLDER_PATH = (0, import_path.dirname)(require.resolve("@diplodoc/client"));
|
|
161
127
|
var YFM_PLUGINS = [
|
|
162
128
|
meta,
|
|
163
129
|
deflist,
|
|
@@ -177,6 +143,7 @@ var YFM_PLUGINS = [
|
|
|
177
143
|
term,
|
|
178
144
|
openapi.transform(),
|
|
179
145
|
mermaid.transform(),
|
|
146
|
+
latex.transform(),
|
|
180
147
|
changelog
|
|
181
148
|
];
|
|
182
149
|
var PROCESSING_FINISHED = "Processing finished:";
|
|
@@ -318,10 +285,10 @@ function argvValidator(argv) {
|
|
|
318
285
|
}
|
|
319
286
|
|
|
320
287
|
// src/cmd/build/index.ts
|
|
321
|
-
var
|
|
288
|
+
var import_path28 = require("path");
|
|
322
289
|
|
|
323
290
|
// src/services/tocs.ts
|
|
324
|
-
var
|
|
291
|
+
var import_path14 = require("path");
|
|
325
292
|
var import_fs3 = require("fs");
|
|
326
293
|
var import_js_yaml4 = require("js-yaml");
|
|
327
294
|
var import_shelljs2 = __toESM(require("shelljs"));
|
|
@@ -369,6 +336,7 @@ var logger = {
|
|
|
369
336
|
};
|
|
370
337
|
|
|
371
338
|
// src/utils/markup.ts
|
|
339
|
+
var import_path4 = require("path");
|
|
372
340
|
var import_process = require("process");
|
|
373
341
|
|
|
374
342
|
// src/utils/singlePage.ts
|
|
@@ -535,8 +503,9 @@ function preprocessPageHtmlForSinglePage(content, options) {
|
|
|
535
503
|
}
|
|
536
504
|
|
|
537
505
|
// src/utils/markup.ts
|
|
538
|
-
var
|
|
539
|
-
var
|
|
506
|
+
var import_ssr = require("@diplodoc/client/ssr");
|
|
507
|
+
var import_manifest = __toESM(require("@diplodoc/client/manifest"));
|
|
508
|
+
var dst = (bundlePath) => (target) => (0, import_path4.join)(bundlePath, target);
|
|
540
509
|
function generateStaticMarkup(props, pathToBundle) {
|
|
541
510
|
const { title: metaTitle, style, script } = props.data.meta || {};
|
|
542
511
|
const { title: tocTitle } = props.data.toc;
|
|
@@ -548,7 +517,7 @@ function generateStaticMarkup(props, pathToBundle) {
|
|
|
548
517
|
});
|
|
549
518
|
const resources = getResources({ style, script });
|
|
550
519
|
const { staticContent } = argv_default.getConfig();
|
|
551
|
-
const html = staticContent ? (0,
|
|
520
|
+
const html = staticContent ? (0, import_ssr.render)(props) : "";
|
|
552
521
|
return `
|
|
553
522
|
<!DOCTYPE html>
|
|
554
523
|
<html lang="${props.lang}">
|
|
@@ -562,7 +531,7 @@ function generateStaticMarkup(props, pathToBundle) {
|
|
|
562
531
|
height: 100vh;
|
|
563
532
|
}
|
|
564
533
|
</style>
|
|
565
|
-
|
|
534
|
+
${import_manifest.default.css.map(dst(pathToBundle)).map((src) => `<link type="text/css" rel="stylesheet" href="${src}" />`).join("\n")}
|
|
566
535
|
${plugins_exports.getHeadContent()}
|
|
567
536
|
${resources}
|
|
568
537
|
</head>
|
|
@@ -572,9 +541,9 @@ function generateStaticMarkup(props, pathToBundle) {
|
|
|
572
541
|
window.STATIC_CONTENT = ${staticContent}
|
|
573
542
|
window.__DATA__ = ${JSON.stringify(props)};
|
|
574
543
|
</script>
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
)}
|
|
544
|
+
${import_manifest.default.js.map(dst(pathToBundle)).map(
|
|
545
|
+
(src) => `<script type="application/javascript" src="${src}"></script>`
|
|
546
|
+
).join("\n")}
|
|
578
547
|
</body>
|
|
579
548
|
</html>
|
|
580
549
|
`;
|
|
@@ -626,9 +595,9 @@ function replaceDoubleToSingleQuotes(str) {
|
|
|
626
595
|
}
|
|
627
596
|
|
|
628
597
|
// src/utils/path.ts
|
|
629
|
-
var
|
|
598
|
+
var import_path5 = require("path");
|
|
630
599
|
function addSlashPrefix(path) {
|
|
631
|
-
const slashPrefix = path.startsWith(
|
|
600
|
+
const slashPrefix = path.startsWith(import_path5.sep) ? "" : import_path5.sep;
|
|
632
601
|
return `${slashPrefix}${path}`;
|
|
633
602
|
}
|
|
634
603
|
function convertBackSlashToSlash(path) {
|
|
@@ -639,7 +608,7 @@ function convertBackSlashToSlash(path) {
|
|
|
639
608
|
}
|
|
640
609
|
|
|
641
610
|
// src/utils/toc.ts
|
|
642
|
-
var
|
|
611
|
+
var import_path6 = require("path");
|
|
643
612
|
|
|
644
613
|
// src/services/utils.ts
|
|
645
614
|
var import_evaluation = __toESM(require("@diplodoc/transform/lib/liquid/evaluation"));
|
|
@@ -765,14 +734,14 @@ function transformToc(toc, pathToFileDirectory) {
|
|
|
765
734
|
navigationItemQueue.push(...navigationItem.items);
|
|
766
735
|
}
|
|
767
736
|
if (href && !isExternalHref(href)) {
|
|
768
|
-
const pathToIndexDirectory = (0,
|
|
769
|
-
const fileExtension = (0,
|
|
770
|
-
const filename = (0,
|
|
771
|
-
const transformedFilename = (0,
|
|
737
|
+
const pathToIndexDirectory = (0, import_path6.relative)(pathToFileDirectory, baseTocPath);
|
|
738
|
+
const fileExtension = (0, import_path6.extname)(href);
|
|
739
|
+
const filename = (0, import_path6.basename)(href, fileExtension);
|
|
740
|
+
const transformedFilename = (0, import_path6.format)({
|
|
772
741
|
name: filename,
|
|
773
742
|
ext: ".html"
|
|
774
743
|
});
|
|
775
|
-
navigationItem.href = (0,
|
|
744
|
+
navigationItem.href = (0, import_path6.join)(pathToIndexDirectory, (0, import_path6.dirname)(href), transformedFilename);
|
|
776
745
|
}
|
|
777
746
|
}
|
|
778
747
|
return localToc;
|
|
@@ -809,15 +778,15 @@ function transformTocForSinglePage(toc, options) {
|
|
|
809
778
|
}
|
|
810
779
|
|
|
811
780
|
// src/utils/presets.ts
|
|
812
|
-
var
|
|
781
|
+
var import_path7 = require("path");
|
|
813
782
|
function getVarsPerFile(filePath) {
|
|
814
783
|
const { vars: argVars } = argv_default.getConfig();
|
|
815
|
-
return __spreadValues(__spreadValues({}, preset_default.get((0,
|
|
784
|
+
return __spreadValues(__spreadValues({}, preset_default.get((0, import_path7.dirname)(filePath))), argVars);
|
|
816
785
|
}
|
|
817
786
|
function getVarsPerRelativeFile(filePath) {
|
|
818
787
|
const { input } = argv_default.getConfig();
|
|
819
|
-
const root = (0,
|
|
820
|
-
const relativeFilePath = (0,
|
|
788
|
+
const root = (0, import_path7.resolve)(input);
|
|
789
|
+
const relativeFilePath = (0, import_path7.relative)(root, filePath);
|
|
821
790
|
return getVarsPerFile(relativeFilePath);
|
|
822
791
|
}
|
|
823
792
|
|
|
@@ -830,14 +799,14 @@ var glob = (pattern, options) => __async(void 0, null, function* () {
|
|
|
830
799
|
});
|
|
831
800
|
|
|
832
801
|
// src/utils/file.ts
|
|
833
|
-
var
|
|
802
|
+
var import_path8 = require("path");
|
|
834
803
|
var import_shelljs = __toESM(require("shelljs"));
|
|
835
804
|
function copyFiles(inputFolderPath, outputFolderPath, files) {
|
|
836
805
|
const dirs = /* @__PURE__ */ new Set();
|
|
837
806
|
files.forEach((pathToAsset) => {
|
|
838
|
-
const outputDir = (0,
|
|
839
|
-
const from = (0,
|
|
840
|
-
const to = (0,
|
|
807
|
+
const outputDir = (0, import_path8.resolve)(outputFolderPath, (0, import_path8.dirname)(pathToAsset));
|
|
808
|
+
const from = (0, import_path8.resolve)(inputFolderPath, pathToAsset);
|
|
809
|
+
const to = (0, import_path8.resolve)(outputFolderPath, pathToAsset);
|
|
841
810
|
if (!dirs.has(outputDir)) {
|
|
842
811
|
dirs.add(outputDir);
|
|
843
812
|
import_shelljs.default.mkdir("-p", outputDir);
|
|
@@ -893,7 +862,7 @@ function getAuthorDetails(vcsConnector, author) {
|
|
|
893
862
|
|
|
894
863
|
// src/services/contributors.ts
|
|
895
864
|
var import_promises = require("fs/promises");
|
|
896
|
-
var
|
|
865
|
+
var import_path9 = require("path");
|
|
897
866
|
function getFileContributorsMetadata(fileData, vcsConnector) {
|
|
898
867
|
return __async(this, null, function* () {
|
|
899
868
|
const contributors = yield getFileContributorsString(fileData, vcsConnector);
|
|
@@ -963,8 +932,8 @@ function getRelativeIncludeFilePaths(fileData, includeContents) {
|
|
|
963
932
|
const relativeIncludeFilePath = includeContent.match(REGEXP_INCLUDE_FILE_PATH);
|
|
964
933
|
if (relativeIncludeFilePath && relativeIncludeFilePath.length !== 0) {
|
|
965
934
|
const relativeIncludeFilePathWithoutHash = relativeIncludeFilePath[0].split("#");
|
|
966
|
-
const includeFilePath = (0,
|
|
967
|
-
(0,
|
|
935
|
+
const includeFilePath = (0, import_path9.join)(
|
|
936
|
+
(0, import_path9.dirname)(tmpInputFilePath),
|
|
968
937
|
relativeIncludeFilePathWithoutHash[0]
|
|
969
938
|
);
|
|
970
939
|
relativeIncludeFilePaths.add(includeFilePath);
|
|
@@ -974,7 +943,7 @@ function getRelativeIncludeFilePaths(fileData, includeContents) {
|
|
|
974
943
|
}
|
|
975
944
|
|
|
976
945
|
// src/services/metadata.ts
|
|
977
|
-
var
|
|
946
|
+
var import_path10 = require("path");
|
|
978
947
|
function getContentWithUpdatedMetadata(fileContent, options, systemVars) {
|
|
979
948
|
return __async(this, null, function* () {
|
|
980
949
|
var _a;
|
|
@@ -1145,8 +1114,8 @@ function getSystemVarsMetadataString(systemVars) {
|
|
|
1145
1114
|
}
|
|
1146
1115
|
function getAssetsPublicPath(filePath) {
|
|
1147
1116
|
const { input } = argv_default.getConfig();
|
|
1148
|
-
const path = (0,
|
|
1149
|
-
return (0,
|
|
1117
|
+
const path = (0, import_path10.resolve)(input, filePath);
|
|
1118
|
+
return (0, import_path10.relative)((0, import_path10.dirname)(path), (0, import_path10.resolve)(input));
|
|
1150
1119
|
}
|
|
1151
1120
|
|
|
1152
1121
|
// src/services/includers/index.ts
|
|
@@ -1156,7 +1125,7 @@ __export(includers_exports, {
|
|
|
1156
1125
|
applyIncluders: () => applyIncluders,
|
|
1157
1126
|
init: () => init
|
|
1158
1127
|
});
|
|
1159
|
-
var
|
|
1128
|
+
var import_path13 = require("path");
|
|
1160
1129
|
var import_lodash3 = require("lodash");
|
|
1161
1130
|
|
|
1162
1131
|
// src/services/includers/batteries/generic.ts
|
|
@@ -1167,7 +1136,7 @@ __export(generic_exports, {
|
|
|
1167
1136
|
name: () => name
|
|
1168
1137
|
});
|
|
1169
1138
|
var import_promises2 = require("fs/promises");
|
|
1170
|
-
var
|
|
1139
|
+
var import_path11 = require("path");
|
|
1171
1140
|
var import_lodash2 = require("lodash");
|
|
1172
1141
|
var import_js_yaml3 = require("js-yaml");
|
|
1173
1142
|
var GenericIncluderError = class extends Error {
|
|
@@ -1195,8 +1164,8 @@ function includerFunction(params) {
|
|
|
1195
1164
|
}
|
|
1196
1165
|
try {
|
|
1197
1166
|
const leadingPageName = (_b = leadingPage == null ? void 0 : leadingPage.name) != null ? _b : "Overview";
|
|
1198
|
-
const tocDirPath = (0,
|
|
1199
|
-
const contentPath = index === 0 ? (0,
|
|
1167
|
+
const tocDirPath = (0, import_path11.dirname)(tocPath);
|
|
1168
|
+
const contentPath = index === 0 ? (0, import_path11.join)(writeBasePath, tocDirPath, input) : (0, import_path11.join)(readBasePath, tocDirPath, input);
|
|
1200
1169
|
let cache = {};
|
|
1201
1170
|
let found = [];
|
|
1202
1171
|
({
|
|
@@ -1207,16 +1176,16 @@ function includerFunction(params) {
|
|
|
1207
1176
|
nocase: true,
|
|
1208
1177
|
cache
|
|
1209
1178
|
}));
|
|
1210
|
-
const writePath = (0,
|
|
1179
|
+
const writePath = (0, import_path11.join)(writeBasePath, tocDirPath, item.include.path);
|
|
1211
1180
|
yield (0, import_promises2.mkdir)(writePath, { recursive: true });
|
|
1212
1181
|
for (const filePath of found) {
|
|
1213
|
-
const file = yield (0, import_promises2.readFile)((0,
|
|
1214
|
-
yield (0, import_promises2.mkdir)((0,
|
|
1215
|
-
yield (0, import_promises2.writeFile)((0,
|
|
1182
|
+
const file = yield (0, import_promises2.readFile)((0, import_path11.join)(contentPath, filePath));
|
|
1183
|
+
yield (0, import_promises2.mkdir)((0, import_path11.dirname)((0, import_path11.join)(writePath, filePath)), { recursive: true });
|
|
1184
|
+
yield (0, import_promises2.writeFile)((0, import_path11.join)(writePath, filePath), file);
|
|
1216
1185
|
}
|
|
1217
1186
|
const graph = createGraphFromPaths(found);
|
|
1218
1187
|
const toc = createToc(leadingPageName, item.include.path)(graph, []);
|
|
1219
|
-
yield (0, import_promises2.writeFile)((0,
|
|
1188
|
+
yield (0, import_promises2.writeFile)((0, import_path11.join)(writePath, "toc.yaml"), (0, import_js_yaml3.dump)(toc));
|
|
1220
1189
|
} catch (err) {
|
|
1221
1190
|
throw new GenericIncluderError(err.toString(), tocPath);
|
|
1222
1191
|
}
|
|
@@ -1248,8 +1217,8 @@ function createToc(leadingPageName, tocName) {
|
|
|
1248
1217
|
return function createTocRec(graph, cursor) {
|
|
1249
1218
|
var _a, _b;
|
|
1250
1219
|
const handler6 = (file) => ({
|
|
1251
|
-
name: (0,
|
|
1252
|
-
href: (0,
|
|
1220
|
+
name: (0, import_path11.parse)(file).name === "index" ? leadingPageName : file,
|
|
1221
|
+
href: (0, import_path11.join)(...cursor, file)
|
|
1253
1222
|
});
|
|
1254
1223
|
const recurse = (key) => createTocRec(graph[key], [...cursor, key]);
|
|
1255
1224
|
const current = {
|
|
@@ -1300,7 +1269,7 @@ __export(unarchive_exports, {
|
|
|
1300
1269
|
name: () => name3
|
|
1301
1270
|
});
|
|
1302
1271
|
var import_fs2 = require("fs");
|
|
1303
|
-
var
|
|
1272
|
+
var import_path12 = require("path");
|
|
1304
1273
|
var import_tar_stream = require("tar-stream");
|
|
1305
1274
|
var name3 = "unarchive";
|
|
1306
1275
|
var UnarchiveIncluderError = class extends Error {
|
|
@@ -1323,8 +1292,8 @@ function pipeline(readPath, writeBasePath) {
|
|
|
1323
1292
|
(0, import_fs2.mkdirSync)(writeBasePath, { recursive: true });
|
|
1324
1293
|
extractor2.on("entry", (header, stream, next) => {
|
|
1325
1294
|
const { type, name: name4 } = header;
|
|
1326
|
-
const writePath = (0,
|
|
1327
|
-
const writeDirPath = type === "directory" ? writePath : (0,
|
|
1295
|
+
const writePath = (0, import_path12.join)(writeBasePath, name4);
|
|
1296
|
+
const writeDirPath = type === "directory" ? writePath : (0, import_path12.dirname)(writePath);
|
|
1328
1297
|
(0, import_fs2.mkdirSync)(writeDirPath, { recursive: true });
|
|
1329
1298
|
if (type !== "directory") {
|
|
1330
1299
|
const writer3 = (0, import_fs2.createWriteStream)(writePath, { flags: "w" });
|
|
@@ -1355,8 +1324,8 @@ function includerFunction3(params) {
|
|
|
1355
1324
|
if (!(input == null ? void 0 : input.length) || !(output == null ? void 0 : output.length)) {
|
|
1356
1325
|
throw new UnarchiveIncluderError("provide includer with input parameter", tocPath);
|
|
1357
1326
|
}
|
|
1358
|
-
const contentPath = index === 0 ? (0,
|
|
1359
|
-
const writePath = (0,
|
|
1327
|
+
const contentPath = index === 0 ? (0, import_path12.join)(writeBasePath, input) : (0, import_path12.join)(readBasePath, input);
|
|
1328
|
+
const writePath = (0, import_path12.join)(writeBasePath, output);
|
|
1360
1329
|
try {
|
|
1361
1330
|
yield pipeline(contentPath, writePath);
|
|
1362
1331
|
} catch (err) {
|
|
@@ -1413,7 +1382,7 @@ function applyIncluders(path, item, vars) {
|
|
|
1413
1382
|
const passedParams = __spreadValues({}, rest);
|
|
1414
1383
|
yield applyIncluder({ path, item, includer, passedParams, index, vars });
|
|
1415
1384
|
}
|
|
1416
|
-
item.include.path = (0,
|
|
1385
|
+
item.include.path = (0, import_path13.join)(item.include.path, "toc.yaml");
|
|
1417
1386
|
index++;
|
|
1418
1387
|
});
|
|
1419
1388
|
}
|
|
@@ -1485,8 +1454,8 @@ function add(path) {
|
|
|
1485
1454
|
ignoreStage,
|
|
1486
1455
|
vars
|
|
1487
1456
|
} = argv_default.getConfig();
|
|
1488
|
-
const pathToDir = (0,
|
|
1489
|
-
const content = (0, import_fs3.readFileSync)((0,
|
|
1457
|
+
const pathToDir = (0, import_path14.dirname)(path);
|
|
1458
|
+
const content = (0, import_fs3.readFileSync)((0, import_path14.resolve)(inputFolderPath, path), "utf8");
|
|
1490
1459
|
const parsedToc = (0, import_js_yaml4.load)(content);
|
|
1491
1460
|
if (parsedToc.stage === ignoreStage) {
|
|
1492
1461
|
return;
|
|
@@ -1503,16 +1472,16 @@ function add(path) {
|
|
|
1503
1472
|
parsedToc.items = yield processTocItems(
|
|
1504
1473
|
path,
|
|
1505
1474
|
parsedToc.items,
|
|
1506
|
-
(0,
|
|
1507
|
-
(0,
|
|
1475
|
+
(0, import_path14.join)(inputFolderPath, pathToDir),
|
|
1476
|
+
(0, import_path14.resolve)(inputFolderPath),
|
|
1508
1477
|
combinedVars
|
|
1509
1478
|
);
|
|
1510
1479
|
storage.set(path, parsedToc);
|
|
1511
1480
|
parsedToc.base = pathToDir;
|
|
1512
1481
|
if (outputFormat === "md") {
|
|
1513
|
-
const outputPath = (0,
|
|
1482
|
+
const outputPath = (0, import_path14.resolve)(outputFolderPath, path);
|
|
1514
1483
|
const outputToc = (0, import_js_yaml4.dump)(parsedToc);
|
|
1515
|
-
import_shelljs2.default.mkdir("-p", (0,
|
|
1484
|
+
import_shelljs2.default.mkdir("-p", (0, import_path14.dirname)(outputPath));
|
|
1516
1485
|
(0, import_fs3.writeFileSync)(outputPath, outputToc);
|
|
1517
1486
|
}
|
|
1518
1487
|
prepareNavigationPaths(parsedToc, pathToDir);
|
|
@@ -1555,7 +1524,7 @@ function prepareNavigationPaths(parsedToc, dirPath) {
|
|
|
1555
1524
|
processItems(preparedSubItems, pathToDir);
|
|
1556
1525
|
}
|
|
1557
1526
|
if (item.href && !isExternalHref(item.href)) {
|
|
1558
|
-
const href = (0,
|
|
1527
|
+
const href = (0, import_path14.join)(pathToDir, item.href);
|
|
1559
1528
|
storage.set(href, parsedToc);
|
|
1560
1529
|
const navigationPath = _normalizeHref(href);
|
|
1561
1530
|
navigationPaths.push(navigationPath);
|
|
@@ -1565,32 +1534,32 @@ function prepareNavigationPaths(parsedToc, dirPath) {
|
|
|
1565
1534
|
processItems([parsedToc], dirPath);
|
|
1566
1535
|
}
|
|
1567
1536
|
function _normalizeHref(href) {
|
|
1568
|
-
const preparedHref = (0,
|
|
1537
|
+
const preparedHref = (0, import_path14.normalize)(href);
|
|
1569
1538
|
if (preparedHref.endsWith(".md") || preparedHref.endsWith(".yaml")) {
|
|
1570
1539
|
return preparedHref;
|
|
1571
1540
|
}
|
|
1572
|
-
if (preparedHref.endsWith(
|
|
1541
|
+
if (preparedHref.endsWith(import_path14.sep)) {
|
|
1573
1542
|
return `${preparedHref}index.yaml`;
|
|
1574
1543
|
}
|
|
1575
1544
|
return `${preparedHref}.md`;
|
|
1576
1545
|
}
|
|
1577
1546
|
function _copyTocDir(tocPath, destDir) {
|
|
1578
1547
|
const { input: inputFolderPath } = argv_default.getConfig();
|
|
1579
|
-
const { dir: tocDir } = (0,
|
|
1548
|
+
const { dir: tocDir } = (0, import_path14.parse)(tocPath);
|
|
1580
1549
|
const files = (0, import_walk_sync.default)(tocDir, {
|
|
1581
1550
|
globs: ["**/*.*"],
|
|
1582
1551
|
ignore: ["**/toc.yaml"],
|
|
1583
1552
|
directories: false
|
|
1584
1553
|
});
|
|
1585
1554
|
files.forEach((relPath) => {
|
|
1586
|
-
const from = (0,
|
|
1587
|
-
const to = (0,
|
|
1588
|
-
const fileExtension = (0,
|
|
1555
|
+
const from = (0, import_path14.resolve)(tocDir, relPath);
|
|
1556
|
+
const to = (0, import_path14.resolve)(destDir, relPath);
|
|
1557
|
+
const fileExtension = (0, import_path14.extname)(relPath);
|
|
1589
1558
|
const isMdFile = fileExtension === ".md";
|
|
1590
|
-
import_shelljs2.default.mkdir("-p", (0,
|
|
1559
|
+
import_shelljs2.default.mkdir("-p", (0, import_path14.parse)(to).dir);
|
|
1591
1560
|
if (isMdFile) {
|
|
1592
1561
|
const fileContent = (0, import_fs3.readFileSync)(from, "utf8");
|
|
1593
|
-
const sourcePath = (0,
|
|
1562
|
+
const sourcePath = (0, import_path14.relative)(inputFolderPath, from);
|
|
1594
1563
|
const updatedFileContent = getContentWithUpdatedStaticMetadata({
|
|
1595
1564
|
fileContent,
|
|
1596
1565
|
sourcePath,
|
|
@@ -1605,14 +1574,14 @@ function _copyTocDir(tocPath, destDir) {
|
|
|
1605
1574
|
function _replaceIncludesHrefs(items, includeTocDir, tocDir) {
|
|
1606
1575
|
return items.reduce((acc, tocItem) => {
|
|
1607
1576
|
if (tocItem.href) {
|
|
1608
|
-
tocItem.href = (0,
|
|
1577
|
+
tocItem.href = (0, import_path14.relative)(tocDir, (0, import_path14.resolve)(includeTocDir, tocItem.href));
|
|
1609
1578
|
}
|
|
1610
1579
|
if (tocItem.items) {
|
|
1611
1580
|
tocItem.items = _replaceIncludesHrefs(tocItem.items, includeTocDir, tocDir);
|
|
1612
1581
|
}
|
|
1613
1582
|
if (tocItem.include) {
|
|
1614
1583
|
const { path } = tocItem.include;
|
|
1615
|
-
tocItem.include.path = (0,
|
|
1584
|
+
tocItem.include.path = (0, import_path14.relative)(tocDir, (0, import_path14.resolve)(includeTocDir, path));
|
|
1616
1585
|
}
|
|
1617
1586
|
return acc.concat(tocItem);
|
|
1618
1587
|
}, []);
|
|
@@ -1636,7 +1605,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
1636
1605
|
for (const item of items) {
|
|
1637
1606
|
let includedInlineItems = null;
|
|
1638
1607
|
if (item.name) {
|
|
1639
|
-
const tocPath = (0,
|
|
1608
|
+
const tocPath = (0, import_path14.join)(tocDir, "toc.yaml");
|
|
1640
1609
|
item.name = _liquidSubstitutions(item.name, vars, tocPath);
|
|
1641
1610
|
}
|
|
1642
1611
|
try {
|
|
@@ -1650,8 +1619,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
1650
1619
|
}
|
|
1651
1620
|
if (item.include) {
|
|
1652
1621
|
const { mode = "root_merge" /* ROOT_MERGE */ } = item.include;
|
|
1653
|
-
const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0,
|
|
1654
|
-
const includeTocDir = (0,
|
|
1622
|
+
const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0, import_path14.resolve)(sourcesDir, item.include.path) : (0, import_path14.resolve)(tocDir, item.include.path);
|
|
1623
|
+
const includeTocDir = (0, import_path14.dirname)(includeTocPath);
|
|
1655
1624
|
try {
|
|
1656
1625
|
const includeToc = (0, import_js_yaml4.load)((0, import_fs3.readFileSync)(includeTocPath, "utf8"));
|
|
1657
1626
|
if (includeToc.stage === "tech-preview" /* TECH_PREVIEW */) {
|
|
@@ -1684,7 +1653,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
1684
1653
|
}
|
|
1685
1654
|
} catch (err) {
|
|
1686
1655
|
const message = `Error while including toc: ${(0, import_chalk2.bold)(includeTocPath)} to ${(0, import_chalk2.bold)(
|
|
1687
|
-
(0,
|
|
1656
|
+
(0, import_path14.join)(tocDir, "toc.yaml")
|
|
1688
1657
|
)}`;
|
|
1689
1658
|
import_log3.default.error(message);
|
|
1690
1659
|
continue;
|
|
@@ -1705,8 +1674,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
1705
1674
|
}
|
|
1706
1675
|
function getTocDir(pagePath) {
|
|
1707
1676
|
const { input: inputFolderPath } = argv_default.getConfig();
|
|
1708
|
-
const tocDir = (0,
|
|
1709
|
-
const tocPath = (0,
|
|
1677
|
+
const tocDir = (0, import_path14.dirname)(pagePath);
|
|
1678
|
+
const tocPath = (0, import_path14.resolve)(tocDir, "toc.yaml");
|
|
1710
1679
|
if (!tocDir.includes(inputFolderPath)) {
|
|
1711
1680
|
throw new Error("Error while finding toc dir");
|
|
1712
1681
|
}
|
|
@@ -1728,19 +1697,19 @@ var tocs_default = {
|
|
|
1728
1697
|
};
|
|
1729
1698
|
|
|
1730
1699
|
// src/services/preset.ts
|
|
1731
|
-
var
|
|
1700
|
+
var import_path15 = require("path");
|
|
1732
1701
|
var presetStorage = /* @__PURE__ */ new Map();
|
|
1733
1702
|
function add2(parsedPreset, path, varsPreset) {
|
|
1734
1703
|
const combinedValues = __spreadValues(__spreadValues({}, parsedPreset.default || {}), parsedPreset[varsPreset] || {});
|
|
1735
|
-
const key = (0,
|
|
1704
|
+
const key = (0, import_path15.dirname)((0, import_path15.normalize)(path));
|
|
1736
1705
|
presetStorage.set(key, combinedValues);
|
|
1737
1706
|
}
|
|
1738
1707
|
function get(path) {
|
|
1739
1708
|
let combinedValues = {};
|
|
1740
|
-
let localPath = (0,
|
|
1709
|
+
let localPath = (0, import_path15.normalize)(path);
|
|
1741
1710
|
while (localPath !== ".") {
|
|
1742
1711
|
const presetValues = presetStorage.get(localPath) || {};
|
|
1743
|
-
localPath = (0,
|
|
1712
|
+
localPath = (0, import_path15.dirname)(localPath);
|
|
1744
1713
|
combinedValues = __spreadValues(__spreadValues({}, presetValues), combinedValues);
|
|
1745
1714
|
}
|
|
1746
1715
|
combinedValues = __spreadValues(__spreadValues({}, presetStorage.get(".")), combinedValues);
|
|
@@ -1760,7 +1729,7 @@ var preset_default = {
|
|
|
1760
1729
|
};
|
|
1761
1730
|
|
|
1762
1731
|
// src/services/argv.ts
|
|
1763
|
-
var
|
|
1732
|
+
var import_path16 = require("path");
|
|
1764
1733
|
var import_fs4 = require("fs");
|
|
1765
1734
|
var _argv;
|
|
1766
1735
|
function getConfig() {
|
|
@@ -1774,7 +1743,7 @@ function init2(argv) {
|
|
|
1774
1743
|
_argv.vars = JSON.parse(argv.vars);
|
|
1775
1744
|
}
|
|
1776
1745
|
try {
|
|
1777
|
-
const ignorefile = (0, import_fs4.readFileSync)((0,
|
|
1746
|
+
const ignorefile = (0, import_fs4.readFileSync)((0, import_path16.join)(_argv.rootInput, ".yfmignore"), "utf8");
|
|
1778
1747
|
const ignore = ignorefile.split("\n");
|
|
1779
1748
|
_argv.ignore = _argv.ignore.concat(ignore);
|
|
1780
1749
|
} catch (e) {
|
|
@@ -1790,15 +1759,15 @@ var argv_default = {
|
|
|
1790
1759
|
};
|
|
1791
1760
|
|
|
1792
1761
|
// src/services/leading.ts
|
|
1793
|
-
var
|
|
1762
|
+
var import_path17 = require("path");
|
|
1794
1763
|
var import_fs5 = require("fs");
|
|
1795
1764
|
var import_js_yaml5 = require("js-yaml");
|
|
1796
1765
|
var import_log4 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
1797
1766
|
function filterFile(path) {
|
|
1798
1767
|
var _a, _b;
|
|
1799
1768
|
const { input: inputFolderPath, vars } = argv_default.getConfig();
|
|
1800
|
-
const pathToDir = (0,
|
|
1801
|
-
const filePath = (0,
|
|
1769
|
+
const pathToDir = (0, import_path17.dirname)(path);
|
|
1770
|
+
const filePath = (0, import_path17.resolve)(inputFolderPath, path);
|
|
1802
1771
|
const content = (0, import_fs5.readFileSync)(filePath, "utf8");
|
|
1803
1772
|
const parsedIndex = (0, import_js_yaml5.load)(content);
|
|
1804
1773
|
const combinedVars = __spreadValues(__spreadValues({}, preset_default.get(pathToDir)), vars);
|
|
@@ -1926,7 +1895,6 @@ var import_includer = __toESM(require("@diplodoc/openapi-extension/includer"));
|
|
|
1926
1895
|
// src/steps/processAssets.ts
|
|
1927
1896
|
var import_walk_sync2 = __toESM(require("walk-sync"));
|
|
1928
1897
|
var import_shelljs3 = __toESM(require("shelljs"));
|
|
1929
|
-
var import_client3 = __toESM(require_client());
|
|
1930
1898
|
function processAssets(outputBundlePath) {
|
|
1931
1899
|
const { input: inputFolderPath, output: outputFolderPath } = argv_default.getConfig();
|
|
1932
1900
|
const assetFilePath = (0, import_walk_sync2.default)(inputFolderPath, {
|
|
@@ -1936,13 +1904,11 @@ function processAssets(outputBundlePath) {
|
|
|
1936
1904
|
});
|
|
1937
1905
|
copyFiles(inputFolderPath, outputFolderPath, assetFilePath);
|
|
1938
1906
|
import_shelljs3.default.mkdir("-p", outputBundlePath);
|
|
1939
|
-
|
|
1940
|
-
import_shelljs3.default.cp(path, outputBundlePath);
|
|
1941
|
-
}
|
|
1907
|
+
import_shelljs3.default.cp(ASSETS_FOLDER + "/*", outputBundlePath);
|
|
1942
1908
|
}
|
|
1943
1909
|
|
|
1944
1910
|
// src/steps/processExcludedFiles.ts
|
|
1945
|
-
var
|
|
1911
|
+
var import_path18 = require("path");
|
|
1946
1912
|
var import_walk_sync3 = __toESM(require("walk-sync"));
|
|
1947
1913
|
var import_shelljs4 = __toESM(require("shelljs"));
|
|
1948
1914
|
function processExcludedFiles() {
|
|
@@ -1955,14 +1921,14 @@ function processExcludedFiles() {
|
|
|
1955
1921
|
ignore: ["**/_*/**/*"]
|
|
1956
1922
|
});
|
|
1957
1923
|
const navigationPaths2 = tocs_default.getNavigationPaths().map(
|
|
1958
|
-
(filePath) => convertBackSlashToSlash((0,
|
|
1924
|
+
(filePath) => convertBackSlashToSlash((0, import_path18.resolve)(inputFolderPath, filePath))
|
|
1959
1925
|
);
|
|
1960
1926
|
const tocSpecifiedFiles = new Set(navigationPaths2);
|
|
1961
1927
|
const excludedFiles = allContentFiles.filter((filePath) => !tocSpecifiedFiles.has(filePath));
|
|
1962
1928
|
import_shelljs4.default.rm("-f", excludedFiles);
|
|
1963
1929
|
const includedTocPaths2 = tocs_default.getIncludedTocPaths().map((filePath) => {
|
|
1964
|
-
const relativeTocPath = (0,
|
|
1965
|
-
const destTocPath = (0,
|
|
1930
|
+
const relativeTocPath = (0, import_path18.relative)(inputFolderPath, filePath);
|
|
1931
|
+
const destTocPath = (0, import_path18.resolve)(outputFolderPath, relativeTocPath);
|
|
1966
1932
|
return convertBackSlashToSlash(destTocPath);
|
|
1967
1933
|
});
|
|
1968
1934
|
import_shelljs4.default.rm("-rf", includedTocPaths2);
|
|
@@ -1982,7 +1948,7 @@ function processLogs(inputFolder) {
|
|
|
1982
1948
|
}
|
|
1983
1949
|
|
|
1984
1950
|
// src/steps/processPages.ts
|
|
1985
|
-
var
|
|
1951
|
+
var import_path23 = require("path");
|
|
1986
1952
|
var import_shelljs6 = __toESM(require("shelljs"));
|
|
1987
1953
|
var import_fs9 = require("fs");
|
|
1988
1954
|
var import_chalk4 = require("chalk");
|
|
@@ -1992,7 +1958,7 @@ var import_log11 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
|
1992
1958
|
|
|
1993
1959
|
// src/resolvers/md2md.ts
|
|
1994
1960
|
var import_fs6 = require("fs");
|
|
1995
|
-
var
|
|
1961
|
+
var import_path19 = require("path");
|
|
1996
1962
|
var import_shelljs5 = __toESM(require("shelljs"));
|
|
1997
1963
|
var import_log6 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
1998
1964
|
var import_liquid3 = __toESM(require("@diplodoc/transform/lib/liquid"));
|
|
@@ -2000,7 +1966,7 @@ function resolveMd2Md(options) {
|
|
|
2000
1966
|
return __async(this, null, function* () {
|
|
2001
1967
|
const { inputPath, outputPath, metadata } = options;
|
|
2002
1968
|
const { input, output } = argv_default.getConfig();
|
|
2003
|
-
const resolvedInputPath = (0,
|
|
1969
|
+
const resolvedInputPath = (0, import_path19.resolve)(input, inputPath);
|
|
2004
1970
|
const vars = getVarsPerFile(inputPath);
|
|
2005
1971
|
const content = yield getContentWithUpdatedMetadata(
|
|
2006
1972
|
(0, import_fs6.readFileSync)(resolvedInputPath, "utf8"),
|
|
@@ -2010,8 +1976,8 @@ function resolveMd2Md(options) {
|
|
|
2010
1976
|
const { result, changelogs } = transformMd2Md(content, {
|
|
2011
1977
|
path: resolvedInputPath,
|
|
2012
1978
|
destPath: outputPath,
|
|
2013
|
-
root: (0,
|
|
2014
|
-
destRoot: (0,
|
|
1979
|
+
root: (0, import_path19.resolve)(input),
|
|
1980
|
+
destRoot: (0, import_path19.resolve)(output),
|
|
2015
1981
|
collectOfPlugins: plugins_exports.getCollectOfPlugins(),
|
|
2016
1982
|
vars,
|
|
2017
1983
|
log: import_log6.default,
|
|
@@ -2019,8 +1985,8 @@ function resolveMd2Md(options) {
|
|
|
2019
1985
|
});
|
|
2020
1986
|
(0, import_fs6.writeFileSync)(outputPath, result);
|
|
2021
1987
|
if (changelogs == null ? void 0 : changelogs.length) {
|
|
2022
|
-
const mdFilename = (0,
|
|
2023
|
-
const outputDir = (0,
|
|
1988
|
+
const mdFilename = (0, import_path19.basename)(outputPath, (0, import_path19.extname)(outputPath));
|
|
1989
|
+
const outputDir = (0, import_path19.dirname)(outputPath);
|
|
2024
1990
|
changelogs.forEach((changes, index) => {
|
|
2025
1991
|
let changesName;
|
|
2026
1992
|
const changesDate = changes.date;
|
|
@@ -2037,7 +2003,7 @@ function resolveMd2Md(options) {
|
|
|
2037
2003
|
"0"
|
|
2038
2004
|
)}`;
|
|
2039
2005
|
}
|
|
2040
|
-
const changesPath = (0,
|
|
2006
|
+
const changesPath = (0, import_path19.join)(outputDir, `changes-${changesName}.json`);
|
|
2041
2007
|
if ((0, import_fs6.existsSync)(changesPath)) {
|
|
2042
2008
|
throw new Error(`Changelog ${changesPath} already exists!`);
|
|
2043
2009
|
}
|
|
@@ -2054,7 +2020,7 @@ function resolveMd2Md(options) {
|
|
|
2054
2020
|
});
|
|
2055
2021
|
}
|
|
2056
2022
|
function copyFile(targetPath, targetDestPath, options) {
|
|
2057
|
-
import_shelljs5.default.mkdir("-p", (0,
|
|
2023
|
+
import_shelljs5.default.mkdir("-p", (0, import_path19.dirname)(targetDestPath));
|
|
2058
2024
|
if (options) {
|
|
2059
2025
|
const sourceIncludeContent = (0, import_fs6.readFileSync)(targetPath, "utf8");
|
|
2060
2026
|
const { result } = transformMd2Md(sourceIncludeContent, options);
|
|
@@ -2113,7 +2079,7 @@ function transformMd2Md(input, options) {
|
|
|
2113
2079
|
}
|
|
2114
2080
|
|
|
2115
2081
|
// src/resolvers/md2html.ts
|
|
2116
|
-
var
|
|
2082
|
+
var import_path20 = require("path");
|
|
2117
2083
|
var import_fs7 = require("fs");
|
|
2118
2084
|
var import_js_yaml6 = __toESM(require("js-yaml"));
|
|
2119
2085
|
var import_transform = __toESM(require("@diplodoc/transform"));
|
|
@@ -2124,19 +2090,19 @@ var FileTransformer = {
|
|
|
2124
2090
|
".md": MdFileTransformer
|
|
2125
2091
|
};
|
|
2126
2092
|
var fixRelativePath = (relativeTo) => (path) => {
|
|
2127
|
-
return (0,
|
|
2093
|
+
return (0, import_path20.join)(getAssetsPublicPath(relativeTo), path);
|
|
2128
2094
|
};
|
|
2129
2095
|
function resolveMd2HTML(options) {
|
|
2130
2096
|
return __async(this, null, function* () {
|
|
2131
2097
|
var _a;
|
|
2132
2098
|
const { inputPath, fileExtension, outputPath, outputBundlePath, metadata } = options;
|
|
2133
|
-
const pathToDir = (0,
|
|
2099
|
+
const pathToDir = (0, import_path20.dirname)(inputPath);
|
|
2134
2100
|
const toc = tocs_default.getForPath(inputPath) || null;
|
|
2135
2101
|
const tocBase = toc && toc.base ? toc.base : "";
|
|
2136
|
-
const pathToFileDir = pathToDir === tocBase ? "" : pathToDir.replace(`${tocBase}${
|
|
2137
|
-
const relativePathToIndex = (0,
|
|
2102
|
+
const pathToFileDir = pathToDir === tocBase ? "" : pathToDir.replace(`${tocBase}${import_path20.sep}`, "");
|
|
2103
|
+
const relativePathToIndex = (0, import_path20.relative)(pathToDir, `${tocBase}${import_path20.sep}`);
|
|
2138
2104
|
const { input, lang, allowCustomResources } = argv_default.getConfig();
|
|
2139
|
-
const resolvedPath = (0,
|
|
2105
|
+
const resolvedPath = (0, import_path20.resolve)(input, inputPath);
|
|
2140
2106
|
const content = (0, import_fs7.readFileSync)(resolvedPath, "utf8");
|
|
2141
2107
|
const transformFn = FileTransformer[fileExtension];
|
|
2142
2108
|
const { result } = transformFn(content, { path: inputPath });
|
|
@@ -2158,12 +2124,12 @@ function resolveMd2HTML(options) {
|
|
|
2158
2124
|
meta: fileMeta
|
|
2159
2125
|
}),
|
|
2160
2126
|
router: {
|
|
2161
|
-
pathname: (0,
|
|
2127
|
+
pathname: (0, import_path20.join)(relativePathToIndex, pathToFileDir, (0, import_path20.basename)(outputPath))
|
|
2162
2128
|
},
|
|
2163
2129
|
lang: lang || "ru" /* RU */
|
|
2164
2130
|
};
|
|
2165
|
-
const outputDir = (0,
|
|
2166
|
-
const relativePathToBundle = (0,
|
|
2131
|
+
const outputDir = (0, import_path20.dirname)(outputPath);
|
|
2132
|
+
const relativePathToBundle = (0, import_path20.relative)((0, import_path20.resolve)(outputDir), (0, import_path20.resolve)(outputBundlePath));
|
|
2167
2133
|
const outputFileContent = generateStaticMarkup(props, relativePathToBundle);
|
|
2168
2134
|
(0, import_fs7.writeFileSync)(outputPath, outputFileContent);
|
|
2169
2135
|
logger.info(inputPath, PROCESSING_FINISHED);
|
|
@@ -2205,8 +2171,8 @@ function MdFileTransformer(content, transformOptions) {
|
|
|
2205
2171
|
const { path: filePath } = transformOptions;
|
|
2206
2172
|
const plugins2 = plugins_exports.getPlugins();
|
|
2207
2173
|
const vars = getVarsPerFile(filePath);
|
|
2208
|
-
const root = (0,
|
|
2209
|
-
const path = (0,
|
|
2174
|
+
const root = (0, import_path20.resolve)(input);
|
|
2175
|
+
const path = (0, import_path20.resolve)(input, filePath);
|
|
2210
2176
|
return (0, import_transform.default)(content, __spreadProps(__spreadValues({}, options), {
|
|
2211
2177
|
plugins: plugins2,
|
|
2212
2178
|
vars,
|
|
@@ -2219,7 +2185,7 @@ function MdFileTransformer(content, transformOptions) {
|
|
|
2219
2185
|
}
|
|
2220
2186
|
|
|
2221
2187
|
// src/resolvers/lintPage.ts
|
|
2222
|
-
var
|
|
2188
|
+
var import_path21 = require("path");
|
|
2223
2189
|
var import_log8 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
2224
2190
|
var import_yfmlint = __toESM(require("@diplodoc/transform/lib/yfmlint"));
|
|
2225
2191
|
var import_fs8 = require("fs");
|
|
@@ -2230,7 +2196,7 @@ var FileLinter = {
|
|
|
2230
2196
|
function lintPage(options) {
|
|
2231
2197
|
const { inputPath, fileExtension, onFinish } = options;
|
|
2232
2198
|
const { input } = argv_default.getConfig();
|
|
2233
|
-
const resolvedPath = (0,
|
|
2199
|
+
const resolvedPath = (0, import_path21.resolve)(input, inputPath);
|
|
2234
2200
|
try {
|
|
2235
2201
|
const content = (0, import_fs8.readFileSync)(resolvedPath, "utf8");
|
|
2236
2202
|
const lintFn = FileLinter[fileExtension];
|
|
@@ -2252,10 +2218,10 @@ function MdFileLinter(content, lintOptions) {
|
|
|
2252
2218
|
const { path: filePath } = lintOptions;
|
|
2253
2219
|
const plugins2 = outputFormat === "md" ? [] : plugins_exports.getPlugins();
|
|
2254
2220
|
const vars = getVarsPerFile(filePath);
|
|
2255
|
-
const root = (0,
|
|
2256
|
-
const path = (0,
|
|
2221
|
+
const root = (0, import_path21.resolve)(input);
|
|
2222
|
+
const path = (0, import_path21.resolve)(input, filePath);
|
|
2257
2223
|
let preparedContent = content;
|
|
2258
|
-
const assetsPublicPath = (0,
|
|
2224
|
+
const assetsPublicPath = (0, import_path21.relative)((0, import_path21.dirname)(path), root);
|
|
2259
2225
|
const lintMarkdown = function lintMarkdown2(opts) {
|
|
2260
2226
|
const { input: localInput, path: localPath, sourceMap: sourceMap2 } = opts;
|
|
2261
2227
|
const pluginOptions = __spreadProps(__spreadValues({}, options), {
|
|
@@ -2299,7 +2265,7 @@ function MdFileLinter(content, lintOptions) {
|
|
|
2299
2265
|
|
|
2300
2266
|
// src/vcs-connector/github.ts
|
|
2301
2267
|
var import_core = require("@octokit/core");
|
|
2302
|
-
var
|
|
2268
|
+
var import_path22 = require("path");
|
|
2303
2269
|
var import_simple_git = __toESM(require("simple-git"));
|
|
2304
2270
|
var import_minimatch = require("minimatch");
|
|
2305
2271
|
|
|
@@ -2513,7 +2479,7 @@ function getAllContributorsTocFiles(httpClientByToken) {
|
|
|
2513
2479
|
"origin/master"
|
|
2514
2480
|
);
|
|
2515
2481
|
const fullRepoLogString = yield (0, import_simple_git.default)({
|
|
2516
|
-
baseDir: (0,
|
|
2482
|
+
baseDir: (0, import_path22.join)(rootInput, masterDir)
|
|
2517
2483
|
}).raw(
|
|
2518
2484
|
"log",
|
|
2519
2485
|
`${FIRST_COMMIT_FROM_ROBOT_IN_GITHUB}..HEAD`,
|
|
@@ -2523,7 +2489,7 @@ function getAllContributorsTocFiles(httpClientByToken) {
|
|
|
2523
2489
|
const repoLogs = fullRepoLogString.split("\n\n");
|
|
2524
2490
|
if (import_process2.default.env.ENABLE_EXPERIMANTAL_AUTHORS) {
|
|
2525
2491
|
const fullAuthorRepoLogString = yield (0, import_simple_git.default)({
|
|
2526
|
-
baseDir: (0,
|
|
2492
|
+
baseDir: (0, import_path22.join)(rootInput, masterDir)
|
|
2527
2493
|
}).raw(
|
|
2528
2494
|
"log",
|
|
2529
2495
|
`${FIRST_COMMIT_FROM_ROBOT_IN_GITHUB}..HEAD`,
|
|
@@ -2620,7 +2586,7 @@ function getAuthorByPaths(commitInfo, paths, httpClientByToken) {
|
|
|
2620
2586
|
if (!path) {
|
|
2621
2587
|
continue;
|
|
2622
2588
|
}
|
|
2623
|
-
const normalizePath = (0,
|
|
2589
|
+
const normalizePath = (0, import_path22.normalize)(addSlashPrefix(path));
|
|
2624
2590
|
const { email, hashCommit } = commitInfo;
|
|
2625
2591
|
let authorToReturn = authorByGitEmail.get(email) || null;
|
|
2626
2592
|
if (!authorToReturn) {
|
|
@@ -2681,7 +2647,7 @@ function addNestedContributorsForPathFunction(path, nestedContributors) {
|
|
|
2681
2647
|
}
|
|
2682
2648
|
function addContributorForPath(paths, newContributor, hasIncludes = false) {
|
|
2683
2649
|
paths.forEach((path) => {
|
|
2684
|
-
const normalizePath = (0,
|
|
2650
|
+
const normalizePath = (0, import_path22.normalize)(addSlashPrefix(path));
|
|
2685
2651
|
if (!contributorsByPath.has(normalizePath)) {
|
|
2686
2652
|
contributorsByPath.set(normalizePath, {
|
|
2687
2653
|
contributors: newContributor,
|
|
@@ -2776,14 +2742,14 @@ function processPages(outputBundlePath) {
|
|
|
2776
2742
|
});
|
|
2777
2743
|
}
|
|
2778
2744
|
function getPathData(pathToFile, inputFolderPath, outputFolderPath, outputFormat, outputBundlePath) {
|
|
2779
|
-
const pathToDir = (0,
|
|
2780
|
-
const filename = (0,
|
|
2781
|
-
const fileExtension = (0,
|
|
2782
|
-
const fileBaseName = (0,
|
|
2783
|
-
const outputDir = (0,
|
|
2745
|
+
const pathToDir = (0, import_path23.dirname)(pathToFile);
|
|
2746
|
+
const filename = (0, import_path23.basename)(pathToFile);
|
|
2747
|
+
const fileExtension = (0, import_path23.extname)(pathToFile);
|
|
2748
|
+
const fileBaseName = (0, import_path23.basename)(filename, fileExtension);
|
|
2749
|
+
const outputDir = (0, import_path23.resolve)(outputFolderPath, pathToDir);
|
|
2784
2750
|
const outputFileName = `${fileBaseName}.${outputFormat}`;
|
|
2785
|
-
const outputPath = (0,
|
|
2786
|
-
const resolvedPathToFile = (0,
|
|
2751
|
+
const outputPath = (0, import_path23.resolve)(outputDir, outputFileName);
|
|
2752
|
+
const resolvedPathToFile = (0, import_path23.resolve)(inputFolderPath, pathToFile);
|
|
2787
2753
|
const outputTocDir = tocs_default.getTocDir(resolvedPathToFile);
|
|
2788
2754
|
const pathData = {
|
|
2789
2755
|
pathToFile,
|
|
@@ -2820,11 +2786,11 @@ function saveSinglePages(outputBundlePath) {
|
|
|
2820
2786
|
inputFolderPath,
|
|
2821
2787
|
tocDir
|
|
2822
2788
|
);
|
|
2823
|
-
const tocPath = (0,
|
|
2789
|
+
const tocPath = (0, import_path23.join)((0, import_path23.relative)(inputFolderPath, tocDir), "toc.yaml");
|
|
2824
2790
|
const toc = tocs_default.getForPath(tocPath) || null;
|
|
2825
2791
|
const preparedToc = transformTocForSinglePage(toc, {
|
|
2826
2792
|
root: inputFolderPath,
|
|
2827
|
-
currentPath: (0,
|
|
2793
|
+
currentPath: (0, import_path23.join)(tocDir, SINGLE_PAGE_FILENAME)
|
|
2828
2794
|
});
|
|
2829
2795
|
const pageData = {
|
|
2830
2796
|
data: {
|
|
@@ -2839,10 +2805,10 @@ function saveSinglePages(outputBundlePath) {
|
|
|
2839
2805
|
},
|
|
2840
2806
|
lang: lang || "ru" /* RU */
|
|
2841
2807
|
};
|
|
2842
|
-
const outputTocDir = (0,
|
|
2843
|
-
const relativeOutputBundlePath = (0,
|
|
2844
|
-
const singlePageFn = (0,
|
|
2845
|
-
const singlePageDataFn = (0,
|
|
2808
|
+
const outputTocDir = (0, import_path23.resolve)(outputFolderPath, (0, import_path23.relative)(inputFolderPath, tocDir));
|
|
2809
|
+
const relativeOutputBundlePath = (0, import_path23.relative)(outputTocDir, outputBundlePath);
|
|
2810
|
+
const singlePageFn = (0, import_path23.join)(tocDir, SINGLE_PAGE_FILENAME);
|
|
2811
|
+
const singlePageDataFn = (0, import_path23.join)(tocDir, SINGLE_PAGE_DATA_FILENAME);
|
|
2846
2812
|
const singlePageContent = generateStaticMarkup(pageData, relativeOutputBundlePath);
|
|
2847
2813
|
(0, import_fs9.writeFileSync)(singlePageFn, singlePageContent);
|
|
2848
2814
|
(0, import_fs9.writeFileSync)(singlePageDataFn, JSON.stringify(pageData));
|
|
@@ -2940,17 +2906,17 @@ function preparingPagesByOutputFormat(path, metaDataOptions, resolveConditions,
|
|
|
2940
2906
|
}
|
|
2941
2907
|
function processingYamlFile(path, metaDataOptions) {
|
|
2942
2908
|
const { pathToFile, outputFolderPath, inputFolderPath } = path;
|
|
2943
|
-
const filePath = (0,
|
|
2909
|
+
const filePath = (0, import_path23.resolve)(inputFolderPath, pathToFile);
|
|
2944
2910
|
const content = (0, import_fs9.readFileSync)(filePath, "utf8");
|
|
2945
2911
|
const parsedContent = (0, import_js_yaml7.load)(content);
|
|
2946
2912
|
if (metaDataOptions.resources) {
|
|
2947
2913
|
parsedContent.meta = __spreadValues(__spreadValues({}, parsedContent.meta), metaDataOptions.resources);
|
|
2948
2914
|
}
|
|
2949
|
-
(0, import_fs9.writeFileSync)((0,
|
|
2915
|
+
(0, import_fs9.writeFileSync)((0, import_path23.resolve)(outputFolderPath, pathToFile), (0, import_js_yaml7.dump)(parsedContent));
|
|
2950
2916
|
}
|
|
2951
2917
|
function copyFileWithoutChanges(resolvedPathToFile, outputDir, filename) {
|
|
2952
2918
|
const from = resolvedPathToFile;
|
|
2953
|
-
const to = (0,
|
|
2919
|
+
const to = (0, import_path23.resolve)(outputDir, filename);
|
|
2954
2920
|
import_shelljs6.default.cp(from, to);
|
|
2955
2921
|
}
|
|
2956
2922
|
function processingFileToMd(path, metaDataOptions) {
|
|
@@ -2980,7 +2946,7 @@ function processingFileToHtml(path, metaDataOptions) {
|
|
|
2980
2946
|
// src/steps/processLinter.ts
|
|
2981
2947
|
var import_log12 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
2982
2948
|
var import_threads = require("threads");
|
|
2983
|
-
var
|
|
2949
|
+
var import_path24 = require("path");
|
|
2984
2950
|
|
|
2985
2951
|
// src/utils/worker.ts
|
|
2986
2952
|
function splitOnChunks(array, chunkSize = 1e3) {
|
|
@@ -3057,7 +3023,7 @@ function lintPagesFallback(navigationPaths2) {
|
|
|
3057
3023
|
navigationPaths2.forEach((pathToFile) => {
|
|
3058
3024
|
lintPage({
|
|
3059
3025
|
inputPath: pathToFile,
|
|
3060
|
-
fileExtension: (0,
|
|
3026
|
+
fileExtension: (0, import_path24.extname)(pathToFile),
|
|
3061
3027
|
onFinish: () => {
|
|
3062
3028
|
logger.info(pathToFile, LINTING_FINISHED);
|
|
3063
3029
|
}
|
|
@@ -3066,7 +3032,7 @@ function lintPagesFallback(navigationPaths2) {
|
|
|
3066
3032
|
}
|
|
3067
3033
|
|
|
3068
3034
|
// src/steps/processServiceFiles.ts
|
|
3069
|
-
var
|
|
3035
|
+
var import_path25 = require("path");
|
|
3070
3036
|
var import_walk_sync4 = __toESM(require("walk-sync"));
|
|
3071
3037
|
var import_fs10 = require("fs");
|
|
3072
3038
|
var import_js_yaml8 = require("js-yaml");
|
|
@@ -3099,7 +3065,7 @@ function preparingPresetFiles(getFilePathsByGlobals) {
|
|
|
3099
3065
|
const presetsFilePaths = getFilePathsByGlobals(["**/presets.yaml"]);
|
|
3100
3066
|
for (const path of presetsFilePaths) {
|
|
3101
3067
|
logger.proc(path);
|
|
3102
|
-
const pathToPresetFile = (0,
|
|
3068
|
+
const pathToPresetFile = (0, import_path25.resolve)(inputFolderPath, path);
|
|
3103
3069
|
const content = (0, import_fs10.readFileSync)(pathToPresetFile, "utf8");
|
|
3104
3070
|
const parsedPreset = (0, import_js_yaml8.load)(content);
|
|
3105
3071
|
preset_default.add(parsedPreset, path, varsPreset);
|
|
@@ -3114,7 +3080,7 @@ function preparingPresetFiles(getFilePathsByGlobals) {
|
|
|
3114
3080
|
}
|
|
3115
3081
|
function saveFilteredPresets(path, parsedPreset) {
|
|
3116
3082
|
const { output: outputFolderPath, varsPreset = "" } = argv_default.getConfig();
|
|
3117
|
-
const outputPath = (0,
|
|
3083
|
+
const outputPath = (0, import_path25.resolve)(outputFolderPath, path);
|
|
3118
3084
|
const filteredPreset = {
|
|
3119
3085
|
default: parsedPreset.default
|
|
3120
3086
|
};
|
|
@@ -3124,7 +3090,7 @@ function saveFilteredPresets(path, parsedPreset) {
|
|
|
3124
3090
|
const outputPreset = (0, import_js_yaml8.dump)(filteredPreset, {
|
|
3125
3091
|
lineWidth: 120
|
|
3126
3092
|
});
|
|
3127
|
-
import_shelljs7.default.mkdir("-p", (0,
|
|
3093
|
+
import_shelljs7.default.mkdir("-p", (0, import_path25.dirname)(outputPath));
|
|
3128
3094
|
(0, import_fs10.writeFileSync)(outputPath, outputPreset);
|
|
3129
3095
|
}
|
|
3130
3096
|
function preparingTocFiles(getFilePathsByGlobals) {
|
|
@@ -3144,11 +3110,11 @@ function preparingTocFiles(getFilePathsByGlobals) {
|
|
|
3144
3110
|
|
|
3145
3111
|
// src/steps/processMapFile.ts
|
|
3146
3112
|
var import_fs11 = require("fs");
|
|
3147
|
-
var
|
|
3113
|
+
var import_path26 = require("path");
|
|
3148
3114
|
function prepareMapFile() {
|
|
3149
3115
|
const { output: outputFolderPath } = argv_default.getConfig();
|
|
3150
3116
|
const navigationPathsWithoutExtensions = tocs_default.getNavigationPaths().map((path) => {
|
|
3151
|
-
let preparedPath = convertBackSlashToSlash(path.replace((0,
|
|
3117
|
+
let preparedPath = convertBackSlashToSlash(path.replace((0, import_path26.extname)(path), ""));
|
|
3152
3118
|
if (preparedPath.endsWith("/index")) {
|
|
3153
3119
|
preparedPath = preparedPath.substring(0, preparedPath.length - 5);
|
|
3154
3120
|
}
|
|
@@ -3156,7 +3122,7 @@ function prepareMapFile() {
|
|
|
3156
3122
|
});
|
|
3157
3123
|
const navigationPaths2 = { files: [...new Set(navigationPathsWithoutExtensions)] };
|
|
3158
3124
|
const filesMapBuffer = Buffer.from(JSON.stringify(navigationPaths2, null, " "), "utf8");
|
|
3159
|
-
const mapFile = (0,
|
|
3125
|
+
const mapFile = (0, import_path26.join)(outputFolderPath, "files.json");
|
|
3160
3126
|
(0, import_fs11.writeFileSync)(mapFile, filesMapBuffer);
|
|
3161
3127
|
}
|
|
3162
3128
|
|
|
@@ -3166,7 +3132,7 @@ var import_shelljs8 = __toESM(require("shelljs"));
|
|
|
3166
3132
|
// src/cmd/publish/upload.ts
|
|
3167
3133
|
var import_fs12 = require("fs");
|
|
3168
3134
|
var import_walk_sync5 = __toESM(require("walk-sync"));
|
|
3169
|
-
var
|
|
3135
|
+
var import_path27 = require("path");
|
|
3170
3136
|
var import_client_s3 = require("@aws-sdk/client-s3");
|
|
3171
3137
|
var import_mime_types = __toESM(require("mime-types"));
|
|
3172
3138
|
var import_async2 = require("async");
|
|
@@ -3187,7 +3153,7 @@ function upload(props) {
|
|
|
3187
3153
|
region,
|
|
3188
3154
|
credentials: { accessKeyId, secretAccessKey }
|
|
3189
3155
|
});
|
|
3190
|
-
const filesToPublish = (0, import_walk_sync5.default)((0,
|
|
3156
|
+
const filesToPublish = (0, import_walk_sync5.default)((0, import_path27.resolve)(input), {
|
|
3191
3157
|
directories: false,
|
|
3192
3158
|
includeBasePath: false,
|
|
3193
3159
|
ignore
|
|
@@ -3203,8 +3169,8 @@ function upload(props) {
|
|
|
3203
3169
|
new import_client_s3.PutObjectCommand({
|
|
3204
3170
|
ContentType: mimeType ? mimeType : void 0,
|
|
3205
3171
|
Bucket: bucket,
|
|
3206
|
-
Key: convertBackSlashToSlash((0,
|
|
3207
|
-
Body: (0, import_fs12.createReadStream)((0,
|
|
3172
|
+
Key: convertBackSlashToSlash((0, import_path27.join)(prefix, pathToFile)),
|
|
3173
|
+
Body: (0, import_fs12.createReadStream)((0, import_path27.resolve)(input, pathToFile))
|
|
3208
3174
|
})
|
|
3209
3175
|
);
|
|
3210
3176
|
} catch (error) {
|
|
@@ -3339,9 +3305,9 @@ function builder(argv) {
|
|
|
3339
3305
|
function handler(args) {
|
|
3340
3306
|
return __async(this, null, function* () {
|
|
3341
3307
|
var _a;
|
|
3342
|
-
const userOutputFolder = (0,
|
|
3343
|
-
const tmpInputFolder = (0,
|
|
3344
|
-
const tmpOutputFolder = (0,
|
|
3308
|
+
const userOutputFolder = (0, import_path28.resolve)(args.output);
|
|
3309
|
+
const tmpInputFolder = (0, import_path28.resolve)(args.output, TMP_INPUT_FOLDER);
|
|
3310
|
+
const tmpOutputFolder = (0, import_path28.resolve)(args.output, TMP_OUTPUT_FOLDER);
|
|
3345
3311
|
try {
|
|
3346
3312
|
argv_default.init(__spreadProps(__spreadValues({}, args), {
|
|
3347
3313
|
rootInput: args.input,
|
|
@@ -3365,10 +3331,10 @@ function handler(args) {
|
|
|
3365
3331
|
if (addMapFile) {
|
|
3366
3332
|
prepareMapFile();
|
|
3367
3333
|
}
|
|
3368
|
-
const outputBundlePath = (0,
|
|
3369
|
-
const pathToConfig = args.config || (0,
|
|
3370
|
-
const pathToRedirects = (0,
|
|
3371
|
-
const pathToLintConfig = (0,
|
|
3334
|
+
const outputBundlePath = (0, import_path28.join)(outputFolderPath, BUNDLE_FOLDER);
|
|
3335
|
+
const pathToConfig = args.config || (0, import_path28.join)(args.input, YFM_CONFIG_FILENAME);
|
|
3336
|
+
const pathToRedirects = (0, import_path28.join)(args.input, REDIRECTS_FILENAME);
|
|
3337
|
+
const pathToLintConfig = (0, import_path28.join)(args.input, LINT_CONFIG_FILENAME);
|
|
3372
3338
|
if (!lintDisabled) {
|
|
3373
3339
|
yield initLinterWorkers();
|
|
3374
3340
|
}
|
|
@@ -3383,9 +3349,9 @@ function handler(args) {
|
|
|
3383
3349
|
processAssets(outputBundlePath);
|
|
3384
3350
|
break;
|
|
3385
3351
|
case "md": {
|
|
3386
|
-
import_shelljs8.default.cp((0,
|
|
3387
|
-
import_shelljs8.default.cp((0,
|
|
3388
|
-
import_shelljs8.default.cp((0,
|
|
3352
|
+
import_shelljs8.default.cp((0, import_path28.resolve)(pathToConfig), tmpOutputFolder);
|
|
3353
|
+
import_shelljs8.default.cp((0, import_path28.resolve)(pathToRedirects), tmpOutputFolder);
|
|
3354
|
+
import_shelljs8.default.cp((0, import_path28.resolve)(pathToLintConfig), tmpOutputFolder);
|
|
3389
3355
|
if (resources && allowCustomResources) {
|
|
3390
3356
|
const resourcePaths = [];
|
|
3391
3357
|
Object.keys(resources).forEach(
|
|
@@ -3403,7 +3369,7 @@ function handler(args) {
|
|
|
3403
3369
|
}
|
|
3404
3370
|
import_shelljs8.default.cp(
|
|
3405
3371
|
"-r",
|
|
3406
|
-
[(0,
|
|
3372
|
+
[(0, import_path28.join)(tmpOutputFolder, "*"), (0, import_path28.join)(tmpOutputFolder, ".*")],
|
|
3407
3373
|
userOutputFolder
|
|
3408
3374
|
);
|
|
3409
3375
|
if (publish2) {
|
|
@@ -3456,7 +3422,7 @@ function preparingTemporaryFolders(userOutputFolder) {
|
|
|
3456
3422
|
}
|
|
3457
3423
|
|
|
3458
3424
|
// src/cmd/publish/index.ts
|
|
3459
|
-
var
|
|
3425
|
+
var import_path29 = require("path");
|
|
3460
3426
|
var command = "publish";
|
|
3461
3427
|
var description = "Upload builded documentation to target S3 bucket";
|
|
3462
3428
|
var publish = {
|
|
@@ -3510,7 +3476,7 @@ function handler2(args) {
|
|
|
3510
3476
|
return __async(this, null, function* () {
|
|
3511
3477
|
argv_default.init(__spreadValues({}, args));
|
|
3512
3478
|
const { input, endpoint, bucket, prefix } = argv_default.getConfig();
|
|
3513
|
-
logger.info("", `Upload artifacts from ${input} to ${(0,
|
|
3479
|
+
logger.info("", `Upload artifacts from ${input} to ${(0, import_path29.join)(endpoint, bucket, prefix)}`);
|
|
3514
3480
|
try {
|
|
3515
3481
|
yield upload(argv_default.getConfig());
|
|
3516
3482
|
} catch (error) {
|
|
@@ -3520,7 +3486,7 @@ function handler2(args) {
|
|
|
3520
3486
|
}
|
|
3521
3487
|
|
|
3522
3488
|
// src/cmd/xliff/extract.ts
|
|
3523
|
-
var
|
|
3489
|
+
var import_path30 = require("path");
|
|
3524
3490
|
var import_markdown_translation = __toESM(require("@diplodoc/markdown-translation"));
|
|
3525
3491
|
var import_async3 = require("async");
|
|
3526
3492
|
var {
|
|
@@ -3583,7 +3549,7 @@ function handler3(args) {
|
|
|
3583
3549
|
try {
|
|
3584
3550
|
({
|
|
3585
3551
|
state: { found, cache }
|
|
3586
|
-
} = yield glob((0,
|
|
3552
|
+
} = yield glob((0, import_path30.join)(input, MD_GLOB2), {
|
|
3587
3553
|
nosort: true,
|
|
3588
3554
|
cache
|
|
3589
3555
|
}));
|
|
@@ -3617,9 +3583,9 @@ function pipeline2(params) {
|
|
|
3617
3583
|
const { input, output, source, target } = params;
|
|
3618
3584
|
return (markdownPath) => __async(this, null, function* () {
|
|
3619
3585
|
const markdown = yield reader({ path: markdownPath });
|
|
3620
|
-
const extension = (0,
|
|
3586
|
+
const extension = (0, import_path30.extname)(markdownPath);
|
|
3621
3587
|
const outputRelativePath = markdownPath.replace(extension, "").slice(input.length);
|
|
3622
|
-
const outputPath = (0,
|
|
3588
|
+
const outputPath = (0, import_path30.join)(output, outputRelativePath);
|
|
3623
3589
|
const xlfPath = outputPath + ".xliff";
|
|
3624
3590
|
const skeletonPath = outputPath + ".skl.md";
|
|
3625
3591
|
const extractParameters = {
|
|
@@ -3673,7 +3639,7 @@ function writer(params) {
|
|
|
3673
3639
|
const { xlfPath, skeletonPath, xlf, skeleton } = params;
|
|
3674
3640
|
logger.info(params.xlfPath, "writing xliff file");
|
|
3675
3641
|
logger.info(params.skeletonPath, "writing skeleton file");
|
|
3676
|
-
yield mkdir2((0,
|
|
3642
|
+
yield mkdir2((0, import_path30.dirname)(xlfPath), { recursive: true });
|
|
3677
3643
|
yield Promise.all([writeFile2(skeletonPath, skeleton), writeFile2(xlfPath, xlf)]);
|
|
3678
3644
|
logger.info(params.xlfPath, "finished writing xliff file");
|
|
3679
3645
|
logger.info(params.skeletonPath, "finished writing skeleton file");
|
|
@@ -3681,7 +3647,7 @@ function writer(params) {
|
|
|
3681
3647
|
}
|
|
3682
3648
|
|
|
3683
3649
|
// src/cmd/xliff/compose.ts
|
|
3684
|
-
var
|
|
3650
|
+
var import_path31 = require("path");
|
|
3685
3651
|
var import_markdown_translation2 = __toESM(require("@diplodoc/markdown-translation"));
|
|
3686
3652
|
var import_async4 = require("async");
|
|
3687
3653
|
var {
|
|
@@ -3721,13 +3687,13 @@ function handler4(args) {
|
|
|
3721
3687
|
try {
|
|
3722
3688
|
({
|
|
3723
3689
|
state: { found: skeletonPaths, cache }
|
|
3724
|
-
} = yield glob((0,
|
|
3690
|
+
} = yield glob((0, import_path31.join)(input, SKL_MD_GLOB), {
|
|
3725
3691
|
nosort: false,
|
|
3726
3692
|
cache
|
|
3727
3693
|
}));
|
|
3728
3694
|
({
|
|
3729
3695
|
state: { found: xliffPaths, cache }
|
|
3730
|
-
} = yield glob((0,
|
|
3696
|
+
} = yield glob((0, import_path31.join)(input, XLF_GLOB), {
|
|
3731
3697
|
nosort: false,
|
|
3732
3698
|
cache
|
|
3733
3699
|
}));
|
|
@@ -3757,7 +3723,7 @@ function handler4(args) {
|
|
|
3757
3723
|
function pipeline3(params) {
|
|
3758
3724
|
const { input, output } = params;
|
|
3759
3725
|
return (xliffPath) => __async(this, null, function* () {
|
|
3760
|
-
const extension = (0,
|
|
3726
|
+
const extension = (0, import_path31.extname)(xliffPath);
|
|
3761
3727
|
const extensionLessPath = xliffPath.replace(extension, "");
|
|
3762
3728
|
const skeletonPath = extensionLessPath + ".skl.md";
|
|
3763
3729
|
const readerParameters = { xliffPath, skeletonPath };
|
|
@@ -3768,7 +3734,7 @@ function pipeline3(params) {
|
|
|
3768
3734
|
});
|
|
3769
3735
|
const { markdown } = yield composer(composerParameters);
|
|
3770
3736
|
const inputRelativePath = extensionLessPath.slice(input.length);
|
|
3771
|
-
const markdownPath = (0,
|
|
3737
|
+
const markdownPath = (0, import_path31.join)(output, inputRelativePath) + ".md";
|
|
3772
3738
|
const writerParameters = {
|
|
3773
3739
|
markdown,
|
|
3774
3740
|
markdownPath
|
|
@@ -3825,7 +3791,7 @@ function writer2(params) {
|
|
|
3825
3791
|
const { markdown, markdownPath } = params;
|
|
3826
3792
|
try {
|
|
3827
3793
|
logger.info(markdownPath, "writing markdown file");
|
|
3828
|
-
yield mkdir3((0,
|
|
3794
|
+
yield mkdir3((0, import_path31.dirname)(markdownPath), { recursive: true });
|
|
3829
3795
|
yield writeFile3(markdownPath, markdown);
|
|
3830
3796
|
logger.info(markdownPath, "finished writing markdown file");
|
|
3831
3797
|
} catch (err) {
|
|
@@ -3855,7 +3821,7 @@ function builder5(argv) {
|
|
|
3855
3821
|
|
|
3856
3822
|
// src/cmd/translate/index.ts
|
|
3857
3823
|
var import_async5 = require("async");
|
|
3858
|
-
var
|
|
3824
|
+
var import_path33 = require("path");
|
|
3859
3825
|
var import_promises4 = require("fs/promises");
|
|
3860
3826
|
var import_fast_xml_parser = require("fast-xml-parser");
|
|
3861
3827
|
var import_session = require("@yandex-cloud/nodejs-sdk/dist/session");
|
|
@@ -3867,7 +3833,7 @@ var import_markdown_translation3 = __toESM(require("@diplodoc/markdown-translati
|
|
|
3867
3833
|
var import_promises3 = require("fs/promises");
|
|
3868
3834
|
var import_process3 = require("process");
|
|
3869
3835
|
var import_os = require("os");
|
|
3870
|
-
var
|
|
3836
|
+
var import_path32 = require("path");
|
|
3871
3837
|
var YANDEX_OAUTH_TOKEN_FILENAME = ".ya_oauth_token";
|
|
3872
3838
|
function getYandexOAuthToken() {
|
|
3873
3839
|
return __async(this, null, function* () {
|
|
@@ -3878,7 +3844,7 @@ function getYandexOAuthToken() {
|
|
|
3878
3844
|
function getYandexOAuthTokenFromHomeDir() {
|
|
3879
3845
|
return __async(this, null, function* () {
|
|
3880
3846
|
const error = "failed reading yandex oauth token";
|
|
3881
|
-
const path = (0,
|
|
3847
|
+
const path = (0, import_path32.join)((0, import_os.homedir)(), YANDEX_OAUTH_TOKEN_FILENAME);
|
|
3882
3848
|
let token;
|
|
3883
3849
|
try {
|
|
3884
3850
|
token = yield (0, import_promises3.readFile)(path, { encoding: "utf8" });
|
|
@@ -3946,7 +3912,7 @@ function handler5(args) {
|
|
|
3946
3912
|
let found = [];
|
|
3947
3913
|
({
|
|
3948
3914
|
state: { found }
|
|
3949
|
-
} = yield glob((0,
|
|
3915
|
+
} = yield glob((0, import_path33.join)(input, MD_GLOB3), {
|
|
3950
3916
|
nosort: true
|
|
3951
3917
|
}));
|
|
3952
3918
|
const oauthToken = yield getYandexOAuthToken();
|
|
@@ -3985,11 +3951,11 @@ function translator(params) {
|
|
|
3985
3951
|
yandexCloudTranslateGlossaryPairs
|
|
3986
3952
|
} = params;
|
|
3987
3953
|
const session = new import_session.Session({ oauthToken });
|
|
3988
|
-
const
|
|
3954
|
+
const client = session.client(import_service_clients.TranslationServiceClient);
|
|
3989
3955
|
return (mdPath) => __async(this, null, function* () {
|
|
3990
3956
|
try {
|
|
3991
3957
|
logger.info(mdPath, "translating");
|
|
3992
|
-
const md = yield (0, import_promises4.readFile)((0,
|
|
3958
|
+
const md = yield (0, import_promises4.readFile)((0, import_path33.resolve)(mdPath), { encoding: "utf-8" });
|
|
3993
3959
|
const { xlf, skeleton } = import_markdown_translation3.default.extract({
|
|
3994
3960
|
source: {
|
|
3995
3961
|
language: sourceLanguage,
|
|
@@ -4025,7 +3991,7 @@ function translator(params) {
|
|
|
4025
3991
|
},
|
|
4026
3992
|
(0, import_async5.asyncify)(
|
|
4027
3993
|
() => __async(this, null, function* () {
|
|
4028
|
-
return yield
|
|
3994
|
+
return yield client.translate(machineTranslateParams).then(
|
|
4029
3995
|
(results) => results.translations.map(({ text }) => text)
|
|
4030
3996
|
);
|
|
4031
3997
|
})
|
|
@@ -4043,7 +4009,7 @@ function translator(params) {
|
|
|
4043
4009
|
skeleton
|
|
4044
4010
|
});
|
|
4045
4011
|
const outputPath = mdPath.replace(input, output);
|
|
4046
|
-
yield (0, import_promises4.mkdir)((0,
|
|
4012
|
+
yield (0, import_promises4.mkdir)((0, import_path33.dirname)(outputPath), { recursive: true });
|
|
4047
4013
|
yield (0, import_promises4.writeFile)(outputPath, composed);
|
|
4048
4014
|
logger.info(outputPath, "finished translating");
|
|
4049
4015
|
} catch (err) {
|
|
@@ -4095,7 +4061,7 @@ import_yargs.default.command(build).command(publish).command(xliff).command(tran
|
|
|
4095
4061
|
default: false,
|
|
4096
4062
|
describe: "Run in quiet mode. Don't write logs to stdout",
|
|
4097
4063
|
type: "boolean"
|
|
4098
|
-
}).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.
|
|
4064
|
+
}).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.7.0-beta-1" : "").help().parse((0, import_helpers.hideBin)(process.argv), {}, (err, { strict }, output) => {
|
|
4099
4065
|
console.timeEnd(MAIN_TIMER_ID);
|
|
4100
4066
|
if (err) {
|
|
4101
4067
|
console.error(err);
|