homey-lib 2.22.1 → 2.22.2
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/lib/App/index.js
CHANGED
|
@@ -298,7 +298,7 @@ class App {
|
|
|
298
298
|
if (!driver.images) {
|
|
299
299
|
throw new Error(`drivers.${driver.id}: property \`images\` is required in order to publish an app.`);
|
|
300
300
|
}
|
|
301
|
-
await this._validateImages(driver.images, 'driver');
|
|
301
|
+
await this._validateImages(driver.images, 'driver', `drivers.${driver.id}`);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
if (levelVerified) {
|
|
@@ -560,7 +560,7 @@ class App {
|
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
562
|
|
|
563
|
-
async _validateImages(imagesObj, type) {
|
|
563
|
+
async _validateImages(imagesObj, type, errorPath) {
|
|
564
564
|
const sizes = ['small', 'large'];
|
|
565
565
|
for (let i = 0; i < sizes.length; i++) {
|
|
566
566
|
const size = sizes[i];
|
|
@@ -568,7 +568,7 @@ class App {
|
|
|
568
568
|
const extension = extname(imagePath);
|
|
569
569
|
|
|
570
570
|
if (typeof IMAGE_MARKERS[extension] === 'undefined') {
|
|
571
|
-
throw new Error(`Invalid image
|
|
571
|
+
throw new Error(`Invalid image extension (${extension})${ errorPath ? ` ${errorPath}.${size}` : ''}: ${join(this._path, imagePath)}`);
|
|
572
572
|
}
|
|
573
573
|
|
|
574
574
|
await this._ensureFileExistsCaseSensitive(imagePath);
|
|
@@ -577,14 +577,14 @@ class App {
|
|
|
577
577
|
const imageBytes = await this._readBytes(imagePath, compareBuffer.length);
|
|
578
578
|
|
|
579
579
|
if (!imageBytes.equals(compareBuffer)) {
|
|
580
|
-
throw new Error(`Invalid image: ${imagePath}`);
|
|
580
|
+
throw new Error(`Invalid image${ errorPath ? ` ${errorPath}.${size}` : ''}: ${join(this._path, imagePath)}`);
|
|
581
581
|
}
|
|
582
582
|
|
|
583
583
|
const requiredSize = IMAGE_SIZES[type][size];
|
|
584
584
|
const imageSize = await imageSizeAsync(join(this._path, imagePath));
|
|
585
585
|
if (imageSize.width !== requiredSize.width
|
|
586
586
|
|| imageSize.height !== requiredSize.height) {
|
|
587
|
-
throw new Error(`Invalid image size (${imageSize.width}x${imageSize.height}): ${imagePath}\nRequired: ${requiredSize.width}x${requiredSize.height}`);
|
|
587
|
+
throw new Error(`Invalid image size (${imageSize.width}x${imageSize.height})${ errorPath ? ` ${errorPath}.${size}` : ''}: ${join(this._path, imagePath)}\nRequired: ${requiredSize.width}x${requiredSize.height}`);
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
590
|
}
|
package/package.json
CHANGED
|
@@ -329,8 +329,8 @@ describe('HomeyLib.App#validate() base manifest', function() {
|
|
|
329
329
|
|
|
330
330
|
await assertValidates(app, {
|
|
331
331
|
debug: true, // debug does not validate images
|
|
332
|
-
publish: /invalid image
|
|
333
|
-
verified: /invalid image
|
|
332
|
+
publish: /invalid image extension/i,
|
|
333
|
+
verified: /invalid image extension/i,
|
|
334
334
|
});
|
|
335
335
|
});
|
|
336
336
|
|
|
@@ -172,8 +172,8 @@ describe('HomeyLib.App#validate() driver manifest', function() {
|
|
|
172
172
|
|
|
173
173
|
await assertValidates(app, {
|
|
174
174
|
debug: true, // debug does not validate images
|
|
175
|
-
publish: /invalid image
|
|
176
|
-
verified: /invalid image
|
|
175
|
+
publish: /invalid image extension/i,
|
|
176
|
+
verified: /invalid image extension/i,
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
|