@diplodoc/cli 4.7.0 → 4.9.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 +317 -233
- package/build/index.js.map +4 -4
- package/build/linter.js +88 -112
- 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/models.ts +1 -0
- package/src/resolvers/md2html.ts +4 -0
- package/src/services/contributors.ts +46 -2
- package/src/services/metadata.ts +42 -2
- package/src/services/tocs.ts +10 -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/src/vcs-connector/connector-models.ts +2 -0
- package/src/vcs-connector/github.ts +42 -1
- 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,
|
|
@@ -739,6 +707,7 @@ function applyIncluder(args) {
|
|
|
739
707
|
var storage = /* @__PURE__ */ new Map();
|
|
740
708
|
var navigationPaths = [];
|
|
741
709
|
var includedTocPaths = /* @__PURE__ */ new Set();
|
|
710
|
+
var tocFileCopyMap = /* @__PURE__ */ new Map();
|
|
742
711
|
function add(path) {
|
|
743
712
|
return __async(this, null, function* () {
|
|
744
713
|
const {
|
|
@@ -748,8 +717,8 @@ function add(path) {
|
|
|
748
717
|
ignoreStage,
|
|
749
718
|
vars
|
|
750
719
|
} = argv_default.getConfig();
|
|
751
|
-
const pathToDir = (0,
|
|
752
|
-
const content = (0, import_fs2.readFileSync)((0,
|
|
720
|
+
const pathToDir = (0, import_path13.dirname)(path);
|
|
721
|
+
const content = (0, import_fs2.readFileSync)((0, import_path13.resolve)(inputFolderPath, path), "utf8");
|
|
753
722
|
const parsedToc = (0, import_js_yaml3.load)(content);
|
|
754
723
|
if (parsedToc.stage === ignoreStage) {
|
|
755
724
|
return;
|
|
@@ -766,16 +735,16 @@ function add(path) {
|
|
|
766
735
|
parsedToc.items = yield processTocItems(
|
|
767
736
|
path,
|
|
768
737
|
parsedToc.items,
|
|
769
|
-
(0,
|
|
770
|
-
(0,
|
|
738
|
+
(0, import_path13.join)(inputFolderPath, pathToDir),
|
|
739
|
+
(0, import_path13.resolve)(inputFolderPath),
|
|
771
740
|
combinedVars
|
|
772
741
|
);
|
|
773
742
|
storage.set(path, parsedToc);
|
|
774
743
|
parsedToc.base = pathToDir;
|
|
775
744
|
if (outputFormat === "md") {
|
|
776
|
-
const outputPath = (0,
|
|
745
|
+
const outputPath = (0, import_path13.resolve)(outputFolderPath, path);
|
|
777
746
|
const outputToc = (0, import_js_yaml3.dump)(parsedToc);
|
|
778
|
-
import_shelljs2.default.mkdir("-p", (0,
|
|
747
|
+
import_shelljs2.default.mkdir("-p", (0, import_path13.dirname)(outputPath));
|
|
779
748
|
(0, import_fs2.writeFileSync)(outputPath, outputToc);
|
|
780
749
|
}
|
|
781
750
|
prepareNavigationPaths(parsedToc, pathToDir);
|
|
@@ -818,7 +787,7 @@ function prepareNavigationPaths(parsedToc, dirPath) {
|
|
|
818
787
|
processItems(preparedSubItems, pathToDir);
|
|
819
788
|
}
|
|
820
789
|
if (item.href && !isExternalHref(item.href)) {
|
|
821
|
-
const href = (0,
|
|
790
|
+
const href = (0, import_path13.join)(pathToDir, item.href);
|
|
822
791
|
storage.set(href, parsedToc);
|
|
823
792
|
const navigationPath = _normalizeHref(href);
|
|
824
793
|
navigationPaths.push(navigationPath);
|
|
@@ -828,32 +797,32 @@ function prepareNavigationPaths(parsedToc, dirPath) {
|
|
|
828
797
|
processItems([parsedToc], dirPath);
|
|
829
798
|
}
|
|
830
799
|
function _normalizeHref(href) {
|
|
831
|
-
const preparedHref = (0,
|
|
800
|
+
const preparedHref = (0, import_path13.normalize)(href);
|
|
832
801
|
if (preparedHref.endsWith(".md") || preparedHref.endsWith(".yaml")) {
|
|
833
802
|
return preparedHref;
|
|
834
803
|
}
|
|
835
|
-
if (preparedHref.endsWith(
|
|
804
|
+
if (preparedHref.endsWith(import_path13.sep)) {
|
|
836
805
|
return `${preparedHref}index.yaml`;
|
|
837
806
|
}
|
|
838
807
|
return `${preparedHref}.md`;
|
|
839
808
|
}
|
|
840
809
|
function _copyTocDir(tocPath, destDir) {
|
|
841
810
|
const { input: inputFolderPath } = argv_default.getConfig();
|
|
842
|
-
const { dir: tocDir } = (0,
|
|
811
|
+
const { dir: tocDir } = (0, import_path13.parse)(tocPath);
|
|
843
812
|
const files = (0, import_walk_sync.default)(tocDir, {
|
|
844
813
|
globs: ["**/*.*"],
|
|
845
814
|
ignore: ["**/toc.yaml"],
|
|
846
815
|
directories: false
|
|
847
816
|
});
|
|
848
817
|
files.forEach((relPath) => {
|
|
849
|
-
const from = (0,
|
|
850
|
-
const to = (0,
|
|
851
|
-
const fileExtension = (0,
|
|
818
|
+
const from = (0, import_path13.resolve)(tocDir, relPath);
|
|
819
|
+
const to = (0, import_path13.resolve)(destDir, relPath);
|
|
820
|
+
const fileExtension = (0, import_path13.extname)(relPath);
|
|
852
821
|
const isMdFile = fileExtension === ".md";
|
|
853
|
-
import_shelljs2.default.mkdir("-p", (0,
|
|
822
|
+
import_shelljs2.default.mkdir("-p", (0, import_path13.parse)(to).dir);
|
|
854
823
|
if (isMdFile) {
|
|
855
824
|
const fileContent = (0, import_fs2.readFileSync)(from, "utf8");
|
|
856
|
-
const sourcePath = (0,
|
|
825
|
+
const sourcePath = (0, import_path13.relative)(inputFolderPath, from);
|
|
857
826
|
const updatedFileContent = getContentWithUpdatedStaticMetadata({
|
|
858
827
|
fileContent,
|
|
859
828
|
sourcePath,
|
|
@@ -863,19 +832,22 @@ function _copyTocDir(tocPath, destDir) {
|
|
|
863
832
|
} else {
|
|
864
833
|
import_shelljs2.default.cp(from, to);
|
|
865
834
|
}
|
|
835
|
+
const relFrom = (0, import_path13.relative)(inputFolderPath, from);
|
|
836
|
+
const relTo = (0, import_path13.relative)(inputFolderPath, to);
|
|
837
|
+
tocFileCopyMap.set(relTo, relFrom);
|
|
866
838
|
});
|
|
867
839
|
}
|
|
868
840
|
function _replaceIncludesHrefs(items, includeTocDir, tocDir) {
|
|
869
841
|
return items.reduce((acc, tocItem) => {
|
|
870
842
|
if (tocItem.href) {
|
|
871
|
-
tocItem.href = (0,
|
|
843
|
+
tocItem.href = (0, import_path13.relative)(tocDir, (0, import_path13.resolve)(includeTocDir, tocItem.href));
|
|
872
844
|
}
|
|
873
845
|
if (tocItem.items) {
|
|
874
846
|
tocItem.items = _replaceIncludesHrefs(tocItem.items, includeTocDir, tocDir);
|
|
875
847
|
}
|
|
876
848
|
if (tocItem.include) {
|
|
877
849
|
const { path } = tocItem.include;
|
|
878
|
-
tocItem.include.path = (0,
|
|
850
|
+
tocItem.include.path = (0, import_path13.relative)(tocDir, (0, import_path13.resolve)(includeTocDir, path));
|
|
879
851
|
}
|
|
880
852
|
return acc.concat(tocItem);
|
|
881
853
|
}, []);
|
|
@@ -899,7 +871,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
899
871
|
for (const item of items) {
|
|
900
872
|
let includedInlineItems = null;
|
|
901
873
|
if (item.name) {
|
|
902
|
-
const tocPath = (0,
|
|
874
|
+
const tocPath = (0, import_path13.join)(tocDir, "toc.yaml");
|
|
903
875
|
item.name = _liquidSubstitutions(item.name, vars, tocPath);
|
|
904
876
|
}
|
|
905
877
|
try {
|
|
@@ -913,8 +885,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
913
885
|
}
|
|
914
886
|
if (item.include) {
|
|
915
887
|
const { mode = "root_merge" /* ROOT_MERGE */ } = item.include;
|
|
916
|
-
const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0,
|
|
917
|
-
const includeTocDir = (0,
|
|
888
|
+
const includeTocPath = mode === "root_merge" /* ROOT_MERGE */ ? (0, import_path13.resolve)(sourcesDir, item.include.path) : (0, import_path13.resolve)(tocDir, item.include.path);
|
|
889
|
+
const includeTocDir = (0, import_path13.dirname)(includeTocPath);
|
|
918
890
|
try {
|
|
919
891
|
const includeToc = (0, import_js_yaml3.load)((0, import_fs2.readFileSync)(includeTocPath, "utf8"));
|
|
920
892
|
if (includeToc.stage === "tech-preview" /* TECH_PREVIEW */) {
|
|
@@ -947,7 +919,7 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
947
919
|
}
|
|
948
920
|
} catch (err) {
|
|
949
921
|
const message = `Error while including toc: ${(0, import_chalk2.bold)(includeTocPath)} to ${(0, import_chalk2.bold)(
|
|
950
|
-
(0,
|
|
922
|
+
(0, import_path13.join)(tocDir, "toc.yaml")
|
|
951
923
|
)}`;
|
|
952
924
|
import_log2.default.error(message);
|
|
953
925
|
continue;
|
|
@@ -968,8 +940,8 @@ function _replaceIncludes(path, items, tocDir, sourcesDir, vars) {
|
|
|
968
940
|
}
|
|
969
941
|
function getTocDir(pagePath) {
|
|
970
942
|
const { input: inputFolderPath } = argv_default.getConfig();
|
|
971
|
-
const tocDir = (0,
|
|
972
|
-
const tocPath = (0,
|
|
943
|
+
const tocDir = (0, import_path13.dirname)(pagePath);
|
|
944
|
+
const tocPath = (0, import_path13.resolve)(tocDir, "toc.yaml");
|
|
973
945
|
if (!tocDir.includes(inputFolderPath)) {
|
|
974
946
|
throw new Error("Error while finding toc dir");
|
|
975
947
|
}
|
|
@@ -981,29 +953,33 @@ function getTocDir(pagePath) {
|
|
|
981
953
|
function setNavigationPaths(paths) {
|
|
982
954
|
navigationPaths = paths;
|
|
983
955
|
}
|
|
956
|
+
function getCopyFileMap() {
|
|
957
|
+
return tocFileCopyMap;
|
|
958
|
+
}
|
|
984
959
|
var tocs_default = {
|
|
985
960
|
add,
|
|
986
961
|
getForPath,
|
|
987
962
|
getNavigationPaths,
|
|
988
963
|
getTocDir,
|
|
989
964
|
getIncludedTocPaths,
|
|
990
|
-
setNavigationPaths
|
|
965
|
+
setNavigationPaths,
|
|
966
|
+
getCopyFileMap
|
|
991
967
|
};
|
|
992
968
|
|
|
993
969
|
// src/services/preset.ts
|
|
994
|
-
var
|
|
970
|
+
var import_path14 = require("path");
|
|
995
971
|
var presetStorage = /* @__PURE__ */ new Map();
|
|
996
972
|
function add2(parsedPreset, path, varsPreset) {
|
|
997
973
|
const combinedValues = __spreadValues(__spreadValues({}, parsedPreset.default || {}), parsedPreset[varsPreset] || {});
|
|
998
|
-
const key = (0,
|
|
974
|
+
const key = (0, import_path14.dirname)((0, import_path14.normalize)(path));
|
|
999
975
|
presetStorage.set(key, combinedValues);
|
|
1000
976
|
}
|
|
1001
977
|
function get(path) {
|
|
1002
978
|
let combinedValues = {};
|
|
1003
|
-
let localPath = (0,
|
|
979
|
+
let localPath = (0, import_path14.normalize)(path);
|
|
1004
980
|
while (localPath !== ".") {
|
|
1005
981
|
const presetValues = presetStorage.get(localPath) || {};
|
|
1006
|
-
localPath = (0,
|
|
982
|
+
localPath = (0, import_path14.dirname)(localPath);
|
|
1007
983
|
combinedValues = __spreadValues(__spreadValues({}, presetValues), combinedValues);
|
|
1008
984
|
}
|
|
1009
985
|
combinedValues = __spreadValues(__spreadValues({}, presetStorage.get(".")), combinedValues);
|
|
@@ -1023,7 +999,7 @@ var preset_default = {
|
|
|
1023
999
|
};
|
|
1024
1000
|
|
|
1025
1001
|
// src/services/argv.ts
|
|
1026
|
-
var
|
|
1002
|
+
var import_path15 = require("path");
|
|
1027
1003
|
var import_fs3 = require("fs");
|
|
1028
1004
|
var _argv;
|
|
1029
1005
|
function getConfig() {
|
|
@@ -1037,7 +1013,7 @@ function init2(argv) {
|
|
|
1037
1013
|
_argv.vars = JSON.parse(argv.vars);
|
|
1038
1014
|
}
|
|
1039
1015
|
try {
|
|
1040
|
-
const ignorefile = (0, import_fs3.readFileSync)((0,
|
|
1016
|
+
const ignorefile = (0, import_fs3.readFileSync)((0, import_path15.join)(_argv.rootInput, ".yfmignore"), "utf8");
|
|
1041
1017
|
const ignore = ignorefile.split("\n");
|
|
1042
1018
|
_argv.ignore = _argv.ignore.concat(ignore);
|
|
1043
1019
|
} catch (e) {
|
|
@@ -1053,7 +1029,7 @@ var argv_default = {
|
|
|
1053
1029
|
};
|
|
1054
1030
|
|
|
1055
1031
|
// src/services/leading.ts
|
|
1056
|
-
var
|
|
1032
|
+
var import_path16 = require("path");
|
|
1057
1033
|
var import_fs4 = require("fs");
|
|
1058
1034
|
var import_js_yaml4 = require("js-yaml");
|
|
1059
1035
|
var import_log3 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
@@ -1129,7 +1105,7 @@ function getDefaultLintConfig() {
|
|
|
1129
1105
|
|
|
1130
1106
|
// src/resolvers/md2md.ts
|
|
1131
1107
|
var import_fs5 = require("fs");
|
|
1132
|
-
var
|
|
1108
|
+
var import_path17 = require("path");
|
|
1133
1109
|
var import_shelljs3 = __toESM(require("shelljs"));
|
|
1134
1110
|
var import_log4 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
1135
1111
|
var import_liquid3 = __toESM(require("@diplodoc/transform/lib/liquid"));
|
|
@@ -1145,7 +1121,7 @@ function liquidMd2Md(input, vars, path) {
|
|
|
1145
1121
|
}
|
|
1146
1122
|
|
|
1147
1123
|
// src/resolvers/md2html.ts
|
|
1148
|
-
var
|
|
1124
|
+
var import_path18 = require("path");
|
|
1149
1125
|
var import_fs6 = require("fs");
|
|
1150
1126
|
var import_js_yaml5 = __toESM(require("js-yaml"));
|
|
1151
1127
|
var import_transform = __toESM(require("@diplodoc/transform"));
|
|
@@ -1160,7 +1136,7 @@ function liquidMd2Html(input, vars, path) {
|
|
|
1160
1136
|
}
|
|
1161
1137
|
|
|
1162
1138
|
// src/resolvers/lintPage.ts
|
|
1163
|
-
var
|
|
1139
|
+
var import_path19 = require("path");
|
|
1164
1140
|
var import_log6 = __toESM(require("@diplodoc/transform/lib/log"));
|
|
1165
1141
|
var import_yfmlint = __toESM(require("@diplodoc/transform/lib/yfmlint"));
|
|
1166
1142
|
var import_fs7 = require("fs");
|
|
@@ -1171,7 +1147,7 @@ var FileLinter = {
|
|
|
1171
1147
|
function lintPage(options) {
|
|
1172
1148
|
const { inputPath, fileExtension, onFinish } = options;
|
|
1173
1149
|
const { input } = argv_default.getConfig();
|
|
1174
|
-
const resolvedPath = (0,
|
|
1150
|
+
const resolvedPath = (0, import_path19.resolve)(input, inputPath);
|
|
1175
1151
|
try {
|
|
1176
1152
|
const content = (0, import_fs7.readFileSync)(resolvedPath, "utf8");
|
|
1177
1153
|
const lintFn = FileLinter[fileExtension];
|
|
@@ -1193,10 +1169,10 @@ function MdFileLinter(content, lintOptions) {
|
|
|
1193
1169
|
const { path: filePath } = lintOptions;
|
|
1194
1170
|
const plugins2 = outputFormat === "md" ? [] : plugins_exports.getPlugins();
|
|
1195
1171
|
const vars = getVarsPerFile(filePath);
|
|
1196
|
-
const root = (0,
|
|
1197
|
-
const path = (0,
|
|
1172
|
+
const root = (0, import_path19.resolve)(input);
|
|
1173
|
+
const path = (0, import_path19.resolve)(input, filePath);
|
|
1198
1174
|
let preparedContent = content;
|
|
1199
|
-
const assetsPublicPath = (0,
|
|
1175
|
+
const assetsPublicPath = (0, import_path19.relative)((0, import_path19.dirname)(path), root);
|
|
1200
1176
|
const lintMarkdown = function lintMarkdown2(opts) {
|
|
1201
1177
|
const { input: localInput, path: localPath, sourceMap: sourceMap2 } = opts;
|
|
1202
1178
|
const pluginOptions = __spreadProps(__spreadValues({}, options), {
|
|
@@ -1249,7 +1225,7 @@ function run(_0) {
|
|
|
1249
1225
|
tocs_default.getNavigationPaths().forEach((pathToFile) => {
|
|
1250
1226
|
lintPage({
|
|
1251
1227
|
inputPath: pathToFile,
|
|
1252
|
-
fileExtension: (0,
|
|
1228
|
+
fileExtension: (0, import_path20.extname)(pathToFile),
|
|
1253
1229
|
onFinish: () => {
|
|
1254
1230
|
processedPages.next(pathToFile);
|
|
1255
1231
|
}
|