@diplodoc/cli 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/app.css +4 -0
- package/assets/app.js +2 -0
- package/assets/react.js +3 -0
- package/{build/app.client.css → assets/vendor.css} +857 -19
- package/assets/vendor.js +3 -0
- package/build/index.js +203 -230
- package/build/index.js.map +4 -4
- package/build/linter.js +79 -111
- package/build/linter.js.map +4 -4
- package/package.json +8 -23
- package/src/cmd/publish/index.ts +16 -4
- package/src/constants.ts +4 -6
- package/src/resolvers/md2html.ts +4 -0
- package/src/steps/processAssets.ts +3 -5
- package/src/utils/markup.ts +18 -7
- package/src/utils/path.ts +0 -8
- package/src/utils/singlePage.ts +10 -5
- package/build/app.client.js +0 -3
package/build/linter.js
CHANGED
|
@@ -34,9 +34,6 @@ var __objRest = (source, exclude) => {
|
|
|
34
34
|
}
|
|
35
35
|
return target;
|
|
36
36
|
};
|
|
37
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
38
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
39
|
-
};
|
|
40
37
|
var __export = (target, all) => {
|
|
41
38
|
for (var name4 in all)
|
|
42
39
|
__defProp(target, name4, { get: all[name4], enumerable: true });
|
|
@@ -59,7 +56,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
59
56
|
));
|
|
60
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
61
58
|
var __async = (__this, __arguments, generator) => {
|
|
62
|
-
return new Promise((
|
|
59
|
+
return new Promise((resolve11, reject) => {
|
|
63
60
|
var fulfilled = (value) => {
|
|
64
61
|
try {
|
|
65
62
|
step(generator.next(value));
|
|
@@ -74,53 +71,21 @@ 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 ? resolve11(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/workers/linter/index.ts
|
|
115
80
|
var linter_exports = {};
|
|
116
81
|
module.exports = __toCommonJS(linter_exports);
|
|
117
82
|
var import_log7 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
118
|
-
var
|
|
83
|
+
var import_path20 = require("path");
|
|
119
84
|
var import_observable = require("threads/observable");
|
|
120
85
|
var import_threads = require("threads");
|
|
121
86
|
|
|
122
87
|
// src/services/tocs.ts
|
|
123
|
-
var
|
|
88
|
+
var import_path13 = require("path");
|
|
124
89
|
var import_fs2 = require("fs");
|
|
125
90
|
var import_js_yaml3 = require("js-yaml");
|
|
126
91
|
var import_shelljs2 = __toESM(require("shelljs"));
|
|
@@ -168,6 +133,7 @@ var logger = {
|
|
|
168
133
|
};
|
|
169
134
|
|
|
170
135
|
// src/utils/markup.ts
|
|
136
|
+
var import_path3 = require("path");
|
|
171
137
|
var import_process = require("process");
|
|
172
138
|
|
|
173
139
|
// src/constants.ts
|
|
@@ -192,11 +158,12 @@ var term = require("@diplodoc/transform/lib/plugins/term");
|
|
|
192
158
|
var blockAnchor = require("@diplodoc/transform/lib/plugins/block-anchor");
|
|
193
159
|
var changelog = require("@diplodoc/transform/lib/plugins/changelog");
|
|
194
160
|
var mermaid = require("@diplodoc/mermaid-extension");
|
|
161
|
+
var latex = require("@diplodoc/latex-extension");
|
|
195
162
|
var openapi = require("@diplodoc/openapi-extension");
|
|
196
163
|
includes.collect = require("@diplodoc/transform/lib/plugins/includes/collect");
|
|
197
164
|
images.collect = require("@diplodoc/transform/lib/plugins/images/collect");
|
|
198
165
|
changelog.collect = require("@diplodoc/transform/lib/plugins/changelog/collect");
|
|
199
|
-
var
|
|
166
|
+
var ASSETS_FOLDER = (0, import_path.resolve)(__dirname, "../assets");
|
|
200
167
|
var YFM_PLUGINS = [
|
|
201
168
|
meta,
|
|
202
169
|
deflist,
|
|
@@ -216,6 +183,7 @@ var YFM_PLUGINS = [
|
|
|
216
183
|
term,
|
|
217
184
|
openapi.transform(),
|
|
218
185
|
mermaid.transform(),
|
|
186
|
+
latex.transform(),
|
|
219
187
|
changelog,
|
|
220
188
|
blockAnchor
|
|
221
189
|
];
|
|
@@ -232,7 +200,7 @@ var import_node_html_parser = require("node-html-parser");
|
|
|
232
200
|
var import_path2 = require("path");
|
|
233
201
|
var import_utilsFS = require("@diplodoc/transform/lib/utilsFS");
|
|
234
202
|
var import_url = __toESM(require("url"));
|
|
235
|
-
var
|
|
203
|
+
var import_escapeRegExp = __toESM(require("lodash/escapeRegExp"));
|
|
236
204
|
|
|
237
205
|
// src/utils/url.ts
|
|
238
206
|
function isExternalHref(href) {
|
|
@@ -240,15 +208,15 @@ function isExternalHref(href) {
|
|
|
240
208
|
}
|
|
241
209
|
|
|
242
210
|
// src/utils/markup.ts
|
|
243
|
-
var
|
|
244
|
-
var
|
|
211
|
+
var import_ssr = require("@diplodoc/client/ssr");
|
|
212
|
+
var import_manifest = __toESM(require("@diplodoc/client/manifest"));
|
|
245
213
|
var \u0441arriage = import_process.platform === "win32" /* WINDOWS */ ? "\r\n" : "\n";
|
|
246
214
|
|
|
247
215
|
// src/utils/path.ts
|
|
248
|
-
var
|
|
216
|
+
var import_path4 = require("path");
|
|
249
217
|
|
|
250
218
|
// src/utils/toc.ts
|
|
251
|
-
var
|
|
219
|
+
var import_path5 = require("path");
|
|
252
220
|
|
|
253
221
|
// src/services/utils.ts
|
|
254
222
|
var import_evaluation = __toESM(require("@diplodoc/transform/lib/liquid/evaluation"));
|
|
@@ -333,15 +301,15 @@ function isObject(o) {
|
|
|
333
301
|
}
|
|
334
302
|
|
|
335
303
|
// src/utils/presets.ts
|
|
336
|
-
var
|
|
304
|
+
var import_path6 = require("path");
|
|
337
305
|
function getVarsPerFile(filePath) {
|
|
338
306
|
const { vars: argVars } = argv_default.getConfig();
|
|
339
|
-
return __spreadValues(__spreadValues({}, preset_default.get((0,
|
|
307
|
+
return __spreadValues(__spreadValues({}, preset_default.get((0, import_path6.dirname)(filePath))), argVars);
|
|
340
308
|
}
|
|
341
309
|
function getVarsPerRelativeFile(filePath) {
|
|
342
310
|
const { input } = argv_default.getConfig();
|
|
343
|
-
const root = (0,
|
|
344
|
-
const relativeFilePath = (0,
|
|
311
|
+
const root = (0, import_path6.resolve)(input);
|
|
312
|
+
const relativeFilePath = (0, import_path6.relative)(root, filePath);
|
|
345
313
|
return getVarsPerFile(relativeFilePath);
|
|
346
314
|
}
|
|
347
315
|
|
|
@@ -354,15 +322,15 @@ var glob = (pattern, options) => __async(void 0, null, function* () {
|
|
|
354
322
|
});
|
|
355
323
|
|
|
356
324
|
// src/utils/file.ts
|
|
357
|
-
var
|
|
325
|
+
var import_path7 = require("path");
|
|
358
326
|
var import_shelljs = __toESM(require("shelljs"));
|
|
359
327
|
|
|
360
328
|
// src/services/contributors.ts
|
|
361
329
|
var import_promises = require("fs/promises");
|
|
362
|
-
var
|
|
330
|
+
var import_path8 = require("path");
|
|
363
331
|
|
|
364
332
|
// src/services/metadata.ts
|
|
365
|
-
var
|
|
333
|
+
var import_path9 = require("path");
|
|
366
334
|
function getContentWithUpdatedStaticMetadata({
|
|
367
335
|
fileContent,
|
|
368
336
|
sourcePath,
|
|
@@ -419,8 +387,8 @@ __export(includers_exports, {
|
|
|
419
387
|
applyIncluders: () => applyIncluders,
|
|
420
388
|
init: () => init
|
|
421
389
|
});
|
|
422
|
-
var
|
|
423
|
-
var
|
|
390
|
+
var import_path12 = require("path");
|
|
391
|
+
var import_lodash2 = require("lodash");
|
|
424
392
|
|
|
425
393
|
// src/services/includers/batteries/generic.ts
|
|
426
394
|
var generic_exports = {};
|
|
@@ -430,8 +398,8 @@ __export(generic_exports, {
|
|
|
430
398
|
name: () => name
|
|
431
399
|
});
|
|
432
400
|
var import_promises2 = require("fs/promises");
|
|
433
|
-
var
|
|
434
|
-
var
|
|
401
|
+
var import_path10 = require("path");
|
|
402
|
+
var import_lodash = require("lodash");
|
|
435
403
|
var import_js_yaml2 = require("js-yaml");
|
|
436
404
|
var GenericIncluderError = class extends Error {
|
|
437
405
|
constructor(message, path) {
|
|
@@ -458,8 +426,8 @@ function includerFunction(params) {
|
|
|
458
426
|
}
|
|
459
427
|
try {
|
|
460
428
|
const leadingPageName = (_b = leadingPage == null ? void 0 : leadingPage.name) != null ? _b : "Overview";
|
|
461
|
-
const tocDirPath = (0,
|
|
462
|
-
const contentPath = index === 0 ? (0,
|
|
429
|
+
const tocDirPath = (0, import_path10.dirname)(tocPath);
|
|
430
|
+
const contentPath = index === 0 ? (0, import_path10.join)(writeBasePath, tocDirPath, input) : (0, import_path10.join)(readBasePath, tocDirPath, input);
|
|
463
431
|
let cache = {};
|
|
464
432
|
let found = [];
|
|
465
433
|
({
|
|
@@ -470,16 +438,16 @@ function includerFunction(params) {
|
|
|
470
438
|
nocase: true,
|
|
471
439
|
cache
|
|
472
440
|
}));
|
|
473
|
-
const writePath = (0,
|
|
441
|
+
const writePath = (0, import_path10.join)(writeBasePath, tocDirPath, item.include.path);
|
|
474
442
|
yield (0, import_promises2.mkdir)(writePath, { recursive: true });
|
|
475
443
|
for (const filePath of found) {
|
|
476
|
-
const file = yield (0, import_promises2.readFile)((0,
|
|
477
|
-
yield (0, import_promises2.mkdir)((0,
|
|
478
|
-
yield (0, import_promises2.writeFile)((0,
|
|
444
|
+
const file = yield (0, import_promises2.readFile)((0, import_path10.join)(contentPath, filePath));
|
|
445
|
+
yield (0, import_promises2.mkdir)((0, import_path10.dirname)((0, import_path10.join)(writePath, filePath)), { recursive: true });
|
|
446
|
+
yield (0, import_promises2.writeFile)((0, import_path10.join)(writePath, filePath), file);
|
|
479
447
|
}
|
|
480
448
|
const graph = createGraphFromPaths(found);
|
|
481
449
|
const toc = createToc(leadingPageName, item.include.path)(graph, []);
|
|
482
|
-
yield (0, import_promises2.writeFile)((0,
|
|
450
|
+
yield (0, import_promises2.writeFile)((0, import_path10.join)(writePath, "toc.yaml"), (0, import_js_yaml2.dump)(toc));
|
|
483
451
|
} catch (err) {
|
|
484
452
|
throw new GenericIncluderError(err.toString(), tocPath);
|
|
485
453
|
}
|
|
@@ -496,7 +464,7 @@ function createGraphFromPaths(paths) {
|
|
|
496
464
|
continue;
|
|
497
465
|
}
|
|
498
466
|
const file = chunks.pop();
|
|
499
|
-
(0,
|
|
467
|
+
(0, import_lodash.updateWith)(
|
|
500
468
|
graph,
|
|
501
469
|
chunks,
|
|
502
470
|
(old) => {
|
|
@@ -511,8 +479,8 @@ function createToc(leadingPageName, tocName) {
|
|
|
511
479
|
return function createTocRec(graph, cursor) {
|
|
512
480
|
var _a, _b;
|
|
513
481
|
const handler = (file) => ({
|
|
514
|
-
name: (0,
|
|
515
|
-
href: (0,
|
|
482
|
+
name: (0, import_path10.parse)(file).name === "index" ? leadingPageName : file,
|
|
483
|
+
href: (0, import_path10.join)(...cursor, file)
|
|
516
484
|
});
|
|
517
485
|
const recurse = (key) => createTocRec(graph[key], [...cursor, key]);
|
|
518
486
|
const current = {
|
|
@@ -563,7 +531,7 @@ __export(unarchive_exports, {
|
|
|
563
531
|
name: () => name3
|
|
564
532
|
});
|
|
565
533
|
var import_fs = require("fs");
|
|
566
|
-
var
|
|
534
|
+
var import_path11 = require("path");
|
|
567
535
|
var import_tar_stream = require("tar-stream");
|
|
568
536
|
var name3 = "unarchive";
|
|
569
537
|
var UnarchiveIncluderError = class extends Error {
|
|
@@ -586,8 +554,8 @@ function pipeline(readPath, writeBasePath) {
|
|
|
586
554
|
(0, import_fs.mkdirSync)(writeBasePath, { recursive: true });
|
|
587
555
|
extractor.on("entry", (header, stream, next) => {
|
|
588
556
|
const { type, name: name4 } = header;
|
|
589
|
-
const writePath = (0,
|
|
590
|
-
const writeDirPath = type === "directory" ? writePath : (0,
|
|
557
|
+
const writePath = (0, import_path11.join)(writeBasePath, name4);
|
|
558
|
+
const writeDirPath = type === "directory" ? writePath : (0, import_path11.dirname)(writePath);
|
|
591
559
|
(0, import_fs.mkdirSync)(writeDirPath, { recursive: true });
|
|
592
560
|
if (type !== "directory") {
|
|
593
561
|
const writer = (0, import_fs.createWriteStream)(writePath, { flags: "w" });
|
|
@@ -618,8 +586,8 @@ function includerFunction3(params) {
|
|
|
618
586
|
if (!(input == null ? void 0 : input.length) || !(output == null ? void 0 : output.length)) {
|
|
619
587
|
throw new UnarchiveIncluderError("provide includer with input parameter", tocPath);
|
|
620
588
|
}
|
|
621
|
-
const contentPath = index === 0 ? (0,
|
|
622
|
-
const writePath = (0,
|
|
589
|
+
const contentPath = index === 0 ? (0, import_path11.join)(writeBasePath, input) : (0, import_path11.join)(readBasePath, input);
|
|
590
|
+
const writePath = (0, import_path11.join)(writeBasePath, output);
|
|
623
591
|
try {
|
|
624
592
|
yield pipeline(contentPath, writePath);
|
|
625
593
|
} catch (err) {
|
|
@@ -676,7 +644,7 @@ function applyIncluders(path, item, vars) {
|
|
|
676
644
|
const passedParams = __spreadValues({}, rest);
|
|
677
645
|
yield applyIncluder({ path, item, includer, passedParams, index, vars });
|
|
678
646
|
}
|
|
679
|
-
item.include.path = (0,
|
|
647
|
+
item.include.path = (0, import_path12.join)(item.include.path, "toc.yaml");
|
|
680
648
|
index++;
|
|
681
649
|
});
|
|
682
650
|
}
|
|
@@ -694,7 +662,7 @@ function includersValid(includers) {
|
|
|
694
662
|
return { status: true };
|
|
695
663
|
}
|
|
696
664
|
function includerValid(includer) {
|
|
697
|
-
if ((0,
|
|
665
|
+
if ((0, import_lodash2.isObject)(includer)) {
|
|
698
666
|
if (typeof includer.name !== "string") {
|
|
699
667
|
return {
|
|
700
668
|
status: false,
|
|
@@ -748,8 +716,8 @@ function add(path) {
|
|
|
748
716
|
ignoreStage,
|
|
749
717
|
vars
|
|
750
718
|
} = argv_default.getConfig();
|
|
751
|
-
const pathToDir = (0,
|
|
752
|
-
const content = (0, import_fs2.readFileSync)((0,
|
|
719
|
+
const pathToDir = (0, import_path13.dirname)(path);
|
|
720
|
+
const content = (0, import_fs2.readFileSync)((0, import_path13.resolve)(inputFolderPath, path), "utf8");
|
|
753
721
|
const parsedToc = (0, import_js_yaml3.load)(content);
|
|
754
722
|
if (parsedToc.stage === ignoreStage) {
|
|
755
723
|
return;
|
|
@@ -766,16 +734,16 @@ function add(path) {
|
|
|
766
734
|
parsedToc.items = yield processTocItems(
|
|
767
735
|
path,
|
|
768
736
|
parsedToc.items,
|
|
769
|
-
(0,
|
|
770
|
-
(0,
|
|
737
|
+
(0, import_path13.join)(inputFolderPath, pathToDir),
|
|
738
|
+
(0, import_path13.resolve)(inputFolderPath),
|
|
771
739
|
combinedVars
|
|
772
740
|
);
|
|
773
741
|
storage.set(path, parsedToc);
|
|
774
742
|
parsedToc.base = pathToDir;
|
|
775
743
|
if (outputFormat === "md") {
|
|
776
|
-
const outputPath = (0,
|
|
744
|
+
const outputPath = (0, import_path13.resolve)(outputFolderPath, path);
|
|
777
745
|
const outputToc = (0, import_js_yaml3.dump)(parsedToc);
|
|
778
|
-
import_shelljs2.default.mkdir("-p", (0,
|
|
746
|
+
import_shelljs2.default.mkdir("-p", (0, import_path13.dirname)(outputPath));
|
|
779
747
|
(0, import_fs2.writeFileSync)(outputPath, outputToc);
|
|
780
748
|
}
|
|
781
749
|
prepareNavigationPaths(parsedToc, pathToDir);
|
|
@@ -818,7 +786,7 @@ function prepareNavigationPaths(parsedToc, dirPath) {
|
|
|
818
786
|
processItems(preparedSubItems, pathToDir);
|
|
819
787
|
}
|
|
820
788
|
if (item.href && !isExternalHref(item.href)) {
|
|
821
|
-
const href = (0,
|
|
789
|
+
const href = (0, import_path13.join)(pathToDir, item.href);
|
|
822
790
|
storage.set(href, parsedToc);
|
|
823
791
|
const navigationPath = _normalizeHref(href);
|
|
824
792
|
navigationPaths.push(navigationPath);
|
|
@@ -828,32 +796,32 @@ function prepareNavigationPaths(parsedToc, dirPath) {
|
|
|
828
796
|
processItems([parsedToc], dirPath);
|
|
829
797
|
}
|
|
830
798
|
function _normalizeHref(href) {
|
|
831
|
-
const preparedHref = (0,
|
|
799
|
+
const preparedHref = (0, import_path13.normalize)(href);
|
|
832
800
|
if (preparedHref.endsWith(".md") || preparedHref.endsWith(".yaml")) {
|
|
833
801
|
return preparedHref;
|
|
834
802
|
}
|
|
835
|
-
if (preparedHref.endsWith(
|
|
803
|
+
if (preparedHref.endsWith(import_path13.sep)) {
|
|
836
804
|
return `${preparedHref}index.yaml`;
|
|
837
805
|
}
|
|
838
806
|
return `${preparedHref}.md`;
|
|
839
807
|
}
|
|
840
808
|
function _copyTocDir(tocPath, destDir) {
|
|
841
809
|
const { input: inputFolderPath } = argv_default.getConfig();
|
|
842
|
-
const { dir: tocDir } = (0,
|
|
810
|
+
const { dir: tocDir } = (0, import_path13.parse)(tocPath);
|
|
843
811
|
const files = (0, import_walk_sync.default)(tocDir, {
|
|
844
812
|
globs: ["**/*.*"],
|
|
845
813
|
ignore: ["**/toc.yaml"],
|
|
846
814
|
directories: false
|
|
847
815
|
});
|
|
848
816
|
files.forEach((relPath) => {
|
|
849
|
-
const from = (0,
|
|
850
|
-
const to = (0,
|
|
851
|
-
const fileExtension = (0,
|
|
817
|
+
const from = (0, import_path13.resolve)(tocDir, relPath);
|
|
818
|
+
const to = (0, import_path13.resolve)(destDir, relPath);
|
|
819
|
+
const fileExtension = (0, import_path13.extname)(relPath);
|
|
852
820
|
const isMdFile = fileExtension === ".md";
|
|
853
|
-
import_shelljs2.default.mkdir("-p", (0,
|
|
821
|
+
import_shelljs2.default.mkdir("-p", (0, import_path13.parse)(to).dir);
|
|
854
822
|
if (isMdFile) {
|
|
855
823
|
const fileContent = (0, import_fs2.readFileSync)(from, "utf8");
|
|
856
|
-
const sourcePath = (0,
|
|
824
|
+
const sourcePath = (0, import_path13.relative)(inputFolderPath, from);
|
|
857
825
|
const updatedFileContent = getContentWithUpdatedStaticMetadata({
|
|
858
826
|
fileContent,
|
|
859
827
|
sourcePath,
|
|
@@ -868,14 +836,14 @@ function _copyTocDir(tocPath, destDir) {
|
|
|
868
836
|
function _replaceIncludesHrefs(items, includeTocDir, tocDir) {
|
|
869
837
|
return items.reduce((acc, tocItem) => {
|
|
870
838
|
if (tocItem.href) {
|
|
871
|
-
tocItem.href = (0,
|
|
839
|
+
tocItem.href = (0, import_path13.relative)(tocDir, (0, import_path13.resolve)(includeTocDir, tocItem.href));
|
|
872
840
|
}
|
|
873
841
|
if (tocItem.items) {
|
|
874
842
|
tocItem.items = _replaceIncludesHrefs(tocItem.items, includeTocDir, tocDir);
|
|
875
843
|
}
|
|
876
844
|
if (tocItem.include) {
|
|
877
845
|
const { path } = tocItem.include;
|
|
878
|
-
tocItem.include.path = (0,
|
|
846
|
+
tocItem.include.path = (0, import_path13.relative)(tocDir, (0, import_path13.resolve)(includeTocDir, path));
|
|
879
847
|
}
|
|
880
848
|
return acc.concat(tocItem);
|
|
881
849
|
}, []);
|
|
@@ -899,7 +867,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
899
867
|
for (const item of items) {
|
|
900
868
|
let includedInlineItems = null;
|
|
901
869
|
if (item.name) {
|
|
902
|
-
const tocPath = (0,
|
|
870
|
+
const tocPath = (0, import_path13.join)(tocDir, "toc.yaml");
|
|
903
871
|
item.name = _liquidSubstitutions(item.name, vars, tocPath);
|
|
904
872
|
}
|
|
905
873
|
try {
|
|
@@ -913,8 +881,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
913
881
|
}
|
|
914
882
|
if (item.include) {
|
|
915
883
|
const { mode = "root_merge" /* ROOT_MERGE */ } = item.include;
|
|
916
|
-
const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0,
|
|
917
|
-
const includeTocDir = (0,
|
|
884
|
+
const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0, import_path13.resolve)(sourcesDir, item.include.path) : (0, import_path13.resolve)(tocDir, item.include.path);
|
|
885
|
+
const includeTocDir = (0, import_path13.dirname)(includeTocPath);
|
|
918
886
|
try {
|
|
919
887
|
const includeToc = (0, import_js_yaml3.load)((0, import_fs2.readFileSync)(includeTocPath, "utf8"));
|
|
920
888
|
if (includeToc.stage === "tech-preview" /* TECH_PREVIEW */) {
|
|
@@ -947,7 +915,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
947
915
|
}
|
|
948
916
|
} catch (err) {
|
|
949
917
|
const message = `Error while including toc: ${(0, import_chalk2.bold)(includeTocPath)} to ${(0, import_chalk2.bold)(
|
|
950
|
-
(0,
|
|
918
|
+
(0, import_path13.join)(tocDir, "toc.yaml")
|
|
951
919
|
)}`;
|
|
952
920
|
import_log2.default.error(message);
|
|
953
921
|
continue;
|
|
@@ -968,8 +936,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
968
936
|
}
|
|
969
937
|
function getTocDir(pagePath) {
|
|
970
938
|
const { input: inputFolderPath } = argv_default.getConfig();
|
|
971
|
-
const tocDir = (0,
|
|
972
|
-
const tocPath = (0,
|
|
939
|
+
const tocDir = (0, import_path13.dirname)(pagePath);
|
|
940
|
+
const tocPath = (0, import_path13.resolve)(tocDir, "toc.yaml");
|
|
973
941
|
if (!tocDir.includes(inputFolderPath)) {
|
|
974
942
|
throw new Error("Error while finding toc dir");
|
|
975
943
|
}
|
|
@@ -991,19 +959,19 @@ var tocs_default = {
|
|
|
991
959
|
};
|
|
992
960
|
|
|
993
961
|
// src/services/preset.ts
|
|
994
|
-
var
|
|
962
|
+
var import_path14 = require("path");
|
|
995
963
|
var presetStorage = /* @__PURE__ */ new Map();
|
|
996
964
|
function add2(parsedPreset, path, varsPreset) {
|
|
997
965
|
const combinedValues = __spreadValues(__spreadValues({}, parsedPreset.default || {}), parsedPreset[varsPreset] || {});
|
|
998
|
-
const key = (0,
|
|
966
|
+
const key = (0, import_path14.dirname)((0, import_path14.normalize)(path));
|
|
999
967
|
presetStorage.set(key, combinedValues);
|
|
1000
968
|
}
|
|
1001
969
|
function get(path) {
|
|
1002
970
|
let combinedValues = {};
|
|
1003
|
-
let localPath = (0,
|
|
971
|
+
let localPath = (0, import_path14.normalize)(path);
|
|
1004
972
|
while (localPath !== ".") {
|
|
1005
973
|
const presetValues = presetStorage.get(localPath) || {};
|
|
1006
|
-
localPath = (0,
|
|
974
|
+
localPath = (0, import_path14.dirname)(localPath);
|
|
1007
975
|
combinedValues = __spreadValues(__spreadValues({}, presetValues), combinedValues);
|
|
1008
976
|
}
|
|
1009
977
|
combinedValues = __spreadValues(__spreadValues({}, presetStorage.get(".")), combinedValues);
|
|
@@ -1023,7 +991,7 @@ var preset_default = {
|
|
|
1023
991
|
};
|
|
1024
992
|
|
|
1025
993
|
// src/services/argv.ts
|
|
1026
|
-
var
|
|
994
|
+
var import_path15 = require("path");
|
|
1027
995
|
var import_fs3 = require("fs");
|
|
1028
996
|
var _argv;
|
|
1029
997
|
function getConfig() {
|
|
@@ -1037,7 +1005,7 @@ function init2(argv) {
|
|
|
1037
1005
|
_argv.vars = JSON.parse(argv.vars);
|
|
1038
1006
|
}
|
|
1039
1007
|
try {
|
|
1040
|
-
const ignorefile = (0, import_fs3.readFileSync)((0,
|
|
1008
|
+
const ignorefile = (0, import_fs3.readFileSync)((0, import_path15.join)(_argv.rootInput, ".yfmignore"), "utf8");
|
|
1041
1009
|
const ignore = ignorefile.split("\n");
|
|
1042
1010
|
_argv.ignore = _argv.ignore.concat(ignore);
|
|
1043
1011
|
} catch (e) {
|
|
@@ -1053,7 +1021,7 @@ var argv_default = {
|
|
|
1053
1021
|
};
|
|
1054
1022
|
|
|
1055
1023
|
// src/services/leading.ts
|
|
1056
|
-
var
|
|
1024
|
+
var import_path16 = require("path");
|
|
1057
1025
|
var import_fs4 = require("fs");
|
|
1058
1026
|
var import_js_yaml4 = require("js-yaml");
|
|
1059
1027
|
var import_log3 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
@@ -1129,7 +1097,7 @@ function getDefaultLintConfig() {
|
|
|
1129
1097
|
|
|
1130
1098
|
// src/resolvers/md2md.ts
|
|
1131
1099
|
var import_fs5 = require("fs");
|
|
1132
|
-
var
|
|
1100
|
+
var import_path17 = require("path");
|
|
1133
1101
|
var import_shelljs3 = __toESM(require("shelljs"));
|
|
1134
1102
|
var import_log4 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
1135
1103
|
var import_liquid3 = __toESM(require("@diplodoc/transform/lib/liquid"));
|
|
@@ -1145,7 +1113,7 @@ function liquidMd2Md(input, vars, path) {
|
|
|
1145
1113
|
}
|
|
1146
1114
|
|
|
1147
1115
|
// src/resolvers/md2html.ts
|
|
1148
|
-
var
|
|
1116
|
+
var import_path18 = require("path");
|
|
1149
1117
|
var import_fs6 = require("fs");
|
|
1150
1118
|
var import_js_yaml5 = __toESM(require("js-yaml"));
|
|
1151
1119
|
var import_transform = __toESM(require("@diplodoc/transform"));
|
|
@@ -1160,7 +1128,7 @@ function liquidMd2Html(input, vars, path) {
|
|
|
1160
1128
|
}
|
|
1161
1129
|
|
|
1162
1130
|
// src/resolvers/lintPage.ts
|
|
1163
|
-
var
|
|
1131
|
+
var import_path19 = require("path");
|
|
1164
1132
|
var import_log6 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
1165
1133
|
var import_yfmlint = __toESM(require("@diplodoc/transform/lib/yfmlint"));
|
|
1166
1134
|
var import_fs7 = require("fs");
|
|
@@ -1171,7 +1139,7 @@ var FileLinter = {
|
|
|
1171
1139
|
function lintPage(options) {
|
|
1172
1140
|
const { inputPath, fileExtension, onFinish } = options;
|
|
1173
1141
|
const { input } = argv_default.getConfig();
|
|
1174
|
-
const resolvedPath = (0,
|
|
1142
|
+
const resolvedPath = (0, import_path19.resolve)(input, inputPath);
|
|
1175
1143
|
try {
|
|
1176
1144
|
const content = (0, import_fs7.readFileSync)(resolvedPath, "utf8");
|
|
1177
1145
|
const lintFn = FileLinter[fileExtension];
|
|
@@ -1193,10 +1161,10 @@ function MdFileLinter(content, lintOptions) {
|
|
|
1193
1161
|
const { path: filePath } = lintOptions;
|
|
1194
1162
|
const plugins2 = outputFormat === "md" ? [] : plugins_exports.getPlugins();
|
|
1195
1163
|
const vars = getVarsPerFile(filePath);
|
|
1196
|
-
const root = (0,
|
|
1197
|
-
const path = (0,
|
|
1164
|
+
const root = (0, import_path19.resolve)(input);
|
|
1165
|
+
const path = (0, import_path19.resolve)(input, filePath);
|
|
1198
1166
|
let preparedContent = content;
|
|
1199
|
-
const assetsPublicPath = (0,
|
|
1167
|
+
const assetsPublicPath = (0, import_path19.relative)((0, import_path19.dirname)(path), root);
|
|
1200
1168
|
const lintMarkdown = function lintMarkdown2(opts) {
|
|
1201
1169
|
const { input: localInput, path: localPath, sourceMap: sourceMap2 } = opts;
|
|
1202
1170
|
const pluginOptions = __spreadProps(__spreadValues({}, options), {
|
|
@@ -1249,7 +1217,7 @@ function run(_0) {
|
|
|
1249
1217
|
tocs_default.getNavigationPaths().forEach((pathToFile) => {
|
|
1250
1218
|
lintPage({
|
|
1251
1219
|
inputPath: pathToFile,
|
|
1252
|
-
fileExtension: (0,
|
|
1220
|
+
fileExtension: (0, import_path20.extname)(pathToFile),
|
|
1253
1221
|
onFinish: () => {
|
|
1254
1222
|
processedPages.next(pathToFile);
|
|
1255
1223
|
}
|