@diplodoc/cli-tests 5.23.1 → 5.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/e2e/__snapshots__/include-with-meta.test.ts.snap +67 -0
- package/e2e/__snapshots__/regression.test.ts.snap +1 -1
- package/e2e/errors.spec.ts +9 -0
- package/e2e/include-with-meta.test.ts +20 -0
- package/fixtures/cliAdapter.ts +18 -26
- package/fixtures/runners/binary.ts +6 -2
- package/fixtures/runners/types.ts +1 -1
- package/fixtures/utils/test.ts +4 -0
- package/mocks/errors/invalid-frontmatter/input/index.md +9 -0
- package/mocks/errors/invalid-frontmatter/input/toc.yaml +1 -0
- package/mocks/include-with-meta/input/included.md +16 -0
- package/mocks/include-with-meta/input/index.md +15 -0
- package/mocks/include-with-meta/input/toc.yaml +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Include with Meta > Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes > filelist 1`] = `
|
|
4
|
+
"[
|
|
5
|
+
"included.md",
|
|
6
|
+
"index.md",
|
|
7
|
+
"toc.yaml"
|
|
8
|
+
]"
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports[`Include with Meta > Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes 1`] = `
|
|
12
|
+
"---
|
|
13
|
+
metadata:
|
|
14
|
+
- name: generator
|
|
15
|
+
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
16
|
+
title: Included Page Title
|
|
17
|
+
description: This is the description for the included page
|
|
18
|
+
vcsPath: included.md
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Included Page
|
|
22
|
+
|
|
23
|
+
This is the content of the included page.
|
|
24
|
+
|
|
25
|
+
## Section 1
|
|
26
|
+
|
|
27
|
+
Some content in section 1.
|
|
28
|
+
|
|
29
|
+
## Section 2
|
|
30
|
+
|
|
31
|
+
Some content in section 2.
|
|
32
|
+
"
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports[`Include with Meta > Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes 2`] = `
|
|
36
|
+
"---
|
|
37
|
+
metadata:
|
|
38
|
+
- name: generator
|
|
39
|
+
content: Diplodoc Platform vDIPLODOC-VERSION
|
|
40
|
+
title: Main Page Title
|
|
41
|
+
description: This is the description for the main page
|
|
42
|
+
vcsPath: index.md
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
# Main Page
|
|
46
|
+
|
|
47
|
+
This is the main page content.
|
|
48
|
+
|
|
49
|
+
## Including another page
|
|
50
|
+
|
|
51
|
+
Here we include the content from the included page:
|
|
52
|
+
|
|
53
|
+
[Included Page](./included.md)
|
|
54
|
+
|
|
55
|
+
"
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
exports[`Include with Meta > Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes 3`] = `
|
|
59
|
+
"items:
|
|
60
|
+
- name: Main Page
|
|
61
|
+
href: index.md
|
|
62
|
+
items:
|
|
63
|
+
- name: Included Page
|
|
64
|
+
href: included.md
|
|
65
|
+
path: toc.yaml
|
|
66
|
+
"
|
|
67
|
+
`;
|
|
@@ -1176,7 +1176,7 @@ exports[`Regression > internal 45`] = `
|
|
|
1176
1176
|
<body class="g-root g-root_theme_light">
|
|
1177
1177
|
<div id="root"></div>
|
|
1178
1178
|
<script type="application/json" id="diplodoc-state">
|
|
1179
|
-
{"data":{"leading":false,"html":"<p>Text</p>/n<p>Bob</p>/n<p>Test</p>/n<h3 id=\\"f1\\"><a href=\\"includes.html#f1\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"><span class=\\"visually-hidden\\" data-no-index=\\"true\\">F1</span></a>F1</h3>/n<p>Content F1</p>/n<p id=\\"p1\\">Some paragraph with anchor</p>/n/n<p>Bob</p>/n<p><a href=\\"latex.html\\"><img src=\\"_assets/3.png\\" alt=\\"img 3\\" /></a></p>/n<p><sup><i class=\\"yfm yfm-term_title\\" term-key=\\":term\\" role=\\"button\\" aria-describedby=\\":term_element\\" tabindex=\\"0\\" id=\\"
|
|
1179
|
+
{"data":{"leading":false,"html":"<p>Text</p>/n<p>Bob</p>/n<p>Test</p>/n<h3 id=\\"f1\\"><a href=\\"includes.html#f1\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"><span class=\\"visually-hidden\\" data-no-index=\\"true\\">F1</span></a>F1</h3>/n<p>Content F1</p>/n<p id=\\"p1\\">Some paragraph with anchor</p>/n/n<p>Bob</p>/n<p><a href=\\"latex.html\\"><img src=\\"_assets/3.png\\" alt=\\"img 3\\" /></a></p>/n<p><sup><i class=\\"yfm yfm-term_title\\" term-key=\\":term\\" role=\\"button\\" aria-describedby=\\":term_element\\" tabindex=\\"0\\" id=\\"vTERM-ID\\">?</i></sup></p>/n<p>[<i class=\\"yfm yfm-term_title\\" term-key=\\":term\\" role=\\"button\\" aria-describedby=\\":term_element\\" tabindex=\\"0\\" id=\\"vTERM-ID\\">?</i>](http://ya.ru)</p>/n<p>Link after include<br />/n<a href=\\"1.html#subtitle\\">Subtitle</a></p>/n<p>Link after include</p>/n<dfn class=\\"yfm yfm-term_dfn\\" id=\\":term_element\\" role=\\"dialog\\"><p>Test terms</p>/n</dfn>","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"includes.md"},"headings":[],"title":""},"router":{"pathname":"includes","depth":1,"base":"./"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
|
|
1180
1180
|
</script>
|
|
1181
1181
|
<script type="application/javascript">
|
|
1182
1182
|
const data = document.querySelector('script#diplodoc-state');
|
package/e2e/errors.spec.ts
CHANGED
|
@@ -61,6 +61,15 @@ describe('Errors', () => {
|
|
|
61
61
|
['--max-asset-size', '2K'],
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
+
test('mocks/errors/invalid-frontmatter', ({md, html}: TestResult) => {
|
|
65
|
+
expectErrors(md, [
|
|
66
|
+
'ERR index.md: 2: YFM017 / invalid front matter format [Reason: "duplicated mapping key"; Line: 2; Key: "title"]',
|
|
67
|
+
]);
|
|
68
|
+
expectErrors(html, [
|
|
69
|
+
'ERR index.md: 2: YFM017 / invalid front matter format [Reason: "duplicated mapping key"; Line: 2; Key: "title"]',
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
|
|
64
73
|
it('translate extract with filtered links', async () => {
|
|
65
74
|
const {inputPath, outputPath} = getTestPaths('mocks/errors/extract-filtered-link');
|
|
66
75
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {describe, test} from 'vitest';
|
|
2
|
+
|
|
3
|
+
import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
|
|
4
|
+
|
|
5
|
+
describe('Include with Meta', () => {
|
|
6
|
+
test('Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes', async () => {
|
|
7
|
+
const {inputPath, outputPath} = getTestPaths('mocks/include-with-meta');
|
|
8
|
+
|
|
9
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
10
|
+
md2md: true,
|
|
11
|
+
md2html: false,
|
|
12
|
+
args: '-j 2',
|
|
13
|
+
env: {
|
|
14
|
+
PAGE_PROCESS_CONCURRENCY: '1',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
await compareDirectories(outputPath);
|
|
19
|
+
});
|
|
20
|
+
});
|
package/fixtures/cliAdapter.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface BuildRunArgs {
|
|
|
7
7
|
md2md?: boolean;
|
|
8
8
|
md2html?: boolean;
|
|
9
9
|
args?: string;
|
|
10
|
+
env?: Record<string, string>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export interface TranslateRunArgs {
|
|
@@ -23,16 +24,11 @@ class Build {
|
|
|
23
24
|
this.runner = runner;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
run(input: string, output: string, args: string[]) {
|
|
27
|
-
return this.runner.runYfmDocs(
|
|
28
|
-
'--input',
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
output,
|
|
32
|
-
'--quiet',
|
|
33
|
-
'--allowHTML',
|
|
34
|
-
...args,
|
|
35
|
-
]);
|
|
27
|
+
run(input: string, output: string, args: string[], env?: Record<string, string>) {
|
|
28
|
+
return this.runner.runYfmDocs(
|
|
29
|
+
['--input', input, '--output', output, '--quiet', '--allowHTML', ...args],
|
|
30
|
+
env,
|
|
31
|
+
);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
|
|
@@ -43,17 +39,11 @@ class Extract {
|
|
|
43
39
|
this.runner = runner;
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
run(input: string, output: string, args: string[]) {
|
|
47
|
-
return this.runner.runYfmDocs(
|
|
48
|
-
'translate',
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
input,
|
|
52
|
-
'--output',
|
|
53
|
-
output,
|
|
54
|
-
'--quiet',
|
|
55
|
-
...args,
|
|
56
|
-
]);
|
|
42
|
+
run(input: string, output: string, args: string[], env?: Record<string, string>) {
|
|
43
|
+
return this.runner.runYfmDocs(
|
|
44
|
+
['translate', 'extract', '--input', input, '--output', output, '--quiet', ...args],
|
|
45
|
+
env,
|
|
46
|
+
);
|
|
57
47
|
}
|
|
58
48
|
}
|
|
59
49
|
|
|
@@ -67,7 +57,7 @@ export class CliTestAdapter {
|
|
|
67
57
|
async testBuildPass(
|
|
68
58
|
inputPath: string,
|
|
69
59
|
outputPath: string,
|
|
70
|
-
{md2md = true, md2html = true, args = ''}: BuildRunArgs = {},
|
|
60
|
+
{md2md = true, md2html = true, args = '', env}: BuildRunArgs = {},
|
|
71
61
|
): Promise<void> {
|
|
72
62
|
await cleanupDirectory(outputPath);
|
|
73
63
|
await cleanupDirectory(`${outputPath}-md`);
|
|
@@ -78,14 +68,16 @@ export class CliTestAdapter {
|
|
|
78
68
|
const tasks = [];
|
|
79
69
|
|
|
80
70
|
if (md2md && md2html) {
|
|
81
|
-
tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md']));
|
|
71
|
+
tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md'], env));
|
|
82
72
|
tasks.push(() =>
|
|
83
|
-
this.build.run(inputPath, `${outputPath}-html`, [...baseArgs, '-f', 'html']),
|
|
73
|
+
this.build.run(inputPath, `${outputPath}-html`, [...baseArgs, '-f', 'html'], env),
|
|
84
74
|
);
|
|
85
75
|
} else if (md2md) {
|
|
86
|
-
tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md']));
|
|
76
|
+
tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md'], env));
|
|
87
77
|
} else {
|
|
88
|
-
tasks.push(() =>
|
|
78
|
+
tasks.push(() =>
|
|
79
|
+
this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'html'], env),
|
|
80
|
+
);
|
|
89
81
|
}
|
|
90
82
|
|
|
91
83
|
for (const task of tasks) {
|
|
@@ -10,8 +10,12 @@ export class BinaryRunner implements Runner {
|
|
|
10
10
|
this.binaryPath = binaryPath;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
async runYfmDocs(argv: string[]) {
|
|
14
|
-
const {stderr, exitCode} = await execa(this.binaryPath, argv, {
|
|
13
|
+
async runYfmDocs(argv: string[], env?: Record<string, string>) {
|
|
14
|
+
const {stderr, exitCode} = await execa(this.binaryPath, argv, {
|
|
15
|
+
all: true,
|
|
16
|
+
reject: false,
|
|
17
|
+
env: {...process.env, ...env},
|
|
18
|
+
});
|
|
15
19
|
const report = {
|
|
16
20
|
code: exitCode || 0,
|
|
17
21
|
warns: fillLog(/^WARN/, stderr),
|
package/fixtures/utils/test.ts
CHANGED
|
@@ -16,6 +16,10 @@ export function platformless(text: string): string {
|
|
|
16
16
|
/(content"?[:=]{1}[" ]{1}Diplodoc.*? )v\d+\.\d+\.\d+(?:-[\w-]+)?/g,
|
|
17
17
|
`$1vDIPLODOC-VERSION`,
|
|
18
18
|
)
|
|
19
|
+
.replace(
|
|
20
|
+
/(aria-describedby=\\":term_element\\" tabindex=\\"\d\\" id=\\")[a-zA-Z0-9]{1,10}/g,
|
|
21
|
+
`$1vTERM-ID`,
|
|
22
|
+
)
|
|
19
23
|
.replace(/(\\(?![/"'])){1,2}/g, '/')
|
|
20
24
|
.replace(
|
|
21
25
|
/id=\\"inline-code-id-[a-zA-Z0-9]{8}\\"/g,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
href: index.md
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Included Page Title
|
|
3
|
+
description: This is the description for the included page
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Included Page
|
|
7
|
+
|
|
8
|
+
This is the content of the included page.
|
|
9
|
+
|
|
10
|
+
## Section 1
|
|
11
|
+
|
|
12
|
+
Some content in section 1.
|
|
13
|
+
|
|
14
|
+
## Section 2
|
|
15
|
+
|
|
16
|
+
Some content in section 2.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Main Page Title
|
|
3
|
+
description: This is the description for the main page
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Main Page
|
|
7
|
+
|
|
8
|
+
This is the main page content.
|
|
9
|
+
|
|
10
|
+
## Including another page
|
|
11
|
+
|
|
12
|
+
Here we include the content from the included page:
|
|
13
|
+
|
|
14
|
+
[{#T}](./included.md)
|
|
15
|
+
|