@diplodoc/cli-tests 5.40.0 → 5.41.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__/build-content-map.spec.ts.snap +329 -0
- package/e2e/build-content-map.spec.ts +220 -0
- package/mocks/build-content-map/autotitle-chain/input/.yfm +0 -0
- package/mocks/build-content-map/autotitle-chain/input/a.md +3 -0
- package/mocks/build-content-map/autotitle-chain/input/b.md +3 -0
- package/mocks/build-content-map/autotitle-chain/input/c.md +3 -0
- package/mocks/build-content-map/autotitle-chain/input/toc.yaml +9 -0
- package/mocks/build-content-map/autotitle-target-with-include/input/.yfm +0 -0
- package/mocks/build-content-map/autotitle-target-with-include/input/_includes/snippet.md +3 -0
- package/mocks/build-content-map/autotitle-target-with-include/input/a.md +3 -0
- package/mocks/build-content-map/autotitle-target-with-include/input/b.md +3 -0
- package/mocks/build-content-map/autotitle-target-with-include/input/toc.yaml +7 -0
- package/mocks/build-content-map/diamond-includes/input/.yfm +0 -0
- package/mocks/build-content-map/diamond-includes/input/_includes/branch-a.md +5 -0
- package/mocks/build-content-map/diamond-includes/input/_includes/branch-b.md +5 -0
- package/mocks/build-content-map/diamond-includes/input/_includes/shared.md +3 -0
- package/mocks/build-content-map/diamond-includes/input/index.md +7 -0
- package/mocks/build-content-map/diamond-includes/input/toc.yaml +5 -0
- package/mocks/build-content-map/nested-includes/input/.yfm +0 -0
- package/mocks/build-content-map/nested-includes/input/_includes/level1.md +5 -0
- package/mocks/build-content-map/nested-includes/input/_includes/level2.md +3 -0
- package/mocks/build-content-map/nested-includes/input/index.md +5 -0
- package/mocks/build-content-map/nested-includes/input/toc.yaml +5 -0
- package/mocks/build-content-map/with-autotitles/input/.yfm +0 -0
- package/mocks/build-content-map/with-autotitles/input/index.md +3 -0
- package/mocks/build-content-map/with-autotitles/input/other.md +3 -0
- package/mocks/build-content-map/with-autotitles/input/toc.yaml +7 -0
- package/mocks/build-content-map/with-includes/input/.yfm +0 -0
- package/mocks/build-content-map/with-includes/input/_includes/snippet.md +1 -0
- package/mocks/build-content-map/with-includes/input/index.md +5 -0
- package/mocks/build-content-map/with-includes/input/logo.svg +1 -0
- package/mocks/build-content-map/with-includes/input/toc.yaml +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Build content map for > autotitle chain (hashIncludes default, mergeIncludes off) 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"contentHashes": {
|
|
6
|
+
".yfm": {
|
|
7
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
8
|
+
"size": 0,
|
|
9
|
+
},
|
|
10
|
+
"a.md": {
|
|
11
|
+
"hash": "sha256-ded797685220c60b5b4e4b625b57593625cd23a2769b740c8c04cfe96e56c207",
|
|
12
|
+
"size": 151,
|
|
13
|
+
},
|
|
14
|
+
"b.md": {
|
|
15
|
+
"hash": "sha256-6c43dbe0f71cd0f9a8c596be5b57e4b0f87acbfa70e064c1851f1e52fa9dc962",
|
|
16
|
+
"size": 155,
|
|
17
|
+
},
|
|
18
|
+
"c.md": {
|
|
19
|
+
"hash": "sha256-dd5586a9c7e73c90600c4af09e51aee7a953f388812c7d1d4cf847aa528fde9c",
|
|
20
|
+
"size": 142,
|
|
21
|
+
},
|
|
22
|
+
"toc.yaml": {
|
|
23
|
+
"hash": "sha256-8bf60b589e4bb972e7b9ca9d924f6f8911f9d41e268bf710f0d5197246b576fd",
|
|
24
|
+
"size": 157,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
"pageAssets": {},
|
|
28
|
+
"schemaVersion": 1,
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
exports[`Build content map for > autotitle chain (mergeIncludes on) 1`] = `
|
|
33
|
+
{
|
|
34
|
+
"contentHashes": {
|
|
35
|
+
".yfm": {
|
|
36
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
37
|
+
"size": 0,
|
|
38
|
+
},
|
|
39
|
+
"a.md": {
|
|
40
|
+
"hash": "sha256-ded797685220c60b5b4e4b625b57593625cd23a2769b740c8c04cfe96e56c207",
|
|
41
|
+
"size": 151,
|
|
42
|
+
},
|
|
43
|
+
"b.md": {
|
|
44
|
+
"hash": "sha256-6c43dbe0f71cd0f9a8c596be5b57e4b0f87acbfa70e064c1851f1e52fa9dc962",
|
|
45
|
+
"size": 155,
|
|
46
|
+
},
|
|
47
|
+
"c.md": {
|
|
48
|
+
"hash": "sha256-dd5586a9c7e73c90600c4af09e51aee7a953f388812c7d1d4cf847aa528fde9c",
|
|
49
|
+
"size": 142,
|
|
50
|
+
},
|
|
51
|
+
"toc.yaml": {
|
|
52
|
+
"hash": "sha256-8bf60b589e4bb972e7b9ca9d924f6f8911f9d41e268bf710f0d5197246b576fd",
|
|
53
|
+
"size": 157,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
"pageAssets": {},
|
|
57
|
+
"schemaVersion": 1,
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
exports[`Build content map for > autotitle target with include (hashIncludes default, mergeIncludes off) 1`] = `
|
|
62
|
+
{
|
|
63
|
+
"contentHashes": {
|
|
64
|
+
".yfm": {
|
|
65
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
66
|
+
"size": 0,
|
|
67
|
+
},
|
|
68
|
+
"_includes/snippet.md": {
|
|
69
|
+
"hash": "sha256-15e5534f3fd87d3799fc5ba720332adc871dc63ac87c27ab1baf6b083d5b5812",
|
|
70
|
+
"size": 57,
|
|
71
|
+
},
|
|
72
|
+
"a.md": {
|
|
73
|
+
"hash": "sha256-a3306e3527c16dd26e0080fd3b6a20a8149bbe200dd27f19a9f8661ba79a2b23",
|
|
74
|
+
"size": 157,
|
|
75
|
+
},
|
|
76
|
+
"b.md": {
|
|
77
|
+
"hash": "sha256-e725d8b1a33dc089e05b34501b611bc56533e48c96d8713ac08f87bc087bb556",
|
|
78
|
+
"size": 166,
|
|
79
|
+
},
|
|
80
|
+
"toc.yaml": {
|
|
81
|
+
"hash": "sha256-f0e5f8342a96da110f1a0c3dc468ce8bf536d9971b7f6268b7afc6327ba2d163",
|
|
82
|
+
"size": 144,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
"pageAssets": {},
|
|
86
|
+
"schemaVersion": 1,
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
|
|
90
|
+
exports[`Build content map for > autotitle target with include (mergeIncludes on) 1`] = `
|
|
91
|
+
{
|
|
92
|
+
"contentHashes": {
|
|
93
|
+
".yfm": {
|
|
94
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
95
|
+
"size": 0,
|
|
96
|
+
},
|
|
97
|
+
"a.md": {
|
|
98
|
+
"hash": "sha256-a3306e3527c16dd26e0080fd3b6a20a8149bbe200dd27f19a9f8661ba79a2b23",
|
|
99
|
+
"size": 157,
|
|
100
|
+
},
|
|
101
|
+
"b.md": {
|
|
102
|
+
"hash": "sha256-a5ad363d0d18d412cd83964d8fe8716f848e6114af59a6b555aecd6595e587f0",
|
|
103
|
+
"size": 243,
|
|
104
|
+
},
|
|
105
|
+
"toc.yaml": {
|
|
106
|
+
"hash": "sha256-f0e5f8342a96da110f1a0c3dc468ce8bf536d9971b7f6268b7afc6327ba2d163",
|
|
107
|
+
"size": 144,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
"pageAssets": {},
|
|
111
|
+
"schemaVersion": 1,
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
exports[`Build content map for > diamond includes (hashIncludes default, mergeIncludes off) 1`] = `
|
|
116
|
+
{
|
|
117
|
+
"contentHashes": {
|
|
118
|
+
".yfm": {
|
|
119
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
120
|
+
"size": 0,
|
|
121
|
+
},
|
|
122
|
+
"_includes/branch-a.md": {
|
|
123
|
+
"hash": "sha256-3314f60ae1fcaaccab27d5075d5a8ad01bb5d139cc37f4240304d83a9ce88ace",
|
|
124
|
+
"size": 101,
|
|
125
|
+
},
|
|
126
|
+
"_includes/branch-b.md": {
|
|
127
|
+
"hash": "sha256-0d5505b5775980c435e7cb35b0452089980640ff5bc0878a45db8b23901099dd",
|
|
128
|
+
"size": 102,
|
|
129
|
+
},
|
|
130
|
+
"_includes/shared.md": {
|
|
131
|
+
"hash": "sha256-42e099cba25de4c74b858b07c83d4feb6565738d4e21ad3e7208f6e35048931d",
|
|
132
|
+
"size": 55,
|
|
133
|
+
},
|
|
134
|
+
"index.md": {
|
|
135
|
+
"hash": "sha256-e784a8386482ca8274a2599533262d0e1a491e13bc0568a6b23ec317f157f9df",
|
|
136
|
+
"size": 276,
|
|
137
|
+
},
|
|
138
|
+
"toc.yaml": {
|
|
139
|
+
"hash": "sha256-5309b6c21d914169deeb265ac1988546c6c0ab47d100b89c4083efb3f711f872",
|
|
140
|
+
"size": 116,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
"pageAssets": {},
|
|
144
|
+
"schemaVersion": 1,
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
exports[`Build content map for > diamond includes (mergeIncludes on) 1`] = `
|
|
149
|
+
{
|
|
150
|
+
"contentHashes": {
|
|
151
|
+
".yfm": {
|
|
152
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
153
|
+
"size": 0,
|
|
154
|
+
},
|
|
155
|
+
"index.md": {
|
|
156
|
+
"hash": "sha256-4a0b4cf64adc48609b3b0448e59bcfca847ca43e96a857673b838b95bfb3b79e",
|
|
157
|
+
"size": 689,
|
|
158
|
+
},
|
|
159
|
+
"toc.yaml": {
|
|
160
|
+
"hash": "sha256-5309b6c21d914169deeb265ac1988546c6c0ab47d100b89c4083efb3f711f872",
|
|
161
|
+
"size": 116,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
"pageAssets": {},
|
|
165
|
+
"schemaVersion": 1,
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
|
|
169
|
+
exports[`Build content map for > nested includes (hashIncludes default, mergeIncludes off) 1`] = `
|
|
170
|
+
{
|
|
171
|
+
"contentHashes": {
|
|
172
|
+
".yfm": {
|
|
173
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
174
|
+
"size": 0,
|
|
175
|
+
},
|
|
176
|
+
"_includes/level1.md": {
|
|
177
|
+
"hash": "sha256-8720c7deb66b06273ae8fb303accf2a399e622b647e222cbb0dc12c74cdb0df7",
|
|
178
|
+
"size": 121,
|
|
179
|
+
},
|
|
180
|
+
"_includes/level2.md": {
|
|
181
|
+
"hash": "sha256-2ce37af4320216777549f95a5e533efb4486802619b4916aae31764ba98f3339",
|
|
182
|
+
"size": 62,
|
|
183
|
+
},
|
|
184
|
+
"index.md": {
|
|
185
|
+
"hash": "sha256-4ec9eb564530dbdb672c762da78022806922a4ef103956e9256c208fa3ebcc7c",
|
|
186
|
+
"size": 231,
|
|
187
|
+
},
|
|
188
|
+
"toc.yaml": {
|
|
189
|
+
"hash": "sha256-8044d42eecbbbfbf108ef785d04d322e72b2381cea30243cf3accc2ccf469f89",
|
|
190
|
+
"size": 115,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
"pageAssets": {},
|
|
194
|
+
"schemaVersion": 1,
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
exports[`Build content map for > nested includes (mergeIncludes on) 1`] = `
|
|
199
|
+
{
|
|
200
|
+
"contentHashes": {
|
|
201
|
+
".yfm": {
|
|
202
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
203
|
+
"size": 0,
|
|
204
|
+
},
|
|
205
|
+
"index.md": {
|
|
206
|
+
"hash": "sha256-82cbe26702322efab28c5788884abd20224d7ab559baac612457d3e61b30f4c1",
|
|
207
|
+
"size": 464,
|
|
208
|
+
},
|
|
209
|
+
"toc.yaml": {
|
|
210
|
+
"hash": "sha256-8044d42eecbbbfbf108ef785d04d322e72b2381cea30243cf3accc2ccf469f89",
|
|
211
|
+
"size": 115,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
"pageAssets": {},
|
|
215
|
+
"schemaVersion": 1,
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
218
|
+
|
|
219
|
+
exports[`Build content map for > project with an include and a picture (mergeIncludes off) 1`] = `
|
|
220
|
+
{
|
|
221
|
+
"contentHashes": {
|
|
222
|
+
".yfm": {
|
|
223
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
224
|
+
"size": 0,
|
|
225
|
+
},
|
|
226
|
+
"_includes/snippet.md": {
|
|
227
|
+
"hash": "sha256-25c382135c889a69ff3a79390f978f030364fc2fcec5e7db6e6e441c57791a61",
|
|
228
|
+
"size": 26,
|
|
229
|
+
},
|
|
230
|
+
"index.md": {
|
|
231
|
+
"hash": "sha256-aea78fb06925f83bf37d1af249c7a556988f2aa32adceaa42befd401de01e037",
|
|
232
|
+
"size": 210,
|
|
233
|
+
},
|
|
234
|
+
"logo.svg": {
|
|
235
|
+
"hash": "sha256-d13530939abcb6584d6b07c97ded2d9fc6d5751ef4c0262afe36cee3fad0d51c",
|
|
236
|
+
"size": 3402,
|
|
237
|
+
},
|
|
238
|
+
"toc.yaml": {
|
|
239
|
+
"hash": "sha256-08e2907230e064c5ce52e5859d5a3780ed84c41756f921f896a88033a40e0ae9",
|
|
240
|
+
"size": 108,
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
"pageAssets": {
|
|
244
|
+
"index.md": [
|
|
245
|
+
"logo.svg",
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
"schemaVersion": 1,
|
|
249
|
+
}
|
|
250
|
+
`;
|
|
251
|
+
|
|
252
|
+
exports[`Build content map for > project with an include and a picture (mergeIncludes on) 1`] = `
|
|
253
|
+
{
|
|
254
|
+
"contentHashes": {
|
|
255
|
+
".yfm": {
|
|
256
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
257
|
+
"size": 0,
|
|
258
|
+
},
|
|
259
|
+
"index.md": {
|
|
260
|
+
"hash": "sha256-7ecfc045bc85006edf4898acb85d62adc33473b7bdd5cdcb9678a46066b547dc",
|
|
261
|
+
"size": 256,
|
|
262
|
+
},
|
|
263
|
+
"logo.svg": {
|
|
264
|
+
"hash": "sha256-d13530939abcb6584d6b07c97ded2d9fc6d5751ef4c0262afe36cee3fad0d51c",
|
|
265
|
+
"size": 3402,
|
|
266
|
+
},
|
|
267
|
+
"toc.yaml": {
|
|
268
|
+
"hash": "sha256-08e2907230e064c5ce52e5859d5a3780ed84c41756f921f896a88033a40e0ae9",
|
|
269
|
+
"size": 108,
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
"pageAssets": {
|
|
273
|
+
"index.md": [
|
|
274
|
+
"logo.svg",
|
|
275
|
+
],
|
|
276
|
+
},
|
|
277
|
+
"schemaVersion": 1,
|
|
278
|
+
}
|
|
279
|
+
`;
|
|
280
|
+
|
|
281
|
+
exports[`Build content map for > project with autotitle links between pages (mergeIncludes off) 1`] = `
|
|
282
|
+
{
|
|
283
|
+
"contentHashes": {
|
|
284
|
+
".yfm": {
|
|
285
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
286
|
+
"size": 0,
|
|
287
|
+
},
|
|
288
|
+
"index.md": {
|
|
289
|
+
"hash": "sha256-7b81e86e1bcce905ef6d2cbf5af9421f1e3e6cd7a4f477e371498b30c07a859d",
|
|
290
|
+
"size": 152,
|
|
291
|
+
},
|
|
292
|
+
"other.md": {
|
|
293
|
+
"hash": "sha256-4807c9359ddc98c38441d32aaabeaa22218027ef69bc1d6118c4c006c8c25b36",
|
|
294
|
+
"size": 130,
|
|
295
|
+
},
|
|
296
|
+
"toc.yaml": {
|
|
297
|
+
"hash": "sha256-1455d101a04ae60d37e5ace467d36e4c650e481d90f22ce46cd7b637c33cf541",
|
|
298
|
+
"size": 145,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
"pageAssets": {},
|
|
302
|
+
"schemaVersion": 1,
|
|
303
|
+
}
|
|
304
|
+
`;
|
|
305
|
+
|
|
306
|
+
exports[`Build content map for > project with autotitle links between pages (mergeIncludes on) 1`] = `
|
|
307
|
+
{
|
|
308
|
+
"contentHashes": {
|
|
309
|
+
".yfm": {
|
|
310
|
+
"hash": "sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
311
|
+
"size": 0,
|
|
312
|
+
},
|
|
313
|
+
"index.md": {
|
|
314
|
+
"hash": "sha256-7b81e86e1bcce905ef6d2cbf5af9421f1e3e6cd7a4f477e371498b30c07a859d",
|
|
315
|
+
"size": 152,
|
|
316
|
+
},
|
|
317
|
+
"other.md": {
|
|
318
|
+
"hash": "sha256-4807c9359ddc98c38441d32aaabeaa22218027ef69bc1d6118c4c006c8c25b36",
|
|
319
|
+
"size": 130,
|
|
320
|
+
},
|
|
321
|
+
"toc.yaml": {
|
|
322
|
+
"hash": "sha256-1455d101a04ae60d37e5ace467d36e4c650e481d90f22ce46cd7b637c33cf541",
|
|
323
|
+
"size": 145,
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
"pageAssets": {},
|
|
327
|
+
"schemaVersion": 1,
|
|
328
|
+
}
|
|
329
|
+
`;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import {describe, expect, test} from 'vitest';
|
|
2
|
+
import {cp, mkdtemp, readFile, realpath, writeFile} from 'node:fs/promises';
|
|
3
|
+
import {tmpdir} from 'node:os';
|
|
4
|
+
import {join} from 'node:path';
|
|
5
|
+
|
|
6
|
+
import {TestAdapter, getTestPaths} from '../fixtures';
|
|
7
|
+
|
|
8
|
+
const buildContentTestTemplate = (testTitle: string, testRootPath: string, extraArgs = '') => {
|
|
9
|
+
test(testTitle, async () => {
|
|
10
|
+
const {inputPath, outputPath} = getTestPaths(testRootPath);
|
|
11
|
+
|
|
12
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
13
|
+
md2md: true,
|
|
14
|
+
md2html: false,
|
|
15
|
+
args: `--build-content ${extraArgs}`.trim(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const contentMap = await readFile(join(outputPath, 'yfm-build-content.json'), 'utf-8');
|
|
19
|
+
|
|
20
|
+
expect(JSON.parse(contentMap)).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe('Build content map for', () => {
|
|
25
|
+
buildContentTestTemplate(
|
|
26
|
+
'project with an include and a picture (mergeIncludes off)',
|
|
27
|
+
'mocks/build-content-map/with-includes',
|
|
28
|
+
'--no-merge-includes',
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
buildContentTestTemplate(
|
|
32
|
+
'project with an include and a picture (mergeIncludes on)',
|
|
33
|
+
'mocks/build-content-map/with-includes',
|
|
34
|
+
'--merge-includes',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
buildContentTestTemplate(
|
|
38
|
+
'project with autotitle links between pages (mergeIncludes off)',
|
|
39
|
+
'mocks/build-content-map/with-autotitles',
|
|
40
|
+
'--no-merge-includes',
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
buildContentTestTemplate(
|
|
44
|
+
'project with autotitle links between pages (mergeIncludes on)',
|
|
45
|
+
'mocks/build-content-map/with-autotitles',
|
|
46
|
+
'--merge-includes',
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
buildContentTestTemplate(
|
|
50
|
+
'nested includes (hashIncludes default, mergeIncludes off)',
|
|
51
|
+
'mocks/build-content-map/nested-includes',
|
|
52
|
+
'--no-merge-includes',
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
buildContentTestTemplate(
|
|
56
|
+
'nested includes (mergeIncludes on)',
|
|
57
|
+
'mocks/build-content-map/nested-includes',
|
|
58
|
+
'--merge-includes',
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
buildContentTestTemplate(
|
|
62
|
+
'diamond includes (hashIncludes default, mergeIncludes off)',
|
|
63
|
+
'mocks/build-content-map/diamond-includes',
|
|
64
|
+
'--no-merge-includes',
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
buildContentTestTemplate(
|
|
68
|
+
'diamond includes (mergeIncludes on)',
|
|
69
|
+
'mocks/build-content-map/diamond-includes',
|
|
70
|
+
'--merge-includes',
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
buildContentTestTemplate(
|
|
74
|
+
'autotitle chain (hashIncludes default, mergeIncludes off)',
|
|
75
|
+
'mocks/build-content-map/autotitle-chain',
|
|
76
|
+
'--no-merge-includes',
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
buildContentTestTemplate(
|
|
80
|
+
'autotitle chain (mergeIncludes on)',
|
|
81
|
+
'mocks/build-content-map/autotitle-chain',
|
|
82
|
+
'--merge-includes',
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
buildContentTestTemplate(
|
|
86
|
+
'autotitle target with include (hashIncludes default, mergeIncludes off)',
|
|
87
|
+
'mocks/build-content-map/autotitle-target-with-include',
|
|
88
|
+
'--no-merge-includes',
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
buildContentTestTemplate(
|
|
92
|
+
'autotitle target with include (mergeIncludes on)',
|
|
93
|
+
'mocks/build-content-map/autotitle-target-with-include',
|
|
94
|
+
'--merge-includes',
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('Build content map propagation', () => {
|
|
99
|
+
test('mutating an include propagates to parent hashes (mergeIncludes: false, hashIncludes: true)', async () => {
|
|
100
|
+
const fixtureRoot = getTestPaths('mocks/build-content-map/nested-includes').inputPath;
|
|
101
|
+
// realpath() canonicalizes macOS /var → /private/var symlink so the
|
|
102
|
+
// build's scope checks (which compare against fs.realpath() results)
|
|
103
|
+
// line up with the configured input/output paths.
|
|
104
|
+
const work = await realpath(
|
|
105
|
+
await mkdtemp(join(tmpdir(), 'yfm-build-content-propagation-')),
|
|
106
|
+
);
|
|
107
|
+
const inputBefore = join(work, 'input-before');
|
|
108
|
+
const inputAfter = join(work, 'input-after');
|
|
109
|
+
const before = join(work, 'before');
|
|
110
|
+
const after = join(work, 'after');
|
|
111
|
+
|
|
112
|
+
await cp(fixtureRoot, inputBefore, {recursive: true});
|
|
113
|
+
await cp(fixtureRoot, inputAfter, {recursive: true});
|
|
114
|
+
|
|
115
|
+
await writeFile(
|
|
116
|
+
join(inputAfter, '_includes/level2.md'),
|
|
117
|
+
'# Level 2 mutated\n\nNew body for the deepest include.\n',
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
await TestAdapter.testBuildPass(inputBefore, before, {
|
|
121
|
+
md2md: true,
|
|
122
|
+
md2html: false,
|
|
123
|
+
args: '--build-content --no-merge-includes',
|
|
124
|
+
});
|
|
125
|
+
await TestAdapter.testBuildPass(inputAfter, after, {
|
|
126
|
+
md2md: true,
|
|
127
|
+
md2html: false,
|
|
128
|
+
args: '--build-content --no-merge-includes',
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const beforeManifest = JSON.parse(
|
|
132
|
+
await readFile(join(before, 'yfm-build-content.json'), 'utf-8'),
|
|
133
|
+
);
|
|
134
|
+
const afterManifest = JSON.parse(
|
|
135
|
+
await readFile(join(after, 'yfm-build-content.json'), 'utf-8'),
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// level2.md changed → its hash differs
|
|
139
|
+
expect(beforeManifest.contentHashes['_includes/level2.md'].hash).not.toBe(
|
|
140
|
+
afterManifest.contentHashes['_includes/level2.md'].hash,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// level1.md transitively references level2 via signlink → name change
|
|
144
|
+
// propagates into level1.md's body → its hash differs.
|
|
145
|
+
expect(beforeManifest.contentHashes['_includes/level1.md'].hash).not.toBe(
|
|
146
|
+
afterManifest.contentHashes['_includes/level1.md'].hash,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
// index.md references level1 via signlink → name change cascades → its
|
|
150
|
+
// hash differs.
|
|
151
|
+
expect(beforeManifest.contentHashes['index.md'].hash).not.toBe(
|
|
152
|
+
afterManifest.contentHashes['index.md'].hash,
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// toc.yaml and .yfm are untouched → identical
|
|
156
|
+
expect(beforeManifest.contentHashes['toc.yaml']?.hash).toBe(
|
|
157
|
+
afterManifest.contentHashes['toc.yaml']?.hash,
|
|
158
|
+
);
|
|
159
|
+
expect(beforeManifest.contentHashes['.yfm']?.hash).toBe(
|
|
160
|
+
afterManifest.contentHashes['.yfm']?.hash,
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('mutating an include propagates to parent hashes (mergeIncludes: true)', async () => {
|
|
165
|
+
const fixtureRoot = getTestPaths('mocks/build-content-map/nested-includes').inputPath;
|
|
166
|
+
const work = await realpath(
|
|
167
|
+
await mkdtemp(join(tmpdir(), 'yfm-build-content-propagation-merge-')),
|
|
168
|
+
);
|
|
169
|
+
const inputBefore = join(work, 'input-before');
|
|
170
|
+
const inputAfter = join(work, 'input-after');
|
|
171
|
+
const before = join(work, 'before');
|
|
172
|
+
const after = join(work, 'after');
|
|
173
|
+
|
|
174
|
+
await cp(fixtureRoot, inputBefore, {recursive: true});
|
|
175
|
+
await cp(fixtureRoot, inputAfter, {recursive: true});
|
|
176
|
+
|
|
177
|
+
await writeFile(
|
|
178
|
+
join(inputAfter, '_includes/level2.md'),
|
|
179
|
+
'# Level 2 mutated\n\nNew body for the deepest include.\n',
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
await TestAdapter.testBuildPass(inputBefore, before, {
|
|
183
|
+
md2md: true,
|
|
184
|
+
md2html: false,
|
|
185
|
+
args: '--build-content --merge-includes',
|
|
186
|
+
});
|
|
187
|
+
await TestAdapter.testBuildPass(inputAfter, after, {
|
|
188
|
+
md2md: true,
|
|
189
|
+
md2html: false,
|
|
190
|
+
args: '--build-content --merge-includes',
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const beforeManifest = JSON.parse(
|
|
194
|
+
await readFile(join(before, 'yfm-build-content.json'), 'utf-8'),
|
|
195
|
+
);
|
|
196
|
+
const afterManifest = JSON.parse(
|
|
197
|
+
await readFile(join(after, 'yfm-build-content.json'), 'utf-8'),
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
// With merge: level2.md and level1.md don't exist in output anymore,
|
|
201
|
+
// their content is inlined into index.md.
|
|
202
|
+
expect(beforeManifest.contentHashes['_includes/level2.md']).toBeUndefined();
|
|
203
|
+
expect(afterManifest.contentHashes['_includes/level2.md']).toBeUndefined();
|
|
204
|
+
expect(beforeManifest.contentHashes['_includes/level1.md']).toBeUndefined();
|
|
205
|
+
expect(afterManifest.contentHashes['_includes/level1.md']).toBeUndefined();
|
|
206
|
+
|
|
207
|
+
// index.md hash differs because the inlined level2 content changed.
|
|
208
|
+
expect(beforeManifest.contentHashes['index.md'].hash).not.toBe(
|
|
209
|
+
afterManifest.contentHashes['index.md'].hash,
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
// toc.yaml and .yfm unchanged.
|
|
213
|
+
expect(beforeManifest.contentHashes['toc.yaml']?.hash).toBe(
|
|
214
|
+
afterManifest.contentHashes['toc.yaml']?.hash,
|
|
215
|
+
);
|
|
216
|
+
expect(beforeManifest.contentHashes['.yfm']?.hash).toBe(
|
|
217
|
+
afterManifest.contentHashes['.yfm']?.hash,
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Reusable snippet content.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="158" height="32" fill="none"><path fill="#1D4634" fill-rule="evenodd" d="M42.03 25.795h7.225q3.25 0 5.56-1.258a8.5 8.5 0 0 0 3.55-3.61q1.24-2.352 1.24-5.624 0-3.263-1.229-5.604-1.228-2.342-3.519-3.59-2.28-1.257-5.456-1.257H42.03zm7.038-3.283h-3.176V8.134h3.29q2.166 0 3.624.798 1.468.787 2.218 2.383.75 1.584.75 3.988t-.75 4.008q-.75 1.596-2.239 2.403-1.49.798-3.717.798m12.868-12.425v15.708h3.769V10.087zm6.472 21.598V10.087h3.707v2.598h.219q.291-.573.822-1.217.531-.655 1.437-1.115.906-.47 2.311-.47 1.854 0 3.343.93 1.499.921 2.374 2.73.885 1.8.885 4.419 0 2.586-.865 4.397-.864 1.81-2.353 2.76-1.489.952-3.373.952-1.375 0-2.28-.45-.906-.45-1.458-1.084a7 7 0 0 1-.844-1.217h-.156v8.365zm3.696-13.744q0 1.524.438 2.669.447 1.145 1.28 1.79.844.633 2.041.634 1.249 0 2.093-.655.844-.664 1.27-1.81.438-1.155.438-2.628 0-1.462-.427-2.597t-1.27-1.78-2.104-.644q-1.208 0-2.051.624t-1.28 1.748q-.428 1.125-.428 2.649m17.226 7.854V4.852h-3.77v20.943zm9.68.306q-2.344 0-4.062-1.012-1.717-1.013-2.665-2.833-.937-1.82-.937-4.254t.937-4.264q.948-1.83 2.665-2.843 1.72-1.012 4.061-1.012 2.343 0 4.061 1.012t2.655 2.843q.948 1.83.947 4.264 0 2.434-.947 4.254-.937 1.82-2.655 2.833-1.719 1.012-4.06 1.012m.02-2.965q1.27 0 2.124-.685.854-.696 1.27-1.861.427-1.166.427-2.598 0-1.441-.427-2.608-.416-1.176-1.27-1.87-.853-.696-2.124-.696-1.302 0-2.166.695-.854.696-1.28 1.871-.417 1.167-.417 2.608 0 1.432.416 2.598.427 1.165 1.281 1.86.864.686 2.166.686m12.23 1.984q1.489.95 3.374.95 1.374 0 2.28-.45t1.458-1.083a6.3 6.3 0 0 0 .843-1.217h.229v2.475h3.707V4.852h-3.78v7.833h-.156a6.8 6.8 0 0 0-.823-1.217q-.531-.655-1.436-1.115-.906-.47-2.312-.47-1.844 0-3.342.93-1.5.921-2.385 2.73-.874 1.8-.874 4.419 0 2.586.864 4.397.864 1.81 2.353 2.76m6.466-2.72q-.843.633-2.041.634-1.239 0-2.093-.655-.843-.664-1.28-1.81-.427-1.155-.427-2.628 0-1.462.427-2.597t1.27-1.78 2.103-.644q1.218 0 2.051.624.844.624 1.271 1.748.437 1.125.437 2.649t-.437 2.669q-.438 1.145-1.281 1.79m15.245 3.701q-2.343 0-4.061-1.012-1.719-1.013-2.666-2.833-.936-1.82-.937-4.254 0-2.433.937-4.264.948-1.83 2.666-2.843t4.061-1.012q2.342 0 4.06 1.012 1.719 1.013 2.655 2.843.948 1.83.948 4.264t-.948 4.254q-.936 1.82-2.655 2.833-1.718 1.012-4.06 1.012m.02-2.965q1.27 0 2.124-.685.854-.696 1.271-1.861.427-1.166.427-2.598 0-1.441-.427-2.608-.417-1.176-1.271-1.87-.853-.696-2.124-.696-1.3 0-2.165.695-.854.696-1.281 1.871-.417 1.167-.417 2.608 0 1.432.417 2.598.427 1.165 1.281 1.86.864.686 2.165.686m12.533 1.933q1.718 1.032 4.112 1.032 2.01 0 3.499-.715 1.488-.726 2.353-2.005.864-1.288.999-2.955h-3.602q-.167.848-.614 1.442-.448.593-1.115.91-.656.307-1.488.307-1.178 0-2.052-.614-.864-.623-1.343-1.769-.479-1.155-.479-2.761 0-1.585.479-2.72.49-1.135 1.364-1.739.874-.613 2.031-.613 1.363 0 2.176.767a3.37 3.37 0 0 1 1.041 1.892h3.602q-.124-1.698-1.02-2.966-.896-1.278-2.405-1.974-1.5-.705-3.447-.705-2.342 0-4.06 1.033-1.708 1.022-2.645 2.863-.937 1.83-.937 4.223 0 2.383.916 4.214a6.94 6.94 0 0 0 2.635 2.853M61.912 4.856V7.63h3.797V4.856z" clip-rule="evenodd"/><path fill="#63D490" fill-rule="evenodd" d="M17.61 0h-7.157a.94.94 0 0 0-.941.942v5.717H.942A.94.94 0 0 0 0 7.6v23.457c0 .52.422.942.942.942h19.116c.52 0 .941-.422.941-.942v-5.624h8.57c.52 0 .942-.422.942-.942V12.9C30.51 5.776 24.735 0 17.61 0M21 25.434V7.6a.94.94 0 0 0-.942-.942H9.512v17.833c0 .52.421.942.941.942z" clip-rule="evenodd"/></svg>
|