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