@diplodoc/cli-tests 5.32.1 → 5.33.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/e2e/__snapshots__/init.test.ts.snap +283 -0
- package/e2e/init.test.ts +105 -0
- package/package.json +1 -1
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`yfm init — multi-lang > --default-lang sets lang field in .yfm > filelist 1`] = `
|
|
4
|
+
"[
|
|
5
|
+
".yfm",
|
|
6
|
+
"en/index.md",
|
|
7
|
+
"en/toc.yaml",
|
|
8
|
+
"ru/index.md",
|
|
9
|
+
"ru/toc.yaml"
|
|
10
|
+
]"
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`yfm init — multi-lang > --default-lang sets lang field in .yfm 1`] = `
|
|
14
|
+
"allowHtml: true
|
|
15
|
+
lang: en
|
|
16
|
+
langs: ['ru', 'en']"
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
exports[`yfm init — multi-lang > --default-lang sets lang field in .yfm 2`] = `
|
|
20
|
+
"# Welcome
|
|
21
|
+
|
|
22
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
23
|
+
|
|
24
|
+
## Getting started
|
|
25
|
+
|
|
26
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
27
|
+
"
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
exports[`yfm init — multi-lang > --default-lang sets lang field in .yfm 3`] = `
|
|
31
|
+
"title: My Docs
|
|
32
|
+
href: index.md
|
|
33
|
+
navigation:
|
|
34
|
+
header:
|
|
35
|
+
rightItems:
|
|
36
|
+
- type: controls
|
|
37
|
+
items:
|
|
38
|
+
- name: Overview
|
|
39
|
+
href: index.md
|
|
40
|
+
"
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
exports[`yfm init — multi-lang > --default-lang sets lang field in .yfm 4`] = `
|
|
44
|
+
"# Welcome
|
|
45
|
+
|
|
46
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
47
|
+
|
|
48
|
+
## Getting started
|
|
49
|
+
|
|
50
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
51
|
+
"
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
exports[`yfm init — multi-lang > --default-lang sets lang field in .yfm 5`] = `
|
|
55
|
+
"title: My Docs
|
|
56
|
+
href: index.md
|
|
57
|
+
navigation:
|
|
58
|
+
header:
|
|
59
|
+
rightItems:
|
|
60
|
+
- type: controls
|
|
61
|
+
items:
|
|
62
|
+
- name: Overview
|
|
63
|
+
href: index.md
|
|
64
|
+
"
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
exports[`yfm init — multi-lang > --no-header removes navigation from all toc.yaml files > filelist 1`] = `
|
|
68
|
+
"[
|
|
69
|
+
".yfm",
|
|
70
|
+
"en/index.md",
|
|
71
|
+
"en/toc.yaml",
|
|
72
|
+
"ru/index.md",
|
|
73
|
+
"ru/toc.yaml"
|
|
74
|
+
]"
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
exports[`yfm init — multi-lang > --no-header removes navigation from all toc.yaml files 1`] = `
|
|
78
|
+
"allowHtml: true
|
|
79
|
+
lang: ru
|
|
80
|
+
langs: ['ru', 'en']"
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
exports[`yfm init — multi-lang > --no-header removes navigation from all toc.yaml files 2`] = `
|
|
84
|
+
"# Welcome
|
|
85
|
+
|
|
86
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
87
|
+
|
|
88
|
+
## Getting started
|
|
89
|
+
|
|
90
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
91
|
+
"
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
exports[`yfm init — multi-lang > --no-header removes navigation from all toc.yaml files 3`] = `
|
|
95
|
+
"title: My Docs
|
|
96
|
+
href: index.md
|
|
97
|
+
items:
|
|
98
|
+
- name: Overview
|
|
99
|
+
href: index.md
|
|
100
|
+
"
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
exports[`yfm init — multi-lang > --no-header removes navigation from all toc.yaml files 4`] = `
|
|
104
|
+
"# Welcome
|
|
105
|
+
|
|
106
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
107
|
+
|
|
108
|
+
## Getting started
|
|
109
|
+
|
|
110
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
111
|
+
"
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
exports[`yfm init — multi-lang > --no-header removes navigation from all toc.yaml files 5`] = `
|
|
115
|
+
"title: My Docs
|
|
116
|
+
href: index.md
|
|
117
|
+
items:
|
|
118
|
+
- name: Overview
|
|
119
|
+
href: index.md
|
|
120
|
+
"
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
exports[`yfm init — multi-lang > creates project structure > filelist 1`] = `
|
|
124
|
+
"[
|
|
125
|
+
".yfm",
|
|
126
|
+
"en/index.md",
|
|
127
|
+
"en/toc.yaml",
|
|
128
|
+
"ru/index.md",
|
|
129
|
+
"ru/toc.yaml"
|
|
130
|
+
]"
|
|
131
|
+
`;
|
|
132
|
+
|
|
133
|
+
exports[`yfm init — multi-lang > creates project structure 1`] = `
|
|
134
|
+
"allowHtml: true
|
|
135
|
+
lang: ru
|
|
136
|
+
langs: ['ru', 'en']"
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
exports[`yfm init — multi-lang > creates project structure 2`] = `
|
|
140
|
+
"# Welcome
|
|
141
|
+
|
|
142
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
143
|
+
|
|
144
|
+
## Getting started
|
|
145
|
+
|
|
146
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
147
|
+
"
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
exports[`yfm init — multi-lang > creates project structure 3`] = `
|
|
151
|
+
"title: My Docs
|
|
152
|
+
href: index.md
|
|
153
|
+
navigation:
|
|
154
|
+
header:
|
|
155
|
+
rightItems:
|
|
156
|
+
- type: controls
|
|
157
|
+
items:
|
|
158
|
+
- name: Overview
|
|
159
|
+
href: index.md
|
|
160
|
+
"
|
|
161
|
+
`;
|
|
162
|
+
|
|
163
|
+
exports[`yfm init — multi-lang > creates project structure 4`] = `
|
|
164
|
+
"# Welcome
|
|
165
|
+
|
|
166
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
167
|
+
|
|
168
|
+
## Getting started
|
|
169
|
+
|
|
170
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
171
|
+
"
|
|
172
|
+
`;
|
|
173
|
+
|
|
174
|
+
exports[`yfm init — multi-lang > creates project structure 5`] = `
|
|
175
|
+
"title: My Docs
|
|
176
|
+
href: index.md
|
|
177
|
+
navigation:
|
|
178
|
+
header:
|
|
179
|
+
rightItems:
|
|
180
|
+
- type: controls
|
|
181
|
+
items:
|
|
182
|
+
- name: Overview
|
|
183
|
+
href: index.md
|
|
184
|
+
"
|
|
185
|
+
`;
|
|
186
|
+
|
|
187
|
+
exports[`yfm init — single-lang > --no-header removes navigation block > filelist 1`] = `
|
|
188
|
+
"[
|
|
189
|
+
".yfm",
|
|
190
|
+
"index.md",
|
|
191
|
+
"toc.yaml"
|
|
192
|
+
]"
|
|
193
|
+
`;
|
|
194
|
+
|
|
195
|
+
exports[`yfm init — single-lang > --no-header removes navigation block 1`] = `"lang: en"`;
|
|
196
|
+
|
|
197
|
+
exports[`yfm init — single-lang > --no-header removes navigation block 2`] = `
|
|
198
|
+
"# Welcome
|
|
199
|
+
|
|
200
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
201
|
+
|
|
202
|
+
## Getting started
|
|
203
|
+
|
|
204
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
205
|
+
"
|
|
206
|
+
`;
|
|
207
|
+
|
|
208
|
+
exports[`yfm init — single-lang > --no-header removes navigation block 3`] = `
|
|
209
|
+
"title: My Docs
|
|
210
|
+
href: index.md
|
|
211
|
+
items:
|
|
212
|
+
- name: Overview
|
|
213
|
+
href: index.md
|
|
214
|
+
"
|
|
215
|
+
`;
|
|
216
|
+
|
|
217
|
+
exports[`yfm init — single-lang > creates project structure > filelist 1`] = `
|
|
218
|
+
"[
|
|
219
|
+
".yfm",
|
|
220
|
+
"index.md",
|
|
221
|
+
"toc.yaml"
|
|
222
|
+
]"
|
|
223
|
+
`;
|
|
224
|
+
|
|
225
|
+
exports[`yfm init — single-lang > creates project structure 1`] = `"lang: en"`;
|
|
226
|
+
|
|
227
|
+
exports[`yfm init — single-lang > creates project structure 2`] = `
|
|
228
|
+
"# Welcome
|
|
229
|
+
|
|
230
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
231
|
+
|
|
232
|
+
## Getting started
|
|
233
|
+
|
|
234
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
235
|
+
"
|
|
236
|
+
`;
|
|
237
|
+
|
|
238
|
+
exports[`yfm init — single-lang > creates project structure 3`] = `
|
|
239
|
+
"title: My Docs
|
|
240
|
+
href: index.md
|
|
241
|
+
navigation:
|
|
242
|
+
header:
|
|
243
|
+
rightItems:
|
|
244
|
+
- type: controls
|
|
245
|
+
items:
|
|
246
|
+
- name: Overview
|
|
247
|
+
href: index.md
|
|
248
|
+
"
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
exports[`yfm init — single-lang > derives project name from output directory basename > filelist 1`] = `
|
|
252
|
+
"[
|
|
253
|
+
".yfm",
|
|
254
|
+
"index.md",
|
|
255
|
+
"toc.yaml"
|
|
256
|
+
]"
|
|
257
|
+
`;
|
|
258
|
+
|
|
259
|
+
exports[`yfm init — single-lang > derives project name from output directory basename 1`] = `"lang: en"`;
|
|
260
|
+
|
|
261
|
+
exports[`yfm init — single-lang > derives project name from output directory basename 2`] = `
|
|
262
|
+
"# Welcome
|
|
263
|
+
|
|
264
|
+
This is your documentation project created with [Diplodoc](https://diplodoc.com).
|
|
265
|
+
|
|
266
|
+
## Getting started
|
|
267
|
+
|
|
268
|
+
Edit this file or add new pages and update \`toc.yaml\`.
|
|
269
|
+
"
|
|
270
|
+
`;
|
|
271
|
+
|
|
272
|
+
exports[`yfm init — single-lang > derives project name from output directory basename 3`] = `
|
|
273
|
+
"title: my-project
|
|
274
|
+
href: index.md
|
|
275
|
+
navigation:
|
|
276
|
+
header:
|
|
277
|
+
rightItems:
|
|
278
|
+
- type: controls
|
|
279
|
+
items:
|
|
280
|
+
- name: Overview
|
|
281
|
+
href: index.md
|
|
282
|
+
"
|
|
283
|
+
`;
|
package/e2e/init.test.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {mkdtemp, rm} from 'node:fs/promises';
|
|
2
|
+
import {tmpdir} from 'node:os';
|
|
3
|
+
import {join} from 'node:path';
|
|
4
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
5
|
+
|
|
6
|
+
import {TestAdapter, compareDirectories} from '../fixtures';
|
|
7
|
+
|
|
8
|
+
function run(args: string[]) {
|
|
9
|
+
return TestAdapter.runner.runYfmDocs(['init', ...args]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let tmpDir: string;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
tmpDir = await mkdtemp(join(tmpdir(), 'yfm-init-'));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(async () => {
|
|
19
|
+
await rm(tmpDir, {recursive: true, force: true});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('yfm init — single-lang', () => {
|
|
23
|
+
it('creates project structure', async () => {
|
|
24
|
+
const out = join(tmpDir, 'proj');
|
|
25
|
+
const report = await run(['--output', out, '--name', 'My Docs', '--skip-interactive']);
|
|
26
|
+
|
|
27
|
+
expect(report.code).toBe(0);
|
|
28
|
+
await compareDirectories(out);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('derives project name from output directory basename', async () => {
|
|
32
|
+
const out = join(tmpDir, 'my-project');
|
|
33
|
+
await run(['--output', out]);
|
|
34
|
+
|
|
35
|
+
await compareDirectories(out);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('--no-header removes navigation block', async () => {
|
|
39
|
+
const out = join(tmpDir, 'proj');
|
|
40
|
+
await run(['--output', out, '--name', 'My Docs', '--no-header', '--skip-interactive']);
|
|
41
|
+
|
|
42
|
+
await compareDirectories(out);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('yfm init — multi-lang', () => {
|
|
47
|
+
it('creates project structure', async () => {
|
|
48
|
+
const out = join(tmpDir, 'proj');
|
|
49
|
+
const report = await run([
|
|
50
|
+
'--output',
|
|
51
|
+
out,
|
|
52
|
+
'--langs',
|
|
53
|
+
'ru,en',
|
|
54
|
+
'--name',
|
|
55
|
+
'My Docs',
|
|
56
|
+
'--skip-interactive',
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
expect(report.code).toBe(0);
|
|
60
|
+
await compareDirectories(out);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('--default-lang sets lang field in .yfm', async () => {
|
|
64
|
+
const out = join(tmpDir, 'proj');
|
|
65
|
+
await run([
|
|
66
|
+
'--output',
|
|
67
|
+
out,
|
|
68
|
+
'--langs',
|
|
69
|
+
'ru,en',
|
|
70
|
+
'--default-lang',
|
|
71
|
+
'en',
|
|
72
|
+
'--name',
|
|
73
|
+
'My Docs',
|
|
74
|
+
'--skip-interactive',
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
await compareDirectories(out);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('--no-header removes navigation from all toc.yaml files', async () => {
|
|
81
|
+
const out = join(tmpDir, 'proj');
|
|
82
|
+
await run([
|
|
83
|
+
'--output',
|
|
84
|
+
out,
|
|
85
|
+
'--langs',
|
|
86
|
+
'ru,en',
|
|
87
|
+
'--no-header',
|
|
88
|
+
'--name',
|
|
89
|
+
'My Docs',
|
|
90
|
+
'--skip-interactive',
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
await compareDirectories(out);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('yfm init — errors', () => {
|
|
98
|
+
it('fails with non-zero exit code if output directory is not empty', async () => {
|
|
99
|
+
const out = join(tmpDir, 'proj');
|
|
100
|
+
await run(['--output', out]);
|
|
101
|
+
|
|
102
|
+
const report = await run(['--output', out]);
|
|
103
|
+
expect(report.code).toBeGreaterThan(0);
|
|
104
|
+
});
|
|
105
|
+
});
|