@diplodoc/cli 4.6.0-alpha-1 → 4.6.0-alpha-2
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 +178 -209
- package/build/index.js.map +4 -4
- package/build/linter.js +71 -100
- package/build/linter.js.map +4 -4
- package/build/pkg.json +3 -11
- package/package.json +1 -1
- package/src/constants.ts +2 -6
- package/src/steps/processAssets.ts +3 -5
- package/src/utils/markup.ts +9 -5
- package/build/app.client.css +0 -2684
- package/build/app.client.js +0 -3
- package/build/app.css +0 -4
- package/build/app.js +0 -2
- package/build/react.js +0 -3
- package/build/vendor.css +0 -3530
- package/build/vendor.js +0 -3
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,38 +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 manifest = require("@diplodoc/client/manifest");
|
|
88
|
-
var CLIENT_PATH = path.dirname(require.resolve("@diplodoc/client/manifest"));
|
|
89
|
-
var BUILD_PATH = path.resolve(__dirname, "..", "build");
|
|
90
|
-
var src = (target) => path.resolve(CLIENT_PATH, target);
|
|
91
|
-
var dst = (target) => path.resolve(BUILD_PATH, target);
|
|
92
|
-
module2.exports = {
|
|
93
|
-
assets: [
|
|
94
|
-
...manifest.js.map((path2) => [src(path2), dst(path2)]),
|
|
95
|
-
...manifest.css.map((path2) => [src(path2), dst(path2)])
|
|
96
|
-
],
|
|
97
|
-
bundle: {
|
|
98
|
-
js(bundlePath) {
|
|
99
|
-
return manifest.js.map((src2) => path.join(bundlePath, src2));
|
|
100
|
-
},
|
|
101
|
-
css(bundlePath) {
|
|
102
|
-
return manifest.css.map((src2) => path.join(bundlePath, src2));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
79
|
// src/index.ts
|
|
110
80
|
var import_yargs = __toESM(require("yargs"));
|
|
111
81
|
var import_helpers = require("yargs/helpers");
|
|
@@ -137,6 +107,7 @@ var openapi = require("@diplodoc/openapi-extension");
|
|
|
137
107
|
includes.collect = require("@diplodoc/transform/lib/plugins/includes/collect");
|
|
138
108
|
images.collect = require("@diplodoc/transform/lib/plugins/images/collect");
|
|
139
109
|
changelog.collect = require("@diplodoc/transform/lib/plugins/changelog/collect");
|
|
110
|
+
var ASSETS_FOLDER = (0, import_path.resolve)(__dirname, "..", "assets");
|
|
140
111
|
var BUNDLE_FOLDER = "_bundle";
|
|
141
112
|
var TMP_INPUT_FOLDER = ".tmp_input";
|
|
142
113
|
var TMP_OUTPUT_FOLDER = ".tmp_output";
|
|
@@ -152,7 +123,6 @@ var ResourceType = /* @__PURE__ */ ((ResourceType2) => {
|
|
|
152
123
|
ResourceType2["script"] = "script";
|
|
153
124
|
return ResourceType2;
|
|
154
125
|
})(ResourceType || {});
|
|
155
|
-
var BUILD_FOLDER_PATH = (0, import_path.dirname)(require.resolve("@diplodoc/client"));
|
|
156
126
|
var YFM_PLUGINS = [
|
|
157
127
|
meta,
|
|
158
128
|
deflist,
|
|
@@ -313,10 +283,10 @@ function argvValidator(argv) {
|
|
|
313
283
|
}
|
|
314
284
|
|
|
315
285
|
// src/cmd/build/index.ts
|
|
316
|
-
var
|
|
286
|
+
var import_path28 = require("path");
|
|
317
287
|
|
|
318
288
|
// src/services/tocs.ts
|
|
319
|
-
var
|
|
289
|
+
var import_path14 = require("path");
|
|
320
290
|
var import_fs3 = require("fs");
|
|
321
291
|
var import_js_yaml4 = require("js-yaml");
|
|
322
292
|
var import_shelljs2 = __toESM(require("shelljs"));
|
|
@@ -364,6 +334,7 @@ var logger = {
|
|
|
364
334
|
};
|
|
365
335
|
|
|
366
336
|
// src/utils/markup.ts
|
|
337
|
+
var import_path4 = require("path");
|
|
367
338
|
var import_process = require("process");
|
|
368
339
|
|
|
369
340
|
// src/utils/singlePage.ts
|
|
@@ -531,7 +502,8 @@ function preprocessPageHtmlForSinglePage(content, options) {
|
|
|
531
502
|
|
|
532
503
|
// src/utils/markup.ts
|
|
533
504
|
var import_client = require("@diplodoc/client");
|
|
534
|
-
var
|
|
505
|
+
var import_manifest = __toESM(require("@diplodoc/client/manifest"));
|
|
506
|
+
var dst = (bundlePath) => (target) => (0, import_path4.join)(bundlePath, target);
|
|
535
507
|
function generateStaticMarkup(props, pathToBundle) {
|
|
536
508
|
const { title: metaTitle, style, script } = props.data.meta || {};
|
|
537
509
|
const { title: tocTitle } = props.data.toc;
|
|
@@ -557,7 +529,7 @@ function generateStaticMarkup(props, pathToBundle) {
|
|
|
557
529
|
height: 100vh;
|
|
558
530
|
}
|
|
559
531
|
</style>
|
|
560
|
-
${
|
|
532
|
+
${import_manifest.default.css.map(dst(pathToBundle)).map((src) => `<link type="text/css" rel="stylesheet" href="${src}" />`).join("\n")}
|
|
561
533
|
${plugins_exports.getHeadContent()}
|
|
562
534
|
${resources}
|
|
563
535
|
</head>
|
|
@@ -567,7 +539,7 @@ function generateStaticMarkup(props, pathToBundle) {
|
|
|
567
539
|
window.STATIC_CONTENT = ${staticContent}
|
|
568
540
|
window.__DATA__ = ${JSON.stringify(props)};
|
|
569
541
|
</script>
|
|
570
|
-
${
|
|
542
|
+
${import_manifest.default.js.map(dst(pathToBundle)).map(
|
|
571
543
|
(src) => `<script type="application/javascript" src="${src}"></script>`
|
|
572
544
|
).join("\n")}
|
|
573
545
|
</body>
|
|
@@ -621,9 +593,9 @@ function replaceDoubleToSingleQuotes(str) {
|
|
|
621
593
|
}
|
|
622
594
|
|
|
623
595
|
// src/utils/path.ts
|
|
624
|
-
var
|
|
596
|
+
var import_path5 = require("path");
|
|
625
597
|
function addSlashPrefix(path) {
|
|
626
|
-
const slashPrefix = path.startsWith(
|
|
598
|
+
const slashPrefix = path.startsWith(import_path5.sep) ? "" : import_path5.sep;
|
|
627
599
|
return `${slashPrefix}${path}`;
|
|
628
600
|
}
|
|
629
601
|
function convertBackSlashToSlash(path) {
|
|
@@ -634,7 +606,7 @@ function convertBackSlashToSlash(path) {
|
|
|
634
606
|
}
|
|
635
607
|
|
|
636
608
|
// src/utils/toc.ts
|
|
637
|
-
var
|
|
609
|
+
var import_path6 = require("path");
|
|
638
610
|
|
|
639
611
|
// src/services/utils.ts
|
|
640
612
|
var import_evaluation = __toESM(require("@diplodoc/transform/lib/liquid/evaluation"));
|
|
@@ -760,14 +732,14 @@ function transformToc(toc, pathToFileDirectory) {
|
|
|
760
732
|
navigationItemQueue.push(...navigationItem.items);
|
|
761
733
|
}
|
|
762
734
|
if (href && !isExternalHref(href)) {
|
|
763
|
-
const pathToIndexDirectory = (0,
|
|
764
|
-
const fileExtension = (0,
|
|
765
|
-
const filename = (0,
|
|
766
|
-
const transformedFilename = (0,
|
|
735
|
+
const pathToIndexDirectory = (0, import_path6.relative)(pathToFileDirectory, baseTocPath);
|
|
736
|
+
const fileExtension = (0, import_path6.extname)(href);
|
|
737
|
+
const filename = (0, import_path6.basename)(href, fileExtension);
|
|
738
|
+
const transformedFilename = (0, import_path6.format)({
|
|
767
739
|
name: filename,
|
|
768
740
|
ext: ".html"
|
|
769
741
|
});
|
|
770
|
-
navigationItem.href = (0,
|
|
742
|
+
navigationItem.href = (0, import_path6.join)(pathToIndexDirectory, (0, import_path6.dirname)(href), transformedFilename);
|
|
771
743
|
}
|
|
772
744
|
}
|
|
773
745
|
return localToc;
|
|
@@ -804,15 +776,15 @@ function transformTocForSinglePage(toc, options) {
|
|
|
804
776
|
}
|
|
805
777
|
|
|
806
778
|
// src/utils/presets.ts
|
|
807
|
-
var
|
|
779
|
+
var import_path7 = require("path");
|
|
808
780
|
function getVarsPerFile(filePath) {
|
|
809
781
|
const { vars: argVars } = argv_default.getConfig();
|
|
810
|
-
return __spreadValues(__spreadValues({}, preset_default.get((0,
|
|
782
|
+
return __spreadValues(__spreadValues({}, preset_default.get((0, import_path7.dirname)(filePath))), argVars);
|
|
811
783
|
}
|
|
812
784
|
function getVarsPerRelativeFile(filePath) {
|
|
813
785
|
const { input } = argv_default.getConfig();
|
|
814
|
-
const root = (0,
|
|
815
|
-
const relativeFilePath = (0,
|
|
786
|
+
const root = (0, import_path7.resolve)(input);
|
|
787
|
+
const relativeFilePath = (0, import_path7.relative)(root, filePath);
|
|
816
788
|
return getVarsPerFile(relativeFilePath);
|
|
817
789
|
}
|
|
818
790
|
|
|
@@ -825,14 +797,14 @@ var glob = (pattern, options) => __async(void 0, null, function* () {
|
|
|
825
797
|
});
|
|
826
798
|
|
|
827
799
|
// src/utils/file.ts
|
|
828
|
-
var
|
|
800
|
+
var import_path8 = require("path");
|
|
829
801
|
var import_shelljs = __toESM(require("shelljs"));
|
|
830
802
|
function copyFiles(inputFolderPath, outputFolderPath, files) {
|
|
831
803
|
const dirs = /* @__PURE__ */ new Set();
|
|
832
804
|
files.forEach((pathToAsset) => {
|
|
833
|
-
const outputDir = (0,
|
|
834
|
-
const from = (0,
|
|
835
|
-
const to = (0,
|
|
805
|
+
const outputDir = (0, import_path8.resolve)(outputFolderPath, (0, import_path8.dirname)(pathToAsset));
|
|
806
|
+
const from = (0, import_path8.resolve)(inputFolderPath, pathToAsset);
|
|
807
|
+
const to = (0, import_path8.resolve)(outputFolderPath, pathToAsset);
|
|
836
808
|
if (!dirs.has(outputDir)) {
|
|
837
809
|
dirs.add(outputDir);
|
|
838
810
|
import_shelljs.default.mkdir("-p", outputDir);
|
|
@@ -888,7 +860,7 @@ function getAuthorDetails(vcsConnector, author) {
|
|
|
888
860
|
|
|
889
861
|
// src/services/contributors.ts
|
|
890
862
|
var import_promises = require("fs/promises");
|
|
891
|
-
var
|
|
863
|
+
var import_path9 = require("path");
|
|
892
864
|
function getFileContributorsMetadata(fileData, vcsConnector) {
|
|
893
865
|
return __async(this, null, function* () {
|
|
894
866
|
const contributors = yield getFileContributorsString(fileData, vcsConnector);
|
|
@@ -958,8 +930,8 @@ function getRelativeIncludeFilePaths(fileData, includeContents) {
|
|
|
958
930
|
const relativeIncludeFilePath = includeContent.match(REGEXP_INCLUDE_FILE_PATH);
|
|
959
931
|
if (relativeIncludeFilePath && relativeIncludeFilePath.length !== 0) {
|
|
960
932
|
const relativeIncludeFilePathWithoutHash = relativeIncludeFilePath[0].split("#");
|
|
961
|
-
const includeFilePath = (0,
|
|
962
|
-
(0,
|
|
933
|
+
const includeFilePath = (0, import_path9.join)(
|
|
934
|
+
(0, import_path9.dirname)(tmpInputFilePath),
|
|
963
935
|
relativeIncludeFilePathWithoutHash[0]
|
|
964
936
|
);
|
|
965
937
|
relativeIncludeFilePaths.add(includeFilePath);
|
|
@@ -969,7 +941,7 @@ function getRelativeIncludeFilePaths(fileData, includeContents) {
|
|
|
969
941
|
}
|
|
970
942
|
|
|
971
943
|
// src/services/metadata.ts
|
|
972
|
-
var
|
|
944
|
+
var import_path10 = require("path");
|
|
973
945
|
function getContentWithUpdatedMetadata(fileContent, options, systemVars) {
|
|
974
946
|
return __async(this, null, function* () {
|
|
975
947
|
var _a;
|
|
@@ -1140,8 +1112,8 @@ function getSystemVarsMetadataString(systemVars) {
|
|
|
1140
1112
|
}
|
|
1141
1113
|
function getAssetsPublicPath(filePath) {
|
|
1142
1114
|
const { input } = argv_default.getConfig();
|
|
1143
|
-
const path = (0,
|
|
1144
|
-
return (0,
|
|
1115
|
+
const path = (0, import_path10.resolve)(input, filePath);
|
|
1116
|
+
return (0, import_path10.relative)((0, import_path10.dirname)(path), (0, import_path10.resolve)(input));
|
|
1145
1117
|
}
|
|
1146
1118
|
|
|
1147
1119
|
// src/services/includers/index.ts
|
|
@@ -1151,7 +1123,7 @@ __export(includers_exports, {
|
|
|
1151
1123
|
applyIncluders: () => applyIncluders,
|
|
1152
1124
|
init: () => init
|
|
1153
1125
|
});
|
|
1154
|
-
var
|
|
1126
|
+
var import_path13 = require("path");
|
|
1155
1127
|
var import_lodash3 = require("lodash");
|
|
1156
1128
|
|
|
1157
1129
|
// src/services/includers/batteries/generic.ts
|
|
@@ -1162,7 +1134,7 @@ __export(generic_exports, {
|
|
|
1162
1134
|
name: () => name
|
|
1163
1135
|
});
|
|
1164
1136
|
var import_promises2 = require("fs/promises");
|
|
1165
|
-
var
|
|
1137
|
+
var import_path11 = require("path");
|
|
1166
1138
|
var import_lodash2 = require("lodash");
|
|
1167
1139
|
var import_js_yaml3 = require("js-yaml");
|
|
1168
1140
|
var GenericIncluderError = class extends Error {
|
|
@@ -1190,8 +1162,8 @@ function includerFunction(params) {
|
|
|
1190
1162
|
}
|
|
1191
1163
|
try {
|
|
1192
1164
|
const leadingPageName = (_b = leadingPage == null ? void 0 : leadingPage.name) != null ? _b : "Overview";
|
|
1193
|
-
const tocDirPath = (0,
|
|
1194
|
-
const contentPath = index === 0 ? (0,
|
|
1165
|
+
const tocDirPath = (0, import_path11.dirname)(tocPath);
|
|
1166
|
+
const contentPath = index === 0 ? (0, import_path11.join)(writeBasePath, tocDirPath, input) : (0, import_path11.join)(readBasePath, tocDirPath, input);
|
|
1195
1167
|
let cache = {};
|
|
1196
1168
|
let found = [];
|
|
1197
1169
|
({
|
|
@@ -1202,16 +1174,16 @@ function includerFunction(params) {
|
|
|
1202
1174
|
nocase: true,
|
|
1203
1175
|
cache
|
|
1204
1176
|
}));
|
|
1205
|
-
const writePath = (0,
|
|
1177
|
+
const writePath = (0, import_path11.join)(writeBasePath, tocDirPath, item.include.path);
|
|
1206
1178
|
yield (0, import_promises2.mkdir)(writePath, { recursive: true });
|
|
1207
1179
|
for (const filePath of found) {
|
|
1208
|
-
const file = yield (0, import_promises2.readFile)((0,
|
|
1209
|
-
yield (0, import_promises2.mkdir)((0,
|
|
1210
|
-
yield (0, import_promises2.writeFile)((0,
|
|
1180
|
+
const file = yield (0, import_promises2.readFile)((0, import_path11.join)(contentPath, filePath));
|
|
1181
|
+
yield (0, import_promises2.mkdir)((0, import_path11.dirname)((0, import_path11.join)(writePath, filePath)), { recursive: true });
|
|
1182
|
+
yield (0, import_promises2.writeFile)((0, import_path11.join)(writePath, filePath), file);
|
|
1211
1183
|
}
|
|
1212
1184
|
const graph = createGraphFromPaths(found);
|
|
1213
1185
|
const toc = createToc(leadingPageName, item.include.path)(graph, []);
|
|
1214
|
-
yield (0, import_promises2.writeFile)((0,
|
|
1186
|
+
yield (0, import_promises2.writeFile)((0, import_path11.join)(writePath, "toc.yaml"), (0, import_js_yaml3.dump)(toc));
|
|
1215
1187
|
} catch (err) {
|
|
1216
1188
|
throw new GenericIncluderError(err.toString(), tocPath);
|
|
1217
1189
|
}
|
|
@@ -1243,8 +1215,8 @@ function createToc(leadingPageName, tocName) {
|
|
|
1243
1215
|
return function createTocRec(graph, cursor) {
|
|
1244
1216
|
var _a, _b;
|
|
1245
1217
|
const handler6 = (file) => ({
|
|
1246
|
-
name: (0,
|
|
1247
|
-
href: (0,
|
|
1218
|
+
name: (0, import_path11.parse)(file).name === "index" ? leadingPageName : file,
|
|
1219
|
+
href: (0, import_path11.join)(...cursor, file)
|
|
1248
1220
|
});
|
|
1249
1221
|
const recurse = (key) => createTocRec(graph[key], [...cursor, key]);
|
|
1250
1222
|
const current = {
|
|
@@ -1295,7 +1267,7 @@ __export(unarchive_exports, {
|
|
|
1295
1267
|
name: () => name3
|
|
1296
1268
|
});
|
|
1297
1269
|
var import_fs2 = require("fs");
|
|
1298
|
-
var
|
|
1270
|
+
var import_path12 = require("path");
|
|
1299
1271
|
var import_tar_stream = require("tar-stream");
|
|
1300
1272
|
var name3 = "unarchive";
|
|
1301
1273
|
var UnarchiveIncluderError = class extends Error {
|
|
@@ -1318,8 +1290,8 @@ function pipeline(readPath, writeBasePath) {
|
|
|
1318
1290
|
(0, import_fs2.mkdirSync)(writeBasePath, { recursive: true });
|
|
1319
1291
|
extractor2.on("entry", (header, stream, next) => {
|
|
1320
1292
|
const { type, name: name4 } = header;
|
|
1321
|
-
const writePath = (0,
|
|
1322
|
-
const writeDirPath = type === "directory" ? writePath : (0,
|
|
1293
|
+
const writePath = (0, import_path12.join)(writeBasePath, name4);
|
|
1294
|
+
const writeDirPath = type === "directory" ? writePath : (0, import_path12.dirname)(writePath);
|
|
1323
1295
|
(0, import_fs2.mkdirSync)(writeDirPath, { recursive: true });
|
|
1324
1296
|
if (type !== "directory") {
|
|
1325
1297
|
const writer3 = (0, import_fs2.createWriteStream)(writePath, { flags: "w" });
|
|
@@ -1350,8 +1322,8 @@ function includerFunction3(params) {
|
|
|
1350
1322
|
if (!(input == null ? void 0 : input.length) || !(output == null ? void 0 : output.length)) {
|
|
1351
1323
|
throw new UnarchiveIncluderError("provide includer with input parameter", tocPath);
|
|
1352
1324
|
}
|
|
1353
|
-
const contentPath = index === 0 ? (0,
|
|
1354
|
-
const writePath = (0,
|
|
1325
|
+
const contentPath = index === 0 ? (0, import_path12.join)(writeBasePath, input) : (0, import_path12.join)(readBasePath, input);
|
|
1326
|
+
const writePath = (0, import_path12.join)(writeBasePath, output);
|
|
1355
1327
|
try {
|
|
1356
1328
|
yield pipeline(contentPath, writePath);
|
|
1357
1329
|
} catch (err) {
|
|
@@ -1408,7 +1380,7 @@ function applyIncluders(path, item, vars) {
|
|
|
1408
1380
|
const passedParams = __spreadValues({}, rest);
|
|
1409
1381
|
yield applyIncluder({ path, item, includer, passedParams, index, vars });
|
|
1410
1382
|
}
|
|
1411
|
-
item.include.path = (0,
|
|
1383
|
+
item.include.path = (0, import_path13.join)(item.include.path, "toc.yaml");
|
|
1412
1384
|
index++;
|
|
1413
1385
|
});
|
|
1414
1386
|
}
|
|
@@ -1480,8 +1452,8 @@ function add(path) {
|
|
|
1480
1452
|
ignoreStage,
|
|
1481
1453
|
vars
|
|
1482
1454
|
} = argv_default.getConfig();
|
|
1483
|
-
const pathToDir = (0,
|
|
1484
|
-
const content = (0, import_fs3.readFileSync)((0,
|
|
1455
|
+
const pathToDir = (0, import_path14.dirname)(path);
|
|
1456
|
+
const content = (0, import_fs3.readFileSync)((0, import_path14.resolve)(inputFolderPath, path), "utf8");
|
|
1485
1457
|
const parsedToc = (0, import_js_yaml4.load)(content);
|
|
1486
1458
|
if (parsedToc.stage === ignoreStage) {
|
|
1487
1459
|
return;
|
|
@@ -1498,16 +1470,16 @@ function add(path) {
|
|
|
1498
1470
|
parsedToc.items = yield processTocItems(
|
|
1499
1471
|
path,
|
|
1500
1472
|
parsedToc.items,
|
|
1501
|
-
(0,
|
|
1502
|
-
(0,
|
|
1473
|
+
(0, import_path14.join)(inputFolderPath, pathToDir),
|
|
1474
|
+
(0, import_path14.resolve)(inputFolderPath),
|
|
1503
1475
|
combinedVars
|
|
1504
1476
|
);
|
|
1505
1477
|
storage.set(path, parsedToc);
|
|
1506
1478
|
parsedToc.base = pathToDir;
|
|
1507
1479
|
if (outputFormat === "md") {
|
|
1508
|
-
const outputPath = (0,
|
|
1480
|
+
const outputPath = (0, import_path14.resolve)(outputFolderPath, path);
|
|
1509
1481
|
const outputToc = (0, import_js_yaml4.dump)(parsedToc);
|
|
1510
|
-
import_shelljs2.default.mkdir("-p", (0,
|
|
1482
|
+
import_shelljs2.default.mkdir("-p", (0, import_path14.dirname)(outputPath));
|
|
1511
1483
|
(0, import_fs3.writeFileSync)(outputPath, outputToc);
|
|
1512
1484
|
}
|
|
1513
1485
|
prepareNavigationPaths(parsedToc, pathToDir);
|
|
@@ -1550,7 +1522,7 @@ function prepareNavigationPaths(parsedToc, dirPath) {
|
|
|
1550
1522
|
processItems(preparedSubItems, pathToDir);
|
|
1551
1523
|
}
|
|
1552
1524
|
if (item.href && !isExternalHref(item.href)) {
|
|
1553
|
-
const href = (0,
|
|
1525
|
+
const href = (0, import_path14.join)(pathToDir, item.href);
|
|
1554
1526
|
storage.set(href, parsedToc);
|
|
1555
1527
|
const navigationPath = _normalizeHref(href);
|
|
1556
1528
|
navigationPaths.push(navigationPath);
|
|
@@ -1560,32 +1532,32 @@ function prepareNavigationPaths(parsedToc, dirPath) {
|
|
|
1560
1532
|
processItems([parsedToc], dirPath);
|
|
1561
1533
|
}
|
|
1562
1534
|
function _normalizeHref(href) {
|
|
1563
|
-
const preparedHref = (0,
|
|
1535
|
+
const preparedHref = (0, import_path14.normalize)(href);
|
|
1564
1536
|
if (preparedHref.endsWith(".md") || preparedHref.endsWith(".yaml")) {
|
|
1565
1537
|
return preparedHref;
|
|
1566
1538
|
}
|
|
1567
|
-
if (preparedHref.endsWith(
|
|
1539
|
+
if (preparedHref.endsWith(import_path14.sep)) {
|
|
1568
1540
|
return `${preparedHref}index.yaml`;
|
|
1569
1541
|
}
|
|
1570
1542
|
return `${preparedHref}.md`;
|
|
1571
1543
|
}
|
|
1572
1544
|
function _copyTocDir(tocPath, destDir) {
|
|
1573
1545
|
const { input: inputFolderPath } = argv_default.getConfig();
|
|
1574
|
-
const { dir: tocDir } = (0,
|
|
1546
|
+
const { dir: tocDir } = (0, import_path14.parse)(tocPath);
|
|
1575
1547
|
const files = (0, import_walk_sync.default)(tocDir, {
|
|
1576
1548
|
globs: ["**/*.*"],
|
|
1577
1549
|
ignore: ["**/toc.yaml"],
|
|
1578
1550
|
directories: false
|
|
1579
1551
|
});
|
|
1580
1552
|
files.forEach((relPath) => {
|
|
1581
|
-
const from = (0,
|
|
1582
|
-
const to = (0,
|
|
1583
|
-
const fileExtension = (0,
|
|
1553
|
+
const from = (0, import_path14.resolve)(tocDir, relPath);
|
|
1554
|
+
const to = (0, import_path14.resolve)(destDir, relPath);
|
|
1555
|
+
const fileExtension = (0, import_path14.extname)(relPath);
|
|
1584
1556
|
const isMdFile = fileExtension === ".md";
|
|
1585
|
-
import_shelljs2.default.mkdir("-p", (0,
|
|
1557
|
+
import_shelljs2.default.mkdir("-p", (0, import_path14.parse)(to).dir);
|
|
1586
1558
|
if (isMdFile) {
|
|
1587
1559
|
const fileContent = (0, import_fs3.readFileSync)(from, "utf8");
|
|
1588
|
-
const sourcePath = (0,
|
|
1560
|
+
const sourcePath = (0, import_path14.relative)(inputFolderPath, from);
|
|
1589
1561
|
const updatedFileContent = getContentWithUpdatedStaticMetadata({
|
|
1590
1562
|
fileContent,
|
|
1591
1563
|
sourcePath,
|
|
@@ -1600,14 +1572,14 @@ function _copyTocDir(tocPath, destDir) {
|
|
|
1600
1572
|
function _replaceIncludesHrefs(items, includeTocDir, tocDir) {
|
|
1601
1573
|
return items.reduce((acc, tocItem) => {
|
|
1602
1574
|
if (tocItem.href) {
|
|
1603
|
-
tocItem.href = (0,
|
|
1575
|
+
tocItem.href = (0, import_path14.relative)(tocDir, (0, import_path14.resolve)(includeTocDir, tocItem.href));
|
|
1604
1576
|
}
|
|
1605
1577
|
if (tocItem.items) {
|
|
1606
1578
|
tocItem.items = _replaceIncludesHrefs(tocItem.items, includeTocDir, tocDir);
|
|
1607
1579
|
}
|
|
1608
1580
|
if (tocItem.include) {
|
|
1609
1581
|
const { path } = tocItem.include;
|
|
1610
|
-
tocItem.include.path = (0,
|
|
1582
|
+
tocItem.include.path = (0, import_path14.relative)(tocDir, (0, import_path14.resolve)(includeTocDir, path));
|
|
1611
1583
|
}
|
|
1612
1584
|
return acc.concat(tocItem);
|
|
1613
1585
|
}, []);
|
|
@@ -1631,7 +1603,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
1631
1603
|
for (const item of items) {
|
|
1632
1604
|
let includedInlineItems = null;
|
|
1633
1605
|
if (item.name) {
|
|
1634
|
-
const tocPath = (0,
|
|
1606
|
+
const tocPath = (0, import_path14.join)(tocDir, "toc.yaml");
|
|
1635
1607
|
item.name = _liquidSubstitutions(item.name, vars, tocPath);
|
|
1636
1608
|
}
|
|
1637
1609
|
try {
|
|
@@ -1645,8 +1617,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
1645
1617
|
}
|
|
1646
1618
|
if (item.include) {
|
|
1647
1619
|
const { mode = "root_merge" /* ROOT_MERGE */ } = item.include;
|
|
1648
|
-
const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0,
|
|
1649
|
-
const includeTocDir = (0,
|
|
1620
|
+
const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0, import_path14.resolve)(sourcesDir, item.include.path) : (0, import_path14.resolve)(tocDir, item.include.path);
|
|
1621
|
+
const includeTocDir = (0, import_path14.dirname)(includeTocPath);
|
|
1650
1622
|
try {
|
|
1651
1623
|
const includeToc = (0, import_js_yaml4.load)((0, import_fs3.readFileSync)(includeTocPath, "utf8"));
|
|
1652
1624
|
if (includeToc.stage === "tech-preview" /* TECH_PREVIEW */) {
|
|
@@ -1679,7 +1651,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
1679
1651
|
}
|
|
1680
1652
|
} catch (err) {
|
|
1681
1653
|
const message = `Error while including toc: ${(0, import_chalk2.bold)(includeTocPath)} to ${(0, import_chalk2.bold)(
|
|
1682
|
-
(0,
|
|
1654
|
+
(0, import_path14.join)(tocDir, "toc.yaml")
|
|
1683
1655
|
)}`;
|
|
1684
1656
|
import_log3.default.error(message);
|
|
1685
1657
|
continue;
|
|
@@ -1700,8 +1672,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
1700
1672
|
}
|
|
1701
1673
|
function getTocDir(pagePath) {
|
|
1702
1674
|
const { input: inputFolderPath } = argv_default.getConfig();
|
|
1703
|
-
const tocDir = (0,
|
|
1704
|
-
const tocPath = (0,
|
|
1675
|
+
const tocDir = (0, import_path14.dirname)(pagePath);
|
|
1676
|
+
const tocPath = (0, import_path14.resolve)(tocDir, "toc.yaml");
|
|
1705
1677
|
if (!tocDir.includes(inputFolderPath)) {
|
|
1706
1678
|
throw new Error("Error while finding toc dir");
|
|
1707
1679
|
}
|
|
@@ -1723,19 +1695,19 @@ var tocs_default = {
|
|
|
1723
1695
|
};
|
|
1724
1696
|
|
|
1725
1697
|
// src/services/preset.ts
|
|
1726
|
-
var
|
|
1698
|
+
var import_path15 = require("path");
|
|
1727
1699
|
var presetStorage = /* @__PURE__ */ new Map();
|
|
1728
1700
|
function add2(parsedPreset, path, varsPreset) {
|
|
1729
1701
|
const combinedValues = __spreadValues(__spreadValues({}, parsedPreset.default || {}), parsedPreset[varsPreset] || {});
|
|
1730
|
-
const key = (0,
|
|
1702
|
+
const key = (0, import_path15.dirname)((0, import_path15.normalize)(path));
|
|
1731
1703
|
presetStorage.set(key, combinedValues);
|
|
1732
1704
|
}
|
|
1733
1705
|
function get(path) {
|
|
1734
1706
|
let combinedValues = {};
|
|
1735
|
-
let localPath = (0,
|
|
1707
|
+
let localPath = (0, import_path15.normalize)(path);
|
|
1736
1708
|
while (localPath !== ".") {
|
|
1737
1709
|
const presetValues = presetStorage.get(localPath) || {};
|
|
1738
|
-
localPath = (0,
|
|
1710
|
+
localPath = (0, import_path15.dirname)(localPath);
|
|
1739
1711
|
combinedValues = __spreadValues(__spreadValues({}, presetValues), combinedValues);
|
|
1740
1712
|
}
|
|
1741
1713
|
combinedValues = __spreadValues(__spreadValues({}, presetStorage.get(".")), combinedValues);
|
|
@@ -1755,7 +1727,7 @@ var preset_default = {
|
|
|
1755
1727
|
};
|
|
1756
1728
|
|
|
1757
1729
|
// src/services/argv.ts
|
|
1758
|
-
var
|
|
1730
|
+
var import_path16 = require("path");
|
|
1759
1731
|
var import_fs4 = require("fs");
|
|
1760
1732
|
var _argv;
|
|
1761
1733
|
function getConfig() {
|
|
@@ -1769,7 +1741,7 @@ function init2(argv) {
|
|
|
1769
1741
|
_argv.vars = JSON.parse(argv.vars);
|
|
1770
1742
|
}
|
|
1771
1743
|
try {
|
|
1772
|
-
const ignorefile = (0, import_fs4.readFileSync)((0,
|
|
1744
|
+
const ignorefile = (0, import_fs4.readFileSync)((0, import_path16.join)(_argv.rootInput, ".yfmignore"), "utf8");
|
|
1773
1745
|
const ignore = ignorefile.split("\n");
|
|
1774
1746
|
_argv.ignore = _argv.ignore.concat(ignore);
|
|
1775
1747
|
} catch (e) {
|
|
@@ -1785,15 +1757,15 @@ var argv_default = {
|
|
|
1785
1757
|
};
|
|
1786
1758
|
|
|
1787
1759
|
// src/services/leading.ts
|
|
1788
|
-
var
|
|
1760
|
+
var import_path17 = require("path");
|
|
1789
1761
|
var import_fs5 = require("fs");
|
|
1790
1762
|
var import_js_yaml5 = require("js-yaml");
|
|
1791
1763
|
var import_log4 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
1792
1764
|
function filterFile(path) {
|
|
1793
1765
|
var _a, _b;
|
|
1794
1766
|
const { input: inputFolderPath, vars } = argv_default.getConfig();
|
|
1795
|
-
const pathToDir = (0,
|
|
1796
|
-
const filePath = (0,
|
|
1767
|
+
const pathToDir = (0, import_path17.dirname)(path);
|
|
1768
|
+
const filePath = (0, import_path17.resolve)(inputFolderPath, path);
|
|
1797
1769
|
const content = (0, import_fs5.readFileSync)(filePath, "utf8");
|
|
1798
1770
|
const parsedIndex = (0, import_js_yaml5.load)(content);
|
|
1799
1771
|
const combinedVars = __spreadValues(__spreadValues({}, preset_default.get(pathToDir)), vars);
|
|
@@ -1921,7 +1893,6 @@ var import_includer = __toESM(require("@diplodoc/openapi-extension/includer"));
|
|
|
1921
1893
|
// src/steps/processAssets.ts
|
|
1922
1894
|
var import_walk_sync2 = __toESM(require("walk-sync"));
|
|
1923
1895
|
var import_shelljs3 = __toESM(require("shelljs"));
|
|
1924
|
-
var import_client3 = __toESM(require_client());
|
|
1925
1896
|
function processAssets(outputBundlePath) {
|
|
1926
1897
|
const { input: inputFolderPath, output: outputFolderPath } = argv_default.getConfig();
|
|
1927
1898
|
const assetFilePath = (0, import_walk_sync2.default)(inputFolderPath, {
|
|
@@ -1931,13 +1902,11 @@ function processAssets(outputBundlePath) {
|
|
|
1931
1902
|
});
|
|
1932
1903
|
copyFiles(inputFolderPath, outputFolderPath, assetFilePath);
|
|
1933
1904
|
import_shelljs3.default.mkdir("-p", outputBundlePath);
|
|
1934
|
-
|
|
1935
|
-
import_shelljs3.default.cp(path, outputBundlePath);
|
|
1936
|
-
}
|
|
1905
|
+
import_shelljs3.default.cp(ASSETS_FOLDER + "/*", outputBundlePath);
|
|
1937
1906
|
}
|
|
1938
1907
|
|
|
1939
1908
|
// src/steps/processExcludedFiles.ts
|
|
1940
|
-
var
|
|
1909
|
+
var import_path18 = require("path");
|
|
1941
1910
|
var import_walk_sync3 = __toESM(require("walk-sync"));
|
|
1942
1911
|
var import_shelljs4 = __toESM(require("shelljs"));
|
|
1943
1912
|
function processExcludedFiles() {
|
|
@@ -1950,14 +1919,14 @@ function processExcludedFiles() {
|
|
|
1950
1919
|
ignore: ["**/_*/**/*"]
|
|
1951
1920
|
});
|
|
1952
1921
|
const navigationPaths2 = tocs_default.getNavigationPaths().map(
|
|
1953
|
-
(filePath) => convertBackSlashToSlash((0,
|
|
1922
|
+
(filePath) => convertBackSlashToSlash((0, import_path18.resolve)(inputFolderPath, filePath))
|
|
1954
1923
|
);
|
|
1955
1924
|
const tocSpecifiedFiles = new Set(navigationPaths2);
|
|
1956
1925
|
const excludedFiles = allContentFiles.filter((filePath) => !tocSpecifiedFiles.has(filePath));
|
|
1957
1926
|
import_shelljs4.default.rm("-f", excludedFiles);
|
|
1958
1927
|
const includedTocPaths2 = tocs_default.getIncludedTocPaths().map((filePath) => {
|
|
1959
|
-
const relativeTocPath = (0,
|
|
1960
|
-
const destTocPath = (0,
|
|
1928
|
+
const relativeTocPath = (0, import_path18.relative)(inputFolderPath, filePath);
|
|
1929
|
+
const destTocPath = (0, import_path18.resolve)(outputFolderPath, relativeTocPath);
|
|
1961
1930
|
return convertBackSlashToSlash(destTocPath);
|
|
1962
1931
|
});
|
|
1963
1932
|
import_shelljs4.default.rm("-rf", includedTocPaths2);
|
|
@@ -1977,7 +1946,7 @@ function processLogs(inputFolder) {
|
|
|
1977
1946
|
}
|
|
1978
1947
|
|
|
1979
1948
|
// src/steps/processPages.ts
|
|
1980
|
-
var
|
|
1949
|
+
var import_path23 = require("path");
|
|
1981
1950
|
var import_shelljs6 = __toESM(require("shelljs"));
|
|
1982
1951
|
var import_fs9 = require("fs");
|
|
1983
1952
|
var import_chalk4 = require("chalk");
|
|
@@ -1987,7 +1956,7 @@ var import_log11 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
|
1987
1956
|
|
|
1988
1957
|
// src/resolvers/md2md.ts
|
|
1989
1958
|
var import_fs6 = require("fs");
|
|
1990
|
-
var
|
|
1959
|
+
var import_path19 = require("path");
|
|
1991
1960
|
var import_shelljs5 = __toESM(require("shelljs"));
|
|
1992
1961
|
var import_log6 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
1993
1962
|
var import_liquid3 = __toESM(require("@diplodoc/transform/lib/liquid"));
|
|
@@ -1995,7 +1964,7 @@ function resolveMd2Md(options) {
|
|
|
1995
1964
|
return __async(this, null, function* () {
|
|
1996
1965
|
const { inputPath, outputPath, metadata } = options;
|
|
1997
1966
|
const { input, output } = argv_default.getConfig();
|
|
1998
|
-
const resolvedInputPath = (0,
|
|
1967
|
+
const resolvedInputPath = (0, import_path19.resolve)(input, inputPath);
|
|
1999
1968
|
const vars = getVarsPerFile(inputPath);
|
|
2000
1969
|
const content = yield getContentWithUpdatedMetadata(
|
|
2001
1970
|
(0, import_fs6.readFileSync)(resolvedInputPath, "utf8"),
|
|
@@ -2005,8 +1974,8 @@ function resolveMd2Md(options) {
|
|
|
2005
1974
|
const { result, changelogs } = transformMd2Md(content, {
|
|
2006
1975
|
path: resolvedInputPath,
|
|
2007
1976
|
destPath: outputPath,
|
|
2008
|
-
root: (0,
|
|
2009
|
-
destRoot: (0,
|
|
1977
|
+
root: (0, import_path19.resolve)(input),
|
|
1978
|
+
destRoot: (0, import_path19.resolve)(output),
|
|
2010
1979
|
collectOfPlugins: plugins_exports.getCollectOfPlugins(),
|
|
2011
1980
|
vars,
|
|
2012
1981
|
log: import_log6.default,
|
|
@@ -2014,8 +1983,8 @@ function resolveMd2Md(options) {
|
|
|
2014
1983
|
});
|
|
2015
1984
|
(0, import_fs6.writeFileSync)(outputPath, result);
|
|
2016
1985
|
if (changelogs == null ? void 0 : changelogs.length) {
|
|
2017
|
-
const mdFilename = (0,
|
|
2018
|
-
const outputDir = (0,
|
|
1986
|
+
const mdFilename = (0, import_path19.basename)(outputPath, (0, import_path19.extname)(outputPath));
|
|
1987
|
+
const outputDir = (0, import_path19.dirname)(outputPath);
|
|
2019
1988
|
changelogs.forEach((changes, index) => {
|
|
2020
1989
|
let changesName;
|
|
2021
1990
|
const changesDate = changes.date;
|
|
@@ -2032,7 +2001,7 @@ function resolveMd2Md(options) {
|
|
|
2032
2001
|
"0"
|
|
2033
2002
|
)}`;
|
|
2034
2003
|
}
|
|
2035
|
-
const changesPath = (0,
|
|
2004
|
+
const changesPath = (0, import_path19.join)(outputDir, `changes-${changesName}.json`);
|
|
2036
2005
|
if ((0, import_fs6.existsSync)(changesPath)) {
|
|
2037
2006
|
throw new Error(`Changelog ${changesPath} already exists!`);
|
|
2038
2007
|
}
|
|
@@ -2049,7 +2018,7 @@ function resolveMd2Md(options) {
|
|
|
2049
2018
|
});
|
|
2050
2019
|
}
|
|
2051
2020
|
function copyFile(targetPath, targetDestPath, options) {
|
|
2052
|
-
import_shelljs5.default.mkdir("-p", (0,
|
|
2021
|
+
import_shelljs5.default.mkdir("-p", (0, import_path19.dirname)(targetDestPath));
|
|
2053
2022
|
if (options) {
|
|
2054
2023
|
const sourceIncludeContent = (0, import_fs6.readFileSync)(targetPath, "utf8");
|
|
2055
2024
|
const { result } = transformMd2Md(sourceIncludeContent, options);
|
|
@@ -2108,7 +2077,7 @@ function transformMd2Md(input, options) {
|
|
|
2108
2077
|
}
|
|
2109
2078
|
|
|
2110
2079
|
// src/resolvers/md2html.ts
|
|
2111
|
-
var
|
|
2080
|
+
var import_path20 = require("path");
|
|
2112
2081
|
var import_fs7 = require("fs");
|
|
2113
2082
|
var import_js_yaml6 = __toESM(require("js-yaml"));
|
|
2114
2083
|
var import_transform = __toESM(require("@diplodoc/transform"));
|
|
@@ -2119,19 +2088,19 @@ var FileTransformer = {
|
|
|
2119
2088
|
".md": MdFileTransformer
|
|
2120
2089
|
};
|
|
2121
2090
|
var fixRelativePath = (relativeTo) => (path) => {
|
|
2122
|
-
return (0,
|
|
2091
|
+
return (0, import_path20.join)(getAssetsPublicPath(relativeTo), path);
|
|
2123
2092
|
};
|
|
2124
2093
|
function resolveMd2HTML(options) {
|
|
2125
2094
|
return __async(this, null, function* () {
|
|
2126
2095
|
var _a;
|
|
2127
2096
|
const { inputPath, fileExtension, outputPath, outputBundlePath, metadata } = options;
|
|
2128
|
-
const pathToDir = (0,
|
|
2097
|
+
const pathToDir = (0, import_path20.dirname)(inputPath);
|
|
2129
2098
|
const toc = tocs_default.getForPath(inputPath) || null;
|
|
2130
2099
|
const tocBase = toc && toc.base ? toc.base : "";
|
|
2131
|
-
const pathToFileDir = pathToDir === tocBase ? "" : pathToDir.replace(`${tocBase}${
|
|
2132
|
-
const relativePathToIndex = (0,
|
|
2100
|
+
const pathToFileDir = pathToDir === tocBase ? "" : pathToDir.replace(`${tocBase}${import_path20.sep}`, "");
|
|
2101
|
+
const relativePathToIndex = (0, import_path20.relative)(pathToDir, `${tocBase}${import_path20.sep}`);
|
|
2133
2102
|
const { input, lang, allowCustomResources } = argv_default.getConfig();
|
|
2134
|
-
const resolvedPath = (0,
|
|
2103
|
+
const resolvedPath = (0, import_path20.resolve)(input, inputPath);
|
|
2135
2104
|
const content = (0, import_fs7.readFileSync)(resolvedPath, "utf8");
|
|
2136
2105
|
const transformFn = FileTransformer[fileExtension];
|
|
2137
2106
|
const { result } = transformFn(content, { path: inputPath });
|
|
@@ -2153,12 +2122,12 @@ function resolveMd2HTML(options) {
|
|
|
2153
2122
|
meta: fileMeta
|
|
2154
2123
|
}),
|
|
2155
2124
|
router: {
|
|
2156
|
-
pathname: (0,
|
|
2125
|
+
pathname: (0, import_path20.join)(relativePathToIndex, pathToFileDir, (0, import_path20.basename)(outputPath))
|
|
2157
2126
|
},
|
|
2158
2127
|
lang: lang || "ru" /* RU */
|
|
2159
2128
|
};
|
|
2160
|
-
const outputDir = (0,
|
|
2161
|
-
const relativePathToBundle = (0,
|
|
2129
|
+
const outputDir = (0, import_path20.dirname)(outputPath);
|
|
2130
|
+
const relativePathToBundle = (0, import_path20.relative)((0, import_path20.resolve)(outputDir), (0, import_path20.resolve)(outputBundlePath));
|
|
2162
2131
|
const outputFileContent = generateStaticMarkup(props, relativePathToBundle);
|
|
2163
2132
|
(0, import_fs7.writeFileSync)(outputPath, outputFileContent);
|
|
2164
2133
|
logger.info(inputPath, PROCESSING_FINISHED);
|
|
@@ -2200,8 +2169,8 @@ function MdFileTransformer(content, transformOptions) {
|
|
|
2200
2169
|
const { path: filePath } = transformOptions;
|
|
2201
2170
|
const plugins2 = plugins_exports.getPlugins();
|
|
2202
2171
|
const vars = getVarsPerFile(filePath);
|
|
2203
|
-
const root = (0,
|
|
2204
|
-
const path = (0,
|
|
2172
|
+
const root = (0, import_path20.resolve)(input);
|
|
2173
|
+
const path = (0, import_path20.resolve)(input, filePath);
|
|
2205
2174
|
return (0, import_transform.default)(content, __spreadProps(__spreadValues({}, options), {
|
|
2206
2175
|
plugins: plugins2,
|
|
2207
2176
|
vars,
|
|
@@ -2214,7 +2183,7 @@ function MdFileTransformer(content, transformOptions) {
|
|
|
2214
2183
|
}
|
|
2215
2184
|
|
|
2216
2185
|
// src/resolvers/lintPage.ts
|
|
2217
|
-
var
|
|
2186
|
+
var import_path21 = require("path");
|
|
2218
2187
|
var import_log8 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
2219
2188
|
var import_yfmlint = __toESM(require("@diplodoc/transform/lib/yfmlint"));
|
|
2220
2189
|
var import_fs8 = require("fs");
|
|
@@ -2225,7 +2194,7 @@ var FileLinter = {
|
|
|
2225
2194
|
function lintPage(options) {
|
|
2226
2195
|
const { inputPath, fileExtension, onFinish } = options;
|
|
2227
2196
|
const { input } = argv_default.getConfig();
|
|
2228
|
-
const resolvedPath = (0,
|
|
2197
|
+
const resolvedPath = (0, import_path21.resolve)(input, inputPath);
|
|
2229
2198
|
try {
|
|
2230
2199
|
const content = (0, import_fs8.readFileSync)(resolvedPath, "utf8");
|
|
2231
2200
|
const lintFn = FileLinter[fileExtension];
|
|
@@ -2247,10 +2216,10 @@ function MdFileLinter(content, lintOptions) {
|
|
|
2247
2216
|
const { path: filePath } = lintOptions;
|
|
2248
2217
|
const plugins2 = outputFormat === "md" ? [] : plugins_exports.getPlugins();
|
|
2249
2218
|
const vars = getVarsPerFile(filePath);
|
|
2250
|
-
const root = (0,
|
|
2251
|
-
const path = (0,
|
|
2219
|
+
const root = (0, import_path21.resolve)(input);
|
|
2220
|
+
const path = (0, import_path21.resolve)(input, filePath);
|
|
2252
2221
|
let preparedContent = content;
|
|
2253
|
-
const assetsPublicPath = (0,
|
|
2222
|
+
const assetsPublicPath = (0, import_path21.relative)((0, import_path21.dirname)(path), root);
|
|
2254
2223
|
const lintMarkdown = function lintMarkdown2(opts) {
|
|
2255
2224
|
const { input: localInput, path: localPath, sourceMap: sourceMap2 } = opts;
|
|
2256
2225
|
const pluginOptions = __spreadProps(__spreadValues({}, options), {
|
|
@@ -2294,7 +2263,7 @@ function MdFileLinter(content, lintOptions) {
|
|
|
2294
2263
|
|
|
2295
2264
|
// src/vcs-connector/github.ts
|
|
2296
2265
|
var import_core = require("@octokit/core");
|
|
2297
|
-
var
|
|
2266
|
+
var import_path22 = require("path");
|
|
2298
2267
|
var import_simple_git = __toESM(require("simple-git"));
|
|
2299
2268
|
var import_minimatch = require("minimatch");
|
|
2300
2269
|
|
|
@@ -2508,7 +2477,7 @@ function getAllContributorsTocFiles(httpClientByToken) {
|
|
|
2508
2477
|
"origin/master"
|
|
2509
2478
|
);
|
|
2510
2479
|
const fullRepoLogString = yield (0, import_simple_git.default)({
|
|
2511
|
-
baseDir: (0,
|
|
2480
|
+
baseDir: (0, import_path22.join)(rootInput, masterDir)
|
|
2512
2481
|
}).raw(
|
|
2513
2482
|
"log",
|
|
2514
2483
|
`${FIRST_COMMIT_FROM_ROBOT_IN_GITHUB}..HEAD`,
|
|
@@ -2518,7 +2487,7 @@ function getAllContributorsTocFiles(httpClientByToken) {
|
|
|
2518
2487
|
const repoLogs = fullRepoLogString.split("\n\n");
|
|
2519
2488
|
if (import_process2.default.env.ENABLE_EXPERIMANTAL_AUTHORS) {
|
|
2520
2489
|
const fullAuthorRepoLogString = yield (0, import_simple_git.default)({
|
|
2521
|
-
baseDir: (0,
|
|
2490
|
+
baseDir: (0, import_path22.join)(rootInput, masterDir)
|
|
2522
2491
|
}).raw(
|
|
2523
2492
|
"log",
|
|
2524
2493
|
`${FIRST_COMMIT_FROM_ROBOT_IN_GITHUB}..HEAD`,
|
|
@@ -2615,7 +2584,7 @@ function getAuthorByPaths(commitInfo, paths, httpClientByToken) {
|
|
|
2615
2584
|
if (!path) {
|
|
2616
2585
|
continue;
|
|
2617
2586
|
}
|
|
2618
|
-
const normalizePath = (0,
|
|
2587
|
+
const normalizePath = (0, import_path22.normalize)(addSlashPrefix(path));
|
|
2619
2588
|
const { email, hashCommit } = commitInfo;
|
|
2620
2589
|
let authorToReturn = authorByGitEmail.get(email) || null;
|
|
2621
2590
|
if (!authorToReturn) {
|
|
@@ -2676,7 +2645,7 @@ function addNestedContributorsForPathFunction(path, nestedContributors) {
|
|
|
2676
2645
|
}
|
|
2677
2646
|
function addContributorForPath(paths, newContributor, hasIncludes = false) {
|
|
2678
2647
|
paths.forEach((path) => {
|
|
2679
|
-
const normalizePath = (0,
|
|
2648
|
+
const normalizePath = (0, import_path22.normalize)(addSlashPrefix(path));
|
|
2680
2649
|
if (!contributorsByPath.has(normalizePath)) {
|
|
2681
2650
|
contributorsByPath.set(normalizePath, {
|
|
2682
2651
|
contributors: newContributor,
|
|
@@ -2771,14 +2740,14 @@ function processPages(outputBundlePath) {
|
|
|
2771
2740
|
});
|
|
2772
2741
|
}
|
|
2773
2742
|
function getPathData(pathToFile, inputFolderPath, outputFolderPath, outputFormat, outputBundlePath) {
|
|
2774
|
-
const pathToDir = (0,
|
|
2775
|
-
const filename = (0,
|
|
2776
|
-
const fileExtension = (0,
|
|
2777
|
-
const fileBaseName = (0,
|
|
2778
|
-
const outputDir = (0,
|
|
2743
|
+
const pathToDir = (0, import_path23.dirname)(pathToFile);
|
|
2744
|
+
const filename = (0, import_path23.basename)(pathToFile);
|
|
2745
|
+
const fileExtension = (0, import_path23.extname)(pathToFile);
|
|
2746
|
+
const fileBaseName = (0, import_path23.basename)(filename, fileExtension);
|
|
2747
|
+
const outputDir = (0, import_path23.resolve)(outputFolderPath, pathToDir);
|
|
2779
2748
|
const outputFileName = `${fileBaseName}.${outputFormat}`;
|
|
2780
|
-
const outputPath = (0,
|
|
2781
|
-
const resolvedPathToFile = (0,
|
|
2749
|
+
const outputPath = (0, import_path23.resolve)(outputDir, outputFileName);
|
|
2750
|
+
const resolvedPathToFile = (0, import_path23.resolve)(inputFolderPath, pathToFile);
|
|
2782
2751
|
const outputTocDir = tocs_default.getTocDir(resolvedPathToFile);
|
|
2783
2752
|
const pathData = {
|
|
2784
2753
|
pathToFile,
|
|
@@ -2815,11 +2784,11 @@ function saveSinglePages(outputBundlePath) {
|
|
|
2815
2784
|
inputFolderPath,
|
|
2816
2785
|
tocDir
|
|
2817
2786
|
);
|
|
2818
|
-
const tocPath = (0,
|
|
2787
|
+
const tocPath = (0, import_path23.join)((0, import_path23.relative)(inputFolderPath, tocDir), "toc.yaml");
|
|
2819
2788
|
const toc = tocs_default.getForPath(tocPath) || null;
|
|
2820
2789
|
const preparedToc = transformTocForSinglePage(toc, {
|
|
2821
2790
|
root: inputFolderPath,
|
|
2822
|
-
currentPath: (0,
|
|
2791
|
+
currentPath: (0, import_path23.join)(tocDir, SINGLE_PAGE_FILENAME)
|
|
2823
2792
|
});
|
|
2824
2793
|
const pageData = {
|
|
2825
2794
|
data: {
|
|
@@ -2834,10 +2803,10 @@ function saveSinglePages(outputBundlePath) {
|
|
|
2834
2803
|
},
|
|
2835
2804
|
lang: lang || "ru" /* RU */
|
|
2836
2805
|
};
|
|
2837
|
-
const outputTocDir = (0,
|
|
2838
|
-
const relativeOutputBundlePath = (0,
|
|
2839
|
-
const singlePageFn = (0,
|
|
2840
|
-
const singlePageDataFn = (0,
|
|
2806
|
+
const outputTocDir = (0, import_path23.resolve)(outputFolderPath, (0, import_path23.relative)(inputFolderPath, tocDir));
|
|
2807
|
+
const relativeOutputBundlePath = (0, import_path23.relative)(outputTocDir, outputBundlePath);
|
|
2808
|
+
const singlePageFn = (0, import_path23.join)(tocDir, SINGLE_PAGE_FILENAME);
|
|
2809
|
+
const singlePageDataFn = (0, import_path23.join)(tocDir, SINGLE_PAGE_DATA_FILENAME);
|
|
2841
2810
|
const singlePageContent = generateStaticMarkup(pageData, relativeOutputBundlePath);
|
|
2842
2811
|
(0, import_fs9.writeFileSync)(singlePageFn, singlePageContent);
|
|
2843
2812
|
(0, import_fs9.writeFileSync)(singlePageDataFn, JSON.stringify(pageData));
|
|
@@ -2935,17 +2904,17 @@ function preparingPagesByOutputFormat(path, metaDataOptions, resolveConditions,
|
|
|
2935
2904
|
}
|
|
2936
2905
|
function processingYamlFile(path, metaDataOptions) {
|
|
2937
2906
|
const { pathToFile, outputFolderPath, inputFolderPath } = path;
|
|
2938
|
-
const filePath = (0,
|
|
2907
|
+
const filePath = (0, import_path23.resolve)(inputFolderPath, pathToFile);
|
|
2939
2908
|
const content = (0, import_fs9.readFileSync)(filePath, "utf8");
|
|
2940
2909
|
const parsedContent = (0, import_js_yaml7.load)(content);
|
|
2941
2910
|
if (metaDataOptions.resources) {
|
|
2942
2911
|
parsedContent.meta = __spreadValues(__spreadValues({}, parsedContent.meta), metaDataOptions.resources);
|
|
2943
2912
|
}
|
|
2944
|
-
(0, import_fs9.writeFileSync)((0,
|
|
2913
|
+
(0, import_fs9.writeFileSync)((0, import_path23.resolve)(outputFolderPath, pathToFile), (0, import_js_yaml7.dump)(parsedContent));
|
|
2945
2914
|
}
|
|
2946
2915
|
function copyFileWithoutChanges(resolvedPathToFile, outputDir, filename) {
|
|
2947
2916
|
const from = resolvedPathToFile;
|
|
2948
|
-
const to = (0,
|
|
2917
|
+
const to = (0, import_path23.resolve)(outputDir, filename);
|
|
2949
2918
|
import_shelljs6.default.cp(from, to);
|
|
2950
2919
|
}
|
|
2951
2920
|
function processingFileToMd(path, metaDataOptions) {
|
|
@@ -2975,7 +2944,7 @@ function processingFileToHtml(path, metaDataOptions) {
|
|
|
2975
2944
|
// src/steps/processLinter.ts
|
|
2976
2945
|
var import_log12 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
2977
2946
|
var import_threads = require("threads");
|
|
2978
|
-
var
|
|
2947
|
+
var import_path24 = require("path");
|
|
2979
2948
|
|
|
2980
2949
|
// src/utils/worker.ts
|
|
2981
2950
|
function splitOnChunks(array, chunkSize = 1e3) {
|
|
@@ -3052,7 +3021,7 @@ function lintPagesFallback(navigationPaths2) {
|
|
|
3052
3021
|
navigationPaths2.forEach((pathToFile) => {
|
|
3053
3022
|
lintPage({
|
|
3054
3023
|
inputPath: pathToFile,
|
|
3055
|
-
fileExtension: (0,
|
|
3024
|
+
fileExtension: (0, import_path24.extname)(pathToFile),
|
|
3056
3025
|
onFinish: () => {
|
|
3057
3026
|
logger.info(pathToFile, LINTING_FINISHED);
|
|
3058
3027
|
}
|
|
@@ -3061,7 +3030,7 @@ function lintPagesFallback(navigationPaths2) {
|
|
|
3061
3030
|
}
|
|
3062
3031
|
|
|
3063
3032
|
// src/steps/processServiceFiles.ts
|
|
3064
|
-
var
|
|
3033
|
+
var import_path25 = require("path");
|
|
3065
3034
|
var import_walk_sync4 = __toESM(require("walk-sync"));
|
|
3066
3035
|
var import_fs10 = require("fs");
|
|
3067
3036
|
var import_js_yaml8 = require("js-yaml");
|
|
@@ -3094,7 +3063,7 @@ function preparingPresetFiles(getFilePathsByGlobals) {
|
|
|
3094
3063
|
const presetsFilePaths = getFilePathsByGlobals(["**/presets.yaml"]);
|
|
3095
3064
|
for (const path of presetsFilePaths) {
|
|
3096
3065
|
logger.proc(path);
|
|
3097
|
-
const pathToPresetFile = (0,
|
|
3066
|
+
const pathToPresetFile = (0, import_path25.resolve)(inputFolderPath, path);
|
|
3098
3067
|
const content = (0, import_fs10.readFileSync)(pathToPresetFile, "utf8");
|
|
3099
3068
|
const parsedPreset = (0, import_js_yaml8.load)(content);
|
|
3100
3069
|
preset_default.add(parsedPreset, path, varsPreset);
|
|
@@ -3109,7 +3078,7 @@ function preparingPresetFiles(getFilePathsByGlobals) {
|
|
|
3109
3078
|
}
|
|
3110
3079
|
function saveFilteredPresets(path, parsedPreset) {
|
|
3111
3080
|
const { output: outputFolderPath, varsPreset = "" } = argv_default.getConfig();
|
|
3112
|
-
const outputPath = (0,
|
|
3081
|
+
const outputPath = (0, import_path25.resolve)(outputFolderPath, path);
|
|
3113
3082
|
const filteredPreset = {
|
|
3114
3083
|
default: parsedPreset.default
|
|
3115
3084
|
};
|
|
@@ -3119,7 +3088,7 @@ function saveFilteredPresets(path, parsedPreset) {
|
|
|
3119
3088
|
const outputPreset = (0, import_js_yaml8.dump)(filteredPreset, {
|
|
3120
3089
|
lineWidth: 120
|
|
3121
3090
|
});
|
|
3122
|
-
import_shelljs7.default.mkdir("-p", (0,
|
|
3091
|
+
import_shelljs7.default.mkdir("-p", (0, import_path25.dirname)(outputPath));
|
|
3123
3092
|
(0, import_fs10.writeFileSync)(outputPath, outputPreset);
|
|
3124
3093
|
}
|
|
3125
3094
|
function preparingTocFiles(getFilePathsByGlobals) {
|
|
@@ -3139,11 +3108,11 @@ function preparingTocFiles(getFilePathsByGlobals) {
|
|
|
3139
3108
|
|
|
3140
3109
|
// src/steps/processMapFile.ts
|
|
3141
3110
|
var import_fs11 = require("fs");
|
|
3142
|
-
var
|
|
3111
|
+
var import_path26 = require("path");
|
|
3143
3112
|
function prepareMapFile() {
|
|
3144
3113
|
const { output: outputFolderPath } = argv_default.getConfig();
|
|
3145
3114
|
const navigationPathsWithoutExtensions = tocs_default.getNavigationPaths().map((path) => {
|
|
3146
|
-
let preparedPath = convertBackSlashToSlash(path.replace((0,
|
|
3115
|
+
let preparedPath = convertBackSlashToSlash(path.replace((0, import_path26.extname)(path), ""));
|
|
3147
3116
|
if (preparedPath.endsWith("/index")) {
|
|
3148
3117
|
preparedPath = preparedPath.substring(0, preparedPath.length - 5);
|
|
3149
3118
|
}
|
|
@@ -3151,7 +3120,7 @@ function prepareMapFile() {
|
|
|
3151
3120
|
});
|
|
3152
3121
|
const navigationPaths2 = { files: [...new Set(navigationPathsWithoutExtensions)] };
|
|
3153
3122
|
const filesMapBuffer = Buffer.from(JSON.stringify(navigationPaths2, null, " "), "utf8");
|
|
3154
|
-
const mapFile = (0,
|
|
3123
|
+
const mapFile = (0, import_path26.join)(outputFolderPath, "files.json");
|
|
3155
3124
|
(0, import_fs11.writeFileSync)(mapFile, filesMapBuffer);
|
|
3156
3125
|
}
|
|
3157
3126
|
|
|
@@ -3161,7 +3130,7 @@ var import_shelljs8 = __toESM(require("shelljs"));
|
|
|
3161
3130
|
// src/cmd/publish/upload.ts
|
|
3162
3131
|
var import_fs12 = require("fs");
|
|
3163
3132
|
var import_walk_sync5 = __toESM(require("walk-sync"));
|
|
3164
|
-
var
|
|
3133
|
+
var import_path27 = require("path");
|
|
3165
3134
|
var import_client_s3 = require("@aws-sdk/client-s3");
|
|
3166
3135
|
var import_mime_types = __toESM(require("mime-types"));
|
|
3167
3136
|
var import_async2 = require("async");
|
|
@@ -3182,7 +3151,7 @@ function upload(props) {
|
|
|
3182
3151
|
region,
|
|
3183
3152
|
credentials: { accessKeyId, secretAccessKey }
|
|
3184
3153
|
});
|
|
3185
|
-
const filesToPublish = (0, import_walk_sync5.default)((0,
|
|
3154
|
+
const filesToPublish = (0, import_walk_sync5.default)((0, import_path27.resolve)(input), {
|
|
3186
3155
|
directories: false,
|
|
3187
3156
|
includeBasePath: false,
|
|
3188
3157
|
ignore
|
|
@@ -3198,8 +3167,8 @@ function upload(props) {
|
|
|
3198
3167
|
new import_client_s3.PutObjectCommand({
|
|
3199
3168
|
ContentType: mimeType ? mimeType : void 0,
|
|
3200
3169
|
Bucket: bucket,
|
|
3201
|
-
Key: convertBackSlashToSlash((0,
|
|
3202
|
-
Body: (0, import_fs12.createReadStream)((0,
|
|
3170
|
+
Key: convertBackSlashToSlash((0, import_path27.join)(prefix, pathToFile)),
|
|
3171
|
+
Body: (0, import_fs12.createReadStream)((0, import_path27.resolve)(input, pathToFile))
|
|
3203
3172
|
})
|
|
3204
3173
|
);
|
|
3205
3174
|
} catch (error) {
|
|
@@ -3334,9 +3303,9 @@ function builder(argv) {
|
|
|
3334
3303
|
function handler(args) {
|
|
3335
3304
|
return __async(this, null, function* () {
|
|
3336
3305
|
var _a;
|
|
3337
|
-
const userOutputFolder = (0,
|
|
3338
|
-
const tmpInputFolder = (0,
|
|
3339
|
-
const tmpOutputFolder = (0,
|
|
3306
|
+
const userOutputFolder = (0, import_path28.resolve)(args.output);
|
|
3307
|
+
const tmpInputFolder = (0, import_path28.resolve)(args.output, TMP_INPUT_FOLDER);
|
|
3308
|
+
const tmpOutputFolder = (0, import_path28.resolve)(args.output, TMP_OUTPUT_FOLDER);
|
|
3340
3309
|
try {
|
|
3341
3310
|
argv_default.init(__spreadProps(__spreadValues({}, args), {
|
|
3342
3311
|
rootInput: args.input,
|
|
@@ -3360,10 +3329,10 @@ function handler(args) {
|
|
|
3360
3329
|
if (addMapFile) {
|
|
3361
3330
|
prepareMapFile();
|
|
3362
3331
|
}
|
|
3363
|
-
const outputBundlePath = (0,
|
|
3364
|
-
const pathToConfig = args.config || (0,
|
|
3365
|
-
const pathToRedirects = (0,
|
|
3366
|
-
const pathToLintConfig = (0,
|
|
3332
|
+
const outputBundlePath = (0, import_path28.join)(outputFolderPath, BUNDLE_FOLDER);
|
|
3333
|
+
const pathToConfig = args.config || (0, import_path28.join)(args.input, YFM_CONFIG_FILENAME);
|
|
3334
|
+
const pathToRedirects = (0, import_path28.join)(args.input, REDIRECTS_FILENAME);
|
|
3335
|
+
const pathToLintConfig = (0, import_path28.join)(args.input, LINT_CONFIG_FILENAME);
|
|
3367
3336
|
if (!lintDisabled) {
|
|
3368
3337
|
yield initLinterWorkers();
|
|
3369
3338
|
}
|
|
@@ -3378,9 +3347,9 @@ function handler(args) {
|
|
|
3378
3347
|
processAssets(outputBundlePath);
|
|
3379
3348
|
break;
|
|
3380
3349
|
case "md": {
|
|
3381
|
-
import_shelljs8.default.cp((0,
|
|
3382
|
-
import_shelljs8.default.cp((0,
|
|
3383
|
-
import_shelljs8.default.cp((0,
|
|
3350
|
+
import_shelljs8.default.cp((0, import_path28.resolve)(pathToConfig), tmpOutputFolder);
|
|
3351
|
+
import_shelljs8.default.cp((0, import_path28.resolve)(pathToRedirects), tmpOutputFolder);
|
|
3352
|
+
import_shelljs8.default.cp((0, import_path28.resolve)(pathToLintConfig), tmpOutputFolder);
|
|
3384
3353
|
if (resources && allowCustomResources) {
|
|
3385
3354
|
const resourcePaths = [];
|
|
3386
3355
|
Object.keys(resources).forEach(
|
|
@@ -3398,7 +3367,7 @@ function handler(args) {
|
|
|
3398
3367
|
}
|
|
3399
3368
|
import_shelljs8.default.cp(
|
|
3400
3369
|
"-r",
|
|
3401
|
-
[(0,
|
|
3370
|
+
[(0, import_path28.join)(tmpOutputFolder, "*"), (0, import_path28.join)(tmpOutputFolder, ".*")],
|
|
3402
3371
|
userOutputFolder
|
|
3403
3372
|
);
|
|
3404
3373
|
if (publish2) {
|
|
@@ -3451,7 +3420,7 @@ function preparingTemporaryFolders(userOutputFolder) {
|
|
|
3451
3420
|
}
|
|
3452
3421
|
|
|
3453
3422
|
// src/cmd/publish/index.ts
|
|
3454
|
-
var
|
|
3423
|
+
var import_path29 = require("path");
|
|
3455
3424
|
var command = "publish";
|
|
3456
3425
|
var description = "Upload builded documentation to target S3 bucket";
|
|
3457
3426
|
var publish = {
|
|
@@ -3505,7 +3474,7 @@ function handler2(args) {
|
|
|
3505
3474
|
return __async(this, null, function* () {
|
|
3506
3475
|
argv_default.init(__spreadValues({}, args));
|
|
3507
3476
|
const { input, endpoint, bucket, prefix } = argv_default.getConfig();
|
|
3508
|
-
logger.info("", `Upload artifacts from ${input} to ${(0,
|
|
3477
|
+
logger.info("", `Upload artifacts from ${input} to ${(0, import_path29.join)(endpoint, bucket, prefix)}`);
|
|
3509
3478
|
try {
|
|
3510
3479
|
yield upload(argv_default.getConfig());
|
|
3511
3480
|
} catch (error) {
|
|
@@ -3515,7 +3484,7 @@ function handler2(args) {
|
|
|
3515
3484
|
}
|
|
3516
3485
|
|
|
3517
3486
|
// src/cmd/xliff/extract.ts
|
|
3518
|
-
var
|
|
3487
|
+
var import_path30 = require("path");
|
|
3519
3488
|
var import_markdown_translation = __toESM(require("@diplodoc/markdown-translation"));
|
|
3520
3489
|
var import_async3 = require("async");
|
|
3521
3490
|
var {
|
|
@@ -3578,7 +3547,7 @@ function handler3(args) {
|
|
|
3578
3547
|
try {
|
|
3579
3548
|
({
|
|
3580
3549
|
state: { found, cache }
|
|
3581
|
-
} = yield glob((0,
|
|
3550
|
+
} = yield glob((0, import_path30.join)(input, MD_GLOB2), {
|
|
3582
3551
|
nosort: true,
|
|
3583
3552
|
cache
|
|
3584
3553
|
}));
|
|
@@ -3612,9 +3581,9 @@ function pipeline2(params) {
|
|
|
3612
3581
|
const { input, output, source, target } = params;
|
|
3613
3582
|
return (markdownPath) => __async(this, null, function* () {
|
|
3614
3583
|
const markdown = yield reader({ path: markdownPath });
|
|
3615
|
-
const extension = (0,
|
|
3584
|
+
const extension = (0, import_path30.extname)(markdownPath);
|
|
3616
3585
|
const outputRelativePath = markdownPath.replace(extension, "").slice(input.length);
|
|
3617
|
-
const outputPath = (0,
|
|
3586
|
+
const outputPath = (0, import_path30.join)(output, outputRelativePath);
|
|
3618
3587
|
const xlfPath = outputPath + ".xliff";
|
|
3619
3588
|
const skeletonPath = outputPath + ".skl.md";
|
|
3620
3589
|
const extractParameters = {
|
|
@@ -3668,7 +3637,7 @@ function writer(params) {
|
|
|
3668
3637
|
const { xlfPath, skeletonPath, xlf, skeleton } = params;
|
|
3669
3638
|
logger.info(params.xlfPath, "writing xliff file");
|
|
3670
3639
|
logger.info(params.skeletonPath, "writing skeleton file");
|
|
3671
|
-
yield mkdir2((0,
|
|
3640
|
+
yield mkdir2((0, import_path30.dirname)(xlfPath), { recursive: true });
|
|
3672
3641
|
yield Promise.all([writeFile2(skeletonPath, skeleton), writeFile2(xlfPath, xlf)]);
|
|
3673
3642
|
logger.info(params.xlfPath, "finished writing xliff file");
|
|
3674
3643
|
logger.info(params.skeletonPath, "finished writing skeleton file");
|
|
@@ -3676,7 +3645,7 @@ function writer(params) {
|
|
|
3676
3645
|
}
|
|
3677
3646
|
|
|
3678
3647
|
// src/cmd/xliff/compose.ts
|
|
3679
|
-
var
|
|
3648
|
+
var import_path31 = require("path");
|
|
3680
3649
|
var import_markdown_translation2 = __toESM(require("@diplodoc/markdown-translation"));
|
|
3681
3650
|
var import_async4 = require("async");
|
|
3682
3651
|
var {
|
|
@@ -3716,13 +3685,13 @@ function handler4(args) {
|
|
|
3716
3685
|
try {
|
|
3717
3686
|
({
|
|
3718
3687
|
state: { found: skeletonPaths, cache }
|
|
3719
|
-
} = yield glob((0,
|
|
3688
|
+
} = yield glob((0, import_path31.join)(input, SKL_MD_GLOB), {
|
|
3720
3689
|
nosort: false,
|
|
3721
3690
|
cache
|
|
3722
3691
|
}));
|
|
3723
3692
|
({
|
|
3724
3693
|
state: { found: xliffPaths, cache }
|
|
3725
|
-
} = yield glob((0,
|
|
3694
|
+
} = yield glob((0, import_path31.join)(input, XLF_GLOB), {
|
|
3726
3695
|
nosort: false,
|
|
3727
3696
|
cache
|
|
3728
3697
|
}));
|
|
@@ -3752,7 +3721,7 @@ function handler4(args) {
|
|
|
3752
3721
|
function pipeline3(params) {
|
|
3753
3722
|
const { input, output } = params;
|
|
3754
3723
|
return (xliffPath) => __async(this, null, function* () {
|
|
3755
|
-
const extension = (0,
|
|
3724
|
+
const extension = (0, import_path31.extname)(xliffPath);
|
|
3756
3725
|
const extensionLessPath = xliffPath.replace(extension, "");
|
|
3757
3726
|
const skeletonPath = extensionLessPath + ".skl.md";
|
|
3758
3727
|
const readerParameters = { xliffPath, skeletonPath };
|
|
@@ -3763,7 +3732,7 @@ function pipeline3(params) {
|
|
|
3763
3732
|
});
|
|
3764
3733
|
const { markdown } = yield composer(composerParameters);
|
|
3765
3734
|
const inputRelativePath = extensionLessPath.slice(input.length);
|
|
3766
|
-
const markdownPath = (0,
|
|
3735
|
+
const markdownPath = (0, import_path31.join)(output, inputRelativePath) + ".md";
|
|
3767
3736
|
const writerParameters = {
|
|
3768
3737
|
markdown,
|
|
3769
3738
|
markdownPath
|
|
@@ -3820,7 +3789,7 @@ function writer2(params) {
|
|
|
3820
3789
|
const { markdown, markdownPath } = params;
|
|
3821
3790
|
try {
|
|
3822
3791
|
logger.info(markdownPath, "writing markdown file");
|
|
3823
|
-
yield mkdir3((0,
|
|
3792
|
+
yield mkdir3((0, import_path31.dirname)(markdownPath), { recursive: true });
|
|
3824
3793
|
yield writeFile3(markdownPath, markdown);
|
|
3825
3794
|
logger.info(markdownPath, "finished writing markdown file");
|
|
3826
3795
|
} catch (err) {
|
|
@@ -3850,7 +3819,7 @@ function builder5(argv) {
|
|
|
3850
3819
|
|
|
3851
3820
|
// src/cmd/translate/index.ts
|
|
3852
3821
|
var import_async5 = require("async");
|
|
3853
|
-
var
|
|
3822
|
+
var import_path33 = require("path");
|
|
3854
3823
|
var import_promises4 = require("fs/promises");
|
|
3855
3824
|
var import_fast_xml_parser = require("fast-xml-parser");
|
|
3856
3825
|
var import_session = require("@yandex-cloud/nodejs-sdk/dist/session");
|
|
@@ -3862,7 +3831,7 @@ var import_markdown_translation3 = __toESM(require("@diplodoc/markdown-translati
|
|
|
3862
3831
|
var import_promises3 = require("fs/promises");
|
|
3863
3832
|
var import_process3 = require("process");
|
|
3864
3833
|
var import_os = require("os");
|
|
3865
|
-
var
|
|
3834
|
+
var import_path32 = require("path");
|
|
3866
3835
|
var YANDEX_OAUTH_TOKEN_FILENAME = ".ya_oauth_token";
|
|
3867
3836
|
function getYandexOAuthToken() {
|
|
3868
3837
|
return __async(this, null, function* () {
|
|
@@ -3873,7 +3842,7 @@ function getYandexOAuthToken() {
|
|
|
3873
3842
|
function getYandexOAuthTokenFromHomeDir() {
|
|
3874
3843
|
return __async(this, null, function* () {
|
|
3875
3844
|
const error = "failed reading yandex oauth token";
|
|
3876
|
-
const path = (0,
|
|
3845
|
+
const path = (0, import_path32.join)((0, import_os.homedir)(), YANDEX_OAUTH_TOKEN_FILENAME);
|
|
3877
3846
|
let token;
|
|
3878
3847
|
try {
|
|
3879
3848
|
token = yield (0, import_promises3.readFile)(path, { encoding: "utf8" });
|
|
@@ -3941,7 +3910,7 @@ function handler5(args) {
|
|
|
3941
3910
|
let found = [];
|
|
3942
3911
|
({
|
|
3943
3912
|
state: { found }
|
|
3944
|
-
} = yield glob((0,
|
|
3913
|
+
} = yield glob((0, import_path33.join)(input, MD_GLOB3), {
|
|
3945
3914
|
nosort: true
|
|
3946
3915
|
}));
|
|
3947
3916
|
const oauthToken = yield getYandexOAuthToken();
|
|
@@ -3980,11 +3949,11 @@ function translator(params) {
|
|
|
3980
3949
|
yandexCloudTranslateGlossaryPairs
|
|
3981
3950
|
} = params;
|
|
3982
3951
|
const session = new import_session.Session({ oauthToken });
|
|
3983
|
-
const
|
|
3952
|
+
const client = session.client(import_service_clients.TranslationServiceClient);
|
|
3984
3953
|
return (mdPath) => __async(this, null, function* () {
|
|
3985
3954
|
try {
|
|
3986
3955
|
logger.info(mdPath, "translating");
|
|
3987
|
-
const md = yield (0, import_promises4.readFile)((0,
|
|
3956
|
+
const md = yield (0, import_promises4.readFile)((0, import_path33.resolve)(mdPath), { encoding: "utf-8" });
|
|
3988
3957
|
const { xlf, skeleton } = import_markdown_translation3.default.extract({
|
|
3989
3958
|
source: {
|
|
3990
3959
|
language: sourceLanguage,
|
|
@@ -4020,7 +3989,7 @@ function translator(params) {
|
|
|
4020
3989
|
},
|
|
4021
3990
|
(0, import_async5.asyncify)(
|
|
4022
3991
|
() => __async(this, null, function* () {
|
|
4023
|
-
return yield
|
|
3992
|
+
return yield client.translate(machineTranslateParams).then(
|
|
4024
3993
|
(results) => results.translations.map(({ text }) => text)
|
|
4025
3994
|
);
|
|
4026
3995
|
})
|
|
@@ -4038,7 +4007,7 @@ function translator(params) {
|
|
|
4038
4007
|
skeleton
|
|
4039
4008
|
});
|
|
4040
4009
|
const outputPath = mdPath.replace(input, output);
|
|
4041
|
-
yield (0, import_promises4.mkdir)((0,
|
|
4010
|
+
yield (0, import_promises4.mkdir)((0, import_path33.dirname)(outputPath), { recursive: true });
|
|
4042
4011
|
yield (0, import_promises4.writeFile)(outputPath, composed);
|
|
4043
4012
|
logger.info(outputPath, "finished translating");
|
|
4044
4013
|
} catch (err) {
|
|
@@ -4090,7 +4059,7 @@ import_yargs.default.command(build).command(publish).command(xliff).command(tran
|
|
|
4090
4059
|
default: false,
|
|
4091
4060
|
describe: "Run in quiet mode. Don't write logs to stdout",
|
|
4092
4061
|
type: "boolean"
|
|
4093
|
-
}).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.6.0-alpha-
|
|
4062
|
+
}).group(["config", "strict", "quiet", "help", "version"], "Common options:").version(true ? "4.6.0-alpha-2" : "").help().parse((0, import_helpers.hideBin)(process.argv), {}, (err, { strict }, output) => {
|
|
4094
4063
|
console.timeEnd(MAIN_TIMER_ID);
|
|
4095
4064
|
if (err) {
|
|
4096
4065
|
console.error(err);
|