@squiz/dxp-cli-next 5.33.0-develop.2 → 5.33.0-develop.3
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.
|
@@ -82,7 +82,7 @@ function loadLayoutFromFile(layoutFile) {
|
|
|
82
82
|
encoding: 'utf-8',
|
|
83
83
|
});
|
|
84
84
|
try {
|
|
85
|
-
const layout = (0, yaml_1.parse)(content);
|
|
85
|
+
const layout = fileType === 'json' ? JSON.parse(content) : (0, yaml_1.parse)(content);
|
|
86
86
|
const fileName = path.basename(layoutFile);
|
|
87
87
|
if (fileName === exports.LAYOUT_MANIFEST_FILE) {
|
|
88
88
|
exports.InputLayoutDefinitionV2.parse(layout);
|
|
@@ -198,14 +198,25 @@ entry: template.hbs
|
|
|
198
198
|
}
|
|
199
199
|
throw new Error('File not found');
|
|
200
200
|
});
|
|
201
|
-
yield expect((0, definitions_1.loadLayoutDefinition)(manifestJson)).rejects
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
201
|
+
yield expect((0, definitions_1.loadLayoutDefinition)(manifestJson)).rejects.toThrowErrorMatchingInlineSnapshot('"Failed loading layout definition: Failed to parse ./some-dir/manifest.json: Expected property name or \'}\' in JSON at position 1 (line 1 column 2)"');
|
|
202
|
+
}));
|
|
203
|
+
it('should throw an error if JSON layout file uses single quotes instead of double quotes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
204
|
+
fs.readFile.mockImplementation((filePath) => {
|
|
205
|
+
if (filePath.endsWith('manifest.json')) {
|
|
206
|
+
// Single quotes are not valid JSON - only double quotes are allowed for string values
|
|
207
|
+
return `{
|
|
208
|
+
"name": 'test-layout',
|
|
209
|
+
"displayName": "Test Layout",
|
|
210
|
+
"entry": "template.hbs",
|
|
211
|
+
"zones": []
|
|
212
|
+
}`;
|
|
213
|
+
}
|
|
214
|
+
if (filePath.endsWith('template.hbs')) {
|
|
215
|
+
return templateContent;
|
|
216
|
+
}
|
|
217
|
+
throw new Error('File not found');
|
|
218
|
+
});
|
|
219
|
+
yield expect((0, definitions_1.loadLayoutDefinition)(manifestJson)).rejects.toThrowErrorMatchingInlineSnapshot('"Failed loading layout definition: Failed to parse ./some-dir/manifest.json: Unexpected token \'\'\', ..." "name": \'test-layo"... is not valid JSON"');
|
|
209
220
|
}));
|
|
210
221
|
it('should throw an error if layout file do not have valid extension', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
211
222
|
yield expect((0, definitions_1.loadLayoutDefinition)('/foo/manifest.html')).rejects.toThrow('Layout file must have a valid extension: [yaml|json]');
|