@diplodoc/cli-tests 5.24.0 → 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/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/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
|
+
`;
|
|
@@ -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),
|
|
@@ -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
|
+
|